Re: [FFmpeg-devel] [PATCH]lavfi/telecine: Mark telecined frames as interlaced
Am So., 5. Apr. 2020 um 03:30 Uhr schrieb Andriy Gelman : > > On Sun, 05. Apr 02:05, Carl Eugen Hoyos wrote: > > Am So., 5. Apr. 2020 um 01:02 Uhr schrieb Carl Eugen Hoyos > > : > > > > > > Am Sa., 4. Apr. 2020 um 00:44 Uhr schrieb Carl Eugen Hoyos > > > : > > > > New patch attached, it should now only change the telecined > > > > frames and leave the other frames as they are, the setfield > > > > filter can be used to force a progressive setting for them. > > > > > > New patch attached that also sets top_field_first > > > > Which had the effect that fate is correct again, new patch attached. > > FYI > Currently patchwork does some filtering on the subject line to understand when > an attachment in a reply-to message is a new version of a patch. > > If you would like patchwork to treat the attachment as a new version, then > pls remove the "Re: " in the subject line of the reply message. This will > create > a new entry for the patch. > Otherwise the reply is treated as part of the existing thread. All revisions of the patch in this thread were picked up and processed by patchwork. (Sorry if I misunderstood your mail) Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavf/chromaprint: Silence compilation warnings
Am Di., 13. Aug. 2019 um 12:45 Uhr schrieb Carl Eugen Hoyos : > Attached patch fixes several compilation warnings when building with > chromapring. I will push this patch if there are no objections. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [FFmpeg-cvslog] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp
Am Mo., 30. März 2020 um 15:38 Uhr schrieb Carl Eugen Hoyos : > > Am Fr., 27. März 2020 um 19:00 Uhr schrieb phunkyfish : > > > > ffmpeg | branch: master | phunkyfish | Mon Mar 2 > > 19:21:09 2020 +| [b71685865fe761925feedda3cd0b288224d9a509] | > > committer: Aman Gupta > > > > avformat/rtp: Pass sources and block filter addresses via sdp file for rtp > > > > Signed-off-by: Aman Gupta > > > > > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b71685865fe761925feedda3cd0b288224d9a509 > > --- > > > > libavformat/rtsp.c | 49 - > > 1 file changed, 40 insertions(+), 9 deletions(-) > > > > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c > > index cd6fc32a29..a69484d78b 100644 > > --- a/libavformat/rtsp.c > > +++ b/libavformat/rtsp.c > > @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p) > > static int rtp_read_header(AVFormatContext *s) > > { > > uint8_t recvbuf[RTP_MAX_PACKET_LENGTH]; > > -char host[500], sdp[500]; > > -int ret, port; > > +char host[500], sdp[1000], filters_buf[1000]; > > +int ret, port, sdp_length, nc; > > URLContext* in = NULL; > > int payload_type; > > AVCodecParameters *par = NULL; > > @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s) > > AVIOContext pb; > > socklen_t addrlen = sizeof(addr); > > RTSPState *rt = s->priv_data; > > +const char *p; > > > > if (!ff_network_init()) > > return AVERROR(EIO); > > @@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s) > > av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, > > NULL, 0, s->url); > > > > -snprintf(sdp, sizeof(sdp), > > - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n", > > - addr.ss_family == AF_INET ? 4 : 6, host, > > - par->codec_type == AVMEDIA_TYPE_DATA ? "application" : > > - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio", > > - port, payload_type); > > -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp); > > +sdp_length = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length, > > Could this be reverted, the used variable is not initialized? I will revert this patch later today if nobody objects. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] lavc/libaomenc: Support lossless encoding
Am Sa., 4. Apr. 2020 um 18:46 Uhr schrieb Ryo Hirafuji : > > > In an ideal world, crf 0 would force all other settings for a lossless > > encoding. > > I forgot to say that if "-lossless 1" is set, "crf" will also be 0 (in > libaom, internally). > > All those conditions will be forced (ot at least checked by libaom) if we > execute this line: > > > codecctl_int(avctx, AV1E_SET_LOSSLESS, ctx->lossless); > > So, how about executing this line if the "-crf 0" is set? I would prefer this but I am not the maintainer. See also: https://patchwork.ffmpeg.org/project/ffmpeg/patch/CAB0OVGr6o6yR3bVAgJix7R7mZCRRVruw=jqa7wgjb+hq2bv...@mail.gmail.com/ Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [FFmpeg-cvslog] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp
Carl Eugen Hoyos: > Am Mo., 30. März 2020 um 15:38 Uhr schrieb Carl Eugen Hoyos > : >> >> Am Fr., 27. März 2020 um 19:00 Uhr schrieb phunkyfish : >>> >>> ffmpeg | branch: master | phunkyfish | Mon Mar 2 >>> 19:21:09 2020 +| [b71685865fe761925feedda3cd0b288224d9a509] | >>> committer: Aman Gupta >>> >>> avformat/rtp: Pass sources and block filter addresses via sdp file for rtp >>> >>> Signed-off-by: Aman Gupta >>> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b71685865fe761925feedda3cd0b288224d9a509 >>> --- >>> >>> libavformat/rtsp.c | 49 - >>> 1 file changed, 40 insertions(+), 9 deletions(-) >>> >>> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c >>> index cd6fc32a29..a69484d78b 100644 >>> --- a/libavformat/rtsp.c >>> +++ b/libavformat/rtsp.c >>> @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p) >>> static int rtp_read_header(AVFormatContext *s) >>> { >>> uint8_t recvbuf[RTP_MAX_PACKET_LENGTH]; >>> -char host[500], sdp[500]; >>> -int ret, port; >>> +char host[500], sdp[1000], filters_buf[1000]; >>> +int ret, port, sdp_length, nc; >>> URLContext* in = NULL; >>> int payload_type; >>> AVCodecParameters *par = NULL; >>> @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s) >>> AVIOContext pb; >>> socklen_t addrlen = sizeof(addr); >>> RTSPState *rt = s->priv_data; >>> +const char *p; >>> >>> if (!ff_network_init()) >>> return AVERROR(EIO); >>> @@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s) >>> av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, >>> NULL, 0, s->url); >>> >>> -snprintf(sdp, sizeof(sdp), >>> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n", >>> - addr.ss_family == AF_INET ? 4 : 6, host, >>> - par->codec_type == AVMEDIA_TYPE_DATA ? "application" : >>> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio", >>> - port, payload_type); >>> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp); >>> +sdp_length = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length, >> >> Could this be reverted, the used variable is not initialized? > > I will revert this patch later today if nobody objects. > Don't forget to revert this in 4.2, too (yes, it has been backported!). And mention the weird things surrounding this patch that I mentioned in [1]. - Andreas [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259150.html ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [FFmpeg-cvslog] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp
On Sun, 5 Apr 2020, Andreas Rheinhardt wrote: Carl Eugen Hoyos: Am Mo., 30. März 2020 um 15:38 Uhr schrieb Carl Eugen Hoyos : Am Fr., 27. März 2020 um 19:00 Uhr schrieb phunkyfish : ffmpeg | branch: master | phunkyfish | Mon Mar 2 19:21:09 2020 +| [b71685865fe761925feedda3cd0b288224d9a509] | committer: Aman Gupta avformat/rtp: Pass sources and block filter addresses via sdp file for rtp Signed-off-by: Aman Gupta http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b71685865fe761925feedda3cd0b288224d9a509 --- libavformat/rtsp.c | 49 - 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index cd6fc32a29..a69484d78b 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p) static int rtp_read_header(AVFormatContext *s) { uint8_t recvbuf[RTP_MAX_PACKET_LENGTH]; -char host[500], sdp[500]; -int ret, port; +char host[500], sdp[1000], filters_buf[1000]; +int ret, port, sdp_length, nc; URLContext* in = NULL; int payload_type; AVCodecParameters *par = NULL; @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s) AVIOContext pb; socklen_t addrlen = sizeof(addr); RTSPState *rt = s->priv_data; +const char *p; if (!ff_network_init()) return AVERROR(EIO); @@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s) av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, NULL, 0, s->url); -snprintf(sdp, sizeof(sdp), - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n", - addr.ss_family == AF_INET ? 4 : 6, host, - par->codec_type == AVMEDIA_TYPE_DATA ? "application" : - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio", - port, payload_type); -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp); +sdp_length = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length, Could this be reverted, the used variable is not initialized? I will revert this patch later today if nobody objects. Don't forget to revert this in 4.2, too (yes, it has been backported!). And mention the weird things surrounding this patch that I mentioned in [1]. - Andreas [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259150.html And using AVBPrint instead of snprintf would be a lot cleaner anyway. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v12] libavcodec/jpeg2000dec.c: Add support for PPT marker
On Sun, Apr 05, 2020 at 10:28:17 +0530, gautamr...@gmail.com wrote: > +tile->has_ppt = 1; // this tile has a ppt marker > +/*Zppt = */ bytestream2_get_byte(&s->g); // Zppt is skipped and not used I don't know what others think, but, as mentioned in my first review, I really dislike this style, because it gives the impression that this line is commented out, when just skimming over the code. How about just: bytestream2_get_byte(&s->g); // skip Zppt ? Thanks, Moritz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [FFmpeg-cvslog] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp
Am So., 5. Apr. 2020 um 11:06 Uhr schrieb Andreas Rheinhardt : > > Carl Eugen Hoyos: > > Am Mo., 30. März 2020 um 15:38 Uhr schrieb Carl Eugen Hoyos > > : > >> > >> Am Fr., 27. März 2020 um 19:00 Uhr schrieb phunkyfish : > >>> > >>> ffmpeg | branch: master | phunkyfish | Mon Mar 2 > >>> 19:21:09 2020 +| [b71685865fe761925feedda3cd0b288224d9a509] | > >>> committer: Aman Gupta > >>> > >>> avformat/rtp: Pass sources and block filter addresses via sdp file for rtp > >>> > >>> Signed-off-by: Aman Gupta > >>> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b71685865fe761925feedda3cd0b288224d9a509 > >>> --- > >>> > >>> libavformat/rtsp.c | 49 - > >>> 1 file changed, 40 insertions(+), 9 deletions(-) > >>> > >>> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c > >>> index cd6fc32a29..a69484d78b 100644 > >>> --- a/libavformat/rtsp.c > >>> +++ b/libavformat/rtsp.c > >>> @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p) > >>> static int rtp_read_header(AVFormatContext *s) > >>> { > >>> uint8_t recvbuf[RTP_MAX_PACKET_LENGTH]; > >>> -char host[500], sdp[500]; > >>> -int ret, port; > >>> +char host[500], sdp[1000], filters_buf[1000]; > >>> +int ret, port, sdp_length, nc; > >>> URLContext* in = NULL; > >>> int payload_type; > >>> AVCodecParameters *par = NULL; > >>> @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s) > >>> AVIOContext pb; > >>> socklen_t addrlen = sizeof(addr); > >>> RTSPState *rt = s->priv_data; > >>> +const char *p; > >>> > >>> if (!ff_network_init()) > >>> return AVERROR(EIO); > >>> @@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s) > >>> av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, > >>> NULL, 0, s->url); > >>> > >>> -snprintf(sdp, sizeof(sdp), > >>> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n", > >>> - addr.ss_family == AF_INET ? 4 : 6, host, > >>> - par->codec_type == AVMEDIA_TYPE_DATA ? "application" : > >>> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio", > >>> - port, payload_type); > >>> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp); > >>> +sdp_length = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length, > >> > >> Could this be reverted, the used variable is not initialized? > > > > I will revert this patch later today if nobody objects. > > > Don't forget to revert this in 4.2, too (yes, it has been backported!). Aman, could you comment: Why was a patch that neither fixed a security issue nor a regression backported? > And mention the weird things surrounding this patch that I mentioned in [1]. I added the link. Thank you, I would not have checked for the backport, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] libavcodec/libaomenc.c: Support lossless encoding
On Sat, Apr 04, 2020 at 18:53:41 +0900, Ryo Hirafuji wrote: > AV1 support lossless encoding. > In this patch, I added a command line flag to enable it. > @@ -154,7 +158,7 @@ static av_cold void dump_enc_cfg(AVCodecContext *avctx, > av_log(avctx, level, "aom_codec_enc_cfg\n"); > av_log(avctx, level, "generic settings\n" > " %*s%u\n %*s%u\n %*s%u\n %*s%u\n %*s%u\n" > - " %*s%u\n %*s%u\n" > + " %*s%u\n %*s%u\n %*s%u\n" > " %*s{%u/%u}\n %*s%u\n %*s%d\n %*s%u\n", > width, "g_usage:", cfg->g_usage, > width, "g_threads:", cfg->g_threads, > @@ -163,6 +167,7 @@ static av_cold void dump_enc_cfg(AVCodecContext *avctx, > width, "g_h:", cfg->g_h, > width, "g_bit_depth:", cfg->g_bit_depth, > width, "g_input_bit_depth:", cfg->g_input_bit_depth, > + width, "monochrome:",cfg->monochrome, > width, "g_timebase:",cfg->g_timebase.num, > cfg->g_timebase.den, > width, "g_error_resilient:", cfg->g_error_resilient, > width, "g_pass:",cfg->g_pass, Shouldn't this be part of the gray patch? Moritz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v12] libavcodec/jpeg2000dec.c: Add support for PPT marker
On Sun, Apr 5, 2020 at 3:13 PM Moritz Barsnick wrote: > > On Sun, Apr 05, 2020 at 10:28:17 +0530, gautamr...@gmail.com wrote: > > +tile->has_ppt = 1; // this tile has a ppt marker > > +/*Zppt = */ bytestream2_get_byte(&s->g); // Zppt is skipped and not > > used > > I don't know what others think, but, as mentioned in my first review, I > really dislike this style, because it gives the impression that this > line is commented out, when just skimming over the code. > > How about just: > bytestream2_get_byte(&s->g); // skip Zppt > ? > This should do. I'll resubmit. Should I remove other instances of something similar to this in another patch? > Thanks, > Moritz > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- - Gautam | ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] lavc/libaomenc: Support lossless encoding
> I would prefer this but I am not the maintainer. Oh, I see. Hi, Rostislav Pehlivanov, please tell me your idea. (How can I address him/her in ML...?) I think it is more useful to execute this line when "-crf 0" is set: > codecctl_int(avctx, AV1E_SET_LOSSLESS, ctx->lossless); It could let users force lossless video more easily and robustly, because libaom prepared such an option. It is true the following settings will enable lossless encoding, but these conditions may change with libaom change: > If these conditions are not met, "-crf 0" will be lossless: > > <> > "-bit_rate 0" (which means, enccfg.rc_end_usage = AOM_Q) > "-aq-mode none" > "-enable_restoration 0" > > <> > AV1E_SET_ENABLE_CHROMA_DELTAQ must be 0 > AV1E_SET_ENABLE_SUPERRES must be 0 2020年4月5日(日) 18:06 Carl Eugen Hoyos : > Am Sa., 4. Apr. 2020 um 18:46 Uhr schrieb Ryo Hirafuji > : > > > > > In an ideal world, crf 0 would force all other settings for a lossless > > > encoding. > > > > I forgot to say that if "-lossless 1" is set, "crf" will also be 0 (in > > libaom, internally). > > > > All those conditions will be forced (ot at least checked by libaom) if we > > execute this line: > > > > > codecctl_int(avctx, AV1E_SET_LOSSLESS, ctx->lossless); > > > > So, how about executing this line if the "-crf 0" is set? > > I would prefer this but I am not the maintainer. > > See also: > > https://patchwork.ffmpeg.org/project/ffmpeg/patch/CAB0OVGr6o6yR3bVAgJix7R7mZCRRVruw=jqa7wgjb+hq2bv...@mail.gmail.com/ > > Carl Eugen > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] libavcodec/libaomenc.c: Support lossless encoding
Hi, Moritz. Yeah, you are right! And sorry. After the discussion, I will move this change from "lossless patch" to "gray patch". Thanks. 2020年4月5日(日) 19:28 Moritz Barsnick : > On Sat, Apr 04, 2020 at 18:53:41 +0900, Ryo Hirafuji wrote: > > AV1 support lossless encoding. > > In this patch, I added a command line flag to enable it. > > > @@ -154,7 +158,7 @@ static av_cold void dump_enc_cfg(AVCodecContext > *avctx, > > av_log(avctx, level, "aom_codec_enc_cfg\n"); > > av_log(avctx, level, "generic settings\n" > > " %*s%u\n %*s%u\n %*s%u\n %*s%u\n %*s%u\n" > > - " %*s%u\n %*s%u\n" > > + " %*s%u\n %*s%u\n %*s%u\n" > > " %*s{%u/%u}\n %*s%u\n %*s%d\n %*s%u\n", > > width, "g_usage:", cfg->g_usage, > > width, "g_threads:", cfg->g_threads, > > @@ -163,6 +167,7 @@ static av_cold void dump_enc_cfg(AVCodecContext > *avctx, > > width, "g_h:", cfg->g_h, > > width, "g_bit_depth:", cfg->g_bit_depth, > > width, "g_input_bit_depth:", cfg->g_input_bit_depth, > > + width, "monochrome:",cfg->monochrome, > > width, "g_timebase:",cfg->g_timebase.num, > cfg->g_timebase.den, > > width, "g_error_resilient:", cfg->g_error_resilient, > > width, "g_pass:",cfg->g_pass, > > Shouldn't this be part of the gray patch? > > Moritz > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v13] libavcodec/jpeg2000dec.c: Add support for PPT marker
From: Gautam Ramakrishnan This patch adds functional changes to support the PPT marker. This patch fixes bug ticket #4610. --- libavcodec/jpeg2000dec.c | 88 +++- 1 file changed, 77 insertions(+), 11 deletions(-) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 732d88e6fc..2af3c61c37 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -83,6 +83,10 @@ typedef struct Jpeg2000Tile { Jpeg2000QuantStyle qntsty[4]; Jpeg2000POC poc; Jpeg2000TileParttile_part[32]; +uint8_t has_ppt;// whether this tile has a ppt marker +uint8_t *packed_headers;// contains packed headers. Used only along with PPT marker +int packed_headers_size;// size in bytes of the packed headers +GetByteContext packed_headers_stream; // byte context corresponding to packed headers uint16_t tp_idx;// Tile-part index int coord[2][2];// border coordinates {{x0, x1}, {y0, y1}} } Jpeg2000Tile; @@ -855,6 +859,37 @@ static int get_plt(Jpeg2000DecoderContext *s, int n) return 0; } +static int get_ppt(Jpeg2000DecoderContext *s, int n) +{ +Jpeg2000Tile *tile; + +if (s->curtileno < 0) +return AVERROR_INVALIDDATA; + +tile = &s->tile[s->curtileno]; +if (tile->tp_idx != 0) { +av_log(s->avctx, AV_LOG_ERROR, + "PPT marker can occur only on first tile part of a tile.\n"); +return AVERROR_INVALIDDATA; +} + +tile->has_ppt = 1; // this tile has a ppt marker +bytestream2_get_byte(&s->g); // Zppt is skipped and not used +if (!tile->packed_headers) +tile->packed_headers = av_malloc(n - 3); +else +tile->packed_headers = av_realloc(tile->packed_headers, + tile->packed_headers_size + n - 3); +if (!tile->packed_headers) +return AVERROR(ENOMEM); +memcpy(tile->packed_headers + tile->packed_headers_size, + s->g.buffer, n - 3); +tile->packed_headers_size += n - 3; +bytestream2_skip(&s->g, n - 3); + +return 0; +} + static int init_tile(Jpeg2000DecoderContext *s, int tileno) { int compno; @@ -927,6 +962,19 @@ static int getlblockinc(Jpeg2000DecoderContext *s) return res; } +static inline void select_stream(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, + int *tp_index) +{ +s->g = tile->tile_part[*tp_index].tpg; +if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) { +if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) { +s->g = tile->tile_part[++(*tp_index)].tpg; +} +} +if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES) +bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH); +} + static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, int *tp_index, Jpeg2000CodingStyle *codsty, Jpeg2000ResLevel *rlevel, int precno, @@ -938,19 +986,15 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, if (layno < rlevel->band[0].prec[precno].decoded_layers) return 0; rlevel->band[0].prec[precno].decoded_layers = layno + 1; - -if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) { -if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) { -s->g = tile->tile_part[++(*tp_index)].tpg; -} -} - -if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES) -bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH); +// Select stream to read from +if (tile->has_ppt) +s->g = tile->packed_headers_stream; +else +select_stream(s, tile, tp_index); if (!(ret = get_bits(s, 1))) { jpeg2000_flush(s); -return 0; +goto skip_data; } else if (ret < 0) return ret; @@ -1056,6 +1100,11 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found. instead %X\n", bytestream2_peek_be32(&s->g)); } +// Save state of stream +if (tile->has_ppt) { +tile->packed_headers_stream = s->g; +select_stream(s, tile, tp_index); +} for (bandno = 0; bandno < rlevel->nbands; bandno++) { Jpeg2000Band *band = rlevel->band + bandno; Jpeg2000Prec *prec = band->prec + precno; @@ -1097,6 +1146,15 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, av_freep(&cblk->lengthinc); } } +// Save state of stream +tile->tile_part[*tp_index].tpg = s->g; +return 0; + +skip_data: +if (tile->has_ppt) +tile->packed_headers_stream = s->g; +else +tile->tile_part[*tp_index].tpg = s->g; return 0; } @@ -
Re: [FFmpeg-devel] [PATCH 2/2] libavcodec/libaomenc.c: Support lossless encoding
Am So., 5. Apr. 2020 um 12:42 Uhr schrieb Ryo Hirafuji : > > Hi, Moritz. > > Yeah, you are right! And sorry. > > After the discussion, I will move this change from "lossless patch" to > "gray patch". And please mention "Fixes ticket #7599" for the gray patch, "Fixes ticket #7600" for the lossless patch. Thank you! Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] libavcodec/libaomenc.c: Support lossless encoding
OK, I will. Thanks! 2020年4月5日(日) 19:45 Carl Eugen Hoyos : > Am So., 5. Apr. 2020 um 12:42 Uhr schrieb Ryo Hirafuji > : > > > > Hi, Moritz. > > > > Yeah, you are right! And sorry. > > > > After the discussion, I will move this change from "lossless patch" to > > "gray patch". > > And please mention "Fixes ticket #7599" for the gray patch, > "Fixes ticket #7600" for the lossless patch. > > Thank you! > > Carl Eugen > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 00/10] Patch set for the enhancement of libopenh264 encoder
> From: "Linjie Fu" > Sent Time: 2020-04-03 23:12:20 (Friday) > To: ffmpeg-devel@ffmpeg.org > Cc: "Linjie Fu" > Subject: [FFmpeg-devel] [PATCH 00/10] Patch set for the enhancement of > libopenh264 encoder > > Docs will be provided later. > > Linjie Fu (10): > lavc/libopenh264enc: Add default qmin/qmax support > [v2] fix the av_clip logic for iMinQp. > lavc/libopenh264enc: fix the if-else coding style > lavc/libopenh264enc: add default gop size and bit rate > lavc/libopenh264enc: add bit rate control select support > lavc/libopenh264enc: prompt slice number changing according to cpus > lavc/libopenh264enc: set slice_mode option to deprecated > lavc/libopenh264enc: separate svc_encode_init() into several functions > [v2] remove forward declarations. > New: > lavc/libopenh264enc: add profile high option support > lavc/libopenh264enc: allow specifying the profile through AVCodecContext > lavc/libopenh264enc: replace cabac option with coder > > libavcodec/libopenh264enc.c | 361 > ++-- > 1 file changed, 246 insertions(+), 115 deletions(-) > Ping for this patch set. - Linjie ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] lavc/libaomenc: Support lossless encoding
Lynne, could you tell me your idea? 2020年4月5日(日) 19:39 Ryo Hirafuji : > > I would prefer this but I am not the maintainer. > > Oh, I see. > > Hi, Rostislav Pehlivanov, please tell me your idea. > (How can I address him/her in ML...?) > > I think it is more useful to execute this line when "-crf 0" is set: > > > codecctl_int(avctx, AV1E_SET_LOSSLESS, ctx->lossless); > > It could let users force lossless video more easily and robustly, because > libaom prepared such an option. > > It is true the following settings will enable lossless encoding, but these > conditions may change with libaom change: > > > If these conditions are not met, "-crf 0" will be lossless: > > > > <> > > "-bit_rate 0" (which means, enccfg.rc_end_usage = AOM_Q) > > "-aq-mode none" > > "-enable_restoration 0" > > > > <> > > AV1E_SET_ENABLE_CHROMA_DELTAQ must be 0 > > AV1E_SET_ENABLE_SUPERRES must be 0 > > > 2020年4月5日(日) 18:06 Carl Eugen Hoyos : > >> Am Sa., 4. Apr. 2020 um 18:46 Uhr schrieb Ryo Hirafuji >> : >> > >> > > In an ideal world, crf 0 would force all other settings for a lossless >> > > encoding. >> > >> > I forgot to say that if "-lossless 1" is set, "crf" will also be 0 (in >> > libaom, internally). >> > >> > All those conditions will be forced (ot at least checked by libaom) if >> we >> > execute this line: >> > >> > > codecctl_int(avctx, AV1E_SET_LOSSLESS, ctx->lossless); >> > >> > So, how about executing this line if the "-crf 0" is set? >> >> I would prefer this but I am not the maintainer. >> >> See also: >> >> https://patchwork.ffmpeg.org/project/ffmpeg/patch/CAB0OVGr6o6yR3bVAgJix7R7mZCRRVruw=jqa7wgjb+hq2bv...@mail.gmail.com/ >> >> Carl Eugen >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [FFmpeg-cvslog] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp
On Sun, 5 Apr 2020, Carl Eugen Hoyos wrote: Am So., 5. Apr. 2020 um 11:06 Uhr schrieb Andreas Rheinhardt : Carl Eugen Hoyos: > Am Mo., 30. März 2020 um 15:38 Uhr schrieb Carl Eugen Hoyos > : >> >> Am Fr., 27. März 2020 um 19:00 Uhr schrieb phunkyfish : >>> >>> ffmpeg | branch: master | phunkyfish | Mon Mar 2 19:21:09 2020 +| [b71685865fe761925feedda3cd0b288224d9a509] | committer: Aman Gupta >>> >>> avformat/rtp: Pass sources and block filter addresses via sdp file for rtp >>> >>> Signed-off-by: Aman Gupta >>> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b71685865fe761925feedda3cd0b288224d9a509 >>> --- >>> >>> libavformat/rtsp.c | 49 - >>> 1 file changed, 40 insertions(+), 9 deletions(-) >>> >>> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c >>> index cd6fc32a29..a69484d78b 100644 >>> --- a/libavformat/rtsp.c >>> +++ b/libavformat/rtsp.c >>> @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p) >>> static int rtp_read_header(AVFormatContext *s) >>> { >>> uint8_t recvbuf[RTP_MAX_PACKET_LENGTH]; >>> -char host[500], sdp[500]; >>> -int ret, port; >>> +char host[500], sdp[1000], filters_buf[1000]; >>> +int ret, port, sdp_length, nc; >>> URLContext* in = NULL; >>> int payload_type; >>> AVCodecParameters *par = NULL; >>> @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s) >>> AVIOContext pb; >>> socklen_t addrlen = sizeof(addr); >>> RTSPState *rt = s->priv_data; >>> +const char *p; >>> >>> if (!ff_network_init()) >>> return AVERROR(EIO); >>> @@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s) >>> av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, >>> NULL, 0, s->url); >>> >>> -snprintf(sdp, sizeof(sdp), >>> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n", >>> - addr.ss_family == AF_INET ? 4 : 6, host, >>> - par->codec_type == AVMEDIA_TYPE_DATA ? "application" : >>> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio", >>> - port, payload_type); >>> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp); >>> +sdp_length = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length, >> >> Could this be reverted, the used variable is not initialized? > > I will revert this patch later today if nobody objects. > Don't forget to revert this in 4.2, too (yes, it has been backported!). Aman, could you comment: Why was a patch that neither fixed a security issue nor a regression backported? Bug fixes are also candidates for backports. I don't think it is productive to single out the committer, what matters is that it gets fixed eventually which it will one way or another. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [FFmpeg-cvslog] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp
Am So., 5. Apr. 2020 um 13:32 Uhr schrieb Marton Balint : > > > > On Sun, 5 Apr 2020, Carl Eugen Hoyos wrote: > > > Am So., 5. Apr. 2020 um 11:06 Uhr schrieb Andreas Rheinhardt > > : > >> > >> Carl Eugen Hoyos: > >> > Am Mo., 30. März 2020 um 15:38 Uhr schrieb Carl Eugen Hoyos > >> > : > >> >> > >> >> Am Fr., 27. März 2020 um 19:00 Uhr schrieb phunkyfish > >> >> : > >> >>> > >> >>> ffmpeg | branch: master | phunkyfish | Mon Mar > >> >>> 2 19:21:09 2020 +| [b71685865fe761925feedda3cd0b288224d9a509] | > >> >>> committer: Aman Gupta > >> >>> > >> >>> avformat/rtp: Pass sources and block filter addresses via sdp file for > >> >>> rtp > >> >>> > >> >>> Signed-off-by: Aman Gupta > >> >>> > >> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b71685865fe761925feedda3cd0b288224d9a509 > >> >>> --- > >> >>> > >> >>> libavformat/rtsp.c | 49 > >> >>> - > >> >>> 1 file changed, 40 insertions(+), 9 deletions(-) > >> >>> > >> >>> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c > >> >>> index cd6fc32a29..a69484d78b 100644 > >> >>> --- a/libavformat/rtsp.c > >> >>> +++ b/libavformat/rtsp.c > >> >>> @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p) > >> >>> static int rtp_read_header(AVFormatContext *s) > >> >>> { > >> >>> uint8_t recvbuf[RTP_MAX_PACKET_LENGTH]; > >> >>> -char host[500], sdp[500]; > >> >>> -int ret, port; > >> >>> +char host[500], sdp[1000], filters_buf[1000]; > >> >>> +int ret, port, sdp_length, nc; > >> >>> URLContext* in = NULL; > >> >>> int payload_type; > >> >>> AVCodecParameters *par = NULL; > >> >>> @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s) > >> >>> AVIOContext pb; > >> >>> socklen_t addrlen = sizeof(addr); > >> >>> RTSPState *rt = s->priv_data; > >> >>> +const char *p; > >> >>> > >> >>> if (!ff_network_init()) > >> >>> return AVERROR(EIO); > >> >>> @@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s) > >> >>> av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, > >> >>> NULL, 0, s->url); > >> >>> > >> >>> -snprintf(sdp, sizeof(sdp), > >> >>> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n", > >> >>> - addr.ss_family == AF_INET ? 4 : 6, host, > >> >>> - par->codec_type == AVMEDIA_TYPE_DATA ? "application" : > >> >>> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : > >> >>> "audio", > >> >>> - port, payload_type); > >> >>> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp); > >> >>> +sdp_length = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length, > >> >> > >> >> Could this be reverted, the used variable is not initialized? > >> > > >> > I will revert this patch later today if nobody objects. > >> > > >> Don't forget to revert this in 4.2, too (yes, it has been backported!). > > > > Aman, could you comment: > > Why was a patch that neither fixed a security issue nor a regression > > backported? > > Bug fixes are also candidates for backports. Which bug was fixed? I very regularly commit things that I (or others) have to fix afterwards. But at least I try to avoid backporting my mistakes, knowing that we don't have the manpower to take care. > I don't think it is productive to single out the committer So, no, I disagree. > what matters is that it gets fixed eventually which it will one way or > another. It turned out that this was surprisingly difficult in HEAD and took weeks. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]configure: Fix libmfx detection
Am Fr., 19. Apr. 2019 um 01:04 Uhr schrieb Carl Eugen Hoyos : > > Hi! > > I needed attached patch to use libmfx. I will push this as I can reproduce the same issue on Linux. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavu/mem: Make alloc array functions more similar to av_malloc
On Sat, Apr 04, 2020 at 12:46:36AM +0200, Carl Eugen Hoyos wrote: > Hi! > > Attached patch makes the alloc array functions more similar to > av_malloc, depending on max_alloc_size instead of INT_MAX. > > Allows a work-around for ticket #7140 > > Please comment, Carl Eugen > mem.c |8 > 1 file changed, 4 insertions(+), 4 deletions(-) > 507531ed6f0932834d005bc1dd7d18e762f158b2 > 0001-lavu-mem-Make-alloc-array-functions-more-similar-to-.patch > From 7ae240a9f7885130251031aba5d0764b11947fec Mon Sep 17 00:00:00 2001 > From: Carl Eugen Hoyos > Date: Sat, 4 Apr 2020 00:37:03 +0200 > Subject: [PATCH] lavu/mem: Make alloc array functions more similar to > av_malloc(). > > Do not limit the array allocation functions to allocations of INT_MAX, > instead depend on max_alloc_size like av_malloc(). > > Allows a workaround for ticket #7140. > --- > libavutil/mem.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) av_size_mult() may be faster also we possibly should check somewhere for SIZE_MAX < INT_MAX for example in configure if we do not support such an oddity thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The educated differ from the uneducated as much as the living from the dead. -- Aristotle signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavfi/telecine: Mark telecined frames as interlaced
On Sun, 05. Apr 10:34, Carl Eugen Hoyos wrote: > Am So., 5. Apr. 2020 um 03:30 Uhr schrieb Andriy Gelman > : > > > > On Sun, 05. Apr 02:05, Carl Eugen Hoyos wrote: > > > Am So., 5. Apr. 2020 um 01:02 Uhr schrieb Carl Eugen Hoyos > > > : > > > > > > > > Am Sa., 4. Apr. 2020 um 00:44 Uhr schrieb Carl Eugen Hoyos > > > > : > > > > > > New patch attached, it should now only change the telecined > > > > > frames and leave the other frames as they are, the setfield > > > > > filter can be used to force a progressive setting for them. > > > > > > > > New patch attached that also sets top_field_first > > > > > > Which had the effect that fate is correct again, new patch attached. > > > > FYI > > Currently patchwork does some filtering on the subject line to understand > > when > > an attachment in a reply-to message is a new version of a patch. > > > > If you would like patchwork to treat the attachment as a new version, then > > pls remove the "Re: " in the subject line of the reply message. This will > > create > > a new entry for the patch. > > Otherwise the reply is treated as part of the existing thread. > > All revisions of the patch in this thread were picked up and processed > by patchwork. > (Sorry if I misunderstood your mail) I did this manually myself :) (i.e. removed "Re: " from subject line and reparsed the emails in patchwork) -- Andriy ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavfi/telecine: Mark telecined frames as interlaced
Andriy Gelman: > On Sun, 05. Apr 10:34, Carl Eugen Hoyos wrote: >> Am So., 5. Apr. 2020 um 03:30 Uhr schrieb Andriy Gelman >> : >>> >>> On Sun, 05. Apr 02:05, Carl Eugen Hoyos wrote: Am So., 5. Apr. 2020 um 01:02 Uhr schrieb Carl Eugen Hoyos : > > Am Sa., 4. Apr. 2020 um 00:44 Uhr schrieb Carl Eugen Hoyos > : >> >> New patch attached, it should now only change the telecined >> frames and leave the other frames as they are, the setfield >> filter can be used to force a progressive setting for them. > > New patch attached that also sets top_field_first Which had the effect that fate is correct again, new patch attached. >>> >>> FYI >>> Currently patchwork does some filtering on the subject line to understand >>> when >>> an attachment in a reply-to message is a new version of a patch. >>> >>> If you would like patchwork to treat the attachment as a new version, then >>> pls remove the "Re: " in the subject line of the reply message. This will >>> create >>> a new entry for the patch. >>> Otherwise the reply is treated as part of the existing thread. > >> >> All revisions of the patch in this thread were picked up and processed >> by patchwork. >> (Sorry if I misunderstood your mail) > > I did this manually myself :) (i.e. removed "Re: " from subject line and > reparsed the emails in patchwork) > Thanks for all the work you put into patchwork, Andriy. Much appreciated. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/vp9: prevent null pointer use on init_frames() failure
On 4/5/2020 3:31 AM, Peter Ross wrote: > --- > libavcodec/vp9.c | 6 ++ > 1 file changed, 6 insertions(+) > > diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c > index 7ee375d4d0..c125e22975 100644 > --- a/libavcodec/vp9.c > +++ b/libavcodec/vp9.c > @@ -1216,18 +1216,24 @@ static av_cold int vp9_decode_free(AVCodecContext > *avctx) > int i; > > for (i = 0; i < 3; i++) { > +if (s->s.frames[i].tf.f) { > if (s->s.frames[i].tf.f->buf[0]) > vp9_frame_unref(avctx, &s->s.frames[i]); > av_frame_free(&s->s.frames[i].tf.f); > +} > } > av_buffer_pool_uninit(&s->frame_extradata_pool); > for (i = 0; i < 8; i++) { > +if (s->s.refs[i].f) { > if (s->s.refs[i].f->buf[0]) > ff_thread_release_buffer(avctx, &s->s.refs[i]); > av_frame_free(&s->s.refs[i].f); > +} > +if (s->next_refs[i].f) { > if (s->next_refs[i].f->buf[0]) > ff_thread_release_buffer(avctx, &s->next_refs[i]); > av_frame_free(&s->next_refs[i].f); > +} > } ff_thread_release_buffer() (and by extension vp9_frame_unref()) already does a check for ThreadFrame->f then ThreadFrame->f->buf[0], so this can be simplified into simply removing the existing checks here and call ff_thread_release_buffer/vp9_frame_unref unconditionally. See vp9_decode_flush(). > > free_buffers(s); > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavc/amrwbdec: Do not ignore NO_DATA frames
On 1/30/2019 10:47 AM, Carl Eugen Hoyos wrote: > 2019-01-29 22:47 GMT+01:00, Carl Eugen Hoyos : >> Hi! >> >> Attached patch fixes decoding NO_DATA amr-wb frames. > > Now with patch. > > Carl Eugen > From 0a8c318c49ec358ad646ed601588154cf7d7da37 Mon Sep 17 00:00:00 2001 > From: Carl Eugen Hoyos > Date: Tue, 29 Jan 2019 22:46:37 +0100 > Subject: [PATCH] lavc/amrwbdec: Do not ignore NO_DATA frames. > > Fixes the actual output duration of the sample in ticket #7113. > --- > libavcodec/amrwbdata.h |2 +- > libavcodec/amrwbdec.c |9 - > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h > index 8a8cbfd..95c0aaa 100644 > --- a/libavcodec/amrwbdata.h > +++ b/libavcodec/amrwbdata.h > @@ -1884,7 +1884,7 @@ static const float lpf_7_coef[31] = { // low pass, 7kHz > cutoff > /** Core frame sizes in each mode */ > static const uint16_t cf_sizes_wb[] = { > 132, 177, 253, 285, 317, 365, 397, 461, 477, > -40 /// SID/comfort noise frame > +40, 0, 0, 0, 0, 0, 0 > }; > > #endif /* AVCODEC_AMRWBDATA_H */ > diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c > index 47fe7eb..b488a5d 100644 > --- a/libavcodec/amrwbdec.c > +++ b/libavcodec/amrwbdec.c > @@ -1119,12 +1119,19 @@ static int amrwb_decode_frame(AVCodecContext *avctx, > void *data, > buf_out = (float *)frame->data[0]; > > header_size = decode_mime_header(ctx, buf); > +expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1; > + > +if (ctx->fr_cur_mode == NO_DATA) { > +for (i = 0; i < frame->nb_samples; i++) > +buf_out[i] = 0.f; You can use av_samples_set_silence() for this. > +*got_frame_ptr = 1; > +return expected_fr_size; > +} > if (ctx->fr_cur_mode > MODE_SID) { > av_log(avctx, AV_LOG_ERROR, > "Invalid mode %d\n", ctx->fr_cur_mode); > return AVERROR_INVALIDDATA; > } > -expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1; > > if (buf_size < expected_fr_size) { > av_log(avctx, AV_LOG_ERROR, > -- > 1.7.10.4 > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavc/amrwbdec: Do not ignore NO_DATA frames
Am So., 5. Apr. 2020 um 16:45 Uhr schrieb James Almer : > > On 1/30/2019 10:47 AM, Carl Eugen Hoyos wrote: > > 2019-01-29 22:47 GMT+01:00, Carl Eugen Hoyos : > >> Hi! > >> > >> Attached patch fixes decoding NO_DATA amr-wb frames. > > > > Now with patch. > > > > Carl Eugen > > > From 0a8c318c49ec358ad646ed601588154cf7d7da37 Mon Sep 17 00:00:00 2001 > > From: Carl Eugen Hoyos > > Date: Tue, 29 Jan 2019 22:46:37 +0100 > > Subject: [PATCH] lavc/amrwbdec: Do not ignore NO_DATA frames. > > > > Fixes the actual output duration of the sample in ticket #7113. > > --- > > libavcodec/amrwbdata.h |2 +- > > libavcodec/amrwbdec.c |9 - > > 2 files changed, 9 insertions(+), 2 deletions(-) > > > > diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h > > index 8a8cbfd..95c0aaa 100644 > > --- a/libavcodec/amrwbdata.h > > +++ b/libavcodec/amrwbdata.h > > @@ -1884,7 +1884,7 @@ static const float lpf_7_coef[31] = { // low pass, > > 7kHz cutoff > > /** Core frame sizes in each mode */ > > static const uint16_t cf_sizes_wb[] = { > > 132, 177, 253, 285, 317, 365, 397, 461, 477, > > -40 /// SID/comfort noise frame > > +40, 0, 0, 0, 0, 0, 0 > > }; > > > > #endif /* AVCODEC_AMRWBDATA_H */ > > diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c > > index 47fe7eb..b488a5d 100644 > > --- a/libavcodec/amrwbdec.c > > +++ b/libavcodec/amrwbdec.c > > @@ -1119,12 +1119,19 @@ static int amrwb_decode_frame(AVCodecContext > > *avctx, void *data, > > buf_out = (float *)frame->data[0]; > > > > header_size = decode_mime_header(ctx, buf); > > +expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1; > > + > > +if (ctx->fr_cur_mode == NO_DATA) { > > +for (i = 0; i < frame->nb_samples; i++) > > +buf_out[i] = 0.f; > > You can use av_samples_set_silence() for this. (Is memset(0) valid for floats?) Patch sent, thank you! Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH]lavc/amrwbdec: Use av_samples_set_silence()
Hi! Attached patch simplifies a funtion in the amrwb decoder, as suggested by James. Please comment, Carl Eugen From 91d50f466728d7d0680882f6f63217f39808c2af Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sun, 5 Apr 2020 17:04:44 +0200 Subject: [PATCH] lavc/amrwbdec: Use av_samples_set_silence(). Suggested-by: James Almer --- libavcodec/amrwbdec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c index b488a5d3c7..1d4f00e717 100644 --- a/libavcodec/amrwbdec.c +++ b/libavcodec/amrwbdec.c @@ -1122,8 +1122,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1; if (ctx->fr_cur_mode == NO_DATA) { -for (i = 0; i < frame->nb_samples; i++) -buf_out[i] = 0.f; +av_samples_set_silence(&buf_out, 0, frame->nb_samples, 1, AV_SAMPLE_FMT_FLT); *got_frame_ptr = 1; return expected_fr_size; } -- 2.24.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavc/amrwbdec: Do not ignore NO_DATA frames
On 4/5/2020 12:07 PM, Carl Eugen Hoyos wrote: > Am So., 5. Apr. 2020 um 16:45 Uhr schrieb James Almer : >> >> On 1/30/2019 10:47 AM, Carl Eugen Hoyos wrote: >>> 2019-01-29 22:47 GMT+01:00, Carl Eugen Hoyos : Hi! Attached patch fixes decoding NO_DATA amr-wb frames. >>> >>> Now with patch. >>> >>> Carl Eugen >> >>> From 0a8c318c49ec358ad646ed601588154cf7d7da37 Mon Sep 17 00:00:00 2001 >>> From: Carl Eugen Hoyos >>> Date: Tue, 29 Jan 2019 22:46:37 +0100 >>> Subject: [PATCH] lavc/amrwbdec: Do not ignore NO_DATA frames. >>> >>> Fixes the actual output duration of the sample in ticket #7113. >>> --- >>> libavcodec/amrwbdata.h |2 +- >>> libavcodec/amrwbdec.c |9 - >>> 2 files changed, 9 insertions(+), 2 deletions(-) >>> >>> diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h >>> index 8a8cbfd..95c0aaa 100644 >>> --- a/libavcodec/amrwbdata.h >>> +++ b/libavcodec/amrwbdata.h >>> @@ -1884,7 +1884,7 @@ static const float lpf_7_coef[31] = { // low pass, >>> 7kHz cutoff >>> /** Core frame sizes in each mode */ >>> static const uint16_t cf_sizes_wb[] = { >>> 132, 177, 253, 285, 317, 365, 397, 461, 477, >>> -40 /// SID/comfort noise frame >>> +40, 0, 0, 0, 0, 0, 0 >>> }; >>> >>> #endif /* AVCODEC_AMRWBDATA_H */ >>> diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c >>> index 47fe7eb..b488a5d 100644 >>> --- a/libavcodec/amrwbdec.c >>> +++ b/libavcodec/amrwbdec.c >>> @@ -1119,12 +1119,19 @@ static int amrwb_decode_frame(AVCodecContext >>> *avctx, void *data, >>> buf_out = (float *)frame->data[0]; >>> >>> header_size = decode_mime_header(ctx, buf); >>> +expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1; >>> + >>> +if (ctx->fr_cur_mode == NO_DATA) { >>> +for (i = 0; i < frame->nb_samples; i++) >>> +buf_out[i] = 0.f; >> >> You can use av_samples_set_silence() for this. > > (Is memset(0) valid for floats?) I would hope so, considering this function is used in half a dozen filters, and the core encoding lavc code... > > Patch sent, thank you! > > Carl Eugen > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavc/amrwbdec: Do not ignore NO_DATA frames
Am So., 5. Apr. 2020 um 17:10 Uhr schrieb James Almer : > > On 4/5/2020 12:07 PM, Carl Eugen Hoyos wrote: > > Am So., 5. Apr. 2020 um 16:45 Uhr schrieb James Almer : > >> > >> On 1/30/2019 10:47 AM, Carl Eugen Hoyos wrote: > >>> 2019-01-29 22:47 GMT+01:00, Carl Eugen Hoyos : > Hi! > > Attached patch fixes decoding NO_DATA amr-wb frames. > >>> > >>> Now with patch. > >>> > >>> Carl Eugen > >> > >>> From 0a8c318c49ec358ad646ed601588154cf7d7da37 Mon Sep 17 00:00:00 2001 > >>> From: Carl Eugen Hoyos > >>> Date: Tue, 29 Jan 2019 22:46:37 +0100 > >>> Subject: [PATCH] lavc/amrwbdec: Do not ignore NO_DATA frames. > >>> > >>> Fixes the actual output duration of the sample in ticket #7113. > >>> --- > >>> libavcodec/amrwbdata.h |2 +- > >>> libavcodec/amrwbdec.c |9 - > >>> 2 files changed, 9 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h > >>> index 8a8cbfd..95c0aaa 100644 > >>> --- a/libavcodec/amrwbdata.h > >>> +++ b/libavcodec/amrwbdata.h > >>> @@ -1884,7 +1884,7 @@ static const float lpf_7_coef[31] = { // low pass, > >>> 7kHz cutoff > >>> /** Core frame sizes in each mode */ > >>> static const uint16_t cf_sizes_wb[] = { > >>> 132, 177, 253, 285, 317, 365, 397, 461, 477, > >>> -40 /// SID/comfort noise frame > >>> +40, 0, 0, 0, 0, 0, 0 > >>> }; > >>> > >>> #endif /* AVCODEC_AMRWBDATA_H */ > >>> diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c > >>> index 47fe7eb..b488a5d 100644 > >>> --- a/libavcodec/amrwbdec.c > >>> +++ b/libavcodec/amrwbdec.c > >>> @@ -1119,12 +1119,19 @@ static int amrwb_decode_frame(AVCodecContext > >>> *avctx, void *data, > >>> buf_out = (float *)frame->data[0]; > >>> > >>> header_size = decode_mime_header(ctx, buf); > >>> +expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1; > >>> + > >>> +if (ctx->fr_cur_mode == NO_DATA) { > >>> +for (i = 0; i < frame->nb_samples; i++) > >>> +buf_out[i] = 0.f; > >> > >> You can use av_samples_set_silence() for this. > > > > (Is memset(0) valid for floats?) > > I would hope so, considering this function is used in half a dozen > filters, and the core encoding lavc code... =-) Is the patch ok? Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavc/amrwbdec: Use av_samples_set_silence()
On 4/5/2020 12:06 PM, Carl Eugen Hoyos wrote: > Hi! > > Attached patch simplifies a funtion in the amrwb decoder, as suggested by > James. > > Please comment, Carl Eugen > From 91d50f466728d7d0680882f6f63217f39808c2af Mon Sep 17 00:00:00 2001 > From: Carl Eugen Hoyos > Date: Sun, 5 Apr 2020 17:04:44 +0200 > Subject: [PATCH] lavc/amrwbdec: Use av_samples_set_silence(). > > Suggested-by: James Almer > --- > libavcodec/amrwbdec.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c > index b488a5d3c7..1d4f00e717 100644 > --- a/libavcodec/amrwbdec.c > +++ b/libavcodec/amrwbdec.c > @@ -1122,8 +1122,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, > void *data, > expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1; > > if (ctx->fr_cur_mode == NO_DATA) { > -for (i = 0; i < frame->nb_samples; i++) > -buf_out[i] = 0.f; > +av_samples_set_silence(&buf_out, 0, frame->nb_samples, 1, > AV_SAMPLE_FMT_FLT); Should be frame->data (or frame->extended_data), not &buf_out. The function expects an uint8_t**, not float**. LGTM otherwise. > *got_frame_ptr = 1; > return expected_fr_size; > } > -- > 2.24.1 > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavc/amrwbdec: Use av_samples_set_silence()
Am So., 5. Apr. 2020 um 17:14 Uhr schrieb James Almer : > > On 4/5/2020 12:06 PM, Carl Eugen Hoyos wrote: > > Hi! > > > > Attached patch simplifies a funtion in the amrwb decoder, as suggested by > > James. > > > > Please comment, Carl Eugen > > > From 91d50f466728d7d0680882f6f63217f39808c2af Mon Sep 17 00:00:00 2001 > > From: Carl Eugen Hoyos > > Date: Sun, 5 Apr 2020 17:04:44 +0200 > > Subject: [PATCH] lavc/amrwbdec: Use av_samples_set_silence(). > > > > Suggested-by: James Almer > > --- > > libavcodec/amrwbdec.c | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c > > index b488a5d3c7..1d4f00e717 100644 > > --- a/libavcodec/amrwbdec.c > > +++ b/libavcodec/amrwbdec.c > > @@ -1122,8 +1122,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, > > void *data, > > expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1; > > > > if (ctx->fr_cur_mode == NO_DATA) { > > -for (i = 0; i < frame->nb_samples; i++) > > -buf_out[i] = 0.f; > > +av_samples_set_silence(&buf_out, 0, frame->nb_samples, 1, > > AV_SAMPLE_FMT_FLT); > > Should be frame->data (or frame->extended_data), not &buf_out. The > function expects an uint8_t**, not float**. > > LGTM otherwise. Applied with that change. Thank you, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavc/amrwb: Output silence for frames marked as broken
Am So., 5. Apr. 2020 um 02:01 Uhr schrieb Carl Eugen Hoyos : > Attached patch makes the output of the file in ticket #7113 very > similar to the reference decoder. New patch attached. Carl Eugen From c5c63dd531aac11f0c927c09a66d2bcff6ea5356 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sun, 5 Apr 2020 17:35:38 +0200 Subject: [PATCH] lavc/amrwbdec: Output silence for frames marked as corrupt. Fixes ticket #7113. --- libavcodec/amrwbdec.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c index 5943bfc84e..7d357a2685 100644 --- a/libavcodec/amrwbdec.c +++ b/libavcodec/amrwbdec.c @@ -1121,7 +1121,10 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, header_size = decode_mime_header(ctx, buf); expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1; -if (ctx->fr_cur_mode == NO_DATA) { +if (!ctx->fr_quality) +av_log(avctx, AV_LOG_ERROR, "Encountered a bad or corrupted frame\n"); + +if (ctx->fr_cur_mode == NO_DATA || !ctx->fr_quality) { av_samples_set_silence(&frame->data[0], 0, frame->nb_samples, 1, AV_SAMPLE_FMT_FLT); *got_frame_ptr = 1; return expected_fr_size; @@ -1139,9 +1142,6 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } -if (!ctx->fr_quality || ctx->fr_cur_mode > MODE_SID) -av_log(avctx, AV_LOG_ERROR, "Encountered a bad or corrupted frame\n"); - if (ctx->fr_cur_mode == MODE_SID) { /* Comfort noise frame */ avpriv_request_sample(avctx, "SID mode"); return AVERROR_PATCHWELCOME; -- 2.24.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 00/20] Matroska muxer patches
This patchset is sort-of a revival of the part of a patchset I sent earlier [1], but which couldn't be applied fully because the way the webm_chunk muxer bypassed the API [2]. Now that this has been fixed [3], I have taken the opportunity to resend this patchset in an updated form. It does not yet completely eliminate the limit on the number of tracks as requested in [4], but no longer counting attachments among the number of tracks is beneficial even if said limit will be removed. - Andreas [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-November/252578.html [2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-December/254783.html [3]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/257850.html [4]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/259734.html Andreas Rheinhardt (20): avformat/matroskaenc: Ensure that ChapterUID are != 0 avformat/matroskaenc: Don't waste bytes writing durations avformat/matroskaenc: Use random TrackUID avformat/matroskaenc: Reuse random seed avformat/matroskaenc: Remove allocations for Attachments avformat/matroskaenc: Make output more deterministic avformat/matroskaenc: Ignore AttachedFiles for track limit avformat/matroskaenc: Automatically use right TrackNumber in Cues avformat/matroskaenc: Increase max supported tracks avformat/matroskaenc: Change signature of mkv_write_track() avformat/matroskaenc: Add check for using explicit TrackNumber avformat/matroskaenc: Improve Cues in case of no video avformat/matroskaenc: Don't use size of inexistent Cluster avformat/matroskaenc: Warn that WebM doesn't support Attachments avformat/matroskaenc: Only write Tracks if there is a track avformat/matroskaenc: Don't waste bytes on length fields avformat/matroskaenc: Add const where appropriate avformat/matroskaenc: Don't needlessly copy AVCodecParameters avformat/matroskaenc: Redo handling of FlagDefault avformat/matroskaenc: Cosmetics doc/muxers.texi | 19 + libavformat/matroskaenc.c | 595 ++ tests/fate/matroska.mak | 2 +- tests/fate/wavpack.mak| 4 +- tests/ref/fate/aac-autobsf-adtstoasc | 4 +- tests/ref/fate/binsub-mksenc | 2 +- tests/ref/fate/matroska-flac-extradata-update | 4 +- tests/ref/fate/rgb24-mkv | 4 +- tests/ref/lavf-fate/av1.mkv | 2 +- tests/ref/lavf/mka| 4 +- tests/ref/lavf/mkv| 4 +- tests/ref/lavf/mkv_attachment | 4 +- tests/ref/seek/lavf-mkv | 44 +- 13 files changed, 384 insertions(+), 308 deletions(-) -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 02/20] avformat/matroskaenc: Don't waste bytes writing durations
Tags in the Matroska file format can be summarized as follows: There is a level 1-element called Tags containing one or many Tag elements each of which in turn contain a Targets element and one or many SimpleTags. Each SimpleTag roughly corresponds to a single key-value pair similar to an AVDictionaryEntry. The Targets meanwhile contains information to what the metadata contained in the SimpleTags contained in the containing Tag applies (i.e. to the file as a whole or to an individual track). The Matroska muxer writes such metadata. It puts the metadata of every stream into a Tag whose Targets makes it point to the corresponding track. And if the output is seekable, then it also adds another Tag for each track whose Targets corresponds to the track and where it reserves space in a SimpleTag to write the duration at the end of the muxing process into. Yet there is no reason to write two Tag elements for a track and a few bytes (typically 24 bytes per track) can be saved by adding the duration SimpleTag to the other Tag of the same track (if it exists). FATE has been updated because the output files changed. (Tests that write to unseekable output (pipes) needn't be updated (no duration tag has ever been written for them) and the same applies to tests without further metadata.) Signed-off-by: Andreas Rheinhardt --- This one is new. libavformat/matroskaenc.c | 48 --- tests/ref/fate/matroska-flac-extradata-update | 4 +- tests/ref/fate/rgb24-mkv | 4 +- tests/ref/lavf/mka| 4 +- tests/ref/lavf/mkv| 4 +- tests/ref/lavf/mkv_attachment | 4 +- tests/ref/seek/lavf-mkv | 44 - 7 files changed, 53 insertions(+), 59 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index a377d092df..96d8c012ad 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1519,14 +1519,14 @@ static int mkv_check_tag_name(const char *name, uint32_t elementid) } static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, uint32_t elementid, - uint64_t uid) + uint64_t uid, ebml_master *tag) { MatroskaMuxContext *mkv = s->priv_data; -ebml_master tag; +ebml_master tag2; int ret; AVDictionaryEntry *t = NULL; -ret = mkv_write_tag_targets(s, elementid, uid, &tag); +ret = mkv_write_tag_targets(s, elementid, uid, tag ? tag : &tag2); if (ret < 0) return ret; @@ -1538,7 +1538,9 @@ static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, uint32_t elementid } } -end_ebml_master(mkv->tags_bc, tag); +if (!tag) +end_ebml_master(mkv->tags_bc, tag2); + return 0; } @@ -1556,53 +1558,43 @@ static int mkv_check_tag(AVDictionary *m, uint32_t elementid) static int mkv_write_tags(AVFormatContext *s) { MatroskaMuxContext *mkv = s->priv_data; +ebml_master tag, *tagp; int i, ret; ff_metadata_conv_ctx(s, ff_mkv_metadata_conv, NULL); if (mkv_check_tag(s->metadata, 0)) { -ret = mkv_write_tag(s, s->metadata, 0, 0); +ret = mkv_write_tag(s, s->metadata, 0, 0, NULL); if (ret < 0) return ret; } +tagp = (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live ? &tag : NULL; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT) continue; -if (!mkv_check_tag(st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID)) +if (!tagp && !mkv_check_tag(st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID)) continue; -ret = mkv_write_tag(s, st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID, i + 1); +ret = mkv_write_tag(s, st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID, +i + 1, tagp); if (ret < 0) return ret; -} - -if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) { -for (i = 0; i < s->nb_streams; i++) { -AVIOContext *pb; -AVStream *st = s->streams[i]; -ebml_master tag_target; -ebml_master tag; -if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT) -continue; - -ret = mkv_write_tag_targets(s, MATROSKA_ID_TAGTARGETS_TRACKUID, -i + 1, &tag_target); -if (ret < 0) -return ret; -pb = mkv->tags_bc; +if (tagp) { +AVIOContext *pb = mkv->tags_bc; +ebml_master simpletag; -tag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, 0); +simpletag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, 0); put_ebml_string(pb, MATROSKA_ID_TAGNAME, "DURATION"); mkv->tracks[i].duration_offset = avio_tell(pb); //
[FFmpeg-devel] [PATCH 01/20] avformat/matroskaenc: Ensure that ChapterUID are != 0
AVChapters have an int as id field and therefore this value can appear <= 0. When remuxing from Matroska, this value actually contains the lower 32 bits of the original ChapterUID (which can be 64 bits). In order to ensure that the ChapterUID is always > 0, they were offset as follows (since 07704c61): First max(0, 1LL - chapter[i].id) was computed and stored in an uint32_t. And then the IDs were offset using this value. This has two downsides: 1. It does not ensure that the UID is actually != 0: Namely if there is a chapter with id == INT_MIN, then the offset will be 2^31 + 1 and a chapter with id == INT_MAX will become 2^31 - 1 + 2^31 + 1 = 2^32 = 0, because the actual calculation was performed in 32 bits. 2. As soon as a chapter id appears to be negative, a nontrivial offset is used, so that not even a ChapterUID that only uses 32 bits is preserved. So change this by treating the id as an unsigned value internally and only offset (by 1) if an id vanishes. The actual offsetting then has to be performed in 64 bits in order to make sure that no UINT32_MAX wraps around. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 060e8b7816..a377d092df 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1422,7 +1422,8 @@ static int mkv_write_chapters(AVFormatContext *s) } chapteratom = start_ebml_master(dyn_cp, MATROSKA_ID_CHAPTERATOM, 0); -put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERUID, c->id + mkv->chapter_id_offset); +put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERUID, + (uint32_t)c->id + (uint64_t)mkv->chapter_id_offset); put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERTIMESTART, chapterstart); put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERTIMEEND, chapterend); if (mkv->mode != MODE_WEBM) { @@ -1479,7 +1480,7 @@ static int mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t) } static int mkv_write_tag_targets(AVFormatContext *s, uint32_t elementid, - unsigned int uid, ebml_master *tag) + uint64_t uid, ebml_master *tag) { AVIOContext *pb; MatroskaMuxContext *mkv = s->priv_data; @@ -1518,7 +1519,7 @@ static int mkv_check_tag_name(const char *name, uint32_t elementid) } static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, uint32_t elementid, - unsigned int uid) + uint64_t uid) { MatroskaMuxContext *mkv = s->priv_data; ebml_master tag; @@ -1612,7 +1613,8 @@ static int mkv_write_tags(AVFormatContext *s) if (!mkv_check_tag(ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID)) continue; -ret = mkv_write_tag(s, ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID, ch->id + mkv->chapter_id_offset); +ret = mkv_write_tag(s, ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID, +(uint32_t)ch->id + (uint64_t)mkv->chapter_id_offset); if (ret < 0) return ret; } @@ -1882,7 +1884,10 @@ static int mkv_write_header(AVFormatContext *s) return ret; for (i = 0; i < s->nb_chapters; i++) -mkv->chapter_id_offset = FFMAX(mkv->chapter_id_offset, 1LL - s->chapters[i]->id); +if (!s->chapters[i]->id) { +mkv->chapter_id_offset = 1; +break; +} ret = mkv_write_chapters(s); if (ret < 0) -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 09/20] avformat/matroskaenc: Increase max supported tracks
Our code can actually write tracks with a TrackNumber in the range of 1..127 without problems. Variable length integers that only have '1' bits after the marker bit are not reserved when being used to encode the TrackNumber in a Block (there is no equivalent of unknown length elements here). Signed-off-by: Andreas Rheinhardt --- Don't know yet if this or a version that completely removes said limit will get in. libavformat/matroskaenc.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index ab1c28ae02..f313b93e2a 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -107,9 +107,9 @@ 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 +/** Maximum number of tracks supported by this muxer (with track numbers + * in the range 1 to 127 (inclusive)) */ +#define MAX_TRACKS 127 typedef struct MatroskaMuxContext { const AVClass *class; @@ -2034,7 +2034,7 @@ static int mkv_write_block(AVFormatContext *s, AVIOContext *pb, put_ebml_id(pb, blockid); put_ebml_num(pb, size + 4, 0); -// this assumes stream_index is less than 126 +// this assumes track_number is <= 127 avio_w8(pb, 0x80 | track_number); avio_wb16(pb, ts - mkv->cluster_pts); avio_w8(pb, (blockid == MATROSKA_ID_SIMPLEBLOCK && keyframe) ? (1 << 7) : 0); @@ -2102,7 +2102,7 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *p put_ebml_id(pb, MATROSKA_ID_BLOCK); put_ebml_num(pb, size + 4, 0); -avio_w8(pb, 0x80 | track->track_num); // this assumes track_num is less than 126 +avio_w8(pb, 0x80 | track->track_num); // this assumes track_num <= 127 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); -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 11/20] 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. Up until now, a TrackNumber of zero was allowed, although this is invalid. Furthermore, it was not checked whether the number of tracks for a file using an explicit TrackNumber was more than one, as such a file would be invalid (it would be impossible to tell to which track a Block belongs if different tracks share the same TrackNumber). Besides that, use the MAX_TRACKS macro for the maximum of dash_track_number. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 27c419954b..b9bfd34756 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2642,6 +2642,9 @@ static int mkv_init(struct AVFormatContext *s) track->track_num = mkv->is_dash ? mkv->dash_track_number : nb_tracks; } +if (mkv->is_dash && nb_tracks != 1) +return AVERROR(EINVAL); + if (nb_tracks > MAX_TRACKS) { av_log(s, AV_LOG_ERROR, "%u > "AV_STRINGIFY(MAX_TRACKS)" tracks (excluding attachments)" @@ -2704,7 +2707,7 @@ static const AVOption options[] = { { "cluster_size_limit", "Store at most the provided amount of bytes in a cluster. ", OFFSET(cluster_size_limit), AV_OPT_TYPE_INT , { .i64 = -1 }, -1, INT_MAX, FLAGS }, { "cluster_time_limit", "Store at most the provided number of milliseconds in a cluster.", OFFSET(cluster_time_limit), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, FLAGS }, { "dash", "Create a WebM file conforming to WebM DASH specification", OFFSET(is_dash), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, -{ "dash_track_number", "Track number for the DASH stream", OFFSET(dash_track_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 127, FLAGS }, +{ "dash_track_number", "Track number for the DASH stream", OFFSET(dash_track_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, MAX_TRACKS, FLAGS }, { "live", "Write files assuming it is a live stream.", OFFSET(is_live), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, { "allow_raw_vfw", "allow RAW VFW mode", OFFSET(allow_raw_vfw), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, { "write_crc32", "write a CRC32 element inside every Level 1 element", OFFSET(write_crc), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS }, -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 03/20] avformat/matroskaenc: Use random TrackUID
Up until now, the TrackUID of a Matroska track which is supposed to be random was not random at all: It always coincided with the TrackNumber which is usually the 1-based index of the corresponding stream in the array of AVStreams. This has been changed: It is now set via an AVLFG if AVFMT_FLAG_BITEXACT is not set. Otherwise it is set like it is set now (the only change happens if an explicit track number has been chosen via dash_track_number, because the system used in the normal situation is now used, too). In particular, no FATE tests need to be updated. This also fixes a bug in case the dash_track_number option was used: In this case the TrackUID was set to the provided number, but the tags were written with a TagTrackUID simply based upon the index, so that the tags didn't apply to the track they ought to apply to. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 47 +-- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 96d8c012ad..d2046193ee 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -95,6 +95,7 @@ typedef struct mkv_cues { typedef struct mkv_track { int write_dts; int has_cue; +uint64_tuid; int sample_rate; int64_t sample_rate_offset; int64_t last_timestamp; @@ -1117,8 +1118,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0); put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER, mkv->is_dash ? mkv->dash_track_number : i + 1); -put_ebml_uint (pb, MATROSKA_ID_TRACKUID, - mkv->is_dash ? mkv->dash_track_number : i + 1); +put_ebml_uint (pb, MATROSKA_ID_TRACKUID, mkv->tracks[i].uid); put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0);// no lacing (yet) if ((tag = av_dict_get(st->metadata, "title", NULL, 0))) @@ -1571,6 +1571,7 @@ static int mkv_write_tags(AVFormatContext *s) tagp = (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live ? &tag : NULL; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; +mkv_track *track = &mkv->tracks[i]; if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT) continue; @@ -1579,7 +1580,7 @@ static int mkv_write_tags(AVFormatContext *s) continue; ret = mkv_write_tag(s, st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID, -i + 1, tagp); +track->uid, tagp); if (ret < 0) return ret; if (tagp) { @@ -1785,10 +1786,6 @@ static int mkv_write_header(AVFormatContext *s) version = 4; } -mkv->tracks = av_mallocz_array(s->nb_streams, sizeof(*mkv->tracks)); -if (!mkv->tracks) { -return AVERROR(ENOMEM); -} ebml_header = start_ebml_master(pb, EBML_ID_HEADER, MAX_EBML_HEADER_SIZE); put_ebml_uint (pb, EBML_ID_EBMLVERSION , 1); put_ebml_uint (pb, EBML_ID_EBMLREADVERSION , 1); @@ -2609,8 +2606,28 @@ static int webm_query_codec(enum AVCodecID codec_id, int std_compliance) return 0; } +static uint64_t mkv_get_uid(const mkv_track *tracks, int i, AVLFG *c) +{ +while (1) { +uint64_t uid; +int k; +uid = (uint64_t)av_lfg_get(c) << 32; +uid |= av_lfg_get(c); +if (!uid) +continue; +for (k = 0; k < i; k++) { +if (tracks[k].uid == uid) +break; +} +if (k == i) +return uid; +} +} + static int mkv_init(struct AVFormatContext *s) { +MatroskaMuxContext *mkv = s->priv_data; +AVLFG c; int i; if (s->nb_streams > MAX_TRACKS) { @@ -2639,7 +2656,23 @@ static int mkv_init(struct AVFormatContext *s) s->internal->avoid_negative_ts_use_pts = 1; } +mkv->tracks = av_mallocz_array(s->nb_streams, sizeof(*mkv->tracks)); +if (!mkv->tracks) { +return AVERROR(ENOMEM); +} + +if (!(s->flags & AVFMT_FLAG_BITEXACT)) +av_lfg_init(&c, av_get_random_seed()); + for (i = 0; i < s->nb_streams; i++) { +mkv_track *track = &mkv->tracks[i]; + +if (s->flags & AVFMT_FLAG_BITEXACT) { +track->uid = i + 1; +} else { +track->uid = mkv_get_uid(mkv->tracks, i, &c); +} + // ms precision is the de-facto standard timescale for mkv files avpriv_set_pts_info(s->streams[i], 64, 1, 1000); } -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 04/20] avformat/matroskaenc: Reuse random seed
This commit reuses the random seed generated in mkv_init() (to determine the TrackUIDs) for the SegmentUID in order to avoid a potentially expensive call to av_get_random_seed(). Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index d2046193ee..b93c50cb01 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -161,6 +161,8 @@ typedef struct MatroskaMuxContext { int wrote_chapters; int allow_raw_vfw; + +uint32_t segment_uid[4]; } MatroskaMuxContext; /** 2 bytes * 7 for EBML IDs, 7 1-byte EBML lengths, 6 1-byte uint, @@ -1821,15 +1823,7 @@ static int mkv_write_header(AVFormatContext *s) put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, LIBAVFORMAT_IDENT); if (mkv->mode != MODE_WEBM) { -uint32_t segment_uid[4]; -AVLFG lfg; - -av_lfg_init(&lfg, av_get_random_seed()); - -for (i = 0; i < 4; i++) -segment_uid[i] = av_lfg_get(&lfg); - -put_ebml_binary(pb, MATROSKA_ID_SEGMENTUID, segment_uid, 16); +put_ebml_binary(pb, MATROSKA_ID_SEGMENTUID, mkv->segment_uid, 16); } } else { const char *ident = "Lavf"; @@ -2661,9 +2655,14 @@ static int mkv_init(struct AVFormatContext *s) return AVERROR(ENOMEM); } -if (!(s->flags & AVFMT_FLAG_BITEXACT)) +if (!(s->flags & AVFMT_FLAG_BITEXACT)) { av_lfg_init(&c, av_get_random_seed()); +// Calculate the SegmentUID now in order not to waste our random seed. +for (i = 0; i < 4; i++) +mkv->segment_uid[i] = av_lfg_get(&c); +} + for (i = 0; i < s->nb_streams; i++) { mkv_track *track = &mkv->tracks[i]; -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 10/20] avformat/matroskaenc: Change signature of mkv_write_track()
Up until now, mkv_write_track() received the index of the stream whose header data it is about to write as parameter; this index has until recently been explicitly used to generate both TrackNumber and TrackUID. But this is no longer so and as there is no reason why the function for writing a single TrackEntry should even know the index of the TrackEntry it is about to write, said index is replaced in the list of function parameters by the corresponding AVStream and mkv_track. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index f313b93e2a..27c419954b 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1083,11 +1083,11 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, } static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, - int i, AVIOContext *pb, int default_stream_exists) + AVStream *st, mkv_track *track, AVIOContext *pb, + int default_stream_exists) { -AVStream *st = s->streams[i]; AVCodecParameters *par = st->codecpar; -ebml_master subinfo, track; +ebml_master subinfo, track_master; int native_id = 0; int qt_id = 0; int bit_depth; @@ -1110,9 +1110,9 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, return ret; } -track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0); -put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER, mkv->tracks[i].track_num); -put_ebml_uid (pb, MATROSKA_ID_TRACKUID, mkv->tracks[i].uid); +track_master = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0); +put_ebml_uint(pb, MATROSKA_ID_TRACKNUMBER, track->track_num); +put_ebml_uid (pb, MATROSKA_ID_TRACKUID,track->uid); put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0);// no lacing (yet) if ((tag = av_dict_get(st->metadata, "title", NULL, 0))) @@ -1209,7 +1209,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, else if (!native_id) { // if there is no mkv-specific codec ID, use VFW mode put_ebml_string(pb, MATROSKA_ID_CODECID, "V_MS/VFW/FOURCC"); -mkv->tracks[i].write_dts = 1; +track->write_dts = 1; s->internal->avoid_negative_ts_use_pts = 0; } @@ -1285,9 +1285,9 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, av_log(s, AV_LOG_ERROR, "Initial padding is invalid\n"); return AVERROR(EINVAL); } -//mkv->tracks[i].ts_offset = av_rescale_q(par->initial_padding, -//(AVRational){ 1, par->sample_rate }, -//st->time_base); +//track->ts_offset = av_rescale_q(par->initial_padding, +//(AVRational){ 1, par->sample_rate }, +//st->time_base); put_ebml_uint(pb, MATROSKA_ID_CODECDELAY, codecdelay); } @@ -1303,7 +1303,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 0); put_ebml_uint (pb, MATROSKA_ID_AUDIOCHANNELS, par->channels); -mkv->tracks[i].sample_rate_offset = avio_tell(pb); +track->sample_rate_offset = avio_tell(pb); put_ebml_float (pb, MATROSKA_ID_AUDIOSAMPLINGFREQ, sample_rate); if (output_sample_rate) put_ebml_float(pb, MATROSKA_ID_AUDIOOUTSAMPLINGFREQ, output_sample_rate); @@ -1339,13 +1339,13 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, } if (mkv->mode != MODE_WEBM || par->codec_id != AV_CODEC_ID_WEBVTT) { -mkv->tracks[i].codecpriv_offset = avio_tell(pb); +track->codecpriv_offset = avio_tell(pb); ret = mkv_write_codecprivate(s, pb, par, native_id, qt_id); if (ret < 0) return ret; } -end_ebml_master(pb, track); +end_ebml_master(pb, track_master); return 0; } @@ -1367,7 +1367,9 @@ static int mkv_write_tracks(AVFormatContext *s) default_stream_exists |= st->disposition & AV_DISPOSITION_DEFAULT; } for (i = 0; i < s->nb_streams; i++) { -ret = mkv_write_track(s, mkv, i, mkv->tracks_bc, default_stream_exists); +AVStream *st = s->streams[i]; +ret = mkv_write_track(s, mkv, st, &mkv->tracks[i], + mkv->tracks_bc, default_stream_exists); if (ret < 0) return ret; } -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, v
[FFmpeg-devel] [PATCH 05/20] avformat/matroskaenc: Remove allocations for Attachments
If there are Attachments to write, the Matroska muxer currently allocates two objects: An array that contains an entry for each AttachedFile containing just the stream index of the corresponding stream and the FileUID used for this AttachedFile; and a structure with a pointer to said array and a counter for said array. These uids are generated via code special to Attachments: It uses an AVLFG in the normal and a sha of the attachment data in the bitexact case. (Said sha requires an allocation, too.) But now that an uid is generated for each stream in mkv_init(), there is no need any more to use special code for generating the FileUIDs of AttachedFiles: One can simply use the uid already generated for the corresponding stream. And this makes the whole allocations of the structures for AttachedFiles as well as the structures itself superfluous. They have been removed. In case AVFMT_FLAG_BITEXACT is set, the uids will be different from the old ones which is the reason why the FATE-test lavf-mkv_attachment needed to be updated. The old method had the drawback that two AttachedFiles with the same data would have the same FileUID. The new one doesn't. Also notice that the dynamic buffer used to write the Attachments leaks if an error happens when writing the buffer. By removing the allocations potential sources of errors have been removed. Signed-off-by: Andreas Rheinhardt --- This will be the last patch of my "remove allocations for"-series; after this there won't be any allocations to remove any more. libavformat/matroskaenc.c | 63 +-- tests/ref/lavf/mkv_attachment | 4 +-- 2 files changed, 11 insertions(+), 56 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index b93c50cb01..135d5e3abd 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -50,7 +50,6 @@ #include "libavutil/random_seed.h" #include "libavutil/rational.h" #include "libavutil/samplefmt.h" -#include "libavutil/sha.h" #include "libavutil/stereo3d.h" #include "libavcodec/xiph.h" @@ -105,16 +104,6 @@ typedef struct mkv_track { int64_t ts_offset; } mkv_track; -typedef struct mkv_attachment { -int stream_idx; -uint32_tfileuid; -} mkv_attachment; - -typedef struct mkv_attachments { -mkv_attachment *entries; -int num_entries; -} mkv_attachments; - #define MODE_MATROSKAv2 0x01 #define MODE_WEBM 0x02 @@ -141,7 +130,6 @@ typedef struct MatroskaMuxContext { mkv_seekheadseekhead; mkv_cuescues; mkv_track *tracks; -mkv_attachments *attachments; AVPacketcur_audio_pkt; @@ -403,10 +391,6 @@ static void mkv_deinit(AVFormatContext *s) ffio_free_dyn_buf(&mkv->tags_bc); av_freep(&mkv->cues.entries); -if (mkv->attachments) { -av_freep(&mkv->attachments->entries); -av_freep(&mkv->attachments); -} av_freep(&mkv->tracks); } @@ -1617,15 +1601,18 @@ static int mkv_write_tags(AVFormatContext *s) } if (mkv->have_attachments && mkv->mode != MODE_WEBM) { -for (i = 0; i < mkv->attachments->num_entries; i++) { -mkv_attachment *attachment = &mkv->attachments->entries[i]; -AVStream *st = s->streams[attachment->stream_idx]; +for (i = 0; i < s->nb_streams; i++) { +mkv_track *track = &mkv->tracks[i]; +AVStream *st = s->streams[i]; + +if (st->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT) +continue; if (!mkv_check_tag(st->metadata, MATROSKA_ID_TAGTARGETS_ATTACHUID)) continue; ret = mkv_write_tag(s, st->metadata, MATROSKA_ID_TAGTARGETS_ATTACHUID, -attachment->fileuid, NULL); +track->uid, NULL); if (ret < 0) return ret; } @@ -1645,18 +1632,11 @@ static int mkv_write_attachments(AVFormatContext *s) { MatroskaMuxContext *mkv = s->priv_data; AVIOContext *dyn_cp = NULL, *pb = s->pb; -AVLFG c; int i, ret; if (!mkv->have_attachments) return 0; -mkv->attachments = av_mallocz(sizeof(*mkv->attachments)); -if (!mkv->attachments) -return AVERROR(ENOMEM); - -av_lfg_init(&c, av_get_random_seed()); - mkv_add_seekhead_entry(mkv, MATROSKA_ID_ATTACHMENTS, avio_tell(pb)); ret = start_ebml_master_crc32(&dyn_cp, mkv); @@ -1664,20 +1644,14 @@ static int mkv_write_attachments(AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; +mkv_track *track = &mkv->tracks[i]; ebml_master attached_file; -mkv_attachment *attachment = mkv->attachments->entries; AVDictionaryEntry *t; const char *mimetype = NULL; -uint32_t fileuid; if (st->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT) continue; -
[FFmpeg-devel] [PATCH 13/20] 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 --- libavformat/matroskaenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index a469d48cc0..acac3828f2 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2328,6 +2328,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 @@ -2355,9 +2356,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, -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 07/20] avformat/matroskaenc: Ignore AttachedFiles for track limit
Attachments are streams in FFmpeg, but they are not tracks in Matroska. Yet they were counted when checking a limit for the number of tracks that the Matroska muxer imposes. This is unnecessary and has been changed. Also use unsigned variables for the variables denoting TrackNumbers as negative TrackNumbers are impossible. (The Matroska file format actually has practically no limit on the number of tracks and this is purely what our muxer supports. But even if this limit were removed/relaxed in the future, it still makes sense to use small TrackNumbers as this patch does, because greater numbers need more bytes to encode.) Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 39 --- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index cf2bb7b933..4607ddd6ad 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -95,6 +95,7 @@ typedef struct mkv_track { int write_dts; int has_cue; uint64_tuid; +unsignedtrack_num; int sample_rate; int64_t sample_rate_offset; int64_t last_timestamp; @@ -1112,8 +1113,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, } track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0); -put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER, - mkv->is_dash ? mkv->dash_track_number : i + 1); +put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER, mkv->tracks[i].track_num); put_ebml_uid (pb, MATROSKA_ID_TRACKUID, mkv->tracks[i].uid); put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0);// no lacing (yet) @@ -1966,7 +1966,7 @@ static int mkv_write_block(AVFormatContext *s, AVIOContext *pb, int64_t ts = track->write_dts ? pkt->dts : pkt->pts; uint64_t additional_id; int64_t discard_padding = 0; -uint8_t track_number = (mkv->is_dash ? mkv->dash_track_number : (pkt->stream_index + 1)); +unsigned track_number = track->track_num; ebml_master block_group, block_additions, block_more; ts += track->ts_offset; @@ -1976,7 +1976,7 @@ static int mkv_write_block(AVFormatContext *s, AVIOContext *pb, av_log(s, AV_LOG_DEBUG, "Writing block of size %d with pts %" PRId64 ", dts %" PRId64 ", " "duration %" PRId64 " at relative offset %" PRId64 " in cluster " - "at offset %" PRId64 ". TrackNumber %d, keyframe %d\n", + "at offset %" PRId64 ". TrackNumber %u, keyframe %d\n", pkt->size, pkt->pts, pkt->dts, pkt->duration, avio_tell(pb), mkv->cluster_pos, track_number, keyframe != 0); @@ -2074,6 +2074,7 @@ static int mkv_write_block(AVFormatContext *s, AVIOContext *pb, static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt) { MatroskaMuxContext *mkv = s->priv_data; +mkv_track *track = &mkv->tracks[pkt->stream_index]; ebml_master blockgroup; int id_size, settings_size, size; uint8_t *id, *settings; @@ -2095,15 +2096,15 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *p av_log(s, AV_LOG_DEBUG, "Writing block of size %d with pts %" PRId64 ", dts %" PRId64 ", " "duration %" PRId64 " at relative offset %" PRId64 " in cluster " - "at offset %" PRId64 ". TrackNumber %d, keyframe %d\n", + "at offset %" PRId64 ". TrackNumber %u, keyframe %d\n", size, pkt->pts, pkt->dts, pkt->duration, avio_tell(pb), - mkv->cluster_pos, pkt->stream_index + 1, 1); + mkv->cluster_pos, track->track_num, 1); blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(size)); put_ebml_id(pb, MATROSKA_ID_BLOCK); put_ebml_num(pb, size + 4, 0); -avio_w8(pb, 0x80 | (pkt->stream_index + 1)); // this assumes stream_index is less than 126 +avio_w8(pb, 0x80 | track->track_num); // this assumes track_num is less than 126 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); @@ -2232,7 +2233,7 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_ int ret; int64_t ts = track->write_dts ? pkt->dts : pkt->pts; int64_t relative_packet_pos; -int tracknum = mkv->is_dash ? mkv->dash_track_number : pkt->stream_index + 1; +unsigned tracknum = track->track_num; if (ts == AV_NOPTS_VALUE) { av_log(s, AV_LOG_ERROR, "Can't write packet with unknown timestamp\n"); @@ -2587,15 +2588,9 @@ static int mkv_init(struct AVFormatContext *s) { MatroskaMuxContext *mkv = s->priv_data; AVLFG c; +unsigned nb_tracks = 0; int i; -if (s->nb_streams > MAX_TRACKS) { -av_log(s, AV_LOG_ERROR, - "At most %d streams are support
[FFmpeg-devel] [PATCH 08/20] avformat/matroskaenc: Automatically use right TrackNumber in Cues
mkv_cuepoint (the structure used to store the index entries in the Matroska muxer) currently contains fields for both the index of the packet's stream in the AVFormatContext.streams array and for the Matroska TrackNumber; correspondingly, mkv_add_cuepoint() has arguments for both. But these two numbers can't be chosen independently, so get rid of the TrackNumber. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 4607ddd6ad..ab1c28ae02 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -80,7 +80,6 @@ typedef struct mkv_seekhead { typedef struct mkv_cuepoint { uint64_tpts; int stream_idx; -int tracknum; int64_t cluster_pos;///< offset of the cluster containing the block relative to the segment int64_t relative_pos; ///< relative offset from the position of the cluster containing the block int64_t duration; ///< duration of the block according to time base @@ -479,7 +478,7 @@ static int mkv_write_seekhead(AVIOContext *pb, MatroskaMuxContext *mkv, return 0; } -static int mkv_add_cuepoint(MatroskaMuxContext *mkv, int stream, int tracknum, int64_t ts, +static int mkv_add_cuepoint(MatroskaMuxContext *mkv, int stream, int64_t ts, int64_t cluster_pos, int64_t relative_pos, int64_t duration) { mkv_cues *cues = &mkv->cues; @@ -495,7 +494,6 @@ static int mkv_add_cuepoint(MatroskaMuxContext *mkv, int stream, int tracknum, i cues->entries[cues->num_entries].pts = ts; cues->entries[cues->num_entries].stream_idx= stream; -cues->entries[cues->num_entries].tracknum = tracknum; cues->entries[cues->num_entries].cluster_pos = cluster_pos - mkv->segment_offset; cues->entries[cues->num_entries].relative_pos = relative_pos; cues->entries[cues->num_entries++].duration= duration; @@ -534,7 +532,7 @@ static int mkv_assemble_cues(AVStream **streams, AVIOContext *dyn_cp, continue; tracks[idx].has_cue = 1; track_positions = start_ebml_master(cuepoint, MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE); -put_ebml_uint(cuepoint, MATROSKA_ID_CUETRACK , entry->tracknum ); +put_ebml_uint(cuepoint, MATROSKA_ID_CUETRACK , tracks[idx].track_num); put_ebml_uint(cuepoint, MATROSKA_ID_CUECLUSTERPOSITION , entry->cluster_pos); put_ebml_uint(cuepoint, MATROSKA_ID_CUERELATIVEPOSITION, entry->relative_pos); if (entry->duration != -1) @@ -2233,7 +2231,6 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_ int ret; int64_t ts = track->write_dts ? pkt->dts : pkt->pts; int64_t relative_packet_pos; -unsigned tracknum = track->track_num; if (ts == AV_NOPTS_VALUE) { av_log(s, AV_LOG_ERROR, "Can't write packet with unknown timestamp\n"); @@ -2270,7 +2267,7 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_ if (ret < 0) return ret; if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && (par->codec_type == AVMEDIA_TYPE_VIDEO && keyframe || add_cue)) { -ret = mkv_add_cuepoint(mkv, pkt->stream_index, tracknum, ts, +ret = mkv_add_cuepoint(mkv, pkt->stream_index, ts, mkv->cluster_pos, relative_packet_pos, -1); if (ret < 0) return ret; } @@ -2296,7 +2293,7 @@ FF_ENABLE_DEPRECATION_WARNINGS } if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { -ret = mkv_add_cuepoint(mkv, pkt->stream_index, tracknum, ts, +ret = mkv_add_cuepoint(mkv, pkt->stream_index, ts, mkv->cluster_pos, relative_packet_pos, duration); if (ret < 0) return ret; -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 06/20] avformat/matroskaenc: Make output more deterministic
Using random values for TrackUID and FileUID (as happens when the AVFMT_FLAG_BITEXACT flag is not set) has the obvious downside of making the output indeterministic. This commit mitigates this by writing the potentially random values with a fixed size of eight byte, even if their actual values would fit into less than eight bytes. This ensures that even in non-bitexact mode, the differences between two files generated with the same settings are restricted to a few bytes in the header. (Namely the SegmentUID, the TrackUIDs (in Tracks as well as when referencing them via TagTrackUID), the FileUIDs (in Attachments as well as in TagAttachmentUID) as well as the CRC-32 checksums of the Info, Tracks, Attachments and Tags level-1-elements.) Without this patch, there might be an offset/a size difference between two such files. The FATE-tests had to be updated because the fixed-sized UIDs are also used in bitexact mode. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 16 +-- tests/fate/matroska.mak | 2 +- tests/fate/wavpack.mak| 4 +- tests/ref/fate/aac-autobsf-adtstoasc | 4 +- tests/ref/fate/binsub-mksenc | 2 +- tests/ref/fate/matroska-flac-extradata-update | 4 +- tests/ref/fate/rgb24-mkv | 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 +-- 12 files changed, 53 insertions(+), 43 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 135d5e3abd..cf2bb7b933 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -226,6 +226,16 @@ static void put_ebml_num(AVIOContext *pb, uint64_t num, int bytes) avio_w8(pb, (uint8_t)(num >> i * 8)); } +/** + * Write a (random) UID with fixed size to make the output more deterministic + */ +static void put_ebml_uid(AVIOContext *pb, uint32_t elementid, uint64_t uid) +{ +put_ebml_id(pb, elementid); +put_ebml_num(pb, 8, 0); +avio_wb64(pb, uid); +} + static void put_ebml_uint(AVIOContext *pb, uint32_t elementid, uint64_t val) { int i, bytes = 1; @@ -1104,7 +1114,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0); put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER, mkv->is_dash ? mkv->dash_track_number : i + 1); -put_ebml_uint (pb, MATROSKA_ID_TRACKUID, mkv->tracks[i].uid); +put_ebml_uid (pb, MATROSKA_ID_TRACKUID, mkv->tracks[i].uid); put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0);// no lacing (yet) if ((tag = av_dict_get(st->metadata, "title", NULL, 0))) @@ -1485,7 +1495,7 @@ static int mkv_write_tag_targets(AVFormatContext *s, uint32_t elementid, *tag= start_ebml_master(pb, MATROSKA_ID_TAG,0); targets = start_ebml_master(pb, MATROSKA_ID_TAGTARGETS, 0); if (elementid) -put_ebml_uint(pb, elementid, uid); +put_ebml_uid(pb, elementid, uid); end_ebml_master(pb, targets); return 0; } @@ -1684,7 +1694,7 @@ static int mkv_write_attachments(AVFormatContext *s) put_ebml_string(dyn_cp, MATROSKA_ID_FILEMIMETYPE, mimetype); put_ebml_binary(dyn_cp, MATROSKA_ID_FILEDATA, st->codecpar->extradata, st->codecpar->extradata_size); -put_ebml_uint(dyn_cp, MATROSKA_ID_FILEUID, track->uid); +put_ebml_uid(dyn_cp, MATROSKA_ID_FILEUID, track->uid); end_ebml_master(dyn_cp, attached_file); } end_ebml_master_crc32(pb, &dyn_cp, mkv, MATROSKA_ID_ATTACHMENTS, 0, 0); diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak index 4b9ee7a872..8cc35d52da 100644 --- a/tests/fate/matroska.mak +++ b/tests/fate/matroska.mak @@ -12,7 +12,7 @@ fate-matroska-prores-header-insertion-bz2: CMD = framecrc -i $(TARGET_SAMPLES)/m FATE_MATROSKA-$(call DEMMUX, MATROSKA, MATROSKA) += fate-matroska-remux fate-matroska-remux: CMD = md5pipe -i $(TARGET_SAMPLES)/vp9-test-vectors/vp90-2-2pass-akiyo.webm -color_trc 4 -c:v copy -fflags +bitexact -strict -2 -f matroska fate-matroska-remux: CMP = oneline -fate-matroska-remux: REF = 49a60ef91cf7302ab7276f9373f8a429 +fate-matroska-remux: REF = 8369f24de64aaa52cf57a699dcdc7d58 FATE_MATROSKA-$(call ALLYES, MATROSKA_DEMUXER VORBIS_PARSER) += fate-matroska-xiph-lacing fate-matroska-xiph-lacing: CMD = framecrc -i $(TARGET_SAMPLES)/mkv/xiph_lacing.mka -c:a copy diff --git a/tests/fate/wavpack.mak b/tests/fate/wavpack.mak index bc7a5cc92f..e3cf4ec632 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-matro
[FFmpeg-devel] [PATCH 14/20] 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 --- libavformat/matroskaenc.c | 19 --- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index acac3828f2..1b9ea45bc0 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1735,12 +1735,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)) @@ -2614,6 +2608,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); @@ -2640,8 +2640,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; -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 12/20] 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 --- 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 b9bfd34756..a469d48cc0 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2120,6 +2120,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); } @@ -,7 +2226,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; @@ -2268,10 +2272,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) { @@ -2336,8 +2342,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 && @@ -2361,9 +2366,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, @@ -2378,7 +2381,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; } @@ -2406,7 +2409,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/ref/fate/aac-autobsf-adtstoasc @@ -1,5 +1,5 @@ -9d0c81ce285a84c0137316004d091d95 *tests/data/fate/aac-autobsf-adtstoasc.matroska -6620 tests/data/fate/aac-autobsf-adtstoasc.matroska +76a14cc1b3292c7f724006d56b7e2eac *tests/data/fate/aac-autobsf-adtstoasc.matroska +6648 tests/data/fate/aac-autobsf-adtstoasc.matroska
[FFmpeg-devel] [PATCH 16/20] 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 --- 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/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 +-- 10 files changed, 43 insertions(+), 42 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 45a2341c22..17e1f8dec9 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -835,7 +835,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) { @@ -1299,7 +1299,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); @@ -1495,7 +1495,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); @@ -1585,7 +1585,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 +6ffdfc7f11f06f94c22cda3a29bf576b *tests/data/fate/aac-autobsf-adtstoasc.matroska +6627 tests/data/fate/aac-autobsf-adtstoasc.matroska #extradata 0:2, 0x0030001c #tb 0: 1/1000 #media_type 0: audio diff --git a/tests/ref/fate/matroska-flac-extradata-update b/tests/ref/fate/matroska-flac-extradata-update index 16b268c4a8..890bf1ac52 100644 --- a/tests/ref/fate/matroska-flac-extradata
[FFmpeg-devel] [PATCH 20/20] avformat/matroskaenc: Cosmetics
Reindentation, removal of { } if they contain only one statement, removal of other useless parentheses and moving the return statement to a line of its own in situations like "if (ret < 0) return ret;". Moreover, several overlong lines were made shorter and a camelCase variable received a name in line with our naming conventions. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 135 +++--- 1 file changed, 66 insertions(+), 69 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 084e7ca416..571fde3ee8 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -261,7 +261,8 @@ static void put_ebml_sint(AVIOContext *pb, uint32_t elementid, int64_t val) int i, bytes = 1; uint64_t tmp = 2*(val < 0 ? val^-1 : val); -while (tmp>>=8) bytes++; +while (tmp >>= 8) +bytes++; put_ebml_id(pb, elementid); put_ebml_num(pb, bytes, 0); @@ -593,8 +594,8 @@ static int put_wv_codecpriv(AVIOContext *pb, const AVCodecParameters *par) return 0; } -static int put_flac_codecpriv(AVFormatContext *s, - AVIOContext *pb, const AVCodecParameters *par) +static int put_flac_codecpriv(AVFormatContext *s, AVIOContext *pb, + const AVCodecParameters *par) { int write_comment = (par->channel_layout && !(par->channel_layout & ~0x3ULL) && @@ -616,7 +617,7 @@ static int put_flac_codecpriv(AVFormatContext *s, av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0); len = ff_vorbiscomment_length(dict, vendor, NULL, 0); -if (len >= ((1<<24) - 4)) { +if (len >= ((1 << 24) - 4)) { av_dict_free(&dict); return AVERROR(EINVAL); } @@ -1109,9 +1110,8 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, int j, ret; const AVDictionaryEntry *tag; -if (par->codec_type == AVMEDIA_TYPE_ATTACHMENT) { +if (par->codec_type == AVMEDIA_TYPE_ATTACHMENT) return 0; -} if (par->codec_id == AV_CODEC_ID_AAC) { ret = get_aac_sample_rates(s, par->extradata, par->extradata_size, &sample_rate, @@ -1123,9 +1123,9 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, track_master = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0); put_ebml_uint(pb, MATROSKA_ID_TRACKNUMBER, track->track_num); put_ebml_uid (pb, MATROSKA_ID_TRACKUID,track->uid); -put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0);// no lacing (yet) +put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGLACING, 0);// no lacing (yet) -if ((tag = av_dict_get(st->metadata, "title", NULL, 0))) +if (tag = av_dict_get(st->metadata, "title", NULL, 0)) put_ebml_string(pb, MATROSKA_ID_TRACKNAME, tag->value); tag = av_dict_get(st->metadata, "language", NULL, 0); put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, @@ -1439,7 +1439,8 @@ static int mkv_write_chapters(AVFormatContext *s) mkv_add_seekhead_entry(mkv, MATROSKA_ID_CHAPTERS, avio_tell(pb)); ret = start_ebml_master_crc32(&dyn_cp, mkv); -if (ret < 0) return ret; +if (ret < 0) +return ret; editionentry = start_ebml_master(dyn_cp, MATROSKA_ID_EDITIONENTRY, 0); if (mkv->mode != MODE_WEBM) { @@ -1468,7 +1469,7 @@ static int mkv_write_chapters(AVFormatContext *s) put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERFLAGHIDDEN , 0); put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERFLAGENABLED, 1); } -if ((t = av_dict_get(c->metadata, "title", NULL, 0))) { +if (t = av_dict_get(c->metadata, "title", NULL, 0)) { chapterdisplay = start_ebml_master(dyn_cp, MATROSKA_ID_CHAPTERDISPLAY, 0); put_ebml_string(dyn_cp, MATROSKA_ID_CHAPSTRING, t->value); put_ebml_string(dyn_cp, MATROSKA_ID_CHAPLANG , "und"); @@ -1556,8 +1557,8 @@ static int mkv_check_tag_name(const char *name, uint32_t elementid) av_strcasecmp(name, "mimetype"))); } -static int mkv_write_tag(AVFormatContext *s, const AVDictionary *m, uint32_t elementid, - uint64_t uid, ebml_master *tag) +static int mkv_write_tag(AVFormatContext *s, const AVDictionary *m, + uint32_t elementid, uint64_t uid, ebml_master *tag) { MatroskaMuxContext *mkv = s->priv_data; const AVDictionaryEntry *t = NULL; @@ -1568,7 +1569,7 @@ static int mkv_write_tag(AVFormatContext *s, const AVDictionary *m, uint32_t ele if (ret < 0) return ret; -while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) { +while (t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX)) { if (mkv_check_tag_name(t->key, elementid)) { ret = mkv_write_simpletag(mkv->tags_bc, t); if (ret < 0) @@ -1586,7 +1587,7 @@ static int mkv_check_tag(const AVDictionary *m, uint32_t elementid) {
[FFmpeg-devel] [PATCH 18/20] 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 --- libavformat/matroskaenc.c | 16 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 3981986e86..3cbaaf9574 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2170,24 +2170,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() -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 15/20] 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 --- libavformat/matroskaenc.c | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 1b9ea45bc0..45a2341c22 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -133,7 +133,7 @@ typedef struct MatroskaMuxContext { AVPacketcur_audio_pkt; -int have_attachments; +unsigned nb_attachments; int have_video; int reserve_cues_space; @@ -1099,7 +1099,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; } @@ -1356,6 +1355,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); @@ -1610,7 +1612,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]; @@ -1644,7 +1646,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)); @@ -2495,9 +2497,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) { @@ -2645,6 +2650,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; } -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 19/20] 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 --- I did not apply this with the last round of patches as I am still hoping that someone would come up with better names. Furthermore, AVFormatContext.nb_streams is actually an unsigned, yet I am using an int to run through it (this is no problem now and probably won't be one ever, because the nb_streams is always in the range of int); I could rewrite this to only use unsigned. Should I do it? 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 3be1c89416..4083e24205 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1358,6 +1358,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 3cbaaf9574..084e7ca416 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -60,6 +60,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 @@ -149,6 +155,7 @@ typedef struct MatroskaMuxContext { int wrote_chapters; int allow_raw_vfw; +int default_mode; uint32_t segment_uid[4]; } MatroskaMuxContext; @@ -1088,7 +1095,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; @@ -1126,8 +1133,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_
[FFmpeg-devel] [PATCH 17/20] avformat/matroskaenc: Add const where appropriate
Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 68 +-- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 17e1f8dec9..3981986e86 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -548,7 +548,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]; @@ -576,7 +577,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); @@ -586,7 +587,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) && @@ -634,8 +635,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; @@ -667,7 +669,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) { @@ -785,7 +787,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; @@ -876,7 +880,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; @@ -989,7 +993,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; @@ -1096,7 +1100,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; @@ -1408,10 +1412,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", @@ -1443,7 +1447,7 @@ static int mkv_write_chapters(AVFormatContext *s) return 0; } -static int mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t) +static int mkv_write_simpletag(AVIOContext *pb, const AVDictionaryEntry *t) { uint8_t *key = av_strdup(t->key); uint8_t *p = key; @@ -1516,13 +1520,13 @@ static int mkv_check_tag_name(const char *name, uint32_t elementid) av_strcasecmp(name, "mimetype"))); } -static int mkv_write_t
Re: [FFmpeg-devel] [PATCH 1/4] avformat/avidec: Don't reimplement ff_free_stream()
Andreas Rheinhardt: > Using ff_free_stream() makes the code more readable, more future-proof > (the old code freed AVCodecContexts and AVCodecParameters and its > substructures manually, so that there is a chance that there would be a > memleak for some time if new substructures were added) and reduces > code size. > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/avidec.c | 17 ++--- > 1 file changed, 2 insertions(+), 15 deletions(-) > > diff --git a/libavformat/avidec.c b/libavformat/avidec.c > index 00c3978b2d..ae343e732a 100644 > --- a/libavformat/avidec.c > +++ b/libavformat/avidec.c > @@ -600,21 +600,8 @@ static int avi_read_header(AVFormatContext *s) > goto fail; > > ast = s->streams[0]->priv_data; > -av_freep(&s->streams[0]->codecpar->extradata); > -av_freep(&s->streams[0]->codecpar); > -#if FF_API_LAVF_AVCTX > -FF_DISABLE_DEPRECATION_WARNINGS > -av_freep(&s->streams[0]->codec); > -FF_ENABLE_DEPRECATION_WARNINGS > -#endif > -if (s->streams[0]->info) > -av_freep(&s->streams[0]->info->duration_error); > -av_freep(&s->streams[0]->info); > -if (s->streams[0]->internal) > -av_freep(&s->streams[0]->internal->avctx); > -av_freep(&s->streams[0]->internal); > -av_freep(&s->streams[0]); > -s->nb_streams = 0; > +st->priv_data = NULL; > +ff_free_stream(s, st); > if (CONFIG_DV_DEMUXER) { > avi->dv_demux = avpriv_dv_init_demux(s); > if (!avi->dv_demux) > Applied the set. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avformat/webmdashenc: Check codec types
Andreas Rheinhardt: > The WebM DASH Manifest muxer only supports VP8, VP9, Vorbis and Opus, > but there was no check for this. The codec type is used to get a pointer > to a string containing the codec name or NULL if it is not one of those > four codecs. Said pointer has then been used without further checks as > string for the %s conversion specifier in an avio_printf()) call which > is undefined behaviour. > > This commit adds a check for the supported codec types. > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/webmdashenc.c | 8 > 1 file changed, 8 insertions(+) > > diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c > index d05b265330..182a361eae 100644 > --- a/libavformat/webmdashenc.c > +++ b/libavformat/webmdashenc.c > @@ -516,6 +516,14 @@ static int > webm_dash_manifest_write_header(AVFormatContext *s) > double start = 0.0; > int ret; > WebMDashMuxContext *w = s->priv_data; > + > +for (unsigned i = 0; i < s->nb_streams; i++) { > +enum AVCodecID codec_id = s->streams[i]->codecpar->codec_id; > +if ((codec_id != AV_CODEC_ID_VP8) && (codec_id != AV_CODEC_ID_VP9) && > +(codec_id != AV_CODEC_ID_VORBIS) && (codec_id != > AV_CODEC_ID_OPUS)) > +return AVERROR(EINVAL); > +} > + > ret = parse_adaptation_sets(s); > if (ret < 0) { > goto fail; > If there are no objections, I intend to apply this patchset tomorrow. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavf/chromaprint: Silence compilation warnings
lgtm with a couple of minor comments On Sun, 05. Apr 10:49, Carl Eugen Hoyos wrote: > Am Di., 13. Aug. 2019 um 12:45 Uhr schrieb Carl Eugen Hoyos > : > > > Attached patch fixes several compilation warnings when building with > > chromapring. > > I will push this patch if there are no objections. > > diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c > index f39c09ddb9..77015d9c10 100644 > --- a/libavformat/chromaprint.c > +++ b/libavformat/chromaprint.c > @@ -114,14 +114,15 @@ fail: > static int write_packet(AVFormatContext *s, AVPacket *pkt) > { > ChromaprintMuxContext *cpr = s->priv_data; > -return chromaprint_feed(cpr->ctx, pkt->data, pkt->size / 2) ? 0 : > AVERROR(EINVAL); > +return chromaprint_feed(cpr->ctx, (const uint16_t *)pkt->data, pkt->size > / 2) ? 0 : AVERROR(EINVAL); > } I noticed that second argument is const int16_t* in chromaprint.h uint16_t* and int16_t* are compatible types in C (I was a bit surprised..) so this doesn't show up as warning. Do you think it's better to change cast to const int16_t* ? > static int write_trailer(AVFormatContext *s) > { > ChromaprintMuxContext *cpr = s->priv_data; > AVIOContext *pb = s->pb; > -void *fp = NULL, *enc_fp = NULL; > +void *fp = NULL; > +char *enc_fp = NULL; > int size, enc_size, ret = AVERROR(EINVAL); > > if (!chromaprint_finish(cpr->ctx)) { > @@ -129,7 +130,7 @@ static int write_trailer(AVFormatContext *s) > goto fail; > } > > -if (!chromaprint_get_raw_fingerprint(cpr->ctx, &fp, &size)) { > +if (!chromaprint_get_raw_fingerprint(cpr->ctx, (uint32_t **)&fp, &size)) > { The second argument used to be void**, so this will show up as a warning in older versions. But probably this is fine. Thanks, -- Andriy ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avformat/webmdashenc: Check codec types
Am Mo., 30. März 2020 um 09:30 Uhr schrieb Andreas Rheinhardt : > > The WebM DASH Manifest muxer only supports VP8, VP9, Vorbis and Opus, > but there was no check for this. The codec type is used to get a pointer > to a string containing the codec name or NULL if it is not one of those > four codecs. Said pointer has then been used without further checks as > string for the %s conversion specifier in an avio_printf()) call which > is undefined behaviour. > > This commit adds a check for the supported codec types. > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/webmdashenc.c | 8 > 1 file changed, 8 insertions(+) > > diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c > index d05b265330..182a361eae 100644 > --- a/libavformat/webmdashenc.c > +++ b/libavformat/webmdashenc.c > @@ -516,6 +516,14 @@ static int > webm_dash_manifest_write_header(AVFormatContext *s) > double start = 0.0; > int ret; > WebMDashMuxContext *w = s->priv_data; > + > +for (unsigned i = 0; i < s->nb_streams; i++) { > +enum AVCodecID codec_id = s->streams[i]->codecpar->codec_id; > +if ((codec_id != AV_CODEC_ID_VP8) && (codec_id != AV_CODEC_ID_VP9) && > +(codec_id != AV_CODEC_ID_VORBIS) && (codec_id != > AV_CODEC_ID_OPUS)) > +return AVERROR(EINVAL); Too man parenthesis imo... Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avformat/webmdashenc: Check codec types
Carl Eugen Hoyos: > Am Mo., 30. März 2020 um 09:30 Uhr schrieb Andreas Rheinhardt > : >> >> The WebM DASH Manifest muxer only supports VP8, VP9, Vorbis and Opus, >> but there was no check for this. The codec type is used to get a pointer >> to a string containing the codec name or NULL if it is not one of those >> four codecs. Said pointer has then been used without further checks as >> string for the %s conversion specifier in an avio_printf()) call which >> is undefined behaviour. >> >> This commit adds a check for the supported codec types. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> libavformat/webmdashenc.c | 8 >> 1 file changed, 8 insertions(+) >> >> diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c >> index d05b265330..182a361eae 100644 >> --- a/libavformat/webmdashenc.c >> +++ b/libavformat/webmdashenc.c >> @@ -516,6 +516,14 @@ static int >> webm_dash_manifest_write_header(AVFormatContext *s) >> double start = 0.0; >> int ret; >> WebMDashMuxContext *w = s->priv_data; >> + >> +for (unsigned i = 0; i < s->nb_streams; i++) { >> +enum AVCodecID codec_id = s->streams[i]->codecpar->codec_id; >> +if ((codec_id != AV_CODEC_ID_VP8) && (codec_id != AV_CODEC_ID_VP9) >> && >> +(codec_id != AV_CODEC_ID_VORBIS) && (codec_id != >> AV_CODEC_ID_OPUS)) >> +return AVERROR(EINVAL); > > Too man parenthesis imo... > Fixed locally. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v13] libavcodec/jpeg2000dec.c: Add support for PPT marker
On Sun, Apr 05, 2020 at 04:13:28PM +0530, gautamr...@gmail.com wrote: > From: Gautam Ramakrishnan > > This patch adds functional changes to support the > PPT marker. This patch fixes bug ticket #4610. > --- > libavcodec/jpeg2000dec.c | 88 +++- > 1 file changed, 77 insertions(+), 11 deletions(-) > > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c > index 732d88e6fc..2af3c61c37 100644 > --- a/libavcodec/jpeg2000dec.c > +++ b/libavcodec/jpeg2000dec.c > @@ -83,6 +83,10 @@ typedef struct Jpeg2000Tile { > Jpeg2000QuantStyle qntsty[4]; > Jpeg2000POC poc; > Jpeg2000TileParttile_part[32]; > +uint8_t has_ppt;// whether this tile has a > ppt marker > +uint8_t *packed_headers;// contains packed headers. > Used only along with PPT marker > +int packed_headers_size;// size in bytes of the > packed headers > +GetByteContext packed_headers_stream; // byte context > corresponding to packed headers > uint16_t tp_idx;// Tile-part index > int coord[2][2];// border coordinates {{x0, x1}, > {y0, y1}} > } Jpeg2000Tile; > @@ -855,6 +859,37 @@ static int get_plt(Jpeg2000DecoderContext *s, int n) > return 0; > } > > +static int get_ppt(Jpeg2000DecoderContext *s, int n) > +{ > +Jpeg2000Tile *tile; > + > +if (s->curtileno < 0) > +return AVERROR_INVALIDDATA; > + > +tile = &s->tile[s->curtileno]; > +if (tile->tp_idx != 0) { > +av_log(s->avctx, AV_LOG_ERROR, > + "PPT marker can occur only on first tile part of a tile.\n"); > +return AVERROR_INVALIDDATA; > +} > + > +tile->has_ppt = 1; // this tile has a ppt marker > +bytestream2_get_byte(&s->g); // Zppt is skipped and not used > +if (!tile->packed_headers) > +tile->packed_headers = av_malloc(n - 3); > +else > +tile->packed_headers = av_realloc(tile->packed_headers, > + tile->packed_headers_size + n - 3); why is the special case with av_malloc() needed ? > +if (!tile->packed_headers) > +return AVERROR(ENOMEM); this is looks like a memleak as the original array has been overwritten but not deallocated thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/4] pthread_frame: make sure ff_thread_release_buffer always cleans the frame
--- libavcodec/pthread_frame.c | 24 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 172731a98e..0e51e89653 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -982,10 +982,11 @@ void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f) PerThreadContext *p = avctx->internal->thread_ctx; FrameThreadContext *fctx; AVFrame *dst, *tmp; +int ret = 0; int can_direct_free = !(avctx->active_thread_type & FF_THREAD_FRAME) || THREAD_SAFE_CALLBACKS(avctx); -if (!f->f || !f->f->buf[0]) +if (!f->f) return; if (avctx->debug & FF_DEBUG_BUFFERS) @@ -994,7 +995,8 @@ void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f) av_buffer_unref(&f->progress); f->owner[0] = f->owner[1] = NULL; -if (can_direct_free) { +// when the frame buffers are not allocated, just reset it to clean state +if (can_direct_free || !f->f->buf[0]) { av_frame_unref(f->f); return; } @@ -1002,13 +1004,17 @@ void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f) fctx = p->parent; pthread_mutex_lock(&fctx->buffer_mutex); -if (p->num_released_buffers + 1 >= INT_MAX / sizeof(*p->released_buffers)) +if (p->num_released_buffers + 1 >= INT_MAX / sizeof(*p->released_buffers)) { +ret = AVERROR(ENOMEM); goto fail; +} tmp = av_fast_realloc(p->released_buffers, &p->released_buffers_allocated, (p->num_released_buffers + 1) * sizeof(*p->released_buffers)); -if (!tmp) +if (!tmp) { +ret = AVERROR(ENOMEM); goto fail; +} p->released_buffers = tmp; dst = &p->released_buffers[p->num_released_buffers]; @@ -1018,4 +1024,14 @@ void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f) fail: pthread_mutex_unlock(&fctx->buffer_mutex); + +// make sure the frame is clean even if we fail to free it +// this leaks, but it is better than crashing +if (ret < 0) { +av_log(avctx, AV_LOG_ERROR, "Could not queue a frame for freeing, this will leak\n"); +memset(f->f->buf, 0, sizeof(f->f->buf)); +if (f->f->extended_buf) +memset(f->f->extended_buf, 0, f->f->nb_extended_buf * sizeof(*f->f->extended_buf)); +av_frame_unref(f->f); +} } -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/4] lavf/wvdec: remove artificial restrictions on stream parameter changes
They are not forbidden by the specification. --- libavformat/wvdec.c | 18 -- 1 file changed, 18 deletions(-) diff --git a/libavformat/wvdec.c b/libavformat/wvdec.c index b9fc6a59f9..4159bf1253 100644 --- a/libavformat/wvdec.c +++ b/libavformat/wvdec.c @@ -208,24 +208,6 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb) if (!wc->rate) wc->rate = rate * rate_x; -if (flags && bpp != wc->bpp) { -av_log(ctx, AV_LOG_ERROR, - "Bits per sample differ, this block: %i, header block: %i\n", - bpp, wc->bpp); -return AVERROR_INVALIDDATA; -} -if (flags && !wc->multichannel && chan != wc->chan) { -av_log(ctx, AV_LOG_ERROR, - "Channels differ, this block: %i, header block: %i\n", - chan, wc->chan); -return AVERROR_INVALIDDATA; -} -if (flags && rate != -1 && !(flags & WV_DSD) && rate * rate_x != wc->rate) { -av_log(ctx, AV_LOG_ERROR, - "Sampling rate differ, this block: %i, header block: %i\n", - rate * rate_x, wc->rate); -return AVERROR_INVALIDDATA; -} return 0; } -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/4] wavpack: fully support stream parameter changes
Fix invalid memory access on DSD streams with changing channel count. --- libavcodec/wavpack.c | 122 +++ 1 file changed, 90 insertions(+), 32 deletions(-) diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index b27262b94e..9cc4104dd0 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/buffer.h" #include "libavutil/channel_layout.h" #define BITSTREAM_READER_LE @@ -109,7 +110,10 @@ typedef struct WavpackContext { AVFrame *frame; ThreadFrame curr_frame, prev_frame; Modulation modulation; + +AVBufferRef *dsd_ref; DSDContext *dsdctx; +int dsd_channels; } WavpackContext; #define LEVEL_DECAY(a) (((a) + 0x80) >> 8) @@ -978,6 +982,32 @@ static av_cold int wv_alloc_frame_context(WavpackContext *c) return 0; } +static int wv_dsd_reset(WavpackContext *s, int channels) +{ +int i; + +s->dsdctx = NULL; +s->dsd_channels = 0; +av_buffer_unref(&s->dsd_ref); + +if (!channels) +return 0; + +if (channels > INT_MAX / sizeof(*s->dsdctx)) +return AVERROR(EINVAL); + +s->dsd_ref = av_buffer_allocz(channels * sizeof(*s->dsdctx)); +if (!s->dsd_ref) +return AVERROR(ENOMEM); +s->dsdctx = (DSDContext*)s->dsd_ref->data; +s->dsd_channels = channels; + +for (i = 0; i < channels; i++) +memset(s->dsdctx[i].buf, 0x69, sizeof(s->dsdctx[i].buf)); + +return 0; +} + #if HAVE_THREADS static int init_thread_copy(AVCodecContext *avctx) { @@ -1008,6 +1038,17 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) return ret; } +av_buffer_unref(&fdst->dsd_ref); +fdst->dsdctx = NULL; +fdst->dsd_channels = 0; +if (fsrc->dsd_ref) { +fdst->dsd_ref = av_buffer_ref(fsrc->dsd_ref); +if (!fdst->dsd_ref) +return AVERROR(ENOMEM); +fdst->dsdctx = (DSDContext*)fdst->dsd_ref->data; +fdst->dsd_channels = fsrc->dsd_channels; +} + return 0; } #endif @@ -1025,15 +1066,9 @@ static av_cold int wavpack_decode_init(AVCodecContext *avctx) s->curr_frame.f = av_frame_alloc(); s->prev_frame.f = av_frame_alloc(); -// the DSD to PCM context is shared (and used serially) between all decoding threads -s->dsdctx = av_calloc(avctx->channels, sizeof(DSDContext)); - -if (!s->curr_frame.f || !s->prev_frame.f || !s->dsdctx) +if (!s->curr_frame.f || !s->prev_frame.f) return AVERROR(ENOMEM); -for (int i = 0; i < avctx->channels; i++) -memset(s->dsdctx[i].buf, 0x69, sizeof(s->dsdctx[i].buf)); - ff_init_dsd_data(); return 0; @@ -1053,8 +1088,7 @@ static av_cold int wavpack_decode_end(AVCodecContext *avctx) ff_thread_release_buffer(avctx, &s->prev_frame); av_frame_free(&s->prev_frame.f); -if (!avctx->internal->is_copy) -av_freep(&s->dsdctx); +av_buffer_unref(&s->dsd_ref); return 0; } @@ -1065,6 +1099,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, WavpackContext *wc = avctx->priv_data; WavpackFrameContext *s; GetByteContext gb; +enum AVSampleFormat sample_fmt; void *samples_l = NULL, *samples_r = NULL; int ret; int got_terms = 0, got_weights = 0, got_samples = 0, @@ -1102,7 +1137,15 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, return AVERROR_INVALIDDATA; } s->frame_flags = bytestream2_get_le32(&gb); -bpp= av_get_bytes_per_sample(avctx->sample_fmt); + +if (s->frame_flags & (WV_FLOAT_DATA | WV_DSD_DATA)) +sample_fmt = AV_SAMPLE_FMT_FLTP; +else if ((s->frame_flags & 0x03) <= 1) +sample_fmt = AV_SAMPLE_FMT_S16P; +else +sample_fmt = AV_SAMPLE_FMT_S32P; + +bpp= av_get_bytes_per_sample(sample_fmt); orig_bpp = ((s->frame_flags & 0x03) + 1) << 3; multiblock = (s->frame_flags & WV_SINGLE_BLOCK) != WV_SINGLE_BLOCK; @@ -1436,11 +1479,11 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, av_log(avctx, AV_LOG_ERROR, "Hybrid config not found\n"); return AVERROR_INVALIDDATA; } -if (!got_float && avctx->sample_fmt == AV_SAMPLE_FMT_FLTP) { +if (!got_float && sample_fmt == AV_SAMPLE_FMT_FLTP) { av_log(avctx, AV_LOG_ERROR, "Float information not found\n"); return AVERROR_INVALIDDATA; } -if (s->got_extra_bits && avctx->sample_fmt != AV_SAMPLE_FMT_FLTP) { +if (s->got_extra_bits && sample_fmt != AV_SAMPLE_FMT_FLTP) { const int size = get_bits_left(&s->gb_extra_bits); const int wanted = s->samples * s->extra_bits << s->stereo_in; if (size < wanted) { @@ -1462,27 +1505,54 @@ static int wavpack_decode_block(AVCodecContext
[FFmpeg-devel] [PATCH 2/4] decode: make sure ff_get_buffer() cleans the frame on failure
Merge ff_get_buffer() and get_buffer_internal() to simplify the code. --- libavcodec/decode.c | 37 +++-- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index af6bb3f952..de1e9fa4a4 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1903,7 +1903,7 @@ int ff_attach_decode_data(AVFrame *frame) return 0; } -static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags) +int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) { const AVHWAccel *hwaccel = avctx->hwaccel; int override_dimensions = 1; @@ -1912,7 +1912,8 @@ static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags) if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { if ((ret = av_image_check_size2(FFALIGN(avctx->width, STRIDE_ALIGN), avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) { av_log(avctx, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n"); -return AVERROR(EINVAL); +ret = AVERROR(EINVAL); +goto fail; } if (frame->width <= 0 || frame->height <= 0) { @@ -1923,56 +1924,48 @@ static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags) if (frame->data[0] || frame->data[1] || frame->data[2] || frame->data[3]) { av_log(avctx, AV_LOG_ERROR, "pic->data[*]!=NULL in get_buffer_internal\n"); -return AVERROR(EINVAL); +ret = AVERROR(EINVAL); +goto fail; } } else if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) { if (frame->nb_samples * (int64_t)avctx->channels > avctx->max_samples) { av_log(avctx, AV_LOG_ERROR, "samples per frame %d, exceeds max_samples %"PRId64"\n", frame->nb_samples, avctx->max_samples); -return AVERROR(EINVAL); +ret = AVERROR(EINVAL); +goto fail; } } ret = ff_decode_frame_props(avctx, frame); if (ret < 0) -return ret; +goto fail; if (hwaccel) { if (hwaccel->alloc_frame) { ret = hwaccel->alloc_frame(avctx, frame); -goto end; +goto fail; } } else avctx->sw_pix_fmt = avctx->pix_fmt; ret = avctx->get_buffer2(avctx, frame, flags); if (ret < 0) -goto end; +goto fail; validate_avframe_allocation(avctx, frame); ret = ff_attach_decode_data(frame); if (ret < 0) -goto end; +goto fail; -end: if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions && !(avctx->codec->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)) { frame->width = avctx->width; frame->height = avctx->height; } -if (ret < 0) -av_frame_unref(frame); - -return ret; -} - -int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) -{ -int ret = get_buffer_internal(avctx, frame, flags); -if (ret < 0) { -av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); -frame->width = frame->height = 0; -} +return 0; +fail: +av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); +av_frame_unref(frame); return ret; } -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]lavf/chromaprint: Silence compilation warnings
Am So., 5. Apr. 2020 um 19:51 Uhr schrieb Andriy Gelman : > > lgtm with a couple of minor comments > > On Sun, 05. Apr 10:49, Carl Eugen Hoyos wrote: > > Am Di., 13. Aug. 2019 um 12:45 Uhr schrieb Carl Eugen Hoyos > > : > > > > > Attached patch fixes several compilation warnings when building with > > > chromapring. > > > > I will push this patch if there are no objections. > > > > > diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c > > index f39c09ddb9..77015d9c10 100644 > > --- a/libavformat/chromaprint.c > > +++ b/libavformat/chromaprint.c > > @@ -114,14 +114,15 @@ fail: > > static int write_packet(AVFormatContext *s, AVPacket *pkt) > > { > > ChromaprintMuxContext *cpr = s->priv_data; > > -return chromaprint_feed(cpr->ctx, pkt->data, pkt->size / 2) ? 0 : > > AVERROR(EINVAL); > > > +return chromaprint_feed(cpr->ctx, (const uint16_t *)pkt->data, > > pkt->size / 2) ? 0 : AVERROR(EINVAL); > > } > > I noticed that second argument is const int16_t* in chromaprint.h > > uint16_t* and int16_t* are compatible types in C (I was a bit surprised..) so > this doesn't show up as warning. > Do you think it's better to change cast to const int16_t* ? Done, thank you for spotting this. > > static int write_trailer(AVFormatContext *s) > > { > > ChromaprintMuxContext *cpr = s->priv_data; > > AVIOContext *pb = s->pb; > > -void *fp = NULL, *enc_fp = NULL; > > +void *fp = NULL; > > +char *enc_fp = NULL; > > int size, enc_size, ret = AVERROR(EINVAL); > > > > if (!chromaprint_finish(cpr->ctx)) { > > @@ -129,7 +130,7 @@ static int write_trailer(AVFormatContext *s) > > goto fail; > > } > > > > -if (!chromaprint_get_raw_fingerprint(cpr->ctx, &fp, &size)) { > > +if (!chromaprint_get_raw_fingerprint(cpr->ctx, (uint32_t **)&fp, > > &size)) { > > The second argument used to be void**, so this will show up as a warning in > older versions. But probably this is fine. Patch applied. Thank you, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avcodec/hapdec: Check tex_size more strictly and before using it
Fixes: OOM Fixes: 20774/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5678608951803904 Fixes: 20956/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5713643025203200 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/hapdec.c | 23 ++- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c index d23ceb5cef..ab364aa790 100644 --- a/libavcodec/hapdec.c +++ b/libavcodec/hapdec.c @@ -305,7 +305,6 @@ static int hap_decode(AVCodecContext *avctx, void *data, HapContext *ctx = avctx->priv_data; ThreadFrame tframe; int ret, i, t; -int tex_size; int section_size; enum HapSectionType section_type; int start_texture_section = 0; @@ -342,6 +341,13 @@ static int hap_decode(AVCodecContext *avctx, void *data, if (ret < 0) return ret; +if (ctx->tex_size != (avctx->coded_width / TEXTURE_BLOCK_W) +*(avctx->coded_height / TEXTURE_BLOCK_H) +*tex_rat[t]) { +av_log(avctx, AV_LOG_ERROR, "uncompressed size mismatches\n"); +return AVERROR_INVALIDDATA; +} + start_texture_section += ctx->texture_section_size + 4; if (avctx->codec->update_thread_context) @@ -349,9 +355,16 @@ static int hap_decode(AVCodecContext *avctx, void *data, /* Unpack the DXT texture */ if (hap_can_use_tex_in_place(ctx)) { +int tex_size; /* Only DXTC texture compression in a contiguous block */ ctx->tex_data = ctx->gbc.buffer; tex_size = FFMIN(ctx->texture_section_size, bytestream2_get_bytes_left(&ctx->gbc)); +if (tex_size < (avctx->coded_width / TEXTURE_BLOCK_W) +*(avctx->coded_height / TEXTURE_BLOCK_H) +*tex_rat[t]) { +av_log(avctx, AV_LOG_ERROR, "Insufficient data\n"); +return AVERROR_INVALIDDATA; +} } else { /* Perform the second-stage decompression */ ret = av_reallocp(&ctx->tex_buf, ctx->tex_size); @@ -367,14 +380,6 @@ static int hap_decode(AVCodecContext *avctx, void *data, } ctx->tex_data = ctx->tex_buf; -tex_size = ctx->tex_size; -} - -if (tex_size < (avctx->coded_width / TEXTURE_BLOCK_W) -*(avctx->coded_height / TEXTURE_BLOCK_H) -*tex_rat[t]) { -av_log(avctx, AV_LOG_ERROR, "Insufficient data\n"); -return AVERROR_INVALIDDATA; } /* Use the decompress function on the texture, one block per thread */ -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avcodec/g2meet: Check tile_width in epic_jb_decode_tile()
Fixes: out of array access Fixes: 21469/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G2M_fuzzer-5199357982015488 Alternatively the arrays can be made bigger or the index can be clipped. In case a real file with such huge tiles exist we ask the user to upload it. Signed-off-by: Michael Niedermayer --- libavcodec/g2meet.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c index 731d29a5d4..7ef275c9fe 100644 --- a/libavcodec/g2meet.c +++ b/libavcodec/g2meet.c @@ -917,6 +917,11 @@ static int epic_jb_decode_tile(G2MContext *c, int tile_x, int tile_y, awidth = FFALIGN(tile_width, 16); aheight = FFALIGN(tile_height, 16); +if (tile_width > (1 << FF_ARRAY_ELEMS(c->ec.prev_row_rung))) { +avpriv_request_sample(avctx, "large tile width"); +return AVERROR_INVALIDDATA; +} + if (els_dsize) { int ret, i, j, k; uint8_t tr_r, tr_g, tr_b, *buf; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/cbs_h264_syntax_template: fix off by 1 error with slice_group_change_cycle
On Mon, Mar 23, 2020 at 05:18:36PM +0100, Michael Niedermayer wrote: > Fixes: assertion failure > Fixes: > 20390/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_REDUNDANT_PPS_fuzzer-5683400772157440 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/cbs_h264_syntax_template.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) will apply [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB During times of universal deceit, telling the truth becomes a revolutionary act. -- George Orwell signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] ERROR: avisynth/avisynth_c.h not found
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 ffmpeg now throws an error during configure: ERROR: avisynth/avisynth_c.h not found I'm pretty sure it has something to do with removing the headers in commit 0c75acb4ce. Cheers, K. C. - -- regards Helmut K. C. Tessarek KeyID 0x172380A011EF4944 Key fingerprint = 8A55 70C1 BD85 D34E ADBC 386C 1723 80A0 11EF 4944 /* Thou shalt not follow the NULL pointer for chaos and madness await thee at its end. */ -BEGIN PGP SIGNATURE- iQIzBAEBCgAdFiEE191csiqpm8f5Ln9WvgmFNJ1E3QAFAl6KUjIACgkQvgmFNJ1E 3QCixg//Z7WbwQDPPliNJDehY3OxdQkeePHVtZ4R/FbBgwu3la36GdOMZ8cbnw/g 2NoKYZy0fcVeM0GTsSVKNV/DSm8DD5hSmKbY6K8h2xpRfvg9UjRHGfKvPPpXgHvb FgvJqsEaKGOs5YVgya8qyfeNGnXa0dxc80oTCoNbUkNCkdLOTnwqVC6FSUbcWhqy zzt4zIHlW5oS/5UBO68o4SHTBpmnCXQjOEbkEDiLwwNKTP/NlDeYgYbnf5AXvsBx +7DEUgapdPGwCossA7mgqy+mUWOXBBrShIpfh5C180822zQd1GehIsOAExKpIVwS M7VPH+HMGL9upe8Nnf8+FI5k2EDjTnRfWumEczd3PGVSVeloMUrf7kuvQZ+mVTe1 /adqHdJp/6le0q4KYcthTBpaFHtNP3ifKLsLvC9Xp/qaWldnKQugVY5+MWjCe2uN LsWHmHSqIO2nAF2WXX6FT3UqZj9875cQu7qBn5CmxWpSV4TrESZ3eRFSxJjX9KuR ctQ6091pB4pMOTQ33D/WEDrSHudTQ/soMPg14CazwHIqQ/I/BUXQK2AtUW62lTIM SFWnX5Gp/3xEZDWeEZxlzSdj7J+WZaHTFfyFargFDBh8Phf/PrvDASCy2EqxowYF KQvH5CngQl2RisqthrM6gafnMC+iKwqeEZd+6QZ6LF8i0vlMnnE= =OVJd -END PGP SIGNATURE- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] ERROR: avisynth/avisynth_c.h not found
On Sun, 5 Apr 2020, Helmut K. C. Tessarek wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA512 ffmpeg now throws an error during configure: ERROR: avisynth/avisynth_c.h not found I'm pretty sure it has something to do with removing the headers in commit 0c75acb4ce. Well, do you have the headers installed? Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] ERROR: avisynth/avisynth_c.h not found
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 2020-04-05 18:57, Marton Balint wrote: > Well, do you have the headers installed? No, because they were always part of ffmpeg. You can't just remove stuff without proper documentation. I have been compiing the macOS binaries for 8 years now and this is a joke. Someone breaks ffmpeg from one compile run to the next and you want to put the blame on me? Cheers, K. C. - -- regards Helmut K. C. Tessarek KeyID 0x172380A011EF4944 Key fingerprint = 8A55 70C1 BD85 D34E ADBC 386C 1723 80A0 11EF 4944 /* Thou shalt not follow the NULL pointer for chaos and madness await thee at its end. */ -BEGIN PGP SIGNATURE- iQIzBAEBCgAdFiEE191csiqpm8f5Ln9WvgmFNJ1E3QAFAl6KafoACgkQvgmFNJ1E 3QCF+A/+Nj2Qd2ywBzJ0HFZhF6tW/YZK0rw5T+9jne9++LrBE3ZZzIHKu3WU2uuf 3wWR8iXFrpzsvjAvEanAt9MEZIDUf0L4dOLV+0yOMqxw0dWOBrU+p0osKPliuTqV rEHb+lsm2NyrXyxQBJyinsU3woW7hbwZ02Ja4VaQLBiEBfQmfzZcI+LfhDsmozTf v3zo5Lslcd4LCDvkn6AtJ11BWjKAZs2Y8zIa+3tcw723nL9jwr0CtddB/O/zg3do SNuKl3oALfwUJ8SJCcjf9ORvHsVhaMPK390IKAEsAGC1FBfT1uGWvAGgHK2ncHjA CmVSF/rjiO6JAMSXKyZZ/Nh8XowAHnHb/YUJFJUHwu4RHph4SNi/8jPHPgFnLzBt j1btyazGyT2qo+51Fmjc7sVscARbZhnWXuQBpOH5xYMkbrflJpnaCQyX1EkMifA/ IrRMfDYL9udQSwxo5MAitKNliUh+6v3vW8vQmP0FK5LCMs4nU4QLoAbcTRTGCYUe Ih+NhGNBYMhT/W2L6A/mSiAWNggNEm1S7SbnHlAwXat6HmP4fluIMBShpAvKcC3n 7To2dmHUC/UWZyp2IXhb39reHQ3IurGYfVCaBMccj5C1WQhZMyY5jeityrTftDsg /iJcgpp+9Yy9vX9Q/fUJ/eCIspg/UdHb8heboGnRd5dZlNTsAIc= =rFtl -END PGP SIGNATURE- ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/3] avdevice/xv: change codec to wrapped avframe
Signed-off-by: Marton Balint --- libavdevice/xv.c | 15 +-- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/libavdevice/xv.c b/libavdevice/xv.c index c3ed2e48bd..2c5f1a4432 100644 --- a/libavdevice/xv.c +++ b/libavdevice/xv.c @@ -113,8 +113,8 @@ static int xv_write_header(AVFormatContext *s) if ( s->nb_streams > 1 || par->codec_type != AVMEDIA_TYPE_VIDEO -|| par->codec_id != AV_CODEC_ID_RAWVIDEO) { -av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n"); +|| par->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) { +av_log(s, AV_LOG_ERROR, "Only supports one wrapped avframe stream\n"); return AVERROR(EINVAL); } @@ -321,13 +321,8 @@ static int write_picture(AVFormatContext *s, uint8_t *input_data[4], static int xv_write_packet(AVFormatContext *s, AVPacket *pkt) { -AVCodecParameters *par = s->streams[0]->codecpar; -uint8_t *data[4]; -int linesize[4]; - -av_image_fill_arrays(data, linesize, pkt->data, par->format, - par->width, par->height, 1); -return write_picture(s, data, linesize); +AVFrame *frame = (AVFrame *)pkt->data; +return write_picture(s, frame->data, frame->linesize); } static int xv_write_frame(AVFormatContext *s, int stream_index, AVFrame **frame, @@ -375,7 +370,7 @@ AVOutputFormat ff_xv_muxer = { .long_name = NULL_IF_CONFIG_SMALL("XV (XVideo) output device"), .priv_data_size = sizeof(XVContext), .audio_codec= AV_CODEC_ID_NONE, -.video_codec= AV_CODEC_ID_RAWVIDEO, +.video_codec= AV_CODEC_ID_WRAPPED_AVFRAME, .write_header = xv_write_header, .write_packet = xv_write_packet, .write_uncoded_frame = xv_write_frame, -- 2.16.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3] avformat: deprecate muxing uncoded frames
The same goal can be achieved using the WRAPPED_AVFRAME codec with the existing API. Signed-off-by: Marton Balint --- doc/APIchanges | 4 libavdevice/alsa_enc.c | 4 libavdevice/opengl_enc.c | 4 libavdevice/pulse_audio_enc.c| 4 libavdevice/version.h| 4 ++-- libavdevice/xv.c | 4 libavformat/avformat.h | 7 +++ libavformat/internal.h | 2 ++ libavformat/mux.c| 16 libavformat/uncodedframecrcenc.c | 6 ++ libavformat/version.h| 6 +- 11 files changed, 58 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index f1d7eac2ee..57d4fdc609 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,10 @@ libavutil: 2017-10-21 API changes, most recent first: +2020-04-xx - xx - lavf 58.43.100 - avformat.h + Deprecate av_interleaved_write_uncoded_frame(), av_write_uncoded_frame() and + av_write_uncoded_frame_query(). + 2020-03-29 - xx - lavf 58.42.100 - avformat.h av_read_frame() now guarantees to handle uninitialized input packets and to return refcounted packets on success. diff --git a/libavdevice/alsa_enc.c b/libavdevice/alsa_enc.c index 1a6d01e3b1..80c9c509e2 100644 --- a/libavdevice/alsa_enc.c +++ b/libavdevice/alsa_enc.c @@ -116,6 +116,7 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt) return 0; } +#if FF_API_UNCODED_FRAME static int audio_write_frame(AVFormatContext *s1, int stream_index, AVFrame **frame, unsigned flags) { @@ -133,6 +134,7 @@ static int audio_write_frame(AVFormatContext *s1, int stream_index, pkt.duration = (*frame)->pkt_duration; return audio_write_packet(s1, &pkt); } +#endif static void audio_get_output_timestamp(AVFormatContext *s1, int stream, @@ -166,7 +168,9 @@ AVOutputFormat ff_alsa_muxer = { .write_header = audio_write_header, .write_packet = audio_write_packet, .write_trailer = ff_alsa_close, +#if FF_API_UNCODED_FRAME .write_uncoded_frame = audio_write_frame, +#endif .get_device_list = audio_get_device_list, .get_output_timestamp = audio_get_output_timestamp, .flags = AVFMT_NOFILE, diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c index b8bc46ebb5..a829f9ccb2 100644 --- a/libavdevice/opengl_enc.c +++ b/libavdevice/opengl_enc.c @@ -1225,6 +1225,7 @@ static int opengl_write_packet(AVFormatContext *h, AVPacket *pkt) return opengl_draw(h, frame, 0); } +#if FF_API_UNCODED_FRAME static int opengl_write_frame(AVFormatContext *h, int stream_index, AVFrame **frame, unsigned flags) { @@ -1232,6 +1233,7 @@ static int opengl_write_frame(AVFormatContext *h, int stream_index, return 0; return opengl_draw(h, *frame, 0); } +#endif #define OFFSET(x) offsetof(OpenGLContext, x) #define ENC AV_OPT_FLAG_ENCODING_PARAM @@ -1259,7 +1261,9 @@ AVOutputFormat ff_opengl_muxer = { .video_codec= AV_CODEC_ID_WRAPPED_AVFRAME, .write_header = opengl_write_header, .write_packet = opengl_write_packet, +#if FF_API_UNCODED_FRAME .write_uncoded_frame = opengl_write_frame, +#endif .write_trailer = opengl_write_trailer, .control_message = opengl_control_message, .flags = AVFMT_NOFILE | AVFMT_VARIABLE_FPS | AVFMT_NOTIMESTAMPS, diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c index e0a631b227..0b56984ec4 100644 --- a/libavdevice/pulse_audio_enc.c +++ b/libavdevice/pulse_audio_enc.c @@ -670,6 +670,7 @@ static int pulse_write_packet(AVFormatContext *h, AVPacket *pkt) return AVERROR_EXTERNAL; } +#if FF_API_UNCODED_FRAME static int pulse_write_frame(AVFormatContext *h, int stream_index, AVFrame **frame, unsigned flags) { @@ -686,6 +687,7 @@ static int pulse_write_frame(AVFormatContext *h, int stream_index, pkt.duration = (*frame)->pkt_duration; return pulse_write_packet(h, &pkt); } +#endif static void pulse_get_output_timestamp(AVFormatContext *h, int stream, int64_t *dts, int64_t *wall) @@ -786,7 +788,9 @@ AVOutputFormat ff_pulse_muxer = { .video_codec = AV_CODEC_ID_NONE, .write_header = pulse_write_header, .write_packet = pulse_write_packet, +#if FF_API_UNCODED_FRAME .write_uncoded_frame = pulse_write_frame, +#endif .write_trailer= pulse_write_trailer, .get_output_timestamp = pulse_get_output_timestamp, .get_device_list = pulse_get_device_list, diff --git a/libavdevice/version.h b/libavdevice/version.h index 10717564e9..9ee3d3db4a 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -28,8 +28,8 @@ #include "libavutil/version.h" #define LIBAVDEVICE_VERSION_MAJOR 58 -#define LIBAVDEVICE_VERSION_MINOR 9 -#define LIBAVDEVICE_VERSION_MICRO 103 +#define LIBAVDEVIC
[FFmpeg-devel] [PATCH 2/3] avdevice/opengl: change codec to wrapped avframe
Signed-off-by: Marton Balint --- libavdevice/opengl_enc.c | 54 +--- 1 file changed, 10 insertions(+), 44 deletions(-) diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c index ae03caa8c5..b8bc46ebb5 100644 --- a/libavdevice/opengl_enc.c +++ b/libavdevice/opengl_enc.c @@ -277,7 +277,7 @@ static const struct OpenGLFormatDesc { }; static av_cold int opengl_prepare_vertex(AVFormatContext *s); -static int opengl_draw(AVFormatContext *h, void *intput, int repaint, int is_pkt); +static int opengl_draw(AVFormatContext *h, void *intput, int repaint); static av_cold int opengl_init_context(OpenGLContext *opengl); static av_cold void opengl_deinit_context(OpenGLContext *opengl) @@ -320,7 +320,7 @@ static int opengl_resize(AVFormatContext *h, int width, int height) } if ((ret = opengl_prepare_vertex(h)) < 0) goto end; -ret = opengl_draw(h, NULL, 1, 0); +ret = opengl_draw(h, NULL, 1); } end: return ret; @@ -1060,8 +1060,8 @@ static av_cold int opengl_write_header(AVFormatContext *h) if (h->nb_streams != 1 || h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO || -h->streams[0]->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) { -av_log(opengl, AV_LOG_ERROR, "Only a single video stream is supported.\n"); +h->streams[0]->codecpar->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) { +av_log(opengl, AV_LOG_ERROR, "Only a single wrapped avframe stream is supported.\n"); return AVERROR(EINVAL); } st = h->streams[0]; @@ -1124,35 +1124,6 @@ static av_cold int opengl_write_header(AVFormatContext *h) return ret; } -static uint8_t* opengl_get_plane_pointer(OpenGLContext *opengl, AVPacket *pkt, int comp_index, - const AVPixFmtDescriptor *desc) -{ -uint8_t *data = pkt->data; -int wordsize = opengl_type_size(opengl->type); -int width_chroma = AV_CEIL_RSHIFT(opengl->width, desc->log2_chroma_w); -int height_chroma = AV_CEIL_RSHIFT(opengl->height, desc->log2_chroma_h); -int plane = desc->comp[comp_index].plane; - -switch(plane) { -case 0: -break; -case 1: -data += opengl->width * opengl->height * wordsize; -break; -case 2: -data += opengl->width * opengl->height * wordsize; -data += width_chroma * height_chroma * wordsize; -break; -case 3: -data += opengl->width * opengl->height * wordsize; -data += 2 * width_chroma * height_chroma * wordsize; -break; -default: -return NULL; -} -return data; -} - #define LOAD_TEXTURE_DATA(comp_index, sub) \ { \ int width = sub ? AV_CEIL_RSHIFT(opengl->width, desc->log2_chroma_w) : opengl->width; \ @@ -1161,7 +1132,7 @@ static uint8_t* opengl_get_plane_pointer(OpenGLContext *opengl, AVPacket *pkt, i int plane = desc->comp[comp_index].plane; \ \ glBindTexture(GL_TEXTURE_2D, opengl->texture_name[comp_index]); \ -if (!is_pkt) { \ +{ \ GLint length = ((AVFrame *)input)->linesize[plane]; \ int bytes_per_pixel = opengl_type_size(opengl->type); \ if (!(desc->flags & AV_PIX_FMT_FLAG_PLANAR)) \ @@ -1184,14 +1155,10 @@ static uint8_t* opengl_get_plane_pointer(OpenGLContext *opengl, AVPacket *pkt, i data += length; \ } \ } \ -} else { \ -data = opengl_get_plane_pointer(opengl, input, comp_index, desc); \ -glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, \ -opengl->format, opengl->type, data); \ } \ } -static int opengl_draw(AVFormatContext *h, void *input, int repaint, int is_pkt) +static int opengl_draw(AVFormatContext *h, void *input, int repaint) { OpenGLContext *opengl = h->priv_data; enum AVPixelFormat pix_fmt = h->streams[0]->codecpar->format; @@ -1211,8 +
Re: [FFmpeg-devel] ERROR: avisynth/avisynth_c.h not found
On Sun, 5 Apr 2020, Helmut K. C. Tessarek wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 2020-04-05 18:57, Marton Balint wrote: Well, do you have the headers installed? No, because they were always part of ffmpeg. The headers got removed because the ffmpeg source tree is no place for third party library headers. Yes, avisynth was an exception, not anymore. You can't just remove stuff without proper documentation. Actually with the change it got documented that you need to install the headers. https://www.ffmpeg.org/general.html#AviSynth I have been compiing the macOS binaries for 8 years now and this is a joke. Someone breaks ffmpeg from one compile run to the next and you want to put the blame on me? Sometimes you have to follow up on your compile scripts to be able to build the newest ffmpeg. Considering that how easy avisynth upstream made it to install the headers, I am sure this is only a small nuisance. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/4] avfilter/vf_derain.c: put all the calculation in model file.
> -Original Message- > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of > Guo, Yejun > Sent: Monday, March 30, 2020 10:01 AM > To: Steven Liu ; FFmpeg development discussions and > patches > Subject: Re: [FFmpeg-devel] [PATCH 4/4] avfilter/vf_derain.c: put all the > calculation in model file. > > > > > -Original Message- > > From: Steven Liu [mailto:l...@chinaffmpeg.org] > > Sent: Monday, March 23, 2020 1:05 PM > > To: FFmpeg development discussions and patches > > > Cc: Steven Liu ; Guo, Yejun > > Subject: Re: [FFmpeg-devel] [PATCH 4/4] avfilter/vf_derain.c: put all the > > calculation in model file. > > > > > > LGTM > > thanks, and the rest patches of this patch set ask for review, thanks. will push tomorrow if no more comments, thanks. > > > > > Thanks > > > > Steven Liu > > > > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/4] wavpack: fully support stream parameter changes
On 4/5/20 1:32 PM, Anton Khirnov wrote: > Fix invalid memory access on DSD streams with changing channel count. > --- > libavcodec/wavpack.c | 122 +++ > 1 file changed, 90 insertions(+), 32 deletions(-) > > diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c > index b27262b94e..9cc4104dd0 100644 > --- a/libavcodec/wavpack.c > +++ b/libavcodec/wavpack.c > @@ -20,6 +20,7 @@ > * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > */ > > +#include "libavutil/buffer.h" > #include "libavutil/channel_layout.h" > > #define BITSTREAM_READER_LE > @@ -109,7 +110,10 @@ typedef struct WavpackContext { > AVFrame *frame; > ThreadFrame curr_frame, prev_frame; > Modulation modulation; > + > +AVBufferRef *dsd_ref; > DSDContext *dsdctx; > +int dsd_channels; > } WavpackContext; > > #define LEVEL_DECAY(a) (((a) + 0x80) >> 8) > @@ -978,6 +982,32 @@ static av_cold int wv_alloc_frame_context(WavpackContext > *c) > return 0; > } > > +static int wv_dsd_reset(WavpackContext *s, int channels) > +{ > +int i; > + > +s->dsdctx = NULL; > +s->dsd_channels = 0; > +av_buffer_unref(&s->dsd_ref); > + > +if (!channels) > +return 0; > + > +if (channels > INT_MAX / sizeof(*s->dsdctx)) > +return AVERROR(EINVAL); > + > +s->dsd_ref = av_buffer_allocz(channels * sizeof(*s->dsdctx)); > +if (!s->dsd_ref) > +return AVERROR(ENOMEM); > +s->dsdctx = (DSDContext*)s->dsd_ref->data; > +s->dsd_channels = channels; > + > +for (i = 0; i < channels; i++) > +memset(s->dsdctx[i].buf, 0x69, sizeof(s->dsdctx[i].buf)); > + > +return 0; > +} > + > #if HAVE_THREADS > static int init_thread_copy(AVCodecContext *avctx) > { > @@ -1008,6 +1038,17 @@ static int update_thread_context(AVCodecContext *dst, > const AVCodecContext *src) > return ret; > } > > +av_buffer_unref(&fdst->dsd_ref); > +fdst->dsdctx = NULL; > +fdst->dsd_channels = 0; > +if (fsrc->dsd_ref) { > +fdst->dsd_ref = av_buffer_ref(fsrc->dsd_ref); > +if (!fdst->dsd_ref) > +return AVERROR(ENOMEM); > +fdst->dsdctx = (DSDContext*)fdst->dsd_ref->data; > +fdst->dsd_channels = fsrc->dsd_channels; > +} > + > return 0; > } > #endif > @@ -1025,15 +1066,9 @@ static av_cold int wavpack_decode_init(AVCodecContext > *avctx) > s->curr_frame.f = av_frame_alloc(); > s->prev_frame.f = av_frame_alloc(); > > -// the DSD to PCM context is shared (and used serially) between all > decoding threads > -s->dsdctx = av_calloc(avctx->channels, sizeof(DSDContext)); > - > -if (!s->curr_frame.f || !s->prev_frame.f || !s->dsdctx) > +if (!s->curr_frame.f || !s->prev_frame.f) > return AVERROR(ENOMEM); > > -for (int i = 0; i < avctx->channels; i++) > -memset(s->dsdctx[i].buf, 0x69, sizeof(s->dsdctx[i].buf)); > - > ff_init_dsd_data(); > > return 0; > @@ -1053,8 +1088,7 @@ static av_cold int wavpack_decode_end(AVCodecContext > *avctx) > ff_thread_release_buffer(avctx, &s->prev_frame); > av_frame_free(&s->prev_frame.f); > > -if (!avctx->internal->is_copy) > -av_freep(&s->dsdctx); > +av_buffer_unref(&s->dsd_ref); > > return 0; > } > @@ -1065,6 +1099,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, > int block_no, > WavpackContext *wc = avctx->priv_data; > WavpackFrameContext *s; > GetByteContext gb; > +enum AVSampleFormat sample_fmt; > void *samples_l = NULL, *samples_r = NULL; > int ret; > int got_terms = 0, got_weights = 0, got_samples = 0, > @@ -1102,7 +1137,15 @@ static int wavpack_decode_block(AVCodecContext *avctx, > int block_no, > return AVERROR_INVALIDDATA; > } > s->frame_flags = bytestream2_get_le32(&gb); > -bpp= av_get_bytes_per_sample(avctx->sample_fmt); > + > +if (s->frame_flags & (WV_FLOAT_DATA | WV_DSD_DATA)) > +sample_fmt = AV_SAMPLE_FMT_FLTP; > +else if ((s->frame_flags & 0x03) <= 1) > +sample_fmt = AV_SAMPLE_FMT_S16P; > +else > +sample_fmt = AV_SAMPLE_FMT_S32P; > + > +bpp= av_get_bytes_per_sample(sample_fmt); > orig_bpp = ((s->frame_flags & 0x03) + 1) << 3; > multiblock = (s->frame_flags & WV_SINGLE_BLOCK) != WV_SINGLE_BLOCK; > > @@ -1436,11 +1479,11 @@ static int wavpack_decode_block(AVCodecContext > *avctx, int block_no, > av_log(avctx, AV_LOG_ERROR, "Hybrid config not found\n"); > return AVERROR_INVALIDDATA; > } > -if (!got_float && avctx->sample_fmt == AV_SAMPLE_FMT_FLTP) { > +if (!got_float && sample_fmt == AV_SAMPLE_FMT_FLTP) { > av_log(avctx, AV_LOG_ERROR, "Float information not found\n"); > return AVERROR_INVALIDDATA; > } > -if (s->got_extra_bits && avctx->sample_fmt !=
Re: [FFmpeg-devel] [PATCH 12/20] avformat/matroskaenc: Improve Cues in case of no video
On Sun, 5 Apr 2020 at 16:01, Andreas Rheinhardt wrote: > > 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 > --- Fixed at last, danke schön! This was a very annoying bug. One thing I noticed is, however, that the spec recommends "CuePoint Elements SHOULD reference audio keyframes at most once every 500 milliseconds" [1], but this is not checked currently. [1]: https://cellar-wg.github.io/matroska-specification/cues.html ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v13] libavcodec/jpeg2000dec.c: Add support for PPT marker
On Mon, Apr 6, 2020 at 1:16 AM Michael Niedermayer wrote: > > On Sun, Apr 05, 2020 at 04:13:28PM +0530, gautamr...@gmail.com wrote: > > From: Gautam Ramakrishnan > > > > This patch adds functional changes to support the > > PPT marker. This patch fixes bug ticket #4610. > > --- > > libavcodec/jpeg2000dec.c | 88 +++- > > 1 file changed, 77 insertions(+), 11 deletions(-) > > > > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c > > index 732d88e6fc..2af3c61c37 100644 > > --- a/libavcodec/jpeg2000dec.c > > +++ b/libavcodec/jpeg2000dec.c > > @@ -83,6 +83,10 @@ typedef struct Jpeg2000Tile { > > Jpeg2000QuantStyle qntsty[4]; > > Jpeg2000POC poc; > > Jpeg2000TileParttile_part[32]; > > +uint8_t has_ppt;// whether this tile has a > > ppt marker > > +uint8_t *packed_headers;// contains packed > > headers. Used only along with PPT marker > > +int packed_headers_size;// size in bytes of the > > packed headers > > +GetByteContext packed_headers_stream; // byte context > > corresponding to packed headers > > uint16_t tp_idx;// Tile-part index > > int coord[2][2];// border coordinates {{x0, x1}, > > {y0, y1}} > > } Jpeg2000Tile; > > @@ -855,6 +859,37 @@ static int get_plt(Jpeg2000DecoderContext *s, int n) > > return 0; > > } > > > > +static int get_ppt(Jpeg2000DecoderContext *s, int n) > > +{ > > +Jpeg2000Tile *tile; > > + > > +if (s->curtileno < 0) > > +return AVERROR_INVALIDDATA; > > + > > +tile = &s->tile[s->curtileno]; > > +if (tile->tp_idx != 0) { > > +av_log(s->avctx, AV_LOG_ERROR, > > + "PPT marker can occur only on first tile part of a > > tile.\n"); > > +return AVERROR_INVALIDDATA; > > +} > > + > > +tile->has_ppt = 1; // this tile has a ppt marker > > +bytestream2_get_byte(&s->g); // Zppt is skipped and not used > > > > +if (!tile->packed_headers) > > +tile->packed_headers = av_malloc(n - 3); > > +else > > +tile->packed_headers = av_realloc(tile->packed_headers, > > + tile->packed_headers_size + n - > > 3); > > why is the special case with av_malloc() needed ? > The if else is to check whether this is the first time this tile is being allocated its packed headers. If packed headers does not exist exist, create it. The else condition is just to add a new packed header to it. > > > +if (!tile->packed_headers) > > +return AVERROR(ENOMEM); > > this is looks like a memleak as the original array has been overwritten but > not deallocated This was a check for the malloc failure > > thx > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > In fact, the RIAA has been known to suggest that students drop out > of college or go to community college in order to be able to afford > settlements. -- The RIAA > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- - Gautam | ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 03/14] pthread_frame: merge the functionality for normal decoder init and init_thread_copy
On 4/2/20 11:32 PM, Anton Khirnov wrote: > Quoting David Bryant (2020-04-03 07:14:21) >> On 4/2/20 2:13 AM, Anton Khirnov wrote: >>> Quoting David Bryant (2020-04-01 23:35:13) On 3/31/20 2:47 AM, Anton Khirnov wrote: >>> Looking at wavpack, the code looks suspicious to me. You allocate one >>> dsdctx per channel at init, but AFAIU the number of channels can change >>> at each frame. >>> >> Multichannel WavPack consists of sequences of stereo or mono WavPack >> blocks that include flags indicating whether they are the >> beginning or end of a "frame" or "packet". This allows the number of >> channels available to be essentially unlimited, however the >> total number of channels in a stream may not change. When decoding, if a >> sequence of blocks generates more or less than the >> correct number of channels, this is flagged as an error and overrun is >> prevented (see libavcodec/wavpack.c, line 1499 and line >> 1621). > If my reading of the code is correct, line 1499 only checks for overflow > of the channel count read for the current sequence. That channel count > is exported to AVCodeContext in the block starting on line 1464 and > I don't see any checks for whether it is equal to the initial one. > Full disclosure: I did not write the WavPack decoder. I understand _how_ it works, but I don't necessarily understand _why_ it was written the way it was due to gaps in my knowledge of the FFmpeg internals, and there are certainly things in there that don't look quite right to me. That said, I have tested it thoroughly and it handles everything I throw at it, and I have extended it to handle the DSD mode without anything unexpected happening. And of course it seems to handle extensive fuzzing, and the recent error was related to my DSD change, suggesting that the core it pretty robust. My inclination has been to not "fix" anything that wasn't broken. Yes, that channel count stuff is a little difficult to follow. I could experiment with streams that abruptly change channel configuration, but again I'm hesitant to change code that's worked so well so long. >>> I can easily get the decoder to crash even in single-threaded mode. Just >>> make the demuxer always say the stream is mono, then try decoding your >>> DSD sample. >> Okay, I reproduced that. However, I'm not sure it's really that serious >> because the demuxer and the decoder use basically the >> same logic to determine that number of channels, so it would be tricky to >> craft a file that caused the demuxer to calculate 1 >> channel and the decoder to reach a different result, which is probably why >> the fuzzers have not been able to do so. > I disagree - this is just as serious as any other crash on invalid data. > > The decoder must not ever crash for arbitrary input data. It cannot > assume that it's always going to be provided valid input or that it's > always used with some specific demuxer. The caller might not be using > libavformat at all, libavcodec should work with any source of data. > > Besides, I can reproduce the crash with no code modification necessary > by muxing your sample into Matroska and then hex-editing the file to say > it has only one channel. Yes, I have reproduced this crash even without Matroska. I was working on a solution but you beat me to it. Thanks! > >> That said, it would not be hard to have the decoder save away the initial >> channel count from avctx, never overwrite it, and >> verify that all superblocks match that count. I don't know off hand whether >> that would break anything though. Is it guaranteed >> that avctx->channels is correct during the call to decode_init(), even if >> it's being demuxed from Matroska, for example? If so, >> why is the WavPack decoder _ever_ writing to the avctx channel count? > The question is what you define as correct. The initial value provided > by the caller is supposed to be the caller's best guess at the correct > (initial) value. It may come from a demuxer, or from the Delphic Oracle. > The decoder doesn't know. > > For some codecs, the relevant parameters are not specified in the > bistream, so they have no choice but to use the caller's value. That is > not the case for WavPack, since the channel count IS written in the > bistream. So I think it's best to ignore the caller-provided value and > always use the one we get from the data. Agreed. > >>> Also, I looked at the specification PDF you linked in the previous email >>> and I see nothing in it that explicitly forbids the channel count from >>> changing from one "superblock" to the next. It seems to me like you >>> could just concatenate wavpack files with different channel counts and >>> get a valid wavpack file. >>> >> You're right, I could not find that being explicitly forbidden. >> Nevertheless, it _is_ forbidden for any stream parame
[FFmpeg-devel] [PATCH 2/2] avcodec/v4l2_context: Log warning when all capture buffers are in userspace
From: Andriy Gelman v4l2_m2m uses device memory mapped buffers to store dequeued frames/packets (reference counted by AVBufferRef). When the reference count drops to zero, the buffer ownership is returned back to the device, so that they can re-filled with frames/packets. There are some cases when all the buffers are in userspace (i.e. due to internal buffering in ffmpeg). On the s5p-mfc this causes an infinite wait when polling to dequeue the buffers, which can be prevented by increasing the total number of capture buffers. This commit adds a warning when this occurs. Signed-off-by: Andriy Gelman --- libavcodec/v4l2_context.c | 12 1 file changed, 12 insertions(+) diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index 31af10d28e..5145772c45 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -285,6 +285,18 @@ static V4L2Buffer* v4l2_dequeue_v4l2buf(V4L2Context *ctx, int timeout) }; int i, ret; +if (!V4L2_TYPE_IS_OUTPUT(ctx->type) && ctx->buffers) { +for (i = 0; i < ctx->num_buffers; i++) { +if (ctx->buffers[i].status == V4L2BUF_IN_DRIVER) +break; +} +if (i == ctx->num_buffers) +av_log(logger(ctx), AV_LOG_WARNING, "All capture buffers returned to " +"userspace. Increase num_capture_buffers " +"to prevent device deadlock or dropped " +"packets/frames.\n"); +} + /* if we are draining and there are no more capture buffers queued in the driver we are done */ if (!V4L2_TYPE_IS_OUTPUT(ctx->type) && ctx_to_m2mctx(ctx)->draining) { for (i = 0; i < ctx->num_buffers; i++) { -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avcodec/v4l2_context: Use av_freep
From: Andriy Gelman Signed-off-by: Andriy Gelman --- libavcodec/v4l2_context.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index 8110bbb555..31af10d28e 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -685,8 +685,7 @@ void ff_v4l2_context_release(V4L2Context* ctx) if (ret) av_log(logger(ctx), AV_LOG_WARNING, "V4L2 failed to unmap the %s buffers\n", ctx->name); -av_free(ctx->buffers); -ctx->buffers = NULL; +av_freep(&ctx->buffers); } int ff_v4l2_context_init(V4L2Context* ctx) @@ -743,8 +742,7 @@ int ff_v4l2_context_init(V4L2Context* ctx) error: v4l2_release_buffers(ctx); -av_free(ctx->buffers); -ctx->buffers = NULL; +av_freep(&ctx->buffers); return ret; } -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/4] lavf/wvdec: remove artificial restrictions on stream parameter changes
On 4/5/20 1:32 PM, Anton Khirnov wrote: > They are not forbidden by the specification. > --- > libavformat/wvdec.c | 18 -- > 1 file changed, 18 deletions(-) > > diff --git a/libavformat/wvdec.c b/libavformat/wvdec.c > index b9fc6a59f9..4159bf1253 100644 > --- a/libavformat/wvdec.c > +++ b/libavformat/wvdec.c > @@ -208,24 +208,6 @@ static int wv_read_block_header(AVFormatContext *ctx, > AVIOContext *pb) > if (!wc->rate) > wc->rate = rate * rate_x; > > -if (flags && bpp != wc->bpp) { > -av_log(ctx, AV_LOG_ERROR, > - "Bits per sample differ, this block: %i, header block: %i\n", > - bpp, wc->bpp); > -return AVERROR_INVALIDDATA; > -} > -if (flags && !wc->multichannel && chan != wc->chan) { > -av_log(ctx, AV_LOG_ERROR, > - "Channels differ, this block: %i, header block: %i\n", > - chan, wc->chan); > -return AVERROR_INVALIDDATA; > -} > -if (flags && rate != -1 && !(flags & WV_DSD) && rate * rate_x != > wc->rate) { > -av_log(ctx, AV_LOG_ERROR, > - "Sampling rate differ, this block: %i, header block: %i\n", > - rate * rate_x, wc->rate); > -return AVERROR_INVALIDDATA; > -} > return 0; > } > The specification does not explicitly mention that the data format, the channel count (and layout), and the sample rate cannot change inside of a WavPack file, but they can't. The first block of a WavPack file that contains audio determines the format of the entire file, and the documentation will be updated shortly to reflect that. And obviously Konstantin Shishkov was aware of this, even referring to the first block containing audio as the "header block". I have no issue with the decoder handling these changes as it might be receiving a WavPack stream from a container that allows this, but the native WavPack container doesn't. And I actually don't have any problem with this specific change going in because it doesn't actually break anything. However, it should not be possible to create a WavPack file with format changes such as these. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/aacdec: fix compilation under soft float MIPS
Place HAVE_MIPSFPU further up so that functions that use floating point ASM are defined away. Otherwise compilation failures result when soft float in enabled on the toolchain. Signed-off-by: Rosen Penev --- libavcodec/mips/aacdec_mips.c | 4 ++-- libavcodec/mips/aacpsdsp_mips.c | 4 ++-- libavcodec/mips/aacsbr_mips.c | 4 ++-- libavcodec/mips/sbrdsp_mips.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/mips/aacdec_mips.c b/libavcodec/mips/aacdec_mips.c index 01a2b3087b..8e30652935 100644 --- a/libavcodec/mips/aacdec_mips.c +++ b/libavcodec/mips/aacdec_mips.c @@ -59,6 +59,7 @@ #include "libavutil/mips/asmdefs.h" #if HAVE_INLINE_ASM +#if HAVE_MIPSFPU static av_always_inline void float_copy(float *dst, const float *src, int count) { // Copy 'count' floats from src to dst @@ -282,7 +283,6 @@ static void apply_ltp_mips(AACContext *ac, SingleChannelElement *sce) } } -#if HAVE_MIPSFPU static av_always_inline void fmul_and_reverse(float *dst, const float *src0, const float *src1, int count) { /* Multiply 'count' floats in src0 by src1 and store the results in dst in reverse */ @@ -433,9 +433,9 @@ static void update_ltp_mips(AACContext *ac, SingleChannelElement *sce) void ff_aacdec_init_mips(AACContext *c) { #if HAVE_INLINE_ASM +#if HAVE_MIPSFPU c->imdct_and_windowing = imdct_and_windowing_mips; c->apply_ltp = apply_ltp_mips; -#if HAVE_MIPSFPU c->update_ltp = update_ltp_mips; #endif /* HAVE_MIPSFPU */ #endif /* HAVE_INLINE_ASM */ diff --git a/libavcodec/mips/aacpsdsp_mips.c b/libavcodec/mips/aacpsdsp_mips.c index 83fdc2f9db..ef47e31a9e 100644 --- a/libavcodec/mips/aacpsdsp_mips.c +++ b/libavcodec/mips/aacpsdsp_mips.c @@ -57,6 +57,7 @@ #include "libavutil/mips/asmdefs.h" #if HAVE_INLINE_ASM +#if HAVE_MIPSFPU static void ps_hybrid_analysis_ileave_mips(float (*out)[32][2], float L[2][38][64], int i, int len) { @@ -187,7 +188,6 @@ static void ps_hybrid_synthesis_deint_mips(float out[2][38][64], } } -#if HAVE_MIPSFPU #if !HAVE_MIPS32R6 && !HAVE_MIPS64R6 static void ps_add_squares_mips(float *dst, const float (*src)[2], int n) { @@ -450,9 +450,9 @@ static void ps_stereo_interpolate_mips(float (*l)[2], float (*r)[2], void ff_psdsp_init_mips(PSDSPContext *s) { #if HAVE_INLINE_ASM +#if HAVE_MIPSFPU s->hybrid_analysis_ileave = ps_hybrid_analysis_ileave_mips; s->hybrid_synthesis_deint = ps_hybrid_synthesis_deint_mips; -#if HAVE_MIPSFPU #if !HAVE_MIPS32R6 && !HAVE_MIPS64R6 s->add_squares= ps_add_squares_mips; s->mul_pair_single= ps_mul_pair_single_mips; diff --git a/libavcodec/mips/aacsbr_mips.c b/libavcodec/mips/aacsbr_mips.c index 56aa4e8682..2e0cd723d7 100644 --- a/libavcodec/mips/aacsbr_mips.c +++ b/libavcodec/mips/aacsbr_mips.c @@ -58,6 +58,7 @@ #define ENVELOPE_ADJUSTMENT_OFFSET 2 #if HAVE_INLINE_ASM +#if HAVE_MIPSFPU static int sbr_lf_gen_mips(AACContext *ac, SpectralBandReplication *sbr, float X_low[32][40][2], const float W[2][32][32][2], int buf_idx) @@ -310,7 +311,6 @@ static int sbr_x_gen_mips(SpectralBandReplication *sbr, float X[2][38][64], return 0; } -#if HAVE_MIPSFPU #if !HAVE_MIPS32R6 && !HAVE_MIPS64R6 static void sbr_hf_assemble_mips(float Y1[38][64][2], const float X_high[64][40][2], @@ -611,9 +611,9 @@ static void sbr_hf_inverse_filter_mips(SBRDSPContext *dsp, void ff_aacsbr_func_ptr_init_mips(AACSBRContext *c) { #if HAVE_INLINE_ASM +#if HAVE_MIPSFPU c->sbr_lf_gen= sbr_lf_gen_mips; c->sbr_x_gen = sbr_x_gen_mips; -#if HAVE_MIPSFPU #if !HAVE_MIPS32R6 && !HAVE_MIPS64R6 c->sbr_hf_inverse_filter = sbr_hf_inverse_filter_mips; c->sbr_hf_assemble = sbr_hf_assemble_mips; diff --git a/libavcodec/mips/sbrdsp_mips.c b/libavcodec/mips/sbrdsp_mips.c index 1b0a10608d..83039fd802 100644 --- a/libavcodec/mips/sbrdsp_mips.c +++ b/libavcodec/mips/sbrdsp_mips.c @@ -59,6 +59,7 @@ #include "libavutil/mips/asmdefs.h" #if HAVE_INLINE_ASM +#if HAVE_MIPSFPU static void sbr_qmf_pre_shuffle_mips(float *z) { int Temp1, Temp2, Temp3, Temp4, Temp5, Temp6; @@ -165,7 +166,6 @@ static void sbr_qmf_post_shuffle_mips(float W[32][2], const float *z) ); } -#if HAVE_MIPSFPU #if !HAVE_MIPS32R6 && !HAVE_MIPS64R6 static void sbr_sum64x5_mips(float *z) { @@ -890,9 +890,9 @@ static void sbr_hf_apply_noise_3_mips(float (*Y)[2], const float *s_m, void ff_sbrdsp_init_mips(SBRDSPContext *s) { #if HAVE_INLINE_ASM +#if HAVE_MIPSFPU s->qmf_pre_shuffle = sbr_qmf_pre_shuffle_mips; s->qmf_post_shuffle = sbr_qmf_post_shuffle_mips; -#if HAVE_MIPSFPU #if !HAVE_MIPS32R6 && !HAVE_MIPS64R6 s->sum64x5 = sbr_sum64x5_mips; s->sum_square = sbr_sum_square_mips; -- 2.25.1 ___ ffmpeg-devel mail