[FFmpeg-devel] [PATCH] avformat/dashenc: Fix a bug with writing "final" manifest

2019-04-16 Thread Karthick J via ffmpeg-devel
This bug was introduced in the commit 951561b64ee6c11f01daedd9dcf73276cc1e765b
---
 libavformat/dashenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5f1333e436..b88d4b3496 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1631,7 +1631,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 }
 }
 if (ret >= 0) {
-if (c->has_video) {
+if (c->has_video && !final) {
 c->nr_of_streams_flushed++;
 if (c->nr_of_streams_flushed != c->nr_of_streams_to_flush)
 return ret;
-- 
2.20.1 (Apple Git-117)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH V2] lavf: bump version/add APIchanges entry when cleanup applehttp

2019-04-16 Thread Jun Zhao
From: Jun Zhao 

commit abfeba9 "lavf/hls: Cleanup the applehttp" missed
the version bump and APIchanges entry.

Signed-off-by: Jun Zhao 
---
 doc/APIchanges|3 +++
 libavformat/version.h |2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 784a5e5..7ed433f 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2019-04-12 - abfeba9724 - lavf 58.27.102
+  Rename hls,applehttp demuxer to hls
+
 2019-01-27 - XX - lavc 58.46.100 - avcodec.h
   Add discard_damaged_percentage
 
diff --git a/libavformat/version.h b/libavformat/version.h
index d57c151..150a72e 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
 #define LIBAVFORMAT_VERSION_MINOR  27
-#define LIBAVFORMAT_VERSION_MICRO 102
+#define LIBAVFORMAT_VERSION_MICRO 103
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
-- 
1.7.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH V2] *** SUBJECT HERE ***

2019-04-16 Thread Jun Zhao
V2: -Fix logic error and use av_strncasecmp, Tks Michael's comments

Jun Zhao (1):
  lavf/oggparsevorbis: Fix change the case of metadata keys issue

 libavformat/oggparsevorbis.c |9 -
 tests/ref/fate/limited_input_seek|2 +-
 tests/ref/fate/limited_input_seek-copyts |2 +-
 3 files changed, 6 insertions(+), 7 deletions(-)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH V2] lavf/oggparsevorbis: Fix change the case of metadata keys issue

2019-04-16 Thread Jun Zhao
From: Jun Zhao 

The spec in https://xiph.org/vorbis/doc/v-comment.html states that
the metadata keys are case-insensitive, so don't change the case
and update the fate test case.

Fix #7784

Signed-off-by: Jun Zhao 
---
 libavformat/oggparsevorbis.c |9 -
 tests/ref/fate/limited_input_seek|2 +-
 tests/ref/fate/limited_input_seek-copyts |2 +-
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index bcfd246..43f05f9 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -44,7 +44,7 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, 
uint8_t *val)
 int i, cnum, h, m, s, ms, keylen = strlen(key);
 AVChapter *chapter = NULL;
 
-if (keylen < 9 || sscanf(key, "CHAPTER%03d", &cnum) != 1)
+if (keylen < 9 || av_strncasecmp(key, "CHAPTER", 7) || sscanf(key+7, 
"%03d", &cnum) != 1)
 return 0;
 
 if (keylen <= 10) {
@@ -55,7 +55,7 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, 
uint8_t *val)
ms + 1000 * (s + 60 * (m + 60 * h)),
AV_NOPTS_VALUE, NULL);
 av_free(val);
-} else if (!strcmp(key + keylen - 4, "NAME")) {
+} else if (!av_strcasecmp(key + keylen - 4, "NAME")) {
 for (i = 0; i < as->nb_chapters; i++)
 if (as->chapters[i]->id == cnum) {
 chapter = as->chapters[i];
@@ -91,7 +91,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
 const uint8_t *p   = buf;
 const uint8_t *end = buf + size;
 int updates= 0;
-unsigned n, j;
+unsigned n;
 int s;
 
 /* must have vendor_length and user_comment_list_length */
@@ -139,8 +139,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
 return AVERROR(ENOMEM);
 }
 
-for (j = 0; j < tl; j++)
-tt[j] = av_toupper(t[j]);
+memcpy(tt, t, tl);
 tt[tl] = 0;
 
 memcpy(ct, v, vl);
diff --git a/tests/ref/fate/limited_input_seek 
b/tests/ref/fate/limited_input_seek
index e0c4bf1..3269dce 100644
--- a/tests/ref/fate/limited_input_seek
+++ b/tests/ref/fate/limited_input_seek
@@ -1 +1 @@
-20a1bb9a1cfb23c1fe86f14e6065cd95
+ae878bdaec23f36a63d142165fe57f49
diff --git a/tests/ref/fate/limited_input_seek-copyts 
b/tests/ref/fate/limited_input_seek-copyts
index 92790a8..6eeaef8 100644
--- a/tests/ref/fate/limited_input_seek-copyts
+++ b/tests/ref/fate/limited_input_seek-copyts
@@ -1 +1 @@
-ec3604b1954ed80de364b8ef491771ce
+ffe8a674bdf38e4f650f91963debc654
-- 
1.7.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avutil/colorspace: add macros for RGB->YUV BT.709

2019-04-16 Thread Gyan



On 13-04-2019 05:23 PM, Gyan wrote:
Will be helpful for correct result in filters that paint like 
fillborders/drawbox or those using drawutils.


Ping.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/3] avcodec/cbs_h2645: use the fixed() macro for forbidden_zero_bit

2019-04-16 Thread James Almer
This follows the spec definition, and removes a field from the relevant
structs.

Signed-off-by: James Almer 
---
 libavcodec/cbs_h264.h | 1 -
 libavcodec/cbs_h264_syntax_template.c | 2 +-
 libavcodec/cbs_h265.h | 1 -
 libavcodec/cbs_h265_syntax_template.c | 2 +-
 4 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
index b5eee7c370..cc46eeb3b0 100644
--- a/libavcodec/cbs_h264.h
+++ b/libavcodec/cbs_h264.h
@@ -38,7 +38,6 @@ enum {
 
 
 typedef struct H264RawNALUnitHeader {
-uint8_t forbidden_zero_bit;
 uint8_t nal_ref_idc;
 uint8_t nal_unit_type;
 
diff --git a/libavcodec/cbs_h264_syntax_template.c 
b/libavcodec/cbs_h264_syntax_template.c
index cc9bd07590..95fc6d7194 100644
--- a/libavcodec/cbs_h264_syntax_template.c
+++ b/libavcodec/cbs_h264_syntax_template.c
@@ -33,7 +33,7 @@ static int FUNC(nal_unit_header)(CodedBitstreamContext *ctx, 
RWContext *rw,
 {
 int err;
 
-u(1, forbidden_zero_bit, 0, 0);
+fixed(1, forbidden_zero_bit, 0);
 ub(2, nal_ref_idc);
 ub(5, nal_unit_type);
 
diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
index 0c0e4f84b0..c9bc90187b 100644
--- a/libavcodec/cbs_h265.h
+++ b/libavcodec/cbs_h265.h
@@ -35,7 +35,6 @@ enum {
 };
 
 typedef struct H265RawNALUnitHeader {
-uint8_t forbidden_zero_bit;
 uint8_t nal_unit_type;
 uint8_t nuh_layer_id;
 uint8_t nuh_temporal_id_plus1;
diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index 87d1332f48..9000bbc307 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -33,7 +33,7 @@ static int FUNC(nal_unit_header)(CodedBitstreamContext *ctx, 
RWContext *rw,
 {
 int err;
 
-u(1, forbidden_zero_bit, 0, 0);
+fixed(1, forbidden_zero_bit, 0);
 
 if (expected_nal_unit_type >= 0)
 u(6, nal_unit_type, expected_nal_unit_type,
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/3] avcodec/cbs_h2645: rename macros to read and write fields with custom range of values

2019-04-16 Thread James Almer
These are more in line with the new ones introduced in the previous commit.

Signed-off-by: James Almer 
---
No more i() macro :p

Figured I'd leave all the byte and checksum fields using the custom range
macro, to have the explicit hex values visible. That's why they were not
changed in the first patch.

 libavcodec/cbs_h2645.c|   8 +-
 libavcodec/cbs_h264_syntax_template.c |  52 ++---
 libavcodec/cbs_h265_syntax_template.c | 106 +-
 3 files changed, 83 insertions(+), 83 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 319202fc48..5623fa705e 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -250,21 +250,21 @@ static int cbs_write_se_golomb(CodedBitstreamContext 
*ctx, PutBitContext *pbc,
 
 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ 
}) : NULL)
 
-#define u(width, name, range_min, range_max) \
+#define uc(width, name, range_min, range_max) \
 xu(width, name, current->name, range_min, range_max, 0)
 #define ub(width, name) \
 xu(width, name, current->name, 0, MAX_UINT_BITS(width), 0)
 #define flag(name) ub(1, name)
 #define ue(name, range_min, range_max) \
 xue(name, current->name, range_min, range_max, 0)
-#define i(width, name, range_min, range_max) \
+#define ic(width, name, range_min, range_max) \
 xi(width, name, current->name, range_min, range_max, 0)
 #define ib(width, name) \
 xi(width, name, current->name, MIN_INT_BITS(width), 
MAX_INT_BITS(width), 0)
 #define se(name, range_min, range_max) \
 xse(name, current->name, range_min, range_max, 0)
 
-#define us(width, name, range_min, range_max, subs, ...) \
+#define ucs(width, name, range_min, range_max, subs, ...) \
 xu(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
 #define ubs(width, name, subs, ...) \
 xu(width, name, current->name, 0, MAX_UINT_BITS(width), subs, 
__VA_ARGS__)
@@ -272,7 +272,7 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, 
PutBitContext *pbc,
 xu(1, name, current->name, 0, 1, subs, __VA_ARGS__)
 #define ues(name, range_min, range_max, subs, ...) \
 xue(name, current->name, range_min, range_max, subs, __VA_ARGS__)
-#define is(width, name, range_min, range_max, subs, ...) \
+#define ics(width, name, range_min, range_max, subs, ...) \
 xi(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
 #define ibs(width, name, subs, ...) \
 xi(width, name, current->name, MIN_INT_BITS(width), 
MAX_INT_BITS(width), subs, __VA_ARGS__)
diff --git a/libavcodec/cbs_h264_syntax_template.c 
b/libavcodec/cbs_h264_syntax_template.c
index 95fc6d7194..898e426cff 100644
--- a/libavcodec/cbs_h264_syntax_template.c
+++ b/libavcodec/cbs_h264_syntax_template.c
@@ -157,8 +157,8 @@ static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, 
RWContext *rw,
 
 flag(timing_info_present_flag);
 if (current->timing_info_present_flag) {
-u(32, num_units_in_tick, 1, UINT32_MAX);
-u(32, time_scale,1, UINT32_MAX);
+uc(32, num_units_in_tick, 1, UINT32_MAX);
+uc(32, time_scale,1, UINT32_MAX);
 flag(fixed_frame_rate_flag);
 } else {
 infer(fixed_frame_rate_flag, 0);
@@ -272,7 +272,7 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext 
*rw,
 flag(constraint_set4_flag);
 flag(constraint_set5_flag);
 
-u(2, reserved_zero_2bits,  0, 0);
+uc(2, reserved_zero_2bits,  0, 0);
 
 ub(8, level_idc);
 
@@ -453,7 +453,7 @@ static int FUNC(pps)(CodedBitstreamContext *ctx, RWContext 
*rw,
 allocate(current->slice_group_id,
  current->pic_size_in_map_units_minus1 + 1);
 for (i = 0; i <= current->pic_size_in_map_units_minus1; i++)
-us(av_log2(2 * current->num_slice_groups_minus1 + 1),
+ucs(av_log2(2 * current->num_slice_groups_minus1 + 1),
slice_group_id[i], 0, current->num_slice_groups_minus1, 1, 
i);
 }
 }
@@ -462,7 +462,7 @@ static int FUNC(pps)(CodedBitstreamContext *ctx, RWContext 
*rw,
 ue(num_ref_idx_l1_default_active_minus1, 0, 31);
 
 flag(weighted_pred_flag);
-u(2, weighted_bipred_idc, 0, 2);
+uc(2, weighted_bipred_idc, 0, 2);
 
 se(pic_init_qp_minus26, -26 - 6 * sps->bit_depth_luma_minus8, +25);
 se(pic_init_qs_minus26, -26, +25);
@@ -559,27 +559,27 @@ static int FUNC(sei_pic_timestamp)(CodedBitstreamContext 
*ctx, RWContext *rw,
 uint8_t time_offset_length;
 int err;
 
-u(2, ct_type, 0, 2);
+uc(2, ct_type, 0, 2);
 flag(nuit_field_based_flag);
-u(5, counting_type, 0, 6);
+uc(5, counting_type, 0, 6);
 flag(full_timestamp_flag);
 flag(discontinuity_flag);
 flag(cnt_dropped_flag);
 ub(8, n_frames);
 if (current->full_timestamp_flag) {
-u(6, seconds_value, 0, 59);
-u(6, minutes_value, 0, 59);
-

[FFmpeg-devel] [PATCH 1/3] avcodec/cbs_h2645: add macros to read and write fields with no custom range of values

2019-04-16 Thread James Almer
Signed-off-by: James Almer 
---
Better macro names welcome. I used the same convention as in cbs_av1.

fate-cbs passes, but i'm sure a bunch of these are not tested by it,
so help double checking i didn't screw up is welcome.

 libavcodec/cbs_h2645.c|  10 +-
 libavcodec/cbs_h264_syntax_template.c |  60 ++--
 libavcodec/cbs_h265_syntax_template.c | 126 +++---
 3 files changed, 90 insertions(+), 106 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index a205293b3c..319202fc48 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -252,22 +252,30 @@ static int cbs_write_se_golomb(CodedBitstreamContext 
*ctx, PutBitContext *pbc,
 
 #define u(width, name, range_min, range_max) \
 xu(width, name, current->name, range_min, range_max, 0)
-#define flag(name) u(1, name, 0, 1)
+#define ub(width, name) \
+xu(width, name, current->name, 0, MAX_UINT_BITS(width), 0)
+#define flag(name) ub(1, name)
 #define ue(name, range_min, range_max) \
 xue(name, current->name, range_min, range_max, 0)
 #define i(width, name, range_min, range_max) \
 xi(width, name, current->name, range_min, range_max, 0)
+#define ib(width, name) \
+xi(width, name, current->name, MIN_INT_BITS(width), 
MAX_INT_BITS(width), 0)
 #define se(name, range_min, range_max) \
 xse(name, current->name, range_min, range_max, 0)
 
 #define us(width, name, range_min, range_max, subs, ...) \
 xu(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
+#define ubs(width, name, subs, ...) \
+xu(width, name, current->name, 0, MAX_UINT_BITS(width), subs, 
__VA_ARGS__)
 #define flags(name, subs, ...) \
 xu(1, name, current->name, 0, 1, subs, __VA_ARGS__)
 #define ues(name, range_min, range_max, subs, ...) \
 xue(name, current->name, range_min, range_max, subs, __VA_ARGS__)
 #define is(width, name, range_min, range_max, subs, ...) \
 xi(width, name, current->name, range_min, range_max, subs, __VA_ARGS__)
+#define ibs(width, name, subs, ...) \
+xi(width, name, current->name, MIN_INT_BITS(width), 
MAX_INT_BITS(width), subs, __VA_ARGS__)
 #define ses(name, range_min, range_max, subs, ...) \
 xse(name, current->name, range_min, range_max, subs, __VA_ARGS__)
 
diff --git a/libavcodec/cbs_h264_syntax_template.c 
b/libavcodec/cbs_h264_syntax_template.c
index 07b4cddb5e..cc9bd07590 100644
--- a/libavcodec/cbs_h264_syntax_template.c
+++ b/libavcodec/cbs_h264_syntax_template.c
@@ -34,8 +34,8 @@ static int FUNC(nal_unit_header)(CodedBitstreamContext *ctx, 
RWContext *rw,
 int err;
 
 u(1, forbidden_zero_bit, 0, 0);
-u(2, nal_ref_idc,0, 3);
-u(5, nal_unit_type,  0, 31);
+ub(2, nal_ref_idc);
+ub(5, nal_unit_type);
 
 if (!(1 << current->nal_unit_type & valid_type_mask)) {
 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid NAL unit type %d.\n",
@@ -91,8 +91,8 @@ static int FUNC(hrd_parameters)(CodedBitstreamContext *ctx, 
RWContext *rw,
 int err, i;
 
 ue(cpb_cnt_minus1, 0, 31);
-u(4, bit_rate_scale, 0, 15);
-u(4, cpb_size_scale, 0, 15);
+ub(4, bit_rate_scale);
+ub(4, cpb_size_scale);
 
 for (i = 0; i <= current->cpb_cnt_minus1; i++) {
 ues(bit_rate_value_minus1[i], 0, UINT32_MAX - 1, 1, i);
@@ -100,10 +100,10 @@ static int FUNC(hrd_parameters)(CodedBitstreamContext 
*ctx, RWContext *rw,
 flags(cbr_flag[i], 1, i);
 }
 
-u(5, initial_cpb_removal_delay_length_minus1, 0, 31);
-u(5, cpb_removal_delay_length_minus1, 0, 31);
-u(5, dpb_output_delay_length_minus1,  0, 31);
-u(5, time_offset_length,  0, 31);
+ub(5, initial_cpb_removal_delay_length_minus1);
+ub(5, cpb_removal_delay_length_minus1);
+ub(5, dpb_output_delay_length_minus1);
+ub(5, time_offset_length);
 
 return 0;
 }
@@ -115,10 +115,10 @@ static int FUNC(vui_parameters)(CodedBitstreamContext 
*ctx, RWContext *rw,
 
 flag(aspect_ratio_info_present_flag);
 if (current->aspect_ratio_info_present_flag) {
-u(8, aspect_ratio_idc, 0, 255);
+ub(8, aspect_ratio_idc);
 if (current->aspect_ratio_idc == 255) {
-u(16, sar_width,  0, 65535);
-u(16, sar_height, 0, 65535);
+ub(16, sar_width);
+ub(16, sar_height);
 }
 } else {
 infer(aspect_ratio_idc, 0);
@@ -130,13 +130,13 @@ static int FUNC(vui_parameters)(CodedBitstreamContext 
*ctx, RWContext *rw,
 
 flag(video_signal_type_present_flag);
 if (current->video_signal_type_present_flag) {
-u(3, video_format, 0, 7);
+ub(3, video_format);
 flag(video_full_range_flag);
 flag(colour_description_present_flag);
 if (current->colour_description_present_flag) {
-u(8, colour_primaries, 0, 255);
-u(8, transfer_characteristics, 0, 255);
-u(8, matrix_coefficients,

Re: [FFmpeg-devel] [PATCH V2 2/2] lavfi/opencl: add nlmeans_opencl filter

2019-04-16 Thread Song, Ruiling


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> Mark Thompson
> Sent: Wednesday, April 17, 2019 5:28 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH V2 2/2] lavfi/opencl: add nlmeans_opencl
> filter
> 
> On 12/04/2019 16:09, Ruiling Song wrote:
> > Signed-off-by: Ruiling Song 
> 
> I can't work out where the problem is, but there is something really weirdly
> nondeterministic going on here.
> 
> E.g.
> 
> $ ./ffmpeg_g -y -init_hw_device opencl:0.0 -i ~/video/test/jellyfish-120-mbps-
> 4k-uhd-hevc-10bit.mkv -an -filter_hw_device opencl0 -vf
> format=yuv420p,hwupload,nlmeans_opencl,hwdownload,format=yuv420p -
> frames:v 10 -f framemd5 -
> ...
> 0,  0,  0,1, 12441600, 
> 8b8805818076b23ae6f80ec2b5a349d4
> 0,  1,  1,1, 12441600, 
> 7a7fdaa083dc337cfb6af31b643f30a3
> 0,  2,  2,1, 12441600, 
> b10ef2a1e5125cc67e262e086f8040b5
> 0,  3,  3,1, 12441600, 
> c06b53ad90e0357e537df41b63d5b1dc
> 0,  4,  4,1, 12441600, 
> 5aa2da07703859a3dee080847dd17d46
> 0,  5,  5,1, 12441600, 
> 733364c6be6af825057e905a6092937d
> 0,  6,  6,1, 12441600, 
> 47edae2dec956a582b04babb745d26b0
> 0,  7,  7,1, 12441600, 
> 4e45fe8268df4298d06a17ab8e46c3e9
> 0,  8,  8,1, 12441600, 
> 960d722a3f8787c9191299a114c04174
> 0,  9,  9,1, 12441600, 
> e759c07ee4834a9cf94bfcb4128e7612
> $ ./ffmpeg_g -y -init_hw_device opencl:0.0 -i ~/video/test/jellyfish-120-mbps-
> 4k-uhd-hevc-10bit.mkv -an -filter_hw_device opencl0 -vf
> format=yuv420p,hwupload,nlmeans_opencl,hwdownload,format=yuv420p -
> frames:v 10 -f framemd5 -
> 0,  0,  0,1, 12441600, 
> 8b8805818076b23ae6f80ec2b5a349d4
> [Parsed_nlmeans_opencl_2 @ 0x5557ae580d00] integral image overflow
> 2157538
> 0,  1,  1,1, 12441600, 
> bce72e10a9f1118940c5a8392ad78ec3
> 0,  2,  2,1, 12441600, 
> b10ef2a1e5125cc67e262e086f8040b5
> 0,  3,  3,1, 12441600, 
> c06b53ad90e0357e537df41b63d5b1dc
> 0,  4,  4,1, 12441600, 
> 5aa2da07703859a3dee080847dd17d46
> 0,  5,  5,1, 12441600, 
> 733364c6be6af825057e905a6092937d
> 0,  6,  6,1, 12441600, 
> 47edae2dec956a582b04babb745d26b0
> 0,  7,  7,1, 12441600, 
> 4e45fe8268df4298d06a17ab8e46c3e9
> 0,  8,  8,1, 12441600, 
> 960d722a3f8787c9191299a114c04174
> 0,  9,  9,1, 12441600, 
> e759c07ee4834a9cf94bfcb4128e7612
> $ ./ffmpeg_g -y -init_hw_device opencl:0.0 -i ~/video/test/jellyfish-120-mbps-
> 4k-uhd-hevc-10bit.mkv -an -filter_hw_device opencl0 -vf
> format=yuv420p,hwupload,nlmeans_opencl,hwdownload,format=yuv420p -
> frames:v 10 -f framemd5 -
> 0,  0,  0,1, 12441600, 
> 8b8805818076b23ae6f80ec2b5a349d4
> 0,  1,  1,1, 12441600, 
> 7a7fdaa083dc337cfb6af31b643f30a3
> [Parsed_nlmeans_opencl_2 @ 0x557c51fbfe80] integral image overflow
> 2098545
> 0,  2,  2,1, 12441600, 
> 68b390535adc5cfa0f8a7942c42a47ca
> 0,  3,  3,1, 12441600, 
> c06b53ad90e0357e537df41b63d5b1dc
> 0,  4,  4,1, 12441600, 
> 5aa2da07703859a3dee080847dd17d46
> 0,  5,  5,1, 12441600, 
> 733364c6be6af825057e905a6092937d
> 0,  6,  6,1, 12441600, 
> 47edae2dec956a582b04babb745d26b0
> 0,  7,  7,1, 12441600, 
> 4e45fe8268df4298d06a17ab8e46c3e9
> 0,  8,  8,1, 12441600, 
> 960d722a3f8787c9191299a114c04174
> 0,  9,  9,1, 12441600, 
> e759c07ee4834a9cf94bfcb4128e7612
> 
> Frame 1 gave an overflow on the second run, and gets a different answer, then
> frame 2 in the same way on the third run?  I can't characterise when this
> happens, it seems to be pretty random with low probability.

I tried to reproduce on my SKL and KBL, with Beignet and Neo. And didn't 
reproduce the issue.
As I am encountering some network issue, I didn't get the video sample you 
provide (I am using https://4ksamples.com/ses-astra-uhd-test-2-2160p-uhdtv/ ), 
I can try later to download the same video as you.
May be an OpenCL driver issue? I am not sure yet. So could you provide what 
hardware and opencl driver version you are using? So I can do some debugging if 
possible.

> 
> (Input here is a 4K file from , but I don't think it 
> matters - I
> saw it with others sometimes as well.)
> 
> >  configure   |   1 +
> >  doc/filters.texi|   4 +
> >  libavfilter/Makefile|   1 +
> >  libavfilter/allfilters.c|   1 +
> >  libavfilter/opencl/nlmeans.cl   | 115 +
> >  libavfilter/openc

[FFmpeg-devel] [PATCH v3] lavfi: add colorkey_opencl filter

2019-04-16 Thread Jarek Samic
This is a direct port of the CPU filter.

Signed-off-by: Jarek Samic 
---
More fixes based on the comments from the second version of the patch (moving 
sampler declaration into the program scope, `f`-suffixing constants, attaching 
the `*` sigil to the variable name rather than the data type).

 configure|   1 +
 doc/filters.texi |  33 +
 libavfilter/Makefile |   2 +
 libavfilter/allfilters.c |   1 +
 libavfilter/opencl/colorkey.cl   |  49 +++
 libavfilter/opencl_source.h  |   1 +
 libavfilter/vf_colorkey_opencl.c | 244 +++
 7 files changed, 331 insertions(+)
 create mode 100644 libavfilter/opencl/colorkey.cl
 create mode 100644 libavfilter/vf_colorkey_opencl.c

diff --git a/configure b/configure
index e10e2c2c46..ac59c4ddec 100755
--- a/configure
+++ b/configure
@@ -3413,6 +3413,7 @@ boxblur_filter_deps="gpl"
 boxblur_opencl_filter_deps="opencl gpl"
 bs2b_filter_deps="libbs2b"
 colormatrix_filter_deps="gpl"
+colorkey_opencl_filter_deps="opencl"
 convolution_opencl_filter_deps="opencl"
 convolve_filter_deps="avcodec"
 convolve_filter_select="fft"
diff --git a/doc/filters.texi b/doc/filters.texi
index 867607d870..390c8b97cf 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19030,6 +19030,39 @@ Apply erosion filter with threshold0 set to 30, 
threshold1 set 40, threshold2 se
 @end example
 @end itemize
 
+@section colorkey_opencl
+RGB colorspace color keying.
+
+The filter accepts the following options:
+
+@table @option
+@item color
+The color which will be replaced with transparency.
+
+@item similarity
+Similarity percentage with the key color.
+
+0.01 matches only the exact key color, while 1.0 matches everything.
+
+@item blend
+Blend percentage.
+
+0.0 makes pixels either fully transparent, or not transparent at all.
+
+Higher values result in semi-transparent pixels, with a higher transparency
+the more similar the pixels color is to the key color.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Make every semi-green pixel in the input transparent with some slight blending:
+@example
+-i INPUT -vf "hwupload, colorkey_opencl=green:0.3:0.1, hwdownload" OUTPUT
+@end example
+@end itemize
+
 @section overlay_opencl
 
 Overlay one video on top of another.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index fef6ec5c55..9589dd8747 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -176,6 +176,8 @@ OBJS-$(CONFIG_CODECVIEW_FILTER)  += 
vf_codecview.o
 OBJS-$(CONFIG_COLORBALANCE_FILTER)   += vf_colorbalance.o
 OBJS-$(CONFIG_COLORCHANNELMIXER_FILTER)  += vf_colorchannelmixer.o
 OBJS-$(CONFIG_COLORKEY_FILTER)   += vf_colorkey.o
+OBJS-$(CONFIG_COLORKEY_OPENCL_FILTER)+= vf_colorkey_opencl.o opencl.o \
+opencl/colorkey.o
 OBJS-$(CONFIG_COLORLEVELS_FILTER)+= vf_colorlevels.o
 OBJS-$(CONFIG_COLORMATRIX_FILTER)+= vf_colormatrix.o
 OBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o colorspace.o 
colorspacedsp.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index c51ae0f3c7..ff4eb5bf6b 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -165,6 +165,7 @@ extern AVFilter ff_vf_codecview;
 extern AVFilter ff_vf_colorbalance;
 extern AVFilter ff_vf_colorchannelmixer;
 extern AVFilter ff_vf_colorkey;
+extern AVFilter ff_vf_colorkey_opencl;
 extern AVFilter ff_vf_colorlevels;
 extern AVFilter ff_vf_colormatrix;
 extern AVFilter ff_vf_colorspace;
diff --git a/libavfilter/opencl/colorkey.cl b/libavfilter/opencl/colorkey.cl
new file mode 100644
index 00..6d71f17164
--- /dev/null
+++ b/libavfilter/opencl/colorkey.cl
@@ -0,0 +1,49 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE |
+  CLK_FILTER_NEAREST;
+
+__kernel void colorkey_blend(
+__read_only  image2d_t src,
+__write_only image2d_t dst,
+float4 colorkey_rgba,
+float similarity,
+float blend
+) {
+int2 loc = (int2)(get_global_id(0), get_global_id(1));
+float4 pixel = read_imagef(src, sampler, loc);
+float diff = distance(pixel.xyz, colo

Re: [FFmpeg-devel] [PATCH V1] lavf/oggparsevorbis: Fix change the case of metadata keys issue

2019-04-16 Thread myp...@gmail.com
On Wed, Apr 17, 2019 at 6:41 AM Michael Niedermayer
 wrote:
>
> On Tue, Apr 16, 2019 at 09:33:08AM +0800, myp...@gmail.com wrote:
> > On Tue, Apr 16, 2019 at 5:51 AM Michael Niedermayer
> >  wrote:
> > >
> > > On Mon, Apr 15, 2019 at 09:58:30AM +0800, Jun Zhao wrote:
> > > > From: Jun Zhao 
> > > >
> > > > The spec in https://xiph.org/vorbis/doc/v-comment.html states that
> > > > the metadata keys are case-insensitive, so don't change the case
> > > > and update the fate test case.
> > > >
> > > > Fix #7784
> > > >
> > > > Signed-off-by: Jun Zhao 
> > > > ---
> > > >  libavformat/oggparsevorbis.c |9 -
> > > >  tests/ref/fate/limited_input_seek|2 +-
> > > >  tests/ref/fate/limited_input_seek-copyts |2 +-
> > > >  3 files changed, 6 insertions(+), 7 deletions(-)
> > > >
> > > > diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
> > > > index bcfd246..c3c8d38 100644
> > > > --- a/libavformat/oggparsevorbis.c
> > > > +++ b/libavformat/oggparsevorbis.c
> > > > @@ -44,7 +44,7 @@ static int ogm_chapter(AVFormatContext *as, uint8_t 
> > > > *key, uint8_t *val)
> > > >  int i, cnum, h, m, s, ms, keylen = strlen(key);
> > > >  AVChapter *chapter = NULL;
> > > >
> > > > -if (keylen < 9 || sscanf(key, "CHAPTER%03d", &cnum) != 1)
> > > > +if (keylen < 9 || (av_strcasecmp(key, "CHAPTER")!=0 && 
> > > > sscanf(key+7, "%03d", &cnum) != 1))
> > >
> > > this looks a bit odd, shouldnt this use av_strncasecmp() ?
> > >
> > It's  in order to be compatible with the fate test case
> > vorbis-1833-chapthers, in this test,
> > we use lower case in test clip but check upper case in the code.
>
> av_strcasecmp() will only succeed if the string ends after "CHAPTER" and
> contains no number which is why av_strncasecmp() feels like more effective.
> The problem is ultimatle that keylen is at this point >= 9 while
> the only case where av_strcasecmp with "CHAPTER" == 0 is with a
> keylen of 7. Thats tricky to achieve ;)
>
> Or said differently this code is not a case insensitive version of the
> previous
Thanks the comments, will update the patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/8] libavfilter/dnn: determine dnn output during execute_model instead of set_input_output

2019-04-16 Thread Guo, Yejun


> -Original Message-
> From: Steven Liu [mailto:l...@chinaffmpeg.org]
> Sent: Tuesday, April 16, 2019 8:04 PM
> To: FFmpeg development discussions and patches 
> Cc: Steven Liu ; Guo, Yejun 
> Subject: Re: [FFmpeg-devel] [PATCH 4/8] libavfilter/dnn: determine dnn output
> during execute_model instead of set_input_output
> 
> 
> 
> > 在 2019年4月2日,22:29,Guo, Yejun  写道:
> >
> > Currently, within interface set_input_output, the dims/memory of the
> tensorflow
> > dnn model output is determined by executing the model with zero input,
> > actually, the output dims might vary with different input data for networks
> > such as object detection models faster-rcnn, ssd and yolo.
> >
> > This patch moves the logic from set_input_output to execute_model which
> > is suitable for all the cases. Since interface changed, and so
> dnn_backend_native
> > also changes.
> >
> > In vf_sr.c, it knows it's srcnn or espcn by executing the model with zero 
> > input,
> > so execute_model has to be called in function config_props
> >
> > Signed-off-by: Guo, Yejun 
> > ---
> > libavfilter/dnn_backend_native.c | 14 +-
> > libavfilter/dnn_backend_native.h |  2 +-
> > libavfilter/dnn_backend_tf.c | 55 
> > 
> > libavfilter/dnn_backend_tf.h |  2 +-
> > libavfilter/dnn_interface.h  |  6 ++---
> > libavfilter/vf_sr.c  | 20 ---
> > 6 files changed, 51 insertions(+), 48 deletions(-)
> >
> > diff --git a/libavfilter/dnn_backend_native.c
> b/libavfilter/dnn_backend_native.c
> > index fe43116..18735c0 100644
> > --- a/libavfilter/dnn_backend_native.c
> > +++ b/libavfilter/dnn_backend_native.c
> > @@ -25,7 +25,7 @@
> >
> > #include "dnn_backend_native.h"
> >
> > -static DNNReturnType set_input_output_native(void *model, DNNData
> *input, const char *input_name, DNNData *output, const char *output_name)
> > +static DNNReturnType set_input_output_native(void *model, DNNData
> *input, const char *input_name, const char *output_name)
> > {
> > ConvolutionalNetwork *network = (ConvolutionalNetwork *)model;
> > InputParams *input_params;
> > @@ -81,11 +81,6 @@ static DNNReturnType set_input_output_native(void
> *model, DNNData *input, const
> > }
> > }
> >
> > -output->data = network->layers[network->layers_num - 1].output;
> > -output->height = cur_height;
> > -output->width = cur_width;
> > -output->channels = cur_channels;
> > -
> > return DNN_SUCCESS;
> > }
> >
> > @@ -280,7 +275,7 @@ static void depth_to_space(const float *input, float
> *output, int block_size, in
> > }
> > }
> >
> > -DNNReturnType ff_dnn_execute_model_native(const DNNModel *model)
> > +DNNReturnType ff_dnn_execute_model_native(const DNNModel *model,
> DNNData *output)
> > {
> > ConvolutionalNetwork *network = (ConvolutionalNetwork
> *)model->model;
> > int cur_width, cur_height, cur_channels;
> > @@ -322,6 +317,11 @@ DNNReturnType
> ff_dnn_execute_model_native(const DNNModel *model)
> > }
> > }
> >
> > +output->data = network->layers[network->layers_num - 1].output;
> > +output->height = cur_height;
> > +output->width = cur_width;
> > +output->channels = cur_channels;
> > +
> > return DNN_SUCCESS;
> > }
> >
> > diff --git a/libavfilter/dnn_backend_native.h
> b/libavfilter/dnn_backend_native.h
> > index 51d4cac..adaf4a7 100644
> > --- a/libavfilter/dnn_backend_native.h
> > +++ b/libavfilter/dnn_backend_native.h
> > @@ -63,7 +63,7 @@ typedef struct ConvolutionalNetwork{
> >
> > DNNModel *ff_dnn_load_model_native(const char *model_filename);
> >
> > -DNNReturnType ff_dnn_execute_model_native(const DNNModel *model);
> > +DNNReturnType ff_dnn_execute_model_native(const DNNModel *model,
> DNNData *output);
> >
> > void ff_dnn_free_model_native(DNNModel **model);
> >
> > diff --git a/libavfilter/dnn_backend_tf.c b/libavfilter/dnn_backend_tf.c
> > index a838907..7966688 100644
> > --- a/libavfilter/dnn_backend_tf.c
> > +++ b/libavfilter/dnn_backend_tf.c
> > @@ -35,7 +35,6 @@ typedef struct TFModel{
> > TF_Status *status;
> > TF_Output input, output;
> > TF_Tensor *input_tensor;
> > -DNNData *output_data;
> > } TFModel;
> >
> > static void free_buffer(void *data, size_t length)
> > @@ -76,13 +75,12 @@ static TF_Buffer *read_graph(const char
> *model_filename)
> > return graph_buf;
> > }
> >
> > -static DNNReturnType set_input_output_tf(void *model, DNNData *input,
> const char *input_name, DNNData *output, const char *output_name)
> > +static DNNReturnType set_input_output_tf(void *model, DNNData *input,
> const char *input_name, const char *output_name)
> > {
> > TFModel *tf_model = (TFModel *)model;
> > int64_t input_dims[] = {1, input->height, input->width, 
> > input->channels};
> > TF_SessionOptions *sess_opts;
> > const TF_Operation *init_op =
> TF_GraphOperationByName(tf_model->graph, "init");
> > -TF_Tensor *output_tensor;
> >
> > // Input operation
> > tf

Re: [FFmpeg-devel] [PATCH 5/5] avcodec/cbs_av1: use the new signed value read/write functions

2019-04-16 Thread James Almer
On 4/16/2019 8:10 PM, Mark Thompson wrote:
> On 15/04/2019 22:17, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>> The sample https://0x0.st/sljR.webm appears to be parsed the exact same way
>> after this patch.
>>
>>  libavcodec/cbs_av1.c | 68 ++--
>>  1 file changed, 8 insertions(+), 60 deletions(-)
>>
>> diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
>> index 41dd4c97ac..eb2d03ef43 100644
>> --- a/libavcodec/cbs_av1.c
>> +++ b/libavcodec/cbs_av1.c
>> @@ -207,62 +207,6 @@ static int cbs_av1_write_leb128(CodedBitstreamContext 
>> *ctx, PutBitContext *pbc,
>>  return 0;
>>  }
>>  
>> -static int cbs_av1_read_su(CodedBitstreamContext *ctx, GetBitContext *gbc,
>> -   int width, const char *name,
>> -   const int *subscripts, int32_t *write_to)
>> -{
>> -int position;
>> -int32_t value;
>> -
>> -if (ctx->trace_enable)
>> -position = get_bits_count(gbc);
>> -
>> -if (get_bits_left(gbc) < width) {
>> -av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid signed value at "
>> -   "%s: bitstream ended.\n", name);
>> -return AVERROR_INVALIDDATA;
>> -}
>> -
>> -value = get_sbits(gbc, width);
>> -
>> -if (ctx->trace_enable) {
>> -char bits[33];
>> -int i;
>> -for (i = 0; i < width; i++)
>> -bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';
> 
> Ohright, it was bad here too.  (But only ever used on small values in AV1, so 
> it couldn't actually be hit.)
> 
>> -bits[i] = 0;
>> -
>> -ff_cbs_trace_syntax_element(ctx, position,
>> -name, subscripts, bits, value);
>> -}
>> -
>> -*write_to = value;
>> -return 0;
>> -}
>> -
>> -static int cbs_av1_write_su(CodedBitstreamContext *ctx, PutBitContext *pbc,
>> -int width, const char *name,
>> -const int *subscripts, int32_t value)
>> -{
>> -if (put_bits_left(pbc) < width)
>> -return AVERROR(ENOSPC);
>> -
>> -if (ctx->trace_enable) {
>> -char bits[33];
>> -int i;
>> -for (i = 0; i < width; i++)
>> -bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';
>> -bits[i] = 0;
>> -
>> -ff_cbs_trace_syntax_element(ctx, put_bits_count(pbc),
>> -name, subscripts, bits, value);
>> -}
>> -
>> -put_sbits(pbc, width, value);
>> -
>> -return 0;
>> -}
>> -
>>  static int cbs_av1_read_ns(CodedBitstreamContext *ctx, GetBitContext *gbc,
>> uint32_t n, const char *name,
>> const int *subscripts, uint32_t *write_to)
>> @@ -639,8 +583,10 @@ static size_t 
>> cbs_av1_get_payload_bytes_left(GetBitContext *gbc)
>>  
>>  #define xsu(width, name, var, subs, ...) do { \
>>  int32_t value = 0; \
>> -CHECK(cbs_av1_read_su(ctx, rw, width, #name, \
>> -  SUBSCRIPTS(subs, __VA_ARGS__), &value)); \
>> +CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \
>> + SUBSCRIPTS(subs, __VA_ARGS__), &value, \
>> + MIN_INT_BITS(width), \
>> + MAX_INT_BITS(width))); \
>>  var = value; \
>>  } while (0)
>>  
>> @@ -723,8 +669,10 @@ static size_t 
>> cbs_av1_get_payload_bytes_left(GetBitContext *gbc)
>>  } while (0)
>>  
>>  #define xsu(width, name, var, subs, ...) do { \
>> -CHECK(cbs_av1_write_su(ctx, rw, width, #name, \
>> -   SUBSCRIPTS(subs, __VA_ARGS__), var)); \
>> +CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \
>> +  SUBSCRIPTS(subs, __VA_ARGS__), var, \
>> +  MIN_INT_BITS(width), \
>> +  MAX_INT_BITS(width))); \
>>  } while (0)
>>  
>>  #define uvlc(name, range_min, range_max) do { \
>>
> 
> LGTM.
> 
> Thanks,
> 
> - Mark

Pushed, thanks!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 3/5] avcodec/cbs_h264: fix storage type for time_offset in Pic Timing SEI

2019-04-16 Thread James Almer
On 4/16/2019 8:00 PM, Mark Thompson wrote:
> On 15/04/2019 22:17, James Almer wrote:
>> The spec defines it as a signed value.
>>
>> Signed-off-by: James Almer 
>> ---
>> The only sample i could find with time_offset values it's in the fate suite,
>> and in all cases it's 0.
>>
>>  libavcodec/cbs_h264.h | 2 +-
>>  libavcodec/cbs_h264_syntax_template.c | 5 +++--
>>  2 files changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
>> index 92277e4750..b5eee7c370 100644
>> --- a/libavcodec/cbs_h264.h
>> +++ b/libavcodec/cbs_h264.h
>> @@ -253,7 +253,7 @@ typedef struct H264RawSEIPicTimestamp {
>>  uint8_t minutes_value;
>>  uint8_t hours_flag;
>>  uint8_t hours_value;
>> -uint32_t time_offset;
>> +int32_t time_offset;
>>  } H264RawSEIPicTimestamp;
>>  
>>  typedef struct H264RawSEIPicTiming {
>> diff --git a/libavcodec/cbs_h264_syntax_template.c 
>> b/libavcodec/cbs_h264_syntax_template.c
>> index 4da4c5da67..07b4cddb5e 100644
>> --- a/libavcodec/cbs_h264_syntax_template.c
>> +++ b/libavcodec/cbs_h264_syntax_template.c
>> @@ -592,8 +592,9 @@ static int FUNC(sei_pic_timestamp)(CodedBitstreamContext 
>> *ctx, RWContext *rw,
>>  time_offset_length = 24;
>>  
>>  if (time_offset_length > 0)
>> -u(time_offset_length, time_offset,
>> -  0, MAX_UINT_BITS(time_offset_length));
>> +i(time_offset_length, time_offset,
>> +  MIN_INT_BITS(time_offset_length),
>> +  MAX_INT_BITS(time_offset_length));
>>  else
>>  infer(time_offset, 0);
>>  
>>
> 
> LGTM.
> 
> I'm glad the standard gets plenty of use out of that i(v) syntax element type 
> definition.
> 
> - Mark
Heh, true, on h264 this is indeed the only case where it's used. On h265
it's also used in the spherical metadata SEI, added in a recent revision
of the spec, so it's not surprising that most implementations got it wrong.

Couldn't find any sample with the spherical SEI, for that matter. All
samples used instead the relevant isobmff boxes.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/5] avcodec/cbs_h2645: add helper macros for signed values

2019-04-16 Thread James Almer
On 4/16/2019 8:24 PM, Mark Thompson wrote:
> On 17/04/2019 00:01, James Almer wrote:
>> On 4/16/2019 7:57 PM, Mark Thompson wrote:
>>> On 15/04/2019 22:17, James Almer wrote:
 Signed-off-by: James Almer 
 ---
  libavcodec/cbs_h2645.c | 20 
  1 file changed, 20 insertions(+)

 diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
 index e74f8dce81..a205293b3c 100644
 --- a/libavcodec/cbs_h2645.c
 +++ b/libavcodec/cbs_h2645.c
 @@ -255,6 +255,8 @@ static int cbs_write_se_golomb(CodedBitstreamContext 
 *ctx, PutBitContext *pbc,
  #define flag(name) u(1, name, 0, 1)
  #define ue(name, range_min, range_max) \
  xue(name, current->name, range_min, range_max, 0)
 +#define i(width, name, range_min, range_max) \
 +xi(width, name, current->name, range_min, range_max, 0)
>>>
>>> I know it's right, but defining "i" as a macro feels like a pretty terrible 
>>> idea in C :P
>>
>> Eh, i guess :p. It at least didn't blow up here.
>>
>> What would be best? s? su like in cbs_av1? Something else?
> 
> To clarify, I do think it's correct to call it i() here to match the H.26[45] 
> standards.
> 
> Any other option would probably be more confusing.  And, as you note, it 
> actually doesn't blow up because none of the many uses of i are followed by (.
> 
> - Mark

Alright, left as is then, and pushed.

Thanks!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/cbs: add helper functions and macros to read and write signed values

2019-04-16 Thread James Almer
On 4/16/2019 8:27 PM, Mark Thompson wrote:
> On 16/04/2019 23:54, James Almer wrote:
>> On 4/16/2019 7:45 PM, Mark Thompson wrote:
>>> On 15/04/2019 22:17, James Almer wrote:
 Signed-off-by: James Almer 
 ---
  libavcodec/cbs.c  | 79 +++
  libavcodec/cbs_internal.h | 20 +-
  2 files changed, 98 insertions(+), 1 deletion(-)
>>>
>>> Looks like a sensible addition, some comments below.
>>>
 diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
 index c388be896b..726bd582f5 100644
 --- a/libavcodec/cbs.c
 +++ b/libavcodec/cbs.c
 @@ -504,6 +504,85 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, 
 PutBitContext *pbc,
  return 0;
  }
  
 +int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc,
 +   int width, const char *name,
 +   const int *subscripts, int32_t *write_to,
 +   int32_t range_min, int32_t range_max)
 +{
 +int32_t value;
 +int position;
 +
 +av_assert0(width > 0 && width <= 32);
 +
 +if (get_bits_left(gbc) < width) {
 +av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid value at "
 +   "%s: bitstream ended.\n", name);
 +return AVERROR_INVALIDDATA;
 +}
 +
 +if (ctx->trace_enable)
 +position = get_bits_count(gbc);
 +
 +value = get_sbits_long(gbc, width);
 +
 +if (ctx->trace_enable) {
 +char bits[33];
 +int i;
 +for (i = 0; i < width; i++)
 +bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';
>>>
>>> 1 << 31 is undefined behaviour for 32-bit int.
>>>
>>> The unsigned versions are careful to right-shift unsigned values to avoid 
>>> overflow problems; a possible fix might be to strip the sign bit and then 
>>> do the same thing.
>>
>> Would "1U << (width - i - 1)" be enough?
> 
> Probably?  A negative value would be promoted to unsigned as positive 
> , which I think does the right thing.

Changed and pushed then.

Thanks!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/5] avcodec/cbs_h265: fix storage type for time_offset_value in Time Code SEI

2019-04-16 Thread James Almer
On 4/16/2019 8:03 PM, Mark Thompson wrote:
> On 15/04/2019 22:17, James Almer wrote:
>> The spec defines it as an array of signed values, inferred to 0 when not
>> present.
>>
>> Signed-off-by: James Almer 
>> ---
>> Couldn't find any sample using it.
>>
>>  libavcodec/cbs_h265.h | 2 +-
>>  libavcodec/cbs_h265_syntax_template.c | 7 +--
>>  2 files changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
>> index d216caca2b..0c0e4f84b0 100644
>> --- a/libavcodec/cbs_h265.h
>> +++ b/libavcodec/cbs_h265.h
>> @@ -659,7 +659,7 @@ typedef struct H265RawSEITimeCode {
>>  uint8_t  minutes_flag[3];
>>  uint8_t  hours_flag[3];
>>  uint8_t  time_offset_length[3];
>> -uint32_t time_offset_value[3];
>> +int32_t  time_offset_value[3];
>>  } H265RawSEITimeCode;
>>  
>>  typedef struct H265RawSEIMasteringDisplayColourVolume {
>> diff --git a/libavcodec/cbs_h265_syntax_template.c 
>> b/libavcodec/cbs_h265_syntax_template.c
>> index f1e1bb0e7e..bbd363a389 100644
>> --- a/libavcodec/cbs_h265_syntax_template.c
>> +++ b/libavcodec/cbs_h265_syntax_template.c
>> @@ -1986,8 +1986,11 @@ static int FUNC(sei_time_code)(CodedBitstreamContext 
>> *ctx, RWContext *rw,
>>  
>>  us(5, time_offset_length[i], 0, 31, 1, i);
>>  if (current->time_offset_length[i] > 0)
>> -us(current->time_offset_length[i], time_offset_value[i],
>> -   0, MAX_UINT_BITS(current->time_offset_length[i]), 1, i);
>> +is(current->time_offset_length[i], time_offset_value[i],
>> +   MIN_INT_BITS(current->time_offset_length[i]),
>> +   MAX_INT_BITS(current->time_offset_length[i]), 1, i);
>> +else
>> +infer(time_offset_value[i], 0);
>>  }
>>  }
>>  
>>
> 
> LGTM.
> 
> Thanks,
> 
> - Mark

Pushed, thanks!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/cbs: add helper functions and macros to read and write signed values

2019-04-16 Thread Mark Thompson
On 16/04/2019 23:54, James Almer wrote:
> On 4/16/2019 7:45 PM, Mark Thompson wrote:
>> On 15/04/2019 22:17, James Almer wrote:
>>> Signed-off-by: James Almer 
>>> ---
>>>  libavcodec/cbs.c  | 79 +++
>>>  libavcodec/cbs_internal.h | 20 +-
>>>  2 files changed, 98 insertions(+), 1 deletion(-)
>>
>> Looks like a sensible addition, some comments below.
>>
>>> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
>>> index c388be896b..726bd582f5 100644
>>> --- a/libavcodec/cbs.c
>>> +++ b/libavcodec/cbs.c
>>> @@ -504,6 +504,85 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, 
>>> PutBitContext *pbc,
>>>  return 0;
>>>  }
>>>  
>>> +int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc,
>>> +   int width, const char *name,
>>> +   const int *subscripts, int32_t *write_to,
>>> +   int32_t range_min, int32_t range_max)
>>> +{
>>> +int32_t value;
>>> +int position;
>>> +
>>> +av_assert0(width > 0 && width <= 32);
>>> +
>>> +if (get_bits_left(gbc) < width) {
>>> +av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid value at "
>>> +   "%s: bitstream ended.\n", name);
>>> +return AVERROR_INVALIDDATA;
>>> +}
>>> +
>>> +if (ctx->trace_enable)
>>> +position = get_bits_count(gbc);
>>> +
>>> +value = get_sbits_long(gbc, width);
>>> +
>>> +if (ctx->trace_enable) {
>>> +char bits[33];
>>> +int i;
>>> +for (i = 0; i < width; i++)
>>> +bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';
>>
>> 1 << 31 is undefined behaviour for 32-bit int.
>>
>> The unsigned versions are careful to right-shift unsigned values to avoid 
>> overflow problems; a possible fix might be to strip the sign bit and then do 
>> the same thing.
> 
> Would "1U << (width - i - 1)" be enough?

Probably?  A negative value would be promoted to unsigned as positive , 
which I think does the right thing.

>>> +bits[i] = 0;
>>> +
>>> +ff_cbs_trace_syntax_element(ctx, position, name, subscripts,
>>> +bits, value);
>>> +}
>>> +
>>> +if (value < range_min || value > range_max) {
>>> +av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: "
>>> +   "%"PRId32", but must be in [%"PRId32",%"PRId32"].\n",
>>> +   name, value, range_min, range_max);
>>> +return AVERROR_INVALIDDATA;
>>> +}
>>> +
>>> +*write_to = value;
>>> +return 0;
>>> +}

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/5] avcodec/cbs_h2645: add helper macros for signed values

2019-04-16 Thread Mark Thompson
On 17/04/2019 00:01, James Almer wrote:
> On 4/16/2019 7:57 PM, Mark Thompson wrote:
>> On 15/04/2019 22:17, James Almer wrote:
>>> Signed-off-by: James Almer 
>>> ---
>>>  libavcodec/cbs_h2645.c | 20 
>>>  1 file changed, 20 insertions(+)
>>>
>>> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
>>> index e74f8dce81..a205293b3c 100644
>>> --- a/libavcodec/cbs_h2645.c
>>> +++ b/libavcodec/cbs_h2645.c
>>> @@ -255,6 +255,8 @@ static int cbs_write_se_golomb(CodedBitstreamContext 
>>> *ctx, PutBitContext *pbc,
>>>  #define flag(name) u(1, name, 0, 1)
>>>  #define ue(name, range_min, range_max) \
>>>  xue(name, current->name, range_min, range_max, 0)
>>> +#define i(width, name, range_min, range_max) \
>>> +xi(width, name, current->name, range_min, range_max, 0)
>>
>> I know it's right, but defining "i" as a macro feels like a pretty terrible 
>> idea in C :P
> 
> Eh, i guess :p. It at least didn't blow up here.
> 
> What would be best? s? su like in cbs_av1? Something else?

To clarify, I do think it's correct to call it i() here to match the H.26[45] 
standards.

Any other option would probably be more confusing.  And, as you note, it 
actually doesn't blow up because none of the many uses of i are followed by (.

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 5/5] avcodec/cbs_av1: use the new signed value read/write functions

2019-04-16 Thread Mark Thompson
On 15/04/2019 22:17, James Almer wrote:
> Signed-off-by: James Almer 
> ---
> The sample https://0x0.st/sljR.webm appears to be parsed the exact same way
> after this patch.
> 
>  libavcodec/cbs_av1.c | 68 ++--
>  1 file changed, 8 insertions(+), 60 deletions(-)
> 
> diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
> index 41dd4c97ac..eb2d03ef43 100644
> --- a/libavcodec/cbs_av1.c
> +++ b/libavcodec/cbs_av1.c
> @@ -207,62 +207,6 @@ static int cbs_av1_write_leb128(CodedBitstreamContext 
> *ctx, PutBitContext *pbc,
>  return 0;
>  }
>  
> -static int cbs_av1_read_su(CodedBitstreamContext *ctx, GetBitContext *gbc,
> -   int width, const char *name,
> -   const int *subscripts, int32_t *write_to)
> -{
> -int position;
> -int32_t value;
> -
> -if (ctx->trace_enable)
> -position = get_bits_count(gbc);
> -
> -if (get_bits_left(gbc) < width) {
> -av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid signed value at "
> -   "%s: bitstream ended.\n", name);
> -return AVERROR_INVALIDDATA;
> -}
> -
> -value = get_sbits(gbc, width);
> -
> -if (ctx->trace_enable) {
> -char bits[33];
> -int i;
> -for (i = 0; i < width; i++)
> -bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';

Ohright, it was bad here too.  (But only ever used on small values in AV1, so 
it couldn't actually be hit.)

> -bits[i] = 0;
> -
> -ff_cbs_trace_syntax_element(ctx, position,
> -name, subscripts, bits, value);
> -}
> -
> -*write_to = value;
> -return 0;
> -}
> -
> -static int cbs_av1_write_su(CodedBitstreamContext *ctx, PutBitContext *pbc,
> -int width, const char *name,
> -const int *subscripts, int32_t value)
> -{
> -if (put_bits_left(pbc) < width)
> -return AVERROR(ENOSPC);
> -
> -if (ctx->trace_enable) {
> -char bits[33];
> -int i;
> -for (i = 0; i < width; i++)
> -bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';
> -bits[i] = 0;
> -
> -ff_cbs_trace_syntax_element(ctx, put_bits_count(pbc),
> -name, subscripts, bits, value);
> -}
> -
> -put_sbits(pbc, width, value);
> -
> -return 0;
> -}
> -
>  static int cbs_av1_read_ns(CodedBitstreamContext *ctx, GetBitContext *gbc,
> uint32_t n, const char *name,
> const int *subscripts, uint32_t *write_to)
> @@ -639,8 +583,10 @@ static size_t 
> cbs_av1_get_payload_bytes_left(GetBitContext *gbc)
>  
>  #define xsu(width, name, var, subs, ...) do { \
>  int32_t value = 0; \
> -CHECK(cbs_av1_read_su(ctx, rw, width, #name, \
> -  SUBSCRIPTS(subs, __VA_ARGS__), &value)); \
> +CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \
> + SUBSCRIPTS(subs, __VA_ARGS__), &value, \
> + MIN_INT_BITS(width), \
> + MAX_INT_BITS(width))); \
>  var = value; \
>  } while (0)
>  
> @@ -723,8 +669,10 @@ static size_t 
> cbs_av1_get_payload_bytes_left(GetBitContext *gbc)
>  } while (0)
>  
>  #define xsu(width, name, var, subs, ...) do { \
> -CHECK(cbs_av1_write_su(ctx, rw, width, #name, \
> -   SUBSCRIPTS(subs, __VA_ARGS__), var)); \
> +CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \
> +  SUBSCRIPTS(subs, __VA_ARGS__), var, \
> +  MIN_INT_BITS(width), \
> +  MAX_INT_BITS(width))); \
>  } while (0)
>  
>  #define uvlc(name, range_min, range_max) do { \
> 

