[FFmpeg-cvslog] Merge commit '239d02eff3ffe9f7d40caa21dde50fb4a0e94c24'
ffmpeg | branch: master | Clément Bœsch | Fri Apr 7 10:07:43 2017 +0200| [92e532c18fee1d1ab2b8ed1ffe95696176df68ab] | committer: Clément Bœsch Merge commit '239d02eff3ffe9f7d40caa21dde50fb4a0e94c24' * commit '239d02eff3ffe9f7d40caa21dde50fb4a0e94c24': avisynth: Cast to the right type when loading avisynth library functions This commit is a noop, we are using dlsym() instead of GetProcAdress(). Merged-by: Clément Bœsch > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=92e532c18fee1d1ab2b8ed1ffe95696176df68ab --- ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avisynth: Cast to the right type when loading avisynth library functions
ffmpeg | branch: master | Diego Biurrun | Thu Nov 24 12:46:30 2016 +0100| [239d02eff3ffe9f7d40caa21dde50fb4a0e94c24] | committer: Diego Biurrun avisynth: Cast to the right type when loading avisynth library functions Fixes a number of related warnings. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=239d02eff3ffe9f7d40caa21dde50fb4a0e94c24 --- libavformat/avisynth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index fd5f323..d3b3ec4 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -127,7 +127,8 @@ static av_cold int avisynth_load_library(void) return AVERROR_UNKNOWN; #define LOAD_AVS_FUNC(name, continue_on_fail) \ -avs_library.name = GetProcAddress(avs_library.library, #name); \ +avs_library.name = (name ## _func) \ + GetProcAddress(avs_library.library, #name); \ if (!continue_on_fail && !avs_library.name)\ goto fail; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit '3ee5f25d37315b27f0e2d47aa69fc445545ee2e3'
ffmpeg | branch: master | Clément Bœsch | Fri Apr 7 10:08:53 2017 +0200| [e7326e2980a079432bf3f5556fdab38e92982fd1] | committer: Clément Bœsch Merge commit '3ee5f25d37315b27f0e2d47aa69fc445545ee2e3' * commit '3ee5f25d37315b27f0e2d47aa69fc445545ee2e3': dxva2: Adjust printf length modifiers where appropriate Merged-by: Clément Bœsch > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e7326e2980a079432bf3f5556fdab38e92982fd1 --- libavcodec/dxva2.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index c782f1c..0036b5b 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -83,7 +83,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, &dxva_data, &dxva_size); #endif if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to get a buffer for %u: 0x%lx\n", +av_log(avctx, AV_LOG_ERROR, "Failed to get a buffer for %u: 0x%x\n", type, hr); return -1; } @@ -125,7 +125,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, #endif if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, - "Failed to release buffer type %u: 0x%lx\n", + "Failed to release buffer type %u: 0x%x\n", type, hr); result = -1; } @@ -179,7 +179,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, } while(1); if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%lx\n", hr); +av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", hr); #if CONFIG_D3D11VA if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) @@ -278,7 +278,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, } #endif if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to execute: 0x%lx\n", hr); +av_log(avctx, AV_LOG_ERROR, "Failed to execute: 0x%x\n", hr); result = -1; } @@ -295,7 +295,7 @@ end: hr = IDirectXVideoDecoder_EndFrame(DXVA2_CONTEXT(ctx)->decoder, NULL); #endif if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%lx\n", hr); +av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%x\n", hr); result = -1; } == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva2: Adjust printf length modifiers where appropriate
ffmpeg | branch: master | Diego Biurrun | Thu Nov 24 12:46:31 2016 +0100| [3ee5f25d37315b27f0e2d47aa69fc445545ee2e3] | committer: Diego Biurrun dxva2: Adjust printf length modifiers where appropriate > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3ee5f25d37315b27f0e2d47aa69fc445545ee2e3 --- libavcodec/dxva2.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 9fedd03..6063993 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -83,7 +83,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, &dxva_data, &dxva_size); #endif if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to get a buffer for %u: 0x%lx\n", +av_log(avctx, AV_LOG_ERROR, "Failed to get a buffer for %u: 0x%x\n", type, hr); return -1; } @@ -125,7 +125,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, #endif if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, - "Failed to release buffer type %u: 0x%lx\n", + "Failed to release buffer type %u: 0x%x\n", type, hr); result = -1; } @@ -179,7 +179,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, } while(1); if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%lx\n", hr); +av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", hr); #if CONFIG_D3D11VA if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) @@ -278,7 +278,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, } #endif if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to execute: 0x%lx\n", hr); +av_log(avctx, AV_LOG_ERROR, "Failed to execute: 0x%x\n", hr); result = -1; } @@ -295,7 +295,7 @@ end: hr = IDirectXVideoDecoder_EndFrame(DXVA2_CONTEXT(ctx)->decoder, NULL); #endif if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%lx\n", hr); +av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%x\n", hr); result = -1; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] mjpegdec: Check return values of functions that may fail
ffmpeg | branch: master | Diego Biurrun | Wed May 11 08:59:17 2016 +0200| [212c6a1d70df011b6f2a2aa02f7677503287bd00] | committer: Diego Biurrun mjpegdec: Check return values of functions that may fail > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=212c6a1d70df011b6f2a2aa02f7677503287bd00 --- libavcodec/mjpegdec.c | 70 ++- 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index a4a6c63..f6e9038 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -68,25 +68,42 @@ static int build_vlc(VLC *vlc, const uint8_t *bits_table, huff_code, 2, 2, huff_sym, 2, 2, use_static); } -static void build_basic_mjpeg_vlc(MJpegDecodeContext *s) +static int build_basic_mjpeg_vlc(MJpegDecodeContext *s) { -build_vlc(&s->vlcs[0][0], avpriv_mjpeg_bits_dc_luminance, - avpriv_mjpeg_val_dc, 12, 0, 0); -build_vlc(&s->vlcs[0][1], avpriv_mjpeg_bits_dc_chrominance, - avpriv_mjpeg_val_dc, 12, 0, 0); -build_vlc(&s->vlcs[1][0], avpriv_mjpeg_bits_ac_luminance, - avpriv_mjpeg_val_ac_luminance, 251, 0, 1); -build_vlc(&s->vlcs[1][1], avpriv_mjpeg_bits_ac_chrominance, - avpriv_mjpeg_val_ac_chrominance, 251, 0, 1); -build_vlc(&s->vlcs[2][0], avpriv_mjpeg_bits_ac_luminance, - avpriv_mjpeg_val_ac_luminance, 251, 0, 0); -build_vlc(&s->vlcs[2][1], avpriv_mjpeg_bits_ac_chrominance, - avpriv_mjpeg_val_ac_chrominance, 251, 0, 0); +int ret; + +if ((ret = build_vlc(&s->vlcs[0][0], avpriv_mjpeg_bits_dc_luminance, + avpriv_mjpeg_val_dc, 12, 0, 0)) < 0) +return ret; + +if ((ret = build_vlc(&s->vlcs[0][1], avpriv_mjpeg_bits_dc_chrominance, + avpriv_mjpeg_val_dc, 12, 0, 0)) < 0) +return ret; + +if ((ret = build_vlc(&s->vlcs[1][0], avpriv_mjpeg_bits_ac_luminance, + avpriv_mjpeg_val_ac_luminance, 251, 0, 1)) < 0) +return ret; + +if ((ret = build_vlc(&s->vlcs[1][1], avpriv_mjpeg_bits_ac_chrominance, + avpriv_mjpeg_val_ac_chrominance, 251, 0, 1)) < 0) +return ret; + +if ((ret = build_vlc(&s->vlcs[2][0], avpriv_mjpeg_bits_ac_luminance, + avpriv_mjpeg_val_ac_luminance, 251, 0, 0)) < 0) +return ret; + +if ((ret = build_vlc(&s->vlcs[2][1], avpriv_mjpeg_bits_ac_chrominance, + avpriv_mjpeg_val_ac_chrominance, 251, 0, 0)) < 0) +return ret; + + +return 0; } av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) { MJpegDecodeContext *s = avctx->priv_data; +int ret; if (!s->picture_ptr) { s->picture = av_frame_alloc(); @@ -109,12 +126,13 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) avctx->chroma_sample_location = AVCHROMA_LOC_CENTER; avctx->colorspace = AVCOL_SPC_BT470BG; -build_basic_mjpeg_vlc(s); +if ((ret = build_basic_mjpeg_vlc(s)) < 0) +return ret; if (s->extern_huff) { -int ret; av_log(avctx, AV_LOG_INFO, "mjpeg: using external huffman table\n"); -init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8); +if ((ret = init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8)) < 0) +return ret; if ((ret = ff_mjpeg_decode_dht(s))) { av_log(avctx, AV_LOG_ERROR, "mjpeg: error using external huffman table\n"); @@ -248,7 +266,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) height= s->height; av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height); -if (av_image_check_size(width, height, 0, s->avctx)) +if (av_image_check_size(width, height, 0, s->avctx) < 0) return AVERROR_INVALIDDATA; nb_components = get_bits(&s->gb, 8); @@ -686,6 +704,9 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int predictor, av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size, (unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0])); +if (!s->ljpeg_buffer) +return AVERROR(ENOMEM); + buffer = s->ljpeg_buffer; for (i = 0; i < 3; i++) @@ -1502,14 +1523,15 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, av_log(avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code); /* process markers */ -if (start_code >= 0xd0 && start_code <= 0xd7) +if (start_code >= 0xd0 && start_code <= 0xd7) { av_log(avctx, AV_LOG_DEBUG, "restart marker: %d\n", start_code & 0x0f); /* APP fields */ -else if (start_code >= APP0 && start_code <= APP15) -mjpeg_decode_app(s); +} else if (start_code >= APP0 && start_code <= APP15) { +if ((ret = mjpeg_decode_app(s)) < 0) +
[FFmpeg-cvslog] Merge commit '212c6a1d70df011b6f2a2aa02f7677503287bd00'
ffmpeg | branch: master | Clément Bœsch | Fri Apr 7 10:17:53 2017 +0200| [9c7ee37490d21350ab1a2e07069284daf1943e52] | committer: Clément Bœsch Merge commit '212c6a1d70df011b6f2a2aa02f7677503287bd00' * commit '212c6a1d70df011b6f2a2aa02f7677503287bd00': mjpegdec: Check return values of functions that may fail Merged-by: Clément Bœsch > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9c7ee37490d21350ab1a2e07069284daf1943e52 --- libavcodec/mjpegdec.c | 70 +++ 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 5470b66..cef3b38 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -71,20 +71,36 @@ static int build_vlc(VLC *vlc, const uint8_t *bits_table, huff_code, 2, 2, huff_sym, 2, 2, use_static); } -static void build_basic_mjpeg_vlc(MJpegDecodeContext *s) +static int build_basic_mjpeg_vlc(MJpegDecodeContext *s) { -build_vlc(&s->vlcs[0][0], avpriv_mjpeg_bits_dc_luminance, - avpriv_mjpeg_val_dc, 12, 0, 0); -build_vlc(&s->vlcs[0][1], avpriv_mjpeg_bits_dc_chrominance, - avpriv_mjpeg_val_dc, 12, 0, 0); -build_vlc(&s->vlcs[1][0], avpriv_mjpeg_bits_ac_luminance, - avpriv_mjpeg_val_ac_luminance, 251, 0, 1); -build_vlc(&s->vlcs[1][1], avpriv_mjpeg_bits_ac_chrominance, - avpriv_mjpeg_val_ac_chrominance, 251, 0, 1); -build_vlc(&s->vlcs[2][0], avpriv_mjpeg_bits_ac_luminance, - avpriv_mjpeg_val_ac_luminance, 251, 0, 0); -build_vlc(&s->vlcs[2][1], avpriv_mjpeg_bits_ac_chrominance, - avpriv_mjpeg_val_ac_chrominance, 251, 0, 0); +int ret; + +if ((ret = build_vlc(&s->vlcs[0][0], avpriv_mjpeg_bits_dc_luminance, + avpriv_mjpeg_val_dc, 12, 0, 0)) < 0) +return ret; + +if ((ret = build_vlc(&s->vlcs[0][1], avpriv_mjpeg_bits_dc_chrominance, + avpriv_mjpeg_val_dc, 12, 0, 0)) < 0) +return ret; + +if ((ret = build_vlc(&s->vlcs[1][0], avpriv_mjpeg_bits_ac_luminance, + avpriv_mjpeg_val_ac_luminance, 251, 0, 1)) < 0) +return ret; + +if ((ret = build_vlc(&s->vlcs[1][1], avpriv_mjpeg_bits_ac_chrominance, + avpriv_mjpeg_val_ac_chrominance, 251, 0, 1)) < 0) +return ret; + +if ((ret = build_vlc(&s->vlcs[2][0], avpriv_mjpeg_bits_ac_luminance, + avpriv_mjpeg_val_ac_luminance, 251, 0, 0)) < 0) +return ret; + +if ((ret = build_vlc(&s->vlcs[2][1], avpriv_mjpeg_bits_ac_chrominance, + avpriv_mjpeg_val_ac_chrominance, 251, 0, 0)) < 0) +return ret; + + +return 0; } static void parse_avid(MJpegDecodeContext *s, uint8_t *buf, int len) @@ -110,6 +126,7 @@ static void init_idct(AVCodecContext *avctx) av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) { MJpegDecodeContext *s = avctx->priv_data; +int ret; if (!s->picture_ptr) { s->picture = av_frame_alloc(); @@ -131,11 +148,13 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) avctx->chroma_sample_location = AVCHROMA_LOC_CENTER; avctx->colorspace = AVCOL_SPC_BT470BG; -build_basic_mjpeg_vlc(s); +if ((ret = build_basic_mjpeg_vlc(s)) < 0) +return ret; if (s->extern_huff) { av_log(avctx, AV_LOG_INFO, "using external huffman table\n"); -init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8); +if ((ret = init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8)) < 0) +return ret; if (ff_mjpeg_decode_dht(s)) { av_log(avctx, AV_LOG_ERROR, "error using external huffman table, switching back to internal\n"); @@ -307,7 +326,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) height= s->height; av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height); -if (av_image_check_size(width, height, 0, s->avctx)) +if (av_image_check_size(width, height, 0, s->avctx) < 0) return AVERROR_INVALIDDATA; nb_components = get_bits(&s->gb, 8); @@ -969,6 +988,9 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size, (unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0])); +if (!s->ljpeg_buffer) +return AVERROR(ENOMEM); + buffer = s->ljpeg_buffer; for (i = 0; i < 4; i++) @@ -2116,19 +2138,22 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, av_log(avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code); /* process markers */ -if (start_code >= 0xd0 && start_code <= 0xd7) +if (start_code >= 0xd0 && start_code <= 0xd7) { av_log(avctx, AV_LOG_DEBUG, "restart marker: %d\n", star
[FFmpeg-cvslog] avcodec/h264: Check weight values to be within the specs limits.
ffmpeg | branch: master | Michael Niedermayer | Tue Mar 21 23:46:14 2017 +0100| [08117a40157464f8a9dcc2df393fa5fe299c1e98] | committer: Michael Niedermayer avcodec/h264: Check weight values to be within the specs limits. Fixes: integer overflows Fixes: 911/clusterfuzz-testcase-5415105606975488 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Reviewed-by: "Ronald S. Bultje" Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=08117a40157464f8a9dcc2df393fa5fe299c1e98 --- libavcodec/h264_parse.c | 9 + libavcodec/h264_slice.c | 7 +-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c index 0c87319..ea202e7 100644 --- a/libavcodec/h264_parse.c +++ b/libavcodec/h264_parse.c @@ -59,6 +59,9 @@ int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps, if (luma_weight_flag) { pwt->luma_weight[i][list][0] = get_se_golomb(gb); pwt->luma_weight[i][list][1] = get_se_golomb(gb); +if ((int8_t)pwt->luma_weight[i][list][0] != pwt->luma_weight[i][list][0] || +(int8_t)pwt->luma_weight[i][list][1] != pwt->luma_weight[i][list][1]) +goto out_range_weight; if (pwt->luma_weight[i][list][0] != luma_def || pwt->luma_weight[i][list][1] != 0) { pwt->use_weight = 1; @@ -76,6 +79,9 @@ int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps, for (j = 0; j < 2; j++) { pwt->chroma_weight[i][list][j][0] = get_se_golomb(gb); pwt->chroma_weight[i][list][j][1] = get_se_golomb(gb); +if ((int8_t)pwt->chroma_weight[i][list][j][0] != pwt->chroma_weight[i][list][j][0] || +(int8_t)pwt->chroma_weight[i][list][j][1] != pwt->chroma_weight[i][list][j][1]) +goto out_range_weight; if (pwt->chroma_weight[i][list][j][0] != chroma_def || pwt->chroma_weight[i][list][j][1] != 0) { pwt->use_weight_chroma= 1; @@ -104,6 +110,9 @@ int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps, } pwt->use_weight = pwt->use_weight || pwt->use_weight_chroma; return 0; +out_range_weight: +avpriv_request_sample(logctx, "Out of range weight\n"); +return AVERROR_INVALIDDATA; } /** diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index d4d31cc..34bd6cf 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1780,9 +1780,12 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, } if ((pps->weighted_pred && sl->slice_type_nos == AV_PICTURE_TYPE_P) || (pps->weighted_bipred_idc == 1 && - sl->slice_type_nos == AV_PICTURE_TYPE_B)) -ff_h264_pred_weight_table(&sl->gb, sps, sl->ref_count, + sl->slice_type_nos == AV_PICTURE_TYPE_B)) { +ret = ff_h264_pred_weight_table(&sl->gb, sps, sl->ref_count, sl->slice_type_nos, &sl->pwt, h->avctx); +if (ret < 0) +return ret; +} sl->explicit_ref_marking = 0; if (nal->ref_idc) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/tta: Don't try to read more than MIN_CACHE_BITS bits
ffmpeg | branch: master | James Almer | Fri Apr 7 12:48:31 2017 -0300| [7c1566fec39492815eda0dc1fdfd18f8bf7ca635] | committer: James Almer avcodec/tta: Don't try to read more than MIN_CACHE_BITS bits This fixes assertion failures introduced in 4fbb56acbe. Reviewed-by: michaelni Reviewed-by: durandal_1707 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7c1566fec39492815eda0dc1fdfd18f8bf7ca635 --- libavcodec/tta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/tta.c b/libavcodec/tta.c index 118b9f7..8f097b3 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -285,7 +285,7 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data, } if (k) { -if (k >= 32 || unary > INT32_MAX >> k) { +if (k > MIN_CACHE_BITS || unary > INT32_MAX >> k) { ret = AVERROR_INVALIDDATA; goto error; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc/mjpegdec: allow failure while decoding APP
ffmpeg | branch: master | Clément Bœsch | Fri Apr 7 17:50:44 2017 +0200| [8d94d9798a6903fc65ceb8e5af843cb6a793e045] | committer: Clément Bœsch lavc/mjpegdec: allow failure while decoding APP Fix decoding frame.jpg from ticket #267 Regression since 9c7ee3749 / 212c6a1d7 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d94d9798a6903fc65ceb8e5af843cb6a793e045 --- libavcodec/mjpegdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index cef3b38..98cbd41 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -2144,7 +2144,8 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, /* APP fields */ } else if (start_code >= APP0 && start_code <= APP15) { if ((ret = mjpeg_decode_app(s)) < 0) -return ret; +av_log(avctx, AV_LOG_ERROR, "unable to decode APP fields: %s\n", + av_err2str(ret)); /* Comment */ } else if (start_code == COM) { ret = mjpeg_decode_com(s); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] h264: don't re-call ff_h264_direct_ref_list_init() w/ frame-mt.
ffmpeg | branch: master | Ronald S. Bultje | Thu Apr 6 11:47:03 2017 -0400| [7f05c5cea04112471d8147487aa3b44141922d09] | committer: Ronald S. Bultje h264: don't re-call ff_h264_direct_ref_list_init() w/ frame-mt. I'm hoping that this will address the remaining tsan fate-h264 issues: WARNING: ThreadSanitizer: data race (pid=24478) Read of size 8 at 0x7dbc0001c828 by main thread (mutexes: write M3243): #0 ff_h264_ref_picture src/libavcodec/h264_picture.c:107 (ffmpeg+0x013b78d8) [..] Previous write of size 1 at 0x7dbc0001c82e by thread T2 (mutexes: write M3245): #0 ff_h264_direct_ref_list_init src/libavcodec/h264_direct.c:137 (ffmpeg+0x01382c93) But I'm not sure because I haven't been able to reproduce locally. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7f05c5cea04112471d8147487aa3b44141922d09 --- libavcodec/h264_slice.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 34bd6cf..acf6a73 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1891,7 +1891,8 @@ static int h264_slice_init(H264Context *h, H264SliceContext *sl, if (sl->slice_type_nos == AV_PICTURE_TYPE_B && !sl->direct_spatial_mv_pred) ff_h264_direct_dist_scale_factor(h, sl); -ff_h264_direct_ref_list_init(h, sl); +if (!h->setup_finished) +ff_h264_direct_ref_list_init(h, sl); if (h->avctx->skip_loop_filter >= AVDISCARD_ALL || (h->avctx->skip_loop_filter >= AVDISCARD_NONKEY && ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] pthread_frame: make accesses to debug field be protected by owner lock.
ffmpeg | branch: master | Ronald S. Bultje | Thu Apr 6 13:58:59 2017 -0400| [2e664b9c1e73c80aab91070c1eb7676f04bdd12d] | committer: Ronald S. Bultje pthread_frame: make accesses to debug field be protected by owner lock. The av_log() is done outside the lock, but this way the accesses to the field (reads and writes) are always protected by a mutex. The av_log() is not run inside the lock context because it may involve user callbacks and doing that in performance-sensitive code is probably not a good idea. This should fix occasional tsan warnings when running fate-h264, like: WARNING: ThreadSanitizer: data race (pid=10916) Write of size 4 at 0x7d64000174fc by main thread (mutexes: write M2313): #0 update_context_from_user src/libavcodec/pthread_frame.c:335 (ffmpeg+0x00df7b06) [..] Previous read of size 4 at 0x7d64000174fc by thread T1 (mutexes: write M2311): #0 ff_thread_await_progress src/libavcodec/pthread_frame.c:592 (ffmpeg+0x00df8b3e) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2e664b9c1e73c80aab91070c1eb7676f04bdd12d --- libavcodec/pthread_frame.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index aaf576d..46c6292 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -566,12 +566,11 @@ void ff_thread_report_progress(ThreadFrame *f, int n, int field) p = f->owner[field]->internal->thread_ctx; +pthread_mutex_lock(&p->progress_mutex); if (f->owner[field]->debug&FF_DEBUG_THREADS) av_log(f->owner[field], AV_LOG_DEBUG, "%p finished %d field %d\n", progress, n, field); -pthread_mutex_lock(&p->progress_mutex); - atomic_store_explicit(&progress[field], n, memory_order_release); pthread_cond_broadcast(&p->progress_cond); @@ -589,11 +588,10 @@ void ff_thread_await_progress(ThreadFrame *f, int n, int field) p = f->owner[field]->internal->thread_ctx; +pthread_mutex_lock(&p->progress_mutex); if (f->owner[field]->debug&FF_DEBUG_THREADS) av_log(f->owner[field], AV_LOG_DEBUG, "thread awaiting %d field %d from %p\n", n, field, progress); - -pthread_mutex_lock(&p->progress_mutex); while (atomic_load_explicit(&progress[field], memory_order_relaxed) < n) pthread_cond_wait(&p->progress_cond, &p->progress_mutex); pthread_mutex_unlock(&p->progress_mutex); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/utvideodec: add support for gradient prediction
ffmpeg | branch: master | Paul B Mahol | Fri Apr 7 20:09:22 2017 +0200| [faa94a576f5f3de10fc7016e0d94229faa1c2159] | committer: Paul B Mahol avcodec/utvideodec: add support for gradient prediction Signed-off-by: Paul B Mahol > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=faa94a576f5f3de10fc7016e0d94229faa1c2159 --- libavcodec/utvideodec.c | 230 ++-- 1 file changed, 225 insertions(+), 5 deletions(-) diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c index 7c65d77..a49cae8 100644 --- a/libavcodec/utvideodec.c +++ b/libavcodec/utvideodec.c @@ -602,6 +602,189 @@ static void restore_median_packed_il(uint8_t *src, int step, ptrdiff_t stride, } } +static void restore_gradient_planar(UtvideoContext *c, uint8_t *src, ptrdiff_t stride, +int width, int height, int slices, int rmode) +{ +int i, j, slice; +int A, B, C; +uint8_t *bsrc; +int slice_start, slice_height; +const int cmask = ~rmode; + +for (slice = 0; slice < slices; slice++) { +slice_start = ((slice * height) / slices) & cmask; +slice_height = slice + 1) * height) / slices) & cmask) - + slice_start; + +if (!slice_height) +continue; +bsrc = src + slice_start * stride; + +// first line - left neighbour prediction +bsrc[0] += 0x80; +c->llviddsp.add_left_pred(bsrc, bsrc, width, 0); +bsrc += stride; +if (slice_height <= 1) +continue; +for (j = 1; j < slice_height; j++) { +// second line - first element has top prediction, the rest uses gradient +bsrc[0] = (bsrc[0] + bsrc[-stride]) & 0xFF; +for (i = 1; i < width; i++) { +A = bsrc[i - stride]; +B = bsrc[i - (stride + 1)]; +C = bsrc[i - 1]; +bsrc[i] = (A - B + C + bsrc[i]) & 0xFF; +} +bsrc += stride; +} +} +} + +static void restore_gradient_planar_il(UtvideoContext *c, uint8_t *src, ptrdiff_t stride, + int width, int height, int slices, int rmode) +{ +int i, j, slice; +int A, B, C; +uint8_t *bsrc; +int slice_start, slice_height; +const int cmask = ~(rmode ? 3 : 1); +const ptrdiff_t stride2 = stride << 1; + +for (slice = 0; slice < slices; slice++) { +slice_start= ((slice * height) / slices) & cmask; +slice_height = slice + 1) * height) / slices) & cmask) - + slice_start; +slice_height >>= 1; +if (!slice_height) +continue; + +bsrc = src + slice_start * stride; + +// first line - left neighbour prediction +bsrc[0] += 0x80; +A = c->llviddsp.add_left_pred(bsrc, bsrc, width, 0); +c->llviddsp.add_left_pred(bsrc + stride, bsrc + stride, width, A); +bsrc += stride2; +if (slice_height <= 1) +continue; +for (j = 1; j < slice_height; j++) { +// second line - first element has top prediction, the rest uses gradient +bsrc[0] = (bsrc[0] + bsrc[-stride2]) & 0xFF; +for (i = 1; i < width; i++) { +A = bsrc[i - stride2]; +B = bsrc[i - (stride2 + 1)]; +C = bsrc[i - 1]; +bsrc[i] = (A - B + C + bsrc[i]) & 0xFF; +} +for (i = 0; i < width; i++) { +A = bsrc[i - stride]; +B = bsrc[i - (1 + stride)]; +C = bsrc[i - 1 + stride]; +bsrc[i + stride] = (A - B + C + bsrc[i + stride]) & 0xFF; +} +bsrc += stride2; +} +} +} + +static void restore_gradient_packed(uint8_t *src, int step, ptrdiff_t stride, +int width, int height, int slices, int rmode) +{ +int i, j, slice; +int A, B, C; +uint8_t *bsrc; +int slice_start, slice_height; +const int cmask = ~rmode; + +for (slice = 0; slice < slices; slice++) { +slice_start = ((slice * height) / slices) & cmask; +slice_height = slice + 1) * height) / slices) & cmask) - + slice_start; + +if (!slice_height) +continue; +bsrc = src + slice_start * stride; + +// first line - left neighbour prediction +bsrc[0] += 0x80; +A = bsrc[0]; +for (i = step; i < width * step; i += step) { +bsrc[i] += A; +A= bsrc[i]; +} +bsrc += stride; +if (slice_height <= 1) +continue; +for (j = 1; j < slice_height; j++) { +// second line - first element has top prediction, the rest uses gradient +C= bsrc[-stride]; +bsrc[0] += C; +for (i = step; i < width * step; i += step) { +A = bsrc
[FFmpeg-cvslog] ffmpeg: use av_stream_new_side_data()
ffmpeg | branch: master | James Almer | Mon Dec 26 18:33:06 2016 -0300| [9f102653fd723005f26c6e8c7525fec585631a72] | committer: James Almer ffmpeg: use av_stream_new_side_data() Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9f102653fd723005f26c6e8c7525fec585631a72 --- ffmpeg.c | 17 - 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 444b963..55467c0 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3062,23 +3062,14 @@ static int init_output_stream_streamcopy(OutputStream *ost) ost->st->disposition = ist->st->disposition; if (ist->st->nb_side_data) { -ost->st->side_data = av_realloc_array(NULL, ist->st->nb_side_data, - sizeof(*ist->st->side_data)); -if (!ost->st->side_data) -return AVERROR(ENOMEM); - -ost->st->nb_side_data = 0; for (i = 0; i < ist->st->nb_side_data; i++) { const AVPacketSideData *sd_src = &ist->st->side_data[i]; -AVPacketSideData *sd_dst = &ost->st->side_data[ost->st->nb_side_data]; +uint8_t *dst_data; -sd_dst->data = av_malloc(sd_src->size); -if (!sd_dst->data) +dst_data = av_stream_new_side_data(ost->st, sd_src->type, sd_src->size); +if (!dst_data) return AVERROR(ENOMEM); -memcpy(sd_dst->data, sd_src->data, sd_src->size); -sd_dst->size = sd_src->size; -sd_dst->type = sd_src->type; -ost->st->nb_side_data++; +memcpy(dst_data, sd_src->data, sd_src->size); } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavf: use the new bitstream filter for extracting extradata
ffmpeg | branch: master | James Almer | Fri Mar 24 18:42:19 2017 -0300| [b8f26779d615dfb466e90627323b1a4e40639f76] | committer: James Almer lavf: use the new bitstream filter for extracting extradata This merges commits 8e2ea691351c5079cdab245ff7bfa5c0f3e3bfe4 and 096a8effa3f8f3455292c958c3ed07e798def7bd by Anton Khirnov, with the following change: - extract_extradata_check() is added to know if the codec is supported by the bsf before trying to initialize it. This behaviour is similar to the old AVCodecParser.split checks. The FATE reference changes are due to the filtered out NAL units that the old AVCodecParser.split implementation left alone. Decoding is unchanged as the functions that parse extradata simply ignored said unnecessary NAL units. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b8f26779d615dfb466e90627323b1a4e40639f76 --- libavformat/internal.h | 9 ++ libavformat/utils.c | 146 --- tests/ref/fate/copy-trac2211-avi | 4 +- tests/ref/fate/h264_mp4toannexb_ticket2991 | 2 +- tests/ref/fate/h264_mp4toannexb_ticket5927 | 2 +- tests/ref/fate/h264_mp4toannexb_ticket5927_2 | 2 +- tests/ref/fate/segment-mp4-to-ts | 2 +- 7 files changed, 148 insertions(+), 19 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index 63a1724..c856945 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -178,6 +178,15 @@ struct AVStreamInternal { enum AVCodecID orig_codec_id; +/* the context for extracting extradata in find_stream_info() + * inited=1/bsf=NULL signals that extracting is not possible (codec not + * supported) */ +struct { +AVBSFContext *bsf; +AVPacket *pkt; +int inited; +} extract_extradata; + /** * Whether the internal avctx needs to be updated from codecpar (after a late change to codecpar) */ diff --git a/libavformat/utils.c b/libavformat/utils.c index a059046..ba82a76 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3370,6 +3370,127 @@ void ff_rfps_calculate(AVFormatContext *ic) } } +static int extract_extradata_check(AVStream *st) +{ +const AVBitStreamFilter *f; + +f = av_bsf_get_by_name("extract_extradata"); +if (!f) +return 0; + +if (f->codec_ids) { +const enum AVCodecID *ids; +for (ids = f->codec_ids; *ids != AV_CODEC_ID_NONE; ids++) +if (*ids == st->codecpar->codec_id) +return 1; +} + +return 0; +} + +static int extract_extradata_init(AVStream *st) +{ +AVStreamInternal *i = st->internal; +const AVBitStreamFilter *f; +int ret; + +f = av_bsf_get_by_name("extract_extradata"); +if (!f) +goto finish; + +/* check that the codec id is supported */ +ret = extract_extradata_check(st); +if (!ret) +goto finish; + +i->extract_extradata.pkt = av_packet_alloc(); +if (!i->extract_extradata.pkt) +return AVERROR(ENOMEM); + +ret = av_bsf_alloc(f, &i->extract_extradata.bsf); +if (ret < 0) +goto fail; + +ret = avcodec_parameters_copy(i->extract_extradata.bsf->par_in, + st->codecpar); +if (ret < 0) +goto fail; + +i->extract_extradata.bsf->time_base_in = st->time_base; + +/* if init fails here, we assume extracting extradata is just not + * supported for this codec, so we return success */ +ret = av_bsf_init(i->extract_extradata.bsf); +if (ret < 0) { +av_bsf_free(&i->extract_extradata.bsf); +ret = 0; +} + +finish: +i->extract_extradata.inited = 1; + +return 0; +fail: +av_bsf_free(&i->extract_extradata.bsf); +av_packet_free(&i->extract_extradata.pkt); +return ret; +} + +static int extract_extradata(AVStream *st, AVPacket *pkt) +{ +AVStreamInternal *i = st->internal; +AVPacket *pkt_ref; +int ret; + +if (!i->extract_extradata.inited) { +ret = extract_extradata_init(st); +if (ret < 0) +return ret; +} + +if (i->extract_extradata.inited && !i->extract_extradata.bsf) +return 0; + +pkt_ref = i->extract_extradata.pkt; +ret = av_packet_ref(pkt_ref, pkt); +if (ret < 0) +return ret; + +ret = av_bsf_send_packet(i->extract_extradata.bsf, pkt_ref); +if (ret < 0) { +av_packet_unref(pkt_ref); +return ret; +} + +while (ret >= 0 && !i->avctx->extradata) { +int extradata_size; +uint8_t *extradata; + +ret = av_bsf_receive_packet(i->extract_extradata.bsf, pkt_ref); +if (ret < 0) { +if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) +return ret; +continue; +} + +extradata = av_packet_get_side_data(pkt_ref, AV_PKT_DATA_NEW_EXTRADATA, +&extradata_s
[FFmpeg-cvslog] avcodec/hevc_parse: ignore all non parameter set NAL units in extradata
ffmpeg | branch: master | James Almer | Sun Apr 2 14:35:03 2017 -0300| [e7fb6bc32d1bbffbc1a466c2a505b138cf8a7e0e] | committer: James Almer avcodec/hevc_parse: ignore all non parameter set NAL units in extradata While they shouldn't be present, they are harmless if they are. Reviewed-by: Michael Niedermayer Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e7fb6bc32d1bbffbc1a466c2a505b138cf8a7e0e --- libavcodec/hevc_parse.c | 21 ++--- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/libavcodec/hevc_parse.c b/libavcodec/hevc_parse.c index 6c1138e..3fe6662 100644 --- a/libavcodec/hevc_parse.c +++ b/libavcodec/hevc_parse.c @@ -41,25 +41,8 @@ static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, HEVCParamSets case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, logctx, ps); break; case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, logctx, ps, 1); break; case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, logctx, ps); break; -case HEVC_NAL_TRAIL_R: -case HEVC_NAL_TRAIL_N: -case HEVC_NAL_TSA_N: -case HEVC_NAL_TSA_R: -case HEVC_NAL_STSA_N: -case HEVC_NAL_STSA_R: -case HEVC_NAL_BLA_W_LP: -case HEVC_NAL_BLA_W_RADL: -case HEVC_NAL_BLA_N_LP: -case HEVC_NAL_IDR_W_RADL: -case HEVC_NAL_IDR_N_LP: -case HEVC_NAL_CRA_NUT: -case HEVC_NAL_RADL_N: -case HEVC_NAL_RADL_R: -case HEVC_NAL_RASL_N: -case HEVC_NAL_RASL_R: -av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", nal->type); -ret = AVERROR_INVALIDDATA; -goto done; +default: +av_log(logctx, AV_LOG_VERBOSE, "Ignoring NAL type %d in extradata\n", nal->type); break; } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] doc/libav-merge: remove line about extract_extradata_bsf usage
ffmpeg | branch: master | James Almer | Fri Apr 7 17:31:13 2017 -0300| [3f8d7342c32c8b22ab177d62f5c7660db213e342] | committer: James Almer doc/libav-merge: remove line about extract_extradata_bsf usage It was addressed in b8f26779d615dfb466e90627323b1a4e40639f76 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3f8d7342c32c8b22ab177d62f5c7660db213e342 --- doc/libav-merge.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/libav-merge.txt b/doc/libav-merge.txt index 2040c6a..454f454 100644 --- a/doc/libav-merge.txt +++ b/doc/libav-merge.txt @@ -96,7 +96,6 @@ Stuff that didn't reach the codebase: - e7078e842 hevcdsp: add x86 SIMD for MC - VAAPI VP8 decode hwaccel (currently under review: http://ffmpeg.org/pipermail/ffmpeg-devel/2017-February/thread.html#207348) - Removal of the custom atomic API (5cc0057f49, see http://ffmpeg.org/pipermail/ffmpeg-devel/2017-March/209003.html) -- Use the new bitstream filter for extracting extradata (8e2ea69135 and 096a8effa3, see https://ffmpeg.org/pipermail/ffmpeg-devel/2017-March/209068.html) - Read aac_adtstoasc extradata updates from packet side data on Matroska once mov and the bsf in question are fixed (See 13a211e632 and 5ef1959080) - new bistream reader (see http://ffmpeg.org/pipermail/ffmpeg-devel/2017-April/209609.html) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] vf_pad: center image on padded area if negative x/y
ffmpeg | branch: master | Ricardo Constantino | Mon Apr 3 19:34:09 2017 +0100| [57c3670896c69714ca1514728edf5ee48b2abcc9] | committer: Rostislav Pehlivanov vf_pad: center image on padded area if negative x/y or if x/y go beyond padded area. This is mostly useful when paired with the aspect option. Defaults aren't changed. Idea for this was taken from mpv's soon-to-be-removed expand vf. Reviewed-by: Paul B Mahol > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=57c3670896c69714ca1514728edf5ee48b2abcc9 --- doc/filters.texi | 3 +++ libavfilter/vf_pad.c | 12 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index bc37e66..32720db 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10430,6 +10430,9 @@ expression, and vice versa. The default value of @var{x} and @var{y} is 0. +If @var{x} or @var{y} evaluate to a negative number, they'll be changed +so the input image is centered on the padded area. + @item color Specify the color of the padded area. For the syntax of this option, check the "Color" section in the ffmpeg-utils manual. diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index 44a8fec..725dc29 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -173,8 +173,13 @@ static int config_input(AVFilterLink *inlink) goto eval_fail; s->x = var_values[VAR_X] = res; +if (s->x < 0 || s->x + inlink->w > s->w) +s->x = var_values[VAR_X] = (s->w - inlink->w) / 2; +if (s->y < 0 || s->y + inlink->h > s->h) +s->y = var_values[VAR_Y] = (s->h - inlink->h) / 2; + /* sanity check params */ -if (s->w < 0 || s->h < 0 || s->x < 0 || s->y < 0) { +if (s->w < 0 || s->h < 0) { av_log(ctx, AV_LOG_ERROR, "Negative values are not acceptable.\n"); return AVERROR(EINVAL); } @@ -192,10 +197,7 @@ static int config_input(AVFilterLink *inlink) inlink->w, inlink->h, s->w, s->h, s->x, s->y, s->rgba_color[0], s->rgba_color[1], s->rgba_color[2], s->rgba_color[3]); -if (s->x < 0 || s->y < 0 || -s->w <= 0 || s->h <= 0 || -(unsigned)s->x + (unsigned)inlink->w > s->w || -(unsigned)s->y + (unsigned)inlink->h > s->h) { +if (s->w <= 0 || s->h <= 0) { av_log(ctx, AV_LOG_ERROR, "Input area %d:%d:%d:%d not within the padded area 0:0:%d:%d or zero-sized\n", s->x, s->y, s->x + inlink->w, s->y + inlink->h, s->w, s->h); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] opusenc: minor style changes
ffmpeg | branch: master | Rostislav Pehlivanov | Sat Apr 8 00:29:03 2017 +0100| [42ffc67208b18e7048c0deed0ff3b289c870c66d] | committer: Rostislav Pehlivanov opusenc: minor style changes Signed-off-by: Rostislav Pehlivanov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=42ffc67208b18e7048c0deed0ff3b289c870c66d --- libavcodec/opusenc.c | 32 ++-- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c index a84e51f..d80ae7a 100644 --- a/libavcodec/opusenc.c +++ b/libavcodec/opusenc.c @@ -280,7 +280,7 @@ static int celt_frame_map_norm_bands(OpusEncContext *s, CeltFrame *f) return !noise; } -static void celt_enc_tf(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame *f) +static void celt_enc_tf(OpusRangeCoder *rc, CeltFrame *f) { int i, tf_select = 0, diff = 0, tf_changed = 0, tf_select_needed; int bits = f->transient ? 2 : 4; @@ -307,7 +307,7 @@ static void celt_enc_tf(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame *f) f->tf_change[i] = ff_celt_tf_select[f->size][f->transient][tf_select][f->tf_change[i]]; } -static void celt_bitalloc(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame *f) +static void ff_celt_enc_bitalloc(OpusRangeCoder *rc, CeltFrame *f) { int i, j, low, high, total, done, bandbits, remaining, tbits_8ths; int skip_startband = f->start_band; @@ -675,7 +675,7 @@ static void celt_quant_coarse(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame * } } -static void celt_quant_fine(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame *f) +static void celt_quant_fine(OpusRangeCoder *rc, CeltFrame *f) { int i, ch; for (i = f->start_band; i < f->end_band; i++) { @@ -712,7 +712,7 @@ static void celt_quant_final(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame *f } } -static void celt_quant_bands(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame *f) +static void celt_quant_bands(OpusRangeCoder *rc, CeltFrame *f) { float lowband_scratch[8 * 22]; float norm[2 * 8 * 100]; @@ -725,6 +725,7 @@ static void celt_quant_bands(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame *f int i, j; for (i = f->start_band; i < f->end_band; i++) { +uint32_t cm[2] = { (1 << f->blocks) - 1, (1 << f->blocks) - 1 }; int band_offset = ff_celt_freq_bands[i] << f->size; int band_size = ff_celt_freq_range[i] << f->size; float *X = f->block[0].coeffs + band_offset; @@ -733,8 +734,7 @@ static void celt_quant_bands(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame *f int consumed = opus_rc_tell_frac(rc); float *norm2 = norm + 8 * 100; int effective_lowband = -1; -unsigned int cm[2]; -int b; +int b = 0; /* Compute how many bits we want to allocate to this band */ if (i != f->start_band) @@ -743,8 +743,7 @@ static void celt_quant_bands(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame *f if (i <= f->coded_bands - 1) { int curr_balance = f->remaining / FFMIN(3, f->coded_bands-i); b = av_clip_uintp2(FFMIN(f->remaining2 + 1, f->pulses[i] + curr_balance), 14); -} else -b = 0; +} if (ff_celt_freq_bands[i] - ff_celt_freq_range[i] >= ff_celt_freq_bands[f->start_band] && (update_lowband || lowband_offset == 0)) @@ -769,10 +768,7 @@ static void celt_quant_bands(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame *f cm[0] |= f->block[0].collapse_masks[j]; cm[1] |= f->block[f->channels - 1].collapse_masks[j]; } -} else -/* Otherwise, we'll be using the LCG to fold, so all blocks will (almost -always) be non-zero.*/ -cm[0] = cm[1] = (1 << f->blocks) - 1; +} if (f->dual_stereo && i == f->intensity_stereo) { /* Switch off dual stereo to do intensity */ @@ -786,13 +782,13 @@ static void celt_quant_bands(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame *f effective_lowband != -1 ? norm + (effective_lowband << f->size) : NULL, f->size, norm + band_offset, 0, 1.0f, lowband_scratch, cm[0]); -cm[1] = ff_celt_encode_band(f, rc, i, Y, NULL, band_size, b/2, f->blocks, +cm[1] = ff_celt_encode_band(f, rc, i, Y, NULL, band_size, b / 2, f->blocks, effective_lowband != -1 ? norm2 + (effective_lowband << f->size) : NULL, f->size, norm2 + band_offset, 0, 1.0f, lowband_scratch, cm[1]); } else { cm[0] = ff_celt_encode_band(f, rc, i, X, Y, band_size, b, f->blocks, effective_lowband != -1 ? norm + (effective_lowband << f->size) : NULL, f->size, -norm + band_offset, 0, 1.0
[FFmpeg-cvslog] opusenc: remove unused header entries and simplify normalization
ffmpeg | branch: master | Rostislav Pehlivanov | Mon Apr 3 13:13:14 2017 +0100| [63744d8afd57851479ed2ff3e9a843c70d1b0031] | committer: Rostislav Pehlivanov opusenc: remove unused header entries and simplify normalization Signed-off-by: Rostislav Pehlivanov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=63744d8afd57851479ed2ff3e9a843c70d1b0031 --- libavcodec/opus_celt.h | 3 --- libavcodec/opusenc.c | 18 +++--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/libavcodec/opus_celt.h b/libavcodec/opus_celt.h index 23c2089..1ed57f3 100644 --- a/libavcodec/opus_celt.h +++ b/libavcodec/opus_celt.h @@ -67,9 +67,6 @@ typedef struct CeltBlock { uint8_t collapse_masks[CELT_MAX_BANDS]; -int band_bins[CELT_MAX_BANDS]; /* MDCT bins per band */ -float *band_coeffs[CELT_MAX_BANDS]; - /* buffer for mdct output + postfilter */ DECLARE_ALIGNED(32, float, buf)[2048]; DECLARE_ALIGNED(32, float, coeffs)[CELT_MAX_FRAME_SIZE]; diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c index cecc8f2..a84e51f 100644 --- a/libavcodec/opusenc.c +++ b/libavcodec/opusenc.c @@ -255,24 +255,20 @@ static int celt_frame_map_norm_bands(OpusEncContext *s, CeltFrame *f) for (ch = 0; ch < f->channels; ch++) { CeltBlock *block = &f->block[ch]; -float *start = block->coeffs; for (i = 0; i < CELT_MAX_BANDS; i++) { float ener = 0.0f; +int band_offset = ff_celt_freq_bands[i] << f->size; +int band_size = ff_celt_freq_range[i] << f->size; +float *coeffs = &block->coeffs[band_offset]; -/* Calculate band bins */ -block->band_bins[i] = ff_celt_freq_range[i] << f->size; -block->band_coeffs[i] = start; -start += block->band_bins[i]; - -/* Normalize band energy */ -for (j = 0; j < block->band_bins[i]; j++) -ener += block->band_coeffs[i][j]*block->band_coeffs[i][j]; +for (j = 0; j < band_size; j++) +ener += coeffs[j]*coeffs[j]; block->lin_energy[i] = sqrtf(ener) + FLT_EPSILON; ener = 1.0f/block->lin_energy[i]; -for (j = 0; j < block->band_bins[i]; j++) -block->band_coeffs[i][j] *= ener; +for (j = 0; j < band_size; j++) +coeffs[j] *= ener; block->energy[i] = log2f(block->lin_energy[i]) - ff_celt_mean_energy[i]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] opus_celt: fix some style issues
ffmpeg | branch: master | Rostislav Pehlivanov | Sun Apr 2 20:55:11 2017 +0100| [6d0b62a12b46edbb3d141c356a7bcf7856a1e351] | committer: Rostislav Pehlivanov opus_celt: fix some style issues Signed-off-by: Rostislav Pehlivanov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6d0b62a12b46edbb3d141c356a7bcf7856a1e351 --- libavcodec/opus_celt.c | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c index af3c100..aee8ddc 100644 --- a/libavcodec/opus_celt.c +++ b/libavcodec/opus_celt.c @@ -700,6 +700,7 @@ static void celt_decode_bands(CeltFrame *f, OpusRangeCoder *rc) memset(f->block[1].coeffs, 0, sizeof(f->block[0].coeffs)); for (i = f->start_band; i < f->end_band; i++) { +uint32_t cm[2] = { (1 << f->blocks) - 1, (1 << f->blocks) - 1 }; int band_offset = ff_celt_freq_bands[i] << f->size; int band_size = ff_celt_freq_range[i] << f->size; float *X = f->block[0].coeffs + band_offset; @@ -708,8 +709,7 @@ static void celt_decode_bands(CeltFrame *f, OpusRangeCoder *rc) int consumed = opus_rc_tell_frac(rc); float *norm2 = norm + 8 * 100; int effective_lowband = -1; -unsigned int cm[2]; -int b; +int b = 0; /* Compute how many bits we want to allocate to this band */ if (i != f->start_band) @@ -718,15 +718,14 @@ static void celt_decode_bands(CeltFrame *f, OpusRangeCoder *rc) if (i <= f->coded_bands - 1) { int curr_balance = f->remaining / FFMIN(3, f->coded_bands-i); b = av_clip_uintp2(FFMIN(f->remaining2 + 1, f->pulses[i] + curr_balance), 14); -} else -b = 0; +} if (ff_celt_freq_bands[i] - ff_celt_freq_range[i] >= ff_celt_freq_bands[f->start_band] && (update_lowband || lowband_offset == 0)) lowband_offset = i; /* Get a conservative estimate of the collapse_mask's for the bands we're -going to be folding from. */ + going to be folding from. */ if (lowband_offset != 0 && (f->spread != CELT_SPREAD_AGGRESSIVE || f->blocks > 1 || f->tf_change[i] < 0)) { int foldstart, foldend; @@ -744,10 +743,7 @@ static void celt_decode_bands(CeltFrame *f, OpusRangeCoder *rc) cm[0] |= f->block[0].collapse_masks[j]; cm[1] |= f->block[f->channels - 1].collapse_masks[j]; } -} else -/* Otherwise, we'll be using the LCG to fold, so all blocks will (almost -always) be non-zero.*/ -cm[0] = cm[1] = (1 << f->blocks) - 1; +} if (f->dual_stereo && i == f->intensity_stereo) { /* Switch off dual stereo to do intensity */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] opusenc: do not signal digital silence
ffmpeg | branch: master | Rostislav Pehlivanov | Sat Apr 8 00:48:28 2017 +0100| [c39fba703bf35da0b4b894b2b33978c205507341] | committer: Rostislav Pehlivanov opusenc: do not signal digital silence Apparently its only use is to enable comfort noise/error recovery. Signed-off-by: Rostislav Pehlivanov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c39fba703bf35da0b4b894b2b33978c205507341 --- libavcodec/opusenc.c | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c index d80ae7a..4e0781b 100644 --- a/libavcodec/opusenc.c +++ b/libavcodec/opusenc.c @@ -249,9 +249,9 @@ static void celt_frame_mdct(OpusEncContext *s, CeltFrame *f) } /* Fills the bands and normalizes them */ -static int celt_frame_map_norm_bands(OpusEncContext *s, CeltFrame *f) +static void celt_frame_map_norm_bands(OpusEncContext *s, CeltFrame *f) { -int i, j, ch, noise = 0; +int i, j, ch; for (ch = 0; ch < f->channels; ch++) { CeltBlock *block = &f->block[ch]; @@ -274,10 +274,8 @@ static int celt_frame_map_norm_bands(OpusEncContext *s, CeltFrame *f) /* CELT_ENERGY_SILENCE is what the decoder uses and its not -infinity */ block->energy[i] = FFMAX(block->energy[i], CELT_ENERGY_SILENCE); -noise |= block->energy[i] > CELT_ENERGY_SILENCE; } } -return !noise; } static void celt_enc_tf(OpusRangeCoder *rc, CeltFrame *f) @@ -811,11 +809,7 @@ static void celt_encode_frame(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame * /* Not implemented */ } celt_frame_mdct(s, f); -f->silence = celt_frame_map_norm_bands(s, f); -if (f->silence) { -f->framebits = 1; -return; -} +celt_frame_map_norm_bands(s, f); ff_opus_rc_enc_log(rc, f->silence, 15); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] mdct15: use existing complex multiplication macros
ffmpeg | branch: master | Rostislav Pehlivanov | Sat Apr 1 19:41:52 2017 +0100| [db788de8ecdee271b59b04c9cbb97320ec28c9ea] | committer: Rostislav Pehlivanov mdct15: use existing complex multiplication macros Signed-off-by: Rostislav Pehlivanov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=db788de8ecdee271b59b04c9cbb97320ec28c9ea --- libavcodec/mdct15.c | 36 +++- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/libavcodec/mdct15.c b/libavcodec/mdct15.c index e038209..8c42ece 100644 --- a/libavcodec/mdct15.c +++ b/libavcodec/mdct15.c @@ -33,17 +33,12 @@ #include "libavutil/attributes.h" #include "libavutil/common.h" -#include "avfft.h" #include "mdct15.h" -// complex c = a * b -#define CMUL3(cre, cim, are, aim, bre, bim) \ -do { \ -cre = are * bre - aim * bim; \ -cim = are * bim + aim * bre; \ -} while (0) +#define FFT_FLOAT 1 +#include "fft-internal.h" -#define CMUL(c, a, b) CMUL3((c).re, (c).im, (a).re, (a).im, (b).re, (b).im) +#define CMUL3(c, a, b) CMUL((c).re, (c).im, (a).re, (a).im, (b).re, (b).im) av_cold void ff_mdct15_uninit(MDCT15Context **ps) { @@ -236,18 +231,18 @@ static void fft15(const FFTComplex exptab[22], FFTComplex *out, const FFTComplex for (k = 0; k < 5; k++) { FFTComplex t[2]; -CMUL(t[0], tmp2[k], exptab[k]); -CMUL(t[1], tmp3[k], exptab[2 * k]); +CMUL3(t[0], tmp2[k], exptab[k]); +CMUL3(t[1], tmp3[k], exptab[2 * k]); out[stride*k].re = tmp1[k].re + t[0].re + t[1].re; out[stride*k].im = tmp1[k].im + t[0].im + t[1].im; -CMUL(t[0], tmp2[k], exptab[k + 5]); -CMUL(t[1], tmp3[k], exptab[2 * (k + 5)]); +CMUL3(t[0], tmp2[k], exptab[k + 5]); +CMUL3(t[1], tmp3[k], exptab[2 * (k + 5)]); out[stride*(k + 5)].re = tmp1[k].re + t[0].re + t[1].re; out[stride*(k + 5)].im = tmp1[k].im + t[0].im + t[1].im; -CMUL(t[0], tmp2[k], exptab[k + 10]); -CMUL(t[1], tmp3[k], exptab[2 * k + 5]); +CMUL3(t[0], tmp2[k], exptab[k + 10]); +CMUL3(t[1], tmp3[k], exptab[2 * k + 5]); out[stride*(k + 10)].re = tmp1[k].re + t[0].re + t[1].re; out[stride*(k + 10)].im = tmp1[k].im + t[0].im + t[1].im; } @@ -272,7 +267,7 @@ static void mdct15(MDCT15Context *s, float *dst, const float *src, ptrdiff_t str re = src[2*k-len4] - src[1*len3-1-2*k]; im = -src[2*k+len4] - src[5*len4-1-2*k]; } -CMUL3(fft15in[j].re, fft15in[j].im, re, im, s->twiddle_exptab[k].re, -s->twiddle_exptab[k].im); +CMUL(fft15in[j].re, fft15in[j].im, re, im, s->twiddle_exptab[k].re, -s->twiddle_exptab[k].im); } fft15(s->exptab, s->tmp + s->ptwo_fft.revtab[i], fft15in, l_ptwo); } @@ -287,9 +282,8 @@ static void mdct15(MDCT15Context *s, float *dst, const float *src, ptrdiff_t str const int i0 = len8 + i, i1 = len8 - i - 1; const int s0 = s->pfa_postreindex[i0], s1 = s->pfa_postreindex[i1]; -CMUL3(im1, re0, s->tmp[s1].re, s->tmp[s1].im, s->twiddle_exptab[i1].im, s->twiddle_exptab[i1].re); -CMUL3(im0, re1, s->tmp[s0].re, s->tmp[s0].im, s->twiddle_exptab[i0].im, s->twiddle_exptab[i0].re); - +CMUL(im1, re0, s->tmp[s1].re, s->tmp[s1].im, s->twiddle_exptab[i1].im, s->twiddle_exptab[i1].re); +CMUL(im0, re1, s->tmp[s0].re, s->tmp[s0].im, s->twiddle_exptab[i0].im, s->twiddle_exptab[i0].re); dst[2*i1*stride ] = re0; dst[2*i1*stride + stride] = im0; dst[2*i0*stride ] = re1; @@ -310,7 +304,7 @@ static void imdct15_half(MDCT15Context *s, float *dst, const float *src, for (j = 0; j < 15; j++) { const int k = s->pfa_prereindex[i*15 + j]; FFTComplex tmp = { *(in2 - 2*k*stride), *(in1 + 2*k*stride) }; -CMUL(fft15in[j], tmp, s->twiddle_exptab[k]); +CMUL3(fft15in[j], tmp, s->twiddle_exptab[k]); } fft15(s->exptab, s->tmp + s->ptwo_fft.revtab[i], fft15in, l_ptwo); } @@ -325,8 +319,8 @@ static void imdct15_half(MDCT15Context *s, float *dst, const float *src, const int i0 = len8 + i, i1 = len8 - i - 1; const int s0 = s->pfa_postreindex[i0], s1 = s->pfa_postreindex[i1]; -CMUL3(re0, im1, s->tmp[s1].im, s->tmp[s1].re, s->twiddle_exptab[i1].im, s->twiddle_exptab[i1].re); -CMUL3(re1, im0, s->tmp[s0].im, s->tmp[s0].re, s->twiddle_exptab[i0].im, s->twiddle_exptab[i0].re); +CMUL(re0, im1, s->tmp[s1].im, s->tmp[s1].re, s->twiddle_exptab[i1].im, s->twiddle_exptab[i1].re); +CMUL(re1, im0, s->tmp[s0].im, s->tmp[s0].re, s->twiddle_exptab[i0].im, s->twiddle_exptab[i0].re); z[i1].re = scale * re0; z[i1].im = scale * im0; z[i0].re = scale * re1;
[FFmpeg-cvslog] opusenc: switch between intra/inter mode for coarse energy
ffmpeg | branch: master | Rostislav Pehlivanov | Sat Apr 8 00:53:31 2017 +0100| [d0a3143193ff3284f3dfbcc173bb94c9b91077d0] | committer: Rostislav Pehlivanov opusenc: switch between intra/inter mode for coarse energy Saves around 5kbps. Signed-off-by: Rostislav Pehlivanov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d0a3143193ff3284f3dfbcc173bb94c9b91077d0 --- libavcodec/opus_celt.h | 1 - libavcodec/opusenc.c | 36 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/libavcodec/opus_celt.h b/libavcodec/opus_celt.h index 1ed57f3..f0d55d6 100644 --- a/libavcodec/opus_celt.h +++ b/libavcodec/opus_celt.h @@ -100,7 +100,6 @@ struct CeltFrame { int end_band; int coded_bands; int transient; -int intra; int pfilter; int skip_band_floor; int tf_select; diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c index 4e0781b..5f5700e 100644 --- a/libavcodec/opusenc.c +++ b/libavcodec/opusenc.c @@ -630,19 +630,20 @@ static void ff_celt_enc_bitalloc(OpusRangeCoder *rc, CeltFrame *f) } } -static void celt_quant_coarse(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame *f) +static void exp_quant_coarse(OpusRangeCoder *rc, CeltFrame *f, + float last_energy[][CELT_MAX_BANDS], int intra) { int i, ch; float alpha, beta, prev[2] = { 0, 0 }; -const uint8_t *pmod = ff_celt_coarse_energy_dist[f->size][f->intra]; +const uint8_t *pmod = ff_celt_coarse_energy_dist[f->size][intra]; /* Inter is really just differential coding */ if (opus_rc_tell(rc) + 3 <= f->framebits) -ff_opus_rc_enc_log(rc, f->intra, 3); +ff_opus_rc_enc_log(rc, intra, 3); else -f->intra = 0; +intra = 0; -if (f->intra) { +if (intra) { alpha = 0.0f; beta = 1.0f - 4915.0f/32768.0f; } else { @@ -654,7 +655,7 @@ static void celt_quant_coarse(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame * for (ch = 0; ch < f->channels; ch++) { CeltBlock *block = &f->block[ch]; const int left = f->framebits - opus_rc_tell(rc); -const float last = FFMAX(-9.0f, s->last_quantized_energy[ch][i]); +const float last = FFMAX(-9.0f, last_energy[ch][i]); float diff = block->energy[i] - prev[ch] - last*alpha; int q_en = lrintf(diff); if (left >= 15) { @@ -673,6 +674,26 @@ static void celt_quant_coarse(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame * } } +static void celt_quant_coarse(OpusRangeCoder *rc, CeltFrame *f, + float last_energy[][CELT_MAX_BANDS]) +{ +uint32_t inter, intra; +OPUS_RC_CHECKPOINT_SPAWN(rc); + +exp_quant_coarse(rc, f, last_energy, 1); +intra = OPUS_RC_CHECKPOINT_BITS(rc); + +OPUS_RC_CHECKPOINT_ROLLBACK(rc); + +exp_quant_coarse(rc, f, last_energy, 0); +inter = OPUS_RC_CHECKPOINT_BITS(rc); + +if (inter > intra) { /* Unlikely */ +OPUS_RC_CHECKPOINT_ROLLBACK(rc); +exp_quant_coarse(rc, f, last_energy, 1); +} +} + static void celt_quant_fine(OpusRangeCoder *rc, CeltFrame *f) { int i, ch; @@ -823,7 +844,7 @@ static void celt_encode_frame(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame * if (f->size && opus_rc_tell(rc) + 3 <= f->framebits) ff_opus_rc_enc_log(rc, f->transient, 3); -celt_quant_coarse (s, rc, f); +celt_quant_coarse(rc, f, s->last_quantized_energy); celt_enc_tf (rc, f); ff_celt_enc_bitalloc(rc, f); celt_quant_fine (rc, f); @@ -871,7 +892,6 @@ static void ff_opus_psy_celt_frame_setup(OpusEncContext *s, CeltFrame *f, int in f->silence = 0; f->pfilter = 0; f->transient = 0; -f->intra = 1; f->tf_select = 0; f->anticollapse = 0; f->alloc_trim = 5; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] opus_rc: add macros for checkpoint rollback
ffmpeg | branch: master | Rostislav Pehlivanov | Sun Apr 2 20:55:30 2017 +0100| [a66121d964558348ffcc2fb820853c9381a6a8d2] | committer: Rostislav Pehlivanov opus_rc: add macros for checkpoint rollback Signed-off-by: Rostislav Pehlivanov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a66121d964558348ffcc2fb820853c9381a6a8d2 --- libavcodec/opus_rc.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/libavcodec/opus_rc.h b/libavcodec/opus_rc.h index 821eead..627f832 100644 --- a/libavcodec/opus_rc.h +++ b/libavcodec/opus_rc.h @@ -109,4 +109,18 @@ void ff_opus_rc_dec_raw_init(OpusRangeCoder *rc, const uint8_t *rightend, ui void ff_opus_rc_enc_end(OpusRangeCoder *rc, uint8_t *dst, int size); void ff_opus_rc_enc_init(OpusRangeCoder *rc); +#define OPUS_RC_CHECKPOINT_UPDATE(rc) \ +rc_rollback_bits = opus_rc_tell_frac(rc); \ +rc_rollback_ctx = *rc + +#define OPUS_RC_CHECKPOINT_SPAWN(rc) \ +uint32_t rc_rollback_bits = opus_rc_tell_frac(rc); \ +OpusRangeCoder rc_rollback_ctx = *rc \ + +#define OPUS_RC_CHECKPOINT_BITS(rc) \ +(opus_rc_tell_frac(rc) - rc_rollback_bits) + +#define OPUS_RC_CHECKPOINT_ROLLBACK(rc) \ +memcpy(rc, &rc_rollback_ctx, sizeof(OpusRangeCoder)); \ + #endif /* AVCODEC_OPUS_RC_H */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffmpeg: use av_stream_new_side_data() in init_output_stream
ffmpeg | branch: master | James Almer | Sat Apr 8 01:12:57 2017 -0300| [b438a7868c8a672f103a6b50e9572f5d31f23ce3] | committer: James Almer ffmpeg: use av_stream_new_side_data() in init_output_stream > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b438a7868c8a672f103a6b50e9572f5d31f23ce3 --- ffmpeg.c | 16 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 55467c0..e4b94b2 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3458,22 +3458,14 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len) if (ost->enc_ctx->nb_coded_side_data) { int i; -ost->st->side_data = av_realloc_array(NULL, ost->enc_ctx->nb_coded_side_data, - sizeof(*ost->st->side_data)); -if (!ost->st->side_data) -return AVERROR(ENOMEM); - for (i = 0; i < ost->enc_ctx->nb_coded_side_data; i++) { const AVPacketSideData *sd_src = &ost->enc_ctx->coded_side_data[i]; -AVPacketSideData *sd_dst = &ost->st->side_data[i]; +uint8_t *dst_data; -sd_dst->data = av_malloc(sd_src->size); -if (!sd_dst->data) +dst_data = av_stream_new_side_data(ost->st, sd_src->type, sd_src->size); +if (!dst_data) return AVERROR(ENOMEM); -memcpy(sd_dst->data, sd_src->data, sd_src->size); -sd_dst->size = sd_src->size; -sd_dst->type = sd_src->type; -ost->st->nb_side_data++; +memcpy(dst_data, sd_src->data, sd_src->size); } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog