Re: [FFmpeg-devel] [PATCH 4/7] avformat/icecast: Use AV_DICT_DONT_STRDUP_VAL to save an av_strdup
On 10 Nov 2019, at 5:07, Andreas Rheinhardt wrote: This will probably also fix CID 1452559, a false positive where Coverity claims a double-free occurs, because it thinks that av_dict_set() frees its key and value arguments even when the AV_DICT_DONT_STRDUP_* flags aren't used. Signed-off-by: Andreas Rheinhardt --- libavformat/icecast.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavformat/icecast.c b/libavformat/icecast.c index 052cd37f3e..7d8f92fe73 100644 --- a/libavformat/icecast.c +++ b/libavformat/icecast.c @@ -114,7 +114,7 @@ static int icecast_open(URLContext *h, const char *uri, int flags) // Set options av_dict_set(&opt_dict, "method", s->legacy_icecast ? "SOURCE" : "PUT", 0); av_dict_set(&opt_dict, "auth_type", "basic", 0); -av_dict_set(&opt_dict, "headers", headers, 0); +av_dict_set(&opt_dict, "headers", headers, AV_DICT_DONT_STRDUP_VAL); av_dict_set(&opt_dict, "chunked_post", "0", 0); av_dict_set(&opt_dict, "send_expect_100", s->legacy_icecast ? "-1" : "1", 0); if (NOT_EMPTY(s->content_type)) @@ -170,7 +170,6 @@ static int icecast_open(URLContext *h, const char *uri, int flags) cleanup: av_freep(&user); -av_freep(&headers); av_dict_free(&opt_dict); return ret; -- 2.20.1 Thanks for the patch, LGTM. (I can’t push it though, so someone else needs to approve too and push this) ___ 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/7] avformat/icecast: Free the right buffer on error
On 19 Dec 2019, at 23:36, Andreas Rheinhardt wrote: > Michael Niedermayer: >> On Sun, Nov 10, 2019 at 05:07:29AM +0100, Andreas Rheinhardt wrote: >>> In case an AVBPrint was not complete, icecast_open() would free some >>> buffers that have not been allocated yet instead of freeing the data of >>> the AVBPrint (if they have been allocated). Because this error does not >>> trigger a jump to the general cleanup section any more, one can moreover >>> remove a (now unnecessary) initialization of a pointer. >>> >>> Furthermore, finalizing an AVBPrint can fail (namely when the string >>> inside the AVBPrint has not been allocated yet) and so this needs to be >>> checked. >>> >>> Signed-off-by: Andreas Rheinhardt >>> --- >>> libavformat/icecast.c | 9 + >>> 1 file changed, 5 insertions(+), 4 deletions(-) >> >> will apply >> >> thx >> >> [...] >> > Thanks. Can you also take a look at the follow-up patch [1]? > > - Andreas Sorry for the late reply, for some reason only saw this patch now… LGTM > > [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-November/252778.html > > ___ > 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 v2 3/7] avformat: Add av_stream_add_coded_side_data()
>> #define LIBAVFORMAT_VERSION_MAJOR 58 >> -#define LIBAVFORMAT_VERSION_MINOR 35 >> +#define LIBAVFORMAT_VERSION_MINOR 36 >> #define LIBAVFORMAT_VERSION_MICRO 101 >> >You forgot to reset micro. > >- Andreas Sorry, I just checked the git log and now understand how micro versions works. I will send a v3 with micro reset to 100. Nicolas ___ 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 3/7] avformat: Add av_stream_add_coded_side_data()
This will allow avformat_find_stream_info() get side data from the codec context. --- doc/APIchanges | 3 +++ libavformat/avformat.h | 11 +++ libavformat/utils.c| 15 +++ libavformat/version.h | 4 ++-- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 401c65a753..62b5effda7 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2019-12-19 - xx - lavf 58.36.101 - avformat.h + Add av_stream_add_coded_side_data(). + 2019-11-17 - 1c23abc88f - lavu 56.36.100 - eval API Add av_expr_count_vars(). diff --git a/libavformat/avformat.h b/libavformat/avformat.h index d4d9a3b06e..4dee1a272a 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2191,6 +2191,17 @@ int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, */ uint8_t *av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, int size); + +/** + * Add stream side_data from the coded_side_data of the supplied context. + * + * @param stream stream + * @param avctx the codec context that may contain coded_side_data + * @return >= 0 in case of success, a negative AVERROR code in case of + * failure + */ +int av_stream_add_coded_side_data(AVStream *stream, AVCodecContext *avctx); + /** * Get side information from stream. * diff --git a/libavformat/utils.c b/libavformat/utils.c index b472762dd1..fe92ad4a1d 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -5556,6 +5556,21 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type, return data; } +int av_stream_add_coded_side_data(AVStream *st, AVCodecContext *avctx) +{ +int i; + +for (i = 0; i < avctx->nb_coded_side_data; i++) { +const AVPacketSideData *sd_src = &avctx->coded_side_data[i]; +uint8_t *dst_data; +dst_data = av_stream_new_side_data(st, sd_src->type, sd_src->size); +if (!dst_data) +return AVERROR(ENOMEM); +memcpy(dst_data, sd_src->data, sd_src->size); +} +return 0; +} + int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *args) { int ret; diff --git a/libavformat/version.h b/libavformat/version.h index 213b66b45f..f72fb9478a 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,8 +32,8 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 -#define LIBAVFORMAT_VERSION_MINOR 35 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MINOR 36 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ -- 2.14.1.windows.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 v3 3/7] avformat: Add av_stream_add_coded_side_data()
Nicolas Gaullier: > This will allow avformat_find_stream_info() get side data from the codec > context. > --- > doc/APIchanges | 3 +++ > libavformat/avformat.h | 11 +++ > libavformat/utils.c| 15 +++ > libavformat/version.h | 4 ++-- > 4 files changed, 31 insertions(+), 2 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index 401c65a753..62b5effda7 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -15,6 +15,9 @@ libavutil: 2017-10-21 > > API changes, most recent first: > > +2019-12-19 - xx - lavf 58.36.101 - avformat.h > + Add av_stream_add_coded_side_data(). > + You forgot to update this version. - Andreas ___ 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 v4 3/7] avformat: Add av_stream_add_coded_side_data()
This will allow avformat_find_stream_info() get side data from the codec context. --- doc/APIchanges | 3 +++ libavformat/avformat.h | 11 +++ libavformat/utils.c| 15 +++ libavformat/version.h | 4 ++-- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 401c65a753..1c71e2bb39 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2019-12-20 - xx - lavf 58.36.100 - avformat.h + Add av_stream_add_coded_side_data(). + 2019-11-17 - 1c23abc88f - lavu 56.36.100 - eval API Add av_expr_count_vars(). diff --git a/libavformat/avformat.h b/libavformat/avformat.h index d4d9a3b06e..4dee1a272a 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2191,6 +2191,17 @@ int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, */ uint8_t *av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, int size); + +/** + * Add stream side_data from the coded_side_data of the supplied context. + * + * @param stream stream + * @param avctx the codec context that may contain coded_side_data + * @return >= 0 in case of success, a negative AVERROR code in case of + * failure + */ +int av_stream_add_coded_side_data(AVStream *stream, AVCodecContext *avctx); + /** * Get side information from stream. * diff --git a/libavformat/utils.c b/libavformat/utils.c index b472762dd1..fe92ad4a1d 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -5556,6 +5556,21 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type, return data; } +int av_stream_add_coded_side_data(AVStream *st, AVCodecContext *avctx) +{ +int i; + +for (i = 0; i < avctx->nb_coded_side_data; i++) { +const AVPacketSideData *sd_src = &avctx->coded_side_data[i]; +uint8_t *dst_data; +dst_data = av_stream_new_side_data(st, sd_src->type, sd_src->size); +if (!dst_data) +return AVERROR(ENOMEM); +memcpy(dst_data, sd_src->data, sd_src->size); +} +return 0; +} + int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *args) { int ret; diff --git a/libavformat/version.h b/libavformat/version.h index 213b66b45f..f72fb9478a 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,8 +32,8 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 -#define LIBAVFORMAT_VERSION_MINOR 35 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MINOR 36 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ -- 2.14.1.windows.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] avformat/mpegtsenc: warn users if codec isn't supported
Regards, Gyan From fbbd221b089f3b272cfd712c3d4824dd86b4eac0 Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Fri, 20 Dec 2019 16:39:32 +0530 Subject: [PATCH] avformat/mpegtsenc: warn users if codec isn't supported The MPEG-TS muxer will mux streams with unsupported codec id as a private data stream; this usually makes the stream not recognizable by ffmpeg and likely other tools. --- libavformat/mpegtsenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 5b4694bfd1..f24112465a 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -382,6 +382,7 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) stream_type = STREAM_TYPE_METADATA; break; default: +av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a private data stream and may not be recognized upon reading.\n", i, avcodec_get_name(st->codecpar->codec_id)); stream_type = STREAM_TYPE_PRIVATE_DATA; break; } -- 2.24.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] -progress option per output
Hi, I would like to work on a "per output" -progress option. I will try to implement this myself but before putting my hands on it I wanted to discuss about the different solutions with the community. I have three of them in mind Proposition 1. to put all output progress feedback in the same progress payload Proposition 2.to change the behavior of the progress option. make it an output option instead of a global option Proposition 3.to create a new per output progress option in order to do not break the current API I also wanted to add the duration of each output in the progress payload. Actually we can not infer the duration from the frame count because we are not always aware of the framerate. Does it seem relevant to you? 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".
[FFmpeg-devel] [PATCH] avcodec/hevcdec: keep closed captions in sync between multiple thread contexts
Based on h264 code. Signed-off-by: James Almer --- libavcodec/hevcdec.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index f8270b87c3..19b0cd815d 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -3463,6 +3463,13 @@ static int hevc_update_thread_context(AVCodecContext *dst, s->max_ra = INT_MAX; } +av_buffer_unref(&s->sei.a53_caption.buf_ref); +if (s0->sei.a53_caption.buf_ref) { +s->sei.a53_caption.buf_ref = av_buffer_ref(s0->sei.a53_caption.buf_ref); +if (!s->sei.a53_caption.buf_ref) +return AVERROR(ENOMEM); +} + s->sei.frame_packing= s0->sei.frame_packing; s->sei.display_orientation = s0->sei.display_orientation; s->sei.mastering_display= s0->sei.mastering_display; -- 2.24.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 v1] avcodec/hevc_sei: switch to AVBufferRef buffer for a53 caption
On 12/19/2019 10:17 PM, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > Please apply after the following patch: > https://patchwork.ffmpeg.org/patch/16878/ It doesn't really depend on it, so i'll apply it alone while that set is reviewed. Thanks. > > libavcodec/hevc_sei.c | 15 +++ > libavcodec/hevc_sei.h | 3 +-- > libavcodec/hevcdec.c | 16 > 3 files changed, 16 insertions(+), 18 deletions(-) > > diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c > index 7f738a049c..b87871e52a 100644 > --- a/libavcodec/hevc_sei.c > +++ b/libavcodec/hevc_sei.c > @@ -177,7 +177,8 @@ static int > decode_registered_user_data_closed_caption(HEVCSEIA53Caption *s, GetB > size -= 2; > > if (cc_count && size >= cc_count * 3) { > -const uint64_t new_size = (s->a53_caption_size + cc_count > +int old_size = s->buf_ref ? s->buf_ref->size : 0; > +const uint64_t new_size = (old_size + cc_count > * UINT64_C(3)); > int i, ret; > > @@ -185,14 +186,14 @@ static int > decode_registered_user_data_closed_caption(HEVCSEIA53Caption *s, GetB > return AVERROR(EINVAL); > > /* Allow merging of the cc data from two fields. */ > -ret = av_reallocp(&s->a53_caption, new_size); > +ret = av_buffer_realloc(&s->buf_ref, new_size); > if (ret < 0) > return ret; > > for (i = 0; i < cc_count; i++) { > -s->a53_caption[s->a53_caption_size++] = get_bits(gb, 8); > -s->a53_caption[s->a53_caption_size++] = get_bits(gb, 8); > -s->a53_caption[s->a53_caption_size++] = get_bits(gb, 8); > +s->buf_ref->data[old_size++] = get_bits(gb, 8); > +s->buf_ref->data[old_size++] = get_bits(gb, 8); > +s->buf_ref->data[old_size++] = get_bits(gb, 8); > } > skip_bits(gb, 8); // marker_bits > } > @@ -392,9 +393,7 @@ int ff_hevc_decode_nal_sei(GetBitContext *gb, void > *logctx, HEVCSEI *s, > > void ff_hevc_reset_sei(HEVCSEI *s) > { > -s->a53_caption.a53_caption_size = 0; > -av_freep(&s->a53_caption.a53_caption); > - > +av_buffer_unref(&s->a53_caption.buf_ref); > for (int i = 0; i < s->unregistered.nb_buf_ref; i++) > av_buffer_unref(&s->unregistered.buf_ref[i]); > s->unregistered.nb_buf_ref = 0; > diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h > index 2464117d47..a8a2ab7dc6 100644 > --- a/libavcodec/hevc_sei.h > +++ b/libavcodec/hevc_sei.h > @@ -83,8 +83,7 @@ typedef struct HEVCSEIPictureTiming { > } HEVCSEIPictureTiming; > > typedef struct HEVCSEIA53Caption { > -int a53_caption_size; > -uint8_t *a53_caption; > +AVBufferRef *buf_ref; > } HEVCSEIA53Caption; > > typedef struct HEVCSEIUnregistered { > diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c > index a4981e983c..451a58fb7f 100644 > --- a/libavcodec/hevcdec.c > +++ b/libavcodec/hevcdec.c > @@ -2778,14 +2778,14 @@ static int set_side_data(HEVCContext *s) > metadata->MaxCLL, metadata->MaxFALL); > } > > -if (s->sei.a53_caption.a53_caption) { > -AVFrameSideData* sd = av_frame_new_side_data(out, > - AV_FRAME_DATA_A53_CC, > - > s->sei.a53_caption.a53_caption_size); > -if (sd) > -memcpy(sd->data, s->sei.a53_caption.a53_caption, > s->sei.a53_caption.a53_caption_size); > -av_freep(&s->sei.a53_caption.a53_caption); > -s->sei.a53_caption.a53_caption_size = 0; > +if (s->sei.a53_caption.buf_ref) { > +HEVCSEIA53Caption *a53 = &s->sei.a53_caption; > + > +AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, > AV_FRAME_DATA_A53_CC, a53->buf_ref); > +if (!sd) > +av_buffer_unref(&a53->buf_ref); > +a53->buf_ref = NULL; > + > s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; > } > > ___ 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 v3 2/5] avcodec/hevc_sei: add support for user data unregistered SEI message
On 12/19/2019 2:09 AM, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavcodec/hevc_sei.c | 34 + > libavcodec/hevc_sei.h | 6 + > libavcodec/hevcdec.c| 18 +++ > tests/ref/fate/hevc-monochrome-crop | 3 +++ > 4 files changed, 61 insertions(+) > > diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c > index c59bd4321e..7f738a049c 100644 > --- a/libavcodec/hevc_sei.c > +++ b/libavcodec/hevc_sei.c > @@ -206,6 +206,33 @@ static int > decode_registered_user_data_closed_caption(HEVCSEIA53Caption *s, GetB > return 0; > } > > +static int decode_nal_sei_user_data_unregistered(HEVCSEIUnregistered *s, > GetBitContext *gb, > + int size) > +{ > +AVBufferRef *buf_ref, **tmp; > + > +if (size < 16) > + return AVERROR(EINVAL); > + > +if (s->nb_buf_ref > INT_MAX / sizeof(*s->buf_ref) - 1) > + return AVERROR(EINVAL); > + > +tmp = av_realloc(s->buf_ref, (s->nb_buf_ref + 1) * sizeof(*s->buf_ref)); Use av_realloc_array() instead and you can remove the above check. > +if (!tmp) > +return AVERROR(ENOMEM); > +s->buf_ref = tmp; > + > +buf_ref = av_buffer_alloc(size); > +if (!buf_ref) > +return AVERROR(ENOMEM); > + > +for (int i = 0; i < size; i++) > +buf_ref->data[i] = get_bits(gb, 8); > +s->buf_ref[s->nb_buf_ref++] = buf_ref; > + > +return 0; > +} > + > static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, > GetBitContext *gb, > int size) > { > @@ -293,6 +320,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void > *logctx, HEVCSEI *s, > return decode_nal_sei_active_parameter_sets(s, gb, logctx); > case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: > return decode_nal_sei_user_data_registered_itu_t_t35(s, gb, size); > +case HEVC_SEI_TYPE_USER_DATA_UNREGISTERED: > +return decode_nal_sei_user_data_unregistered(&s->unregistered, gb, > size); > case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: > return decode_nal_sei_alternative_transfer(&s->alternative_transfer, > gb); > default: > @@ -365,4 +394,9 @@ void ff_hevc_reset_sei(HEVCSEI *s) > { > s->a53_caption.a53_caption_size = 0; > av_freep(&s->a53_caption.a53_caption); > + > +for (int i = 0; i < s->unregistered.nb_buf_ref; i++) > +av_buffer_unref(&s->unregistered.buf_ref[i]); > +s->unregistered.nb_buf_ref = 0; > +av_freep(&s->unregistered.buf_ref); > } > diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h > index f6516ae982..2464117d47 100644 > --- a/libavcodec/hevc_sei.h > +++ b/libavcodec/hevc_sei.h > @@ -87,6 +87,11 @@ typedef struct HEVCSEIA53Caption { > uint8_t *a53_caption; > } HEVCSEIA53Caption; > > +typedef struct HEVCSEIUnregistered { > +AVBufferRef **buf_ref; > +int nb_buf_ref; > +} HEVCSEIUnregistered; > + > typedef struct HEVCSEIMasteringDisplay { > int present; > uint16_t display_primaries[3][2]; > @@ -112,6 +117,7 @@ typedef struct HEVCSEI { > HEVCSEIDisplayOrientation display_orientation; > HEVCSEIPictureTiming picture_timing; > HEVCSEIA53Caption a53_caption; > +HEVCSEIUnregistered unregistered; > HEVCSEIMasteringDisplay mastering_display; > HEVCSEIContentLight content_light; > int active_seq_parameter_set_id; > diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c > index 8f1c162ace..a4981e983c 100644 > --- a/libavcodec/hevcdec.c > +++ b/libavcodec/hevcdec.c > @@ -2789,6 +2789,24 @@ static int set_side_data(HEVCContext *s) > s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; > } > > +for (int i = 0; i < s->sei.unregistered.nb_buf_ref; i++) { > +HEVCSEIUnregistered *unreg = &s->sei.unregistered; > + > +if (unreg->buf_ref[i]) { > +AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, > +AV_FRAME_DATA_USER_DATA_UNREGISTERED, > +unreg->buf_ref[i]); > +if (!sd) > +av_buffer_unref(&unreg->buf_ref[i]); > +unreg->buf_ref[i] = NULL; > +} > +} > + > +if (s->sei.unregistered.nb_buf_ref > 0) { > +s->sei.unregistered.nb_buf_ref = 0; > +av_freep(&s->sei.unregistered.buf_ref); No need to free the array since it can be reused. And if it's never reused, it will be freed by ff_hevc_reset_sei() anyway. Just set s->sei.unregistered.nb_buf_ref to 0 unconditionally. > +} > + > return 0; > } > > diff --git a/tests/ref/fate/hevc-monochrome-crop > b/tests/ref/fate/hevc-monochrome-crop > index 4e45412acf..43f0abbcfa 100644 > --- a/tests/ref/fate/hevc-monochrome-crop > +++ b/tests/ref/fate/hevc-monochrome-crop > @@ -1,6 +1,9 @@ > [FRAME] > width=384 > height=240 > +[SIDE_DATA] >
Re: [FFmpeg-devel] [PATCH v3 3/5] avfilter/vf_showinfo: display user data unregistered message
On 12/19/2019 2:09 AM, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavfilter/vf_showinfo.c | 33 + > 1 file changed, 33 insertions(+) > > diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c > index 31f6b32aa4..bb3b37e0c5 100644 > --- a/libavfilter/vf_showinfo.c > +++ b/libavfilter/vf_showinfo.c > @@ -169,6 +169,36 @@ static void dump_content_light_metadata(AVFilterContext > *ctx, AVFrameSideData *s > metadata->MaxCLL, metadata->MaxFALL); > } > > +static int string_is_ascii(const uint8_t *str) > +{ > +while (*str && *str < 128) str++; I don't think the buffer is guaranteed to end with \0. You have sd->size, so you should probably use that, while also ensuring it ends with a \0 so the av_log below using %s works as intended. Also < 128 includes DEL. And you're not checking for >= 32. > +return !*str; > +} > + > +static void dump_user_data_unregistered_metadata(AVFilterContext *ctx, > AVFrameSideData *sd) > +{ > +const int uuid_size = 16; > +uint8_t *user_data = sd->data; > + > +if (sd->size < uuid_size) { > +av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", > sd->size, uuid_size); > +return; > +} > + > +av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n"); > +av_log(ctx, AV_LOG_INFO, "UUID="); > +for (int i = 0; i < uuid_size; i++) > +av_log(ctx, AV_LOG_INFO, "%x", user_data[i]); > +av_log(ctx, AV_LOG_INFO, "\n"); > + > +user_data += uuid_size; > +/* Only print the user data details if it's string */ > +if (string_is_ascii(user_data)) { > +av_log(ctx, AV_LOG_INFO, "User Data="); > +av_log(ctx, AV_LOG_INFO, "%s", user_data); > +} > +} > + > static void dump_color_property(AVFilterContext *ctx, AVFrame *frame) > { > const char *color_range_str = > av_color_range_name(frame->color_range); > @@ -319,6 +349,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *frame) > av_log(ctx, AV_LOG_INFO, "GOP timecode - %s", tcbuf); > break; > } > +case AV_FRAME_DATA_USER_DATA_UNREGISTERED: > +dump_user_data_unregistered_metadata(ctx, sd); > +break; > default: > av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d > bytes)", > sd->type, sd->size); > ___ 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] Add a commandline option to control loop restoration for libaom
On Wed, Dec 18, 2019 at 7:25 PM Wang Cao wrote: > > Signed-off-by: Wang Cao > --- > libavcodec/libaomenc.c | 6 ++ Can you update doc/encoders.texi with this detail please? ___ 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] doc/encoders: correct the description for ts_target_bitrate
On Wed, Dec 18, 2019 at 4:17 PM Wonkap Jang wrote: > > ts_target_bitrate is in kbps, not bps. This commit clarifies the unit > and modifies the example to match the description. > --- > doc/encoders.texi | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > applied, 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] [PATCHv2] movenc: Write durations based on pts into mvhd/mdhd/tkhd/elst
On Tue, Dec 17, 2019 at 03:15:09PM +0200, Martin Storsjö wrote: > Keep all the existing data fields as they are (there's lots and > lots of nontrivial calculation and heuristics based on them in > their current form), but derive the duration as the difference > between the pts of the first packet to the maximum pts+duration > (not necessarily the last packet); use this duration in any box > where the actual presentation duration is supposed to be. > > Fixes: 8420 > --- > Fixed to fetch the duration for tmcd tracks from their designated > source track. > --- > libavformat/movenc.c | 35 --- > 1 file changed, 28 insertions(+), 7 deletions(-) I found another case that changes, again dont know which is more correct make -j12 && ./ffmpeg -i ~/tickets/3453/mov_with_tmcd.mov -y -bitexact -codec copy -map 0 -t 2 file.mov ; ./ffprobe -v 0 file.mov -show_packets -print_format compact > /tmp/before --- /tmp/before 2019-12-20 23:28:04.009327038 +0100 +++ /tmp/after 2019-12-20 23:27:17.213326052 +0100 @@ -188,7 +188,7 @@ packet|codec_type=audio|stream_index=1|pts=88320|pts_time=1.84|dts=88320|dts_time=1.84|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=4096|pos=408905|flags=K_ packet|codec_type=data|stream_index=2|pts=46|pts_time=1.84|dts=46|dts_time=1.84|duration=1|duration_time=0.04|convergence_duration=N/A|convergence_duration_time=N/A|size=4|pos=413001|flags=K_ packet|codec_type=audio|stream_index=1|pts=89344|pts_time=1.861333|dts=89344|dts_time=1.861333|duration=896|duration_time=0.018667|convergence_duration=N/A|convergence_duration_time=N/A|size=3584|pos=413005|flags=K_ -packet|codec_type=video|stream_index=0|pts=26624|pts_time=2.08|dts=24064|dts_time=1.88|duration=512|duration_time=0.04|convergence_duration=N/A|convergence_duration_time=N/A|size=776|pos=416589|flags=_D +packet|codec_type=video|stream_index=0|pts=26624|pts_time=2.08|dts=24064|dts_time=1.88|duration=512|duration_time=0.04|convergence_duration=N/A|convergence_duration_time=N/A|size=776|pos=416589|flags=__ packet|codec_type=audio|stream_index=1|pts=90240|pts_time=1.88|dts=90240|dts_time=1.88|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=4096|pos=417365|flags=K_ packet|codec_type=data|stream_index=2|pts=47|pts_time=1.88|dts=47|dts_time=1.88|duration=1|duration_time=0.04|convergence_duration=N/A|convergence_duration_time=N/A|size=4|pos=421461|flags=K_ packet|codec_type=audio|stream_index=1|pts=91264|pts_time=1.901333|dts=91264|dts_time=1.901333|duration=896|duration_time=0.018667|convergence_duration=N/A|convergence_duration_time=N/A|size=3584|pos=421465|flags=K_ file should be here: https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket3453/ [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Awnsering whenever a program halts or runs forever is On a turing machine, in general impossible (turings halting problem). On any real computer, always possible as a real computer has a finite number of states N, and will either halt in less than N cycles or never halt. 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".
[FFmpeg-devel] [PATCH] nvenc: implement flush to help allow an encoder to be re-used
It can be useful to re-use an encoder instance when doing segmented encodings, and this requires flushing the encoder at the start of each segment. --- libavcodec/nvenc.c | 5 + libavcodec/nvenc.h | 2 ++ libavcodec/nvenc_h264.c | 1 + libavcodec/nvenc_hevc.c | 1 + 4 files changed, 9 insertions(+) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 310e30805d..9a96bf2bba 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -2262,3 +2262,8 @@ int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, return 0; } + +av_cold void ff_nvenc_encode_flush(AVCodecContext *avctx) +{ +ff_nvenc_send_frame(avctx, NULL); +} diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index a269bd97bb..c44c81e675 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -214,6 +214,8 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, AVPacket *pkt); int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet); +void ff_nvenc_encode_flush(AVCodecContext *avctx); + extern const enum AVPixelFormat ff_nvenc_pix_fmts[]; #endif /* AVCODEC_NVENC_H */ diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index d5c7370aaa..479155fe15 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -240,6 +240,7 @@ AVCodec ff_h264_nvenc_encoder = { .receive_packet = ff_nvenc_receive_packet, .encode2= ff_nvenc_encode_frame, .close = ff_nvenc_encode_close, +.flush = ff_nvenc_encode_flush, .priv_data_size = sizeof(NvencContext), .priv_class = &h264_nvenc_class, .defaults = defaults, diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c index c668b97f86..7c9b3848f1 100644 --- a/libavcodec/nvenc_hevc.c +++ b/libavcodec/nvenc_hevc.c @@ -198,6 +198,7 @@ AVCodec ff_hevc_nvenc_encoder = { .receive_packet = ff_nvenc_receive_packet, .encode2= ff_nvenc_encode_frame, .close = ff_nvenc_encode_close, +.flush = ff_nvenc_encode_flush, .priv_data_size = sizeof(NvencContext), .priv_class = &hevc_nvenc_class, .defaults = defaults, -- 2.20.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][DISCUSS] nvenc: Add encoder flush API.
On 2019-11-18 17:13, Josh Allmann wrote: This patch is meant to be an entry point for discussion around an issue we are having with flushing the nvenc encoder while doing segmented transcoding. Hopefully there will be a less kludgey workaround than this. Hi Josh, I happened to see your email recently, and took a quick look into this. It seems that encoders are allowed to implement .flush() and then avcodec_flush_buffers() can be called on them like on a decoder. So I've posted a patch that does this (with the same impl that you had). If that works for you, then that's all it takes - no need for a new API call because there's already one you can use. Let us know, --phil ___ 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][DISCUSS] nvenc: Add encoder flush API.
On Fri, 20 Dec 2019 at 15:36, Philip Langdale wrote: > > On 2019-11-18 17:13, Josh Allmann wrote: > > This patch is meant to be an entry point for discussion around an > > issue we are having with flushing the nvenc encoder while doing > > segmented transcoding. Hopefully there will be a less kludgey > > workaround than this. > > Hi Josh, > > I happened to see your email recently, and took a quick look into > this. It seems that encoders are allowed to implement .flush() and > then avcodec_flush_buffers() can be called on them like on a > decoder. So I've posted a patch that does this (with the same impl > that you had). If that works for you, then that's all it takes - > no need for a new API call because there's already one you can use. That would be perfect - thought .flush() was decode-only for some reason. Thank you! Josh ___ 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] nvenc: implement flush to help allow an encoder to be re-used
On Fri, 20 Dec 2019 at 15:34, Philip Langdale wrote: > > It can be useful to re-use an encoder instance when doing segmented > encodings, and this requires flushing the encoder at the start of > each segment. > --- > libavcodec/nvenc.c | 5 + > libavcodec/nvenc.h | 2 ++ > libavcodec/nvenc_h264.c | 1 + > libavcodec/nvenc_hevc.c | 1 + > 4 files changed, 9 insertions(+) > > diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c > index 310e30805d..9a96bf2bba 100644 > --- a/libavcodec/nvenc.c > +++ b/libavcodec/nvenc.c > @@ -2262,3 +2262,8 @@ int ff_nvenc_encode_frame(AVCodecContext *avctx, > AVPacket *pkt, > > return 0; > } > + > +av_cold void ff_nvenc_encode_flush(AVCodecContext *avctx) > +{ > +ff_nvenc_send_frame(avctx, NULL); One concern I had was about the long-term stability of this behavior. Right now, it works, but perhaps only coincidentally? Being flushable and resumable like this isn't explicitly part of the "contract" for nvenc, as far as I can see. Could future changes inadvertently introduce state that isn't reset in between flushes, breaking the resumable behavior? If so, is there a way to safeguard against that? Josh ___ 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][DISCUSS] nvenc: Add encoder flush API.
On Fri, 20 Dec 2019 at 19:03, Josh Allmann wrote: > > On Fri, 20 Dec 2019 at 15:36, Philip Langdale wrote: > > > > On 2019-11-18 17:13, Josh Allmann wrote: > > > This patch is meant to be an entry point for discussion around an > > > issue we are having with flushing the nvenc encoder while doing > > > segmented transcoding. Hopefully there will be a less kludgey > > > workaround than this. > > > > Hi Josh, > > > > I happened to see your email recently, and took a quick look into > > this. It seems that encoders are allowed to implement .flush() and > > then avcodec_flush_buffers() can be called on them like on a > > decoder. So I've posted a patch that does this (with the same impl > > that you had). If that works for you, then that's all it takes - > > no need for a new API call because there's already one you can use. > > That would be perfect - thought .flush() was decode-only for some > reason. Thank you! > > Josh Related: For CLI usage, does this affect the behavior of the global output option -flush_packets 1 When the NVENC encoder is in use, in any way? ___ 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 v3 2/5] avcodec/hevc_sei: add support for user data unregistered SEI message
On Fri, Dec 20, 2019 at 02:23:40PM -0300, James Almer wrote: > On 12/19/2019 2:09 AM, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavcodec/hevc_sei.c | 34 + > > libavcodec/hevc_sei.h | 6 + > > libavcodec/hevcdec.c| 18 +++ > > tests/ref/fate/hevc-monochrome-crop | 3 +++ > > 4 files changed, 61 insertions(+) > > > > diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c > > index c59bd4321e..7f738a049c 100644 > > --- a/libavcodec/hevc_sei.c > > +++ b/libavcodec/hevc_sei.c > > @@ -206,6 +206,33 @@ static int > > decode_registered_user_data_closed_caption(HEVCSEIA53Caption *s, GetB > > return 0; > > } > > > > +static int decode_nal_sei_user_data_unregistered(HEVCSEIUnregistered *s, > > GetBitContext *gb, > > + int size) > > +{ > > +AVBufferRef *buf_ref, **tmp; > > + > > +if (size < 16) > > + return AVERROR(EINVAL); > > + > > +if (s->nb_buf_ref > INT_MAX / sizeof(*s->buf_ref) - 1) > > + return AVERROR(EINVAL); > > + > > +tmp = av_realloc(s->buf_ref, (s->nb_buf_ref + 1) * > > sizeof(*s->buf_ref)); > > Use av_realloc_array() instead and you can remove the above check. will update to use it > > > +if (!tmp) > > +return AVERROR(ENOMEM); > > +s->buf_ref = tmp; > > + > > +buf_ref = av_buffer_alloc(size); > > +if (!buf_ref) > > +return AVERROR(ENOMEM); > > + > > +for (int i = 0; i < size; i++) > > +buf_ref->data[i] = get_bits(gb, 8); > > +s->buf_ref[s->nb_buf_ref++] = buf_ref; > > + > > +return 0; > > +} > > + > > static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, > > GetBitContext *gb, > > int size) > > { > > @@ -293,6 +320,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, > > void *logctx, HEVCSEI *s, > > return decode_nal_sei_active_parameter_sets(s, gb, logctx); > > case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: > > return decode_nal_sei_user_data_registered_itu_t_t35(s, gb, size); > > +case HEVC_SEI_TYPE_USER_DATA_UNREGISTERED: > > +return decode_nal_sei_user_data_unregistered(&s->unregistered, gb, > > size); > > case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: > > return > > decode_nal_sei_alternative_transfer(&s->alternative_transfer, gb); > > default: > > @@ -365,4 +394,9 @@ void ff_hevc_reset_sei(HEVCSEI *s) > > { > > s->a53_caption.a53_caption_size = 0; > > av_freep(&s->a53_caption.a53_caption); > > + > > +for (int i = 0; i < s->unregistered.nb_buf_ref; i++) > > +av_buffer_unref(&s->unregistered.buf_ref[i]); > > +s->unregistered.nb_buf_ref = 0; > > +av_freep(&s->unregistered.buf_ref); > > } > > diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h > > index f6516ae982..2464117d47 100644 > > --- a/libavcodec/hevc_sei.h > > +++ b/libavcodec/hevc_sei.h > > @@ -87,6 +87,11 @@ typedef struct HEVCSEIA53Caption { > > uint8_t *a53_caption; > > } HEVCSEIA53Caption; > > > > +typedef struct HEVCSEIUnregistered { > > +AVBufferRef **buf_ref; > > +int nb_buf_ref; > > +} HEVCSEIUnregistered; > > + > > typedef struct HEVCSEIMasteringDisplay { > > int present; > > uint16_t display_primaries[3][2]; > > @@ -112,6 +117,7 @@ typedef struct HEVCSEI { > > HEVCSEIDisplayOrientation display_orientation; > > HEVCSEIPictureTiming picture_timing; > > HEVCSEIA53Caption a53_caption; > > +HEVCSEIUnregistered unregistered; > > HEVCSEIMasteringDisplay mastering_display; > > HEVCSEIContentLight content_light; > > int active_seq_parameter_set_id; > > diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c > > index 8f1c162ace..a4981e983c 100644 > > --- a/libavcodec/hevcdec.c > > +++ b/libavcodec/hevcdec.c > > @@ -2789,6 +2789,24 @@ static int set_side_data(HEVCContext *s) > > s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; > > } > > > > +for (int i = 0; i < s->sei.unregistered.nb_buf_ref; i++) { > > +HEVCSEIUnregistered *unreg = &s->sei.unregistered; > > + > > +if (unreg->buf_ref[i]) { > > +AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, > > +AV_FRAME_DATA_USER_DATA_UNREGISTERED, > > +unreg->buf_ref[i]); > > +if (!sd) > > +av_buffer_unref(&unreg->buf_ref[i]); > > +unreg->buf_ref[i] = NULL; > > +} > > +} > > + > > +if (s->sei.unregistered.nb_buf_ref > 0) { > > +s->sei.unregistered.nb_buf_ref = 0; > > +av_freep(&s->sei.unregistered.buf_ref); > > No need to free the array since it can be reused. And if it's never > reused, it will be freed by ff_hevc_reset_sei() anyway. > > Just set s->sei.unregistered.nb_buf_ref t
Re: [FFmpeg-devel] [PATCH v3 3/5] avfilter/vf_showinfo: display user data unregistered message
On Fri, Dec 20, 2019 at 02:30:23PM -0300, James Almer wrote: > On 12/19/2019 2:09 AM, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavfilter/vf_showinfo.c | 33 + > > 1 file changed, 33 insertions(+) > > > > diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c > > index 31f6b32aa4..bb3b37e0c5 100644 > > --- a/libavfilter/vf_showinfo.c > > +++ b/libavfilter/vf_showinfo.c > > @@ -169,6 +169,36 @@ static void > > dump_content_light_metadata(AVFilterContext *ctx, AVFrameSideData *s > > metadata->MaxCLL, metadata->MaxFALL); > > } > > > > +static int string_is_ascii(const uint8_t *str) > > +{ > > +while (*str && *str < 128) str++; > > I don't think the buffer is guaranteed to end with \0. You have > sd->size, so you should probably use that, while also ensuring it ends > with a \0 so the av_log below using %s works as intended. If the str has any '\0', it'll end immediately, even < sd->size still, for the print %s will work like that. In case it's end without '\0', we don't consider it's string, so it'll not print out like binary code. Below is the example: 'hello\0'will print hello 'hello\0tty' will print hello 'hello' don't print > > Also < 128 includes DEL. And you're not checking for >= 32. I consider LF(\r), CR(\n) should be expected ascii, for example the string may be json format, so I change to include all valid ascii including the control character(0-31 and 121). For example 'hello\ncc'will print hello cc > > > +return !*str; > > +} > > + > > +static void dump_user_data_unregistered_metadata(AVFilterContext *ctx, > > AVFrameSideData *sd) > > +{ > > +const int uuid_size = 16; > > +uint8_t *user_data = sd->data; > > + > > +if (sd->size < uuid_size) { > > +av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", > > sd->size, uuid_size); > > +return; > > +} > > + > > +av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n"); > > +av_log(ctx, AV_LOG_INFO, "UUID="); > > +for (int i = 0; i < uuid_size; i++) > > +av_log(ctx, AV_LOG_INFO, "%x", user_data[i]); > > +av_log(ctx, AV_LOG_INFO, "\n"); > > + > > +user_data += uuid_size; > > +/* Only print the user data details if it's string */ > > +if (string_is_ascii(user_data)) { > > +av_log(ctx, AV_LOG_INFO, "User Data="); > > +av_log(ctx, AV_LOG_INFO, "%s", user_data); > > +} > > +} > > + > > static void dump_color_property(AVFilterContext *ctx, AVFrame *frame) > > { > > const char *color_range_str = > > av_color_range_name(frame->color_range); > > @@ -319,6 +349,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > > *frame) > > av_log(ctx, AV_LOG_INFO, "GOP timecode - %s", tcbuf); > > break; > > } > > +case AV_FRAME_DATA_USER_DATA_UNREGISTERED: > > +dump_user_data_unregistered_metadata(ctx, sd); > > +break; > > default: > > av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d > > bytes)", > > sd->type, sd->size); > > > > ___ > 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/hevcdec: keep closed captions in sync between multiple thread contexts
On Fri, Dec 20, 2019 at 02:05:42PM -0300, James Almer wrote: > Based on h264 code. > > Signed-off-by: James Almer > --- > libavcodec/hevcdec.c | 7 +++ > 1 file changed, 7 insertions(+) > > diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c > index f8270b87c3..19b0cd815d 100644 > --- a/libavcodec/hevcdec.c > +++ b/libavcodec/hevcdec.c > @@ -3463,6 +3463,13 @@ static int hevc_update_thread_context(AVCodecContext > *dst, > s->max_ra = INT_MAX; > } > > +av_buffer_unref(&s->sei.a53_caption.buf_ref); > +if (s0->sei.a53_caption.buf_ref) { > +s->sei.a53_caption.buf_ref = > av_buffer_ref(s0->sei.a53_caption.buf_ref); > +if (!s->sei.a53_caption.buf_ref) > +return AVERROR(ENOMEM); > +} > + LGTM > s->sei.frame_packing= s0->sei.frame_packing; > s->sei.display_orientation = s0->sei.display_orientation; > s->sei.mastering_display= s0->sei.mastering_display; > -- > 2.24.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".
Re: [FFmpeg-devel] [PATCH v3 4/5] avcodec/h264_sei: fix the size of user data unregistered
On 12/19/2019 2:09 AM, lance.lmw...@gmail.com wrote: > From: Limin Wang > > According to the specifications, the payloadSize includes the 16-byte size of > UUID. > > Signed-off-by: Limin Wang > --- > libavcodec/h264_sei.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c > index d4eb9c0dab..a565feabe2 100644 > --- a/libavcodec/h264_sei.c > +++ b/libavcodec/h264_sei.c > @@ -247,14 +247,14 @@ static int > decode_unregistered_user_data(H264SEIUnregistered *h, GetBitContext * > uint8_t *user_data; > int e, build, i; > > -if (size < 16 || size >= INT_MAX - 16) > +if (size < 16 || size >= INT_MAX - 1) > return AVERROR_INVALIDDATA; > > -user_data = av_malloc(16 + size + 1); > +user_data = av_malloc(size + 1); > if (!user_data) > return AVERROR(ENOMEM); > > -for (i = 0; i < size + 16; i++) > +for (i = 0; i < size; i++) > user_data[i] = get_bits(gb, 8); > > user_data[i] = 0; Applied, 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".
[FFmpeg-devel] [PATCH v4 4/4] avcodec/h264: create user data unregistered side data H.264
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/h264_sei.c | 20 +++-- libavcodec/h264_sei.h | 2 + libavcodec/h264_slice.c | 14 tests/ref/fate/mov-zombie | 195 ++ 4 files changed, 161 insertions(+), 70 deletions(-) diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index a565fea..43e2814 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -52,6 +52,10 @@ void ff_h264_sei_uninit(H264SEIContext *h) h->afd.present = 0; av_buffer_unref(&h->a53_caption.buf_ref); +for (int i = 0; i < h->unregistered.nb_buf_ref; i++) +av_buffer_unref(&h->unregistered.buf_ref[i]); +h->unregistered.nb_buf_ref = 0; +av_freep(&h->unregistered.buf_ref); } static int decode_picture_timing(H264SEIPictureTiming *h, GetBitContext *gb, @@ -246,25 +250,31 @@ static int decode_unregistered_user_data(H264SEIUnregistered *h, GetBitContext * { uint8_t *user_data; int e, build, i; +AVBufferRef *buf_ref, **tmp; -if (size < 16 || size >= INT_MAX - 1) +if (size < 16) return AVERROR_INVALIDDATA; -user_data = av_malloc(size + 1); -if (!user_data) +tmp = av_realloc_array(h->buf_ref, h->nb_buf_ref + 1, sizeof(*h->buf_ref)); +if (!tmp) return AVERROR(ENOMEM); +h->buf_ref = tmp; + +buf_ref = av_buffer_alloc(size); +if (!buf_ref) +return AVERROR(ENOMEM); +user_data = buf_ref->data; for (i = 0; i < size; i++) user_data[i] = get_bits(gb, 8); +h->buf_ref[h->nb_buf_ref++] = buf_ref; -user_data[i] = 0; e = sscanf(user_data + 16, "x264 - core %d", &build); if (e == 1 && build > 0) h->x264_build = build; if (e == 1 && build == 1 && !strncmp(user_data+16, "x264 - core ", 16)) h->x264_build = 67; -av_free(user_data); return 0; } diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h index a75c3aa..aa4595f 100644 --- a/libavcodec/h264_sei.h +++ b/libavcodec/h264_sei.h @@ -121,6 +121,8 @@ typedef struct H264SEIA53Caption { typedef struct H264SEIUnregistered { int x264_build; +AVBufferRef **buf_ref; +int nb_buf_ref; } H264SEIUnregistered; typedef struct H264SEIRecoveryPoint { diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index e24d41c..ea967c8 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1285,6 +1285,20 @@ static int h264_export_frame_props(H264Context *h) h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; } +for (int i = 0; i < h->sei.unregistered.nb_buf_ref; i++) { +H264SEIUnregistered *unreg = &h->sei.unregistered; + +if (unreg->buf_ref[i]) { +AVFrameSideData *sd = av_frame_new_side_data_from_buf(cur->f, +AV_FRAME_DATA_USER_DATA_UNREGISTERED, +unreg->buf_ref[i]); +if (!sd) +av_buffer_unref(&unreg->buf_ref[i]); +unreg->buf_ref[i] = NULL; +} +} +h->sei.unregistered.nb_buf_ref = 0; + if (h->sei.picture_timing.timecode_cnt > 0) { uint32_t tc = 0; uint32_t *tc_sd; diff --git a/tests/ref/fate/mov-zombie b/tests/ref/fate/mov-zombie index f45fa59..0888295 100644 --- a/tests/ref/fate/mov-zombie +++ b/tests/ref/fate/mov-zombie @@ -1,133 +1,198 @@ packet|codec_type=video|stream_index=0|pts=0|pts_time=0.00|dts=-3004|dts_time=-0.033378|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=4133|pos=11309|flags=K_ packet|codec_type=video|stream_index=0|pts=5440|pts_time=0.060444|dts=-567|dts_time=-0.006300|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=1077|pos=15442|flags=__ -frame|media_type=video|stream_index=0|key_frame=1|pkt_pts=0|pkt_pts_time=0.00|pkt_dts=-567|pkt_dts_time=-0.006300|best_effort_timestamp=0|best_effort_timestamp_time=0.00|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=11309|pkt_size=4133|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleft +frame|media_type=video|stream_index=0|key_frame=1|pkt_pts=0|pkt_pts_time=0.00|pkt_dts=-567|pkt_dts_time=-0.006300|best_effort_timestamp=0|best_effort_timestamp_time=0.00|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=11309|pkt_size=4133|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=User Data Unregistered + packet|codec_type=video|stream_index=0|pts=2437|pts_time=0.0
[FFmpeg-devel] [PATCH v4 2/4] avcodec/hevc_sei: add support for user data unregistered SEI message
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/hevc_sei.c | 31 +++ libavcodec/hevc_sei.h | 6 ++ libavcodec/hevcdec.c| 14 ++ tests/ref/fate/hevc-monochrome-crop | 3 +++ 4 files changed, 54 insertions(+) diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c index daca9d5..4c9a2b4 100644 --- a/libavcodec/hevc_sei.c +++ b/libavcodec/hevc_sei.c @@ -207,6 +207,30 @@ static int decode_registered_user_data_closed_caption(HEVCSEIA53Caption *s, GetB return 0; } +static int decode_nal_sei_user_data_unregistered(HEVCSEIUnregistered *s, GetBitContext *gb, + int size) +{ +AVBufferRef *buf_ref, **tmp; + +if (size < 16) + return AVERROR(EINVAL); + +tmp = av_realloc_array(s->buf_ref, s->nb_buf_ref + 1, sizeof(*s->buf_ref)); +if (!tmp) +return AVERROR(ENOMEM); +s->buf_ref = tmp; + +buf_ref = av_buffer_alloc(size); +if (!buf_ref) +return AVERROR(ENOMEM); + +for (int i = 0; i < size; i++) +buf_ref->data[i] = get_bits(gb, 8); +s->buf_ref[s->nb_buf_ref++] = buf_ref; + +return 0; +} + static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetBitContext *gb, int size) { @@ -294,6 +318,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s, return decode_nal_sei_active_parameter_sets(s, gb, logctx); case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: return decode_nal_sei_user_data_registered_itu_t_t35(s, gb, size); +case HEVC_SEI_TYPE_USER_DATA_UNREGISTERED: +return decode_nal_sei_user_data_unregistered(&s->unregistered, gb, size); case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: return decode_nal_sei_alternative_transfer(&s->alternative_transfer, gb); default: @@ -365,4 +391,9 @@ int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s, void ff_hevc_reset_sei(HEVCSEI *s) { av_buffer_unref(&s->a53_caption.buf_ref); + +for (int i = 0; i < s->unregistered.nb_buf_ref; i++) +av_buffer_unref(&s->unregistered.buf_ref[i]); +s->unregistered.nb_buf_ref = 0; +av_freep(&s->unregistered.buf_ref); } diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h index 2769d41..a8a2ab7 100644 --- a/libavcodec/hevc_sei.h +++ b/libavcodec/hevc_sei.h @@ -86,6 +86,11 @@ typedef struct HEVCSEIA53Caption { AVBufferRef *buf_ref; } HEVCSEIA53Caption; +typedef struct HEVCSEIUnregistered { +AVBufferRef **buf_ref; +int nb_buf_ref; +} HEVCSEIUnregistered; + typedef struct HEVCSEIMasteringDisplay { int present; uint16_t display_primaries[3][2]; @@ -111,6 +116,7 @@ typedef struct HEVCSEI { HEVCSEIDisplayOrientation display_orientation; HEVCSEIPictureTiming picture_timing; HEVCSEIA53Caption a53_caption; +HEVCSEIUnregistered unregistered; HEVCSEIMasteringDisplay mastering_display; HEVCSEIContentLight content_light; int active_seq_parameter_set_id; diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index f8270b8..18385df 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2789,6 +2789,20 @@ static int set_side_data(HEVCContext *s) s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; } +for (int i = 0; i < s->sei.unregistered.nb_buf_ref; i++) { +HEVCSEIUnregistered *unreg = &s->sei.unregistered; + +if (unreg->buf_ref[i]) { +AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, +AV_FRAME_DATA_USER_DATA_UNREGISTERED, +unreg->buf_ref[i]); +if (!sd) +av_buffer_unref(&unreg->buf_ref[i]); +unreg->buf_ref[i] = NULL; +} +} +s->sei.unregistered.nb_buf_ref = 0; + return 0; } diff --git a/tests/ref/fate/hevc-monochrome-crop b/tests/ref/fate/hevc-monochrome-crop index 4e45412..43f0abb 100644 --- a/tests/ref/fate/hevc-monochrome-crop +++ b/tests/ref/fate/hevc-monochrome-crop @@ -1,6 +1,9 @@ [FRAME] width=384 height=240 +[SIDE_DATA] +side_data_type=User Data Unregistered +[/SIDE_DATA] [/FRAME] [STREAM] width=384 -- 2.9.5 ___ 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][DISCUSS] nvenc: Add encoder flush API.
On Fri, 20 Dec 2019 19:12:00 -0500 Dennis Mungai wrote: > On Fri, 20 Dec 2019 at 19:03, Josh Allmann > > For CLI usage, does this affect the behavior of the global output > option > > -flush_packets 1 > > When the NVENC encoder is in use, in any way? It's unrelated. This is a muxer level (avio specific, in fact) option. It doesn't affect decoders or encoders. --phil ___ 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] Changelog: Fix typo of comments
Signed-off-by: Steven Liu --- Changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index d654ea5321..2b576b8051 100644 --- a/Changelog +++ b/Changelog @@ -5,8 +5,8 @@ version : - v360 filter - Intel QSV-accelerated MJPEG decoding - Intel QSV-accelerated VP9 decoding -- support for TrueHD in mp4 -- Supoort AMD AMF encoder on Linux (via Vulkan) +- Support for TrueHD in mp4 +- Support AMD AMF encoder on Linux (via Vulkan) - IMM5 video decoder - ZeroMQ protocol - support Sipro ACELP.KELVIN decoding -- 2.17.2 (Apple Git-113) ___ 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".