LGTM.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/5] avcodec/cbs_h265: fix storage type for time_offset_value in Time Code SEI

2019-04-16 Thread Mark Thompson
On 15/04/2019 22:17, James Almer wrote:
> The spec defines it as an array of signed values, inferred to 0 when not
> present.
> 
> Signed-off-by: James Almer 
> ---
> Couldn't find any sample using it.
> 
>  libavcodec/cbs_h265.h | 2 +-
>  libavcodec/cbs_h265_syntax_template.c | 7 +--
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
> index d216caca2b..0c0e4f84b0 100644
> --- a/libavcodec/cbs_h265.h
> +++ b/libavcodec/cbs_h265.h
> @@ -659,7 +659,7 @@ typedef struct H265RawSEITimeCode {
>  uint8_t  minutes_flag[3];
>  uint8_t  hours_flag[3];
>  uint8_t  time_offset_length[3];
> -uint32_t time_offset_value[3];
> +int32_t  time_offset_value[3];
>  } H265RawSEITimeCode;
>  
>  typedef struct H265RawSEIMasteringDisplayColourVolume {
> diff --git a/libavcodec/cbs_h265_syntax_template.c 
> b/libavcodec/cbs_h265_syntax_template.c
> index f1e1bb0e7e..bbd363a389 100644
> --- a/libavcodec/cbs_h265_syntax_template.c
> +++ b/libavcodec/cbs_h265_syntax_template.c
> @@ -1986,8 +1986,11 @@ static int FUNC(sei_time_code)(CodedBitstreamContext 
> *ctx, RWContext *rw,
>  
>  us(5, time_offset_length[i], 0, 31, 1, i);
>  if (current->time_offset_length[i] > 0)
> -us(current->time_offset_length[i], time_offset_value[i],
> -   0, MAX_UINT_BITS(current->time_offset_length[i]), 1, i);
> +is(current->time_offset_length[i], time_offset_value[i],
> +   MIN_INT_BITS(current->time_offset_length[i]),
> +   MAX_INT_BITS(current->time_offset_length[i]), 1, i);
> +else
> +infer(time_offset_value[i], 0);
>  }
>  }
>  
> 

LGTM.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] avformat/mxfenc: support XAVC long gop

2019-04-16 Thread Michael Niedermayer
On Wed, Apr 10, 2019 at 06:54:53PM -0300, James Almer wrote:
> On 4/10/2019 6:26 PM, Baptiste Coudurier wrote:
> >> On Apr 9, 2019, at 6:27 PM, James Almer  wrote:
> >>
> >> On 4/9/2019 9:40 PM, Baptiste Coudurier wrote:
> >>>
>  On Apr 9, 2019, at 5:24 PM, James Almer  wrote:
> 
>  On 4/9/2019 8:59 PM, Baptiste Coudurier wrote:
> >
> >> On Apr 9, 2019, at 4:51 PM, James Almer  wrote:
> >>
> >> On 4/9/2019 8:22 PM, Baptiste Coudurier wrote:
> >>> Hi James,
> >>>
>  On Apr 9, 2019, at 4:09 PM, James Almer  wrote:
> 
> > […]
> 
>  Ok so, the only fields you need from the sps are 
>  constraint_set_flags,
>  frame_mbs_only_flag, bit_depth_luma, profile_idc, level_idc and sar,
>  meaning you don't even need to parse the sps until the very end (sar 
>  is
>  the furthest value, and right at the beginning of vui_parameters).
>  I'd very much prefer if we can avoid making
>  ff_h264_decode_seq_parameter_set() avpriv and with it H264ParamSets 
>  part
>  of the ABI, so i think it's worth copying the required bitstream 
>  parsing
>  code at least until the beginning of vui_parameters. It was done for
>  hevc and av1, so it can be done for h264 as well.
> >>>
> >>> Since vui parsing is needed, that would be the entire 
> >>> "ff_h264_decode_seq_parameter_set()” function.
> >>
> >> If you only need up to sar, then yo don't need to parse the entire VUI.
> >
> > It still requires copying the entire 
> > ff_h264_decode_seq_parameter_set(), even though the sub functions are 
> > not needed. 
> >
> >>>
> >>> I disagree with the copying. I also disagree with the copying for 
> >>> AVC1 and HEVC btw.
> >>
> >> Using avpriv opens a whole can of worms that will be unpredictable in
> >> the future. Just look at recent commits like
> >> f4ea930a119298c6110ee4e3d24219a66e27e230 that started storing 
> >> previously
> >> skipped values. If hevc_pc was made avpriv for isombff/matroska muxing
> >> purposes and its structs part of the ABI, this wouldn't have been
> >> possible until a major bump.
> >
> > When did the sharing policy between avformat and avcodec (in the sense 
> > avformat using avcodec) change ?
> > It seems perfectly natural to me to have libavformat require the 
> > libavcodec version that it was compiled with,
> > and check it at runtime.
> 
>  More than one ffmpeg release will ship with libavcodec/libavformat
>  sharing the same soname. Backwards compatibility is expected, hence the
>  split between major, minor and micro, as you're meant to be able to drop
>  a newer libavcodec library, say for example ffmpeg 4.1's
>  libavcodec.58.so, and it should work with an existing libavformat.so.58
>  that was linked against ffmpeg 4.0's libavcodec.58.so.
> >>>
> >>> Sorry to repeat the question but when did that change ?
> >>
> >> I don't know if it ever changed to being with. It's been like this for
> >> as long as i remember, and i don't recall inter-library version checks
> >> that would take minor and micro into consideration (which would be
> >> needed to truly tie a given libavformat library with the exact
> >> libavcodec it was linked to) whereas ABI backwards compatibility
> >> considerations for inter-library stuff can be seen all across the
> >> codebase and git history.
> > 
> > It definitely changed, probably around the introduction of “avpriv” prefix.
> 
> I think that predates my arrival to the project. Someone else will have
> to chime in...

