[FFmpeg-cvslog] lavc/libx264.c: Fix possible UB by NULL pointer LHS
ffmpeg | branch: master | Michael Goulet | Thu Jun 16 17:52:56 2022 +0200| [0aa5dd084b8e26c9d644354c42c9252cf3b19cea] | committer: Thilo Borgmann lavc/libx264.c: Fix possible UB by NULL pointer LHS It is UB to attempt to do pointer arithmetic on NULL pointer LHS, even if that pointer arithmetic ends up being "+= 0" (i.e. !!p == 0 if p == NULL). > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0aa5dd084b8e26c9d644354c42c9252cf3b19cea --- libavcodec/libx264.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 14177b3016..616d855067 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -940,7 +940,9 @@ static av_cold int X264_init(AVCodecContext *avctx) return ret; } p= strchr(p, ':'); -p+=!!p; +if (p) { +++p; +} } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] tests/checkasm/sw_scale: Fix alignment for movdqa
ffmpeg | branch: master | Michael Goulet | Thu Jun 16 10:14:50 2022 +0200| [b7f6a933fa4873c7523586d6e203cfd1798decd6] | committer: Thilo Borgmann tests/checkasm/sw_scale: Fix alignment for movdqa SSE3 instruction movdqa in ff_yuv2yuvX_sse3() expects a 16-byte aligned address for a memory address, or else a segfault is generated. The src_pixels buffer below was not aligned to 16 bytes on the stack necessarily, so we got segfaults during fate-checkasm-sw_scale. Therefore 16-byte align all of these local variables, aligning them too much shouldn't hurt. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7f6a933fa4873c7523586d6e203cfd1798decd6 --- tests/checkasm/sw_scale.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c index 31d9a525e9..b643a47c30 100644 --- a/tests/checkasm/sw_scale.c +++ b/tests/checkasm/sw_scale.c @@ -75,11 +75,11 @@ static void check_yuv2yuvX(void) int dstW, const uint8_t *dither, int offset); const int16_t **src; -LOCAL_ALIGNED_8(int16_t, src_pixels, [LARGEST_FILTER * LARGEST_INPUT_SIZE]); -LOCAL_ALIGNED_8(int16_t, filter_coeff, [LARGEST_FILTER]); -LOCAL_ALIGNED_8(uint8_t, dst0, [LARGEST_INPUT_SIZE]); -LOCAL_ALIGNED_8(uint8_t, dst1, [LARGEST_INPUT_SIZE]); -LOCAL_ALIGNED_8(uint8_t, dither, [LARGEST_INPUT_SIZE]); +LOCAL_ALIGNED_16(int16_t, src_pixels, [LARGEST_FILTER * LARGEST_INPUT_SIZE]); +LOCAL_ALIGNED_16(int16_t, filter_coeff, [LARGEST_FILTER]); +LOCAL_ALIGNED_16(uint8_t, dst0, [LARGEST_INPUT_SIZE]); +LOCAL_ALIGNED_16(uint8_t, dst1, [LARGEST_INPUT_SIZE]); +LOCAL_ALIGNED_16(uint8_t, dither, [LARGEST_INPUT_SIZE]); union VFilterData{ const int16_t *src; uint16_t coeff[8]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mfenc: set variable frame size flag.
ffmpeg | branch: master | Gyan Doshi | Fri Jun 17 11:30:05 2022 +0530| [56419428a85fa83c2d2275b6eb82a4e7ac543401] | committer: Gyan Doshi avcodec/mfenc: set variable frame size flag. Default avctx->frame_size is 0 which led to init failure for audio MediaFoundation encoders since 827d6fe73d. The MF audio encoders accept variable frame size input buffers. Fixes #9802 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=56419428a85fa83c2d2275b6eb82a4e7ac543401 --- libavcodec/mfenc.c | 23 ++- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c index 13ed7b3e11..bbe78605a9 100644 --- a/libavcodec/mfenc.c +++ b/libavcodec/mfenc.c @@ -1220,7 +1220,7 @@ static int mf_init(AVCodecContext *avctx) #define OFFSET(x) offsetof(MFContext, x) -#define MF_ENCODER(MEDIATYPE, NAME, ID, OPTS, EXTRA) \ +#define MF_ENCODER(MEDIATYPE, NAME, ID, OPTS, FMTS, CAPS) \ static const AVClass ff_ ## NAME ## _mf_encoder_class = { \ .class_name = #NAME "_mf", \ .item_name = av_default_item_name, \ @@ -1237,9 +1237,8 @@ static int mf_init(AVCodecContext *avctx) .init = mf_init, \ .close = mf_close, \ FF_CODEC_RECEIVE_PACKET_CB(mf_receive_packet), \ -EXTRA \ -.p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID | \ - AV_CODEC_CAP_DR1, \ +FMTS \ +CAPS \ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | \ FF_CODEC_CAP_INIT_CLEANUP, \ }; @@ -1247,10 +1246,13 @@ static int mf_init(AVCodecContext *avctx) #define AFMTS \ .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, \ AV_SAMPLE_FMT_NONE }, +#define ACAPS \ +.p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID | \ + AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE, -MF_ENCODER(AUDIO, aac, AAC, NULL, AFMTS); -MF_ENCODER(AUDIO, ac3, AC3, NULL, AFMTS); -MF_ENCODER(AUDIO, mp3, MP3, NULL, AFMTS); +MF_ENCODER(AUDIO, aac, AAC, NULL, AFMTS, ACAPS); +MF_ENCODER(AUDIO, ac3, AC3, NULL, AFMTS, ACAPS); +MF_ENCODER(AUDIO, mp3, MP3, NULL, AFMTS, ACAPS); #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption venc_opts[] = { @@ -1283,6 +1285,9 @@ static const AVOption venc_opts[] = { .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \ AV_PIX_FMT_YUV420P, \ AV_PIX_FMT_NONE }, +#define VCAPS \ +.p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID | \ + AV_CODEC_CAP_DR1, -MF_ENCODER(VIDEO, h264,H264, venc_opts, VFMTS); -MF_ENCODER(VIDEO, hevc,HEVC, venc_opts, VFMTS); +MF_ENCODER(VIDEO, h264,H264, venc_opts, VFMTS, VCAPS); +MF_ENCODER(VIDEO, hevc,HEVC, venc_opts, VFMTS, VCAPS); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/v210dec: properly support odd widths
ffmpeg | branch: master | Marton Balint | Sat Jun 11 23:10:44 2022 +0200| [9793760f22ccbaeda2a3462d2d235bd7b6fe013b] | committer: Marton Balint avcodec/v210dec: properly support odd widths Fixes ticket #5195. Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9793760f22ccbaeda2a3462d2d235bd7b6fe013b --- libavcodec/v210dec.c | 49 + 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c index 6c10ef6a7c..48ebe57100 100644 --- a/libavcodec/v210dec.c +++ b/libavcodec/v210dec.c @@ -60,14 +60,16 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th int slice_start = (avctx->height * jobnr) / s->thread_count; int slice_end = (avctx->height * (jobnr+1)) / s->thread_count; uint8_t *psrc = td->buf + stride * slice_start; -uint16_t *y, *u, *v; +int16_t *py = (uint16_t*)frame->data[0] + slice_start * frame->linesize[0] / 2; +int16_t *pu = (uint16_t*)frame->data[1] + slice_start * frame->linesize[1] / 2; +int16_t *pv = (uint16_t*)frame->data[2] + slice_start * frame->linesize[2] / 2; -y = (uint16_t*)frame->data[0] + slice_start * frame->linesize[0] / 2; -u = (uint16_t*)frame->data[1] + slice_start * frame->linesize[1] / 2; -v = (uint16_t*)frame->data[2] + slice_start * frame->linesize[2] / 2; for (h = slice_start; h < slice_end; h++) { const uint32_t *src = (const uint32_t*)psrc; uint32_t val; +uint16_t *y = py; +uint16_t *u = pu; +uint16_t *v = pv; w = (avctx->width / 12) * 12; s->unpack_frame(src, y, u, v, w); @@ -85,25 +87,40 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th w += 6; } -if (w < avctx->width - 1) { +if (w++ < avctx->width) { READ_PIXELS(u, y, v); -val = av_le2ne32(*src++); -*y++ = val & 0x3FF; -if (w < avctx->width - 3) { -*u++ = (val >> 10) & 0x3FF; -*y++ = (val >> 20) & 0x3FF; - +if (w++ < avctx->width) { val = av_le2ne32(*src++); -*v++ = val & 0x3FF; -*y++ = (val >> 10) & 0x3FF; +*y++ = val & 0x3FF; + +if (w++ < avctx->width) { +*u++ = (val >> 10) & 0x3FF; +*y++ = (val >> 20) & 0x3FF; +val = av_le2ne32(*src++); +*v++ = val & 0x3FF; + +if (w++ < avctx->width) { +*y++ = (val >> 10) & 0x3FF; + +if (w++ < avctx->width) { +*u++ = (val >> 20) & 0x3FF; +val = av_le2ne32(*src++); +*y++ = val & 0x3FF; +*v++ = (val >> 10) & 0x3FF; + +if (w++ < avctx->width) +*y++ = (val >> 20) & 0x3FF; +} +} +} } } psrc += stride; -y += frame->linesize[0] / 2 - avctx->width + (avctx->width & 1); -u += frame->linesize[1] / 2 - avctx->width / 2; -v += frame->linesize[2] / 2 - avctx->width / 2; +py += frame->linesize[0] / 2; +pu += frame->linesize[1] / 2; +pv += frame->linesize[2] / 2; } return 0; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/v210dec: factorize row decoding
ffmpeg | branch: master | Marton Balint | Sun Jun 12 00:04:12 2022 +0200| [a5c7d3173c756e9a9b33f1620e3620eb60dd52b4] | committer: Marton Balint avcodec/v210dec: factorize row decoding Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a5c7d3173c756e9a9b33f1620e3620eb60dd52b4 --- libavcodec/v210dec.c | 108 +-- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c index 48ebe57100..c89440658f 100644 --- a/libavcodec/v210dec.c +++ b/libavcodec/v210dec.c @@ -50,10 +50,61 @@ static av_cold int decode_init(AVCodecContext *avctx) return 0; } +static void decode_row(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, const int width, + void (*unpack_frame)(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width)) +{ +uint32_t val; +int w = (width / 12) * 12; + +unpack_frame(src, y, u, v, w); + +y += w; +u += w >> 1; +v += w >> 1; +src += (w << 1) / 3; + +if (w < width - 5) { +READ_PIXELS(u, y, v); +READ_PIXELS(y, u, y); +READ_PIXELS(v, y, u); +READ_PIXELS(y, v, y); +w += 6; +} + +if (w++ < width) { +READ_PIXELS(u, y, v); + +if (w++ < width) { +val = av_le2ne32(*src++); +*y++ = val & 0x3FF; + +if (w++ < width) { +*u++ = (val >> 10) & 0x3FF; +*y++ = (val >> 20) & 0x3FF; +val = av_le2ne32(*src++); +*v++ = val & 0x3FF; + +if (w++ < width) { +*y++ = (val >> 10) & 0x3FF; + +if (w++ < width) { +*u++ = (val >> 20) & 0x3FF; +val = av_le2ne32(*src++); +*y++ = val & 0x3FF; +*v++ = (val >> 10) & 0x3FF; + +if (w++ < width) +*y++ = (val >> 20) & 0x3FF; +} +} +} +} +} +} + static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int threadnr) { V210DecContext *s = avctx->priv_data; -int h, w; ThreadData *td = arg; AVFrame *frame = td->frame; int stride = td->stride; @@ -64,59 +115,8 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th int16_t *pu = (uint16_t*)frame->data[1] + slice_start * frame->linesize[1] / 2; int16_t *pv = (uint16_t*)frame->data[2] + slice_start * frame->linesize[2] / 2; -for (h = slice_start; h < slice_end; h++) { -const uint32_t *src = (const uint32_t*)psrc; -uint32_t val; -uint16_t *y = py; -uint16_t *u = pu; -uint16_t *v = pv; - -w = (avctx->width / 12) * 12; -s->unpack_frame(src, y, u, v, w); - -y += w; -u += w >> 1; -v += w >> 1; -src += (w << 1) / 3; - -if (w < avctx->width - 5) { -READ_PIXELS(u, y, v); -READ_PIXELS(y, u, y); -READ_PIXELS(v, y, u); -READ_PIXELS(y, v, y); -w += 6; -} - -if (w++ < avctx->width) { -READ_PIXELS(u, y, v); - -if (w++ < avctx->width) { -val = av_le2ne32(*src++); -*y++ = val & 0x3FF; - -if (w++ < avctx->width) { -*u++ = (val >> 10) & 0x3FF; -*y++ = (val >> 20) & 0x3FF; -val = av_le2ne32(*src++); -*v++ = val & 0x3FF; - -if (w++ < avctx->width) { -*y++ = (val >> 10) & 0x3FF; - -if (w++ < avctx->width) { -*u++ = (val >> 20) & 0x3FF; -val = av_le2ne32(*src++); -*y++ = val & 0x3FF; -*v++ = (val >> 10) & 0x3FF; - -if (w++ < avctx->width) -*y++ = (val >> 20) & 0x3FF; -} -} -} -} -} - +for (int h = slice_start; h < slice_end; h++) { +decode_row((const uint32_t *)psrc, py, pu, pv, avctx->width, s->unpack_frame); psrc += stride; py += frame->linesize[0] / 2; pu += frame->linesize[1] / 2; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/v210dec: do not use accelerated code for the last pixels of a row
ffmpeg | branch: master | Marton Balint | Sun Jun 12 02:44:38 2022 +0200| [2e895edb5d2ae820e8ead0fbccea3fe2b5749287] | committer: Marton Balint avcodec/v210dec: do not use accelerated code for the last pixels of a row ASM code tends to overwrite the buffers by 2-4 bytes and it can cause issues with slice threads. Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2e895edb5d2ae820e8ead0fbccea3fe2b5749287 --- libavcodec/v210dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c index e97f43a8e6..4268b5b748 100644 --- a/libavcodec/v210dec.c +++ b/libavcodec/v210dec.c @@ -54,7 +54,7 @@ static void decode_row(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t * void (*unpack_frame)(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width)) { uint32_t val; -int w = (width / 12) * 12; +int w = (FFMAX(0, width - 12) / 12) * 12; unpack_frame(src, y, u, v, w); @@ -63,7 +63,7 @@ static void decode_row(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t * v += w >> 1; src += (w << 1) / 3; -if (w < width - 5) { +while (w < width - 5) { READ_PIXELS(u, y, v); READ_PIXELS(y, u, y); READ_PIXELS(v, y, u); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/v210dec: disallow negative custom stride
ffmpeg | branch: master | Marton Balint | Sun Jun 12 00:13:27 2022 +0200| [571683696306f22d9519f62dcffb2164d49ee3c5] | committer: Marton Balint avcodec/v210dec: disallow negative custom stride Also make sure a big custom stride does not overflow size check. Avoids segfaults. Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=571683696306f22d9519f62dcffb2164d49ee3c5 --- libavcodec/v210dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c index c89440658f..e97f43a8e6 100644 --- a/libavcodec/v210dec.c +++ b/libavcodec/v210dec.c @@ -141,7 +141,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic, stride = aligned_width * 8 / 3; } -if (avpkt->size < stride * avctx->height) { +if (avpkt->size < (int64_t)stride * avctx->height) { if avctx->width + 23) / 24) * 24 * 8) / 3 * avctx->height == avpkt->size) { stride = avpkt->size / avctx->height; if (!s->stride_warning_shown) @@ -190,7 +190,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic, #define V210DEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM static const AVOption v210dec_options[] = { {"custom_stride", "Custom V210 stride", offsetof(V210DecContext, custom_stride), AV_OPT_TYPE_INT, - {.i64 = 0}, INT_MIN, INT_MAX, V210DEC_FLAGS}, + {.i64 = 0}, 0, INT_MAX, V210DEC_FLAGS}, {NULL} }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/v210dec: add support for strideless v210 as in BOXX files
ffmpeg | branch: master | Marton Balint | Sun Jun 12 03:38:56 2022 +0200| [96f2fc3841f3c71c9d166d1fabe345687e827bd5] | committer: Marton Balint avcodec/v210dec: add support for strideless v210 as in BOXX files Fixes ticket #1838. Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=96f2fc3841f3c71c9d166d1fabe345687e827bd5 --- libavcodec/v210dec.c | 34 +++--- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c index ba48bb6fe4..bf84cd4428 100644 --- a/libavcodec/v210dec.c +++ b/libavcodec/v210dec.c @@ -26,6 +26,7 @@ #include "v210dec.h" #include "v210dec_init.h" #include "libavutil/bswap.h" +#include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "thread.h" @@ -140,7 +141,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic, const uint8_t *psrc = avpkt->data; if (s->custom_stride ) -stride = s->custom_stride; +stride = s->custom_stride > 0 ? s->custom_stride : 0; else { stride = v210_stride(avctx->width, 48); if (avpkt->size < stride * avctx->height) { @@ -155,14 +156,21 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic, break; } } +if (align < 6 && avctx->codec_tag == MKTAG('b', 'x', 'y', '2')) +stride = 0; } } -if (avpkt->size < (int64_t)stride * avctx->height) { +if (stride == 0 && ((avctx->width & 1) || (int64_t)avctx->width * avctx->height > INT_MAX / 6)) { +av_log(avctx, AV_LOG_ERROR, "Strideless v210 is not supported for size %dx%d\n", avctx->width, avctx->height); +return AVERROR_INVALIDDATA; +} + +if (stride > 0 && avpkt->size < (int64_t)stride * avctx->height || +stride == 0 && avpkt->size < v210_stride(avctx->width * avctx->height, 6)) { av_log(avctx, AV_LOG_ERROR, "packet too small\n"); return AVERROR_INVALIDDATA; } -td.stride = stride; if ( avctx->codec_tag == MKTAG('C', '2', '1', '0') && avpkt->size > 64 && AV_RN32(psrc) == AV_RN32("INFO") @@ -181,9 +189,21 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic, pic->pict_type = AV_PICTURE_TYPE_I; pic->key_frame = 1; -td.buf = (uint8_t*)psrc; -td.frame = pic; -avctx->execute2(avctx, v210_decode_slice, &td, NULL, s->thread_count); +if (stride) { +td.stride = stride; +td.buf = (uint8_t*)psrc; +td.frame = pic; +avctx->execute2(avctx, v210_decode_slice, &td, NULL, s->thread_count); +} else { +uint8_t *pointers[4]; +int linesizes[4]; +int ret = av_image_alloc(pointers, linesizes, avctx->width, avctx->height, avctx->pix_fmt, 1); +if (ret < 0) +return ret; +decode_row((const uint32_t *)psrc, (uint16_t *)pointers[0], (uint16_t *)pointers[1], (uint16_t *)pointers[2], avctx->width * avctx->height, s->unpack_frame); +av_image_copy(pic->data, pic->linesize, (const uint8_t **)pointers, linesizes, avctx->pix_fmt, avctx->width, avctx->height); +av_freep(&pointers[0]); +} if (avctx->field_order > AV_FIELD_PROGRESSIVE) { /* we have interlaced material flagged in container */ @@ -200,7 +220,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic, #define V210DEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM static const AVOption v210dec_options[] = { {"custom_stride", "Custom V210 stride", offsetof(V210DecContext, custom_stride), AV_OPT_TYPE_INT, - {.i64 = 0}, 0, INT_MAX, V210DEC_FLAGS}, + {.i64 = 0}, -1, INT_MAX, V210DEC_FLAGS}, {NULL} }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/v210dec: add support for invalid paddings up to 16 bytes
ffmpeg | branch: master | Marton Balint | Sun Jun 12 04:27:53 2022 +0200| [a10132b967a1989366950800c155ed2c07271cca] | committer: Marton Balint avcodec/v210dec: add support for invalid paddings up to 16 bytes Fixes ticket #1528. Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a10132b967a1989366950800c155ed2c07271cca --- libavcodec/v210dec.c | 32 +--- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c index 4268b5b748..ba48bb6fe4 100644 --- a/libavcodec/v210dec.c +++ b/libavcodec/v210dec.c @@ -126,6 +126,11 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th return 0; } +static int v210_stride(int width, int align) { +int aligned_width = ((width + align - 1) / align) * align; +return aligned_width * 8 / 3; +} + static int decode_frame(AVCodecContext *avctx, AVFrame *pic, int *got_frame, AVPacket *avpkt) { @@ -137,20 +142,25 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic, if (s->custom_stride ) stride = s->custom_stride; else { -int aligned_width = ((avctx->width + 47) / 48) * 48; -stride = aligned_width * 8 / 3; +stride = v210_stride(avctx->width, 48); +if (avpkt->size < stride * avctx->height) { +int align; +for (align = 24; align >= 6; align >>= 1) { +int small_stride = v210_stride(avctx->width, align); +if (avpkt->size == small_stride * avctx->height) { +stride = small_stride; +if (!s->stride_warning_shown) +av_log(avctx, AV_LOG_WARNING, "Broken v210 with too small padding (%d byte) detected\n", align * 8 / 3); +s->stride_warning_shown = 1; +break; +} +} +} } if (avpkt->size < (int64_t)stride * avctx->height) { -if avctx->width + 23) / 24) * 24 * 8) / 3 * avctx->height == avpkt->size) { -stride = avpkt->size / avctx->height; -if (!s->stride_warning_shown) -av_log(avctx, AV_LOG_WARNING, "Broken v210 with too small padding (64 byte) detected\n"); -s->stride_warning_shown = 1; -} else { -av_log(avctx, AV_LOG_ERROR, "packet too small\n"); -return AVERROR_INVALIDDATA; -} +av_log(avctx, AV_LOG_ERROR, "packet too small\n"); +return AVERROR_INVALIDDATA; } td.stride = stride; if ( avctx->codec_tag == MKTAG('C', '2', '1', '0') ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] doc/decoders: add docs for v210 decoder
ffmpeg | branch: master | Marton Balint | Sun Jun 12 13:55:50 2022 +0200| [5468548d5e161d2e28a2611f8a9c14ebb164da42] | committer: Marton Balint doc/decoders: add docs for v210 decoder Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5468548d5e161d2e28a2611f8a9c14ebb164da42 --- doc/decoders.texi | 15 +++ 1 file changed, 15 insertions(+) diff --git a/doc/decoders.texi b/doc/decoders.texi index de2429abba..e2fcbf5dc9 100644 --- a/doc/decoders.texi +++ b/doc/decoders.texi @@ -168,6 +168,21 @@ A :-separate list of hexadecimal plugin UIDs to load in an internal session @end table +@section v210 + +Uncompressed 4:2:2 10-bit decoder. + +@subsection Options + +@table @option + +@item custom_stride +Set the line size of the v210 data in bytes. The default value is 0 +(autodetect). You can use the special -1 value for a strideless v210 as seen in +BOXX files. + +@end table + @c man end VIDEO DECODERS @chapter Audio Decoders ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/mpegts: remove obsolate hacks for detecting streams with bad PMTs
ffmpeg | branch: master | Marton Balint | Tue Jun 14 00:32:05 2022 +0200| [58df81b02779c9c87cbf5403cfdbb437d5344669] | committer: Marton Balint avformat/mpegts: remove obsolate hacks for detecting streams with bad PMTs Ffmpeg/ffprobe/ffplay sets scan_all_pmts to 1 when finding the streams, that should be enough to handle files for which some early PMTs miss some streams. Fixes ticket #9782. Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=58df81b02779c9c87cbf5403cfdbb437d5344669 --- libavformat/mpegts.c | 12 ++-- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 6e761c07f1..8a3436f2be 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2870,16 +2870,8 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet, int64_t pos) break; } if (i == ts->nb_prg && ts->nb_prg > 0) { -int types = 0; -for (i = 0; i < ts->stream->nb_streams; i++) { -AVStream *st = ts->stream->streams[i]; -if (st->codecpar->codec_type >= 0) -types |= 1codec_type; -} -if ((types & (1< 10) { -av_log(ts->stream, AV_LOG_DEBUG, "All programs have pmt, headers found\n"); -ts->stream->ctx_flags &= ~AVFMTCTX_NOHEADER; -} +av_log(ts->stream, AV_LOG_DEBUG, "All programs have pmt, headers found\n"); +ts->stream->ctx_flags &= ~AVFMTCTX_NOHEADER; } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/matroskaenc: Don't waste bytes to Write Tag length fields
ffmpeg | branch: master | Andreas Rheinhardt | Wed Jun 15 11:25:12 2022 +0200| [b468ddc75dde91cdb434457e7efc3d9efe40ddcf] | committer: Andreas Rheinhardt avformat/matroskaenc: Don't waste bytes to Write Tag length fields This is possible by using a dynamic buffer to write them; said dynamic buffer is (re)used and reset as appropriate. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b468ddc75dde91cdb434457e7efc3d9efe40ddcf --- libavformat/matroskaenc.c | 113 +++-- tests/ref/fate/aac-autobsf-adtstoasc | 4 +- tests/ref/fate/matroska-avoid-negative-ts | 4 +- tests/ref/fate/matroska-dovi-write-config7 | 4 +- tests/ref/fate/matroska-dovi-write-config8 | 4 +- tests/ref/fate/matroska-dvbsub-remux | 4 +- tests/ref/fate/matroska-flac-extradata-update | 4 +- tests/ref/fate/matroska-h264-remux | 4 +- tests/ref/fate/matroska-mastering-display-metadata | 4 +- tests/ref/fate/matroska-move-cues-to-front | 4 +- tests/ref/fate/matroska-mpegts-remux | 4 +- tests/ref/fate/matroska-ms-mode| 4 +- tests/ref/fate/matroska-pgs-remux | 4 +- tests/ref/fate/matroska-pgs-remux-durations| 4 +- tests/ref/fate/matroska-qt-mode| 4 +- tests/ref/fate/matroska-spherical-mono-remux | 4 +- tests/ref/fate/matroska-vp8-alpha-remux| 4 +- tests/ref/fate/matroska-zero-length-block | 4 +- tests/ref/fate/rgb24-mkv | 4 +- tests/ref/fate/webm-dash-chapters | 4 +- tests/ref/fate/webm-webvtt-remux | 4 +- tests/ref/lavf-fate/av1.mkv| 4 +- tests/ref/lavf/mka | 4 +- tests/ref/lavf/mkv | 4 +- tests/ref/lavf/mkv_attachment | 4 +- tests/ref/seek/lavf-mkv| 44 26 files changed, 131 insertions(+), 122 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index c32d4286c1..a8eadd49ea 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -216,6 +216,13 @@ typedef struct MatroskaMuxContext { BlockContextcur_block; +/* Used as temporary buffer to use the minimal amount of bytes + * to write the length field of EBML Masters. + * Every user has to reset the buffer after using it and + * different uses may not overlap. It is currently used in + * mkv_write_tag(). */ +AVIOContext*tmp_bc; + AVPacket *cur_audio_pkt; unsignednb_attachments; @@ -247,6 +254,9 @@ typedef struct MatroskaMuxContext { /** 4 * (1-byte EBML ID, 1-byte EBML size, 8-byte uint max) */ #define MAX_CUETRACKPOS_SIZE 40 +/** 2 + 1 Simpletag header, 2 + 1 + 8 Name "DURATION", 23B for TagString */ +#define DURATION_SIMPLETAG_SIZE (2 + 1 + (2 + 1 + 8) + 23) + /** Seek preroll value for opus */ #define OPUS_SEEK_PREROLL 8000 @@ -824,6 +834,7 @@ static void mkv_deinit(AVFormatContext *s) ffio_free_dyn_buf(&mkv->info.bc); ffio_free_dyn_buf(&mkv->track.bc); ffio_free_dyn_buf(&mkv->tags.bc); +ffio_free_dyn_buf(&mkv->tmp_bc); av_freep(&mkv->cur_block.h2645_nalu_list.nalus); av_freep(&mkv->cues.entries); @@ -1921,24 +1932,14 @@ static int mkv_write_simpletag(AVIOContext *pb, const AVDictionaryEntry *t) return ret; } -static int mkv_write_tag_targets(MatroskaMuxContext *mkv, AVIOContext **pb, - ebml_master *tag, uint32_t elementid, uint64_t uid) +static void mkv_write_tag_targets(MatroskaMuxContext *mkv, AVIOContext *pb, + uint32_t elementid, uint64_t uid) { -ebml_master targets; -int ret; - -if (!*pb) { -ret = start_ebml_master_crc32(pb, mkv); -if (ret < 0) -return ret; -} - -*tag= start_ebml_master(*pb, MATROSKA_ID_TAG,0); -targets = start_ebml_master(*pb, MATROSKA_ID_TAGTARGETS, 4 + 1 + 8); +ebml_master targets = start_ebml_master(pb, MATROSKA_ID_TAGTARGETS, +4 + 1 + 8); if (elementid) -put_ebml_uid(*pb, elementid, uid); -end_ebml_master(*pb, targets); -return 0; +put_ebml_uid(pb, elementid, uid); +end_ebml_master(pb, targets); } static int mkv_check_tag_name(const char *name, uint32_t elementid) @@ -1956,29 +1957,41 @@ static int mkv_check_tag_name(const char *name, uint32_t elementid) } static int mkv_write_tag(MatroskaMuxContext *mkv, const AVDictionary *m, - AVIOContext **pb, ebml_master *tag, + AVIOContext **pb, unsigned reserved_size, uint32_t elementid, uint64_t uid) { const A
[FFmpeg-cvslog] avformat/matroskaenc: Don't check twice whether to write tags
ffmpeg | branch: master | Andreas Rheinhardt | Wed Jun 15 11:49:48 2022 +0200| [fe662516a526c3821b77057c5572bc7f83c21b60] | committer: Andreas Rheinhardt avformat/matroskaenc: Don't check twice whether to write tags Because not all metadata is written as tags, the Matroska muxer filters out the tags that are not written as tags. Therefore the code first checks whether a Tag master element needs to be opened for a given stream/chapter/attachment/global metadata. If the answer turns out to be yes, it is checked again whether a given AVDictionaryEntry is written as a tag. This commit changes this: The Tag element is opened unconditionally and in case it turns out that it was unneeded, it is discarded again. This is possible because the Tag element is written into its own dynamic buffer. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fe662516a526c3821b77057c5572bc7f83c21b60 --- libavformat/matroskaenc.c | 40 +++- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index a8eadd49ea..163af8aec8 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1963,7 +1963,7 @@ static int mkv_write_tag(MatroskaMuxContext *mkv, const AVDictionary *m, const AVDictionaryEntry *t = NULL; AVIOContext *const tmp_bc = mkv->tmp_bc; uint8_t *buf; -int ret, size; +int ret = 0, size, tag_written = 0; mkv_write_tag_targets(mkv, tmp_bc, elementid, uid); @@ -1972,10 +1972,13 @@ static int mkv_write_tag(MatroskaMuxContext *mkv, const AVDictionary *m, ret = mkv_write_simpletag(tmp_bc, t); if (ret < 0) goto end; +tag_written = 1; } } if (reserved_size) put_ebml_void(tmp_bc, reserved_size); +else if (!tag_written) +goto end; size = avio_get_dyn_buf(tmp_bc, &buf); if (tmp_bc->error) { @@ -1994,17 +1997,6 @@ end: return ret; } -static int mkv_check_tag(const AVDictionary *m, uint32_t elementid) -{ -const AVDictionaryEntry *t = NULL; - -while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) -if (mkv_check_tag_name(t->key, elementid)) -return 1; - -return 0; -} - static int mkv_write_tags(AVFormatContext *s) { MatroskaMuxContext *mkv = s->priv_data; @@ -2014,11 +2006,9 @@ static int mkv_write_tags(AVFormatContext *s) ff_metadata_conv_ctx(s, ff_mkv_metadata_conv, NULL); -if (mkv_check_tag(s->metadata, 0)) { -ret = mkv_write_tag(mkv, s->metadata, &mkv->tags.bc, 0, 0, 0); -if (ret < 0) -return ret; -} +ret = mkv_write_tag(mkv, s->metadata, &mkv->tags.bc, 0, 0, 0); +if (ret < 0) +return ret; for (i = 0; i < s->nb_streams; i++) { const AVStream *st = s->streams[i]; @@ -2027,9 +2017,6 @@ static int mkv_write_tags(AVFormatContext *s) if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT) continue; -if (!seekable && !mkv_check_tag(st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID)) -continue; - ret = mkv_write_tag(mkv, st->metadata, &mkv->tags.bc, seekable ? DURATION_SIMPLETAG_SIZE : 0, MATROSKA_ID_TAGTARGETS_TRACKUID, track->uid); @@ -2047,9 +2034,6 @@ static int mkv_write_tags(AVFormatContext *s) if (st->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT) continue; -if (!mkv_check_tag(st->metadata, MATROSKA_ID_TAGTARGETS_ATTACHUID)) -continue; - ret = mkv_write_tag(mkv, st->metadata, &mkv->tags.bc, 0, MATROSKA_ID_TAGTARGETS_ATTACHUID, track->uid); if (ret < 0) @@ -2134,12 +2118,10 @@ static int mkv_write_chapters(AVFormatContext *s) if (tags) { ff_metadata_conv(&c->metadata, ff_mkv_metadata_conv, NULL); -if (mkv_check_tag(c->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID)) { -ret = mkv_write_tag(mkv, c->metadata, tags, 0, -MATROSKA_ID_TAGTARGETS_CHAPTERUID, uid); -if (ret < 0) -goto fail; -} +ret = mkv_write_tag(mkv, c->metadata, tags, 0, +MATROSKA_ID_TAGTARGETS_CHAPTERUID, uid); +if (ret < 0) +goto fail; } } end_ebml_master(dyn_cp, editionentry); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fftools/ffprobe: report avio errors
ffmpeg | branch: master | Marton Balint | Mon Jun 13 23:02:04 2022 +0200| [c11fb467312716f15247397ebafc0093d5e7cab0] | committer: Marton Balint fftools/ffprobe: report avio errors Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c11fb467312716f15247397ebafc0093d5e7cab0 --- fftools/ffprobe.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 4e2fdbaec8..5020ba484c 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -545,12 +545,13 @@ static const AVClass writer_class = { .child_next = writer_child_next, }; -static void writer_close(WriterContext **wctx) +static int writer_close(WriterContext **wctx) { int i; +int ret = 0; if (!*wctx) -return; +return -1; if ((*wctx)->writer->uninit) (*wctx)->writer->uninit(*wctx); @@ -562,9 +563,10 @@ static void writer_close(WriterContext **wctx) av_opt_free(*wctx); if ((*wctx)->avio) { avio_flush((*wctx)->avio); -avio_close((*wctx)->avio); +ret = avio_close((*wctx)->avio); } av_freep(wctx); +return ret; } static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size) @@ -4145,7 +4147,9 @@ int main(int argc, char **argv) } writer_print_section_footer(wctx); -writer_close(&wctx); +ret = writer_close(&wctx); +if (ret < 0) +av_log(NULL, AV_LOG_ERROR, "Writing output failed: %s\n", av_err2str(ret)); } end: ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".