[FFmpeg-devel] [PATCH] avfilter/vf_delogo: remove duplicated code
From: Zhao Zhili 1. Remove the modification of x, y, w and h parameters since they are reset by filter_frame. 2. config_input leads to error out when logo area is outside of the frame, while filter_frame fix the parameters automatically. Make config_input don't return error to keep the logic consistent. --- libavfilter/vf_delogo.c | 39 +++ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index 6069c30163..39f06512fa 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -271,11 +271,6 @@ static av_cold int init(AVFilterContext *ctx) av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d, w:%d h:%d band:%d show:%d\n", s->x, s->y, s->w, s->h, s->band, s->show); -s->w += s->band*2; -s->h += s->band*2; -s->x -= s->band; -s->y -= s->band; - return 0; } @@ -284,10 +279,21 @@ static int config_input(AVFilterLink *inlink) DelogoContext *s = inlink->dst->priv; /* Check whether the logo area fits in the frame */ -if (s->x + (s->band - 1) < 0 || s->x + s->w - (s->band*2 - 2) > inlink->w || -s->y + (s->band - 1) < 0 || s->y + s->h - (s->band*2 - 2) > inlink->h) { -av_log(s, AV_LOG_ERROR, "Logo area is outside of the frame.\n"); -return AVERROR(EINVAL); +if (s->x + (s->band - 1) <= 0 || s->x + s->w - (s->band*2 - 2) > inlink->w || +s->y + (s->band - 1) <= 0 || s->y + s->h - (s->band*2 - 2) > inlink->h) { +av_log(s, AV_LOG_WARNING, "Logo area is outside of the frame," + " logo(x:%d y:%d w:%d h:%d), frame(%dx%d)," + " auto set the area inside of the frame." + " Note: x and y must be 1 at least.\n", + s->x, s->y, s->w, s->h, inlink->w, inlink->h); +if (s->x + (s->band - 1) <= 0) +s->x = 1 + s->band; +if (s->y + (s->band - 1) <= 0) +s->y = 1 + s->band; +if (s->x + s->w - (s->band*2 - 2) > inlink->w) +s->w = inlink->w - s->x - (s->band*2 - 2); +if (s->y + s->h - (s->band*2 - 2) > inlink->h) +s->h = inlink->h - s->y - (s->band*2 - 2); } return 0; @@ -313,21 +319,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) s->w = av_expr_eval(s->w_pexpr, s->var_values, s); s->h = av_expr_eval(s->h_pexpr, s->var_values, s); -if (s->x + (s->band - 1) <= 0 || s->x + s->w - (s->band*2 - 2) > inlink->w || -s->y + (s->band - 1) <= 0 || s->y + s->h - (s->band*2 - 2) > inlink->h) { -av_log(s, AV_LOG_WARNING, "Logo area is outside of the frame," - " auto set the area inside of the frame\n"); -} - -if (s->x + (s->band - 1) <= 0) -s->x = 1 + s->band; -if (s->y + (s->band - 1) <= 0) -s->y = 1 + s->band; -if (s->x + s->w - (s->band*2 - 2) > inlink->w) -s->w = inlink->w - s->x - (s->band*2 - 2); -if (s->y + s->h - (s->band*2 - 2) > inlink->h) -s->h = inlink->h - s->y - (s->band*2 - 2); - ret = config_input(inlink); if (ret < 0) { av_frame_free(); -- 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] AVFrame.color_trc wrong since f2ad6238e4c0e99e2fc131ee14c586e87b045680
On Tue, Sep 15, 2020, 21:25 James Almer wrote: > On 9/15/2020 10:57 PM, Pavel Koshevoy wrote: > > set_side_data used to do out->color_trc = > > s->sei.alternative_transfer.preferred_transfer_characteristics; > > > > In commit f2ad6238e4c0e99e2fc131ee14c586e87b045680 this was removed. > > Now ffprobe of an HLG stream reports wrong transfer characteristics for > > each frame: > > > > ``` > > $ ffprobe -show_frames 20190914-1435_iowa_vs_iowa-state_fox-cfb-dertp.ts > | > > grep color_transfer= | head > > > > ffprobe version N-99190-g7cc8a2b Copyright (c) 2007-2020 the FFmpeg > > developers > > built with gcc 8 (Ubuntu 8.4.0-1ubuntu1~16.04.1) > > configuration: --prefix=/home/xyz/x86_64 --enable-rpath --enable-shared > > --disable-static --disable-stripping --enable-libfreetype > > --enable-libfontconfig --enable-libfribidi --enable-libass > > --enable-libmodplug --enable-openssl --enable-ffnvcodec --enable-cuda > > --extra-ldflags='-L/home/xyz/x86_64/lib -L/usr/local/cuda/lib64' > > --extra-cflags='-I/home/xyz/x86_64/include -I/usr/local/cuda/include' > > libavutil 56. 59.100 / 56. 59.100 > > libavcodec 58.106.100 / 58.106.100 > > libavformat58. 56.100 / 58. 56.100 > > libavdevice58. 11.102 / 58. 11.102 > > libavfilter 7. 87.100 / 7. 87.100 > > libswscale 5. 8.100 / 5. 8.100 > > libswresample 3. 8.100 / 3. 8.100 > > [hevc @ 0xb78b00] PPS id out of range: 0 > > Last message repeated 1 times > > [hevc @ 0xb78b00] Error parsing NAL unit #2. > > [hevc @ 0xb78b00] PPS id out of range: 0 > > Last message repeated 1 times > > [hevc @ 0xb78b00] Error parsing NAL unit #2. > > [hevc @ 0xb78b00] PPS id out of range: 0 > > Last message repeated 1 times > > [hevc @ 0xb78b00] Error parsing NAL unit #2. > > [hevc @ 0xb78b00] PPS id out of range: 0 > > Last message repeated 1 times > > [hevc @ 0xb78b00] Error parsing NAL unit #2. > > [hevc @ 0xb78b00] PPS id out of range: 0 > > Last message repeated 1 times > > [hevc @ 0xb78b00] Error parsing NAL unit #2. > > [hevc @ 0xb78b00] PPS id out of range: 0 > > Last message repeated 1 times > > [hevc @ 0xb78b00] Error parsing NAL unit #2. > > [hevc @ 0xb78b00] PPS id out of range: 0 > > Last message repeated 1 times > > [hevc @ 0xb78b00] Error parsing NAL unit #2. > > [mpegts @ 0xb72c40] PES packet size mismatch > > > > > > > > > > > > [mpegts @ 0xb72c40] Packet corrupt (stream = 2, dts = 3870328878). > > > > > > > > > > > > [mpegts @ 0xb72c40] PES packet size mismatch > > > > > > > > > > > > [mpegts @ 0xb72c40] Packet corrupt (stream = 1, dts = 3870334067). > > [mpegts @ 0xb72c40] PES packet size mismatch > > [mpegts @ 0xb72c40] Packet corrupt (stream = 2, dts = 3870328878). > > [mpegts @ 0xb72c40] stream 0 : no PTS found at end of file, duration not > set > > Input #0, mpegts, from > '20190914-1435_iowa_vs_iowa-state_fox-cfb-dertp.ts': > > Duration: 00:05:00.05, start: 42703.686200, bitrate: 70429 kb/s > > Program 1 > > Stream #0:0[0x3ff]: Video: hevc (Main 10) ([36][0][0][0] / 0x0024), > > yuv420p10le(tv, bt2020nc/bt2020/arib-std-b67), 3840x2160 [SAR 1:1 DAR > > 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc > > Stream #0:1[0x400](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), > > 48000 Hz, stereo, fltp, 126 kb/s > > Stream #0:2[0x401](eng): Audio: eac3 ([129][0][0][0] / 0x0081), 48000 > > Hz, 5.1(side), fltp, 384 kb/s > > [hevc @ 0xba2d80] Could not find ref with POC -40 > > [hevc @ 0xba2d80] Could not find ref with POC -48 > > [hevc @ 0xba2d80] Could not find ref with POC -32 > > [hevc @ 0xba2d80] First slice in a frame missing. > > Last message repeated 34 times > > [aac @ 0xba1200] channel element 2.4 is not allocated > > color_transfer=bt2020-10 > > color_transfer=bt2020-10 > > color_transfer=bt2020-10 > > color_transfer=bt2020-10 > > color_transfer=bt2020-10 > > color_transfer=bt2020-10 > > color_transfer=bt2020-10 > > color_transfer=bt2020-10 > > color_transfer=bt2020-10 > > color_transfer=bt2020-10 > > ^C > > > > ``` > > > > that should be color_transfer=arib-std-b67 > > > > Would anyone object if I restored previous behavior? I'd prefer avoid > > reimplementing SEI parsing outside of libav just to get the correct > > per-frame color_trc... > > Yes, the point of the change was to set color_trc before the frame > buffers were allocated, so a full revert would break that. > I don't think I understand what color_trc has to do with buffers... it's not a buffer property (it does not affect the size or layout of the buffer). I wasn't planning on a full revert, just want to restore what was removed from set_side_data. > Can you share the sample that reproduces this? > I may be able to share a short chunk. At 70Mbps even a short chunk would be large. I'd like to confirm tomorrow whether I have permission to share a short file publicly or privately. Thank you, Pavel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org
Re: [FFmpeg-devel] AVFrame.color_trc wrong since f2ad6238e4c0e99e2fc131ee14c586e87b045680
On 9/15/2020 10:57 PM, Pavel Koshevoy wrote: > set_side_data used to do out->color_trc = > s->sei.alternative_transfer.preferred_transfer_characteristics; > > In commit f2ad6238e4c0e99e2fc131ee14c586e87b045680 this was removed. > Now ffprobe of an HLG stream reports wrong transfer characteristics for > each frame: > > ``` > $ ffprobe -show_frames 20190914-1435_iowa_vs_iowa-state_fox-cfb-dertp.ts | > grep color_transfer= | head > > ffprobe version N-99190-g7cc8a2b Copyright (c) 2007-2020 the FFmpeg > developers > built with gcc 8 (Ubuntu 8.4.0-1ubuntu1~16.04.1) > configuration: --prefix=/home/xyz/x86_64 --enable-rpath --enable-shared > --disable-static --disable-stripping --enable-libfreetype > --enable-libfontconfig --enable-libfribidi --enable-libass > --enable-libmodplug --enable-openssl --enable-ffnvcodec --enable-cuda > --extra-ldflags='-L/home/xyz/x86_64/lib -L/usr/local/cuda/lib64' > --extra-cflags='-I/home/xyz/x86_64/include -I/usr/local/cuda/include' > libavutil 56. 59.100 / 56. 59.100 > libavcodec 58.106.100 / 58.106.100 > libavformat58. 56.100 / 58. 56.100 > libavdevice58. 11.102 / 58. 11.102 > libavfilter 7. 87.100 / 7. 87.100 > libswscale 5. 8.100 / 5. 8.100 > libswresample 3. 8.100 / 3. 8.100 > [hevc @ 0xb78b00] PPS id out of range: 0 > Last message repeated 1 times > [hevc @ 0xb78b00] Error parsing NAL unit #2. > [hevc @ 0xb78b00] PPS id out of range: 0 > Last message repeated 1 times > [hevc @ 0xb78b00] Error parsing NAL unit #2. > [hevc @ 0xb78b00] PPS id out of range: 0 > Last message repeated 1 times > [hevc @ 0xb78b00] Error parsing NAL unit #2. > [hevc @ 0xb78b00] PPS id out of range: 0 > Last message repeated 1 times > [hevc @ 0xb78b00] Error parsing NAL unit #2. > [hevc @ 0xb78b00] PPS id out of range: 0 > Last message repeated 1 times > [hevc @ 0xb78b00] Error parsing NAL unit #2. > [hevc @ 0xb78b00] PPS id out of range: 0 > Last message repeated 1 times > [hevc @ 0xb78b00] Error parsing NAL unit #2. > [hevc @ 0xb78b00] PPS id out of range: 0 > Last message repeated 1 times > [hevc @ 0xb78b00] Error parsing NAL unit #2. > [mpegts @ 0xb72c40] PES packet size mismatch > > > > > > [mpegts @ 0xb72c40] Packet corrupt (stream = 2, dts = 3870328878). > > > > > > [mpegts @ 0xb72c40] PES packet size mismatch > > > > > > [mpegts @ 0xb72c40] Packet corrupt (stream = 1, dts = 3870334067). > [mpegts @ 0xb72c40] PES packet size mismatch > [mpegts @ 0xb72c40] Packet corrupt (stream = 2, dts = 3870328878). > [mpegts @ 0xb72c40] stream 0 : no PTS found at end of file, duration not set > Input #0, mpegts, from '20190914-1435_iowa_vs_iowa-state_fox-cfb-dertp.ts': > Duration: 00:05:00.05, start: 42703.686200, bitrate: 70429 kb/s > Program 1 > Stream #0:0[0x3ff]: Video: hevc (Main 10) ([36][0][0][0] / 0x0024), > yuv420p10le(tv, bt2020nc/bt2020/arib-std-b67), 3840x2160 [SAR 1:1 DAR > 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc > Stream #0:1[0x400](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), > 48000 Hz, stereo, fltp, 126 kb/s > Stream #0:2[0x401](eng): Audio: eac3 ([129][0][0][0] / 0x0081), 48000 > Hz, 5.1(side), fltp, 384 kb/s > [hevc @ 0xba2d80] Could not find ref with POC -40 > [hevc @ 0xba2d80] Could not find ref with POC -48 > [hevc @ 0xba2d80] Could not find ref with POC -32 > [hevc @ 0xba2d80] First slice in a frame missing. > Last message repeated 34 times > [aac @ 0xba1200] channel element 2.4 is not allocated > color_transfer=bt2020-10 > color_transfer=bt2020-10 > color_transfer=bt2020-10 > color_transfer=bt2020-10 > color_transfer=bt2020-10 > color_transfer=bt2020-10 > color_transfer=bt2020-10 > color_transfer=bt2020-10 > color_transfer=bt2020-10 > color_transfer=bt2020-10 > ^C > > ``` > > that should be color_transfer=arib-std-b67 > > Would anyone object if I restored previous behavior? I'd prefer avoid > reimplementing SEI parsing outside of libav just to get the correct > per-frame color_trc... Yes, the point of the change was to set color_trc before the frame buffers were allocated, so a full revert would break that. Can you share the sample that reproduces this? > > Thank you, > Pavel. > ___ > 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] AVFrame.color_trc wrong since f2ad6238e4c0e99e2fc131ee14c586e87b045680
set_side_data used to do out->color_trc = s->sei.alternative_transfer.preferred_transfer_characteristics; In commit f2ad6238e4c0e99e2fc131ee14c586e87b045680 this was removed. Now ffprobe of an HLG stream reports wrong transfer characteristics for each frame: ``` $ ffprobe -show_frames 20190914-1435_iowa_vs_iowa-state_fox-cfb-dertp.ts | grep color_transfer= | head ffprobe version N-99190-g7cc8a2b Copyright (c) 2007-2020 the FFmpeg developers built with gcc 8 (Ubuntu 8.4.0-1ubuntu1~16.04.1) configuration: --prefix=/home/xyz/x86_64 --enable-rpath --enable-shared --disable-static --disable-stripping --enable-libfreetype --enable-libfontconfig --enable-libfribidi --enable-libass --enable-libmodplug --enable-openssl --enable-ffnvcodec --enable-cuda --extra-ldflags='-L/home/xyz/x86_64/lib -L/usr/local/cuda/lib64' --extra-cflags='-I/home/xyz/x86_64/include -I/usr/local/cuda/include' libavutil 56. 59.100 / 56. 59.100 libavcodec 58.106.100 / 58.106.100 libavformat58. 56.100 / 58. 56.100 libavdevice58. 11.102 / 58. 11.102 libavfilter 7. 87.100 / 7. 87.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 [hevc @ 0xb78b00] PPS id out of range: 0 Last message repeated 1 times [hevc @ 0xb78b00] Error parsing NAL unit #2. [hevc @ 0xb78b00] PPS id out of range: 0 Last message repeated 1 times [hevc @ 0xb78b00] Error parsing NAL unit #2. [hevc @ 0xb78b00] PPS id out of range: 0 Last message repeated 1 times [hevc @ 0xb78b00] Error parsing NAL unit #2. [hevc @ 0xb78b00] PPS id out of range: 0 Last message repeated 1 times [hevc @ 0xb78b00] Error parsing NAL unit #2. [hevc @ 0xb78b00] PPS id out of range: 0 Last message repeated 1 times [hevc @ 0xb78b00] Error parsing NAL unit #2. [hevc @ 0xb78b00] PPS id out of range: 0 Last message repeated 1 times [hevc @ 0xb78b00] Error parsing NAL unit #2. [hevc @ 0xb78b00] PPS id out of range: 0 Last message repeated 1 times [hevc @ 0xb78b00] Error parsing NAL unit #2. [mpegts @ 0xb72c40] PES packet size mismatch [mpegts @ 0xb72c40] Packet corrupt (stream = 2, dts = 3870328878). [mpegts @ 0xb72c40] PES packet size mismatch [mpegts @ 0xb72c40] Packet corrupt (stream = 1, dts = 3870334067). [mpegts @ 0xb72c40] PES packet size mismatch [mpegts @ 0xb72c40] Packet corrupt (stream = 2, dts = 3870328878). [mpegts @ 0xb72c40] stream 0 : no PTS found at end of file, duration not set Input #0, mpegts, from '20190914-1435_iowa_vs_iowa-state_fox-cfb-dertp.ts': Duration: 00:05:00.05, start: 42703.686200, bitrate: 70429 kb/s Program 1 Stream #0:0[0x3ff]: Video: hevc (Main 10) ([36][0][0][0] / 0x0024), yuv420p10le(tv, bt2020nc/bt2020/arib-std-b67), 3840x2160 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc Stream #0:1[0x400](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 126 kb/s Stream #0:2[0x401](eng): Audio: eac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 384 kb/s [hevc @ 0xba2d80] Could not find ref with POC -40 [hevc @ 0xba2d80] Could not find ref with POC -48 [hevc @ 0xba2d80] Could not find ref with POC -32 [hevc @ 0xba2d80] First slice in a frame missing. Last message repeated 34 times [aac @ 0xba1200] channel element 2.4 is not allocated color_transfer=bt2020-10 color_transfer=bt2020-10 color_transfer=bt2020-10 color_transfer=bt2020-10 color_transfer=bt2020-10 color_transfer=bt2020-10 color_transfer=bt2020-10 color_transfer=bt2020-10 color_transfer=bt2020-10 color_transfer=bt2020-10 ^C ``` that should be color_transfer=arib-std-b67 Would anyone object if I restored previous behavior? I'd prefer avoid reimplementing SEI parsing outside of libav just to get the correct per-frame color_trc... Thank you, Pavel. ___ 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 02/16] avcodec/pcm-dvd: Avoid allocation of buffer
Andreas Rheinhardt: > In this case, it also allows to remove the decoder's close function. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/pcm-dvd.c | 16 ++-- > 1 file changed, 2 insertions(+), 14 deletions(-) > > diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c > index 0a751a8191..725c2f5b29 100644 > --- a/libavcodec/pcm-dvd.c > +++ b/libavcodec/pcm-dvd.c > @@ -34,8 +34,9 @@ typedef struct PCMDVDContext { > int last_block_size; // Size of the last block of samples in bytes > int samples_per_block; // Number of samples per channel per block > int groups_per_block;// Number of 20/24-bit sample groups per block > -uint8_t *extra_samples; // Pointer to leftover samples from a frame > int extra_sample_count; // Number of leftover samples in the buffer > +uint8_t extra_samples[8 * 3 * 4]; // Space for leftover samples from a > frame > + // (8 channels, 3B/sample, 4 > samples/block) > } PCMDVDContext; > > static av_cold int pcm_dvd_decode_init(AVCodecContext *avctx) > @@ -44,18 +45,6 @@ static av_cold int pcm_dvd_decode_init(AVCodecContext > *avctx) > > /* Invalid header to force parsing of the first header */ > s->last_header = -1; > -/* reserve space for 8 channels, 3 bytes/sample, 4 samples/block */ > -if (!(s->extra_samples = av_malloc(8 * 3 * 4))) > -return AVERROR(ENOMEM); > - > -return 0; > -} > - > -static av_cold int pcm_dvd_decode_uninit(AVCodecContext *avctx) > -{ > -PCMDVDContext *s = avctx->priv_data; > - > -av_freep(>extra_samples); > > return 0; > } > @@ -310,7 +299,6 @@ AVCodec ff_pcm_dvd_decoder = { > .priv_data_size = sizeof(PCMDVDContext), > .init = pcm_dvd_decode_init, > .decode = pcm_dvd_decode_frame, > -.close = pcm_dvd_decode_uninit, > .capabilities = AV_CODEC_CAP_DR1, > .sample_fmts= (const enum AVSampleFormat[]) { > AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE > Will apply the patches in the first batch (i.e. everything until #16) tomorrow if there are no objections. - 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] avformat/argo_asf: initialise file header inline
On Mon, 14 Sep 2020 23:31:00 + "Zane van Iperen" wrote: > > Garbage was left-over in the ArgoASFFileHeader::name field if the url > was too short. This zero-initialises it. > > Signed-off-by: Zane van Iperen Will apply soon. ___ 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] Unrolls main loop of yuv2yuvX_sse3 and general code tidying for ~20% speedup
On Tue, Sep 15, 2020 at 06:11:58PM +0200, Alan Kelly wrote: > --- > libswscale/x86/swscale.c | 138 --- > 1 file changed, 72 insertions(+), 66 deletions(-) > > diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c > index 3160fedf04..e47fee2bbd 100644 > --- a/libswscale/x86/swscale.c > +++ b/libswscale/x86/swscale.c > @@ -201,76 +201,82 @@ static void yuv2yuvX_sse3(const int16_t *filter, int > filterSize, > const int16_t **src, uint8_t *dest, int dstW, > const uint8_t *dither, int offset) > { > -if(((uintptr_t)dest) & 15){ > +if(((uintptr_t)dest) & 31){ > yuv2yuvX_mmxext(filter, filterSize, src, dest, dstW, dither, offset); > return; > } > filterSize--; > -#define MAIN_FUNCTION \ > -"pxor %%xmm0, %%xmm0 \n\t" \ > -"punpcklbw %%xmm0, %%xmm3 \n\t" \ > -"movd %4, %%xmm1 \n\t" \ > -"punpcklwd %%xmm1, %%xmm1 \n\t" \ > -"punpckldq %%xmm1, %%xmm1 \n\t" \ > -"punpcklqdq %%xmm1, %%xmm1 \n\t" \ > -"psllw $3, %%xmm1 \n\t" \ > -"paddw %%xmm1, %%xmm3 \n\t" \ > -"psraw $4, %%xmm3 \n\t" \ > -"movdqa %%xmm3, %%xmm4 \n\t" \ > -"movdqa %%xmm3, %%xmm7 \n\t" \ > -"movl %3, %%ecx \n\t" \ > -"mov %0, %%"FF_REG_d"\n\t"\ > -"mov(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\ > -".p2align 4 \n\t" /* FIXME > Unroll? */\ > -"1: \n\t"\ > -"movddup 8(%%"FF_REG_d"), %%xmm0 \n\t" /* > filterCoeff */\ > -"movdqa (%%"FF_REG_S", %%"FF_REG_c", 2), %%xmm2 \n\t" > /* srcData */\ > -"movdqa16(%%"FF_REG_S", %%"FF_REG_c", 2), %%xmm5 \n\t" > /* srcData */\ > -"add$16, %%"FF_REG_d"\n\t"\ > -"mov(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\ > -"test %%"FF_REG_S", %%"FF_REG_S" \n\t"\ > -"pmulhw %%xmm0, %%xmm2 \n\t"\ > -"pmulhw %%xmm0, %%xmm5 \n\t"\ > -"paddw%%xmm2, %%xmm3 \n\t"\ > -"paddw%%xmm5, %%xmm4 \n\t"\ > -" jnz1b \n\t"\ > -"psraw $3, %%xmm3 \n\t"\ > -"psraw $3, %%xmm4 \n\t"\ > -"packuswb %%xmm4, %%xmm3 \n\t"\ > -"movntdq %%xmm3, (%1, %%"FF_REG_c") \n\t"\ > -"add $16, %%"FF_REG_c"\n\t"\ > -"cmp %2, %%"FF_REG_c"\n\t"\ > -"movdqa %%xmm7, %%xmm3\n\t" \ > -"movdqa %%xmm7, %%xmm4\n\t" \ > -"mov %0, %%"FF_REG_d"\n\t"\ > -"mov(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\ > -"jb 1b \n\t" > - > -if (offset) { > -__asm__ volatile( > -"movq %5, %%xmm3 \n\t" > -"movdqa%%xmm3, %%xmm4 \n\t" > -"psrlq$24, %%xmm3 \n\t" > -"psllq$40, %%xmm4 \n\t" > -"por %%xmm4, %%xmm3 \n\t" > -MAIN_FUNCTION > - :: "g" (filter), > - "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset), > - "m"(filterSize), "m"(((uint64_t *) dither)[0]) > - : XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" , "%xmm4" > , "%xmm5" , "%xmm7" ,) > -"%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_c > - ); > -} else { > -__asm__ volatile( > -"movq %5, %%xmm3 \n\t" > -MAIN_FUNCTION > - :: "g" (filter), > - "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset), > - "m"(filterSize), "m"(((uint64_t *) dither)[0]) > - : XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" , "%xmm4" > , "%xmm5" , "%xmm7" ,) > -"%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_c > - ); > -} > +__asm__ volatile( > +"vmovq%5, %%xmm3\n\t" > +"cmpl $0, %3\n\t" > +"jz 2f\n\t" > + > +"# offset != 0 path.\n\t" > +"vpsrlq $24, %%xmm3, %%xmm5\n\t" > +"vpsllq $40, %%xmm3, %%xmm3\n\t" > +
Re: [FFmpeg-devel] [PATCH 3/4 v2] ffmpeg: move A/V non-streamcopy initialization to a later point
On Mon, Sep 14, 2020 at 12:33:14AM +0300, Jan Ekström wrote: > - For video, this means a single initialization point in do_video_out. > - For audio we unfortunately need to do it in two places just > before the buffer sink is utilized (if av_buffersink_get_samples > would still work according to its specification after a call to > avfilter_graph_request_oldest was made, we could at least remove > the one in transcode_step). > > Other adjustments to make things work: > - As the AVFrame PTS adjustment to encoder time base needs the encoder > to be initialized, so it is now moved to do_{video,audio}_out, > right after the encoder has been initialized. Due to this, > the additional parameter in do_video_out is removed as it is no > longer necessary. > --- > fftools/ffmpeg.c | 112 --- > 1 file changed, 77 insertions(+), 35 deletions(-) breaks this: ./ffmpeg -ss 30.0 -i ~/tickets/1745/1745-Sample.mkv -f vob -c:a copy -bitexact -t 1 -f framecrc - (sample file is linked in the ticket https://trac.ffmpeg.org/ticket/1745) (Too many packets buffered for output stream 0:1. Conversion failed!) thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have often repented speaking, but never of holding my tongue. -- Xenocrates 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] avfilter/vf_scale: set RGB to always be full range
This value - while it looks like the actual range of the content - is nothing but the internal value of swscale. Thus, if we have RGB content, force the value to 1. Swscale will ignore it, but at least the value of the output AVFrame will now properly be "full range" instead of "limited range", as it is right now. --- libavfilter/vf_scale.c | 17 + 1 file changed, 17 insertions(+) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 58eee96744..12df27edf4 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -751,6 +751,15 @@ scale: || scale->out_range != AVCOL_RANGE_UNSPECIFIED) { int in_full, out_full, brightness, contrast, saturation; const int *inv_table, *table; +const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(out->format); +if (!out_desc) { +av_log(ctx, AV_LOG_ERROR, + "Failed to get the pixel format descriptor for format %d!\n", + out->format); +av_frame_free(); +av_frame_free(frame_out); +return AVERROR_INVALIDDATA; +} sws_getColorspaceDetails(scale->sws, (int **)_table, _full, (int **), _full, @@ -768,7 +777,15 @@ scale: else if (in_range != AVCOL_RANGE_UNSPECIFIED) in_full = (in_range == AVCOL_RANGE_JPEG); if (scale->out_range != AVCOL_RANGE_UNSPECIFIED) +// note: this can be silently overridden by +// sws_setColorspaceDetails for non-YCbCr formats out_full = (scale->out_range == AVCOL_RANGE_JPEG); +else if (out_desc->flags & AV_PIX_FMT_FLAG_RGB) +// the range values received from swscale are its internal +// identifiers, and will not be nonzero for any sort of RGB. +// thus, if we do not set it to nonzero ourselves, this will +// be incorrect. +out_full = 1; sws_setColorspaceDetails(scale->sws, inv_table, in_full, table, out_full, -- 2.26.2 ___ 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] fate: Add aa-demux test
This should help fuzzer coverage The sample file can be generated by dd if=samples/audible/2004FirstPresidentialDebateBushvs.Kerry93004_acelp85_maihde.aa of=bush.aa count=110 Signed-off-by: Michael Niedermayer --- tests/fate/demux.mak| 3 + tests/ref/fate/aa-demux | 283 2 files changed, 286 insertions(+) create mode 100644 tests/ref/fate/aa-demux diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak index 9f3a6be276..b8a1a30d4b 100644 --- a/tests/fate/demux.mak +++ b/tests/fate/demux.mak @@ -7,6 +7,9 @@ fate-adts-id3v1-demux: CMD = framecrc -f aac -i $(TARGET_SAMPLES)/aac/id3v1.aac fate-adts-id3v2-demux: CMD = framecrc -f aac -i $(TARGET_SAMPLES)/aac/id3v2.aac -c:a copy fate-adts-id3v2-two-tags-demux: CMD = framecrc -i $(TARGET_SAMPLES)/aac/id3v2_two_tags.aac -c:a copy +FATE_SAMPLES_DEMUX-$(CONFIG_AA_DEMUXER) += fate-aa-demux +fate-aa-demux: CMD = framecrc -i $(TARGET_SAMPLES)/aa/bush.aa -c:a copy + FATE_SAMPLES_DEMUX-$(CONFIG_AEA_DEMUXER) += fate-aea-demux fate-aea-demux: CMD = crc -i $(TARGET_SAMPLES)/aea/chirp.aea -c:a copy diff --git a/tests/ref/fate/aa-demux b/tests/ref/fate/aa-demux new file mode 100644 index 00..89350b8803 --- /dev/null +++ b/tests/ref/fate/aa-demux @@ -0,0 +1,283 @@ +#tb 0: 1/1062500 +#media_type 0: audio +#codec_id 0: sipr +#sample_rate 0: 8500 +#channel_layout 0: 4 +#channel_layout_name 0: mono +0, 0, 0,18000, 19, 0x36e10529 +0, 18000, 18000,18000, 19, 0x70810a69 +0, 36000, 36000,18000, 19, 0x618f08a0 +0, 54000, 54000,18000, 19, 0x65a508bd +0, 72000, 72000,18000, 19, 0x50420796 +0, 9, 9,18000, 19, 0x6468084f +0, 108000, 108000,18000, 19, 0x75020a84 +0, 126000, 126000,18000, 19, 0x68be09ae +0, 144000, 144000,18000, 19, 0x6cb709b8 +0, 162000, 162000,18000, 19, 0x3fee061e +0, 18, 18,18000, 19, 0x53220770 +0, 198000, 198000,18000, 19, 0x57590888 +0, 216000, 216000,18000, 19, 0x6653089c +0, 234000, 234000,18000, 19, 0x55eb081f +0, 252000, 252000,18000, 19, 0x79750ad6 +0, 27, 27,18000, 19, 0x5e340927 +0, 288000, 288000,18000, 19, 0x60c80974 +0, 306000, 306000,18000, 19, 0x6c5008f5 +0, 324000, 324000,18000, 19, 0x6f5609ca +0, 342000, 342000,18000, 19, 0x79a609f5 +0, 36, 36,18000, 19, 0x6fa308d5 +0, 378000, 378000,18000, 19, 0x56de0789 +0, 396000, 396000,18000, 19, 0x567408bf +0, 414000, 414000,18000, 19, 0x62800968 +0, 432000, 432000,18000, 19, 0x64ae0a88 +0, 45, 45,18000, 19, 0x73eb0af5 +0, 468000, 468000,18000, 19, 0x6f1e0ac0 +0, 486000, 486000,18000, 19, 0x5d0e0a34 +0, 504000, 504000,18000, 19, 0x61990a70 +0, 522000, 522000,18000, 19, 0x71e00a8a +0, 54, 54,18000, 19, 0x6c400a3f +0, 558000, 558000,18000, 19, 0x5f850921 +0, 576000, 576000,18000, 19, 0x6e7e0a5e +0, 594000, 594000,18000, 19, 0x4bbe08cd +0, 612000, 612000,18000, 19, 0x62c407d5 +0, 63, 63,18000, 19, 0x475f07b9 +0, 648000, 648000,18000, 19, 0x6f480a68 +0, 666000, 666000,18000, 19, 0x65710a4d +0, 684000, 684000,18000, 19, 0x4b2d0841 +0, 702000, 702000,18000, 19, 0x64a80a03 +0, 72, 72,18000, 19, 0x61f608fa +0, 738000, 738000,18000, 19, 0x6fb70a5e +0, 756000, 756000,18000, 19, 0x5f4e0a48 +0, 774000, 774000,18000, 19, 0x5a200919 +0, 792000, 792000,18000, 19, 0x69af0a1f +0, 81, 81,18000, 19, 0x643d094a +0, 828000, 828000,18000, 19, 0x56e707f7 +0, 846000, 846000,18000, 19, 0x60ed0923 +0, 864000, 864000,18000, 19, 0x6d5d099c +0, 882000, 882000,18000, 19, 0x736d0abd +0, 90, 90,18000, 19, 0x578d0981 +0, 918000, 918000,18000, 19, 0x621f0979 +0, 936000, 936000,18000, 19, 0x690a0938 +0, 954000, 954000,18000, 19, 0x55df096f +0, 972000, 972000,18000, 19, 0x5b900945 +0, 99, 99,18000, 19, 0x595e090a +0,1008000,1008000,18000, 19, 0x6f3a0b0d +0,1026000,1026000,18000, 19, 0x5df80902 +0,1044000,1044000,18000, 19, 0x61fa08f6 +0,1062000,1062000,18000, 19, 0x6a8e0a90 +0,108,108,18000,
Re: [FFmpeg-devel] [PATCH] avformat/aviobuf: realloc memory in ffio_ensure_seekback()
On Tue, 15 Sep 2020, Andreas Rheinhardt wrote: Marton Balint: On Tue, 15 Sep 2020, Paul B Mahol wrote: This removes big CPU overhead for demuxing chained ogg streams. Signed-off-by: Paul B Mahol --- libavformat/aviobuf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index a77517d712..6d01150f66 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1005,12 +1005,11 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size) return 0; av_assert0(!s->write_flag); - buffer = av_malloc(buf_size); + buffer = s->buffer; + buffer = av_realloc(buffer, buf_size); It is not guaranteed that buffer is allocated with av_realloc, so you cannot realloc it. This isn't true since 21f70940ae106bfffa07e73057cdb4b5e81a767a any more. Then av_realloc() docs need updating as well. 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 26/30] avcodec/mpc7, mpc7data: Avoid gaps in array
Paul B Mahol: > On Tue, Sep 15, 2020 at 09:39:56AM +0200, Andreas Rheinhardt wrote: >> The Musepack decoder uses static VLC tables to parse the bitstream. >> There are 14 different quant tables VLCs and each of them has a varying >> number of codes. The maximum number is 63, the average number is 25.3. >> Up until now, the array containing the raw data was of type >> uint16_t [7][2][64 * 2] (the 14 tables come in pairs of two, hence [7][2] >> instead of [14]) and from this it follows that there were large gaps in >> said array. This commit changes this by making it a continuous array >> instead. Doing so saves about 2KB. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> libavcodec/mpc7.c | 17 ++ >> libavcodec/mpc7data.h | 76 +-- >> 2 files changed, 32 insertions(+), 61 deletions(-) > > Should be fine if there is full coverage of code with samples covering those > vlcs. > This code is covered by the musepack7 FATE-test. I just added a few counters to it in order to check whether all VLC tables are used. They indeed are: Counter for quant[0][0]: 1478 Counter for quant[0][1]: 2021 Counter for quant[1][0]: 2628 Counter for quant[1][1]: 3500 Counter for quant[2][0]: 1061 Counter for quant[2][1]: 2355 Counter for quant[3][0]: 367 Counter for quant[3][1]: 1048 Counter for quant[4][0]: 598 Counter for quant[4][1]: 1000 Counter for quant[5][0]: 274 Counter for quant[5][1]: 771 Counter for quant[6][0]: 229 Counter for quant[6][1]: 232 Just to be sure I have also calculated the CRCs (AV_CRC_32_IEEE) of the tables. They are unchanged: CRC for quant table 0 0 3BDAC345 CRC for quant table 0 1 F97ACD5D CRC for quant table 1 0 2EBC08F1 CRC for quant table 1 1 FA19B798 CRC for quant table 2 0 16C9A42B CRC for quant table 2 1 B3DF7046 CRC for quant table 3 0 D4162F07 CRC for quant table 3 1 DA23BC68 CRC for quant table 4 0 16D7D50F CRC for quant table 4 1 433F7CB CRC for quant table 5 0 2511392D CRC for quant table 5 1 60C43D91 CRC for quant table 6 0 31C9B671 CRC for quant table 6 1 563EFA5D I have therefore pushed this and the other musepack patch; I have also incorporated a fix for 1e40dc920a838e35f1483b20bfcd417437e68741 in the latter (the topic fits). - 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] avformat/aviobuf: realloc memory in ffio_ensure_seekback()
Marton Balint: > > > On Tue, 15 Sep 2020, Paul B Mahol wrote: > >> This removes big CPU overhead for demuxing chained ogg streams. >> >> Signed-off-by: Paul B Mahol >> --- >> libavformat/aviobuf.c | 5 ++--- >> 1 file changed, 2 insertions(+), 3 deletions(-) >> >> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c >> index a77517d712..6d01150f66 100644 >> --- a/libavformat/aviobuf.c >> +++ b/libavformat/aviobuf.c >> @@ -1005,12 +1005,11 @@ int ffio_ensure_seekback(AVIOContext *s, >> int64_t buf_size) >> return 0; >> av_assert0(!s->write_flag); >> >> - buffer = av_malloc(buf_size); >> + buffer = s->buffer; >> + buffer = av_realloc(buffer, buf_size); > > It is not guaranteed that buffer is allocated with av_realloc, so you > cannot realloc it. > This isn't true since 21f70940ae106bfffa07e73057cdb4b5e81a767a any more. - 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] avformat/aviobuf: realloc memory in ffio_ensure_seekback()
On Tue, 15 Sep 2020, Paul B Mahol wrote: This removes big CPU overhead for demuxing chained ogg streams. Signed-off-by: Paul B Mahol --- libavformat/aviobuf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index a77517d712..6d01150f66 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1005,12 +1005,11 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size) return 0; av_assert0(!s->write_flag); -buffer = av_malloc(buf_size); +buffer = s->buffer; +buffer = av_realloc(buffer, buf_size); It is not guaranteed that buffer is allocated with av_realloc, so you cannot realloc it. Regards, Marton if (!buffer) return AVERROR(ENOMEM); -memcpy(buffer, s->buffer, filled); -av_free(s->buffer); s->buf_ptr = buffer + (s->buf_ptr - s->buffer); s->buf_end = buffer + (s->buf_end - s->buffer); s->buffer = buffer; -- 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 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] avdevice/decklink_dec: fix build with older SDK
On Tue, 15 Sep 2020, Gyan Doshi wrote: On 15-09-2020 12:54 am, Marton Balint wrote: Apparently bmdFormatUnspecified needs SDK 11.0. It is just a fancy way of checking for zero, so let's do that instead. Fixes build issue since f1b908d20a8. Signed-off-by: Marton Balint --- libavdevice/decklink_dec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 92b8feed14..6517b9df13 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -1232,7 +1232,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) } av_log(avctx, AV_LOG_INFO, "Autodetected the input mode\n"); } -if (ctx->raw_format == bmdFormatUnspecified) +if (ctx->raw_format == (BMDPixelFormat)0) ctx->raw_format = bmdFormat8BitYUV; if (ff_decklink_set_format(avctx, DIRECTION_IN) < 0) { av_log(avctx, AV_LOG_ERROR, "Could not set format code %s for %s\n", LGTM. Thanks, applied. 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] ffmpeg: pass decoded or filtered AVFrame to output stream initialization
On Tue, Sep 15, 2020 at 9:12 PM Jan Ekström wrote: > > On Tue, Sep 15, 2020 at 7:39 PM James Almer wrote: > > > > On 9/15/2020 1:21 PM, Jan Ekström wrote: > > > On Tue, Sep 15, 2020 at 5:28 PM Jan Ekström wrote: > > >> > > >> > > >> Further looking into this, it seems to come from filtering (?) (diff > > >> attached) > > >> > > >> decoded AVFrame: 128x128, pix_fmt: rgba, range: pc > > >> while... > > >> AVFrame to be encoded: 128x128, pix_fmt: bgra, range: tv > > >> > > >> Jan > > > > > > For the record, the culprit seems to be this piece of logic within > > > libavfilter/vf_scale.c: > > > http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavfilter/vf_scale.c;h=58eee967440657798f84383ec6f79e8a05c3ece0;hb=HEAD#l747 > > > > > > Only input has range defined, out_full never gets set to nonzero. > > > Thus, > > > out->color_range = out_full ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG > > > leads to AVCOL_RANGE_MPEG. > > > > Would changing that to out->color_range = scale->out_range help, or > > break things too much? > > > > I was informed that swscale doesn't say that RGB is full range, so I > moved on to fix that since that is utilized as out_full here. Patch > follows. > > After doing that, FATE still passed but... > > [swscaler @ 0x62f00400] sws_init_context: srcRange: 1, dstRange: 1 > [auto_scaler_0 @ 0x61107980] w:128 h:128 fmt:rgba sar:2835/2835 -> > w:128 h:128 fmt:bgra sar:1/1 flags:0x4 > scale_frame: out_full: 0 > vf_scale AVFrame: 128x128, pix_fmt: bgra, range: tv > > I am very confused at this point :P > > Jan > > -->8 > diff --git a/libswscale/utils.c b/libswscale/utils.c > index 9ca378bd3b..59d4d5e873 100644 > --- a/libswscale/utils.c > +++ b/libswscale/utils.c > @@ -1200,8 +1200,11 @@ av_cold int sws_init_context(SwsContext *c, > SwsFilter *srcFilter, > > unscaled = (srcW == dstW && srcH == dstH); > > -c->srcRange |= handle_jpeg(>srcFormat); > -c->dstRange |= handle_jpeg(>dstFormat); > +c->srcRange |= isAnyRGB(c->srcFormat) ? 1 : handle_jpeg(>srcFormat); > +c->dstRange |= isAnyRGB(c->dstFormat) ? 1 : handle_jpeg(>dstFormat); > + > +av_log(c, AV_LOG_VERBOSE, "%s: srcRange: %d, dstRange: %d\n", > + __FUNCTION__, c->srcRange, c->dstRange); > > if(srcFormat!=c->srcFormat || dstFormat!=c->dstFormat) > av_log(c, AV_LOG_WARNING, "deprecated pixel format used, make > sure you did set range correctly\n"); OK, I found the silent override in sws_setColorspaceDetails. If this is indeed how swscale notes what the input/output range is, maybe it should be something a la the following? (maybe just without the duplication by making it a function). @@ -876,10 +914,23 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], desc_dst = av_pix_fmt_desc_get(c->dstFormat); desc_src = av_pix_fmt_desc_get(c->srcFormat); -if(!isYUV(c->dstFormat) && !isGray(c->dstFormat)) -dstRange = 0; -if(!isYUV(c->srcFormat) && !isGray(c->srcFormat)) -srcRange = 0; +if ((isAnyRGB(c->dstFormat) || handle_jpeg(>dstFormat)) && !dstRange) { +av_log(c, AV_LOG_WARNING, + "Destination pixel format '%s' is considered full range, " + "but an attempt was made to set the conversion to limited " + "range. Enforcing full range.\n", + (desc_dst && desc_dst->name) ? desc_dst->name : "unknown"); +dstRange = 1; +} + +if ((isAnyRGB(c->srcFormat) || handle_jpeg(>srcFormat)) && !srcRange) { +av_log(c, AV_LOG_WARNING, + "Source pixel format '%s' is considered full range, " + "but an attempt was made to set the conversion to limited " + "range. Enforcing full range.\n", + (desc_dst && desc_dst->name) ? desc_dst->name : "unknown"); +srcRange = 1; +} if (c->srcRange != srcRange || c->dstRange != dstRange || Alternatively, if the swscale value is not the input/output range exactly, maybe we should switch to something a la the following? static int decide_color_range(ScaleContext *scale, AVFrame *in_frame, AVFrame *out_frame) { const AVPixFmtDescriptor *in_desc = av_pix_fmt_desc_get(in_frame->format); const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(out_frame->format); if (!in_desc || !out_desc) { return AVERROR_INVALIDDATA; } int output_is_yuvj = \ (out_desc->name && !strncmp(out_desc->name, "yuvj", 4)); // first decide on the range. start by setting it to the // scale context's value. out_frame->color_range = scale->out_range; if (out_frame->color_range != AVCOL_RANGE_UNSPECIFIED) // we have a range specified for output, off ye go goto early_exit; // output range is unspecified, time to do some logic if (!!(in_desc->flags & AV_PIX_FMT_FLAG_RGB) == !!(out_desc->flags & AV_PIX_FMT_FLAG_RGB)) { // if both input and output match in
Re: [FFmpeg-devel] [PATCH 4/4] ffmpeg: pass decoded or filtered AVFrame to output stream initialization
On Tue, Sep 15, 2020 at 7:39 PM James Almer wrote: > > On 9/15/2020 1:21 PM, Jan Ekström wrote: > > On Tue, Sep 15, 2020 at 5:28 PM Jan Ekström wrote: > >> > >> > >> Further looking into this, it seems to come from filtering (?) (diff > >> attached) > >> > >> decoded AVFrame: 128x128, pix_fmt: rgba, range: pc > >> while... > >> AVFrame to be encoded: 128x128, pix_fmt: bgra, range: tv > >> > >> Jan > > > > For the record, the culprit seems to be this piece of logic within > > libavfilter/vf_scale.c: > > http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavfilter/vf_scale.c;h=58eee967440657798f84383ec6f79e8a05c3ece0;hb=HEAD#l747 > > > > Only input has range defined, out_full never gets set to nonzero. > > Thus, > > out->color_range = out_full ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG > > leads to AVCOL_RANGE_MPEG. > > Would changing that to out->color_range = scale->out_range help, or > break things too much? > I was informed that swscale doesn't say that RGB is full range, so I moved on to fix that since that is utilized as out_full here. Patch follows. After doing that, FATE still passed but... [swscaler @ 0x62f00400] sws_init_context: srcRange: 1, dstRange: 1 [auto_scaler_0 @ 0x61107980] w:128 h:128 fmt:rgba sar:2835/2835 -> w:128 h:128 fmt:bgra sar:1/1 flags:0x4 scale_frame: out_full: 0 vf_scale AVFrame: 128x128, pix_fmt: bgra, range: tv I am very confused at this point :P Jan -->8 diff --git a/libswscale/utils.c b/libswscale/utils.c index 9ca378bd3b..59d4d5e873 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1200,8 +1200,11 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, unscaled = (srcW == dstW && srcH == dstH); -c->srcRange |= handle_jpeg(>srcFormat); -c->dstRange |= handle_jpeg(>dstFormat); +c->srcRange |= isAnyRGB(c->srcFormat) ? 1 : handle_jpeg(>srcFormat); +c->dstRange |= isAnyRGB(c->dstFormat) ? 1 : handle_jpeg(>dstFormat); + +av_log(c, AV_LOG_VERBOSE, "%s: srcRange: %d, dstRange: %d\n", + __FUNCTION__, c->srcRange, c->dstRange); if(srcFormat!=c->srcFormat || dstFormat!=c->dstFormat) av_log(c, AV_LOG_WARNING, "deprecated pixel format used, make sure you did set range correctly\n"); ___ 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 25/30] avcodec/mpc7: Don't pretend initializing static VLC tables can fail
On Tue, Sep 15, 2020 at 09:39:55AM +0200, Andreas Rheinhardt wrote: > It can't if one hasn't made a mistake at calculating the sizes; > and this is checked by asserts/aborts. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/mpc7.c | 45 - > 1 file changed, 12 insertions(+), 33 deletions(-) > looks ok ___ 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 26/30] avcodec/mpc7, mpc7data: Avoid gaps in array
On Tue, Sep 15, 2020 at 09:39:56AM +0200, Andreas Rheinhardt wrote: > The Musepack decoder uses static VLC tables to parse the bitstream. > There are 14 different quant tables VLCs and each of them has a varying > number of codes. The maximum number is 63, the average number is 25.3. > Up until now, the array containing the raw data was of type > uint16_t [7][2][64 * 2] (the 14 tables come in pairs of two, hence [7][2] > instead of [14]) and from this it follows that there were large gaps in > said array. This commit changes this by making it a continuous array > instead. Doing so saves about 2KB. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/mpc7.c | 17 ++ > libavcodec/mpc7data.h | 76 +-- > 2 files changed, 32 insertions(+), 61 deletions(-) Should be fine if there is full coverage of code with samples covering those vlcs. ___ 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 04/30] avcodec/flashsv2enc: Cleanup generically after init failure
On Tue, Sep 15, 2020 at 09:39:34AM +0200, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/flashsv2enc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) ok ___ 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 16/30] avcodec/indeo5: Fix memleaks upon allocation error
On Tue, Sep 15, 2020 at 09:39:46AM +0200, Andreas Rheinhardt wrote: > ff_ivi_init_planes() might error out after having allocated some arrays. > Set the FF_CODEC_CAP_INIT_CLEANUP flag in order to free these arrays in > this case. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/indeo5.c | 2 ++ > 1 file changed, 2 insertions(+) looks ok > > diff --git a/libavcodec/indeo5.c b/libavcodec/indeo5.c > index 4ccdbcaf0a..ac15d31fef 100644 > --- a/libavcodec/indeo5.c > +++ b/libavcodec/indeo5.c > @@ -30,6 +30,7 @@ > #define BITSTREAM_READER_LE > #include "avcodec.h" > #include "get_bits.h" > +#include "internal.h" > #include "ivi.h" > #include "ivi_dsp.h" > #include "indeo5data.h" > @@ -692,4 +693,5 @@ AVCodec ff_indeo5_decoder = { > .close = ff_ivi_decode_close, > .decode = ff_ivi_decode_frame, > .capabilities = AV_CODEC_CAP_DR1, > +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, > }; > -- > 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 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 15/30] avcodec/ivi: Fix segfault on allocation error
On Tue, Sep 15, 2020 at 09:39:45AM +0200, Andreas Rheinhardt wrote: > If allocating the tiles array for indeo 4/5 fails, the context is in an > inconsistent state, because the counter for the number of tiles is > 0. > This will lead to a segfault when freeing the tiles' substructures. > Fix this by setting the number of tiles to zero if the allocation was > unsuccessfull. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/ivi.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > looks ok ___ 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 05/30] avcodec/flashsv2enc: Return better error codes
On Tue, Sep 15, 2020 at 09:39:35AM +0200, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/flashsv2enc.c | 11 ++- > 1 file changed, 6 insertions(+), 5 deletions(-) > looks ok ___ 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 20/30] avcodec/mlpenc: Fix memleak upon init failure
On Tue, Sep 15, 2020 at 09:39:50AM +0200, Andreas Rheinhardt wrote: > If an error happens during init after an allocation has succeeded, > the already allocated data leaked up until now. Fix this by setting the > FF_CODEC_CAP_INIT_CLEANUP flag. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/mlpenc.c | 2 ++ > 1 file changed, 2 insertions(+) > lgtm > diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c > index 52ea06ed91..f6159d39c8 100644 > --- a/libavcodec/mlpenc.c > +++ b/libavcodec/mlpenc.c > @@ -2391,6 +2391,7 @@ AVCodec ff_mlp_encoder = { > .sample_fmts= (const enum AVSampleFormat[]) > {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE}, > .supported_samplerates = (const int[]) {44100, 48000, 88200, 96000, > 176400, 192000, 0}, > .channel_layouts= ff_mlp_channel_layouts, > +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, > }; > #endif > #if CONFIG_TRUEHD_ENCODER > @@ -2407,5 +2408,6 @@ AVCodec ff_truehd_encoder = { > .sample_fmts= (const enum AVSampleFormat[]) > {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE}, > .supported_samplerates = (const int[]) {44100, 48000, 88200, 96000, > 176400, 192000, 0}, > .channel_layouts= (const uint64_t[]) {AV_CH_LAYOUT_STEREO, > AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_5POINT1_BACK, 0}, > +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, > }; > #endif > -- > 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 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 17/30] avcodec/j2kenc: Fix leaks on init failure
On Tue, Sep 15, 2020 at 09:39:47AM +0200, Andreas Rheinhardt wrote: > The JPEG2000 encoder did not clean up after itself on error. > This commit fixes this by modifying the cleanup function to be able to > handle only partially allocated structures and by setting the > FF_CODEC_CAP_INIT_CLEANUP flag. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/j2kenc.c | 15 ++- > 1 file changed, 10 insertions(+), 5 deletions(-) > lgtm ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/4] ffmpeg: pass decoded or filtered AVFrame to output stream initialization
On 9/15/2020 1:21 PM, Jan Ekström wrote: > On Tue, Sep 15, 2020 at 5:28 PM Jan Ekström wrote: >> >> >> Further looking into this, it seems to come from filtering (?) (diff >> attached) >> >> decoded AVFrame: 128x128, pix_fmt: rgba, range: pc >> while... >> AVFrame to be encoded: 128x128, pix_fmt: bgra, range: tv >> >> Jan > > For the record, the culprit seems to be this piece of logic within > libavfilter/vf_scale.c: > http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavfilter/vf_scale.c;h=58eee967440657798f84383ec6f79e8a05c3ece0;hb=HEAD#l747 > > Only input has range defined, out_full never gets set to nonzero. > Thus, > out->color_range = out_full ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG > leads to AVCOL_RANGE_MPEG. Would changing that to out->color_range = scale->out_range help, or break things too much? > > Jan > ___ > 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 4/4] ffmpeg: pass decoded or filtered AVFrame to output stream initialization
On Tue, Sep 15, 2020 at 5:28 PM Jan Ekström wrote: > > > Further looking into this, it seems to come from filtering (?) (diff attached) > > decoded AVFrame: 128x128, pix_fmt: rgba, range: pc > while... > AVFrame to be encoded: 128x128, pix_fmt: bgra, range: tv > > Jan For the record, the culprit seems to be this piece of logic within libavfilter/vf_scale.c: http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavfilter/vf_scale.c;h=58eee967440657798f84383ec6f79e8a05c3ece0;hb=HEAD#l747 Only input has range defined, out_full never gets set to nonzero. Thus, out->color_range = out_full ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG leads to AVCOL_RANGE_MPEG. Jan ___ 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] Unrolls main loop of yuv2yuvX_sse3 and general code tidying for ~20% speedup
--- libswscale/x86/swscale.c | 138 --- 1 file changed, 72 insertions(+), 66 deletions(-) diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c index 3160fedf04..e47fee2bbd 100644 --- a/libswscale/x86/swscale.c +++ b/libswscale/x86/swscale.c @@ -201,76 +201,82 @@ static void yuv2yuvX_sse3(const int16_t *filter, int filterSize, const int16_t **src, uint8_t *dest, int dstW, const uint8_t *dither, int offset) { -if(((uintptr_t)dest) & 15){ +if(((uintptr_t)dest) & 31){ yuv2yuvX_mmxext(filter, filterSize, src, dest, dstW, dither, offset); return; } filterSize--; -#define MAIN_FUNCTION \ -"pxor %%xmm0, %%xmm0 \n\t" \ -"punpcklbw %%xmm0, %%xmm3 \n\t" \ -"movd %4, %%xmm1 \n\t" \ -"punpcklwd %%xmm1, %%xmm1 \n\t" \ -"punpckldq %%xmm1, %%xmm1 \n\t" \ -"punpcklqdq %%xmm1, %%xmm1 \n\t" \ -"psllw $3, %%xmm1 \n\t" \ -"paddw %%xmm1, %%xmm3 \n\t" \ -"psraw $4, %%xmm3 \n\t" \ -"movdqa %%xmm3, %%xmm4 \n\t" \ -"movdqa %%xmm3, %%xmm7 \n\t" \ -"movl %3, %%ecx \n\t" \ -"mov %0, %%"FF_REG_d"\n\t"\ -"mov(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\ -".p2align 4 \n\t" /* FIXME Unroll? */\ -"1: \n\t"\ -"movddup 8(%%"FF_REG_d"), %%xmm0 \n\t" /* filterCoeff */\ -"movdqa (%%"FF_REG_S", %%"FF_REG_c", 2), %%xmm2 \n\t" /* srcData */\ -"movdqa16(%%"FF_REG_S", %%"FF_REG_c", 2), %%xmm5 \n\t" /* srcData */\ -"add$16, %%"FF_REG_d"\n\t"\ -"mov(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\ -"test %%"FF_REG_S", %%"FF_REG_S" \n\t"\ -"pmulhw %%xmm0, %%xmm2 \n\t"\ -"pmulhw %%xmm0, %%xmm5 \n\t"\ -"paddw%%xmm2, %%xmm3 \n\t"\ -"paddw%%xmm5, %%xmm4 \n\t"\ -" jnz1b \n\t"\ -"psraw $3, %%xmm3 \n\t"\ -"psraw $3, %%xmm4 \n\t"\ -"packuswb %%xmm4, %%xmm3 \n\t"\ -"movntdq %%xmm3, (%1, %%"FF_REG_c") \n\t"\ -"add $16, %%"FF_REG_c"\n\t"\ -"cmp %2, %%"FF_REG_c"\n\t"\ -"movdqa %%xmm7, %%xmm3\n\t" \ -"movdqa %%xmm7, %%xmm4\n\t" \ -"mov %0, %%"FF_REG_d"\n\t"\ -"mov(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\ -"jb 1b \n\t" - -if (offset) { -__asm__ volatile( -"movq %5, %%xmm3 \n\t" -"movdqa%%xmm3, %%xmm4 \n\t" -"psrlq$24, %%xmm3 \n\t" -"psllq$40, %%xmm4 \n\t" -"por %%xmm4, %%xmm3 \n\t" -MAIN_FUNCTION - :: "g" (filter), - "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset), - "m"(filterSize), "m"(((uint64_t *) dither)[0]) - : XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" , "%xmm4" , "%xmm5" , "%xmm7" ,) -"%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_c - ); -} else { -__asm__ volatile( -"movq %5, %%xmm3 \n\t" -MAIN_FUNCTION - :: "g" (filter), - "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset), - "m"(filterSize), "m"(((uint64_t *) dither)[0]) - : XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" , "%xmm4" , "%xmm5" , "%xmm7" ,) -"%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_c - ); -} +__asm__ volatile( +"vmovq%5, %%xmm3\n\t" +"cmpl $0, %3\n\t" +"jz 2f\n\t" + +"# offset != 0 path.\n\t" +"vpsrlq $24, %%xmm3, %%xmm5\n\t" +"vpsllq $40, %%xmm3, %%xmm3\n\t" +"vpor %%xmm3, %%xmm5, %%xmm3\n\t" + +"2: \n\t" +"vpxor%%xmm0, %%xmm0, %%xmm0\n\t" +"mov(%0), %%"FF_REG_S" \n\t" +
Re: [FFmpeg-devel] [PATCH 4/4] ffmpeg: pass decoded or filtered AVFrame to output stream initialization
On Tue, Sep 15, 2020 at 1:06 PM Jan Ekström wrote: > > On Tue, Sep 15, 2020 at 10:54 AM Michael Niedermayer > wrote: > > > > On Sun, Sep 13, 2020 at 01:26:22PM +0300, Jan Ekström wrote: > > > Additionally, reap the first rewards by being able to set the > > > color related encoding values based on the passed AVFrame. > > > > > > The only tests that seem to have changed their results with this > > > change seem to be the MXF tests. There, the muxer writes the > > > limited/full range flag to the output container if the encoder > > > is not set to "unspecified". > > > --- > > > fftools/ffmpeg.c| 42 +++-- > > > tests/ref/lavf/mxf_d10 | 2 +- > > > tests/ref/lavf/mxf_dv25 | 2 +- > > > tests/ref/lavf/mxf_dvcpro50 | 2 +- > > > tests/ref/lavf/mxf_opatom | 2 +- > > > 5 files changed, 35 insertions(+), 15 deletions(-) > > > > This breaks: > > > > ./ffmpeg -i fate-suite//png1/lena-rgba.png -pix_fmt rgba -vcodec ljpeg > > -bitexact ljpeg.jpeg > > By applying some logging (patch follows), it seems like the AVFrame > incorrectly identifies itself as limited range: > AVFrame: 128x128, pix_fmt: bgra, range: tv > > Will have to see which filter does this, or if this is a general issue > when initializing AVFrames. > > Jan > > -->8 > diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c > index 8874da9268..27185441ff 100644 > --- a/fftools/ffmpeg.c > +++ b/fftools/ffmpeg.c > @@ -1124,6 +1124,13 @@ static void do_video_out(OutputFile *of, > InputStream *ist = NULL; > AVFilterContext *filter = ost->filter->filter; > > +if (next_picture) { > +const AVPixFmtDescriptor *desc = > av_pix_fmt_desc_get(next_picture->format); > +av_log(NULL, AV_LOG_VERBOSE, "AVFrame: %dx%d, pix_fmt: %s, > range: %s\n", > + next_picture->width, next_picture->height, > + desc->name, av_color_range_name(next_picture->color_range)); > +} > + > init_output_stream_wrapper(ost, next_picture, 1); > sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture); Further looking into this, it seems to come from filtering (?) (diff attached) decoded AVFrame: 128x128, pix_fmt: rgba, range: pc while... AVFrame to be encoded: 128x128, pix_fmt: bgra, range: tv Jan -->8 diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 8874da9268..f4af6cc71f 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1124,6 +1124,13 @@ static void do_video_out(OutputFile *of, InputStream *ist = NULL; AVFilterContext *filter = ost->filter->filter; +if (next_picture) { +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(next_picture->format); +av_log(NULL, AV_LOG_VERBOSE, "AVFrame to be encoded: %dx%d, pix_fmt: %s, range: %s\n", + next_picture->width, next_picture->height, + desc->name, av_color_range_name(next_picture->color_range)); +} + init_output_stream_wrapper(ost, next_picture, 1); sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture); @@ -2266,6 +2273,13 @@ static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacke if (ret >= 0) *got_frame = 1; +if (frame) { +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); +av_log(NULL, AV_LOG_VERBOSE, "decoded AVFrame: %dx%d, pix_fmt: %s, range: %s\n", + frame->width, frame->height, + desc ? desc->name : "unknown", av_color_range_name(frame->color_range)); +} + return 0; } ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avcodec/libdav1d: parse sequence headers in extradata if available
This allows the decoder context to be initialized with all stream parameters before a packet is parsed. Signed-off-by: James Almer --- libavcodec/libdav1d.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index 1b9289824f..13673ae2dc 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -191,6 +191,17 @@ static av_cold int libdav1d_init(AVCodecContext *c) if (res < 0) return AVERROR(ENOMEM); +if (c->extradata && c->extradata_size) { +res = dav1d_parse_sequence_header(, c->extradata, c->extradata_size); +if (res < 0) +return AVERROR_INVALIDDATA; + +libdav1d_init_params(c, ); +res = ff_set_dimensions(c, seq.max_width, seq.max_height); +if (res < 0) +return res; +} + return 0; } -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2 v3] avcodec/packet: move AVPacketList definition and function helpers over from libavformat
On 9/11/2020 5:06 PM, James Almer wrote: > On 9/7/2020 11:31 AM, James Almer wrote: >> And replace the flags parameter with a function callback that can be used to >> copy the contents of the packet (e.g, av_packet_ref and >> av_packet_copy_props). >> >> Signed-off-by: James Almer >> --- >> This version achieves the same effect as v2 while being cleaner. >> I could leave the flags parameter, too, for the sake of keeping the function >> easily extensible without having to wait for a major bump. > > I'll do the above and push the set soon. Pushed. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avcodec/libdav1d: use ff_decode_frame_props() to fill frame properties
The main benefit comes from propagating container level metadata like hdr, which is more commonly used than the relevant Metadata OBUs. Signed-off-by: James Almer --- libavcodec/libdav1d.c | 94 +-- 1 file changed, 46 insertions(+), 48 deletions(-) diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index 3af7ef4edc..1b9289824f 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -119,9 +119,45 @@ static void libdav1d_picture_release(Dav1dPicture *p, void *cookie) av_buffer_unref(); } +static void libdav1d_init_params(AVCodecContext *c, Dav1dSequenceHeader *seq) +{ +c->profile = seq->profile; +c->level = ((seq->operating_points[0].major_level - 2) << 2) + | seq->operating_points[0].minor_level; + +switch (seq->chr) { +case DAV1D_CHR_VERTICAL: +c->chroma_sample_location = AVCHROMA_LOC_LEFT; +break; +case DAV1D_CHR_COLOCATED: +c->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; +break; +} +c->colorspace = (enum AVColorSpace) seq->mtrx; +c->color_primaries = (enum AVColorPrimaries) seq->pri; +c->color_trc = (enum AVColorTransferCharacteristic) seq->trc; +c->color_range = seq->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; + +if (seq->layout == DAV1D_PIXEL_LAYOUT_I444 && +seq->mtrx == DAV1D_MC_IDENTITY && +seq->pri == DAV1D_COLOR_PRI_BT709 && +seq->trc == DAV1D_TRC_SRGB) +c->pix_fmt = pix_fmt_rgb[seq->hbd]; +else +c->pix_fmt = pix_fmt[seq->layout][seq->hbd]; + +if (seq->num_units_in_tick && seq->time_scale) { +av_reduce(>framerate.den, >framerate.num, + seq->num_units_in_tick, seq->time_scale, INT_MAX); +if (seq->equal_picture_interval) +c->ticks_per_frame = seq->num_ticks_per_picture; +} +} + static av_cold int libdav1d_init(AVCodecContext *c) { Libdav1dContext *dav1d = c->priv_data; +Dav1dSequenceHeader seq; Dav1dSettings s; int threads = (c->thread_count ? c->thread_count : av_cpu_count()) * 3 / 2; int res; @@ -198,10 +234,6 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) return res; } -data->m.timestamp = pkt.pts; -data->m.offset = pkt.pos; -data->m.duration = pkt.duration; - pkt.buf = NULL; av_packet_unref(); @@ -258,9 +290,11 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) frame->linesize[1] = p->stride[1]; frame->linesize[2] = p->stride[1]; -c->profile = p->seq_hdr->profile; -c->level = ((p->seq_hdr->operating_points[0].major_level - 2) << 2) - | p->seq_hdr->operating_points[0].minor_level; +libdav1d_init_params(c, p->seq_hdr); +res = ff_decode_frame_props(c, frame); +if (res < 0) +goto fail; + frame->width = p->p.w; frame->height = p->p.h; if (c->width != p->p.w || c->height != p->p.h) { @@ -276,50 +310,12 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) INT_MAX); ff_set_sar(c, frame->sample_aspect_ratio); -switch (p->seq_hdr->chr) { -case DAV1D_CHR_VERTICAL: -frame->chroma_location = c->chroma_sample_location = AVCHROMA_LOC_LEFT; -break; -case DAV1D_CHR_COLOCATED: -frame->chroma_location = c->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; -break; -} -frame->colorspace = c->colorspace = (enum AVColorSpace) p->seq_hdr->mtrx; -frame->color_primaries = c->color_primaries = (enum AVColorPrimaries) p->seq_hdr->pri; -frame->color_trc = c->color_trc = (enum AVColorTransferCharacteristic) p->seq_hdr->trc; -frame->color_range = c->color_range = p->seq_hdr->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; - -if (p->p.layout == DAV1D_PIXEL_LAYOUT_I444 && -p->seq_hdr->mtrx == DAV1D_MC_IDENTITY && -p->seq_hdr->pri == DAV1D_COLOR_PRI_BT709 && -p->seq_hdr->trc == DAV1D_TRC_SRGB) -frame->format = c->pix_fmt = pix_fmt_rgb[p->seq_hdr->hbd]; -else -frame->format = c->pix_fmt = pix_fmt[p->p.layout][p->seq_hdr->hbd]; - if (p->m.user_data.data) memcpy(>reordered_opaque, p->m.user_data.data, sizeof(frame->reordered_opaque)); else frame->reordered_opaque = AV_NOPTS_VALUE; -if (p->seq_hdr->num_units_in_tick && p->seq_hdr->time_scale) { -av_reduce(>framerate.den, >framerate.num, - p->seq_hdr->num_units_in_tick, p->seq_hdr->time_scale, INT_MAX); -if (p->seq_hdr->equal_picture_interval) -c->ticks_per_frame = p->seq_hdr->num_ticks_per_picture; -} - -// match timestamps and packet size -frame->pts = frame->best_effort_timestamp = p->m.timestamp; -#if FF_API_PKT_PTS -FF_DISABLE_DEPRECATION_WARNINGS -frame->pkt_pts = p->m.timestamp; -FF_ENABLE_DEPRECATION_WARNINGS -#endif -
Re: [FFmpeg-devel] [PATCH] avformat/aviobuf: realloc memory in ffio_ensure_seekback()
Paul B Mahol (12020-09-15): > It leaks nothing in case of failure. > In case of failure old memory is kept and > seeking back will fail and thus give errors when syncing. My bad, it was a common pattern, but avoided here. -- Nicolas George 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] avformat/aviobuf: realloc memory in ffio_ensure_seekback()
On Tue, Sep 15, 2020 at 01:39:45PM +0200, Nicolas George wrote: > Paul B Mahol (12020-09-15): > > This removes big CPU overhead for demuxing chained ogg streams. > > > > Signed-off-by: Paul B Mahol > > --- > > libavformat/aviobuf.c | 5 ++--- > > 1 file changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c > > index a77517d712..6d01150f66 100644 > > --- a/libavformat/aviobuf.c > > +++ b/libavformat/aviobuf.c > > @@ -1005,12 +1005,11 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t > > buf_size) > > return 0; > > av_assert0(!s->write_flag); > > > > -buffer = av_malloc(buf_size); > > +buffer = s->buffer; > > > +buffer = av_realloc(buffer, buf_size); > > if (!buffer) > > return AVERROR(ENOMEM); > > Leaks in case of failure. It leaks nothing in case of failure. In case of failure old memory is kept and seeking back will fail and thus give errors when syncing. > > > > > -memcpy(buffer, s->buffer, filled); > > -av_free(s->buffer); > > s->buf_ptr = buffer + (s->buf_ptr - s->buffer); > > s->buf_end = buffer + (s->buf_end - s->buffer); > > s->buffer = buffer; > > -- > Nicolas George > ___ > 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] avformat/aviobuf: realloc memory in ffio_ensure_seekback()
Paul B Mahol (12020-09-15): > This removes big CPU overhead for demuxing chained ogg streams. > > Signed-off-by: Paul B Mahol > --- > libavformat/aviobuf.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c > index a77517d712..6d01150f66 100644 > --- a/libavformat/aviobuf.c > +++ b/libavformat/aviobuf.c > @@ -1005,12 +1005,11 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t > buf_size) > return 0; > av_assert0(!s->write_flag); > > -buffer = av_malloc(buf_size); > +buffer = s->buffer; > +buffer = av_realloc(buffer, buf_size); > if (!buffer) > return AVERROR(ENOMEM); Leaks in case of failure. > > -memcpy(buffer, s->buffer, filled); > -av_free(s->buffer); > s->buf_ptr = buffer + (s->buf_ptr - s->buffer); > s->buf_end = buffer + (s->buf_end - s->buffer); > s->buffer = buffer; -- Nicolas George 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] avformat/aviobuf: realloc memory in ffio_ensure_seekback()
This removes big CPU overhead for demuxing chained ogg streams. Signed-off-by: Paul B Mahol --- libavformat/aviobuf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index a77517d712..6d01150f66 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1005,12 +1005,11 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size) return 0; av_assert0(!s->write_flag); -buffer = av_malloc(buf_size); +buffer = s->buffer; +buffer = av_realloc(buffer, buf_size); if (!buffer) return AVERROR(ENOMEM); -memcpy(buffer, s->buffer, filled); -av_free(s->buffer); s->buf_ptr = buffer + (s->buf_ptr - s->buffer); s->buf_end = buffer + (s->buf_end - s->buffer); s->buffer = buffer; -- 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 4/4] ffmpeg: pass decoded or filtered AVFrame to output stream initialization
On Tue, Sep 15, 2020 at 10:54 AM Michael Niedermayer wrote: > > On Sun, Sep 13, 2020 at 01:26:22PM +0300, Jan Ekström wrote: > > Additionally, reap the first rewards by being able to set the > > color related encoding values based on the passed AVFrame. > > > > The only tests that seem to have changed their results with this > > change seem to be the MXF tests. There, the muxer writes the > > limited/full range flag to the output container if the encoder > > is not set to "unspecified". > > --- > > fftools/ffmpeg.c| 42 +++-- > > tests/ref/lavf/mxf_d10 | 2 +- > > tests/ref/lavf/mxf_dv25 | 2 +- > > tests/ref/lavf/mxf_dvcpro50 | 2 +- > > tests/ref/lavf/mxf_opatom | 2 +- > > 5 files changed, 35 insertions(+), 15 deletions(-) > > This breaks: > > ./ffmpeg -i fate-suite//png1/lena-rgba.png -pix_fmt rgba -vcodec ljpeg > -bitexact ljpeg.jpeg By applying some logging (patch follows), it seems like the AVFrame incorrectly identifies itself as limited range: AVFrame: 128x128, pix_fmt: bgra, range: tv Will have to see which filter does this, or if this is a general issue when initializing AVFrames. Jan -->8 diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 8874da9268..27185441ff 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1124,6 +1124,13 @@ static void do_video_out(OutputFile *of, InputStream *ist = NULL; AVFilterContext *filter = ost->filter->filter; +if (next_picture) { +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(next_picture->format); +av_log(NULL, AV_LOG_VERBOSE, "AVFrame: %dx%d, pix_fmt: %s, range: %s\n", + next_picture->width, next_picture->height, + desc->name, av_color_range_name(next_picture->color_range)); +} + init_output_stream_wrapper(ost, next_picture, 1); sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture); ___ 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 23/30] avcodec/motionpixels: Cleanup generically after init failure
On Tue, Sep 15, 2020 at 09:39:53AM +0200, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/motionpixels.c | 11 +++ > 1 file changed, 3 insertions(+), 8 deletions(-) > looks ok. > diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c > index 6cb444a703..b48200b017 100644 > --- a/libavcodec/motionpixels.c > +++ b/libavcodec/motionpixels.c > @@ -81,19 +81,13 @@ static av_cold int mp_decode_init(AVCodecContext *avctx) > mp->offset_bits_len = av_log2(avctx->width * avctx->height) + 1; > mp->vpt = av_mallocz_array(avctx->height, sizeof(YuvPixel)); > mp->hpt = av_mallocz_array(h4 / 4, w4 / 4 * sizeof(YuvPixel)); > -if (!mp->changes_map || !mp->vpt || !mp->hpt) { > -av_freep(>changes_map); > -av_freep(>vpt); > -av_freep(>hpt); > +if (!mp->changes_map || !mp->vpt || !mp->hpt) > return AVERROR(ENOMEM); > -} > avctx->pix_fmt = AV_PIX_FMT_RGB555; > > mp->frame = av_frame_alloc(); > -if (!mp->frame) { > -mp_decode_end(avctx); > +if (!mp->frame) > return AVERROR(ENOMEM); > -} > > return 0; > } > @@ -354,4 +348,5 @@ AVCodec ff_motionpixels_decoder = { > .close = mp_decode_end, > .decode = mp_decode_frame, > .capabilities = AV_CODEC_CAP_DR1, > +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, > }; > -- > 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 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 07/30] avcodec/gif: Fix leaks upon allocation error
On Tue, Sep 15, 2020 at 09:39:37AM +0200, Andreas Rheinhardt wrote: > If one of several allocations the gif encoder performs in its init > function fails, the successfull allocations leak. Fix this by adding the > FF_CODEC_CAP_INIT_CLEANUP. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/gif.c | 1 + > 1 file changed, 1 insertion(+) ok > > diff --git a/libavcodec/gif.c b/libavcodec/gif.c > index 65a76cfde4..de41992851 100644 > --- a/libavcodec/gif.c > +++ b/libavcodec/gif.c > @@ -497,4 +497,5 @@ AVCodec ff_gif_encoder = { > AV_PIX_FMT_GRAY8, AV_PIX_FMT_PAL8, AV_PIX_FMT_NONE > }, > .priv_class = _class, > +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, > }; > -- > 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 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 22/30] avcodec/mobiclip: Fix heap-buffer-overflow
On Tue, Sep 15, 2020 at 09:39:52AM +0200, Andreas Rheinhardt wrote: > The MobiClip decoder uses adjacent pixels for prediction; yet when > accessing the left pixel, it was forgotten to clip the x coordinate. > This results in an heap-buffer-overflow. It can e.g. be reproduced with > the sample from https://samples.ffmpeg.org/V-codecs/MOHD/crap.avi when > forcing the video decoder to mobiclip. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/mobiclip.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > ok > diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c > index 8758e7f617..47387fce90 100644 > --- a/libavcodec/mobiclip.c > +++ b/libavcodec/mobiclip.c > @@ -905,7 +905,7 @@ static int predict_intra(AVCodecContext *avctx, AVFrame > *frame, int ax, int ay, > int arr1[16]; > int arr2[16]; > uint8_t *top = frame->data[plane] + FFMAX(ay - 1, 0) * > frame->linesize[plane] + ax; > -uint8_t *left = frame->data[plane] + ay * frame->linesize[plane] > + ax - 1; > +uint8_t *left = frame->data[plane] + ay * frame->linesize[plane] > + FFMAX(ax - 1, 0); > int bottommost = frame->data[plane][(ay + size - 1) * > frame->linesize[plane] + FFMAX(ax - 1, 0)]; > int rightmost = frame->data[plane][FFMAX(ay - 1, 0) * > frame->linesize[plane] + ax + size - 1]; > int avg = (bottommost + rightmost + 1) / 2 + 2 * > get_se_golomb(gb); > -- > 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 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 21/30] avcodec/mobiclip: Fix memleak upon init failure
On Tue, Sep 15, 2020 at 09:39:51AM +0200, Andreas Rheinhardt wrote: > If an error happens during init after an allocation has succeeded, > the already allocated data leaked up until now. Fix this by setting the > FF_CODEC_CAP_INIT_CLEANUP flag. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/mobiclip.c | 1 + > 1 file changed, 1 insertion(+) > ok > diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c > index 25a7f0ed14..8758e7f617 100644 > --- a/libavcodec/mobiclip.c > +++ b/libavcodec/mobiclip.c > @@ -1436,4 +1436,5 @@ AVCodec ff_mobiclip_decoder = { > .flush = mobiclip_flush, > .close = mobiclip_close, > .capabilities = AV_CODEC_CAP_DR1, > +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, > }; > -- > 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 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 19/30] avcodec/magicyuvenc: Fix memleak upon init failure
On Tue, Sep 15, 2020 at 09:39:49AM +0200, Andreas Rheinhardt wrote: > If an error happens during init after an allocation has succeeded, > the already allocated data leaked up until now. Fix this by setting the > FF_CODEC_CAP_INIT_CLEANUP flag. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/magicyuvenc.c | 1 + > 1 file changed, 1 insertion(+) ok > > diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c > index e9fe3bf519..0bd6b8ef6a 100644 > --- a/libavcodec/magicyuvenc.c > +++ b/libavcodec/magicyuvenc.c > @@ -587,4 +587,5 @@ AVCodec ff_magicyuv_encoder = { >AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, > AV_PIX_FMT_YUVA444P, AV_PIX_FMT_GRAY8, >AV_PIX_FMT_NONE >}, > +.caps_internal= FF_CODEC_CAP_INIT_CLEANUP, > }; > -- > 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 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 08/30] avcodec/hcom: Cleanup generically upon init failure
On Tue, Sep 15, 2020 at 09:39:38AM +0200, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/hcom.c | 9 +++-- > 1 file changed, 3 insertions(+), 6 deletions(-) probably ok > > diff --git a/libavcodec/hcom.c b/libavcodec/hcom.c > index 8300676f98..06fa25fcd2 100644 > --- a/libavcodec/hcom.c > +++ b/libavcodec/hcom.c > @@ -67,15 +67,11 @@ static av_cold int hcom_init(AVCodecContext *avctx) > if (s->dict[i].l >= 0 && > (s->dict[i].l >= s->dict_entries || > s->dict[i].r >= s->dict_entries || > - s->dict[i].r < 0 )) { > -av_freep(>dict); > + s->dict[i].r < 0 )) > return AVERROR_INVALIDDATA; > -} > } > -if (s->dict[0].l < 0) { > -av_freep(>dict); > +if (s->dict[0].l < 0) > return AVERROR_INVALIDDATA; > -} > > avctx->sample_fmt = AV_SAMPLE_FMT_U8; > s->dict_entry = 0; > @@ -148,4 +144,5 @@ AVCodec ff_hcom_decoder = { > .close = hcom_close, > .decode = hcom_decode, > .capabilities = AV_CODEC_CAP_DR1, > +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, > }; > -- > 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 mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 2/2] dnn_backend_native_layer_conv2d.c: refine code.
From: Xu Jun Move thread area allocate out of thread function into main thread. Signed-off-by: Xu Jun --- v2: fix build warnings .../dnn/dnn_backend_native_layer_conv2d.c | 44 +-- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c index 5ed1851512..134016be34 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c @@ -33,12 +33,11 @@ typedef struct thread_common_param{ const void *parameters; NativeContext *ctx; float *output_data; -int thread_num; } thread_common_param; typedef struct thread_param{ thread_common_param *thread_common_param; -int thread_index; +int thread_start, thread_end; } thread_param; int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) @@ -113,7 +112,6 @@ static void * dnn_execute_layer_conv2d_thread(void *threadarg) thread_common_param *thread_common_param = thread_param->thread_common_param; DnnOperand *operands = thread_common_param->operands; int32_t input_operand_index = thread_common_param->input_operand_indexes[0]; -int number = operands[input_operand_index].dims[0]; int height = operands[input_operand_index].dims[1]; int width = operands[input_operand_index].dims[2]; int channel = operands[input_operand_index].dims[3]; @@ -126,16 +124,12 @@ static void * dnn_execute_layer_conv2d_thread(void *threadarg) int filter_size = conv_params->kernel_size * filter_linesize; int pad_size = (conv_params->padding_method == VALID) ? (conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0; -int thread_stride = (height - pad_size * 2) / thread_common_param->thread_num; -int thread_start = thread_stride * thread_param->thread_index + pad_size; -int thread_end = (thread_param->thread_index == thread_common_param->thread_num - 1) ? (height - pad_size) : (thread_start + thread_stride); - float *output = thread_common_param->output_data; -output += (conv_params->output_num) * (width - 2 * pad_size) * (thread_start - pad_size); +output += (conv_params->output_num) * (width - 2 * pad_size) * (thread_param->thread_start - pad_size); av_assert0(channel == conv_params->input_num); -for (int y = thread_start; y < thread_end; ++y) { +for (int y = thread_param->thread_start; y < thread_param->thread_end; ++y) { for (int x = pad_size; x < width - pad_size; ++x) { for (int n_filter = 0; n_filter < conv_params->output_num; ++n_filter) { if (conv_params->has_bias) @@ -194,24 +188,20 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ ? (av_cpu_count() + 1) : (ctx->options.conv2d_threads); #if HAVE_PTHREAD_CANCEL pthread_t *thread_id = av_malloc(thread_num * sizeof(pthread_t)); +int thread_stride; #endif thread_param **thread_param = av_malloc(thread_num * sizeof(*thread_param)); - -//struct used to pass parameters thread_common_param thread_common_param; -thread_common_param.operands = operands; -thread_common_param.input_operand_indexes = input_operand_indexes; -thread_common_param.output_operand_index = output_operand_index; -thread_common_param.parameters = parameters; -thread_common_param.ctx = ctx; //alloc memory const ConvolutionalParams *conv_params = (const ConvolutionalParams *)(parameters); +int height = operands[input_operand_indexes[0]].dims[1]; +int width = operands[input_operand_indexes[0]].dims[2]; int pad_size = (conv_params->padding_method == VALID) ? (conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0; DnnOperand *output_operand = [output_operand_index]; output_operand->dims[0] = operands[input_operand_indexes[0]].dims[0]; -output_operand->dims[1] = operands[input_operand_indexes[0]].dims[1] - pad_size * 2; -output_operand->dims[2] = operands[input_operand_indexes[0]].dims[2] - pad_size * 2; +output_operand->dims[1] = height - pad_size * 2; +output_operand->dims[2] = width - pad_size * 2; output_operand->dims[3] = conv_params->output_num; output_operand->data_type = operands[input_operand_indexes[0]].data_type; output_operand->length = calculate_operand_data_length(output_operand); @@ -224,16 +214,22 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); return DNN_ERROR; } + thread_common_param.output_data = output_operand->data; +thread_common_param.operands = operands; +thread_common_param.input_operand_indexes = input_operand_indexes; +thread_common_param.output_operand_index = output_operand_index; +thread_common_param.parameters =
[FFmpeg-devel] [PATCH v2 1/2] dnn_backend_native_layer_conv2d.c: fix memory allocation bug in multithread function.
From: Xu Jun Before patch, memory was allocated in each thread functions, which may cause more than one time of memory allocation and cause crash. After patch, memory is allocated in the main thread once, an index was parsed into thread functions. Bug fixed. Signed-off-by: Xu Jun --- .../dnn/dnn_backend_native_layer_conv2d.c | 55 +-- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c index c52725aa2b..5ed1851512 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c @@ -32,6 +32,7 @@ typedef struct thread_common_param{ int32_t output_operand_index; const void *parameters; NativeContext *ctx; +float *output_data; int thread_num; } thread_common_param; @@ -111,7 +112,6 @@ static void * dnn_execute_layer_conv2d_thread(void *threadarg) thread_param *thread_param = (struct thread_param *)threadarg; thread_common_param *thread_common_param = thread_param->thread_common_param; DnnOperand *operands = thread_common_param->operands; -float *output; int32_t input_operand_index = thread_common_param->input_operand_indexes[0]; int number = operands[input_operand_index].dims[0]; int height = operands[input_operand_index].dims[1]; @@ -130,24 +130,7 @@ static void * dnn_execute_layer_conv2d_thread(void *threadarg) int thread_start = thread_stride * thread_param->thread_index + pad_size; int thread_end = (thread_param->thread_index == thread_common_param->thread_num - 1) ? (height - pad_size) : (thread_start + thread_stride); -DnnOperand *output_operand = [thread_common_param->output_operand_index]; -output_operand->dims[0] = number; -output_operand->dims[1] = height - pad_size * 2; -output_operand->dims[2] = width - pad_size * 2; -output_operand->dims[3] = conv_params->output_num; -output_operand->data_type = operands[input_operand_index].data_type; -output_operand->length = calculate_operand_data_length(output_operand); -if (output_operand->length <= 0) { -av_log(thread_common_param->ctx, AV_LOG_ERROR, "The output data length overflow\n"); -return (void *)DNN_ERROR; -} -output_operand->data = av_realloc(output_operand->data, output_operand->length); -if (!output_operand->data) { -av_log(thread_common_param->ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); -return (void *)DNN_ERROR; -} - -output = output_operand->data; +float *output = thread_common_param->output_data; output += (conv_params->output_num) * (width - 2 * pad_size) * (thread_start - pad_size); av_assert0(channel == conv_params->input_num); @@ -213,8 +196,6 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ pthread_t *thread_id = av_malloc(thread_num * sizeof(pthread_t)); #endif thread_param **thread_param = av_malloc(thread_num * sizeof(*thread_param)); -void *res; -int error_flag = DNN_SUCCESS; //struct used to pass parameters thread_common_param thread_common_param; @@ -223,6 +204,28 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ thread_common_param.output_operand_index = output_operand_index; thread_common_param.parameters = parameters; thread_common_param.ctx = ctx; + +//alloc memory +const ConvolutionalParams *conv_params = (const ConvolutionalParams *)(parameters); +int pad_size = (conv_params->padding_method == VALID) ? (conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0; +DnnOperand *output_operand = [output_operand_index]; +output_operand->dims[0] = operands[input_operand_indexes[0]].dims[0]; +output_operand->dims[1] = operands[input_operand_indexes[0]].dims[1] - pad_size * 2; +output_operand->dims[2] = operands[input_operand_indexes[0]].dims[2] - pad_size * 2; +output_operand->dims[3] = conv_params->output_num; +output_operand->data_type = operands[input_operand_indexes[0]].data_type; +output_operand->length = calculate_operand_data_length(output_operand); +if (output_operand->length <= 0) { +av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); +return DNN_ERROR; +} +output_operand->data = av_realloc(output_operand->data, output_operand->length); +if (!output_operand->data) { +av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); +return DNN_ERROR; +} +thread_common_param.output_data = output_operand->data; + #if HAVE_PTHREAD_CANCEL thread_common_param.thread_num = thread_num; @@ -236,9 +239,7 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ //join threads, res gets function return for (int i = 0; i < thread_num; i++){ -
Re: [FFmpeg-devel] [PATCH 4/4] ffmpeg: pass decoded or filtered AVFrame to output stream initialization
On Sun, Sep 13, 2020 at 01:26:22PM +0300, Jan Ekström wrote: > Additionally, reap the first rewards by being able to set the > color related encoding values based on the passed AVFrame. > > The only tests that seem to have changed their results with this > change seem to be the MXF tests. There, the muxer writes the > limited/full range flag to the output container if the encoder > is not set to "unspecified". > --- > fftools/ffmpeg.c| 42 +++-- > tests/ref/lavf/mxf_d10 | 2 +- > tests/ref/lavf/mxf_dv25 | 2 +- > tests/ref/lavf/mxf_dvcpro50 | 2 +- > tests/ref/lavf/mxf_opatom | 2 +- > 5 files changed, 35 insertions(+), 15 deletions(-) This breaks: ./ffmpeg -i fate-suite//png1/lena-rgba.png -pix_fmt rgba -vcodec ljpeg -bitexact ljpeg.jpeg [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Elect your leaders based on what they did after the last election, not based on what they say before an election. 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 03/30] avcodec/flashsv2enc: Check allocations for success before usage
Signed-off-by: Andreas Rheinhardt --- libavcodec/flashsv2enc.c | 15 +++ 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c index 65db112696..e2a603f312 100644 --- a/libavcodec/flashsv2enc.c +++ b/libavcodec/flashsv2enc.c @@ -231,6 +231,13 @@ static av_cold int flashsv2_encode_init(AVCodecContext * avctx) s->key_frame = av_mallocz(s->frame_size); s->frame_blocks = av_mallocz(s->blocks_size); s->key_blocks= av_mallocz(s->blocks_size); +if (!s->encbuffer || !s->keybuffer || !s->databuffer +|| !s->current_frame || !s->key_frame || !s->key_blocks +|| !s->frame_blocks) { +av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n"); +cleanup(s); +return AVERROR(ENOMEM); +} s->blockbuffer = NULL; s->blockbuffer_size = 0; @@ -245,14 +252,6 @@ static av_cold int flashsv2_encode_init(AVCodecContext * avctx) s->use_custom_palette = 0; s->palette_type = -1;// so that the palette will be generated in reconfigure_at_keyframe -if (!s->encbuffer || !s->keybuffer || !s->databuffer -|| !s->current_frame || !s->key_frame || !s->key_blocks -|| !s->frame_blocks) { -av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n"); -cleanup(s); -return -1; -} - 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 05/30] avcodec/flashsv2enc: Return better error codes
Signed-off-by: Andreas Rheinhardt --- libavcodec/flashsv2enc.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c index 851abdc822..6603d0ded1 100644 --- a/libavcodec/flashsv2enc.c +++ b/libavcodec/flashsv2enc.c @@ -177,6 +177,7 @@ static void reset_stats(FlashSV2Context * s) static av_cold int flashsv2_encode_init(AVCodecContext * avctx) { FlashSV2Context *s = avctx->priv_data; +int ret; s->avctx = avctx; @@ -186,23 +187,23 @@ static av_cold int flashsv2_encode_init(AVCodecContext * avctx) if (s->comp < 0 || s->comp > 9) { av_log(avctx, AV_LOG_ERROR, "Compression level should be 0-9, not %d\n", s->comp); -return -1; +return AVERROR(EINVAL); } if ((avctx->width > 4095) || (avctx->height > 4095)) { av_log(avctx, AV_LOG_ERROR, "Input dimensions too large, input must be max 4095x4095 !\n"); -return -1; +return AVERROR(EINVAL); } if ((avctx->width < 16) || (avctx->height < 16)) { av_log(avctx, AV_LOG_ERROR, "Input dimensions too small, input must be at least 16x16 !\n"); -return -1; +return AVERROR(EINVAL); } -if (av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) -return -1; +if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0) +return ret; s->last_key_frame = 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 02/30] avcodec/flashsvenc: Remove unused z_stream
This encoder uses the compress2 utility function provided by zlib instead of using a z_stream. Signed-off-by: Andreas Rheinhardt --- libavcodec/flashsvenc.c | 7 --- 1 file changed, 7 deletions(-) diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index 4ac643c036..95ae988448 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -61,7 +61,6 @@ typedef struct FlashSVContext { int block_width, block_height; uint8_t*encbuffer; int block_size; -z_streamzstream; int last_key_frame; uint8_t tmpblock[3 * 256 * 256]; } FlashSVContext; @@ -92,8 +91,6 @@ static av_cold int flashsv_encode_end(AVCodecContext *avctx) { FlashSVContext *s = avctx->priv_data; -deflateEnd(>zstream); - av_freep(>encbuffer); av_freep(>previous_frame); @@ -112,9 +109,6 @@ static av_cold int flashsv_encode_init(AVCodecContext *avctx) return AVERROR_INVALIDDATA; } -// Needed if zlib unused or init aborted before deflateInit -memset(>zstream, 0, sizeof(z_stream)); - s->last_key_frame = 0; s->image_width = avctx->width; @@ -180,7 +174,6 @@ static int encode_bitstream(FlashSVContext *s, const AVFrame *p, uint8_t *buf, ret = compress2(ptr + 2, , s->tmpblock, 3 * cur_blk_width * cur_blk_height, 9); -//ret = deflateReset(>zstream); if (ret != Z_OK) av_log(s->avctx, AV_LOG_ERROR, "error while compressing block %dx%d\n", i, j); -- 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 04/30] avcodec/flashsv2enc: Cleanup generically after init failure
Signed-off-by: Andreas Rheinhardt --- libavcodec/flashsv2enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c index e2a603f312..851abdc822 100644 --- a/libavcodec/flashsv2enc.c +++ b/libavcodec/flashsv2enc.c @@ -235,7 +235,6 @@ static av_cold int flashsv2_encode_init(AVCodecContext * avctx) || !s->current_frame || !s->key_frame || !s->key_blocks || !s->frame_blocks) { av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n"); -cleanup(s); return AVERROR(ENOMEM); } @@ -918,4 +917,5 @@ AVCodec ff_flashsv2_encoder = { .encode2= flashsv2_encode_frame, .close = flashsv2_encode_end, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24, AV_PIX_FMT_NONE }, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -- 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 30/30] avcodec/mpegaudiodec*: Cleanup generically on init failure
Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_fixed.c| 1 + libavcodec/mpegaudiodec_float.c| 1 + libavcodec/mpegaudiodec_template.c | 9 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libavcodec/mpegaudiodec_fixed.c b/libavcodec/mpegaudiodec_fixed.c index ad7ceb20b6..a2c433954b 100644 --- a/libavcodec/mpegaudiodec_fixed.c +++ b/libavcodec/mpegaudiodec_fixed.c @@ -116,5 +116,6 @@ AVCodec ff_mp3on4_decoder = { .flush = flush_mp3on4, .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; #endif diff --git a/libavcodec/mpegaudiodec_float.c b/libavcodec/mpegaudiodec_float.c index 0defdf3af1..4aa52d4f53 100644 --- a/libavcodec/mpegaudiodec_float.c +++ b/libavcodec/mpegaudiodec_float.c @@ -116,5 +116,6 @@ AVCodec ff_mp3on4float_decoder = { .flush = flush_mp3on4, .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; #endif diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index 8ed2f74eee..68e6dbfdf8 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -1906,16 +1906,14 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) // Allocate zeroed memory for the decoder contexts s->mp3decctx = av_mallocz_array(sizeof(MPADecodeContext), s->frames); if (!s->mp3decctx) -goto alloc_fail; +return AVERROR(ENOMEM); // Put decoder context in place to make init_decode() happy avctx->priv_data = s->mp3decctx; ret = decode_init(avctx); // Restore mp3on4 context pointer avctx->priv_data = s; -if (ret < 0) { -decode_close_mp3on4(avctx); +if (ret < 0) return ret; -} s->mp3decctx[0].adu_mode = 1; // Set adu mode /* Create a separate codec/context for each frame (first is already ok). @@ -1929,9 +1927,6 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) } return 0; -alloc_fail: -decode_close_mp3on4(avctx); -return AVERROR(ENOMEM); } -- 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 24/30] avcodec/mpc7data: Make overlong array smaller
Signed-off-by: Andreas Rheinhardt --- libavcodec/mpc7data.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpc7data.h b/libavcodec/mpc7data.h index 5609e8fbf3..90ab75fe65 100644 --- a/libavcodec/mpc7data.h +++ b/libavcodec/mpc7data.h @@ -51,7 +51,7 @@ static const uint8_t mpc7_hdr[MPC7_HDR_SIZE * 2] = { }; #define MPC7_QUANT_VLC_TABLES 7 -static const uint8_t mpc7_quant_vlc_sizes[MPC7_QUANT_VLC_TABLES * 2] = { +static const uint8_t mpc7_quant_vlc_sizes[MPC7_QUANT_VLC_TABLES] = { 27, 25, 7, 9, 15, 31, 63 }; -- 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 26/30] avcodec/mpc7, mpc7data: Avoid gaps in array
The Musepack decoder uses static VLC tables to parse the bitstream. There are 14 different quant tables VLCs and each of them has a varying number of codes. The maximum number is 63, the average number is 25.3. Up until now, the array containing the raw data was of type uint16_t [7][2][64 * 2] (the 14 tables come in pairs of two, hence [7][2] instead of [14]) and from this it follows that there were large gaps in said array. This commit changes this by making it a continuous array instead. Doing so saves about 2KB. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpc7.c | 17 ++ libavcodec/mpc7data.h | 76 +-- 2 files changed, 32 insertions(+), 61 deletions(-) diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index 8518bc2f8a..4a4f8cf616 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -38,10 +38,9 @@ static VLC scfi_vlc, dscf_vlc, hdr_vlc, quant_vlc[MPC7_QUANT_VLC_TABLES][2]; -static const uint16_t quant_offsets[MPC7_QUANT_VLC_TABLES*2 + 1] = +static const uint16_t quant_sizes[MPC7_QUANT_VLC_TABLES*2] = { - 0, 512, 1024, 1536, 2052, 2564, 3076, 3588, 4100, 4612, 5124, - 5636, 6164, 6676, 7224 +512, 512, 512, 516, 512, 512, 512, 512, 512, 512, 512, 528, 512, 548 }; @@ -54,6 +53,8 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) static int vlc_initialized = 0; static VLC_TYPE quant_tables[7224][2]; +VLC_TYPE (*quant_table)[2] = quant_tables; +const uint16_t *raw_quant_table = mpc7_quant_vlcs; /* Musepack SV7 is always stereo */ if (avctx->channels != 2) { @@ -103,11 +104,13 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) _hdr[0], 2, 1, 1 << MPC7_HDR_SIZE); for(i = 0; i < MPC7_QUANT_VLC_TABLES; i++){ for(j = 0; j < 2; j++){ -quant_vlc[i][j].table = _tables[quant_offsets[i*2 + j]]; -quant_vlc[i][j].table_allocated = quant_offsets[i*2 + j + 1] - quant_offsets[i*2 + j]; +quant_vlc[i][j].table = quant_table; +quant_vlc[i][j].table_allocated = quant_sizes[i * 2 + j]; +quant_table += quant_sizes[i * 2 + j]; init_vlc(_vlc[i][j], 9, mpc7_quant_vlc_sizes[i], -_quant_vlc[i][j][1], 4, 2, - _quant_vlc[i][j][0], 4, 2, INIT_VLC_USE_NEW_STATIC); + raw_quant_table + 1, 4, 2, + raw_quant_table, 4, 2, INIT_VLC_USE_NEW_STATIC); +raw_quant_table += 2 * mpc7_quant_vlc_sizes[i]; } } vlc_initialized = 1; diff --git a/libavcodec/mpc7data.h b/libavcodec/mpc7data.h index 90ab75fe65..b9c5f208a4 100644 --- a/libavcodec/mpc7data.h +++ b/libavcodec/mpc7data.h @@ -59,87 +59,59 @@ static const uint8_t mpc7_quant_vlc_off[MPC7_QUANT_VLC_TABLES] = { 0, 0, 3, 4, 7, 15, 31 }; -static const uint16_t mpc7_quant_vlc[MPC7_QUANT_VLC_TABLES][2][64 * 2] = { -{ -{ +static const uint16_t mpc7_quant_vlcs[177 * 2 * 2] = { 0x0036, 6, 0x0009, 5, 0x0020, 6, 0x0005, 5, 0x000A, 4, 0x0007, 5, 0x0034, 6, 0x, 5, 0x0023, 6, 0x000A, 5, 0x0006, 4, 0x0004, 5, 0x000B, 4, 0x0007, 3, 0x000C, 4, 0x0003, 5, 0x0007, 4, 0x000B, 5, 0x0022, 6, 0x0001, 5, 0x0035, 6, 0x0006, 5, 0x0009, 4, 0x0002, 5, -0x0021, 6, 0x0008, 5, 0x0037, 6 -}, -{ +0x0021, 6, 0x0008, 5, 0x0037, 6, 0x0067, 8, 0x003E, 7, 0x00E1, 9, 0x0037, 7, 0x0003, 4, 0x0034, 7, 0x0065, 8, 0x003C, 7, 0x00E3, 9, 0x0018, 6, 0x, 4, 0x003D, 7, 0x0004, 4, 0x0001, 1, 0x0005, 4, 0x003F, 7, 0x0001, 4, 0x003B, 7, 0x00E2, 9, 0x0039, 7, 0x0064, 8, 0x0035, 7, 0x0002, 4, 0x0036, 7, -0x00E0, 9, 0x003A, 7, 0x0066, 8 -} -}, -{ -{ +0x00E0, 9, 0x003A, 7, 0x0066, 8, + 0x0059, 7, 0x002F, 6, 0x000F, 5, 0x, 5, 0x005B, 7, 0x0004, 5, 0x0006, 4, 0x000D, 4, 0x0004, 4, 0x0005, 5, 0x0014, 5, 0x000C, 4, 0x0004, 3, 0x000F, 4, 0x000E, 5, 0x0003, 5, 0x0003, 4, 0x000E, 4, 0x0005, 4, 0x0001, 5, 0x005A, 7, 0x0002, 5, 0x0015, 5, 0x002E, 6, -0x0058, 7 -}, -{ +0x0058, 7, 0x0399, 10, 0x0071, 7, 0x0033, 6, 0x00E7, 8, 0x039A, 10, 0x0068, 7, 0x001E, 5, 0x, 3, 0x001D, 5, 0x0069, 7, 0x0032, 6, 0x0001, 3, 0x0002, 2, 0x0003, 3, 0x0031, 6, 0x006B, 7, 0x001B, 5, 0x0002, 3, 0x001F, 5, 0x0070, 7, 0x0398, 10, 0x006A, 7, 0x0030, 6, 0x0072, 7, -0x039B, 10 -} -}, -{ -{ -0x000C, 4, 0x0004, 3, 0x, 2, 0x0001, 2, 0x0007, 3, 0x0005, 3, 0x000D, 4 -}, -{ -0x0004, 5, 0x0003, 4, 0x0002, 2, 0x0003, 2, 0x0001, 2, 0x, 3, 0x0005, 5 -} -}, -{ -{ -0x0005, 4, 0x, 3, 0x0004, 3, 0x0006, 3, 0x0007, 3, 0x0005, 3, 0x0003, 3, 0x0001, 3, 0x0004, 4 -}, -{ -0x0009, 5,
[FFmpeg-devel] [PATCH 25/30] avcodec/mpc7: Don't pretend initializing static VLC tables can fail
It can't if one hasn't made a mistake at calculating the sizes; and this is checked by asserts/aborts. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpc7.c | 45 - 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index e09f1b604f..8518bc2f8a 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -47,15 +47,12 @@ static const uint16_t quant_offsets[MPC7_QUANT_VLC_TABLES*2 + 1] = static av_cold int mpc7_decode_init(AVCodecContext * avctx) { -int i, j, ret; +int i, j; MPCContext *c = avctx->priv_data; GetBitContext gb; LOCAL_ALIGNED_16(uint8_t, buf, [16]); static int vlc_initialized = 0; -static VLC_TYPE scfi_table[1 << MPC7_SCFI_BITS][2]; -static VLC_TYPE dscf_table[1 << MPC7_DSCF_BITS][2]; -static VLC_TYPE hdr_table[1 << MPC7_HDR_BITS][2]; static VLC_TYPE quant_tables[7224][2]; /* Musepack SV7 is always stereo */ @@ -95,40 +92,22 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) if(vlc_initialized) return 0; av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n"); -scfi_vlc.table = scfi_table; -scfi_vlc.table_allocated = 1 << MPC7_SCFI_BITS; -if ((ret = init_vlc(_vlc, MPC7_SCFI_BITS, MPC7_SCFI_SIZE, -_scfi[1], 2, 1, -_scfi[0], 2, 1, INIT_VLC_USE_NEW_STATIC))) { -av_log(avctx, AV_LOG_ERROR, "Cannot init SCFI VLC\n"); -return ret; -} -dscf_vlc.table = dscf_table; -dscf_vlc.table_allocated = 1 << MPC7_DSCF_BITS; -if ((ret = init_vlc(_vlc, MPC7_DSCF_BITS, MPC7_DSCF_SIZE, -_dscf[1], 2, 1, -_dscf[0], 2, 1, INIT_VLC_USE_NEW_STATIC))) { -av_log(avctx, AV_LOG_ERROR, "Cannot init DSCF VLC\n"); -return ret; -} -hdr_vlc.table = hdr_table; -hdr_vlc.table_allocated = 1 << MPC7_HDR_BITS; -if ((ret = init_vlc(_vlc, MPC7_HDR_BITS, MPC7_HDR_SIZE, -_hdr[1], 2, 1, -_hdr[0], 2, 1, INIT_VLC_USE_NEW_STATIC))) { -av_log(avctx, AV_LOG_ERROR, "Cannot init HDR VLC\n"); -return ret; -} +INIT_VLC_STATIC(_vlc, MPC7_SCFI_BITS, MPC7_SCFI_SIZE, +_scfi[1], 2, 1, +_scfi[0], 2, 1, 1 << MPC7_SCFI_BITS); +INIT_VLC_STATIC(_vlc, MPC7_DSCF_BITS, MPC7_DSCF_SIZE, +_dscf[1], 2, 1, +_dscf[0], 2, 1, 1 << MPC7_DSCF_SIZE); +INIT_VLC_STATIC(_vlc, MPC7_HDR_BITS, MPC7_HDR_SIZE, +_hdr[1], 2, 1, +_hdr[0], 2, 1, 1 << MPC7_HDR_SIZE); for(i = 0; i < MPC7_QUANT_VLC_TABLES; i++){ for(j = 0; j < 2; j++){ quant_vlc[i][j].table = _tables[quant_offsets[i*2 + j]]; quant_vlc[i][j].table_allocated = quant_offsets[i*2 + j + 1] - quant_offsets[i*2 + j]; -if ((ret = init_vlc(_vlc[i][j], 9, mpc7_quant_vlc_sizes[i], +init_vlc(_vlc[i][j], 9, mpc7_quant_vlc_sizes[i], _quant_vlc[i][j][1], 4, 2, -_quant_vlc[i][j][0], 4, 2, INIT_VLC_USE_NEW_STATIC))) { -av_log(avctx, AV_LOG_ERROR, "Cannot init QUANT VLC %i,%i\n",i,j); -return ret; -} + _quant_vlc[i][j][0], 4, 2, INIT_VLC_USE_NEW_STATIC); } } vlc_initialized = 1; -- 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 27/30] avcodec/mpegaudiodec_template: Check return value of subdecoder
After all, allocating an AVFloatDSPContext might have failed. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_template.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index de10f71e7b..98759b8e01 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -1885,7 +1885,7 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) { MP3On4DecodeContext *s = avctx->priv_data; MPEG4AudioConfig cfg; -int i; +int i, ret; if ((avctx->extradata_size < 2) || !avctx->extradata) { av_log(avctx, AV_LOG_ERROR, "Codec extradata missing or too short.\n"); @@ -1919,9 +1919,13 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) goto alloc_fail; // Put decoder context in place to make init_decode() happy avctx->priv_data = s->mp3decctx[0]; -decode_init(avctx); +ret = decode_init(avctx); // Restore mp3on4 context pointer avctx->priv_data = s; +if (ret < 0) { +decode_close_mp3on4(avctx); +return ret; +} s->mp3decctx[0]->adu_mode = 1; // Set adu mode /* Create a separate codec/context for each frame (first is already ok). -- 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 28/30] avcodec/mpegaudiodec_float: Avoid indirection with float dsp function
Do this by only keeping the only function pointer from the AVFloatDSPContext that is needed lateron. This also allows to remove the decoders' close function. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_float.c| 4 libavcodec/mpegaudiodec_template.c | 30 +++--- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/libavcodec/mpegaudiodec_float.c b/libavcodec/mpegaudiodec_float.c index ddfa5e0daa..0defdf3af1 100644 --- a/libavcodec/mpegaudiodec_float.c +++ b/libavcodec/mpegaudiodec_float.c @@ -46,7 +46,6 @@ AVCodec ff_mp1float_decoder = { .id = AV_CODEC_ID_MP1, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, -.close = decode_close, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, .flush = flush, @@ -64,7 +63,6 @@ AVCodec ff_mp2float_decoder = { .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, -.close = decode_close, .capabilities = AV_CODEC_CAP_DR1, .flush = flush, .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, @@ -80,7 +78,6 @@ AVCodec ff_mp3float_decoder = { .id = AV_CODEC_ID_MP3, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, -.close = decode_close, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, .flush = flush, @@ -97,7 +94,6 @@ AVCodec ff_mp3adufloat_decoder = { .id = AV_CODEC_ID_MP3ADU, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, -.close = decode_close, .decode = decode_frame_adu, .capabilities = AV_CODEC_CAP_DR1, .flush = flush, diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index 98759b8e01..d2b72497e1 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -87,7 +87,7 @@ typedef struct MPADecodeContext { int err_recognition; AVCodecContext* avctx; MPADSPContext mpadsp; -AVFloatDSPContext *fdsp; +void (*butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len); AVFrame *frame; uint32_t crc; } MPADecodeContext; @@ -410,16 +410,6 @@ static av_cold void decode_init_static(void) } } -#if USE_FLOATS -static av_cold int decode_close(AVCodecContext * avctx) -{ -MPADecodeContext *s = avctx->priv_data; -av_freep(>fdsp); - -return 0; -} -#endif - static av_cold int decode_init(AVCodecContext * avctx) { static int initialized_tables = 0; @@ -433,9 +423,14 @@ static av_cold int decode_init(AVCodecContext * avctx) s->avctx = avctx; #if USE_FLOATS -s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); -if (!s->fdsp) -return AVERROR(ENOMEM); +{ +AVFloatDSPContext *fdsp; +fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); +if (!fdsp) +return AVERROR(ENOMEM); +s->butterflies_float = fdsp->butterflies_float; +av_free(fdsp); +} #endif ff_mpadsp_init(>mpadsp); @@ -1188,7 +1183,7 @@ found2: /* NOTE: the 1/sqrt(2) normalization factor is included in the global gain */ #if USE_FLOATS - s->fdsp->butterflies_float(g0->sb_hybrid, g1->sb_hybrid, 576); + s->butterflies_float(g0->sb_hybrid, g1->sb_hybrid, 576); #else tab0 = g0->sb_hybrid; tab1 = g1->sb_hybrid; @@ -1871,9 +1866,6 @@ static av_cold int decode_close_mp3on4(AVCodecContext * avctx) MP3On4DecodeContext *s = avctx->priv_data; int i; -if (s->mp3decctx[0]) -av_freep(>mp3decctx[0]->fdsp); - for (i = 0; i < s->frames; i++) av_freep(>mp3decctx[i]); @@ -1938,7 +1930,7 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) s->mp3decctx[i]->adu_mode = 1; s->mp3decctx[i]->avctx = avctx; s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp; -s->mp3decctx[i]->fdsp = s->mp3decctx[0]->fdsp; +s->mp3decctx[i]->butterflies_float = s->mp3decctx[0]->butterflies_float; } 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 29/30] avcodec/mpegaudiodec_template: Simplify creating mp3on4 child decoders
Allocating the child codec contexts in one piece simplifies both allocating as well as freeing. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_template.c | 33 +- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index d2b72497e1..8ed2f74eee 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -1827,7 +1827,7 @@ typedef struct MP3On4DecodeContext { int frames; ///< number of mp3 frames per block (number of mp3 decoder instances) int syncword; ///< syncword patch const uint8_t *coff;///< channel offsets in output buffer -MPADecodeContext *mp3decctx[5]; ///< MPADecodeContext for every decoder instance +MPADecodeContext *mp3decctx;///< MPADecodeContext for every decoder instance } MP3On4DecodeContext; #include "mpeg4audio.h" @@ -1864,10 +1864,8 @@ static const int16_t chan_layout[8] = { static av_cold int decode_close_mp3on4(AVCodecContext * avctx) { MP3On4DecodeContext *s = avctx->priv_data; -int i; -for (i = 0; i < s->frames; i++) -av_freep(>mp3decctx[i]); +av_freep(>mp3decctx); return 0; } @@ -1905,12 +1903,12 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) * decode_init() does not have to be changed. * Other decoders will be initialized here copying data from the first context */ -// Allocate zeroed memory for the first decoder context -s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext)); -if (!s->mp3decctx[0]) +// Allocate zeroed memory for the decoder contexts +s->mp3decctx = av_mallocz_array(sizeof(MPADecodeContext), s->frames); +if (!s->mp3decctx) goto alloc_fail; // Put decoder context in place to make init_decode() happy -avctx->priv_data = s->mp3decctx[0]; +avctx->priv_data = s->mp3decctx; ret = decode_init(avctx); // Restore mp3on4 context pointer avctx->priv_data = s; @@ -1918,19 +1916,16 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) decode_close_mp3on4(avctx); return ret; } -s->mp3decctx[0]->adu_mode = 1; // Set adu mode +s->mp3decctx[0].adu_mode = 1; // Set adu mode /* Create a separate codec/context for each frame (first is already ok). * Each frame is 1 or 2 channels - up to 5 frames allowed */ for (i = 1; i < s->frames; i++) { -s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext)); -if (!s->mp3decctx[i]) -goto alloc_fail; -s->mp3decctx[i]->adu_mode = 1; -s->mp3decctx[i]->avctx = avctx; -s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp; -s->mp3decctx[i]->butterflies_float = s->mp3decctx[0]->butterflies_float; +s->mp3decctx[i].adu_mode = 1; +s->mp3decctx[i].avctx= avctx; +s->mp3decctx[i].mpadsp = s->mp3decctx[0].mpadsp; +s->mp3decctx[i].butterflies_float = s->mp3decctx[0].butterflies_float; } return 0; @@ -1946,7 +1941,7 @@ static void flush_mp3on4(AVCodecContext *avctx) MP3On4DecodeContext *s = avctx->priv_data; for (i = 0; i < s->frames; i++) -mp_flush(s->mp3decctx[i]); +mp_flush(>mp3decctx[i]); } @@ -1980,7 +1975,7 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data, for (fr = 0; fr < s->frames; fr++) { fsize = AV_RB16(buf) >> 4; fsize = FFMIN3(fsize, len, MPA_MAX_CODED_FRAME_SIZE); -m = s->mp3decctx[fr]; +m = >mp3decctx[fr]; av_assert1(m); if (fsize < HEADER_SIZE) { @@ -2027,7 +2022,7 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data, } /* update codec info */ -avctx->sample_rate = s->mp3decctx[0]->sample_rate; +avctx->sample_rate = s->mp3decctx[0].sample_rate; frame->nb_samples = out_size / (avctx->channels * sizeof(OUT_INT)); *got_frame_ptr= 1; -- 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 21/30] avcodec/mobiclip: Fix memleak upon init failure
If an error happens during init after an allocation has succeeded, the already allocated data leaked up until now. Fix this by setting the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavcodec/mobiclip.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c index 25a7f0ed14..8758e7f617 100644 --- a/libavcodec/mobiclip.c +++ b/libavcodec/mobiclip.c @@ -1436,4 +1436,5 @@ AVCodec ff_mobiclip_decoder = { .flush = mobiclip_flush, .close = mobiclip_close, .capabilities = AV_CODEC_CAP_DR1, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -- 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 23/30] avcodec/motionpixels: Cleanup generically after init failure
Signed-off-by: Andreas Rheinhardt --- libavcodec/motionpixels.c | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index 6cb444a703..b48200b017 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -81,19 +81,13 @@ static av_cold int mp_decode_init(AVCodecContext *avctx) mp->offset_bits_len = av_log2(avctx->width * avctx->height) + 1; mp->vpt = av_mallocz_array(avctx->height, sizeof(YuvPixel)); mp->hpt = av_mallocz_array(h4 / 4, w4 / 4 * sizeof(YuvPixel)); -if (!mp->changes_map || !mp->vpt || !mp->hpt) { -av_freep(>changes_map); -av_freep(>vpt); -av_freep(>hpt); +if (!mp->changes_map || !mp->vpt || !mp->hpt) return AVERROR(ENOMEM); -} avctx->pix_fmt = AV_PIX_FMT_RGB555; mp->frame = av_frame_alloc(); -if (!mp->frame) { -mp_decode_end(avctx); +if (!mp->frame) return AVERROR(ENOMEM); -} return 0; } @@ -354,4 +348,5 @@ AVCodec ff_motionpixels_decoder = { .close = mp_decode_end, .decode = mp_decode_frame, .capabilities = AV_CODEC_CAP_DR1, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -- 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 22/30] avcodec/mobiclip: Fix heap-buffer-overflow
The MobiClip decoder uses adjacent pixels for prediction; yet when accessing the left pixel, it was forgotten to clip the x coordinate. This results in an heap-buffer-overflow. It can e.g. be reproduced with the sample from https://samples.ffmpeg.org/V-codecs/MOHD/crap.avi when forcing the video decoder to mobiclip. Signed-off-by: Andreas Rheinhardt --- libavcodec/mobiclip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c index 8758e7f617..47387fce90 100644 --- a/libavcodec/mobiclip.c +++ b/libavcodec/mobiclip.c @@ -905,7 +905,7 @@ static int predict_intra(AVCodecContext *avctx, AVFrame *frame, int ax, int ay, int arr1[16]; int arr2[16]; uint8_t *top = frame->data[plane] + FFMAX(ay - 1, 0) * frame->linesize[plane] + ax; -uint8_t *left = frame->data[plane] + ay * frame->linesize[plane] + ax - 1; +uint8_t *left = frame->data[plane] + ay * frame->linesize[plane] + FFMAX(ax - 1, 0); int bottommost = frame->data[plane][(ay + size - 1) * frame->linesize[plane] + FFMAX(ax - 1, 0)]; int rightmost = frame->data[plane][FFMAX(ay - 1, 0) * frame->linesize[plane] + ax + size - 1]; int avg = (bottommost + rightmost + 1) / 2 + 2 * get_se_golomb(gb); -- 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 19/30] avcodec/magicyuvenc: Fix memleak upon init failure
If an error happens during init after an allocation has succeeded, the already allocated data leaked up until now. Fix this by setting the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavcodec/magicyuvenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c index e9fe3bf519..0bd6b8ef6a 100644 --- a/libavcodec/magicyuvenc.c +++ b/libavcodec/magicyuvenc.c @@ -587,4 +587,5 @@ AVCodec ff_magicyuv_encoder = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE }, +.caps_internal= FF_CODEC_CAP_INIT_CLEANUP, }; -- 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 18/30] avcodec/ljpegenc: Don't free buffer known to be NULL
The lossless JPEG encoder allocates one buffer in its init function and freeing said buffer is the only thing done in its close function. Despite this the init function called the close function if allocating said buffer fails, although there is nothing to free in this case. This commit stops doing this. Signed-off-by: Andreas Rheinhardt --- libavcodec/ljpegenc.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c index 70eff9e6fe..39ce5a0089 100644 --- a/libavcodec/ljpegenc.c +++ b/libavcodec/ljpegenc.c @@ -309,7 +309,7 @@ FF_ENABLE_DEPRECATION_WARNINGS s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch)); if (!s->scratch) -goto fail; +return AVERROR(ENOMEM); ff_idctdsp_init(>idsp, avctx); ff_init_scantable(s->idsp.idct_permutation, >scantable, @@ -327,9 +327,6 @@ FF_ENABLE_DEPRECATION_WARNINGS avpriv_mjpeg_val_dc); return 0; -fail: -ljpeg_encode_close(avctx); -return AVERROR(ENOMEM); } #define OFFSET(x) offsetof(LJpegEncContext, x) -- 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 20/30] avcodec/mlpenc: Fix memleak upon init failure
If an error happens during init after an allocation has succeeded, the already allocated data leaked up until now. Fix this by setting the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavcodec/mlpenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index 52ea06ed91..f6159d39c8 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -2391,6 +2391,7 @@ AVCodec ff_mlp_encoder = { .sample_fmts= (const enum AVSampleFormat[]) {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE}, .supported_samplerates = (const int[]) {44100, 48000, 88200, 96000, 176400, 192000, 0}, .channel_layouts= ff_mlp_channel_layouts, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; #endif #if CONFIG_TRUEHD_ENCODER @@ -2407,5 +2408,6 @@ AVCodec ff_truehd_encoder = { .sample_fmts= (const enum AVSampleFormat[]) {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE}, .supported_samplerates = (const int[]) {44100, 48000, 88200, 96000, 176400, 192000, 0}, .channel_layouts= (const uint64_t[]) {AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_5POINT1_BACK, 0}, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; #endif -- 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 13/30] avcodec/imc: Avoid indirection when calling float dsp function
Do this by only keeping the only function pointer from the AVFloatDSPContext that is needed lateron. Signed-off-by: Andreas Rheinhardt --- libavcodec/imc.c | 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libavcodec/imc.c b/libavcodec/imc.c index 82a908160a..6766d53643 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -95,7 +95,7 @@ typedef struct IMCContext { GetBitContext gb; BswapDSPContext bdsp; -AVFloatDSPContext *fdsp; +void (*butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len); FFTContext fft; DECLARE_ALIGNED(32, FFTComplex, samples)[COEFFS / 2]; float *out_samples; @@ -179,6 +179,7 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) { int i, j, ret; IMCContext *q = avctx->priv_data; +AVFloatDSPContext *fdsp; double r1, r2; if (avctx->codec_id == AV_CODEC_ID_IAC && avctx->sample_rate > 96000) { @@ -252,17 +253,16 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) memcpy(q->weights2, imc_weights2, sizeof(imc_weights2)); } +fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); +if (!fdsp) +return AVERROR(ENOMEM); +q->butterflies_float = fdsp->butterflies_float; +av_free(fdsp); if ((ret = ff_fft_init(>fft, 7, 1))) { av_log(avctx, AV_LOG_INFO, "FFT init failed\n"); return ret; } ff_bswapdsp_init(>bdsp); -q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); -if (!q->fdsp) { -ff_fft_end(>fft); - -return AVERROR(ENOMEM); -} avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO @@ -1050,8 +1050,8 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, } if (avctx->channels == 2) { -q->fdsp->butterflies_float((float *)frame->extended_data[0], - (float *)frame->extended_data[1], COEFFS); +q->butterflies_float((float *)frame->extended_data[0], + (float *)frame->extended_data[1], COEFFS); } *got_frame_ptr = 1; @@ -1064,7 +1064,6 @@ static av_cold int imc_decode_close(AVCodecContext * avctx) IMCContext *q = avctx->priv_data; ff_fft_end(>fft); -av_freep(>fdsp); 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 16/30] avcodec/indeo5: Fix memleaks upon allocation error
ff_ivi_init_planes() might error out after having allocated some arrays. Set the FF_CODEC_CAP_INIT_CLEANUP flag in order to free these arrays in this case. Signed-off-by: Andreas Rheinhardt --- libavcodec/indeo5.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/indeo5.c b/libavcodec/indeo5.c index 4ccdbcaf0a..ac15d31fef 100644 --- a/libavcodec/indeo5.c +++ b/libavcodec/indeo5.c @@ -30,6 +30,7 @@ #define BITSTREAM_READER_LE #include "avcodec.h" #include "get_bits.h" +#include "internal.h" #include "ivi.h" #include "ivi_dsp.h" #include "indeo5data.h" @@ -692,4 +693,5 @@ AVCodec ff_indeo5_decoder = { .close = ff_ivi_decode_close, .decode = ff_ivi_decode_frame, .capabilities = AV_CODEC_CAP_DR1, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -- 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 14/30] avcodec/indeo3: Cleanup generically after init failure
Signed-off-by: Andreas Rheinhardt --- libavcodec/indeo3.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c index 71d478c9fc..75113a7541 100644 --- a/libavcodec/indeo3.c +++ b/libavcodec/indeo3.c @@ -203,10 +203,8 @@ static av_cold int allocate_frame_buffers(Indeo3DecodeContext *ctx, ctx->planes[p].buffers[0] = av_malloc(!p ? luma_size : chroma_size); ctx->planes[p].buffers[1] = av_malloc(!p ? luma_size : chroma_size); -if (!ctx->planes[p].buffers[0] || !ctx->planes[p].buffers[1]) { -free_frame_buffers(ctx); +if (!ctx->planes[p].buffers[0] || !ctx->planes[p].buffers[1]) return AVERROR(ENOMEM); -} /* fill the INTRA prediction lines with the middle pixel value = 64 */ memset(ctx->planes[p].buffers[0], 0x40, ctx->planes[p].pitch); @@ -1143,4 +1141,5 @@ AVCodec ff_indeo3_decoder = { .close = decode_close, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -- 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 15/30] avcodec/ivi: Fix segfault on allocation error
If allocating the tiles array for indeo 4/5 fails, the context is in an inconsistent state, because the counter for the number of tiles is > 0. This will lead to a segfault when freeing the tiles' substructures. Fix this by setting the number of tiles to zero if the allocation was unsuccessfull. Signed-off-by: Andreas Rheinhardt --- libavcodec/ivi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/ivi.c b/libavcodec/ivi.c index c5c50fb5c1..c10984e83e 100644 --- a/libavcodec/ivi.c +++ b/libavcodec/ivi.c @@ -442,8 +442,10 @@ av_cold int ff_ivi_init_tiles(IVIPlaneDesc *planes, av_freep(>tiles); band->tiles = av_mallocz_array(band->num_tiles, sizeof(IVITile)); -if (!band->tiles) +if (!band->tiles) { +band->num_tiles = 0; return AVERROR(ENOMEM); +} /* use the first luma band as reference for motion vectors * and quant */ -- 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 17/30] avcodec/j2kenc: Fix leaks on init failure
The JPEG2000 encoder did not clean up after itself on error. This commit fixes this by modifying the cleanup function to be able to handle only partially allocated structures and by setting the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavcodec/j2kenc.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 4cefe6d7fb..e3c5a32188 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -459,7 +459,7 @@ static int init_tiles(Jpeg2000EncoderContext *s) s->numXtiles = ff_jpeg2000_ceildiv(s->width, s->tile_width); s->numYtiles = ff_jpeg2000_ceildiv(s->height, s->tile_height); -s->tile = av_malloc_array(s->numXtiles, s->numYtiles * sizeof(Jpeg2000Tile)); +s->tile = av_calloc(s->numXtiles, s->numYtiles * sizeof(Jpeg2000Tile)); if (!s->tile) return AVERROR(ENOMEM); for (tileno = 0, tiley = 0; tiley < s->numYtiles; tiley++) @@ -1495,12 +1495,16 @@ static void cleanup(Jpeg2000EncoderContext *s) int tileno, compno; Jpeg2000CodingStyle *codsty = >codsty; +if (!s->tile) +return; for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ -for (compno = 0; compno < s->ncomponents; compno++){ -Jpeg2000Component *comp = s->tile[tileno].comp + compno; -ff_jpeg2000_cleanup(comp, codsty); +if (s->tile[tileno].comp) { +for (compno = 0; compno < s->ncomponents; compno++){ +Jpeg2000Component *comp = s->tile[tileno].comp + compno; +ff_jpeg2000_cleanup(comp, codsty); +} +av_freep(>tile[tileno].comp); } -av_freep(>tile[tileno].comp); av_freep(>tile[tileno].layer_rates); } av_freep(>tile); @@ -1853,4 +1857,5 @@ AVCodec ff_jpeg2000_encoder = { AV_PIX_FMT_NONE }, .priv_class = _class, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -- 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 09/30] avcodec/hmm4video: Cleanup generically on init failure
Signed-off-by: Andreas Rheinhardt --- libavcodec/hnm4video.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c index 177ce1d47a..ac080e398b 100644 --- a/libavcodec/hnm4video.c +++ b/libavcodec/hnm4video.c @@ -486,9 +486,6 @@ static av_cold int hnm_decode_init(AVCodecContext *avctx) || avctx->width * avctx->height == 0 || avctx->height % 2) { av_log(avctx, AV_LOG_ERROR, "av_mallocz() failed\n"); -av_freep(>buffer1); -av_freep(>buffer2); -av_freep(>processed); return AVERROR(ENOMEM); } @@ -519,4 +516,5 @@ AVCodec ff_hnm4_video_decoder = { .close = hnm_decode_end, .decode = hnm_decode_frame, .capabilities = AV_CODEC_CAP_DR1, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -- 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 07/30] avcodec/gif: Fix leaks upon allocation error
If one of several allocations the gif encoder performs in its init function fails, the successfull allocations leak. Fix this by adding the FF_CODEC_CAP_INIT_CLEANUP. Signed-off-by: Andreas Rheinhardt --- libavcodec/gif.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/gif.c b/libavcodec/gif.c index 65a76cfde4..de41992851 100644 --- a/libavcodec/gif.c +++ b/libavcodec/gif.c @@ -497,4 +497,5 @@ AVCodec ff_gif_encoder = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_PAL8, AV_PIX_FMT_NONE }, .priv_class = _class, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -- 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 11/30] avcodec/hnm4video: Don't reimplement FFSWAP()
Signed-off-by: Andreas Rheinhardt --- libavcodec/hnm4video.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c index 173691a1eb..43baa9c572 100644 --- a/libavcodec/hnm4video.c +++ b/libavcodec/hnm4video.c @@ -387,15 +387,6 @@ static void hnm_update_palette(AVCodecContext *avctx, uint8_t *src, } } -static void hnm_flip_buffers(Hnm4VideoContext *hnm) -{ -uint8_t *temp; - -temp = hnm->current; -hnm->current = hnm->previous; -hnm->previous = temp; -} - static int hnm_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { @@ -450,7 +441,7 @@ static int hnm_decode_frame(AVCodecContext *avctx, void *data, frame->key_frame = 0; memcpy(frame->data[1], hnm->palette, 256 * 4); *got_frame = 1; -hnm_flip_buffers(hnm); +FFSWAP(uint8_t *, hnm->current, hnm->previous); } else { av_log(avctx, AV_LOG_ERROR, "invalid chunk id: %d\n", chunk_id); return AVERROR_INVALIDDATA; -- 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 12/30] avcodec/hq_hqadata: Make local arrays static
Signed-off-by: Andreas Rheinhardt --- libavcodec/hq_hqadata.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/hq_hqadata.c b/libavcodec/hq_hqadata.c index ae9231aa02..56470eadc1 100644 --- a/libavcodec/hq_hqadata.c +++ b/libavcodec/hq_hqadata.c @@ -1142,7 +1142,7 @@ const int32_t *const ff_hq_quants[NUM_HQ_QUANTS][2][4] = { { { qmat3A, qmat48, qmat4C, qmat4C }, { qmat3B, qmat49, qmat4D, qmat4D } }, }; -const uint8_t ff_hq_ac_bits[NUM_HQ_AC_ENTRIES] = { +static const uint8_t hq_ac_bits[NUM_HQ_AC_ENTRIES] = { 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, @@ -1192,7 +1192,7 @@ const uint8_t ff_hq_ac_bits[NUM_HQ_AC_ENTRIES] = { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, }; -const uint16_t ff_hq_ac_codes[NUM_HQ_AC_ENTRIES] = { +static const uint16_t hq_ac_codes[NUM_HQ_AC_ENTRIES] = { 0x, 0x0001, 0x0004, 0x0005, 0x0006, 0x000E, 0x000F, 0x0010, 0x0011, 0x0012, 0x0013, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, @@ -8373,5 +8373,5 @@ av_cold int ff_hq_init_vlcs(HQContext *c) return ret; return init_vlc(>hq_ac_vlc, 9, NUM_HQ_AC_ENTRIES, -ff_hq_ac_bits, 1, 1, ff_hq_ac_codes, 2, 2, 0); +hq_ac_bits, 1, 1, hq_ac_codes, 2, 2, 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 08/30] avcodec/hcom: Cleanup generically upon init failure
Signed-off-by: Andreas Rheinhardt --- libavcodec/hcom.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libavcodec/hcom.c b/libavcodec/hcom.c index 8300676f98..06fa25fcd2 100644 --- a/libavcodec/hcom.c +++ b/libavcodec/hcom.c @@ -67,15 +67,11 @@ static av_cold int hcom_init(AVCodecContext *avctx) if (s->dict[i].l >= 0 && (s->dict[i].l >= s->dict_entries || s->dict[i].r >= s->dict_entries || - s->dict[i].r < 0 )) { -av_freep(>dict); + s->dict[i].r < 0 )) return AVERROR_INVALIDDATA; -} } -if (s->dict[0].l < 0) { -av_freep(>dict); +if (s->dict[0].l < 0) return AVERROR_INVALIDDATA; -} avctx->sample_fmt = AV_SAMPLE_FMT_U8; s->dict_entry = 0; @@ -148,4 +144,5 @@ AVCodec ff_hcom_decoder = { .close = hcom_close, .decode = hcom_decode, .capabilities = AV_CODEC_CAP_DR1, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -- 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 06/30] avcodec/g722enc: Cleanup generically on init failure
Signed-off-by: Andreas Rheinhardt --- libavcodec/g722enc.c | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c index 25b61df19e..9357f170fe 100644 --- a/libavcodec/g722enc.c +++ b/libavcodec/g722enc.c @@ -59,7 +59,6 @@ static av_cold int g722_encode_close(AVCodecContext *avctx) static av_cold int g722_encode_init(AVCodecContext * avctx) { G722Context *c = avctx->priv_data; -int ret; c->band[0].scale_factor = 8; c->band[1].scale_factor = 2; @@ -73,10 +72,8 @@ static av_cold int g722_encode_init(AVCodecContext * avctx) c->paths[i] = av_mallocz_array(max_paths, sizeof(**c->paths)); c->node_buf[i] = av_mallocz_array(frontier, 2 * sizeof(**c->node_buf)); c->nodep_buf[i] = av_mallocz_array(frontier, 2 * sizeof(**c->nodep_buf)); -if (!c->paths[i] || !c->node_buf[i] || !c->nodep_buf[i]) { -ret = AVERROR(ENOMEM); -goto error; -} +if (!c->paths[i] || !c->node_buf[i] || !c->nodep_buf[i]) +return AVERROR(ENOMEM); } } @@ -118,9 +115,6 @@ static av_cold int g722_encode_init(AVCodecContext * avctx) ff_g722dsp_init(>dsp); return 0; -error: -g722_encode_close(avctx); -return ret; } static const int16_t low_quant[33] = { @@ -387,4 +381,5 @@ AVCodec ff_adpcm_g722_encoder = { .capabilities= AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .channel_layouts = (const uint64_t[]){ AV_CH_LAYOUT_MONO, 0 }, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -- 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 10/30] avcodec/hnm4video: Don't return nonsense error messages
The HNM 4 video decoder's init function claimed that an allocation failed if the image dimensions are wrong. This is fixed in this commit: The dimensions are checked before the allocations are attempted. The check whether width * height is zero is redundant as av_image_check_size() already checks for this; it has been removed. Signed-off-by: Andreas Rheinhardt --- libavcodec/hnm4video.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c index ac080e398b..173691a1eb 100644 --- a/libavcodec/hnm4video.c +++ b/libavcodec/hnm4video.c @@ -473,6 +473,8 @@ static av_cold int hnm_decode_init(AVCodecContext *avctx) ret = av_image_check_size(avctx->width, avctx->height, 0, avctx); if (ret < 0) return ret; +if (avctx->height & 1) +return AVERROR(EINVAL); hnm->version = avctx->extradata[0]; avctx->pix_fmt = AV_PIX_FMT_PAL8; @@ -482,9 +484,7 @@ static av_cold int hnm_decode_init(AVCodecContext *avctx) hnm->buffer2 = av_mallocz(avctx->width * avctx->height); hnm->processed = av_mallocz(avctx->width * avctx->height); -if ( !hnm->buffer1 || !hnm->buffer2 || !hnm->processed -|| avctx->width * avctx->height == 0 -|| avctx->height % 2) { +if (!hnm->buffer1 || !hnm->buffer2 || !hnm->processed) { av_log(avctx, AV_LOG_ERROR, "av_mallocz() failed\n"); return AVERROR(ENOMEM); } -- 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 01/30] avcodec/flashsvenc: Avoid allocation of buffer, fix memleak
Up until now, the flashsv encoder tried to allocate two buffers in its init function; if only one of these allocations succeeds, the other buffer leaks. Fix this by making one of these buffers part of the context (its size is a compile-time constant). Signed-off-by: Andreas Rheinhardt --- libavcodec/flashsvenc.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index f7f98efde3..4ac643c036 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -59,11 +59,11 @@ typedef struct FlashSVContext { uint8_t*previous_frame; int image_width, image_height; int block_width, block_height; -uint8_t*tmpblock; uint8_t*encbuffer; int block_size; z_streamzstream; int last_key_frame; +uint8_t tmpblock[3 * 256 * 256]; } FlashSVContext; static int copy_region_enc(uint8_t *sptr, uint8_t *dptr, int dx, int dy, @@ -96,7 +96,6 @@ static av_cold int flashsv_encode_end(AVCodecContext *avctx) av_freep(>encbuffer); av_freep(>previous_frame); -av_freep(>tmpblock); return 0; } @@ -121,10 +120,9 @@ static av_cold int flashsv_encode_init(AVCodecContext *avctx) s->image_width = avctx->width; s->image_height = avctx->height; -s->tmpblock = av_mallocz(3 * 256 * 256); s->encbuffer = av_mallocz(s->image_width * s->image_height * 3); -if (!s->tmpblock || !s->encbuffer) { +if (!s->encbuffer) { av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n"); return AVERROR(ENOMEM); } -- 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/srt: fix build fail when used the libsrt 1.4.1
On Tue, Sep 15, 2020 at 2:23 PM Gyan Doshi wrote: > > This should be backported to 4.3 and other releases whose builds fail. > > Gyan Will backporting, thx ___ 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/srt: fix build fail when used the libsrt 1.4.1
This should be backported to 4.3 and other releases whose builds fail. Gyan On 12-07-2020 11:33 am, Jun Zhao wrote: From: Jun Zhao libsrt 1.4.1 changed the: SRTO_SMOOTHER -> SRTO_CONGESTION SRTO_STRICTENC -> SRTO_ENFORCEDENCRYPTION SRTO_TSBPDDELAY -> SRTO_LATENCY and removed the front of deprecated option, it's lead to build fail fix #8760 Signed-off-by: Jun Zhao --- libavformat/libsrt.c | 8 1 file changed, 8 insertions(+) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 4de575b..4719ce0 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -313,8 +313,12 @@ static int libsrt_set_options_pre(URLContext *h, int fd) (s->pbkeylen >= 0 && libsrt_setsockopt(h, fd, SRTO_PBKEYLEN, "SRTO_PBKEYLEN", >pbkeylen, sizeof(s->pbkeylen)) < 0) || (s->passphrase && libsrt_setsockopt(h, fd, SRTO_PASSPHRASE, "SRTO_PASSPHRASE", s->passphrase, strlen(s->passphrase)) < 0) || #if SRT_VERSION_VALUE >= 0x010302 +#if SRT_VERSION_VALUE >= 0x010401 +(s->enforced_encryption >= 0 && libsrt_setsockopt(h, fd, SRTO_ENFORCEDENCRYPTION, "SRTO_ENFORCEDENCRYPTION", >enforced_encryption, sizeof(s->enforced_encryption)) < 0) || +#else /* SRTO_STRICTENC == SRTO_ENFORCEDENCRYPTION (53), but for compatibility, we used SRTO_STRICTENC */ (s->enforced_encryption >= 0 && libsrt_setsockopt(h, fd, SRTO_STRICTENC, "SRTO_STRICTENC", >enforced_encryption, sizeof(s->enforced_encryption)) < 0) || +#endif (s->kmrefreshrate >= 0 && libsrt_setsockopt(h, fd, SRTO_KMREFRESHRATE, "SRTO_KMREFRESHRATE", >kmrefreshrate, sizeof(s->kmrefreshrate)) < 0) || (s->kmpreannounce >= 0 && libsrt_setsockopt(h, fd, SRTO_KMPREANNOUNCE, "SRTO_KMPREANNOUNCE", >kmpreannounce, sizeof(s->kmpreannounce)) < 0) || #endif @@ -333,7 +337,11 @@ static int libsrt_set_options_pre(URLContext *h, int fd) (s->lossmaxttl >= 0 && libsrt_setsockopt(h, fd, SRTO_LOSSMAXTTL, "SRTO_LOSSMAXTTL", >lossmaxttl, sizeof(s->lossmaxttl)) < 0) || (s->minversion >= 0 && libsrt_setsockopt(h, fd, SRTO_MINVERSION, "SRTO_MINVERSION", >minversion, sizeof(s->minversion)) < 0) || (s->streamid && libsrt_setsockopt(h, fd, SRTO_STREAMID, "SRTO_STREAMID", s->streamid, strlen(s->streamid)) < 0) || +#if SRT_VERSION_VALUE >= 0x010401 +(s->smoother && libsrt_setsockopt(h, fd, SRTO_CONGESTION, "SRTO_CONGESTION", s->smoother, strlen(s->smoother)) < 0) || +#else (s->smoother && libsrt_setsockopt(h, fd, SRTO_SMOOTHER, "SRTO_SMOOTHER", s->smoother, strlen(s->smoother)) < 0) || +#endif (s->messageapi >= 0 && libsrt_setsockopt(h, fd, SRTO_MESSAGEAPI, "SRTO_MESSAGEAPI", >messageapi, sizeof(s->messageapi)) < 0) || (s->payload_size >= 0 && libsrt_setsockopt(h, fd, SRTO_PAYLOADSIZE, "SRTO_PAYLOADSIZE", >payload_size, sizeof(s->payload_size)) < 0) || ((h->flags & AVIO_FLAG_WRITE) && libsrt_setsockopt(h, fd, SRTO_SENDER, "SRTO_SENDER", , sizeof(yes)) < 0)) { ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".