it possibly changed from "we dont care / we didnt think about it" in the 
distant past, iam not sure its very long ago.
But strange interdependancies on minor/micro versions that are outside
the established rules (https://semver.org/)
can cause surprises and problems to for example packagers for distros.
So i suggest to stay close to what most users of the libs / packagers do
expect and whould causes the least problems and surprise ...

Thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/5] avcodec/cbs_h2645: add helper macros for signed values

2019-04-16 Thread James Almer
On 4/16/2019 7:57 PM, Mark Thompson wrote:
> On 15/04/2019 22:17, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>>  libavcodec/cbs_h2645.c | 20 
>>  1 file changed, 20 insertions(+)
>>
>> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
>> index e74f8dce81..a205293b3c 100644
>> --- a/libavcodec/cbs_h2645.c
>> +++ b/libavcodec/cbs_h2645.c
>> @@ -255,6 +255,8 @@ static int cbs_write_se_golomb(CodedBitstreamContext 
>> *ctx, PutBitContext *pbc,
>>  #define flag(name) u(1, name, 0, 1)
>>  #define ue(name, range_min, range_max) \
>>  xue(name, current->name, range_min, range_max, 0)
>> +#define i(width, name, range_min, range_max) \
>> +xi(width, name, current->name, range_min, range_max, 0)
> 
> I know it's right, but defining "i" as a macro feels like a pretty terrible 
> idea in C :P

Eh, i guess :p. It at least didn't blow up here.

What would be best? s? su like in cbs_av1? Something else?

> 
>>  #define se(name, range_min, range_max) \
>>  xse(name, current->name, range_min, range_max, 0)
>>  
>> @@ -264,6 +266,8 @@ static int cbs_write_se_golomb(CodedBitstreamContext 
>> *ctx, PutBitContext *pbc,
>>  xu(1, name, current->name, 0, 1, subs, __VA_ARGS__)
>>  #define ues(name, range_min, range_max, subs, ...) \
>>  xue(name, current->name, range_min, range_max, subs, __VA_ARGS__)
>> +#define is(width, name, range_min, range_max, subs, ...) \
>> +xi(width, name, current->name, range_min, range_max, subs, 
>> __VA_ARGS__)
>>  #define ses(name, range_min, range_max, subs, ...) \
>>  xse(name, current->name, range_min, range_max, subs, __VA_ARGS__)
>>  
>> @@ -291,6 +295,13 @@ static int cbs_write_se_golomb(CodedBitstreamContext 
>> *ctx, PutBitContext *pbc,
>>   &value, range_min, range_max)); \
>>  var = value; \
>>  } while (0)
>> +#define xi(width, name, var, range_min, range_max, subs, ...) do { \
>> +int32_t value = range_min; \
>> +CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \
>> + SUBSCRIPTS(subs, __VA_ARGS__), \
>> + &value, range_min, range_max)); \
>> +var = value; \
>> +} while (0)
>>  #define xse(name, var, range_min, range_max, subs, ...) do { \
>>  int32_t value = range_min; \
>>  CHECK(cbs_read_se_golomb(ctx, rw, #name, \
>> @@ -338,6 +349,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
>> *gbc)
>>  #undef READWRITE
>>  #undef RWContext
>>  #undef xu
>> +#undef xi
>>  #undef xue
>>  #undef xse
>>  #undef infer
>> @@ -362,6 +374,12 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
>> *gbc)
>>SUBSCRIPTS(subs, __VA_ARGS__), \
>>value, range_min, range_max)); \
>>  } while (0)
>> +#define xi(width, name, var, range_min, range_max, subs, ...) do { \
>> +int32_t value = var; \
>> +CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \
>> +  SUBSCRIPTS(subs, __VA_ARGS__), \
>> +  value, range_min, range_max)); \
>> +} while (0)
>>  #define xse(name, var, range_min, range_max, subs, ...) do { \
>>  int32_t value = var; \
>>  CHECK(cbs_write_se_golomb(ctx, rw, #name, \
>> @@ -402,9 +420,11 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
>> *gbc)
>>  #undef READWRITE
>>  #undef RWContext
>>  #undef xu
>> +#undef xi
>>  #undef xue
>>  #undef xse
>>  #undef u
>> +#undef i
>>  #undef flag
>>  #undef ue
>>  #undef se
>>
> 
> LGTM.
> 
> Thanks,
> 
> - Mark
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 3/5] avcodec/cbs_h264: fix storage type for time_offset in Pic Timing SEI

2019-04-16 Thread Mark Thompson
On 15/04/2019 22:17, James Almer wrote:
> The spec defines it as a signed value.
> 
> Signed-off-by: James Almer 
> ---
> The only sample i could find with time_offset values it's in the fate suite,
> and in all cases it's 0.
> 
>  libavcodec/cbs_h264.h | 2 +-
>  libavcodec/cbs_h264_syntax_template.c | 5 +++--
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
> index 92277e4750..b5eee7c370 100644
> --- a/libavcodec/cbs_h264.h
> +++ b/libavcodec/cbs_h264.h
> @@ -253,7 +253,7 @@ typedef struct H264RawSEIPicTimestamp {
>  uint8_t minutes_value;
>  uint8_t hours_flag;
>  uint8_t hours_value;
> -uint32_t time_offset;
> +int32_t time_offset;
>  } H264RawSEIPicTimestamp;
>  
>  typedef struct H264RawSEIPicTiming {
> diff --git a/libavcodec/cbs_h264_syntax_template.c 
> b/libavcodec/cbs_h264_syntax_template.c
> index 4da4c5da67..07b4cddb5e 100644
> --- a/libavcodec/cbs_h264_syntax_template.c
> +++ b/libavcodec/cbs_h264_syntax_template.c
> @@ -592,8 +592,9 @@ static int FUNC(sei_pic_timestamp)(CodedBitstreamContext 
> *ctx, RWContext *rw,
>  time_offset_length = 24;
>  
>  if (time_offset_length > 0)
> -u(time_offset_length, time_offset,
> -  0, MAX_UINT_BITS(time_offset_length));
> +i(time_offset_length, time_offset,
> +  MIN_INT_BITS(time_offset_length),
> +  MAX_INT_BITS(time_offset_length));
>  else
>  infer(time_offset, 0);
>  
> 

LGTM.

I'm glad the standard gets plenty of use out of that i(v) syntax element type 
definition.

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/5] avcodec/cbs_h2645: add helper macros for signed values

2019-04-16 Thread Mark Thompson
On 15/04/2019 22:17, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  libavcodec/cbs_h2645.c | 20 
>  1 file changed, 20 insertions(+)
> 
> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> index e74f8dce81..a205293b3c 100644
> --- a/libavcodec/cbs_h2645.c
> +++ b/libavcodec/cbs_h2645.c
> @@ -255,6 +255,8 @@ static int cbs_write_se_golomb(CodedBitstreamContext 
> *ctx, PutBitContext *pbc,
>  #define flag(name) u(1, name, 0, 1)
>  #define ue(name, range_min, range_max) \
>  xue(name, current->name, range_min, range_max, 0)
> +#define i(width, name, range_min, range_max) \
> +xi(width, name, current->name, range_min, range_max, 0)

I know it's right, but defining "i" as a macro feels like a pretty terrible 
idea in C :P

>  #define se(name, range_min, range_max) \
>  xse(name, current->name, range_min, range_max, 0)
>  
> @@ -264,6 +266,8 @@ static int cbs_write_se_golomb(CodedBitstreamContext 
> *ctx, PutBitContext *pbc,
>  xu(1, name, current->name, 0, 1, subs, __VA_ARGS__)
>  #define ues(name, range_min, range_max, subs, ...) \
>  xue(name, current->name, range_min, range_max, subs, __VA_ARGS__)
> +#define is(width, name, range_min, range_max, subs, ...) \
> +xi(width, name, current->name, range_min, range_max, subs, 
> __VA_ARGS__)
>  #define ses(name, range_min, range_max, subs, ...) \
>  xse(name, current->name, range_min, range_max, subs, __VA_ARGS__)
>  
> @@ -291,6 +295,13 @@ static int cbs_write_se_golomb(CodedBitstreamContext 
> *ctx, PutBitContext *pbc,
>   &value, range_min, range_max)); \
>  var = value; \
>  } while (0)
> +#define xi(width, name, var, range_min, range_max, subs, ...) do { \
> +int32_t value = range_min; \
> +CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \
> + SUBSCRIPTS(subs, __VA_ARGS__), \
> + &value, range_min, range_max)); \
> +var = value; \
> +} while (0)
>  #define xse(name, var, range_min, range_max, subs, ...) do { \
>  int32_t value = range_min; \
>  CHECK(cbs_read_se_golomb(ctx, rw, #name, \
> @@ -338,6 +349,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
> *gbc)
>  #undef READWRITE
>  #undef RWContext
>  #undef xu
> +#undef xi
>  #undef xue
>  #undef xse
>  #undef infer
> @@ -362,6 +374,12 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
> *gbc)
>SUBSCRIPTS(subs, __VA_ARGS__), \
>value, range_min, range_max)); \
>  } while (0)
> +#define xi(width, name, var, range_min, range_max, subs, ...) do { \
> +int32_t value = var; \
> +CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \
> +  SUBSCRIPTS(subs, __VA_ARGS__), \
> +  value, range_min, range_max)); \
> +} while (0)
>  #define xse(name, var, range_min, range_max, subs, ...) do { \
>  int32_t value = var; \
>  CHECK(cbs_write_se_golomb(ctx, rw, #name, \
> @@ -402,9 +420,11 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
> *gbc)
>  #undef READWRITE
>  #undef RWContext
>  #undef xu
> +#undef xi
>  #undef xue
>  #undef xse
>  #undef u
> +#undef i
>  #undef flag
>  #undef ue
>  #undef se
> 

LGTM.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/cbs: add helper functions and macros to read and write signed values

2019-04-16 Thread James Almer
On 4/16/2019 7:45 PM, Mark Thompson wrote:
> On 15/04/2019 22:17, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>>  libavcodec/cbs.c  | 79 +++
>>  libavcodec/cbs_internal.h | 20 +-
>>  2 files changed, 98 insertions(+), 1 deletion(-)
> 
> Looks like a sensible addition, some comments below.
> 
>> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
>> index c388be896b..726bd582f5 100644
>> --- a/libavcodec/cbs.c
>> +++ b/libavcodec/cbs.c
>> @@ -504,6 +504,85 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, 
>> PutBitContext *pbc,
>>  return 0;
>>  }
>>  
>> +int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc,
>> +   int width, const char *name,
>> +   const int *subscripts, int32_t *write_to,
>> +   int32_t range_min, int32_t range_max)
>> +{
>> +int32_t value;
>> +int position;
>> +
>> +av_assert0(width > 0 && width <= 32);
>> +
>> +if (get_bits_left(gbc) < width) {
>> +av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid value at "
>> +   "%s: bitstream ended.\n", name);
>> +return AVERROR_INVALIDDATA;
>> +}
>> +
>> +if (ctx->trace_enable)
>> +position = get_bits_count(gbc);
>> +
>> +value = get_sbits_long(gbc, width);
>> +
>> +if (ctx->trace_enable) {
>> +char bits[33];
>> +int i;
>> +for (i = 0; i < width; i++)
>> +bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';
> 
> 1 << 31 is undefined behaviour for 32-bit int.
> 
> The unsigned versions are careful to right-shift unsigned values to avoid 
> overflow problems; a possible fix might be to strip the sign bit and then do 
> the same thing.

Would "1U << (width - i - 1)" be enough?

> 
>> +bits[i] = 0;
>> +
>> +ff_cbs_trace_syntax_element(ctx, position, name, subscripts,
>> +bits, value);
>> +}
>> +
>> +if (value < range_min || value > range_max) {
>> +av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: "
>> +   "%"PRId32", but must be in [%"PRId32",%"PRId32"].\n",
>> +   name, value, range_min, range_max);
>> +return AVERROR_INVALIDDATA;
>> +}
>> +
>> +*write_to = value;
>> +return 0;
>> +}
>> +
>> +int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc,
>> +int width, const char *name,
>> +const int *subscripts, int32_t value,
>> +int32_t range_min, int32_t range_max)
>> +{
>> +av_assert0(width > 0 && width <= 32);
>> +
>> +if (value < range_min || value > range_max) {
>> +av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: "
>> +   "%"PRId32", but must be in [%"PRId32",%"PRId32"].\n",
>> +   name, value, range_min, range_max);
>> +return AVERROR_INVALIDDATA;
>> +}
>> +
>> +if (put_bits_left(pbc) < width)
>> +return AVERROR(ENOSPC);
>> +
>> +if (ctx->trace_enable) {
>> +char bits[33];
>> +int i;
>> +for (i = 0; i < width; i++)
>> +bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';
> 
> As above.
> 
>> +bits[i] = 0;
>> +
>> +ff_cbs_trace_syntax_element(ctx, put_bits_count(pbc),
>> +name, subscripts, bits, value);
>> +}
>> +
>> +if (width < 32)
>> +put_sbits(pbc, width, value);
>> +else
>> +put_bits32(pbc, value);
>> +
>> +return 0;
>> +}
>> +
>>  
>>  int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx,
>>CodedBitstreamUnit *unit,
>> diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
>> index 53f2e5d187..6ab85679dd 100644
>> --- a/libavcodec/cbs_internal.h
>> +++ b/libavcodec/cbs_internal.h
>> @@ -81,10 +81,28 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, 
>> PutBitContext *pbc,
>>const int *subscripts, uint32_t value,
>>uint32_t range_min, uint32_t range_max);
>>  
>> -// The largest value representable in N bits, suitable for use as
>> +int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc,
>> +   int width, const char *name,
>> +   const int *subscripts, int32_t *write_to,
>> +   int32_t range_min, int32_t range_max);
>> +
>> +int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc,
>> +int width, const char *name,
>> +const int *subscripts, int32_t value,
>> +int32_t range_min, int32_t range_max);
>> +
>> +// The largest unsigned value representable in N bits, suitable for use as
>>  // range_max in the above functions.
>>  #define MAX_UINT_BITS(length) ((UINT64_C(1) << (length)) - 1)
>>  
>> +// The largest signed value representable in N b

Re: [FFmpeg-devel] [PATCH] libavfilter/f_select: response file support

2019-04-16 Thread Carl Eugen Hoyos
2019-04-16 19:14 GMT+02:00, Jonathan Gilbert :
> Hello :-)
>
> I had a project recently where I wanted to externally specify a list
> of specific frame numbers to drop. I understand this can be done with
> select expressions like "not(eq(n,45)+eq(n,47)+eq(n,75))", but in my
> case I wanted to drop nearly 16,000 frames, which would have required
> a command-line over 250 KB in size. I chose a different approach: I
> have added functionality to f_select.c so that you can specify the
> list of frames you want to include/exclude in an external response
> file. I have successfully used this code for my project, and thought I
> might submit it up to for consideration. :-)
>
> I've never submitted a patch in this format before, I hope I'm doing
> this correctly.

This is definitely not the only issue:
Instead of using malloc() and friends, please see libavutil/mem.h
for the appropriate functions.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] libavfilter/f_select: response file support

2019-04-16 Thread Michael Niedermayer
On Tue, Apr 16, 2019 at 12:14:13PM -0500, Jonathan Gilbert wrote:
> Hello :-)
> 
> I had a project recently where I wanted to externally specify a list
> of specific frame numbers to drop. I understand this can be done with
> select expressions like "not(eq(n,45)+eq(n,47)+eq(n,75))", but in my
> case I wanted to drop nearly 16,000 frames, which would have required
> a command-line over 250 KB in size. I chose a different approach: I
> have added functionality to f_select.c so that you can specify the
> list of frames you want to include/exclude in an external response
> file. I have successfully used this code for my project, and thought I
> might submit it up to for consideration. :-)
> 
> I've never submitted a patch in this format before, I hope I'm doing
> this correctly.
> 
> Thanks very much,
> 
> Jonathan Gilbert

Applying: libavfilter/f_select: response file support
error: corrupt patch at line 51
error: could not build fake ancestor

please make sure your MUA doesnt wrap long lines or attach the patch

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/cbs: add helper functions and macros to read and write signed values

2019-04-16 Thread Mark Thompson
On 15/04/2019 22:17, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  libavcodec/cbs.c  | 79 +++
>  libavcodec/cbs_internal.h | 20 +-
>  2 files changed, 98 insertions(+), 1 deletion(-)

Looks like a sensible addition, some comments below.

> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index c388be896b..726bd582f5 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -504,6 +504,85 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, 
> PutBitContext *pbc,
>  return 0;
>  }
>  
> +int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc,
> +   int width, const char *name,
> +   const int *subscripts, int32_t *write_to,
> +   int32_t range_min, int32_t range_max)
> +{
> +int32_t value;
> +int position;
> +
> +av_assert0(width > 0 && width <= 32);
> +
> +if (get_bits_left(gbc) < width) {
> +av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid value at "
> +   "%s: bitstream ended.\n", name);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +if (ctx->trace_enable)
> +position = get_bits_count(gbc);
> +
> +value = get_sbits_long(gbc, width);
> +
> +if (ctx->trace_enable) {
> +char bits[33];
> +int i;
> +for (i = 0; i < width; i++)
> +bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';

1 << 31 is undefined behaviour for 32-bit int.

The unsigned versions are careful to right-shift unsigned values to avoid 
overflow problems; a possible fix might be to strip the sign bit and then do 
the same thing.

> +bits[i] = 0;
> +
> +ff_cbs_trace_syntax_element(ctx, position, name, subscripts,
> +bits, value);
> +}
> +
> +if (value < range_min || value > range_max) {
> +av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: "
> +   "%"PRId32", but must be in [%"PRId32",%"PRId32"].\n",
> +   name, value, range_min, range_max);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +*write_to = value;
> +return 0;
> +}
> +
> +int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc,
> +int width, const char *name,
> +const int *subscripts, int32_t value,
> +int32_t range_min, int32_t range_max)
> +{
> +av_assert0(width > 0 && width <= 32);
> +
> +if (value < range_min || value > range_max) {
> +av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: "
> +   "%"PRId32", but must be in [%"PRId32",%"PRId32"].\n",
> +   name, value, range_min, range_max);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +if (put_bits_left(pbc) < width)
> +return AVERROR(ENOSPC);
> +
> +if (ctx->trace_enable) {
> +char bits[33];
> +int i;
> +for (i = 0; i < width; i++)
> +bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';

As above.

> +bits[i] = 0;
> +
> +ff_cbs_trace_syntax_element(ctx, put_bits_count(pbc),
> +name, subscripts, bits, value);
> +}
> +
> +if (width < 32)
> +put_sbits(pbc, width, value);
> +else
> +put_bits32(pbc, value);
> +
> +return 0;
> +}
> +
>  
>  int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx,
>CodedBitstreamUnit *unit,
> diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
> index 53f2e5d187..6ab85679dd 100644
> --- a/libavcodec/cbs_internal.h
> +++ b/libavcodec/cbs_internal.h
> @@ -81,10 +81,28 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, 
> PutBitContext *pbc,
>const int *subscripts, uint32_t value,
>uint32_t range_min, uint32_t range_max);
>  
> -// The largest value representable in N bits, suitable for use as
> +int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc,
> +   int width, const char *name,
> +   const int *subscripts, int32_t *write_to,
> +   int32_t range_min, int32_t range_max);
> +
> +int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc,
> +int width, const char *name,
> +const int *subscripts, int32_t value,
> +int32_t range_min, int32_t range_max);
> +
> +// The largest unsigned value representable in N bits, suitable for use as
>  // range_max in the above functions.
>  #define MAX_UINT_BITS(length) ((UINT64_C(1) << (length)) - 1)
>  
> +// The largest signed value representable in N bits, suitable for use as
> +// range_max in the above functions.
> +#define MAX_INT_BITS(length) ((INT64_C(1) << (length - 1)) - 1)

