[FFmpeg-cvslog] cmdutils: stop using deprecated av_codec_next()
ffmpeg | branch: master | Anton Khirnov | Tue Apr 14 10:09:24 2020 +0200| [4cde83c780761b1f611d130285a5aee47d0be657] | committer: Josh de Kock cmdutils: stop using deprecated av_codec_next() Signed-off-by: Josh de Kock > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4cde83c780761b1f611d130285a5aee47d0be657 --- fftools/cmdutils.c | 33 +++-- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index f0f2b4fde4..7f5a5ca664 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -1500,13 +1500,14 @@ static char get_media_type_char(enum AVMediaType type) } } -static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev, +static const AVCodec *next_codec_for_id(enum AVCodecID id, void **iter, int encoder) { -while ((prev = av_codec_next(prev))) { -if (prev->id == id && -(encoder ? av_codec_is_encoder(prev) : av_codec_is_decoder(prev))) -return prev; +const AVCodec *c; +while ((c = av_codec_iterate(iter))) { +if (c->id == id && +(encoder ? av_codec_is_encoder(c) : av_codec_is_decoder(c))) +return c; } return NULL; } @@ -1543,11 +1544,12 @@ static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs) static void print_codecs_for_id(enum AVCodecID id, int encoder) { -const AVCodec *codec = NULL; +void *iter = NULL; +const AVCodec *codec; printf(" (%s: ", encoder ? "encoders" : "decoders"); -while ((codec = next_codec_for_id(id, codec, encoder))) +while ((codec = next_codec_for_id(id, &iter, encoder))) printf("%s ", codec->name); printf(")"); @@ -1570,7 +1572,8 @@ int show_codecs(void *optctx, const char *opt, const char *arg) " ---\n"); for (i = 0; i < nb_codecs; i++) { const AVCodecDescriptor *desc = codecs[i]; -const AVCodec *codec = NULL; +const AVCodec *codec; +void *iter = NULL; if (strstr(desc->name, "_deprecated")) continue; @@ -1588,14 +1591,14 @@ int show_codecs(void *optctx, const char *opt, const char *arg) /* print decoders/encoders when there's more than one or their * names are different from codec name */ -while ((codec = next_codec_for_id(desc->id, codec, 0))) { +while ((codec = next_codec_for_id(desc->id, &iter, 0))) { if (strcmp(codec->name, desc->name)) { print_codecs_for_id(desc->id, 0); break; } } -codec = NULL; -while ((codec = next_codec_for_id(desc->id, codec, 1))) { +iter = NULL; +while ((codec = next_codec_for_id(desc->id, &iter, 1))) { if (strcmp(codec->name, desc->name)) { print_codecs_for_id(desc->id, 1); break; @@ -1626,9 +1629,10 @@ static void print_codecs(int encoder) encoder ? "Encoders" : "Decoders"); for (i = 0; i < nb_codecs; i++) { const AVCodecDescriptor *desc = codecs[i]; -const AVCodec *codec = NULL; +const AVCodec *codec; +void *iter = NULL; -while ((codec = next_codec_for_id(desc->id, codec, encoder))) { +while ((codec = next_codec_for_id(desc->id, &iter, encoder))) { printf(" %c", get_media_type_char(desc->type)); printf((codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ? "F" : "."); printf((codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ? "S" : "."); @@ -1833,9 +1837,10 @@ static void show_help_codec(const char *name, int encoder) if (codec) print_codec(codec); else if ((desc = avcodec_descriptor_get_by_name(name))) { +void *iter = NULL; int printed = 0; -while ((codec = next_codec_for_id(desc->id, codec, encoder))) { +while ((codec = next_codec_for_id(desc->id, &iter, encoder))) { printed = 1; print_codec(codec); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc: stop using deprecated av_codec_next()
ffmpeg | branch: master | Josh de Kock | Tue Apr 14 13:33:01 2020 +0100| [bd2e7b74e1ed1bb050cabc46925ba65f6d87d351] | committer: Josh de Kock lavc: stop using deprecated av_codec_next() Signed-off-by: Josh de Kock > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bd2e7b74e1ed1bb050cabc46925ba65f6d87d351 --- libavcodec/options.c | 7 --- libavcodec/tests/utils.c | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libavcodec/options.c b/libavcodec/options.c index 35e8ac9313..7706a03297 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -55,15 +55,16 @@ static void *codec_child_next(void *obj, void *prev) static const AVClass *codec_child_class_next(const AVClass *prev) { -AVCodec *c = NULL; +void *iter = NULL; +const AVCodec *c = NULL; /* find the codec that corresponds to prev */ -while (prev && (c = av_codec_next(c))) +while (prev && (c = av_codec_iterate(&iter))) if (c->priv_class == prev) break; /* find next codec with priv options */ -while (c = av_codec_next(c)) +while (c = av_codec_iterate(&iter)) if (c->priv_class) return c->priv_class; return NULL; diff --git a/libavcodec/tests/utils.c b/libavcodec/tests/utils.c index f6ba7fe66e..9232647ff0 100644 --- a/libavcodec/tests/utils.c +++ b/libavcodec/tests/utils.c @@ -19,10 +19,11 @@ #include "libavcodec/avcodec.h" int main(void){ -AVCodec *codec = NULL; +void *iter = NULL; +const AVCodec *codec = NULL; int ret = 0; -while (codec = av_codec_next(codec)) { +while (codec = av_codec_iterate(&iter)) { if (av_codec_is_encoder(codec)) { if (codec->type == AVMEDIA_TYPE_AUDIO) { if (!codec->sample_fmts) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavf/utils: stop using deprecated av_codec_next()
ffmpeg | branch: master | Josh de Kock | Tue Apr 14 12:21:52 2020 +0100| [43c648817d2cc65d78070d5926f1fb83e8e9] | committer: Josh de Kock lavf/utils: stop using deprecated av_codec_next() Signed-off-by: Josh de Kock > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=43c648817d2cc65d78070d5926f1fb83e8e9 --- libavformat/utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index a58e47fabc..4f777ba849 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -222,7 +222,8 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st, if (codec->capabilities & AV_CODEC_CAP_AVOID_PROBING) { const AVCodec *probe_codec = NULL; -while (probe_codec = av_codec_next(probe_codec)) { +void *iter = NULL; +while ((probe_codec = av_codec_iterate(&iter))) { if (probe_codec->id == codec_id && av_codec_is_decoder(probe_codec) && !(probe_codec->capabilities & (AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_EXPERIMENTAL))) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] tools: stop using deprecated av_codec_next()
ffmpeg | branch: master | Josh de Kock | Tue Apr 14 13:34:53 2020 +0100| [39962072a83eb846d8f2aa7757a0ff33cc3dad51] | committer: Josh de Kock tools: stop using deprecated av_codec_next() Signed-off-by: Josh de Kock > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=39962072a83eb846d8f2aa7757a0ff33cc3dad51 --- tools/enum_options.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/enum_options.c b/tools/enum_options.c index 28631d1a6b..548e427b7a 100644 --- a/tools/enum_options.c +++ b/tools/enum_options.c @@ -113,13 +113,14 @@ static void show_format_opts(void) static void show_codec_opts(void) { +void *iter = NULL; AVCodec *c = NULL; printf("@section Generic codec AVOptions\n"); show_opts(avcodec_get_class()); printf("@section Codec-specific AVOptions\n"); -while ((c = av_codec_next(c))) { +while ((c = av_codec_iterate(&iter))) { if (!c->priv_class) continue; printf("@subsection %s AVOptions\n", c->priv_class->class_name); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/movenc: cosmetics
ffmpeg | branch: master | Limin Wang | Sat Apr 4 11:46:27 2020 +0800| [a97281699bc7973e91fb22788d7ac40b17e737aa] | committer: Josh de Kock avformat/movenc: cosmetics Signed-off-by: Limin Wang Signed-off-by: Josh de Kock > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a97281699bc7973e91fb22788d7ac40b17e737aa --- libavformat/movenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index bf3e4fa2ce..253cff86eb 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2688,7 +2688,7 @@ static int mov_write_hdlr_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra } else { hdlr_type = "text"; } -descr = "SubtitleHandler"; +descr = "SubtitleHandler"; } } else if (track->par->codec_tag == MKTAG('r','t','p',' ')) { hdlr_type = "hint"; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/rtsp: Don't free uninitialized AVBPrint
ffmpeg | branch: master | Andreas Rheinhardt | Mon Apr 20 03:31:56 2020 +0200| [87b056e6af0ccebc6813c54c88b5eb78ac06faf2] | committer: Andreas Rheinhardt avformat/rtsp: Don't free uninitialized AVBPrint Fixes Coverity ID 1462307. Reviewed-by: Marton Balint Reviewed-by: Ross Nicholson Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=87b056e6af0ccebc6813c54c88b5eb78ac06faf2 --- libavformat/rtsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 49f7644fab..0a6462000d 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -2567,8 +2567,8 @@ static int rtp_read_header(AVFormatContext *s) fail_nobuf: ret = AVERROR(ENOMEM); av_log(s, AV_LOG_ERROR, "rtp_read_header(): not enough buffer space for sdp-headers\n"); -fail: av_bprint_finalize(&sdp, NULL); +fail: avcodec_parameters_free(&par); if (in) ffurl_close(in); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/rtsp: Put strings instead of pointers to strings into array
ffmpeg | branch: master | Andreas Rheinhardt | Fri Apr 3 15:02:07 2020 +0200| [4e254ec6be86977d9ea173f1769398f153bd1d28] | committer: Andreas Rheinhardt avformat/rtsp: Put strings instead of pointers to strings into array In this example, the difference in length between the shortest and longest string is three, so that not using pointers to strings saves space even on 32bit systems. Moreover, there is no need to use a sentinel here; it can be replaced with FF_ARRAY_ELEMS. Reviewed-by: Ross Nicholson Reviewed-by: Marton Balint Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4e254ec6be86977d9ea173f1769398f153bd1d28 --- libavformat/rtsp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 0a6462000d..b2b3f32011 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -2526,10 +2526,11 @@ static int rtp_read_header(AVFormatContext *s) p = strchr(s->url, '?'); if (p) { -static const char *filters[][2] = {{"sources", "incl"}, {"block", "excl"}, {NULL, NULL}}; +static const char filters[][2][8] = { { "sources", "incl" }, + { "block", "excl" } }; int i; char *q; -for (i = 0; filters[i][0]; i++) { +for (i = 0; i < FF_ARRAY_ELEMS(filters); i++) { if (av_find_info_tag(filters_buf, sizeof(filters_buf), filters[i][0], p)) { q = filters_buf; while ((q = strchr(q, ',')) != NULL) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/bsf: Use macro for "packet is empty"
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 19 21:18:51 2020 +0200| [ee593bff984bed20a35e2a98119d82a1bcf6d3bd] | committer: Andreas Rheinhardt avcodec/bsf: Use macro for "packet is empty" Reviewed-by: Anton Khirnov Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ee593bff984bed20a35e2a98119d82a1bcf6d3bd --- libavcodec/bsf.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c index b9fc771a88..68fee82e0d 100644 --- a/libavcodec/bsf.c +++ b/libavcodec/bsf.c @@ -28,6 +28,8 @@ #include "avcodec.h" #include "bsf.h" +#define IS_EMPTY(pkt) (!(pkt)->data && !(pkt)->side_data_elems) + struct AVBSFInternal { AVPacket *buffer_pkt; int eof; @@ -195,7 +197,7 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt) AVBSFInternal *bsfi = ctx->internal; int ret; -if (!pkt || (!pkt->data && !pkt->side_data_elems)) { +if (!pkt || IS_EMPTY(pkt)) { bsfi->eof = 1; return 0; } @@ -205,8 +207,7 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt) return AVERROR(EINVAL); } -if (bsfi->buffer_pkt->data || -bsfi->buffer_pkt->side_data_elems) +if (!IS_EMPTY(bsfi->buffer_pkt)) return AVERROR(EAGAIN); ret = av_packet_make_refcounted(pkt); @@ -230,8 +231,7 @@ int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt) if (bsfi->eof) return AVERROR_EOF; -if (!bsfi->buffer_pkt->data && -!bsfi->buffer_pkt->side_data_elems) +if (IS_EMPTY(bsfi->buffer_pkt)) return AVERROR(EAGAIN); tmp_pkt = av_packet_alloc(); @@ -251,8 +251,7 @@ int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt) if (bsfi->eof) return AVERROR_EOF; -if (!bsfi->buffer_pkt->data && -!bsfi->buffer_pkt->side_data_elems) +if (IS_EMPTY(bsfi->buffer_pkt)) return AVERROR(EAGAIN); av_packet_move_ref(pkt, bsfi->buffer_pkt); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/utils: Fix memleak when decoding subtitle in find_stream_info
ffmpeg | branch: master | Andreas Rheinhardt | Sat Apr 18 21:36:09 2020 +0200| [d026fef999f7e2491721b3878bea6e6da8b9f92e] | committer: Andreas Rheinhardt avformat/utils: Fix memleak when decoding subtitle in find_stream_info avformat_find_stream_info() may decode some frames to get stream information. And when it does this for subtitles, the decoded subtitles leak. (Decoding subtitles was added in b1511e00f6fefde6cb31b2e17f7812cfac1c8bd6 for PGS subtitles. When PGS subtitles originate from a container that exports every segment as a packet of its own, no output will be generated when decoding a packet, because not enough input is available. Yet when used with PGS subtitles in the Matroska form a single packet contains enough data to generate output. Yet said output is not freed, hence this leak.) Reviewed-by: Anton Khirnov Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d026fef999f7e2491721b3878bea6e6da8b9f92e --- libavformat/utils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/utils.c b/libavformat/utils.c index 4f777ba849..2fb2309f68 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3126,6 +3126,8 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, } else if (avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) { ret = avcodec_decode_subtitle2(avctx, &subtitle, &got_picture, &pkt); +if (got_picture) +avsubtitle_free(&subtitle); if (ret >= 0) pkt.size = 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/oggenc: Don't free AVStream's priv_data, fix memleak
ffmpeg | branch: master | Andreas Rheinhardt | Tue Apr 14 04:30:59 2020 +0200| [0fcf74f4357e949f5971d39b04a128103b8949bb] | committer: Andreas Rheinhardt avformat/oggenc: Don't free AVStream's priv_data, fix memleak For FLAC, Speex, Opus and VP8 the Ogg muxer allocates two buffers for building the headers: The first for extradata in an Ogg-specific format and the second contains a Vorbiscomment. These buffers are reachable via pointers in the corresponding AVStream's priv_data. If an error happens during building the headers, the AVStream's priv_data would be freed. This is pointless in general as it would be freed generically anyway, but here it is actively harmful: If the second of the aforementioned allocations fails, the first buffer would leak upon freeing priv_data. This commit stops freeing priv_data manually, which allows the muxer to properly clean up in the deinit function. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0fcf74f4357e949f5971d39b04a128103b8949bb --- libavformat/oggenc.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index fe89f23e36..fbd14fedf9 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -546,7 +546,6 @@ static int ogg_init(AVFormatContext *s) &st->metadata); if (err) { av_log(s, AV_LOG_ERROR, "Error writing FLAC headers\n"); -av_freep(&st->priv_data); return err; } } else if (st->codecpar->codec_id == AV_CODEC_ID_SPEEX) { @@ -555,7 +554,6 @@ static int ogg_init(AVFormatContext *s) &st->metadata); if (err) { av_log(s, AV_LOG_ERROR, "Error writing Speex headers\n"); -av_freep(&st->priv_data); return err; } } else if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) { @@ -564,7 +562,6 @@ static int ogg_init(AVFormatContext *s) &st->metadata, s->chapters, s->nb_chapters); if (err) { av_log(s, AV_LOG_ERROR, "Error writing Opus headers\n"); -av_freep(&st->priv_data); return err; } } else if (st->codecpar->codec_id == AV_CODEC_ID_VP8) { @@ -572,7 +569,6 @@ static int ogg_init(AVFormatContext *s) s->flags & AVFMT_FLAG_BITEXACT); if (err) { av_log(s, AV_LOG_ERROR, "Error writing VP8 headers\n"); -av_freep(&st->priv_data); return err; } } else { @@ -585,7 +581,7 @@ static int ogg_init(AVFormatContext *s) st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 30 : 42, (const uint8_t**)oggstream->header, oggstream->header_len) < 0) { av_log(s, AV_LOG_ERROR, "Extradata corrupted\n"); -av_freep(&st->priv_data); +oggstream->header[1] = NULL; return AVERROR_INVALIDDATA; } @@ -755,7 +751,6 @@ static void ogg_free(AVFormatContext *s) av_freep(&oggstream->header[0]); } av_freep(&oggstream->header[1]); -av_freep(&st->priv_data); } while (p) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/qpeg: export missing frame properties
ffmpeg | branch: master | James Almer | Fri Apr 17 00:03:30 2020 -0300| [18bb1d40c1546c573efbec3709fc99a40e79076e] | committer: James Almer avcodec/qpeg: export missing frame properties Reviewed-by: Anton Khirnov Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=18bb1d40c1546c573efbec3709fc99a40e79076e --- libavcodec/qpeg.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index 3fde6381f2..22afd9fa81 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -270,7 +270,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame * const p = data; AVFrame * const ref = a->ref; uint8_t* outdata; -int delta, ret; +int delta, intra, ret; int pal_size; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size); @@ -289,7 +289,8 @@ static int decode_frame(AVCodecContext *avctx, bytestream2_skip(&a->buffer, 1); delta = bytestream2_get_byte(&a->buffer); -if(delta == 0x10) { +intra = delta == 0x10; +if (intra) { qpeg_decode_intra(a, outdata, p->linesize[0], avctx->width, avctx->height); } else { qpeg_decode_inter(a, outdata, p->linesize[0], avctx->width, avctx->height, delta, ctable, ref->data[0]); @@ -308,6 +309,9 @@ static int decode_frame(AVCodecContext *avctx, if ((ret = av_frame_ref(ref, p)) < 0) return ret; +p->key_frame = intra; +p->pict_type = intra ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; + *got_frame = 1; return avpkt->size; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/qpeg: remove an unnecessary intermediary AVFrame
ffmpeg | branch: master | James Almer | Thu Apr 16 23:20:43 2020 -0300| [1b13023860a6ede2699153bcad0bbb8bb72f6e38] | committer: James Almer avcodec/qpeg: remove an unnecessary intermediary AVFrame Decoding can be handled directly in the output frame. Also ensure flushing cleans the reference frame in all cases. Reviewed-by: Anton Khirnov Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1b13023860a6ede2699153bcad0bbb8bb72f6e38 --- libavcodec/qpeg.c | 22 +- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index d4195c5f0b..3fde6381f2 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -30,7 +30,7 @@ typedef struct QpegContext{ AVCodecContext *avctx; -AVFrame *pic, *ref; +AVFrame *ref; uint32_t pal[256]; GetByteContext buffer; } QpegContext; @@ -267,7 +267,7 @@ static int decode_frame(AVCodecContext *avctx, { uint8_t ctable[128]; QpegContext * const a = avctx->priv_data; -AVFrame * const p = a->pic; +AVFrame * const p = data; AVFrame * const ref = a->ref; uint8_t* outdata; int delta, ret; @@ -281,9 +281,6 @@ static int decode_frame(AVCodecContext *avctx, bytestream2_init(&a->buffer, avpkt->data, avpkt->size); -av_frame_unref(ref); -av_frame_move_ref(ref, p); - if ((ret = ff_get_buffer(avctx, p, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; outdata = p->data[0]; @@ -307,7 +304,8 @@ static int decode_frame(AVCodecContext *avctx, } memcpy(p->data[1], a->pal, AVPALETTE_SIZE); -if ((ret = av_frame_ref(data, p)) < 0) +av_frame_unref(ref); +if ((ret = av_frame_ref(ref, p)) < 0) return ret; *got_frame = 1; @@ -320,6 +318,8 @@ static void decode_flush(AVCodecContext *avctx){ int i, pal_size; const uint8_t *pal_src; +av_frame_unref(a->ref); + pal_size = FFMIN(1024U, avctx->extradata_size); pal_src = avctx->extradata + avctx->extradata_size - pal_size; @@ -331,7 +331,6 @@ static av_cold int decode_end(AVCodecContext *avctx) { QpegContext * const a = avctx->priv_data; -av_frame_free(&a->pic); av_frame_free(&a->ref); return 0; @@ -343,14 +342,11 @@ static av_cold int decode_init(AVCodecContext *avctx){ a->avctx = avctx; avctx->pix_fmt= AV_PIX_FMT_PAL8; -decode_flush(avctx); - -a->pic = av_frame_alloc(); a->ref = av_frame_alloc(); -if (!a->pic || !a->ref) { -decode_end(avctx); +if (!a->ref) return AVERROR(ENOMEM); -} + +decode_flush(avctx); return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/qpeg: mark the init function as thread-safe and init cleanup capable
ffmpeg | branch: master | James Almer | Fri Apr 17 00:03:37 2020 -0300| [795ff53f188f4eb67074422211cb3e282c5eec17] | committer: James Almer avcodec/qpeg: mark the init function as thread-safe and init cleanup capable Reviewed-by: Anton Khirnov Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=795ff53f188f4eb67074422211cb3e282c5eec17 --- libavcodec/qpeg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index 22afd9fa81..84304cae3b 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -366,4 +366,6 @@ AVCodec ff_qpeg_decoder = { .decode = decode_frame, .flush = decode_flush, .capabilities = AV_CODEC_CAP_DR1, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_INIT_CLEANUP, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/dashenc: add a maxSegmentDuration attribute to the Manifest
ffmpeg | branch: master | James Almer | Wed Apr 15 18:02:44 2020 -0300| [0ea41ee32e7cf5d9bad7abf5b4f659bd1641efdb] | committer: James Almer avformat/dashenc: add a maxSegmentDuration attribute to the Manifest Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0ea41ee32e7cf5d9bad7abf5b4f659bd1641efdb --- libavformat/dashenc.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 5a8cff4034..ef1bedd18d 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -190,6 +190,7 @@ typedef struct DASHContext { int frag_type; int write_prft; int64_t max_gop_size; +int64_t max_segment_duration; int profile; int64_t target_latency; int target_latency_refid; @@ -1189,6 +1190,9 @@ static int write_manifest(AVFormatContext *s, int final) avio_printf(out, "\"\n"); } } +avio_printf(out, "\tmaxSegmentDuration=\""); +write_time(out, c->max_segment_duration); +avio_printf(out, "\"\n"); avio_printf(out, "\tminBufferTime=\""); write_time(out, c->ldash && c->max_gop_size ? c->max_gop_size : c->last_duration * 2); avio_printf(out, "\">\n"); @@ -1564,6 +1568,8 @@ static int dash_init(AVFormatContext *s) os->frag_duration = as->frag_duration; os->frag_type = as->frag_type; +c->max_segment_duration = FFMAX(c->max_segment_duration, as->seg_duration); + if (c->profile & MPD_PROFILE_DVB && (os->seg_duration > 1500 || os->seg_duration < 96)) { av_log(s, AV_LOG_ERROR, "Segment duration %"PRId64" is outside the allowed range for DVB-DASH profile\n", os->seg_duration); return AVERROR(EINVAL); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/dashenc: add missing startWithSap attribute to AdaptationSet elements
ffmpeg | branch: master | James Almer | Wed Apr 15 22:41:02 2020 -0300| [1f5d6e6b665089194d06ec39ab613b060d8807b7] | committer: James Almer avformat/dashenc: add missing startWithSap attribute to AdaptationSet elements Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1f5d6e6b665089194d06ec39ab613b060d8807b7 --- libavformat/dashenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 86329b7f9a..b08253618d 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -806,7 +806,7 @@ static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_ind AVDictionaryEntry *lang, *role; int i; -avio_printf(out, "\t\tid, as->media_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio"); if (as->media_type == AVMEDIA_TYPE_VIDEO && as->max_frame_rate.num && !as->ambiguous_frame_rate && av_cmp_q(as->min_frame_rate, as->max_frame_rate) < 0) avio_printf(out, " maxFrameRate=\"%d/%d\"", as->max_frame_rate.num, as->max_frame_rate.den); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] doc/muxers: fix some dashenc option names
ffmpeg | branch: master | James Almer | Wed Apr 15 22:47:44 2020 -0300| [fd0f110a37cbfc4f57d656a9ae7b52175f85f041] | committer: James Almer doc/muxers: fix some dashenc option names Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fd0f110a37cbfc4f57d656a9ae7b52175f85f041 --- doc/muxers.texi | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index e5b8debcb3..856ed74e56 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -339,20 +339,20 @@ Enable Low-latency Dash by constraining the presence and values of some elements @item master_m3u8_publish_rate @var{master_m3u8_publish_rate} Publish master playlist repeatedly every after specified number of segment intervals. -@item -write_prft @var{write_prft} +@item write_prft @var{write_prft} Write Producer Reference Time elements on supported streams. This also enables writing prft boxes in the underlying muxer. Applicable only when the @var{utc_url} option is enabled. It's set to auto by default, in which case the muxer will attempt to enable it only in modes that require it. -@item -mpd_profile @var{mpd_profile} +@item mpd_profile @var{mpd_profile} Set one or more manifest profiles. -@item -http_opts @var{http_opts} +@item http_opts @var{http_opts} A :-separated list of key=value options to pass to the underlying HTTP protocol. Applicable only for HTTP output. -@item -target_latency @var{target_latency} +@item target_latency @var{target_latency} Set an intended target latency in seconds (fractional value can be set) for serving. Applicable only when @var{streaming} and @var{write_prft} options are enabled. This is an informative fields clients can use to measure the latency of the service. ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/dashenc: add a PlaybackRate element
ffmpeg | branch: master | James Almer | Wed Apr 15 22:36:10 2020 -0300| [ff327a58f1377dc6b1bae2fef12c3750f9e5f698] | committer: James Almer avformat/dashenc: add a PlaybackRate element Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ff327a58f1377dc6b1bae2fef12c3750f9e5f698 --- doc/muxers.texi | 8 libavformat/dashenc.c | 18 -- libavformat/version.h | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 856ed74e56..d341827a86 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -356,6 +356,14 @@ protocol. Applicable only for HTTP output. Set an intended target latency in seconds (fractional value can be set) for serving. Applicable only when @var{streaming} and @var{write_prft} options are enabled. This is an informative fields clients can use to measure the latency of the service. +@item min_playback_rate @var{min_playback_rate} +Set the minimum playback rate indicated as appropriate for the purposes of automatically +adjusting playback latency and buffer occupancy during normal playback by clients. + +@item max_playback_rate @var{max_playback_rate} +Set the maximum playback rate indicated as appropriate for the purposes of automatically +adjusting playback latency and buffer occupancy during normal playback by clients. + @end table @anchor{framecrc} diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index ef1bedd18d..86329b7f9a 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -194,6 +194,8 @@ typedef struct DASHContext { int profile; int64_t target_latency; int target_latency_refid; +AVRational min_playback_rate; +AVRational max_playback_rate; } DASHContext; static struct codec_string { @@ -1203,14 +1205,19 @@ static int write_manifest(AVFormatContext *s, int final) av_free(escaped); } avio_printf(out, "\t\n"); + +avio_printf(out, "\t\n"); if (!final && c->target_latency && c->target_latency_refid >= 0) { -avio_printf(out, "\t\n"); avio_printf(out, "\t\ttarget_latency / 1000); if (s->nb_streams > 1) avio_printf(out, " referenceId=\"%d\"", c->target_latency_refid); avio_printf(out, "/>\n"); -avio_printf(out, "\t\n"); } +if (av_cmp_q(c->min_playback_rate, (AVRational) {1, 1}) || +av_cmp_q(c->max_playback_rate, (AVRational) {1, 1})) +avio_printf(out, "\t\t\n", +av_q2d(c->min_playback_rate), av_q2d(c->max_playback_rate)); +avio_printf(out, "\t\n"); if (c->window_size && s->nb_streams > 0 && c->streams[0].nb_segments > 0 && !c->use_template) { OutputStream *os = &c->streams[0]; @@ -1423,6 +1430,11 @@ static int dash_init(AVFormatContext *s) c->target_latency = 0; } +if (av_cmp_q(c->max_playback_rate, c->min_playback_rate) < 0) { +av_log(s, AV_LOG_WARNING, "Minimum playback rate value is higer than the Maximum. Both will be ignored\n"); +c->min_playback_rate = c->max_playback_rate = (AVRational) {1, 1}; +} + av_strlcpy(c->dirname, s->url, sizeof(c->dirname)); ptr = strrchr(c->dirname, '/'); if (ptr) { @@ -2370,6 +2382,8 @@ static const AVOption options[] = { { "dvb_dash", "DVB-DASH profile", 0, AV_OPT_TYPE_CONST, {.i64 = MPD_PROFILE_DVB }, 0, UINT_MAX, E, "mpd_profile"}, { "http_opts", "HTTP protocol options", OFFSET(http_opts), AV_OPT_TYPE_DICT, { .str = NULL }, 0, 0, E }, { "target_latency", "Set desired target latency for Low-latency dash", OFFSET(target_latency), AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT_MAX, E }, +{ "min_playback_rate", "Set desired minimum playback rate", OFFSET(min_playback_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 1.0 }, 0.5, 1.5, E }, +{ "max_playback_rate", "Set desired maximum playback rate", OFFSET(max_playback_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 1.0 }, 0.5, 1.5, E }, { NULL }, }; diff --git a/libavformat/version.h b/libavformat/version.h index 18c2f5fec2..719cda6b98 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 42 -#define LIBAVFORMAT_VERSION_MICRO 100 +#define LIBAVFORMAT_VERSION_MICRO 101 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fate: move TrueHD tests to their own file
ffmpeg | branch: master | James Almer | Sun Apr 19 11:48:37 2020 -0300| [051d5b284e4f56a55d9d4a3cffd7b6f1ac000bfe] | committer: James Almer fate: move TrueHD tests to their own file Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=051d5b284e4f56a55d9d4a3cffd7b6f1ac000bfe --- tests/Makefile | 1 + tests/fate/lossless-audio.mak | 6 -- tests/fate/truehd.mak | 12 tests/ref/fate/lossless-truehd-5.1 | 1 - tests/ref/fate/lossless-truehd-5.1-downmix-2.0 | 1 - 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index bf5b658926..ab3c235f25 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -187,6 +187,7 @@ include $(SRC_PATH)/tests/fate/segment.mak include $(SRC_PATH)/tests/fate/source.mak include $(SRC_PATH)/tests/fate/speedhq.mak include $(SRC_PATH)/tests/fate/subtitles.mak +include $(SRC_PATH)/tests/fate/truehd.mak include $(SRC_PATH)/tests/fate/utvideo.mak include $(SRC_PATH)/tests/fate/video.mak include $(SRC_PATH)/tests/fate/voice.mak diff --git a/tests/fate/lossless-audio.mak b/tests/fate/lossless-audio.mak index d29285328d..66ac6d8972 100644 --- a/tests/fate/lossless-audio.mak +++ b/tests/fate/lossless-audio.mak @@ -13,12 +13,6 @@ fate-lossless-shorten: CMD = md5 -i $(TARGET_SAMPLES)/lossless-audio/luckynight- FATE_SAMPLES_LOSSLESS_AUDIO-$(call DEMDEC, TAK, TAK) += fate-lossless-tak fate-lossless-tak: CMD = crc -i $(TARGET_SAMPLES)/lossless-audio/luckynight-partial.tak -FATE_TRUEHD = fate-lossless-truehd-5.1 fate-lossless-truehd-5.1-downmix-2.0 -fate-lossless-truehd-5.1: CMD = md5 -f truehd -i $(TARGET_SAMPLES)/lossless-audio/truehd_5.1.raw -f s32le -fate-lossless-truehd-5.1-downmix-2.0: CMD = md5 -f truehd -request_channel_layout 2 -i $(TARGET_SAMPLES)/lossless-audio/truehd_5.1.raw -f s32le -fate-lossless-truehd: $(FATE_TRUEHD) -FATE_SAMPLES_LOSSLESS_AUDIO-$(call DEMDEC, TRUEHD, TRUEHD) += $(FATE_TRUEHD) - FATE_SAMPLES_LOSSLESS_AUDIO-$(call DEMDEC, TTA, TTA) += fate-lossless-tta fate-lossless-tta: CMD = crc -i $(TARGET_SAMPLES)/lossless-audio/inside.tta diff --git a/tests/fate/truehd.mak b/tests/fate/truehd.mak new file mode 100644 index 00..6c8b1220f1 --- /dev/null +++ b/tests/fate/truehd.mak @@ -0,0 +1,12 @@ +FATE_TRUEHD-$(call DEMDEC, TRUEHD, TRUEHD) += fate-truehd-5.1 +fate-truehd-5.1: CMD = md5pipe -f truehd -i $(TARGET_SAMPLES)/lossless-audio/truehd_5.1.raw -f s32le +fate-truehd-5.1: CMP = oneline +fate-truehd-5.1: REF = 95d8aac39dd9f0d7fb83dc7b6f88df35 + +FATE_TRUEHD-$(call DEMDEC, TRUEHD, TRUEHD) += fate-truehd-5.1-downmix-2.0 +fate-truehd-5.1-downmix-2.0: CMD = md5pipe -f truehd -request_channel_layout 2 -i $(TARGET_SAMPLES)/lossless-audio/truehd_5.1.raw -f s32le +fate-truehd-5.1-downmix-2.0: CMP = oneline +fate-truehd-5.1-downmix-2.0: REF = a269aee0051d4400c9117136f08c9767 + +FATE_SAMPLES_AUDIO += $(FATE_TRUEHD-yes) +fate-truehd: $(FATE_TRUEHD-yes) diff --git a/tests/ref/fate/lossless-truehd-5.1 b/tests/ref/fate/lossless-truehd-5.1 deleted file mode 100644 index 373b917948..00 --- a/tests/ref/fate/lossless-truehd-5.1 +++ /dev/null @@ -1 +0,0 @@ -95d8aac39dd9f0d7fb83dc7b6f88df35 diff --git a/tests/ref/fate/lossless-truehd-5.1-downmix-2.0 b/tests/ref/fate/lossless-truehd-5.1-downmix-2.0 deleted file mode 100644 index f4afbc19b8..00 --- a/tests/ref/fate/lossless-truehd-5.1-downmix-2.0 +++ /dev/null @@ -1 +0,0 @@ -a269aee0051d4400c9117136f08c9767 ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fate/truehd: add a test for the truehd_core bitstream filter
ffmpeg | branch: master | James Almer | Sun Apr 19 11:57:19 2020 -0300| [300e6f03d96062279d8fbaed3f49c32cfd8fb270] | committer: James Almer fate/truehd: add a test for the truehd_core bitstream filter Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=300e6f03d96062279d8fbaed3f49c32cfd8fb270 --- tests/fate/truehd.mak | 5 + 1 file changed, 5 insertions(+) diff --git a/tests/fate/truehd.mak b/tests/fate/truehd.mak index 6c8b1220f1..e672716527 100644 --- a/tests/fate/truehd.mak +++ b/tests/fate/truehd.mak @@ -8,5 +8,10 @@ fate-truehd-5.1-downmix-2.0: CMD = md5pipe -f truehd -request_channel_layout 2 - fate-truehd-5.1-downmix-2.0: CMP = oneline fate-truehd-5.1-downmix-2.0: REF = a269aee0051d4400c9117136f08c9767 +FATE_TRUEHD-$(call ALLYES, TRUEHD_DEMUXER TRUEHD_MUXER TRUEHD_CORE_BSF) += fate-truehd-core-bsf +fate-truehd-core-bsf: CMD = md5pipe -i $(TARGET_SAMPLES)/truehd/atmos.thd -c:a copy -bsf:a truehd_core -fflags +bitexact -f truehd +fate-truehd-core-bsf: CMP = oneline +fate-truehd-core-bsf: REF = 3aa5d0c7825051f3657b71fd6135183b + FATE_SAMPLES_AUDIO += $(FATE_TRUEHD-yes) fate-truehd: $(FATE_TRUEHD-yes) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/adpcm: update get_nb_samples() doc
ffmpeg | branch: master | Zane van Iperen | Sat Apr 18 00:59:33 2020 +| [0bce55ac89491842d6ff57a84a5222a00f03c772] | committer: Michael Niedermayer avcodec/adpcm: update get_nb_samples() doc Signed-off-by: Zane van Iperen Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0bce55ac89491842d6ff57a84a5222a00f03c772 --- libavcodec/adpcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 7d35884056..9ea6a268eb 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -668,7 +668,7 @@ static inline int16_t adpcm_argo_expand_nibble(ADPCMChannelStatus *cs, int nibbl } /** - * Get the number of samples that will be decoded from the packet. + * Get the number of samples (per channel) that will be decoded from the packet. * In one case, this is actually the maximum number of samples possible to * decode with the given buf_size. * ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/adpcm_ima_{apc, ssi, oki}: replace while() with for()
ffmpeg | branch: master | Zane van Iperen | Sat Apr 18 00:59:25 2020 +| [7150123aab0f3861208a6b7278b90c29d4b83298] | committer: Michael Niedermayer avcodec/adpcm_ima_{apc, ssi, oki}: replace while() with for() Per discussion at https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/260854.html Signed-off-by: Zane van Iperen Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7150123aab0f3861208a6b7278b90c29d4b83298 --- libavcodec/adpcm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index ee18875579..7d35884056 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -1271,14 +1271,14 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } break; case AV_CODEC_ID_ADPCM_IMA_APC: -while (bytestream2_get_bytes_left(&gb) > 0) { +for (n = nb_samples >> (1 - st); n > 0; n--) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4 , 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3); } break; case AV_CODEC_ID_ADPCM_IMA_SSI: -while (bytestream2_get_bytes_left(&gb) > 0) { +for (n = nb_samples >> (1 - st); n > 0; n--) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_ima_qt_expand_nibble(&c->status[0], v >> 4 ); *samples++ = adpcm_ima_qt_expand_nibble(&c->status[st], v & 0x0F); @@ -1305,7 +1305,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } break; case AV_CODEC_ID_ADPCM_IMA_OKI: -while (bytestream2_get_bytes_left(&gb) > 0) { +for (n = nb_samples >> (1 - st); n > 0; n--) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_ima_oki_expand_nibble(&c->status[0], v >> 4 ); *samples++ = adpcm_ima_oki_expand_nibble(&c->status[st], v & 0x0F); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/pngdec: Pass ret from decode_iccp_chunk()
ffmpeg | branch: master | Michael Niedermayer | Sat Apr 18 01:48:47 2020 +0200| [4c7bcaa385e5e5fda0084de2fb823ac25c0deba0] | committer: Michael Niedermayer avcodec/pngdec: Pass ret from decode_iccp_chunk() Found while reviewing a patch fixing a similar issue Reviewed-by: Anton Khirnov Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4c7bcaa385e5e5fda0084de2fb823ac25c0deba0 --- libavcodec/pngdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 12d4eb0610..67bfc41b31 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1302,7 +1302,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, break; } case MKTAG('i', 'C', 'C', 'P'): { -if (decode_iccp_chunk(s, length, p) < 0) +if ((ret = decode_iccp_chunk(s, length, p)) < 0) goto fail; break; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskaenc: Improve mimetype search
ffmpeg | branch: master | Andreas Rheinhardt | Sun Nov 3 13:06:49 2019 +0100| [3589b3f2e217e78d16a92b372d95ce4a3f7df896] | committer: Andreas Rheinhardt avformat/matroskaenc: Improve mimetype search Use the mime_types of the corresponding AVCodecDescriptor instead of tables specific to Matroska. The former are generally more encompassing: They contain every item of the current lists except "text/plain" for AV_CODEC_ID_TEXT and "binary" for AV_CODEC_ID_BIN_DATA. The former has been preserved by special-casing it while the latter is a hack added in c9212abf so that the demuxer (which uses the same tables) sets the appropriate CodecID for broken files ("binary" is not a correct mime type at all); using it for the muxer was a mistake. The correct mime type for AV_CODEC_ID_BIN_DATA is "application/octet-stream" and this is what one gets from the AVCodecDescriptor. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3589b3f2e217e78d16a92b372d95ce4a3f7df896 --- libavformat/matroskaenc.c | 16 +--- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index d3256d8f5d..e1ddf366d4 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1667,17 +1667,11 @@ static int mkv_write_attachments(AVFormatContext *s) if (t = av_dict_get(st->metadata, "mimetype", NULL, 0)) mimetype = t->value; else if (st->codecpar->codec_id != AV_CODEC_ID_NONE ) { -int i; -for (i = 0; ff_mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++) -if (ff_mkv_mime_tags[i].id == st->codecpar->codec_id) { -mimetype = ff_mkv_mime_tags[i].str; -break; -} -for (i = 0; ff_mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++) -if (ff_mkv_image_mime_tags[i].id == st->codecpar->codec_id) { -mimetype = ff_mkv_image_mime_tags[i].str; -break; -} +const AVCodecDescriptor *desc = avcodec_descriptor_get(st->codecpar->codec_id); +if (desc && desc->mime_types) { +mimetype = desc->mime_types[0]; +} else if (st->codecpar->codec_id = AV_CODEC_ID_TEXT) +mimetype = "text/plain"; } if (!mimetype) { av_log(s, AV_LOG_ERROR, "Attachment stream %d has no mimetype tag and " ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroska: Move mime_tag lists to matroskadec
ffmpeg | branch: master | Andreas Rheinhardt | Thu Apr 16 03:39:05 2020 +0200| [67e957b43a2fdc197018968b0adc2f6a9c04e961] | committer: Andreas Rheinhardt avformat/matroska: Move mime_tag lists to matroskadec They are not used any more by the muxer. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=67e957b43a2fdc197018968b0adc2f6a9c04e961 --- libavformat/matroska.c| 19 --- libavformat/matroska.h| 2 -- libavformat/matroskadec.c | 35 +++ 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/libavformat/matroska.c b/libavformat/matroska.c index 4d18d147fc..7c56aba403 100644 --- a/libavformat/matroska.c +++ b/libavformat/matroska.c @@ -119,25 +119,6 @@ const CodecTags ff_webm_codec_tags[] = { {"" , AV_CODEC_ID_NONE} }; -const CodecMime ff_mkv_image_mime_tags[] = { -{"image/gif" , AV_CODEC_ID_GIF}, -{"image/jpeg" , AV_CODEC_ID_MJPEG}, -{"image/png" , AV_CODEC_ID_PNG}, -{"image/tiff" , AV_CODEC_ID_TIFF}, - -{"" , AV_CODEC_ID_NONE} -}; - -const CodecMime ff_mkv_mime_tags[] = { -{"text/plain" , AV_CODEC_ID_TEXT}, -{"application/x-truetype-font", AV_CODEC_ID_TTF}, -{"application/x-font" , AV_CODEC_ID_TTF}, -{"application/vnd.ms-opentype", AV_CODEC_ID_OTF}, -{"binary" , AV_CODEC_ID_BIN_DATA}, - -{"" , AV_CODEC_ID_NONE} -}; - const AVMetadataConv ff_mkv_metadata_conv[] = { { "LEAD_PERFORMER", "performer" }, { "PART_NUMBER" , "track" }, diff --git a/libavformat/matroska.h b/libavformat/matroska.h index e177cd027f..6f198f06e6 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -362,8 +362,6 @@ typedef struct CodecTags{ extern const CodecTags ff_mkv_codec_tags[]; extern const CodecTags ff_webm_codec_tags[]; -extern const CodecMime ff_mkv_mime_tags[]; -extern const CodecMime ff_mkv_image_mime_tags[]; extern const AVMetadataConv ff_mkv_metadata_conv[]; extern const char * const ff_matroska_video_stereo_mode[MATROSKA_VIDEO_STEREOMODE_TYPE_NB]; extern const char * const ff_matroska_video_stereo_plane[MATROSKA_VIDEO_STEREO_PLANE_COUNT]; diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 761d8b3743..8e1326abf6 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -747,6 +747,25 @@ static EbmlSyntax matroska_cluster_enter[] = { }; #undef CHILD_OF +static const CodecMime mkv_image_mime_tags[] = { +{"image/gif" , AV_CODEC_ID_GIF}, +{"image/jpeg" , AV_CODEC_ID_MJPEG}, +{"image/png" , AV_CODEC_ID_PNG}, +{"image/tiff" , AV_CODEC_ID_TIFF}, + +{"" , AV_CODEC_ID_NONE} +}; + +static const CodecMime mkv_mime_tags[] = { +{"text/plain" , AV_CODEC_ID_TEXT}, +{"application/x-truetype-font", AV_CODEC_ID_TTF}, +{"application/x-font" , AV_CODEC_ID_TTF}, +{"application/vnd.ms-opentype", AV_CODEC_ID_OTF}, +{"binary" , AV_CODEC_ID_BIN_DATA}, + +{"" , AV_CODEC_ID_NONE} +}; + static const char *const matroska_doctypes[] = { "matroska", "webm" }; static int matroska_read_close(AVFormatContext *s); @@ -2882,10 +2901,10 @@ static int matroska_read_header(AVFormatContext *s) av_dict_set(&st->metadata, "mimetype", attachments[j].mime, 0); st->codecpar->codec_id = AV_CODEC_ID_NONE; -for (i = 0; ff_mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++) { -if (!strncmp(ff_mkv_image_mime_tags[i].str, attachments[j].mime, - strlen(ff_mkv_image_mime_tags[i].str))) { -st->codecpar->codec_id = ff_mkv_image_mime_tags[i].id; +for (i = 0; mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++) { +if (!strncmp(mkv_image_mime_tags[i].str, attachments[j].mime, + strlen(mkv_image_mime_tags[i].str))) { +st->codecpar->codec_id = mkv_image_mime_tags[i].id; break; } } @@ -2913,10 +2932,10 @@ static int matroska_read_header(AVFormatContext *s) memcpy(st->codecpar->extradata, attachments[j].bin.data, attachments[j].bin.size); -for (i = 0; ff_mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++) { -if (!strncmp(ff_mkv_mime_tags[i].str, attachments[j].mime, -strlen(ff_mkv_mime_tags[i].str))) { -st->codecpar->codec_id = ff_mkv_mime_tags[i].id; +for (i = 0; mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++) { +if (!strncmp(mkv_mime_tags[i].str, attachments[j].mim
[FFmpeg-cvslog] avformat/matroskaenc: Make ebml_num_size() more robust
ffmpeg | branch: master | Andreas Rheinhardt | Thu Apr 2 23:07:55 2020 +0200| [9b0f9003dfab6a230d46aaa94091bf509d889f37] | committer: Andreas Rheinhardt avformat/matroskaenc: Make ebml_num_size() more robust Matroska (or actually EBML) uses variable-length numbers where only seven bits of every byte is usable for the length; the other bits encode the length of the variable-length number. So in order to find out how many bytes one needs to encode a given number one can use a loop like while (num >> 7 * bytes) bytes++; the Matroska muxer effectively did this. Yet it has a disadvantage: It is impossible for the result of a single right shift of an unsigned number with most significant bit set to be zero, because one can only shift by 0..(width - 1). On some architectures like x64 it is not even possible to do it with undefined right shifts in which case this leads to an infinite loop. This can be easily avoided by switching to a loop whose condition is (num >>= 7). The maximum value the so modified function can return is 10; any value > 8 is invalid and will now lead to an assert in put_ebml_num() or in start_ebml_master() (or actually in put_ebml_size_unknown()). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b0f9003dfab6a230d46aaa94091bf509d889f37 --- libavformat/matroskaenc.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index e1ddf366d4..1a3db72043 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -194,9 +194,11 @@ static void put_ebml_size_unknown(AVIOContext *pb, int bytes) */ static int ebml_num_size(uint64_t num) { -int bytes = 1; -while ((num + 1) >> bytes * 7) +int bytes = 0; +num++; +do { bytes++; +} while (num >>= 7); return bytes; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskaenc: Rename functions to better reflect what they do
ffmpeg | branch: master | Andreas Rheinhardt | Wed Apr 15 03:39:37 2020 +0200| [40d038a63531bac12fca50e3b0f6f55037733671] | committer: Andreas Rheinhardt avformat/matroskaenc: Rename functions to better reflect what they do EBML uses variable length integers both for the EBML IDs as well as for the EBML lengths; Matroska also uses them for the TrackNumber in (Simple)Blocks and for the lengths of laces when EBML lacing is used. When encoding EBML lengths, certain encodings have a special meaning, namely that the element has an unknown length. This is not so when encoding general EBML variable length integers. Yet the functions called ebml_num_size() and put_ebml_num() had this special meaning hardcoded, i.e. they are there to write EBML lengths and not general EBML numbers. So rename them. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=40d038a63531bac12fca50e3b0f6f55037733671 --- libavformat/matroskaenc.c | 53 --- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 1a3db72043..3408b49a81 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -190,30 +190,31 @@ static void put_ebml_size_unknown(AVIOContext *pb, int bytes) } /** - * Calculate how many bytes are needed to represent a given number in EBML. + * Calculate how many bytes are needed to represent the length field + * of an EBML element whose payload has a given length. */ -static int ebml_num_size(uint64_t num) +static int ebml_length_size(uint64_t length) { int bytes = 0; -num++; +length++; do { bytes++; -} while (num >>= 7); +} while (length >>= 7); return bytes; } /** - * Write a number in EBML variable length format. + * Write a length as EBML variable length integer. * * @param bytes The number of bytes that need to be used to write the number. * If zero, the minimal number of bytes will be used. */ -static void put_ebml_num(AVIOContext *pb, uint64_t num, int bytes) +static void put_ebml_length(AVIOContext *pb, uint64_t length, int bytes) { -int i, needed_bytes = ebml_num_size(num); +int i, needed_bytes = ebml_length_size(length); // sizes larger than this are currently undefined in EBML -av_assert0(num < (1ULL << 56) - 1); +av_assert0(length < (1ULL << 56) - 1); if (bytes == 0) bytes = needed_bytes; @@ -221,9 +222,9 @@ static void put_ebml_num(AVIOContext *pb, uint64_t num, int bytes) // the bytes that we ought to use. av_assert0(bytes >= needed_bytes); -num |= 1ULL << bytes * 7; +length |= 1ULL << bytes * 7; for (i = bytes - 1; i >= 0; i--) -avio_w8(pb, (uint8_t)(num >> i * 8)); +avio_w8(pb, (uint8_t)(length >> i * 8)); } /** @@ -232,7 +233,7 @@ static void put_ebml_num(AVIOContext *pb, uint64_t num, int bytes) static void put_ebml_uid(AVIOContext *pb, uint32_t elementid, uint64_t uid) { put_ebml_id(pb, elementid); -put_ebml_num(pb, 8, 0); +put_ebml_length(pb, 8, 0); avio_wb64(pb, uid); } @@ -244,7 +245,7 @@ static void put_ebml_uint(AVIOContext *pb, uint32_t elementid, uint64_t val) bytes++; put_ebml_id(pb, elementid); -put_ebml_num(pb, bytes, 0); +put_ebml_length(pb, bytes, 0); for (i = bytes - 1; i >= 0; i--) avio_w8(pb, (uint8_t)(val >> i * 8)); } @@ -257,7 +258,7 @@ static void put_ebml_sint(AVIOContext *pb, uint32_t elementid, int64_t val) while (tmp>>=8) bytes++; put_ebml_id(pb, elementid); -put_ebml_num(pb, bytes, 0); +put_ebml_length(pb, bytes, 0); for (i = bytes - 1; i >= 0; i--) avio_w8(pb, (uint8_t)(val >> i * 8)); } @@ -265,7 +266,7 @@ static void put_ebml_sint(AVIOContext *pb, uint32_t elementid, int64_t val) static void put_ebml_float(AVIOContext *pb, uint32_t elementid, double val) { put_ebml_id(pb, elementid); -put_ebml_num(pb, 8, 0); +put_ebml_length(pb, 8, 0); avio_wb64(pb, av_double2int(val)); } @@ -273,7 +274,7 @@ static void put_ebml_binary(AVIOContext *pb, uint32_t elementid, const void *buf, int size) { put_ebml_id(pb, elementid); -put_ebml_num(pb, size, 0); +put_ebml_length(pb, size, 0); avio_write(pb, buf, size); } @@ -299,10 +300,10 @@ static void put_ebml_void(AVIOContext *pb, int size) // size if possible, 1 byte otherwise if (size < 10) { size -= 2; -put_ebml_num(pb, size, 0); +put_ebml_length(pb, size, 0); } else { size -= 9; -put_ebml_num(pb, size, 8); +put_ebml_length(pb, size, 8); } ffio_fill(pb, 0, size); } @@ -310,7 +311,7 @@ static void put_ebml_void(AVIOContext *pb, int size) static ebml_master start_ebml_master(AVIOContext *pb, uint32_t elementid, uint64_t expectedsize)
[FFmpeg-cvslog] avformat/matroskaenc: Refactor writing EBML lengths
ffmpeg | branch: master | Andreas Rheinhardt | Wed Apr 15 04:05:09 2020 +0200| [112afaccdfa56e446527f0303f3e1277bc34b500] | committer: Andreas Rheinhardt avformat/matroskaenc: Refactor writing EBML lengths This commit factors the ability to write ordinary EBML numbers out of the functions for writing EBML lengths. This is in preparation for future commits. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=112afaccdfa56e446527f0303f3e1277bc34b500 --- libavformat/matroskaenc.c | 36 ++-- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 3408b49a81..d3c6a7ea9b 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -190,19 +190,38 @@ static void put_ebml_size_unknown(AVIOContext *pb, int bytes) } /** - * Calculate how many bytes are needed to represent the length field - * of an EBML element whose payload has a given length. + * Returns how many bytes are needed to represent a number + * as EBML variable length integer. */ -static int ebml_length_size(uint64_t length) +static int ebml_num_size(uint64_t num) { int bytes = 0; -length++; do { bytes++; -} while (length >>= 7); +} while (num >>= 7); return bytes; } +/** + * Calculate how many bytes are needed to represent the length field + * of an EBML element whose payload has a given length. + */ +static int ebml_length_size(uint64_t length) +{ +return ebml_num_size(length + 1); +} + +/** + * Write a number as EBML variable length integer on `bytes` bytes. + * `bytes` is taken literally without checking. + */ +static void put_ebml_num(AVIOContext *pb, uint64_t num, int bytes) +{ +num |= 1ULL << bytes * 7; +for (int i = bytes - 1; i >= 0; i--) +avio_w8(pb, (uint8_t)(num >> i * 8)); +} + /** * Write a length as EBML variable length integer. * @@ -211,7 +230,7 @@ static int ebml_length_size(uint64_t length) */ static void put_ebml_length(AVIOContext *pb, uint64_t length, int bytes) { -int i, needed_bytes = ebml_length_size(length); +int needed_bytes = ebml_length_size(length); // sizes larger than this are currently undefined in EBML av_assert0(length < (1ULL << 56) - 1); @@ -221,10 +240,7 @@ static void put_ebml_length(AVIOContext *pb, uint64_t length, int bytes) // The bytes needed to write the given size must not exceed // the bytes that we ought to use. av_assert0(bytes >= needed_bytes); - -length |= 1ULL << bytes * 7; -for (i = bytes - 1; i >= 0; i--) -avio_w8(pb, (uint8_t)(length >> i * 8)); +put_ebml_num(pb, length, bytes); } /** ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskaenc: Remove limit on the number of tracks
ffmpeg | branch: master | Andreas Rheinhardt | Wed Apr 15 04:49:46 2020 +0200| [13c12cd4702e621c7363be8f22a8b55c22a31a02] | committer: Andreas Rheinhardt avformat/matroskaenc: Remove limit on the number of tracks The Matroska file format has practically no limit on the number of tracks (the current limit is 2^56 - 1); yet because they are encoded in a variable length format in (Simple)Blocks this muxer has simply imposed a limit on the number of tracks in order to ensure that they can always be written on one byte in order to simplify the muxing process. This commit removes said limit. Also, zero is an invalid TrackNumber, so disallow this value in the dash_track_number option. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=13c12cd4702e621c7363be8f22a8b55c22a31a02 --- libavformat/matroskaenc.c | 34 +- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index d3c6a7ea9b..116b89fb4d 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -93,6 +93,7 @@ typedef struct mkv_track { int has_cue; uint64_tuid; unsignedtrack_num; +int track_num_size; int sample_rate; int64_t sample_rate_offset; int64_t last_timestamp; @@ -105,10 +106,6 @@ typedef struct mkv_track { #define MODE_MATROSKAv2 0x01 #define MODE_WEBM 0x02 -/** Maximum number of tracks allowed in a Matroska file (with track numbers in - * range 1 to 126 (inclusive) */ -#define MAX_TRACKS 126 - typedef struct MatroskaMuxContext { const AVClass *class; int mode; @@ -1899,9 +1896,9 @@ static int mkv_write_header(AVFormatContext *s) return 0; } -static int mkv_blockgroup_size(int pkt_size) +static int mkv_blockgroup_size(int pkt_size, int track_num_size) { -int size = pkt_size + 4; +int size = pkt_size + track_num_size + 3; size += ebml_length_size(size); size += 2; // EBML ID for block and block duration size += 9; // max size of block duration incl. length field @@ -2041,9 +2038,8 @@ static int mkv_write_block(AVFormatContext *s, AVIOContext *pb, } put_ebml_id(pb, blockid); -put_ebml_length(pb, size + 4, 0); -// this assumes stream_index is less than 126 -avio_w8(pb, 0x80 | track_number); +put_ebml_length(pb, size + track->track_num_size + 3, 0); +put_ebml_num(pb, track_number, track->track_num_size); avio_wb16(pb, ts - mkv->cluster_pts); avio_w8(pb, (blockid == MATROSKA_ID_SIMPLEBLOCK && keyframe) ? (1 << 7) : 0); avio_write(pb, data + offset, size); @@ -2106,11 +2102,12 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *p size, pkt->pts, pkt->dts, pkt->duration, avio_tell(pb), mkv->cluster_pos, track->track_num, 1); -blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(size)); +blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, + mkv_blockgroup_size(size, track->track_num_size)); put_ebml_id(pb, MATROSKA_ID_BLOCK); -put_ebml_length(pb, size + 4, 0); -avio_w8(pb, 0x80 | track->track_num); // this assumes track_num is less than 126 +put_ebml_length(pb, size + track->track_num_size + 3, 0); +put_ebml_num(pb, track->track_num, track->track_num_size); avio_wb16(pb, ts - mkv->cluster_pts); avio_w8(pb, flags); avio_printf(pb, "%.*s\n%.*s\n%.*s", id_size, id, settings_size, settings, pkt->size, pkt->data); @@ -2284,7 +2281,8 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_ duration = mkv_write_vtt_blocks(s, pb, pkt); } else { ebml_master blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, - mkv_blockgroup_size(pkt->size)); + mkv_blockgroup_size(pkt->size, + track->track_num_size)); #if FF_API_CONVERGENCE_DURATION FF_DISABLE_DEPRECATION_WARNINGS @@ -2646,13 +2644,7 @@ static int mkv_init(struct AVFormatContext *s) nb_tracks++; track->track_num = mkv->is_dash ? mkv->dash_track_number : nb_tracks; -} - -if (nb_tracks > MAX_TRACKS) { -av_log(s, AV_LOG_ERROR, - "%u > "AV_STRINGIFY(MAX_TRACKS)" tracks (excluding attachments)" - " not supported for muxing in Matroska\n", nb_tracks); -return AVERROR(EINVAL); +track->track_num_size = ebml_num_size(track->track_num); } return 0; @@ -2710,7 +2702,7 @@ static const AVOption options[] = { { "cluster_size_limit", "Store at most the provided amount of bytes in a cluster. ",
[FFmpeg-cvslog] avformat/matroskaenc: Improve Cues in case of no video
ffmpeg | branch: master | Andreas Rheinhardt | Sun Dec 29 03:14:53 2019 +0100| [945b92873061c66b82df892887cd9baf8146857b] | committer: Andreas Rheinhardt avformat/matroskaenc: Improve Cues in case of no video The Matroska muxer currently only adds CuePoints in three cases: a) For video keyframes. b) For the first audio frame in a new Cluster if in DASH-mode. c) For subtitles. This means that ordinary Matroska audio files won't have any Cues which impedes seeking. This commit changes this. For every track in a file without video track it is checked and tracked whether a Cue entry has already been added for said track for the current Cluster. This is used to add a Cue entry for each first packet of each track in each Cluster. Implements #3149. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=945b92873061c66b82df892887cd9baf8146857b --- libavformat/matroskaenc.c | 21 - tests/ref/fate/aac-autobsf-adtstoasc | 4 ++-- tests/ref/fate/matroska-flac-extradata-update | 4 ++-- tests/ref/lavf/mka| 4 ++-- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 116b89fb4d..a65221e143 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2123,6 +2123,10 @@ static void mkv_end_cluster(AVFormatContext *s) MatroskaMuxContext *mkv = s->priv_data; end_ebml_master_crc32(s->pb, &mkv->cluster_bc, mkv, MATROSKA_ID_CLUSTER, 0, 1); +if (!mkv->have_video) { +for (unsigned i = 0; i < s->nb_streams; i++) +mkv->tracks[i].has_cue = 0; +} mkv->cluster_pos = -1; avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_FLUSH_POINT); } @@ -2225,7 +2229,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, AVPacket *pkt) return 0; } -static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_cue) +static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt) { MatroskaMuxContext *mkv = s->priv_data; AVIOContext *pb; @@ -2271,10 +2275,12 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_ ret = mkv_write_block(s, pb, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe); if (ret < 0) return ret; -if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && (par->codec_type == AVMEDIA_TYPE_VIDEO && keyframe || add_cue)) { +if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && keyframe && +(par->codec_type == AVMEDIA_TYPE_VIDEO || !mkv->have_video && !track->has_cue)) { ret = mkv_add_cuepoint(mkv, pkt->stream_index, ts, mkv->cluster_pos, relative_packet_pos, -1); if (ret < 0) return ret; +track->has_cue = 1; } } else { if (par->codec_id == AV_CODEC_ID_WEBVTT) { @@ -2340,8 +2346,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) // on seeing key frames. start_new_cluster = keyframe; } else if (mkv->is_dash && codec_type == AVMEDIA_TYPE_AUDIO && - (mkv->cluster_pos == -1 || -cluster_time > mkv->cluster_time_limit)) { + cluster_time > mkv->cluster_time_limit) { // For DASH audio, we create a Cluster based on cluster_time_limit start_new_cluster = 1; } else if (!mkv->is_dash && @@ -2365,9 +2370,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) // check if we have an audio packet cached if (mkv->cur_audio_pkt.size > 0) { -// for DASH audio, a CuePoint has to be added when there is a new cluster. -ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt, -mkv->is_dash ? start_new_cluster : 0); +ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt); av_packet_unref(&mkv->cur_audio_pkt); if (ret < 0) { av_log(s, AV_LOG_ERROR, @@ -2382,7 +2385,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) if (pkt->size > 0) ret = av_packet_ref(&mkv->cur_audio_pkt, pkt); } else -ret = mkv_write_packet_internal(s, pkt, 0); +ret = mkv_write_packet_internal(s, pkt); return ret; } @@ -2410,7 +2413,7 @@ static int mkv_write_trailer(AVFormatContext *s) // check if we have an audio packet cached if (mkv->cur_audio_pkt.size > 0) { -ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt, 0); +ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Could not write cached audio packet ret:%d\n", ret); diff --git a/tests/ref/fate/aac-autobsf-adtstoasc b/tests/ref/fate/aac-autobsf-adtstoasc index f1c6f889d4..d9191fb37f 100644 --- a/tests/ref/fate/aac-autobsf-adtstoasc +++ b/tests/
[FFmpeg-cvslog] avformat/matroskaenc: Add check for using explicit TrackNumber
ffmpeg | branch: master | Andreas Rheinhardt | Fri Nov 1 11:49:47 2019 +0100| [86de864741fdc046f353a82da526445db44c4287] | committer: Andreas Rheinhardt avformat/matroskaenc: Add check for using explicit TrackNumber When creating DASH streams, the TrackNumber is externally prescribed and not derived from the number of streams in the AVFormatContext, so if the number of tracks for a file using an explicit TrackNumber was more than one, the resulting file would be broken (it would be impossible to tell to which track a Block belongs if different tracks share the same TrackNumber). So disallow this. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=86de864741fdc046f353a82da526445db44c4287 --- libavformat/matroskaenc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index a65221e143..2cd5933da8 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2650,6 +2650,9 @@ static int mkv_init(struct AVFormatContext *s) track->track_num_size = ebml_num_size(track->track_num); } +if (mkv->is_dash && nb_tracks != 1) +return AVERROR(EINVAL); + return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskaenc: Don't use size of inexistent Cluster
ffmpeg | branch: master | Andreas Rheinhardt | Wed Jan 22 20:01:30 2020 +0100| [4dd63ae86c311da269426803d440d907cd9f66a2] | committer: Andreas Rheinhardt avformat/matroskaenc: Don't use size of inexistent Cluster In order to determine whether the current Cluster needs to be closed because of the limits on clustersize and clustertime, mkv_write_packet() would first get the size of the current Cluster by applying avio_tell() on the dynamic buffer holding the current Cluster. It did this without checking whether there is a dynamic buffer for writing Clusters open right now. In this case (which happens when writing the first packet) avio_tell() returned AVERROR(EINVAL); yet it is not good to rely on avio_tell() (or actually, avio_seek()) to handle the situation gracefully. Fixing this is easy: Only check whether a Cluster needs to be closed if a Cluster is in fact open. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4dd63ae86c311da269426803d440d907cd9f66a2 --- libavformat/matroskaenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 2cd5933da8..5e0346d341 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2332,6 +2332,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) if (ret < 0) return ret; +if (mkv->cluster_pos != -1) { if (mkv->tracks[pkt->stream_index].write_dts) cluster_time = pkt->dts - mkv->cluster_pts; else @@ -2359,9 +2360,10 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) start_new_cluster = 0; } -if (mkv->cluster_pos != -1 && start_new_cluster) { +if (start_new_cluster) { mkv_end_cluster(s); } +} if (!mkv->cluster_pos) avio_write_marker(s->pb, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskaenc: Warn that WebM doesn't support Attachments
ffmpeg | branch: master | Andreas Rheinhardt | Sat Nov 2 18:56:31 2019 +0100| [ef4581d5f0deff2c69d223bf0bd7c0012294] | committer: Andreas Rheinhardt avformat/matroskaenc: Warn that WebM doesn't support Attachments As WebM doesn't support Attachments, the Matroska muxer drops them when in WebM mode. This happened silently until this commit which adds a warning for this. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ef4581d5f0deff2c69d223bf0bd7c0012294 --- libavformat/matroskaenc.c | 19 --- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 5e0346d341..936dfba2ee 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1738,12 +1738,6 @@ static int mkv_write_header(AVFormatContext *s) int ret, i, version = 2; int64_t creation_time; -if (!strcmp(s->oformat->name, "webm")) { -mkv->mode = MODE_WEBM; -mkv->write_crc = 0; -} else -mkv->mode = MODE_MATROSKAv2; - if (mkv->mode != MODE_WEBM || av_dict_get(s->metadata, "stereo_mode", NULL, 0) || av_dict_get(s->metadata, "alpha_mode", NULL, 0)) @@ -2618,6 +2612,12 @@ static int mkv_init(struct AVFormatContext *s) s->internal->avoid_negative_ts_use_pts = 1; } +if (!strcmp(s->oformat->name, "webm")) { +mkv->mode = MODE_WEBM; +mkv->write_crc = 0; +} else +mkv->mode = MODE_MATROSKAv2; + mkv->tracks = av_mallocz_array(s->nb_streams, sizeof(*mkv->tracks)); if (!mkv->tracks) { return AVERROR(ENOMEM); @@ -2644,8 +2644,13 @@ static int mkv_init(struct AVFormatContext *s) // ms precision is the de-facto standard timescale for mkv files avpriv_set_pts_info(s->streams[i], 64, 1, 1000); -if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT) +if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT) { +if (mkv->mode == MODE_WEBM) { +av_log(s, AV_LOG_WARNING, "Stream %d will be ignored " + "as WebM doesn't support attachments.\n", i); +} continue; +} nb_tracks++; track->track_num = mkv->is_dash ? mkv->dash_track_number : nb_tracks; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskaenc: Only write Tracks if there is a track
ffmpeg | branch: master | Andreas Rheinhardt | Sun Dec 29 03:26:05 2019 +0100| [a9844341f78e6eba78a9bb503e71a5d9e3ceea81] | committer: Andreas Rheinhardt avformat/matroskaenc: Only write Tracks if there is a track The Matroska muxer does not write every stream as a Matroska track; some streams are written as AttachedFile. But should no stream be written as a Matroska track, the Matroska muxer would nevertheless write a Tracks element without a TrackEntry. This is against the spec. This commit changes this and only writes a Tracks if there is a Matroska track. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a9844341f78e6eba78a9bb503e71a5d9e3ceea81 --- libavformat/matroskaenc.c | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 936dfba2ee..6796ac4747 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -128,7 +128,7 @@ typedef struct MatroskaMuxContext { AVPacketcur_audio_pkt; -int have_attachments; +unsigned nb_attachments; int have_video; int reserve_cues_space; @@ -1113,7 +1113,6 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, AVDictionaryEntry *tag; if (par->codec_type == AVMEDIA_TYPE_ATTACHMENT) { -mkv->have_attachments = 1; return 0; } @@ -1370,6 +1369,9 @@ static int mkv_write_tracks(AVFormatContext *s) AVIOContext *pb = s->pb; int i, ret, default_stream_exists = 0; +if (mkv->nb_attachments == s->nb_streams) +return 0; + mkv_add_seekhead_entry(mkv, MATROSKA_ID_TRACKS, avio_tell(pb)); ret = start_ebml_master_crc32(&mkv->tracks_bc, mkv); @@ -1619,7 +1621,7 @@ static int mkv_write_tags(AVFormatContext *s) } } -if (mkv->have_attachments && mkv->mode != MODE_WEBM) { +if (mkv->nb_attachments && mkv->mode != MODE_WEBM) { for (i = 0; i < s->nb_streams; i++) { mkv_track *track = &mkv->tracks[i]; AVStream *st = s->streams[i]; @@ -1653,7 +1655,7 @@ static int mkv_write_attachments(AVFormatContext *s) AVIOContext *dyn_cp = NULL, *pb = s->pb; int i, ret; -if (!mkv->have_attachments) +if (!mkv->nb_attachments) return 0; mkv_add_seekhead_entry(mkv, MATROSKA_ID_ATTACHMENTS, avio_tell(pb)); @@ -2499,9 +2501,12 @@ static int mkv_write_trailer(AVFormatContext *s) put_ebml_float(mkv->info_bc, MATROSKA_ID_DURATION, mkv->duration); end_ebml_master_crc32(pb, &mkv->info_bc, mkv, MATROSKA_ID_INFO, 0, 0); -// write tracks master -avio_seek(pb, mkv->tracks_pos, SEEK_SET); -end_ebml_master_crc32(pb, &mkv->tracks_bc, mkv, MATROSKA_ID_TRACKS, 0, 0); +if (mkv->tracks_bc) { +// write Tracks master +avio_seek(pb, mkv->tracks_pos, SEEK_SET); +end_ebml_master_crc32(pb, &mkv->tracks_bc, mkv, + MATROSKA_ID_TRACKS, 0, 0); +} // update stream durations if (mkv->tags_bc) { @@ -2649,6 +2654,7 @@ static int mkv_init(struct AVFormatContext *s) av_log(s, AV_LOG_WARNING, "Stream %d will be ignored " "as WebM doesn't support attachments.\n", i); } +mkv->nb_attachments++; continue; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskaenc: Don't waste bytes on length fields
ffmpeg | branch: master | Andreas Rheinhardt | Sun Dec 29 10:22:49 2019 +0100| [5b6e164b4baccc5b36eb8fa5aa91c02d16c88dcf] | committer: Andreas Rheinhardt avformat/matroskaenc: Don't waste bytes on length fields Several EBML Master elements for which a good upper bound of the final length was available were nevertheless written without giving an upper bound of the final length to start_ebml_master(), so that their length fields were eight bytes long. This has been changed. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5b6e164b4baccc5b36eb8fa5aa91c02d16c88dcf --- libavformat/matroskaenc.c | 9 +++--- tests/fate/wavpack.mak| 4 +-- tests/ref/fate/aac-autobsf-adtstoasc | 4 +-- tests/ref/fate/matroska-flac-extradata-update | 4 +-- tests/ref/fate/rgb24-mkv | 4 +-- tests/ref/fate/webm-dash-chapters | 4 +-- tests/ref/lavf-fate/av1.mkv | 4 +-- tests/ref/lavf/mka| 4 +-- tests/ref/lavf/mkv| 4 +-- tests/ref/lavf/mkv_attachment | 4 +-- tests/ref/seek/lavf-mkv | 44 +-- 11 files changed, 45 insertions(+), 44 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 6796ac4747..b03239f9c7 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -849,7 +849,7 @@ static int mkv_write_video_color(AVIOContext *pb, AVCodecParameters *par, AVStre &side_data_size); if (side_data_size == sizeof(AVMasteringDisplayMetadata)) { ebml_master meta_element = start_ebml_master( -dyn_cp, MATROSKA_ID_VIDEOCOLORMASTERINGMETA, 0); +dyn_cp, MATROSKA_ID_VIDEOCOLORMASTERINGMETA, 10 * (2 + 1 + 8)); const AVMasteringDisplayMetadata *metadata = (const AVMasteringDisplayMetadata*)side_data; if (metadata->has_primaries) { @@ -1313,7 +1313,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, // no mkv-specific ID, use ACM mode put_ebml_string(pb, MATROSKA_ID_CODECID, "A_MS/ACM"); -subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 0); +subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 6 + 4 * 9); put_ebml_uint (pb, MATROSKA_ID_AUDIOCHANNELS, par->channels); track->sample_rate_offset = avio_tell(pb); @@ -1504,7 +1504,7 @@ static int mkv_write_tag_targets(AVFormatContext *s, uint32_t elementid, pb = mkv->tags_bc; *tag= start_ebml_master(pb, MATROSKA_ID_TAG,0); -targets = start_ebml_master(pb, MATROSKA_ID_TAGTARGETS, 0); +targets = start_ebml_master(pb, MATROSKA_ID_TAGTARGETS, 4 + 1 + 8); if (elementid) put_ebml_uid(pb, elementid, uid); end_ebml_master(pb, targets); @@ -1594,7 +1594,8 @@ static int mkv_write_tags(AVFormatContext *s) AVIOContext *pb = mkv->tags_bc; ebml_master simpletag; -simpletag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, 0); +simpletag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, + 2 + 1 + 8 + 23); put_ebml_string(pb, MATROSKA_ID_TAGNAME, "DURATION"); mkv->tracks[i].duration_offset = avio_tell(pb); diff --git a/tests/fate/wavpack.mak b/tests/fate/wavpack.mak index e3cf4ec632..c62b3ceefd 100644 --- a/tests/fate/wavpack.mak +++ b/tests/fate/wavpack.mak @@ -91,12 +91,12 @@ fate-wavpack-matroskamode: CMD = md5 -i $(TARGET_SAMPLES)/wavpack/special/matros FATE_WAVPACK-$(call DEMMUX, WV, MATROSKA) += fate-wavpack-matroska_mux-mono fate-wavpack-matroska_mux-mono: CMD = md5pipe -i $(TARGET_SAMPLES)/wavpack/num_channels/mono_16bit_int.wv -c copy -fflags +bitexact -f matroska fate-wavpack-matroska_mux-mono: CMP = oneline -fate-wavpack-matroska_mux-mono: REF = 7ebd447336f0ba76b41a3f32d1551f05 +fate-wavpack-matroska_mux-mono: REF = a378996c1bb5a54998fc804fb1ad97b1 FATE_WAVPACK-$(call DEMMUX, WV, MATROSKA) += fate-wavpack-matroska_mux-61 fate-wavpack-matroska_mux-61: CMD = md5pipe -i $(TARGET_SAMPLES)/wavpack/num_channels/eva_2.22_6.1_16bit-partial.wv -c copy -fflags +bitexact -f matroska fate-wavpack-matroska_mux-61: CMP = oneline -fate-wavpack-matroska_mux-61: REF = c95bca3c3023230a324c633942c453d5 +fate-wavpack-matroska_mux-61: REF = 3d708dfce5ac85df114ea91b30143708 FATE_SAMPLES_AVCONV += $(FATE_WAVPACK-yes) fate-wavpack: $(FATE_WAVPACK-yes) diff --git a/tests/ref/fate/aac-autobsf-adtstoasc b/tests/ref/fate/aac-autobsf-adtstoasc index d9191fb37f..c7eae5d6c1 100644 --- a/tests/ref/fate/aac-autobsf-adtstoasc +++ b/tests/ref/fate/aac-autobsf-adtstoasc @@ -1,5 +1,5 @@ -76a14cc1b3292c7f724006d56b7e2eac *tests/data/fate/aac-autobsf-adtstoasc.matroska -6648 tests/data/fate/aac-autobsf-adtstoasc.matroska +6ff
[FFmpeg-cvslog] avformat/matroskaenc: Add const where appropriate
ffmpeg | branch: master | Andreas Rheinhardt | Wed Nov 20 03:35:24 2019 +0100| [abc7dc32bd36759e82e2298eb884c0aa41ca0ac2] | committer: Andreas Rheinhardt avformat/matroskaenc: Add const where appropriate Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=abc7dc32bd36759e82e2298eb884c0aa41ca0ac2 --- libavformat/matroskaenc.c | 68 +-- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index b03239f9c7..bdb768209d 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -562,7 +562,8 @@ static int mkv_assemble_cues(AVStream **streams, AVIOContext *dyn_cp, return 0; } -static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par) +static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, + const AVCodecParameters *par) { const uint8_t *header_start[3]; int header_len[3]; @@ -590,7 +591,7 @@ static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecParame return 0; } -static int put_wv_codecpriv(AVIOContext *pb, AVCodecParameters *par) +static int put_wv_codecpriv(AVIOContext *pb, const AVCodecParameters *par) { if (par->extradata && par->extradata_size == 2) avio_write(pb, par->extradata, 2); @@ -600,7 +601,7 @@ static int put_wv_codecpriv(AVIOContext *pb, AVCodecParameters *par) } static int put_flac_codecpriv(AVFormatContext *s, - AVIOContext *pb, AVCodecParameters *par) + AVIOContext *pb, const AVCodecParameters *par) { int write_comment = (par->channel_layout && !(par->channel_layout & ~0x3ULL) && @@ -648,8 +649,9 @@ static int put_flac_codecpriv(AVFormatContext *s, return 0; } -static int get_aac_sample_rates(AVFormatContext *s, uint8_t *extradata, int extradata_size, -int *sample_rate, int *output_sample_rate) +static int get_aac_sample_rates(AVFormatContext *s, const uint8_t *extradata, +int extradata_size, int *sample_rate, +int *output_sample_rate) { MPEG4AudioConfig mp4ac; int ret; @@ -681,7 +683,7 @@ static int get_aac_sample_rates(AVFormatContext *s, uint8_t *extradata, int extr } static int mkv_write_native_codecprivate(AVFormatContext *s, AVIOContext *pb, - AVCodecParameters *par, + const AVCodecParameters *par, AVIOContext *dyn_cp) { switch (par->codec_id) { @@ -799,7 +801,9 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, return ret; } -static int mkv_write_video_color(AVIOContext *pb, AVCodecParameters *par, AVStream *st) { +static int mkv_write_video_color(AVIOContext *pb, const AVCodecParameters *par, + const AVStream *st) +{ AVIOContext *dyn_cp; uint8_t *colorinfo_ptr; int side_data_size = 0; @@ -890,7 +894,7 @@ static int mkv_write_video_color(AVIOContext *pb, AVCodecParameters *par, AVStre } static int mkv_write_video_projection(AVFormatContext *s, AVIOContext *pb, - AVStream *st) + const AVStream *st) { ebml_master projection; int side_data_size = 0; @@ -1003,7 +1007,7 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, { int i; int ret = 0; -AVDictionaryEntry *tag; +const AVDictionaryEntry *tag; MatroskaVideoStereoModeType format = MATROSKA_VIDEO_STEREOMODE_TYPE_NB; *h_width = 1; @@ -1110,7 +1114,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, int display_width_div = 1; int display_height_div = 1; int j, ret; -AVDictionaryEntry *tag; +const AVDictionaryEntry *tag; if (par->codec_type == AVMEDIA_TYPE_ATTACHMENT) { return 0; @@ -1421,10 +1425,10 @@ static int mkv_write_chapters(AVFormatContext *s) } for (i = 0; i < s->nb_chapters; i++) { ebml_master chapteratom, chapterdisplay; -AVChapter *c = s->chapters[i]; +const AVChapter *c = s->chapters[i]; int64_t chapterstart = av_rescale_q(c->start, c->time_base, scale); int64_t chapterend = av_rescale_q(c->end, c->time_base, scale); -AVDictionaryEntry *t = NULL; +const AVDictionaryEntry *t; if (chapterstart < 0 || chapterstart > chapterend || chapterend < 0) { av_log(s, AV_LOG_ERROR, "Invalid chapter start (%"PRId64") or end (%"PRId64").\n", @@ -1452,7 +1456,7 @@ static int mkv_write_chapters(AVFormatContext *s) return 0; } -static int mkv_write_simpletag(AVIOContext *pb, AVDictionaryEn
[FFmpeg-cvslog] avformat/matroskaenc: Don't needlessly copy AVCodecParameters
ffmpeg | branch: master | Andreas Rheinhardt | Wed Jan 22 20:03:15 2020 +0100| [75e50c3141c5e3f96110fcab5fb819736dcdc62e] | committer: Andreas Rheinhardt avformat/matroskaenc: Don't needlessly copy AVCodecParameters At the end of encoding, the FLAC encoder sends a packet whose side data contains updated extradata (e.g. a correct md5 checksum). The Matroska muxer uses this to update the CodecPrivate. In doing so, the stream's codecpar was copied. But given that writing a FLAC CodecPrivate does not modify the used AVCodecParameters at all, there is no need to do so and this commit changes this. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=75e50c3141c5e3f96110fcab5fb819736dcdc62e --- libavformat/matroskaenc.c | 16 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index bdb768209d..71b6b6cc91 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2173,24 +2173,16 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt) break; case AV_CODEC_ID_FLAC: if (side_data_size && (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) { -AVCodecParameters *codecpriv_par; +uint8_t *old_extradata = par->extradata; if (side_data_size != par->extradata_size) { av_log(s, AV_LOG_ERROR, "Invalid FLAC STREAMINFO metadata for output stream %d\n", pkt->stream_index); return AVERROR(EINVAL); } -codecpriv_par = avcodec_parameters_alloc(); -if (!codecpriv_par) -return AVERROR(ENOMEM); -ret = avcodec_parameters_copy(codecpriv_par, par); -if (ret < 0) { -avcodec_parameters_free(&codecpriv_par); -return ret; -} -memcpy(codecpriv_par->extradata, side_data, side_data_size); +par->extradata = side_data; avio_seek(mkv->tracks_bc, track->codecpriv_offset, SEEK_SET); -mkv_write_codecprivate(s, mkv->tracks_bc, codecpriv_par, 1, 0); -avcodec_parameters_free(&codecpriv_par); +mkv_write_codecprivate(s, mkv->tracks_bc, par, 1, 0); +par->extradata = old_extradata; } break; // FIXME: Remove the following once libaom starts propagating extradata during init() ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskaenc: Redo handling of FlagDefault
ffmpeg | branch: master | Andreas Rheinhardt | Sat Jan 18 07:05:20 2020 +0100| [e3c54b549abf2798422245582c0ed775c894ddeb] | committer: Andreas Rheinhardt avformat/matroskaenc: Redo handling of FlagDefault Up until now, the Matroska muxer would mark a track as default if it had the disposition AV_DISPOSITION_DEFAULT or if there was no track with AV_DISPOSITION_DEFAULT set; in the latter case even more than one track of a kind (audio, video, subtitles) was marked as default which is not sensible. This commit changes the logic used to mark tracks as default. There are now three modes for this: a) In the "infer" mode the first track of every type (audio, video, subtitles) with default disposition set will be marked as default; if there is no such track (for a given type), then the first track of this type (if existing) will be marked as default. This behaviour is inspired by mkvmerge. It ensures that the default flags will be set in a sensible way even if the input comes from containers that lack the concept of default flags. This mode is the default mode. b) The "infer_no_subs" mode is similar to the "infer" mode; the difference is that if no subtitle track with default disposition exists, no subtitle track will be marked as default at all. c) The "passthrough" mode: Here the track will be marked as default if and only the corresponding input stream had disposition default. This fixes ticket #8173 (the passthrough mode is ideal for this) as well as ticket #8416 (the "infer_no_subs" mode leads to the desired output). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e3c54b549abf2798422245582c0ed775c894ddeb --- doc/muxers.texi | 19 + libavformat/matroskaenc.c | 56 +++ tests/ref/fate/matroska-flac-extradata-update | 4 +- 3 files changed, 69 insertions(+), 10 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index d341827a86..1a1cdb910a 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1384,6 +1384,25 @@ A safe size for most use cases should be about 50kB per hour of video. Note that cues are only written if the output is seekable and this option will have no effect if it is not. +@item default_mode +This option controls how the FlagDefault of the output tracks will be set. +It influences which tracks players should play by default. The default mode +is @samp{infer}. +@table @samp +@item infer +In this mode, for each type of track (audio, video or subtitle), if there is +a track with disposition default of this type, then the first such track +(i.e. the one with the lowest index) will be marked as default; if no such +track exists, the first track of this type will be marked as default instead +(if existing). This ensures that the default flag is set in a sensible way even +if the input originated from containers that lack the concept of default tracks. +@item infer_no_subs +This mode is the same as infer except that if no subtitle track with +disposition default exists, no subtitle track will be marked as default. +@item passthrough +In this mode the FlagDefault is set if and only if the AV_DISPOSITION_DEFAULT +flag is set in the disposition of the corresponding stream. +@end table @end table @anchor{md5} diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 71b6b6cc91..b7b6e9fbc0 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -58,6 +58,12 @@ * Info, Tracks, Chapters, Attachments, Tags and Cues */ #define MAX_SEEKHEAD_ENTRIES 6 +enum { +DEFAULT_MODE_INFER, +DEFAULT_MODE_INFER_NO_SUBS, +DEFAULT_MODE_PASSTHROUGH, +}; + typedef struct ebml_master { int64_t pos;///< absolute offset in the containing AVIOContext where the master's elements start int sizebytes; ///< how many bytes were reserved for the size @@ -144,6 +150,7 @@ typedef struct MatroskaMuxContext { int wrote_chapters; int allow_raw_vfw; +int default_mode; uint32_t segment_uid[4]; } MatroskaMuxContext; @@ -1102,7 +1109,7 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, AVStream *st, mkv_track *track, AVIOContext *pb, - int default_stream_exists) + int is_default) { AVCodecParameters *par = st->codecpar; ebml_master subinfo, track_master; @@ -1140,8 +1147,8 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, // The default value for TRACKFLAGDEFAULT is 1, so add element // if we need to clear it. -if (default_stream_exists && !(st->disposition & AV_DISPOSITION_DEFAULT)) -put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGDEFAULT, !!(st->disposition & AV_DISPOSITION_DEFAULT)); +if (!is_default) +put_ebml_uint(pb, M