Not so good for, say, MAX_INT_BITS(a ? b : c).

> +
> +// The smallest signed value representable in N

Re: [FFmpeg-devel] [PATCH V1] lavf/oggparsevorbis: Fix change the case of metadata keys issue

2019-04-16 Thread Michael Niedermayer
On Tue, Apr 16, 2019 at 09:33:08AM +0800, myp...@gmail.com wrote:
> On Tue, Apr 16, 2019 at 5:51 AM Michael Niedermayer
>  wrote:
> >
> > On Mon, Apr 15, 2019 at 09:58:30AM +0800, Jun Zhao wrote:
> > > From: Jun Zhao 
> > >
> > > The spec in https://xiph.org/vorbis/doc/v-comment.html states that
> > > the metadata keys are case-insensitive, so don't change the case
> > > and update the fate test case.
> > >
> > > Fix #7784
> > >
> > > Signed-off-by: Jun Zhao 
> > > ---
> > >  libavformat/oggparsevorbis.c |9 -
> > >  tests/ref/fate/limited_input_seek|2 +-
> > >  tests/ref/fate/limited_input_seek-copyts |2 +-
> > >  3 files changed, 6 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
> > > index bcfd246..c3c8d38 100644
> > > --- a/libavformat/oggparsevorbis.c
> > > +++ b/libavformat/oggparsevorbis.c
> > > @@ -44,7 +44,7 @@ static int ogm_chapter(AVFormatContext *as, uint8_t 
> > > *key, uint8_t *val)
> > >  int i, cnum, h, m, s, ms, keylen = strlen(key);
> > >  AVChapter *chapter = NULL;
> > >
> > > -if (keylen < 9 || sscanf(key, "CHAPTER%03d", &cnum) != 1)
> > > +if (keylen < 9 || (av_strcasecmp(key, "CHAPTER")!=0 && sscanf(key+7, 
> > > "%03d", &cnum) != 1))
> >
> > this looks a bit odd, shouldnt this use av_strncasecmp() ?
> >
> It's  in order to be compatible with the fate test case
> vorbis-1833-chapthers, in this test,
> we use lower case in test clip but check upper case in the code.

av_strcasecmp() will only succeed if the string ends after "CHAPTER" and
contains no number which is why av_strncasecmp() feels like more effective.
The problem is ultimatle that keylen is at this point >= 9 while
the only case where av_strcasecmp with "CHAPTER" == 0 is with a
keylen of 7. Thats tricky to achieve ;)

Or said differently this code is not a case insensitive version of the
previous 


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] mxfdec: Constrain run-in to 64k

2019-04-16 Thread Michael Niedermayer
On Tue, Apr 16, 2019 at 12:03:48AM +0200, Tomas Härdin wrote:
> mån 2019-04-15 klockan 23:03 +0200 skrev Marton Balint:
> > 
> > On Mon, 15 Apr 2019, Tomas Härdin wrote:
> > 
> > > This isn't likely to be a huge problem, but it allows us to reason more
> > > about run-in. It also exposes my gripe about klv_read_packet() using
> > > mxf_read_sync()
> > 
> > I would allow 65536 bytes as well for run-in, even if that is against the 
> > standard. The MXF book for example says this:
> > 
> > run-in - a sequence of up to 65536 bytes at the front of the file that 
> > preceeds the first partition pack.
> 

> So I see. Hm.. We could report that to the publisher as an error in the
> book. But I doubt they'd do a reprint for such a minor error.

But if a reprint ever happens it is more likely to contain reported
issues than unreported ones. So i agree its a good idea to report it

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cbs_av1: add support for Scalability Metadata

2019-04-16 Thread James Almer
On 4/16/2019 7:05 PM, Mark Thompson wrote:
> On 14/04/2019 23:04, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>> This will make the AV1RawObu struct weigh about ~3kb instead of ~1kb.
>>
>>  libavcodec/av1.h | 33 
>>  libavcodec/cbs_av1.h | 15 +-
>>  libavcodec/cbs_av1_syntax_template.c | 45 ++--
>>  3 files changed, 90 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavcodec/av1.h b/libavcodec/av1.h
>> index f2ec39c86b..6c0e32485b 100644
>> --- a/libavcodec/av1.h
>> +++ b/libavcodec/av1.h
>> @@ -127,4 +127,37 @@ enum {
>>  AV1_CSP_COLOCATED = 2, // -> AVCHROMA_LOC_TOPLEFT.
>>  };
>>  
>> +// Scalability modes (section 6.7.5)
>> +enum {
>> +AV1_SCALABILITY_L1T2 = 0,
>> +AV1_SCALABILITY_L1T3 = 1,
>> +AV1_SCALABILITY_L2T1 = 2,
>> +AV1_SCALABILITY_L2T2 = 3,
>> +AV1_SCALABILITY_L2T3 = 4,
>> +AV1_SCALABILITY_S2T1 = 5,
>> +AV1_SCALABILITY_S2T2 = 6,
>> +AV1_SCALABILITY_S2T3 = 7,
>> +AV1_SCALABILITY_L2T1h = 8,
>> +AV1_SCALABILITY_L2T2h = 9,
>> +AV1_SCALABILITY_L2T3h = 10,
>> +AV1_SCALABILITY_S2T1h = 11,
>> +AV1_SCALABILITY_S2T2h = 12,
>> +AV1_SCALABILITY_S2T3h = 13,
>> +AV1_SCALABILITY_SS = 14,
>> +AV1_SCALABILITY_L3T1 = 15,
>> +AV1_SCALABILITY_L3T2 = 16,
>> +AV1_SCALABILITY_L3T3 = 17,
>> +AV1_SCALABILITY_S3T1 = 18,
>> +AV1_SCALABILITY_S3T2 = 19,
>> +AV1_SCALABILITY_S3T3 = 20,
>> +AV1_SCALABILITY_L3T2_KEY = 21,
>> +AV1_SCALABILITY_L3T3_KEY = 22,
>> +AV1_SCALABILITY_L4T5_KEY = 23,
>> +AV1_SCALABILITY_L4T7_KEY = 24,
>> +AV1_SCALABILITY_L3T2_KEY_SHIFT = 25,
>> +AV1_SCALABILITY_L3T3_KEY_SHIFT = 26,
>> +AV1_SCALABILITY_L4T5_KEY_SHIFT = 27,
>> +AV1_SCALABILITY_L4T7_KEY_SHIFT = 28,
>> +};
>> +
>>  #endif /* AVCODEC_AV1_H */
>> diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
>> index e799964b72..1fb668ada4 100644
>> --- a/libavcodec/cbs_av1.h
>> +++ b/libavcodec/cbs_av1.h
>> @@ -325,7 +325,20 @@ typedef struct AV1RawMetadataHDRMDCV {
>>  
>>  typedef struct AV1RawMetadataScalability {
>>  uint8_t scalability_mode_idc;
>> -// TODO: more stuff.
>> +uint8_t spatial_layers_cnt_minus_1;
>> +uint8_t spatial_layer_dimensions_present_flag;
>> +uint8_t spatial_layer_description_present_flag;
>> +uint8_t temporal_group_description_present_flag;
>> +uint8_t scalability_structure_reserved_3bits;
>> +uint16_t spatial_layer_max_width[4];
>> +uint16_t spatial_layer_max_height[4];
>> +uint8_t spatial_layer_ref_id[4];
>> +uint8_t temporal_group_size;
>> +uint8_t temporal_group_temporal_id[255];
>> +uint8_t temporal_group_temporal_switching_up_point_flag[255];
>> +uint8_t temporal_group_spatial_switching_up_point_flag[255];
>> +uint8_t temporal_group_ref_cnt[255];
>> +uint8_t temporal_group_ref_pic_diff[255][7];
>>  } AV1RawMetadataScalability;
>>  
>>  typedef struct AV1RawMetadataITUTT35 {
>> diff --git a/libavcodec/cbs_av1_syntax_template.c 
>> b/libavcodec/cbs_av1_syntax_template.c
>> index 0e019aa113..ef48173470 100644
>> --- a/libavcodec/cbs_av1_syntax_template.c
>> +++ b/libavcodec/cbs_av1_syntax_template.c
>> @@ -1653,12 +1653,53 @@ static int 
>> FUNC(metadata_hdr_mdcv)(CodedBitstreamContext *ctx, RWContext *rw,
>>  return 0;
>>  }
>>  
>> +static int FUNC(scalability_structure)(CodedBitstreamContext *ctx, 
>> RWContext *rw,
>> +   AV1RawMetadataScalability *current)
>> +{
>> +int err, i, j;
>> +
>> +fb(2, spatial_layers_cnt_minus_1);
>> +flag(spatial_layer_dimensions_present_flag);
>> +flag(spatial_layer_description_present_flag);
>> +flag(temporal_group_description_present_flag);
>> +fc(3, scalability_structure_reserved_3bits, 0, 0);
>> +if (current->spatial_layer_dimensions_present_flag) {
>> +for (i = 0; i <= current->spatial_layers_cnt_minus_1; i++) {
>> +fbs(16, spatial_layer_max_width[i], 1, i);
>> +fbs(16, spatial_layer_max_height[i], 1, i);
> 
> Can we verify against the "must not be larger than max_frame_*_minus_1 + 1" 
> constraint here?  (I think a sequence header should be available.)

Ah, good catch. Added a check for that.
> 
>> +}
>> +}
>> +if (current->spatial_layer_description_present_flag) {
>> +for (i = 0; i <= current->spatial_layers_cnt_minus_1; i++)
>> +fbs(8, spatial_layer_ref_id[i], 1, i);
>> +}
>> +if (current->temporal_group_description_present_flag) {
>> +fb(8, temporal_group_size);
>> +for (i = 0; i < current->temporal_group_size; i++) {
>> +fbs(3, temporal_group_temporal_id[i], 1, i);
>> +flags(temporal_group_temporal_switching_up_point_flag[i], 1, i);
>> +flags(temporal_group_spatial_switching_up_point_flag[i], 1, i);
>> +fbs(3, temporal_group_ref_cnt[i], 1, i);
>> +for (j = 0; j < current->tem

[FFmpeg-devel] [PATCH 2/2] avformat/aadec: Check for scanf() failure

2019-04-16 Thread Michael Niedermayer
Fixes: use of uninitialized variables
Fixes: blank.aa

Found-by: Chamal De Silva 
Signed-off-by: Michael Niedermayer 
---
 libavformat/aadec.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavformat/aadec.c b/libavformat/aadec.c
index dc94061dcf..b9dd51ebfc 100644
--- a/libavformat/aadec.c
+++ b/libavformat/aadec.c
@@ -85,6 +85,7 @@ static int aa_read_header(AVFormatContext *s)
 AADemuxContext *c = s->priv_data;
 AVIOContext *pb = s->pb;
 AVStream *st;
+int ret;
 
 /* parse .aa header */
 avio_skip(pb, 4); // file size
@@ -118,8 +119,12 @@ static int aa_read_header(AVFormatContext *s)
 header_seed = atoi(val);
 } else if (!strcmp(key, "HeaderKey")) { // this looks like "1234567890 
1234567890 1234567890 1234567890"
 av_log(s, AV_LOG_DEBUG, "HeaderKey is <%s>\n", val);
-sscanf(val, "%"SCNu32"%"SCNu32"%"SCNu32"%"SCNu32,
+
+ret = sscanf(val, "%"SCNu32"%"SCNu32"%"SCNu32"%"SCNu32,
&header_key_part[0], &header_key_part[1], 
&header_key_part[2], &header_key_part[3]);
+if (ret != 4)
+return AVERROR_INVALIDDATA;
+
 for (idx = 0; idx < 4; idx++) {
 AV_WB32(&header_key[idx * 4], header_key_part[idx]); // 
convert each part to BE!
 }
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] avformat/mov: Skip stsd adjustment without chunks

2019-04-16 Thread Michael Niedermayer
Fixes: Assertion failure
Fixes: 
clusterfuzz-testcase-minimized-media_pipeline_integration_fuzzer-5683096400822272

Found-by: Clusterfuzz
Reported-by: Dan Sanders 
Signed-off-by: Michael Niedermayer 
---
 libavformat/mov.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index d5ce077e63..a87571b7d1 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7872,6 +7872,7 @@ static int mov_seek_stream(AVFormatContext *s, AVStream 
*st, int64_t timestamp,
 }
 
 /* adjust stsd index */
+if (sc->chunk_count) {
 time_sample = 0;
 for (i = 0; i < sc->stsc_count; i++) {
 int64_t next = time_sample + mov_get_stsc_samples(sc, i);
@@ -7883,6 +7884,7 @@ static int mov_seek_stream(AVFormatContext *s, AVStream 
*st, int64_t timestamp,
 av_assert0(next == (int)next);
 time_sample = next;
 }
+}
 
 return sample;
 }
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/h264_ps: fix storage size for offset_for_ref_frame

2019-04-16 Thread Baptiste Coudurier
> On Apr 16, 2019, at 3:01 PM, James Almer  wrote:
> 
> On 4/16/2019 6:48 PM, Mark Thompson wrote:
>> On 11/04/2019 04:10, James Almer wrote:
>>> On 4/10/2019 3:30 PM, James Almer wrote:
 The spec defines the valid range of values to be INT32_MIN + 1 to 
 INT32_MAX, inclusive.
 
 Signed-off-by: James Almer 
 ---
 A good example of why making offsets and sizes of structs like this tied 
 to the
 ABI is not a good idea.
 
 libavcodec/h264_ps.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/libavcodec/h264_ps.h b/libavcodec/h264_ps.h
 index e967b9cbcf..9014326dfb 100644
 --- a/libavcodec/h264_ps.h
 +++ b/libavcodec/h264_ps.h
 @@ -81,7 +81,7 @@ typedef struct SPS {
 uint32_t num_units_in_tick;
 uint32_t time_scale;
 int fixed_frame_rate_flag;
 -short offset_for_ref_frame[256]; // FIXME dyn aloc?
 +int32_t offset_for_ref_frame[256];
>>> 
>>> The doxy for get_se_golomb() doesn't mention the range of values it can
>>> handle, but seeing there's also a get_se_golomb_long(), I guess the
>>> relevant line in h264_ps.c should now use the latter instead?
>> 
>> I think it's correct to do that.  Seems highly unlikely anyone would ever 
>> hit it outside a conformance-checking context, though - using anything other 
>> than pic_order_cnt_type 0 for nontrivial reference structures is madness.
>> 
 int bitstream_restriction_flag;
 int num_reorder_frames;
 int scaling_matrix_present;
>> 
>> There are some other fields with int32_t range which are using 
>> get_se_golomb() - e.g. offset_for_non_ref_pic.  I guess they should use 
>> get_se_golomb_long() as above.  They're also plain ints - do they want to be 
>> explicitly int32_t?
> 
> It's wildly inconsistent. There are both scalar values and arrays as
> uint32_t, int, and unsigned it, but in all cases they can store the
> correct range of values, so IMO, not worth changing unless the whole
> structs are made consistent, like you did with the CBS ones.

Sounds like a good opportunity to make the whole structs consistent.

—
Baptiste



signature.asc
Description: Message signed with OpenPGP
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cbs_av1: add support for Scalability Metadata

2019-04-16 Thread Mark Thompson
On 14/04/2019 23:04, James Almer wrote:
> Signed-off-by: James Almer 
> ---
> This will make the AV1RawObu struct weigh about ~3kb instead of ~1kb.
> 
>  libavcodec/av1.h | 33 
>  libavcodec/cbs_av1.h | 15 +-
>  libavcodec/cbs_av1_syntax_template.c | 45 ++--
>  3 files changed, 90 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/av1.h b/libavcodec/av1.h
> index f2ec39c86b..6c0e32485b 100644
> --- a/libavcodec/av1.h
> +++ b/libavcodec/av1.h
> @@ -127,4 +127,37 @@ enum {
>  AV1_CSP_COLOCATED = 2, // -> AVCHROMA_LOC_TOPLEFT.
>  };
>  
> +// Scalability modes (section 6.7.5)
> +enum {
> +AV1_SCALABILITY_L1T2 = 0,
> +AV1_SCALABILITY_L1T3 = 1,
> +AV1_SCALABILITY_L2T1 = 2,
> +AV1_SCALABILITY_L2T2 = 3,
> +AV1_SCALABILITY_L2T3 = 4,
> +AV1_SCALABILITY_S2T1 = 5,
> +AV1_SCALABILITY_S2T2 = 6,
> +AV1_SCALABILITY_S2T3 = 7,
> +AV1_SCALABILITY_L2T1h = 8,
> +AV1_SCALABILITY_L2T2h = 9,
> +AV1_SCALABILITY_L2T3h = 10,
> +AV1_SCALABILITY_S2T1h = 11,
> +AV1_SCALABILITY_S2T2h = 12,
> +AV1_SCALABILITY_S2T3h = 13,
> +AV1_SCALABILITY_SS = 14,
> +AV1_SCALABILITY_L3T1 = 15,
> +AV1_SCALABILITY_L3T2 = 16,
> +AV1_SCALABILITY_L3T3 = 17,
> +AV1_SCALABILITY_S3T1 = 18,
> +AV1_SCALABILITY_S3T2 = 19,
> +AV1_SCALABILITY_S3T3 = 20,
> +AV1_SCALABILITY_L3T2_KEY = 21,
> +AV1_SCALABILITY_L3T3_KEY = 22,
> +AV1_SCALABILITY_L4T5_KEY = 23,
> +AV1_SCALABILITY_L4T7_KEY = 24,
> +AV1_SCALABILITY_L3T2_KEY_SHIFT = 25,
> +AV1_SCALABILITY_L3T3_KEY_SHIFT = 26,
> +AV1_SCALABILITY_L4T5_KEY_SHIFT = 27,
> +AV1_SCALABILITY_L4T7_KEY_SHIFT = 28,
> +};
> +
>  #endif /* AVCODEC_AV1_H */
> diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
> index e799964b72..1fb668ada4 100644
> --- a/libavcodec/cbs_av1.h
> +++ b/libavcodec/cbs_av1.h
> @@ -325,7 +325,20 @@ typedef struct AV1RawMetadataHDRMDCV {
>  
>  typedef struct AV1RawMetadataScalability {
>  uint8_t scalability_mode_idc;
> -// TODO: more stuff.
> +uint8_t spatial_layers_cnt_minus_1;
> +uint8_t spatial_layer_dimensions_present_flag;
> +uint8_t spatial_layer_description_present_flag;
> +uint8_t temporal_group_description_present_flag;
> +uint8_t scalability_structure_reserved_3bits;
> +uint16_t spatial_layer_max_width[4];
> +uint16_t spatial_layer_max_height[4];
> +uint8_t spatial_layer_ref_id[4];
> +uint8_t temporal_group_size;
> +uint8_t temporal_group_temporal_id[255];
> +uint8_t temporal_group_temporal_switching_up_point_flag[255];
> +uint8_t temporal_group_spatial_switching_up_point_flag[255];
> +uint8_t temporal_group_ref_cnt[255];
> +uint8_t temporal_group_ref_pic_diff[255][7];
>  } AV1RawMetadataScalability;
>  
>  typedef struct AV1RawMetadataITUTT35 {
> diff --git a/libavcodec/cbs_av1_syntax_template.c 
> b/libavcodec/cbs_av1_syntax_template.c
> index 0e019aa113..ef48173470 100644
> --- a/libavcodec/cbs_av1_syntax_template.c
> +++ b/libavcodec/cbs_av1_syntax_template.c
> @@ -1653,12 +1653,53 @@ static int 
> FUNC(metadata_hdr_mdcv)(CodedBitstreamContext *ctx, RWContext *rw,
>  return 0;
>  }
>  
> +static int FUNC(scalability_structure)(CodedBitstreamContext *ctx, RWContext 
> *rw,
> +   AV1RawMetadataScalability *current)
> +{
> +int err, i, j;
> +
> +fb(2, spatial_layers_cnt_minus_1);
> +flag(spatial_layer_dimensions_present_flag);
> +flag(spatial_layer_description_present_flag);
> +flag(temporal_group_description_present_flag);
> +fc(3, scalability_structure_reserved_3bits, 0, 0);
> +if (current->spatial_layer_dimensions_present_flag) {
> +for (i = 0; i <= current->spatial_layers_cnt_minus_1; i++) {
> +fbs(16, spatial_layer_max_width[i], 1, i);
> +fbs(16, spatial_layer_max_height[i], 1, i);

Can we verify against the "must not be larger than max_frame_*_minus_1 + 1" 
constraint here?  (I think a sequence header should be available.)

> +}
> +}
> +if (current->spatial_layer_description_present_flag) {
> +for (i = 0; i <= current->spatial_layers_cnt_minus_1; i++)
> +fbs(8, spatial_layer_ref_id[i], 1, i);
> +}
> +if (current->temporal_group_description_present_flag) {
> +fb(8, temporal_group_size);
> +for (i = 0; i < current->temporal_group_size; i++) {
> +fbs(3, temporal_group_temporal_id[i], 1, i);
> +flags(temporal_group_temporal_switching_up_point_flag[i], 1, i);
> +flags(temporal_group_spatial_switching_up_point_flag[i], 1, i);
> +fbs(3, temporal_group_ref_cnt[i], 1, i);
> +for (j = 0; j < current->temporal_group_ref_cnt[i]; j++) {
> +fbs(8, temporal_group_ref_pic_diff[i][j], 2, i, j);
> +}
> +}
> +}
> +
> +return 0;
> +}
> +
>  static int FUNC(metadata_scalabili

Re: [FFmpeg-devel] [PATCH] avcodec/h264_ps: fix storage size for offset_for_ref_frame

2019-04-16 Thread James Almer
On 4/16/2019 6:48 PM, Mark Thompson wrote:
> On 11/04/2019 04:10, James Almer wrote:
>> On 4/10/2019 3:30 PM, James Almer wrote:
>>> The spec defines the valid range of values to be INT32_MIN + 1 to 
>>> INT32_MAX, inclusive.
>>>
>>> Signed-off-by: James Almer 
>>> ---
>>> A good example of why making offsets and sizes of structs like this tied to 
>>> the
>>> ABI is not a good idea.
>>>
>>>  libavcodec/h264_ps.h | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/h264_ps.h b/libavcodec/h264_ps.h
>>> index e967b9cbcf..9014326dfb 100644
>>> --- a/libavcodec/h264_ps.h
>>> +++ b/libavcodec/h264_ps.h
>>> @@ -81,7 +81,7 @@ typedef struct SPS {
>>>  uint32_t num_units_in_tick;
>>>  uint32_t time_scale;
>>>  int fixed_frame_rate_flag;
>>> -short offset_for_ref_frame[256]; // FIXME dyn aloc?
>>> +int32_t offset_for_ref_frame[256];
>>
>> The doxy for get_se_golomb() doesn't mention the range of values it can
>> handle, but seeing there's also a get_se_golomb_long(), I guess the
>> relevant line in h264_ps.c should now use the latter instead?
> 
> I think it's correct to do that.  Seems highly unlikely anyone would ever hit 
> it outside a conformance-checking context, though - using anything other than 
> pic_order_cnt_type 0 for nontrivial reference structures is madness.
> 
>>>  int bitstream_restriction_flag;
>>>  int num_reorder_frames;
>>>  int scaling_matrix_present;
> 
> There are some other fields with int32_t range which are using 
> get_se_golomb() - e.g. offset_for_non_ref_pic.  I guess they should use 
> get_se_golomb_long() as above.  They're also plain ints - do they want to be 
> explicitly int32_t?

It's wildly inconsistent. There are both scalar values and arrays as
uint32_t, int, and unsigned it, but in all cases they can store the
correct range of values, so IMO, not worth changing unless the whole
structs are made consistent, like you did with the CBS ones.

Which are these? I'll send a separate patch changing get_se_golomb() to
get_se_golomb_long() for all of them.

> 
> - Mark
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/h264_ps: fix storage size for offset_for_ref_frame

2019-04-16 Thread Mark Thompson
On 11/04/2019 04:10, James Almer wrote:
> On 4/10/2019 3:30 PM, James Almer wrote:
>> The spec defines the valid range of values to be INT32_MIN + 1 to INT32_MAX, 
>> inclusive.
>>
>> Signed-off-by: James Almer 
>> ---
>> A good example of why making offsets and sizes of structs like this tied to 
>> the
>> ABI is not a good idea.
>>
>>  libavcodec/h264_ps.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/h264_ps.h b/libavcodec/h264_ps.h
>> index e967b9cbcf..9014326dfb 100644
>> --- a/libavcodec/h264_ps.h
>> +++ b/libavcodec/h264_ps.h
>> @@ -81,7 +81,7 @@ typedef struct SPS {
>>  uint32_t num_units_in_tick;
>>  uint32_t time_scale;
>>  int fixed_frame_rate_flag;
>> -short offset_for_ref_frame[256]; // FIXME dyn aloc?
>> +int32_t offset_for_ref_frame[256];
> 
> The doxy for get_se_golomb() doesn't mention the range of values it can
> handle, but seeing there's also a get_se_golomb_long(), I guess the
> relevant line in h264_ps.c should now use the latter instead?

I think it's correct to do that.  Seems highly unlikely anyone would ever hit 
it outside a conformance-checking context, though - using anything other than 
pic_order_cnt_type 0 for nontrivial reference structures is madness.

>>  int bitstream_restriction_flag;
>>  int num_reorder_frames;
>>  int scaling_matrix_present;

There are some other fields with int32_t range which are using get_se_golomb() 
- e.g. offset_for_non_ref_pic.  I guess they should use get_se_golomb_long() as 
above.  They're also plain ints - do they want to be explicitly int32_t?

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V2 1/2] lavfi/opencl: add more opencl helper macro

2019-04-16 Thread Mark Thompson
On 12/04/2019 16:09, Ruiling Song wrote:
> Signed-off-by: Ruiling Song 
> ---
>  libavfilter/opencl.h | 38 ++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h
> index 0b06232ade..0fa5b49d3f 100644
> --- a/libavfilter/opencl.h
> +++ b/libavfilter/opencl.h
> @@ -73,6 +73,44 @@ typedef struct OpenCLFilterContext {
>  goto fail; \
>  }  \
>  } while(0)
> +/**
> +  * release an OpenCL Kernel
> +  */
> +#define CL_RELEASE_KERNEL(k)  \
> +do {  \
> +if (k) {  \
> +cle = clReleaseKernel(k); \
> +if (cle != CL_SUCCESS)\
> +av_log(avctx, AV_LOG_ERROR, "Failed to release "  \
> +   "OpenCL kernel: %d.\n", cle);  \
> +} \
> +} while(0)
> +
> +/**
> +  * release an OpenCL Memory Object
> +  */
> +#define CL_RELEASE_MEMORY(m)  \
> +do {  \
> +if (m) {  \
> +cle = clReleaseMemObject(m);  \
> +if (cle != CL_SUCCESS)\
> +av_log(avctx, AV_LOG_ERROR, "Failed to release "  \
> +   "OpenCL memory: %d.\n", cle);  \
> +} \
> +} while(0)
> +
> +/**
> +  * release an OpenCL Command Queue
> +  */
> +#define CL_RELEASE_QUEUE(q)   \
> +do {  \
> +if (q) {  \
> +cle = clReleaseCommandQueue(q);   \
> +if (cle != CL_SUCCESS)\
> +av_log(avctx, AV_LOG_ERROR, "Failed to release "  \
> +   "cl command queue: %d.\n", cle);   \
> +} \
> +} while(0)
>  
>  /**
>   * Return that all inputs and outputs support only AV_PIX_FMT_OPENCL.
> 

LGTM.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V2 2/2] lavfi/opencl: add nlmeans_opencl filter

2019-04-16 Thread Mark Thompson
On 12/04/2019 16:09, Ruiling Song wrote:
> Signed-off-by: Ruiling Song 

I can't work out where the problem is, but there is something really weirdly 
nondeterministic going on here.

E.g.

$ ./ffmpeg_g -y -init_hw_device opencl:0.0 -i 
~/video/test/jellyfish-120-mbps-4k-uhd-hevc-10bit.mkv -an -filter_hw_device 
opencl0 -vf format=yuv420p,hwupload,nlmeans_opencl,hwdownload,format=yuv420p 
-frames:v 10 -f framemd5 -
...
0,  0,  0,1, 12441600, 8b8805818076b23ae6f80ec2b5a349d4
0,  1,  1,1, 12441600, 7a7fdaa083dc337cfb6af31b643f30a3
0,  2,  2,1, 12441600, b10ef2a1e5125cc67e262e086f8040b5
0,  3,  3,1, 12441600, c06b53ad90e0357e537df41b63d5b1dc
0,  4,  4,1, 12441600, 5aa2da07703859a3dee080847dd17d46
0,  5,  5,1, 12441600, 733364c6be6af825057e905a6092937d
0,  6,  6,1, 12441600, 47edae2dec956a582b04babb745d26b0
0,  7,  7,1, 12441600, 4e45fe8268df4298d06a17ab8e46c3e9
0,  8,  8,1, 12441600, 960d722a3f8787c9191299a114c04174
0,  9,  9,1, 12441600, e759c07ee4834a9cf94bfcb4128e7612
$ ./ffmpeg_g -y -init_hw_device opencl:0.0 -i 
~/video/test/jellyfish-120-mbps-4k-uhd-hevc-10bit.mkv -an -filter_hw_device 
opencl0 -vf format=yuv420p,hwupload,nlmeans_opencl,hwdownload,format=yuv420p 
-frames:v 10 -f framemd5 -
0,  0,  0,1, 12441600, 8b8805818076b23ae6f80ec2b5a349d4
[Parsed_nlmeans_opencl_2 @ 0x5557ae580d00] integral image overflow 2157538
0,  1,  1,1, 12441600, bce72e10a9f1118940c5a8392ad78ec3
0,  2,  2,1, 12441600, b10ef2a1e5125cc67e262e086f8040b5
0,  3,  3,1, 12441600, c06b53ad90e0357e537df41b63d5b1dc
0,  4,  4,1, 12441600, 5aa2da07703859a3dee080847dd17d46
0,  5,  5,1, 12441600, 733364c6be6af825057e905a6092937d
0,  6,  6,1, 12441600, 47edae2dec956a582b04babb745d26b0
0,  7,  7,1, 12441600, 4e45fe8268df4298d06a17ab8e46c3e9
0,  8,  8,1, 12441600, 960d722a3f8787c9191299a114c04174
0,  9,  9,1, 12441600, e759c07ee4834a9cf94bfcb4128e7612
$ ./ffmpeg_g -y -init_hw_device opencl:0.0 -i 
~/video/test/jellyfish-120-mbps-4k-uhd-hevc-10bit.mkv -an -filter_hw_device 
opencl0 -vf format=yuv420p,hwupload,nlmeans_opencl,hwdownload,format=yuv420p 
-frames:v 10 -f framemd5 -
0,  0,  0,1, 12441600, 8b8805818076b23ae6f80ec2b5a349d4
0,  1,  1,1, 12441600, 7a7fdaa083dc337cfb6af31b643f30a3
[Parsed_nlmeans_opencl_2 @ 0x557c51fbfe80] integral image overflow 2098545
0,  2,  2,1, 12441600, 68b390535adc5cfa0f8a7942c42a47ca
0,  3,  3,1, 12441600, c06b53ad90e0357e537df41b63d5b1dc
0,  4,  4,1, 12441600, 5aa2da07703859a3dee080847dd17d46
0,  5,  5,1, 12441600, 733364c6be6af825057e905a6092937d
0,  6,  6,1, 12441600, 47edae2dec956a582b04babb745d26b0
0,  7,  7,1, 12441600, 4e45fe8268df4298d06a17ab8e46c3e9
0,  8,  8,1, 12441600, 960d722a3f8787c9191299a114c04174
0,  9,  9,1, 12441600, e759c07ee4834a9cf94bfcb4128e7612

Frame 1 gave an overflow on the second run, and gets a different answer, then 
frame 2 in the same way on the third run?  I can't characterise when this 
happens, it seems to be pretty random with low probability.

(Input here is a 4K file from , but I don't think it 
matters - I saw it with others sometimes as well.)

>  configure   |   1 +
>  doc/filters.texi|   4 +
>  libavfilter/Makefile|   1 +
>  libavfilter/allfilters.c|   1 +
>  libavfilter/opencl/nlmeans.cl   | 115 +
>  libavfilter/opencl_source.h |   1 +
>  libavfilter/vf_nlmeans_opencl.c | 442 
>  7 files changed, 565 insertions(+)
>  create mode 100644 libavfilter/opencl/nlmeans.cl
>  create mode 100644 libavfilter/vf_nlmeans_opencl.c

Code all looks fine, as far as I can tell.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avfilter: add audio soft clip filter

2019-04-16 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi   |  22 
 libavfilter/Makefile   |   1 +
 libavfilter/af_asoftclip.c | 206 +
 libavfilter/allfilters.c   |   1 +
 4 files changed, 230 insertions(+)
 create mode 100644 libavfilter/af_asoftclip.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 867607d870..404096e478 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -2093,6 +2093,28 @@ audio, the data is treated as if all the planes were 
concatenated.
 A list of Adler-32 checksums for each data plane.
 @end table
 
+@section asoftclip
+
+Apply audio soft clipping.
+
+This filter accepts the following options:
+
+@table @option
+@item type
+Set type of soft-clipping.
+
+It accepts the following values:
+@table @option
+@item tanh
+@item sin
+@item bdj
+@item atan
+@end table
+
+@item clip
+Set clipping limit value. Default is 1. Allowed range is @code{[0.01 - 1]}.
+@end table
+
 @anchor{astats}
 @section astats
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index fef6ec5c55..682df45ef5 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -80,6 +80,7 @@ OBJS-$(CONFIG_ASETRATE_FILTER)   += af_asetrate.o
 OBJS-$(CONFIG_ASETTB_FILTER) += settb.o
 OBJS-$(CONFIG_ASHOWINFO_FILTER)  += af_ashowinfo.o
 OBJS-$(CONFIG_ASIDEDATA_FILTER)  += f_sidedata.o
+OBJS-$(CONFIG_ASOFTCLIP_FILTER)  += af_asoftclip.o
 OBJS-$(CONFIG_ASPLIT_FILTER) += split.o
 OBJS-$(CONFIG_ASTATS_FILTER) += af_astats.o
 OBJS-$(CONFIG_ASTREAMSELECT_FILTER)  += f_streamselect.o framesync.o
diff --git a/libavfilter/af_asoftclip.c b/libavfilter/af_asoftclip.c
new file mode 100644
index 00..ee2a0f0562
--- /dev/null
+++ b/libavfilter/af_asoftclip.c
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2019 The FFmpeg Project
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/channel_layout.h"
+#include "libavutil/opt.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "formats.h"
+
+enum ASoftClipTypes {
+ASC_TANH,
+ASC_SIN,
+ASC_BDJ,
+ASC_ATAN,
+NB_TYPES,
+};
+
+typedef struct ASoftClipContext {
+const AVClass *class;
+
+int type;
+double clip;
+
+void (*filter)(struct ASoftClipContext *s, void **dst, const void **src,
+   int nb_samples, int channels);
+} ASoftClipContext;
+
+#define OFFSET(x) offsetof(ASoftClipContext, x)
+#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption asoftclip_options[] = {
+{ "type", "set softclip type", OFFSET(type), AV_OPT_TYPE_INT,{.i64=0}, 
   0, NB_TYPES-1, A, "types" },
+{ "tanh",NULL,0, AV_OPT_TYPE_CONST,  
{.i64=ASC_TANH}, 0,  0, A, "types" },
+{  "sin",NULL,0, AV_OPT_TYPE_CONST,  
{.i64=ASC_SIN},  0,  0, A, "types" },
+{  "bdj",NULL,0, AV_OPT_TYPE_CONST,  
{.i64=ASC_BDJ},  0,  0, A, "types" },
+{ "atan",NULL,0, AV_OPT_TYPE_CONST,  
{.i64=ASC_ATAN}, 0,  0, A, "types" },
+{ "clip", "set softclip clip", OFFSET(clip), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 
0.01,  1, A },
+{ NULL }
+};
+
+AVFILTER_DEFINE_CLASS(asoftclip);
+
+static int query_formats(AVFilterContext *ctx)
+{
+AVFilterFormats *formats = NULL;
+AVFilterChannelLayouts *layouts = NULL;
+static const enum AVSampleFormat sample_fmts[] = {
+AV_SAMPLE_FMT_DBLP,
+AV_SAMPLE_FMT_NONE
+};
+int ret;
+
+formats = ff_make_format_list(sample_fmts);
+if (!formats)
+return AVERROR(ENOMEM);
+ret = ff_set_common_formats(ctx, formats);
+if (ret < 0)
+return ret;
+
+layouts = ff_all_channel_counts();
+if (!layouts)
+return AVERROR(ENOMEM);
+
+ret = ff_set_common_channel_layouts(ctx, layouts);
+if (ret < 0)
+return ret;
+
+formats = ff_all_samplerates();
+return ff_set_common_samplerates(ctx, formats);
+}
+
+#define SQR(x) ((x) * (x))
+
+static void filter_dblp(ASoftClipContext *s,
+void **dptr, const void **sptr,
+int nb_samples, int ch

Re: [FFmpeg-devel] Need help with FFmpeg javacpp-presets

2019-04-16 Thread Lou Logan
On Tue, Apr 16, 2019, at 10:27 AM, sourabh jain wrote:
> Hi ,
> 
> can someone here , help me with
> Impossible to convert between the formats supported by the filter
> 'Parsed_ebur128_0' and the filter 'auto_resampler_0
> explained my situation here :
> 
> https://github.com/bytedeco/javacpp-presets/issues/715
> 
> 
> issue comes when try to call  avfilter_graph_config(filter_graph, null))

This mailing list (ffmpeg-devel) is only for patch submissions and discussions 
related to the development of FFmpeg.

Questions from users involving the FFmpeg libraries should be asked at 
libav-user.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] Need help with FFmpeg javacpp-presets

2019-04-16 Thread sourabh jain
Hi ,

can someone here , help me with
Impossible to convert between the formats supported by the filter
'Parsed_ebur128_0' and the filter 'auto_resampler_0
explained my situation here :

https://github.com/bytedeco/javacpp-presets/issues/715


issue comes when try to call  avfilter_graph_config(filter_graph, null))
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/h264_ps: fix storage size for offset_for_ref_frame

2019-04-16 Thread James Almer
On 4/11/2019 12:10 AM, James Almer wrote:
> On 4/10/2019 3:30 PM, James Almer wrote:
>> The spec defines the valid range of values to be INT32_MIN + 1 to INT32_MAX, 
>> inclusive.
>>
>> Signed-off-by: James Almer 
>> ---
>> A good example of why making offsets and sizes of structs like this tied to 
>> the
>> ABI is not a good idea.
>>
>>  libavcodec/h264_ps.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/h264_ps.h b/libavcodec/h264_ps.h
>> index e967b9cbcf..9014326dfb 100644
>> --- a/libavcodec/h264_ps.h
>> +++ b/libavcodec/h264_ps.h
>> @@ -81,7 +81,7 @@ typedef struct SPS {
>>  uint32_t num_units_in_tick;
>>  uint32_t time_scale;
>>  int fixed_frame_rate_flag;
>> -short offset_for_ref_frame[256]; // FIXME dyn aloc?
>> +int32_t offset_for_ref_frame[256];
> 
> The doxy for get_se_golomb() doesn't mention the range of values it can
> handle, but seeing there's also a get_se_golomb_long(), I guess the
> relevant line in h264_ps.c should now use the latter instead?
> 

Ping.

Also, could use another pair of eyes to make sure other fields have an
storage type that can handle their defined range of valid values.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] libavfilter/f_select: response file support

2019-04-16 Thread Jonathan Gilbert
Hello :-)

I had a project recently where I wanted to externally specify a list
of specific frame numbers to drop. I understand this can be done with
select expressions like "not(eq(n,45)+eq(n,47)+eq(n,75))", but in my
case I wanted to drop nearly 16,000 frames, which would have required
a command-line over 250 KB in size. I chose a different approach: I
have added functionality to f_select.c so that you can specify the
list of frames you want to include/exclude in an external response
file. I have successfully used this code for my project, and thought I
might submit it up to for consideration. :-)

I've never submitted a patch in this format before, I hope I'm doing
this correctly.

Thanks very much,

Jonathan Gilbert

---
 libavfilter/f_select.c | 316 -
 1 file changed, 310 insertions(+), 6 deletions(-)

diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index 1132375758..0852fffb44 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -22,6 +22,8 @@
  * @file
  * filter for selecting which frame passes in the filterchain
  */
+#include 
+#include 

 #include "libavutil/avstring.h"
 #include "libavutil/eval.h"
@@ -139,10 +141,33 @@ enum var_name {
 VAR_VARS_NB
 };

+enum filemode {
+SELECT_FILEMODE_INCLUDE,
+SELECT_FILEMODE_EXCLUDE
+};
+
+enum filetype {
+SELECT_FILETYPE_FRAMENO,
+SELECT_FILETYPE_PTS
+};
+
+enum warnunused {
+SELECT_WARNUNUSED_NO,
+SELECT_WARNUNUSED_YES,
+SELECT_WARNUNUSED_ALL
+};
+
 typedef struct SelectContext {
 const AVClass *class;
 char *expr_str;
 AVExpr *expr;
+char *file_str;
+int *file_frame_list;
+int file_frame_list_length;
+enum filemode filemode;
+enum filetype filetype;
+char *file_frame_list_used;
+enum warnunused file_warn_unused;
 double var_values[VAR_VARS_NB];
 int do_scene_detect;///< 1 if the expression requires
scene detection variables, 0 otherwise
 ff_scene_sad_fn sad;///< Sum of the absolute
difference function (scene detect only)
@@ -158,6 +183,17 @@ typedef struct SelectContext {
 static const AVOption filt_name##_options[] = { \
 { "expr", "set an expression to use for selecting frames",
OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags=FLAGS },
\
 { "e","set an expression to use for selecting frames",
OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags=FLAGS },
\
+{ "file", "set the name of a file from which frame numbers
are read", OFFSET(file_str), AV_OPT_TYPE_STRING, { .str = "" },
.flags=FLAGS }, \
+{ "filemode", "set the interpretation of the file (include or
exclude)", OFFSET(filemode), AV_OPT_TYPE_INT, { .i64 =
SELECT_FILEMODE_INCLUDE }, INT_MIN, INT_MAX, FLAGS, "filemode" }, \
+{ "include", "include all frames listed in the file", 0,
AV_OPT_TYPE_CONST, { .i64 = SELECT_FILEMODE_INCLUDE }, INT_MIN,
INT_MAX, FLAGS, "filemode" }, \
+{ "exclude", "exclude all frames listed in the file", 0,
AV_OPT_TYPE_CONST, { .i64 = SELECT_FILEMODE_EXCLUDE }, INT_MIN,
INT_MAX, FLAGS, "filemode" }, \
+{ "filetype", "set the interpretation of the file (frameno or
pts)", OFFSET(filetype), AV_OPT_TYPE_INT, { .i64 =
SELECT_FILETYPE_FRAMENO }, INT_MIN, INT_MAX, FLAGS, "filetype" }, \
+{ "frameno", "match frames by frame number", 0,
AV_OPT_TYPE_CONST, { .i64 = SELECT_FILETYPE_FRAMENO }, INT_MIN,
INT_MAX, FLAGS, "filetype" }, \
+{ "pts", "match frames by pts", 0, AV_OPT_TYPE_CONST, { .i64
= SELECT_FILETYPE_PTS }, INT_MIN, INT_MAX, FLAGS, "filetype" }, \
+{ "warnunused", "if enabled, warns if any of the frame numbers
from the input file are never matched", OFFSET(file_warn_unused),
AV_OPT_TYPE_INT, { .i64 = SELECT_WARNUNUSED_NO }, INT_MIN, INT_MAX,
FLAGS, "warnunused" }, \
+{ "no", "do not warn about unused frame numbers from the
input file", 0, AV_OPT_TYPE_CONST, { .i64 = SELECT_WARNUNUSED_NO },
INT_MIN, INT_MAX, FLAGS, "warnunused" }, \
+{ "yes", "warn about unused frame numbers from the input
file, but don't show a long list", 0, AV_OPT_TYPE_CONST, { .i64 =
SELECT_WARNUNUSED_YES }, INT_MIN, INT_MAX, FLAGS, "warnunused" }, \
+{ "all", "warn about all unused frame numbers from the input
file, even if there are many", 0, AV_OPT_TYPE_CONST, { .i64 =
SELECT_WARNUNUSED_ALL }, INT_MIN, INT_MAX, FLAGS, "warnunused" }, \
 { "outputs", "set the number of outputs", OFFSET(nb_outputs),
AV_OPT_TYPE_INT, {.i64 = 1}, 1, INT_MAX, .flags=FLAGS }, \
 { "n",   "set the number of outputs", OFFSET(nb_outputs),
AV_OPT_TYPE_INT, {.i64 = 1}, 1, INT_MAX, .flags=FLAGS }, \
 { NULL }\
@@ -165,17 +201,220 @@ static const AVOption filt_name##_options[] = {
\

 static int request_frame(AVFilterLink *outlink);

+static int read_line(FILE *file, char **buffer, int *buffer_length)
+{
+int ch;
+int offset = 0;
+

Re: [FFmpeg-devel] [PATCH 1/4] avutil/avstring: Fix bug and undefined behavior in av_strncasecmp()

2019-04-16 Thread Paul B Mahol
On 4/16/19, Michael Niedermayer  wrote:
> The function in case of n=0 would read more bytes than 0.
> The end pointer could be beyond the allocated space, which
> is undefined.
>
> Signed-off-by: Michael Niedermayer 
> ---
>  libavutil/avstring.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavutil/avstring.c b/libavutil/avstring.c
> index f03dd25141..4c068f5bc5 100644
> --- a/libavutil/avstring.c
> +++ b/libavutil/avstring.c
> @@ -222,12 +222,13 @@ int av_strcasecmp(const char *a, const char *b)
>
>  int av_strncasecmp(const char *a, const char *b, size_t n)
>  {
> -const char *end = a + n;
>  uint8_t c1, c2;
> +if (n <= 0)
> +return 0;
>  do {
>  c1 = av_tolower(*a++);
>  c2 = av_tolower(*b++);
> -} while (a < end && c1 && c1 == c2);
> +} while (--n && c1 && c1 == c2);
>  return c1 - c2;
>  }
>
> --
> 2.21.0
>

LGTM

> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] mxfdec: Constrain run-in to 64k

2019-04-16 Thread Tomas Härdin
tis 2019-04-16 klockan 15:29 +0200 skrev Carl Eugen Hoyos:
> > 2019-04-16 14:44 GMT+02:00, Tomas Härdin :
> > tis 2019-04-16 klockan 00:41 +0200 skrev Carl Eugen Hoyos:
> > > > > > > > 2019-04-16 0:00 GMT+02:00, Tomas Härdin :
> > > > mån 2019-04-15 klockan 12:40 +0200 skrev Carl Eugen Hoyos:
> > > > > > > > > > 2019-04-15 10:30 GMT+02:00, Tomas Härdin
> > > > > > > > > > :
> > > > > > 
> > > > > > This isn't likely to be a huge problem, but it allows us to reason
> > > > > > more
> > > > > > about run-in. It also exposes my gripe about klv_read_packet() using
> > > > > > mxf_read_sync()
> > > > > 
> > > > > Does this patch have an effect on one of our samples?
> > > > 
> > > > It passes FATE if that's what you mean.
> > > 
> > > No.
> > > 
> > > > The intent is rather to pre-emptively stop the ability for new
> > > > broken muxers to pop up, which would end up straying
> > > > from the spec because mxfdec.c is being too forgiving
> > > 
> > > As such, and if I don't misunderstand, this sounds to me
> > > like an explanation why this patch should not be pushed.
> > 
> > If you want to encourage spec violating behavior in professional
> > muxers, sure. But for anyone who has to work with MXF, the ability to
> > tell the other engineer "no, go fix your damn muxer" is important.
> 
> Apart from: This is - fortunately - not what we do for all other
> formats (we wouldn't be here for a very long time if we did):
> Why don't you print a warning?

Eh, that doesn't really accomplish much.

I guess I'll have to look at this from the positive side: more people
writing broken muxers means more consulting hours for the rest of us!

/Tomas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/4] avcodec/jpeg2000dec: Replace the step_x/y assert by a check in the CPRL case as with the PCRL case

2019-04-16 Thread Michael Niedermayer
Fixes: assertion failure
Fixes: 
14246/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5758393601490944

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/jpeg2000dec.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 7749c980e5..9198cf87cb 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1171,7 +1171,10 @@ static int 
jpeg2000_decode_packets_po_iteration(Jpeg2000DecoderContext *s, Jpeg2
 step_x = FFMIN(step_x, rlevel->log2_prec_width  + 
reducedresno);
 step_y = FFMIN(step_y, rlevel->log2_prec_height + 
reducedresno);
 }
-av_assert0(step_x < 32 && step_y < 32);
+if (step_x >= 31 || step_y >= 31){
+avpriv_request_sample(s->avctx, "CPRL with large step");
+return AVERROR_PATCHWELCOME;
+}
 step_x = 1

[FFmpeg-devel] [PATCH 2/4] avcodec/jpeg2000: Check stepsize before using it

2019-04-16 Thread Michael Niedermayer
Fixes: value 1.87633e+10 is outside the range of representable values of type 
'int'
Fixes: Undefined behavior
Fixes: 
14246/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5758393601490944

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/jpeg2000.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 8e90980976..3f50bf9fb3 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -247,6 +247,11 @@ static void init_band_stepsize(AVCodecContext *avctx,
 }
 }
 
+if (band->f_stepsize > (INT_MAX >> 15)) {
+band->f_stepsize = 0;
+av_log(avctx, AV_LOG_ERROR, "stepsize out of range\n");
+}
+
 band->i_stepsize = band->f_stepsize * (1 << 15);
 
 /* FIXME: In OpenJPEG code stepsize = stepsize * 0.5. Why?
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/4] avutil/avstring: Fix bug and undefined behavior in av_strncasecmp()

2019-04-16 Thread Michael Niedermayer
The function in case of n=0 would read more bytes than 0.
The end pointer could be beyond the allocated space, which
is undefined.

Signed-off-by: Michael Niedermayer 
---
 libavutil/avstring.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index f03dd25141..4c068f5bc5 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -222,12 +222,13 @@ int av_strcasecmp(const char *a, const char *b)
 
 int av_strncasecmp(const char *a, const char *b, size_t n)
 {
-const char *end = a + n;
 uint8_t c1, c2;
+if (n <= 0)
+return 0;
 do {
 c1 = av_tolower(*a++);
 c2 = av_tolower(*b++);
-} while (a < end && c1 && c1 == c2);
+} while (--n && c1 && c1 == c2);
 return c1 - c2;
 }
 
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 4/4] avcodec/jpeg2000dec: Check PLT data somewhat

2019-04-16 Thread Michael Niedermayer
Fixes: Timeout (21sec -> 0.6sec)
Fixes: 
14134/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5768371078955008

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/jpeg2000dec.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 9198cf87cb..62b0b1f9b7 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -832,15 +832,21 @@ static uint8_t get_tlm(Jpeg2000DecoderContext *s, int n)
 static uint8_t get_plt(Jpeg2000DecoderContext *s, int n)
 {
 int i;
+int v;
 
 av_log(s->avctx, AV_LOG_DEBUG,
 "PLT marker at pos 0x%X\n", bytestream2_tell(&s->g) - 4);
 
+if (n < 4)
+return AVERROR_INVALIDDATA;
+
 /*Zplt =*/ bytestream2_get_byte(&s->g);
 
 for (i = 0; i < n - 3; i++) {
-bytestream2_get_byte(&s->g);
+v = bytestream2_get_byte(&s->g);
 }
+if (v & 0x80)
+return AVERROR_INVALIDDATA;
 
 return 0;
 }
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] mxfdec: Constrain run-in to 64k

2019-04-16 Thread Carl Eugen Hoyos
2019-04-16 14:44 GMT+02:00, Tomas Härdin :
> tis 2019-04-16 klockan 00:41 +0200 skrev Carl Eugen Hoyos:
>> > 2019-04-16 0:00 GMT+02:00, Tomas Härdin :
>> > mån 2019-04-15 klockan 12:40 +0200 skrev Carl Eugen Hoyos:
>> > > > > > > > 2019-04-15 10:30 GMT+02:00, Tomas Härdin
>> > > > > > > > :
>> > > > This isn't likely to be a huge problem, but it allows us to reason
>> > > > more
>> > > > about run-in. It also exposes my gripe about klv_read_packet() using
>> > > > mxf_read_sync()
>> > >
>> > > Does this patch have an effect on one of our samples?
>> >
>> > It passes FATE if that's what you mean.
>>
>> No.
>>
>> > The intent is rather to pre-emptively stop the ability for new
>> > broken muxers to pop up, which would end up straying
>> > from the spec because mxfdec.c is being too forgiving
>>
>> As such, and if I don't misunderstand, this sounds to me
>> like an explanation why this patch should not be pushed.
>
> If you want to encourage spec violating behavior in professional
> muxers, sure. But for anyone who has to work with MXF, the ability to
> tell the other engineer "no, go fix your damn muxer" is important.

Apart from: This is - fortunately - not what we do for all other
formats (we wouldn't be here for a very long time if we did):
Why don't you print a warning?

> The field is already a huge mess of broken muxers and
> demuxers. We should make sure our own yard is in order

This can only be true for muxers (and encoders), never for
demuxers (and decoders).

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] mxfdec: Constrain run-in to 64k

2019-04-16 Thread Paul B Mahol
On 4/16/19, Tomas Härdin  wrote:
> tis 2019-04-16 klockan 00:41 +0200 skrev Carl Eugen Hoyos:
>> > 2019-04-16 0:00 GMT+02:00, Tomas Härdin :
>> > mån 2019-04-15 klockan 12:40 +0200 skrev Carl Eugen Hoyos:
>> > > > > > > > 2019-04-15 10:30 GMT+02:00, Tomas Härdin
>> > > > > > > > :
>> > > > This isn't likely to be a huge problem, but it allows us to reason
>> > > > more
>> > > > about run-in. It also exposes my gripe about klv_read_packet() using
>> > > > mxf_read_sync()
>> > >
>> > > Does this patch have an effect on one of our samples?
>> >
>> > It passes FATE if that's what you mean.
>>
>> No.
>>
>> > The intent is rather to pre-emptively stop the ability for new
>> > broken muxers to pop up, which would end up straying
>> > from the spec because mxfdec.c is being too forgiving
>>
>> As such, and if I don't misunderstand, this sounds to me
>> like an explanation why this patch should not be pushed.
>
> If you want to encourage spec violating behavior in professional
> muxers, sure. But for anyone who has to work with MXF, the ability to
> tell the other engineer "no, go fix your damn muxer" is important. The
> field is already a huge mess of broken muxers and demuxers. We should
> make sure our own yard is in order
>
> As always, I'm going to point out that we'd be better off using bmxlib

I can not follow your logic.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] mxfdec: Constrain run-in to 64k

2019-04-16 Thread Tomas Härdin
tis 2019-04-16 klockan 00:41 +0200 skrev Carl Eugen Hoyos:
> > 2019-04-16 0:00 GMT+02:00, Tomas Härdin :
> > mån 2019-04-15 klockan 12:40 +0200 skrev Carl Eugen Hoyos:
> > > > > > > > 2019-04-15 10:30 GMT+02:00, Tomas Härdin :
> > > > This isn't likely to be a huge problem, but it allows us to reason more
> > > > about run-in. It also exposes my gripe about klv_read_packet() using
> > > > mxf_read_sync()
> > > 
> > > Does this patch have an effect on one of our samples?
> > 
> > It passes FATE if that's what you mean.
> 
> No.
> 
> > The intent is rather to pre-emptively stop the ability for new
> > broken muxers to pop up, which would end up straying
> > from the spec because mxfdec.c is being too forgiving
> 
> As such, and if I don't misunderstand, this sounds to me
> like an explanation why this patch should not be pushed.

If you want to encourage spec violating behavior in professional
muxers, sure. But for anyone who has to work with MXF, the ability to
tell the other engineer "no, go fix your damn muxer" is important. The
field is already a huge mess of broken muxers and demuxers. We should
make sure our own yard is in order

As always, I'm going to point out that we'd be better off using bmxlib

/Tomas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/8] libavfilter/dnn: determine dnn output during execute_model instead of set_input_output

2019-04-16 Thread Steven Liu


> 在 2019年4月2日,22:29,Guo, Yejun  写道:
> 
> Currently, within interface set_input_output, the dims/memory of the 
> tensorflow
> dnn model output is determined by executing the model with zero input,
> actually, the output dims might vary with different input data for networks
> such as object detection models faster-rcnn, ssd and yolo.
> 
> This patch moves the logic from set_input_output to execute_model which
> is suitable for all the cases. Since interface changed, and so 
> dnn_backend_native
> also changes.
> 
> In vf_sr.c, it knows it's srcnn or espcn by executing the model with zero 
> input,
> so execute_model has to be called in function config_props
> 
> Signed-off-by: Guo, Yejun 
> ---
> libavfilter/dnn_backend_native.c | 14 +-
> libavfilter/dnn_backend_native.h |  2 +-
> libavfilter/dnn_backend_tf.c | 55 
> libavfilter/dnn_backend_tf.h |  2 +-
> libavfilter/dnn_interface.h  |  6 ++---
> libavfilter/vf_sr.c  | 20 ---
> 6 files changed, 51 insertions(+), 48 deletions(-)
> 
> diff --git a/libavfilter/dnn_backend_native.c 
> b/libavfilter/dnn_backend_native.c
> index fe43116..18735c0 100644
> --- a/libavfilter/dnn_backend_native.c
> +++ b/libavfilter/dnn_backend_native.c
> @@ -25,7 +25,7 @@
> 
> #include "dnn_backend_native.h"
> 
> -static DNNReturnType set_input_output_native(void *model, DNNData *input, 
> const char *input_name, DNNData *output, const char *output_name)
> +static DNNReturnType set_input_output_native(void *model, DNNData *input, 
> const char *input_name, const char *output_name)
> {
> ConvolutionalNetwork *network = (ConvolutionalNetwork *)model;
> InputParams *input_params;
> @@ -81,11 +81,6 @@ static DNNReturnType set_input_output_native(void *model, 
> DNNData *input, const
> }
> }
> 
> -output->data = network->layers[network->layers_num - 1].output;
> -output->height = cur_height;
> -output->width = cur_width;
> -output->channels = cur_channels;
> -
> return DNN_SUCCESS;
> }
> 
> @@ -280,7 +275,7 @@ static void depth_to_space(const float *input, float 
> *output, int block_size, in
> }
> }
> 
> -DNNReturnType ff_dnn_execute_model_native(const DNNModel *model)
> +DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData 
> *output)
> {
> ConvolutionalNetwork *network = (ConvolutionalNetwork *)model->model;
> int cur_width, cur_height, cur_channels;
> @@ -322,6 +317,11 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel 
> *model)
> }
> }
> 
> +output->data = network->layers[network->layers_num - 1].output;
> +output->height = cur_height;
> +output->width = cur_width;
> +output->channels = cur_channels;
> +
> return DNN_SUCCESS;
> }
> 
> diff --git a/libavfilter/dnn_backend_native.h 
> b/libavfilter/dnn_backend_native.h
> index 51d4cac..adaf4a7 100644
> --- a/libavfilter/dnn_backend_native.h
> +++ b/libavfilter/dnn_backend_native.h
> @@ -63,7 +63,7 @@ typedef struct ConvolutionalNetwork{
> 
> DNNModel *ff_dnn_load_model_native(const char *model_filename);
> 
> -DNNReturnType ff_dnn_execute_model_native(const DNNModel *model);
> +DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData 
> *output);
> 
> void ff_dnn_free_model_native(DNNModel **model);
> 
> diff --git a/libavfilter/dnn_backend_tf.c b/libavfilter/dnn_backend_tf.c
> index a838907..7966688 100644
> --- a/libavfilter/dnn_backend_tf.c
> +++ b/libavfilter/dnn_backend_tf.c
> @@ -35,7 +35,6 @@ typedef struct TFModel{
> TF_Status *status;
> TF_Output input, output;
> TF_Tensor *input_tensor;
> -DNNData *output_data;
> } TFModel;
> 
> static void free_buffer(void *data, size_t length)
> @@ -76,13 +75,12 @@ static TF_Buffer *read_graph(const char *model_filename)
> return graph_buf;
> }
> 
> -static DNNReturnType set_input_output_tf(void *model, DNNData *input, const 
> char *input_name, DNNData *output, const char *output_name)
> +static DNNReturnType set_input_output_tf(void *model, DNNData *input, const 
> char *input_name, const char *output_name)
> {
> TFModel *tf_model = (TFModel *)model;
> int64_t input_dims[] = {1, input->height, input->width, input->channels};
> TF_SessionOptions *sess_opts;
> const TF_Operation *init_op = TF_GraphOperationByName(tf_model->graph, 
> "init");
> -TF_Tensor *output_tensor;
> 
> // Input operation
> tf_model->input.oper = TF_GraphOperationByName(tf_model->graph, 
> input_name);
> @@ -132,26 +130,6 @@ static DNNReturnType set_input_output_tf(void *model, 
> DNNData *input, const char
> }
> }
> 
> -// Execute network to get output height, width and number of channels
> -TF_SessionRun(tf_model->session, NULL,
> -  &tf_model->input, &tf_model->input_tensor, 1,
> -  &tf_model->output, &output_tensor, 1,
> -  NULL, 0, NULL, tf_model->status);
> -if (TF_GetCode(tf_model

Re: [FFmpeg-devel] [PATCH 4/8] libavfilter/dnn: determine dnn output during execute_model instead of set_input_output

2019-04-16 Thread Steven Liu


> 在 2019年4月2日,22:29,Guo, Yejun  写道:
> 
> Currently, within interface set_input_output, the dims/memory of the 
> tensorflow
> dnn model output is determined by executing the model with zero input,
> actually, the output dims might vary with different input data for networks
> such as object detection models faster-rcnn, ssd and yolo.
> 
> This patch moves the logic from set_input_output to execute_model which
> is suitable for all the cases. Since interface changed, and so 
> dnn_backend_native
> also changes.
> 
> In vf_sr.c, it knows it's srcnn or espcn by executing the model with zero 
> input,
> so execute_model has to be called in function config_props
> 
> Signed-off-by: Guo, Yejun 
> ---
> libavfilter/dnn_backend_native.c | 14 +-
> libavfilter/dnn_backend_native.h |  2 +-
> libavfilter/dnn_backend_tf.c | 55 
> libavfilter/dnn_backend_tf.h |  2 +-
> libavfilter/dnn_interface.h  |  6 ++---
> libavfilter/vf_sr.c  | 20 ---
> 6 files changed, 51 insertions(+), 48 deletions(-)
> 
> diff --git a/libavfilter/dnn_backend_native.c 
> b/libavfilter/dnn_backend_native.c
> index fe43116..18735c0 100644
> --- a/libavfilter/dnn_backend_native.c
> +++ b/libavfilter/dnn_backend_native.c
> @@ -25,7 +25,7 @@
> 
> #include "dnn_backend_native.h"
> 
> -static DNNReturnType set_input_output_native(void *model, DNNData *input, 
> const char *input_name, DNNData *output, const char *output_name)
> +static DNNReturnType set_input_output_native(void *model, DNNData *input, 
> const char *input_name, const char *output_name)
> {
> ConvolutionalNetwork *network = (ConvolutionalNetwork *)model;
> InputParams *input_params;
> @@ -81,11 +81,6 @@ static DNNReturnType set_input_output_native(void *model, 
> DNNData *input, const
> }
> }
> 
> -output->data = network->layers[network->layers_num - 1].output;
> -output->height = cur_height;
> -output->width = cur_width;
> -output->channels = cur_channels;
> -
> return DNN_SUCCESS;
> }
> 
> @@ -280,7 +275,7 @@ static void depth_to_space(const float *input, float 
> *output, int block_size, in
> }
> }
> 
> -DNNReturnType ff_dnn_execute_model_native(const DNNModel *model)
> +DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData 
> *output)
> {
> ConvolutionalNetwork *network = (ConvolutionalNetwork *)model->model;
> int cur_width, cur_height, cur_channels;
> @@ -322,6 +317,11 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel 
> *model)
> }
> }
> 
> +output->data = network->layers[network->layers_num - 1].output;
> +output->height = cur_height;
> +output->width = cur_width;
> +output->channels = cur_channels;
> +
> return DNN_SUCCESS;
> }
> 
> diff --git a/libavfilter/dnn_backend_native.h 
> b/libavfilter/dnn_backend_native.h
> index 51d4cac..adaf4a7 100644
> --- a/libavfilter/dnn_backend_native.h
> +++ b/libavfilter/dnn_backend_native.h
> @@ -63,7 +63,7 @@ typedef struct ConvolutionalNetwork{
> 
> DNNModel *ff_dnn_load_model_native(const char *model_filename);
> 
> -DNNReturnType ff_dnn_execute_model_native(const DNNModel *model);
> +DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData 
> *output);
> 
> void ff_dnn_free_model_native(DNNModel **model);
> 
> diff --git a/libavfilter/dnn_backend_tf.c b/libavfilter/dnn_backend_tf.c
> index a838907..7966688 100644
> --- a/libavfilter/dnn_backend_tf.c
> +++ b/libavfilter/dnn_backend_tf.c
> @@ -35,7 +35,6 @@ typedef struct TFModel{
> TF_Status *status;
> TF_Output input, output;
> TF_Tensor *input_tensor;
> -DNNData *output_data;
> } TFModel;
> 
> static void free_buffer(void *data, size_t length)
> @@ -76,13 +75,12 @@ static TF_Buffer *read_graph(const char *model_filename)
> return graph_buf;
> }
> 
> -static DNNReturnType set_input_output_tf(void *model, DNNData *input, const 
> char *input_name, DNNData *output, const char *output_name)
> +static DNNReturnType set_input_output_tf(void *model, DNNData *input, const 
> char *input_name, const char *output_name)
> {
> TFModel *tf_model = (TFModel *)model;
> int64_t input_dims[] = {1, input->height, input->width, input->channels};
> TF_SessionOptions *sess_opts;
> const TF_Operation *init_op = TF_GraphOperationByName(tf_model->graph, 
> "init");
> -TF_Tensor *output_tensor;
> 
> // Input operation
> tf_model->input.oper = TF_GraphOperationByName(tf_model->graph, 
> input_name);
> @@ -132,26 +130,6 @@ static DNNReturnType set_input_output_tf(void *model, 
> DNNData *input, const char
> }
> }
> 
> -// Execute network to get output height, width and number of channels
> -TF_SessionRun(tf_model->session, NULL,
> -  &tf_model->input, &tf_model->input_tensor, 1,
> -  &tf_model->output, &output_tensor, 1,
> -  NULL, 0, NULL, tf_model->status);
> -if (TF_GetCode(tf_model

Re: [FFmpeg-devel] [PATCH 1/8] libavfilter/dnn_backend_tf.c: set layer_add_res for input layer

2019-04-16 Thread Steven Liu


> 在 2019年4月2日,22:28,Guo, Yejun  写道:
> 
> otherwise, the following check will return error if layer_add_res
> is randomly initialized.
> 
> Signed-off-by: Guo, Yejun 
> ---
> libavfilter/dnn_backend_tf.c | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/libavfilter/dnn_backend_tf.c b/libavfilter/dnn_backend_tf.c
> index 5bc7f06..9e0c127 100644
> --- a/libavfilter/dnn_backend_tf.c
> +++ b/libavfilter/dnn_backend_tf.c
> @@ -440,6 +440,7 @@ static DNNReturnType load_native_model(TFModel *tf_model, 
> const char *model_file
> for (layer = 0; layer < conv_network->layers_num; ++layer){
> switch (conv_network->layers[layer].type){
> case INPUT:
> +layer_add_res = DNN_SUCCESS;
> break;
> case CONV:
> layer_add_res = add_conv_layer(tf_model, transpose_op, &op,
> -- 
> 2.7.4
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe”.

LGTM

Thanks
Steven





___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/dashenc: Disable streaming for webm output

2019-04-16 Thread Jeyapal, Karthick via ffmpeg-devel

On 4/10/19 12:09 PM, Karthick J wrote:
> Currently streaming for webm output doesn't work.
> Disabling explicitly will make sure that the manifest will get generated 
> correctly.
> ---
>  libavformat/dashenc.c | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index f8d71166d4..d8dcbc1230 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -1200,6 +1200,11 @@ static int dash_init(AVFormatContext *s)
> "Override -init_seg_name and/or -media_seg_name 
> and/or "
> "-single_file_name to end with the extension 
> .webm\n");
>  }
> +if (c->streaming) {
> +// Streaming not supported as matroskaenc buffers internally 
> before writing the output
> +av_log(s, AV_LOG_WARNING, "One or more streams in WebM 
> output format. Streaming option will be ignored\n");
> +c->streaming = 0;
> +}
>  }
>  
>  ctx->oformat = av_guess_format(os->format_name, NULL, NULL);
Pushed

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] lavfi: add colorkey_opencl filter

2019-04-16 Thread Timo Rothenpieler
More a general question regarding OpenCL filters than related to this 
specific one.
We are not integrating OpenCL acceleration into the relevant native 
filter anymore, like the very old original OpenCL infra worked, are we?
So that vf_colorkey would just use OpenCL acceleration on its own 
whenever available and fallback to the software path otherwise.




Timo



smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V1 2/2] lavf: bump version/add Changelog entry when cleanup applehttp

2019-04-16 Thread Carl Eugen Hoyos
2019-04-16 11:32 GMT+02:00, Hendrik Leppkes :
> On Tue, Apr 16, 2019 at 10:58 AM Carl Eugen Hoyos 
> wrote:
>>
>> 2019-04-16 10:52 GMT+02:00, myp...@gmail.com :
>> > On Tue, Apr 16, 2019 at 4:42 PM Hendrik Leppkes 
>> > wrote:
>> >>
>> >> On Tue, Apr 16, 2019 at 7:57 AM Jun Zhao  wrote:
>> >> >
>> >> > From: Jun Zhao 
>> >> >
>> >> > commit abfeba9 "lavf/hls: Cleanup the applehttp" missed
>> >> > the version bump and Changelog entry.
>> >> >
>> >> > Signed-off-by: Jun Zhao 
>> >> > ---
>> >> >  Changelog |1 +
>> >> >  libavformat/version.h |2 +-
>> >> >  2 files changed, 2 insertions(+), 1 deletions(-)
>> >> >
>> >> > diff --git a/Changelog b/Changelog
>> >> > index 5b2b1e5..2930471 100644
>> >> > --- a/Changelog
>> >> > +++ b/Changelog
>> >> > @@ -24,6 +24,7 @@ version :
>> >> >  - KUX demuxer
>> >> >  - AV1 frame split bitstream filter
>> >> >  - lscr decoder
>> >> > +- cleanup applehttp in hls demuxer
>> >> >
>> >>
>> >> If you read the other changelog entries, does this seem like matching
>> >> the pattern in there? :)
>> >> ChangeLog is for end-users, for changes that developers should care
>> >> about, there is APIchanges.
>>
>> Without a version bump?
>>
>
> Well thats no reason to put it into ChangeLog regardless, because it
> just doesn't belong in there.
> This is runtime API, not compile-time API anyway, so someone needing
> this string for some reason and wanting to support all versions will
> have to check both strings regardless of version information,

All true!

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V1 2/2] lavf: bump version/add Changelog entry when cleanup applehttp

2019-04-16 Thread Hendrik Leppkes
On Tue, Apr 16, 2019 at 10:58 AM Carl Eugen Hoyos  wrote:
>
> 2019-04-16 10:52 GMT+02:00, myp...@gmail.com :
> > On Tue, Apr 16, 2019 at 4:42 PM Hendrik Leppkes  wrote:
> >>
> >> On Tue, Apr 16, 2019 at 7:57 AM Jun Zhao  wrote:
> >> >
> >> > From: Jun Zhao 
> >> >
> >> > commit abfeba9 "lavf/hls: Cleanup the applehttp" missed
> >> > the version bump and Changelog entry.
> >> >
> >> > Signed-off-by: Jun Zhao 
> >> > ---
> >> >  Changelog |1 +
> >> >  libavformat/version.h |2 +-
> >> >  2 files changed, 2 insertions(+), 1 deletions(-)
> >> >
> >> > diff --git a/Changelog b/Changelog
> >> > index 5b2b1e5..2930471 100644
> >> > --- a/Changelog
> >> > +++ b/Changelog
> >> > @@ -24,6 +24,7 @@ version :
> >> >  - KUX demuxer
> >> >  - AV1 frame split bitstream filter
> >> >  - lscr decoder
> >> > +- cleanup applehttp in hls demuxer
> >> >
> >>
> >> If you read the other changelog entries, does this seem like matching
> >> the pattern in there? :)
> >> ChangeLog is for end-users, for changes that developers should care
> >> about, there is APIchanges.
>
> Without a version bump?
>

Well thats no reason to put it into ChangeLog regardless, because it
just doesn't belong in there.
This is runtime API, not compile-time API anyway, so someone needing
this string for some reason and wanting to support all versions will
have to check both strings regardless of version information,

- Hendrik
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V1 2/2] lavf: bump version/add Changelog entry when cleanup applehttp

2019-04-16 Thread Carl Eugen Hoyos
2019-04-16 10:52 GMT+02:00, myp...@gmail.com :
> On Tue, Apr 16, 2019 at 4:42 PM Hendrik Leppkes  wrote:
>>
>> On Tue, Apr 16, 2019 at 7:57 AM Jun Zhao  wrote:
>> >
>> > From: Jun Zhao 
>> >
>> > commit abfeba9 "lavf/hls: Cleanup the applehttp" missed
>> > the version bump and Changelog entry.
>> >
>> > Signed-off-by: Jun Zhao 
>> > ---
>> >  Changelog |1 +
>> >  libavformat/version.h |2 +-
>> >  2 files changed, 2 insertions(+), 1 deletions(-)
>> >
>> > diff --git a/Changelog b/Changelog
>> > index 5b2b1e5..2930471 100644
>> > --- a/Changelog
>> > +++ b/Changelog
>> > @@ -24,6 +24,7 @@ version :
>> >  - KUX demuxer
>> >  - AV1 frame split bitstream filter
>> >  - lscr decoder
>> > +- cleanup applehttp in hls demuxer
>> >
>>
>> If you read the other changelog entries, does this seem like matching
>> the pattern in there? :)
>> ChangeLog is for end-users, for changes that developers should care
>> about, there is APIchanges.

Without a version bump?

> Thanks the comments, Hendrik, will update APIChanges

Please make "clean up" "rename applehts demuxer".

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V1 2/2] lavf: bump version/add Changelog entry when cleanup applehttp

2019-04-16 Thread myp...@gmail.com
On Tue, Apr 16, 2019 at 4:42 PM Hendrik Leppkes  wrote:
>
> On Tue, Apr 16, 2019 at 7:57 AM Jun Zhao  wrote:
> >
> > From: Jun Zhao 
> >
> > commit abfeba9 "lavf/hls: Cleanup the applehttp" missed
> > the version bump and Changelog entry.
> >
> > Signed-off-by: Jun Zhao 
> > ---
> >  Changelog |1 +
> >  libavformat/version.h |2 +-
> >  2 files changed, 2 insertions(+), 1 deletions(-)
> >
> > diff --git a/Changelog b/Changelog
> > index 5b2b1e5..2930471 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -24,6 +24,7 @@ version :
> >  - KUX demuxer
> >  - AV1 frame split bitstream filter
> >  - lscr decoder
> > +- cleanup applehttp in hls demuxer
> >
>
> If you read the other changelog entries, does this seem like matching
> the pattern in there? :)
> ChangeLog is for end-users, for changes that developers should care
> about, there is APIchanges.
>
> - Hendrik
Thanks the comments, Hendrik, will update APIChanges
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V1 2/2] lavf: bump version/add Changelog entry when cleanup applehttp

2019-04-16 Thread Hendrik Leppkes
On Tue, Apr 16, 2019 at 7:57 AM Jun Zhao  wrote:
>
> From: Jun Zhao 
>
> commit abfeba9 "lavf/hls: Cleanup the applehttp" missed
> the version bump and Changelog entry.
>
> Signed-off-by: Jun Zhao 
> ---
>  Changelog |1 +
>  libavformat/version.h |2 +-
>  2 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/Changelog b/Changelog
> index 5b2b1e5..2930471 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -24,6 +24,7 @@ version :
>  - KUX demuxer
>  - AV1 frame split bitstream filter
>  - lscr decoder
> +- cleanup applehttp in hls demuxer
>

If you read the other changelog entries, does this seem like matching
the pattern in there? :)
ChangeLog is for end-users, for changes that developers should care
about, there is APIchanges.

- Hendrik
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V1 2/2] lavf: bump version/add Changelog entry when cleanup applehttp

2019-04-16 Thread Paul B Mahol
On 4/16/19, Jun Zhao  wrote:
> From: Jun Zhao 
>
> commit abfeba9 "lavf/hls: Cleanup the applehttp" missed
> the version bump and Changelog entry.
>
> Signed-off-by: Jun Zhao 
> ---
>  Changelog |1 +
>  libavformat/version.h |2 +-
>  2 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/Changelog b/Changelog
> index 5b2b1e5..2930471 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -24,6 +24,7 @@ version :
>  - KUX demuxer
>  - AV1 frame split bitstream filter
>  - lscr decoder
> +- cleanup applehttp in hls demuxer


No.


>
>
>  version 4.1:
> diff --git a/libavformat/version.h b/libavformat/version.h
> index d57c151..150a72e 100644
> --- a/libavformat/version.h
> +++ b/libavformat/version.h
> @@ -33,7 +33,7 @@
>  // Also please add any ticket numbers that you believe might be affected
> here
>  #define LIBAVFORMAT_VERSION_MAJOR  58
>  #define LIBAVFORMAT_VERSION_MINOR  27
> -#define LIBAVFORMAT_VERSION_MICRO 102
> +#define LIBAVFORMAT_VERSION_MICRO 103
>
>  #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
> LIBAVFORMAT_VERSION_MINOR, \
> --
> 1.7.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3] avcodec: add AV_CODEC_FLAG_DROPCHANGED to flags

2019-04-16 Thread Gyan
Patch revised as per 
http://www.ffmpeg.org/pipermail/ffmpeg-devel/2019-April/242591.html


Gyan
From d97a89d0335cc6d11f111a7a6bebc891501837d2 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Sun, 14 Apr 2019 22:12:25 +0530
Subject: [PATCH v3] avcodec: add AV_CODEC_FLAG_DROPCHANGED to flags

Discard decoded frames which differ from first decoded frame in stream.
---
 doc/codecs.texi|  2 ++
 libavcodec/avcodec.h   |  8 +++
 libavcodec/decode.c| 47 +-
 libavcodec/internal.h  |  8 +++
 libavcodec/options_table.h |  1 +
 libavcodec/version.h   |  2 +-
 6 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/doc/codecs.texi b/doc/codecs.texi
index 572e561c1a..0baafee2e1 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -55,6 +55,8 @@ Do not draw edges.
 @item psnr
 Set error[?] variables during encoding.
 @item truncated
+@item drop_changed
+Don't output frames whose parameters differ from first decoded frame in stream.
 
 @item ildct
 Use interlaced DCT.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 9e37466641..b749946633 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -859,6 +859,11 @@ typedef struct RcOverride{
  * Use qpel MC.
  */
 #define AV_CODEC_FLAG_QPEL(1 <<  4)
+/**
+ * Don't output frames whose parameters differ from first
+ * decoded frame in stream.
+ */
+#define AV_CODEC_FLAG_DROPCHANGED (1 <<  5)
 /**
  * Use internal 2pass ratecontrol in first pass mode.
  */
@@ -4918,6 +4923,9 @@ int avcodec_send_packet(AVCodecContext *avctx, const 
AVPacket *avpkt);
  *  AVERROR_EOF:   the decoder has been fully flushed, and there will 
be
  * no more output frames
  *  AVERROR(EINVAL):   codec not opened, or it is an encoder
+ *  AVERROR_INPUT_CHANGED:   current decoded frame has changed parameters
+ *   with respect to first decoded frame. 
Applicable
+ *   when flag AV_CODEC_FLAG_DROPCHANGED is set.
  *  other negative values: legitimate decoding errors
  */
 int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame);
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index a32ff2fcd3..6c31166ec2 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -740,7 +740,7 @@ static int apply_cropping(AVCodecContext *avctx, AVFrame 
*frame)
 int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame 
*frame)
 {
 AVCodecInternal *avci = avctx->internal;
-int ret;
+int ret, changed;
 
 av_frame_unref(frame);
 
@@ -765,6 +765,51 @@ int attribute_align_arg 
avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr
 
 avctx->frame_number++;
 
+if (avctx->flags & AV_CODEC_FLAG_DROPCHANGED) {
+
+if (avctx->frame_number == 1) {
+avci->initial_format = frame->format;
+switch(avctx->codec_type) {
+case AVMEDIA_TYPE_VIDEO:
+avci->initial_width  = frame->width;
+avci->initial_height = frame->height;
+break;
+case AVMEDIA_TYPE_AUDIO:
+avci->initial_sample_rate = frame->sample_rate ? 
frame->sample_rate :
+ 
avctx->sample_rate;
+avci->initial_channels   = frame->channels;
+avci->initial_channel_layout = frame->channel_layout;
+break;
+}
+}
+
+if (avctx->frame_number > 1) {
+changed = avci->initial_format != frame->format;
+
+   switch(avctx->codec_type) {
+case AVMEDIA_TYPE_VIDEO:
+changed |= avci->initial_width  != frame->width ||
+   avci->initial_height != frame->height;
+break;
+case AVMEDIA_TYPE_AUDIO:
+changed |= avci->initial_sample_rate!= frame->sample_rate 
||
+   avci->initial_sample_rate!= avctx->sample_rate 
||
+   avci->initial_channels   != frame->channels ||
+   avci->initial_channel_layout != 
frame->channel_layout;
+break;
+}
+
+if (changed) {
+avci->changed_frames_dropped++;
+av_log(avctx, AV_LOG_INFO, "dropped changed frame #%d pts 
%"PRId64
+" drop count: %d \n",
+avctx->frame_number, frame->pts,
+avci->changed_frames_dropped);
+av_frame_unref(frame);
+return AVERROR_INPUT_CHANGED;
+}
+}
+}
 return 0;
 }
 
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index f2e6f00ace..5096ffa1d9 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -218,6 +218,14 @@ typedef struct AVCodecInternal