[FFmpeg-cvslog] doc/filters: add links to ffmpeg-utils and ffmpeg documentation
ffmpeg | branch: master | Tobias Rapp| Thu Feb 22 08:53:03 2018 +0100| [aedbb3c72c97099a633c151b68d29b63c2a89339] | committer: Tobias Rapp doc/filters: add links to ffmpeg-utils and ffmpeg documentation Signed-off-by: Tobias Rapp > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aedbb3c72c97099a633c151b68d29b63c2a89339 --- doc/filters.texi | 48 ++-- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 8a9b78d778..7908c51d48 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1611,7 +1611,7 @@ The filter accepts the syntax [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate} expresses a sample rate and @var{resampler_options} is a list of @var{key}=@var{value} pairs, separated by ":". See the -@ref{Resampler Options,,the "Resampler Options" section in the +@ref{Resampler Options,,"Resampler Options" section in the ffmpeg-resampler(1) manual,ffmpeg-resampler} for the complete list of supported options. @@ -7449,7 +7449,7 @@ the input width and height. It defaults to 0. @item color, c Specify the color of the box to write. For the general syntax of this option, -check the "Color" section in the ffmpeg-utils manual. If the special +check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}. If the special value @code{invert} is used, the box edge color is the same as the video with inverted luma. @@ -7552,7 +7552,7 @@ framed. Default to 0. @item color, c Specify the color of the grid. For the general syntax of this option, -check the "Color" section in the ffmpeg-utils manual. If the special +check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}. If the special value @code{invert} is used, the grid color is the same as the video with inverted luma. @@ -7648,7 +7648,7 @@ The default value of @var{boxborderw} is 0. @item boxcolor The color to be used for drawing box around text. For the syntax of this -option, check the "Color" section in the ffmpeg-utils manual. +option, check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}. The default value of @var{boxcolor} is "white". @@ -7662,7 +7662,7 @@ The default value of @var{borderw} is 0. @item bordercolor Set the color to be used for drawing border around text. For the syntax of this -option, check the "Color" section in the ffmpeg-utils manual. +option, check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}. The default value of @var{bordercolor} is "black". @@ -7683,7 +7683,7 @@ If true, check and fix text coords to avoid clipping. @item fontcolor The color to be used for drawing fonts. For the syntax of this option, check -the "Color" section in the ffmpeg-utils manual. +the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}. The default value of @var{fontcolor} is "black". @@ -7746,7 +7746,8 @@ libfreetype flags. @item shadowcolor The color to be used for drawing a shadow behind the drawn text. For the -syntax of this option, check the "Color" section in the ffmpeg-utils manual. +syntax of this option, check the @ref{color syntax,,"Color" section in the +ffmpeg-utils manual,ffmpeg-utils}. The default value of @var{shadowcolor} is "black". @@ -9322,8 +9323,9 @@ A '|'-separated list of parameters to pass to the frei0r effect. A frei0r effect parameter can be a boolean (its value is either "y" or "n"), a double, a color (specified as @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point -numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color" -section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where +numbers between 0.0 and 1.0, inclusive) or a color description as specified in the +@ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}, +a position (specified as @var{X}/@var{Y}, where @var{X} and @var{Y} are floating point numbers) and/or a string. The number and types of parameters depend on the loaded effect. If an @@ -11881,7 +11883,8 @@ 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. +check the @ref{color syntax,,"Color" section in the ffmpeg-utils +manual,ffmpeg-utils}. The default value of @var{color} is "black". @@ -13273,8 +13276,9 @@ it. Default value is 1. @item fillcolor, c Set the color used to fill the output area not covered by the rotated -image. For the general syntax of this option, check the "Color" section in the -ffmpeg-utils manual. If the special value "none" is selected then no +image. For the general syntax of this option, check the +@ref{color syntax,,"Color" section in the
[FFmpeg-cvslog] Parse and drop gain control data, so that SSR packets decode.
ffmpeg | branch: master | Dale Curtis| Thu Feb 15 16:22:55 2018 -0800| [a246701e9abe8ef7cb9b0dd9fb5fa877e78334ef] | committer: Alex Converse Parse and drop gain control data, so that SSR packets decode. This will result in poor quality audio for SSR streams, but they will at least demux and decode without error; partially fixing ticket #1693. This pulls in the decode_gain_control() function from the ffmpeg summer-of-code repo (original author Maxim Gavrilov) at svn://svn.mplayerhq.hu/soc/aac/aac.c with some minor modifications and adds AOT_AAC_SSR to decode_audio_specific_config_gb(). Signed-off-by: Dale Curtis Co-authored-by: Maxim Gavrilov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a246701e9abe8ef7cb9b0dd9fb5fa877e78334ef --- libavcodec/aac.h | 2 ++ libavcodec/aacdec_template.c | 36 +--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 4910c661d6..05bc95385f 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -357,6 +357,8 @@ struct AACContext { int warned_num_aac_frames; int warned_960_sbr; +int warned_gain_control; + /* aacdec functions pointers */ void (*imdct_and_windowing)(AACContext *ac, SingleChannelElement *sce); void (*apply_ltp)(AACContext *ac, SingleChannelElement *sce); diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index c2d9802023..cf97181092 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -997,6 +997,7 @@ static int decode_audio_specific_config_gb(AACContext *ac, switch (m4ac->object_type) { case AOT_AAC_MAIN: case AOT_AAC_LC: +case AOT_AAC_SSR: case AOT_AAC_LTP: case AOT_ER_AAC_LC: case AOT_ER_AAC_LD: @@ -1967,6 +1968,33 @@ static void apply_prediction(AACContext *ac, SingleChannelElement *sce) reset_all_predictors(sce->predictor_state); } +static void decode_gain_control(SingleChannelElement * sce, GetBitContext * gb) +{ +// wd_num, wd_test, aloc_size +static const uint8_t gain_mode[4][3] = { +{1, 0, 5}, // ONLY_LONG_SEQUENCE = 0, +{2, 1, 2}, // LONG_START_SEQUENCE, +{8, 0, 2}, // EIGHT_SHORT_SEQUENCE, +{2, 1, 5}, // LONG_STOP_SEQUENCE +}; + +const int mode = sce->ics.window_sequence[0]; +uint8_t bd, wd, ad; + +// FIXME: Store the gain control data on |sce| and do something with it. +uint8_t max_band = get_bits(gb, 2); +for (bd = 0; bd < max_band; bd++) { +for (wd = 0; wd < gain_mode[mode][0]; wd++) { +uint8_t adjust_num = get_bits(gb, 3); +for (ad = 0; ad < adjust_num; ad++) { +skip_bits(gb, 4 + ((wd == 0 && gain_mode[mode][1]) + ? 4 + : gain_mode[mode][2])); +} +} +} +} + /** * Decode an individual_channel_stream payload; reference: table 4.44. * @@ -2034,9 +2062,11 @@ static int decode_ics(AACContext *ac, SingleChannelElement *sce, goto fail; } if (!eld_syntax && get_bits1(gb)) { -avpriv_request_sample(ac->avctx, "SSR"); -ret = AVERROR_PATCHWELCOME; -goto fail; +decode_gain_control(sce, gb); +if (!ac->warned_gain_control) { +avpriv_report_missing_feature(ac->avctx, "Gain control"); +ac->warned_gain_control = 1; +} } // I see no textual basis in the spec for this occurring after SSR gain // control, but this is what both reference and real implmentations do ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/nvdec: Implement mjpeg nvdec hwaccel
ffmpeg | branch: master | Philip Langdale| Sun Feb 18 15:53:33 2018 -0800| [cd98f20b4abac8241ef7f922eb85ba6fe3fe230b] | committer: Mark Thompson avcodec/nvdec: Implement mjpeg nvdec hwaccel > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cd98f20b4abac8241ef7f922eb85ba6fe3fe230b --- Changelog| 2 +- configure| 2 ++ libavcodec/Makefile | 1 + libavcodec/hwaccels.h| 1 + libavcodec/mjpegdec.c| 6 libavcodec/nvdec.c | 1 + libavcodec/nvdec_mjpeg.c | 86 libavcodec/version.h | 2 +- 8 files changed, 99 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 441ee1cd29..f7afd2f9ed 100644 --- a/Changelog +++ b/Changelog @@ -13,7 +13,7 @@ version : - PCE support for extended channel layouts in the AAC encoder - native aptX and aptX HD encoder and decoder - Raw aptX and aptX HD muxer and demuxer -- NVIDIA NVDEC-accelerated H.264, HEVC, MPEG-1/2/4, VC1, VP8/9 hwaccel decoding +- NVIDIA NVDEC-accelerated H.264, HEVC, MJPEG, MPEG-1/2/4, VC1, VP8/9 hwaccel decoding - Intel QSV-accelerated overlay filter - mcompand audio filter - acontrast audio filter diff --git a/configure b/configure index 9b2468516a..d40718f842 100755 --- a/configure +++ b/configure @@ -2714,6 +2714,8 @@ hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC" hevc_vdpau_hwaccel_select="hevc_decoder" hevc_videotoolbox_hwaccel_deps="videotoolbox" hevc_videotoolbox_hwaccel_select="hevc_decoder" +mjpeg_nvdec_hwaccel_deps="nvdec" +mjpeg_nvdec_hwaccel_select="mjpeg_decoder" mjpeg_vaapi_hwaccel_deps="vaapi" mjpeg_vaapi_hwaccel_select="mjpeg_decoder" mpeg_xvmc_hwaccel_deps="xvmc" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index de52bc2094..c7a5692421 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -854,6 +854,7 @@ OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec_h2645.o OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o +OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL)+= nvdec_mjpeg.o OBJS-$(CONFIG_MJPEG_VAAPI_HWACCEL)+= vaapi_mjpeg.o OBJS-$(CONFIG_MPEG1_NVDEC_HWACCEL)+= nvdec_mpeg12.o OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL)+= vdpau_mpeg12.o diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h index 420e2feeea..7d73da8676 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -37,6 +37,7 @@ extern const AVHWAccel ff_hevc_nvdec_hwaccel; extern const AVHWAccel ff_hevc_vaapi_hwaccel; extern const AVHWAccel ff_hevc_vdpau_hwaccel; extern const AVHWAccel ff_hevc_videotoolbox_hwaccel; +extern const AVHWAccel ff_mjpeg_nvdec_hwaccel; extern const AVHWAccel ff_mjpeg_vaapi_hwaccel; extern const AVHWAccel ff_mpeg1_nvdec_hwaccel; extern const AVHWAccel ff_mpeg1_vdpau_hwaccel; diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 939f2849d0..beef174618 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -650,6 +650,9 @@ unk_pixfmt: s->avctx->pix_fmt = s->hwaccel_pix_fmt; } else { enum AVPixelFormat pix_fmts[] = { +#if CONFIG_MJPEG_NVDEC_HWACCEL +AV_PIX_FMT_CUDA, +#endif #if CONFIG_MJPEG_VAAPI_HWACCEL AV_PIX_FMT_VAAPI, #endif @@ -2780,6 +2783,9 @@ AVCodec ff_mjpeg_decoder = { .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, .hw_configs = (const AVCodecHWConfigInternal*[]) { +#if CONFIG_MJPEG_NVDEC_HWACCEL +HWACCEL_NVDEC(mjpeg), +#endif #if CONFIG_MJPEG_VAAPI_HWACCEL HWACCEL_VAAPI(mjpeg), #endif diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c index e9e6ea0f8b..ab3cb88b27 100644 --- a/libavcodec/nvdec.c +++ b/libavcodec/nvdec.c @@ -54,6 +54,7 @@ static int map_avcodec_id(enum AVCodecID id) switch (id) { case AV_CODEC_ID_H264: return cudaVideoCodec_H264; case AV_CODEC_ID_HEVC: return cudaVideoCodec_HEVC; +case AV_CODEC_ID_MJPEG: return cudaVideoCodec_JPEG; case AV_CODEC_ID_MPEG1VIDEO: return cudaVideoCodec_MPEG1; case AV_CODEC_ID_MPEG2VIDEO: return cudaVideoCodec_MPEG2; case AV_CODEC_ID_MPEG4: return cudaVideoCodec_MPEG4; diff --git a/libavcodec/nvdec_mjpeg.c b/libavcodec/nvdec_mjpeg.c new file mode 100644 index 00..7e404246ce --- /dev/null +++ b/libavcodec/nvdec_mjpeg.c @@ -0,0 +1,86 @@ +/* + * MJPEG HW decode acceleration through NVDEC + * + * Copyright (c) 2017 Philip Langdale + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + *
[FFmpeg-cvslog] vaapi: Add MJPEG decode hwaccel
ffmpeg | branch: master | Mark Thompson| Thu Nov 23 23:47:52 2017 +| [63c690ad154509dcda78d3d3537bd1af9c406241] | committer: Mark Thompson vaapi: Add MJPEG decode hwaccel > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=63c690ad154509dcda78d3d3537bd1af9c406241 --- Changelog | 2 +- configure | 2 + libavcodec/Makefile | 1 + libavcodec/hwaccels.h | 1 + libavcodec/mjpegdec.c | 6 ++ libavcodec/vaapi_decode.c | 2 + libavcodec/vaapi_mjpeg.c | 159 ++ libavcodec/version.h | 2 +- 8 files changed, 173 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 56dedd1aea..441ee1cd29 100644 --- a/Changelog +++ b/Changelog @@ -21,7 +21,7 @@ version : - video mix filter - video normalize filter - audio lv2 wrapper filter -- VAAPI VP8 decoding +- VAAPI MJPEG and VP8 decoding - AMD AMF H.264 and HEVC encoders - video fillborders filter - video setrange filter diff --git a/configure b/configure index fa5c530abe..9b2468516a 100755 --- a/configure +++ b/configure @@ -2714,6 +2714,8 @@ hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC" hevc_vdpau_hwaccel_select="hevc_decoder" hevc_videotoolbox_hwaccel_deps="videotoolbox" hevc_videotoolbox_hwaccel_select="hevc_decoder" +mjpeg_vaapi_hwaccel_deps="vaapi" +mjpeg_vaapi_hwaccel_select="mjpeg_decoder" mpeg_xvmc_hwaccel_deps="xvmc" mpeg_xvmc_hwaccel_select="mpeg2video_decoder" mpeg1_nvdec_hwaccel_deps="nvdec" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3d4b738e0b..de52bc2094 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -854,6 +854,7 @@ OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec_h2645.o OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o +OBJS-$(CONFIG_MJPEG_VAAPI_HWACCEL)+= vaapi_mjpeg.o OBJS-$(CONFIG_MPEG1_NVDEC_HWACCEL)+= nvdec_mpeg12.o OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL)+= vdpau_mpeg12.o OBJS-$(CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h index fcfe4e088e..420e2feeea 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -37,6 +37,7 @@ extern const AVHWAccel ff_hevc_nvdec_hwaccel; extern const AVHWAccel ff_hevc_vaapi_hwaccel; extern const AVHWAccel ff_hevc_vdpau_hwaccel; extern const AVHWAccel ff_hevc_videotoolbox_hwaccel; +extern const AVHWAccel ff_mjpeg_vaapi_hwaccel; extern const AVHWAccel ff_mpeg1_nvdec_hwaccel; extern const AVHWAccel ff_mpeg1_vdpau_hwaccel; extern const AVHWAccel ff_mpeg1_videotoolbox_hwaccel; diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 6141f06367..939f2849d0 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -650,6 +650,9 @@ unk_pixfmt: s->avctx->pix_fmt = s->hwaccel_pix_fmt; } else { enum AVPixelFormat pix_fmts[] = { +#if CONFIG_MJPEG_VAAPI_HWACCEL +AV_PIX_FMT_VAAPI, +#endif s->avctx->pix_fmt, AV_PIX_FMT_NONE, }; @@ -2777,6 +2780,9 @@ AVCodec ff_mjpeg_decoder = { .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, .hw_configs = (const AVCodecHWConfigInternal*[]) { +#if CONFIG_MJPEG_VAAPI_HWACCEL +HWACCEL_VAAPI(mjpeg), +#endif NULL }, }; diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index 28c6eeb801..d0a6b5817d 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -379,6 +379,8 @@ static const struct { MAP(HEVC,HEVC_MAIN, HEVCMain), MAP(HEVC,HEVC_MAIN_10,HEVCMain10 ), #endif +MAP(MJPEG, MJPEG_HUFFMAN_BASELINE_DCT, + JPEGBaseline), MAP(WMV3,VC1_SIMPLE, VC1Simple ), MAP(WMV3,VC1_MAIN,VC1Main ), MAP(WMV3,VC1_COMPLEX, VC1Advanced ), diff --git a/libavcodec/vaapi_mjpeg.c b/libavcodec/vaapi_mjpeg.c new file mode 100644 index 00..14e0206ae1 --- /dev/null +++ b/libavcodec/vaapi_mjpeg.c @@ -0,0 +1,159 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free
[FFmpeg-cvslog] lavc/mjpeg: Add profiles for MJPEG using SOF marker codes
ffmpeg | branch: master | Mark Thompson| Thu Nov 23 22:44:27 2017 +| [9ca79784e9e640829645b0b28201cf9cdfbfc0f4] | committer: Mark Thompson lavc/mjpeg: Add profiles for MJPEG using SOF marker codes This is needed by later hwaccel code to tell which encoding process was used for a particular frame, because hardware decoders may only support a subset of possible methods. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9ca79784e9e640829645b0b28201cf9cdfbfc0f4 --- libavcodec/avcodec.h | 6 ++ libavcodec/mjpegdec.c| 7 +++ libavcodec/version.h | 4 ++-- tests/ref/fate/api-mjpeg-codec-param | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index bc0eacd66b..74c7b9dadd 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2918,6 +2918,12 @@ typedef struct AVCodecContext { #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3 #define FF_PROFILE_HEVC_REXT4 +#define FF_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT0xc0 +#define FF_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT 0xc1 +#define FF_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT 0xc2 +#define FF_PROFILE_MJPEG_HUFFMAN_LOSSLESS0xc3 +#define FF_PROFILE_MJPEG_JPEG_LS 0xf7 + /** * level * - encoding: Set by user. diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 5055ee2826..29f99373cc 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -2288,6 +2288,10 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, break; case SOF0: case SOF1: +if (start_code == SOF0) +s->avctx->profile = FF_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT; +else +s->avctx->profile = FF_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT; s->lossless= 0; s->ls = 0; s->progressive = 0; @@ -2295,6 +2299,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, goto fail; break; case SOF2: +s->avctx->profile = FF_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT; s->lossless= 0; s->ls = 0; s->progressive = 1; @@ -2302,6 +2307,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, goto fail; break; case SOF3: +s->avctx->profile = FF_PROFILE_MJPEG_HUFFMAN_LOSSLESS; s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS; s->lossless= 1; s->ls = 0; @@ -2310,6 +2316,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, goto fail; break; case SOF48: +s->avctx->profile = FF_PROFILE_MJPEG_JPEG_LS; s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS; s->lossless= 1; s->ls = 1; diff --git a/libavcodec/version.h b/libavcodec/version.h index d13dd41fa3..d772f3e48e 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,8 +28,8 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 58 -#define LIBAVCODEC_VERSION_MINOR 11 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MINOR 12 +#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/tests/ref/fate/api-mjpeg-codec-param b/tests/ref/fate/api-mjpeg-codec-param index e5ad2b7656..290f941ff3 100644 --- a/tests/ref/fate/api-mjpeg-codec-param +++ b/tests/ref/fate/api-mjpeg-codec-param @@ -81,7 +81,7 @@ stream=0, decode=0 nssew=8 skip_top=0 skip_bottom=0 -profile=-99 +profile=192 level=-99 lowres=0 skip_threshold=0 @@ -221,7 +221,7 @@ stream=0, decode=1 nssew=8 skip_top=0 skip_bottom=0 -profile=-99 +profile=192 level=-99 lowres=0 skip_threshold=0 ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] vaapi_decode: Make the frames context format selection more general
ffmpeg | branch: master | Mark Thompson| Mon Feb 19 20:04:31 2018 +| [99ab0a13dc231b92dcd207f58a1101fe5f11d663] | committer: Mark Thompson vaapi_decode: Make the frames context format selection more general Examine the supported fourcc list manually and make the best choice, then use the external attribute on the frames context to force that fourcc. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=99ab0a13dc231b92dcd207f58a1101fe5f11d663 --- libavcodec/vaapi_decode.c | 152 +++--- libavcodec/vaapi_decode.h | 2 + 2 files changed, 132 insertions(+), 22 deletions(-) diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index 572b3a40ac..28c6eeb801 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -233,6 +233,132 @@ int ff_vaapi_decode_cancel(AVCodecContext *avctx, } static const struct { +uint32_t fourcc; +enum AVPixelFormat pix_fmt; +} vaapi_format_map[] = { +#define MAP(va, av) { VA_FOURCC_ ## va, AV_PIX_FMT_ ## av } +// 4:0:0 +MAP(Y800, GRAY8), +// 4:2:0 +MAP(NV12, NV12), +MAP(YV12, YUV420P), +MAP(IYUV, YUV420P), +#ifdef VA_FOURCC_I420 +MAP(I420, YUV420P), +#endif +MAP(IMC3, YUV420P), +// 4:1:1 +MAP(411P, YUV411P), +// 4:2:2 +MAP(422H, YUV422P), +#ifdef VA_FOURCC_YV16 +MAP(YV16, YUV422P), +#endif +// 4:4:0 +MAP(422V, YUV440P), +// 4:4:4 +MAP(444P, YUV444P), +// 4:2:0 10-bit +#ifdef VA_FOURCC_P010 +MAP(P010, P010), +#endif +#ifdef VA_FOURCC_I010 +MAP(I010, YUV420P10), +#endif +#undef MAP +}; + +static int vaapi_decode_find_best_format(AVCodecContext *avctx, + AVHWDeviceContext *device, + VAConfigID config_id, + AVHWFramesContext *frames) +{ +AVVAAPIDeviceContext *hwctx = device->hwctx; +VAStatus vas; +VASurfaceAttrib *attr; +enum AVPixelFormat source_format, best_format, format; +uint32_t best_fourcc, fourcc; +int i, j, nb_attr; + +source_format = avctx->sw_pix_fmt; +av_assert0(source_format != AV_PIX_FMT_NONE); + +vas = vaQuerySurfaceAttributes(hwctx->display, config_id, + NULL, _attr); +if (vas != VA_STATUS_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Failed to query surface attributes: " + "%d (%s).\n", vas, vaErrorStr(vas)); +return AVERROR(ENOSYS); +} + +attr = av_malloc_array(nb_attr, sizeof(*attr)); +if (!attr) +return AVERROR(ENOMEM); + +vas = vaQuerySurfaceAttributes(hwctx->display, config_id, + attr, _attr); +if (vas != VA_STATUS_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Failed to query surface attributes: " + "%d (%s).\n", vas, vaErrorStr(vas)); +av_freep(); +return AVERROR(ENOSYS); +} + +best_format = AV_PIX_FMT_NONE; + +for (i = 0; i < nb_attr; i++) { +if (attr[i].type != VASurfaceAttribPixelFormat) +continue; + +fourcc = attr[i].value.value.i; +for (j = 0; j < FF_ARRAY_ELEMS(vaapi_format_map); j++) { +if (fourcc == vaapi_format_map[j].fourcc) +break; +} +if (j >= FF_ARRAY_ELEMS(vaapi_format_map)) { +av_log(avctx, AV_LOG_DEBUG, "Ignoring unknown format %#x.\n", + fourcc); +continue; +} +format = vaapi_format_map[j].pix_fmt; +av_log(avctx, AV_LOG_DEBUG, "Considering format %#x -> %s.\n", + fourcc, av_get_pix_fmt_name(format)); + +best_format = av_find_best_pix_fmt_of_2(format, best_format, +source_format, 0, NULL); +if (format == best_format) +best_fourcc = fourcc; +} + +av_freep(); + +if (best_format == AV_PIX_FMT_NONE) { +av_log(avctx, AV_LOG_ERROR, "No usable formats for decoding!\n"); +return AVERROR(EINVAL); +} + +av_log(avctx, AV_LOG_DEBUG, "Picked %s (%#x) as best match for %s.\n", + av_get_pix_fmt_name(best_format), best_fourcc, + av_get_pix_fmt_name(source_format)); + +frames->sw_format = best_format; +if (avctx->internal->hwaccel_priv_data) { +VAAPIDecodeContext*ctx = avctx->internal->hwaccel_priv_data; +AVVAAPIFramesContext *avfc = frames->hwctx; + +ctx->pixel_format_attribute = (VASurfaceAttrib) { +.type = VASurfaceAttribPixelFormat, +.value.value.i = best_fourcc, +}; + +avfc->attributes= >pixel_format_attribute; +avfc->nb_attributes = 1; +} + +return 0; +} + +static const struct { enum AVCodecID codec_id; int codec_profile; VAProfile va_profile; @@ -289,7 +415,6 @@ static int vaapi_decode_make_config(AVCodecContext *avctx, const
[FFmpeg-cvslog] mjpegdec: Add hwaccel hooks
ffmpeg | branch: master | Mark Thompson| Thu Nov 23 23:45:32 2017 +| [6c0bfa30c00d062737b10f22c2532f60d94afdf2] | committer: Mark Thompson mjpegdec: Add hwaccel hooks Also adds some extra fields to the main context structure that may be needed by a hwaccel decoder. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6c0bfa30c00d062737b10f22c2532f60d94afdf2 --- libavcodec/mjpegdec.c | 74 --- libavcodec/mjpegdec.h | 13 + 2 files changed, 83 insertions(+), 4 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 29f99373cc..6141f06367 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -36,6 +36,7 @@ #include "avcodec.h" #include "blockdsp.h" #include "copy_block.h" +#include "hwaccel.h" #include "idctdsp.h" #include "internal.h" #include "jpegtables.h" @@ -147,6 +148,7 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) s->org_height= avctx->coded_height; avctx->chroma_sample_location = AVCHROMA_LOC_CENTER; avctx->colorspace = AVCOL_SPC_BT470BG; +s->hwaccel_pix_fmt = s->hwaccel_sw_pix_fmt = AV_PIX_FMT_NONE; if ((ret = build_basic_mjpeg_vlc(s)) < 0) return ret; @@ -279,13 +281,18 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s) code_max + 1, 0, 0)) < 0) return ret; } + +for (i = 0; i < 16; i++) +s->raw_huffman_lengths[class][index][i] = bits_table[i + 1]; +for (i = 0; i < 256; i++) +s->raw_huffman_values[class][index][i] = val_table[i]; } return 0; } int ff_mjpeg_decode_sof(MJpegDecodeContext *s) { -int len, nb_components, i, width, height, bits, ret; +int len, nb_components, i, width, height, bits, ret, size_change; unsigned pix_fmt_id; int h_count[MAX_COMPONENTS] = { 0 }; int v_count[MAX_COMPONENTS] = { 0 }; @@ -392,6 +399,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) if (width != s->width || height != s->height || bits != s->bits || memcmp(s->h_count, h_count, sizeof(h_count))|| memcmp(s->v_count, v_count, sizeof(v_count))) { +size_change = 1; s->width = width; s->height = height; @@ -418,6 +426,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) return ret; s->first_picture = 0; +} else { +size_change = 0; } if (s->got_picture && s->interlaced && (s->bottom_field == !s->interlace_polarity)) { @@ -636,6 +646,21 @@ unk_pixfmt: return AVERROR_BUG; } +if (s->avctx->pix_fmt == s->hwaccel_sw_pix_fmt && !size_change) { +s->avctx->pix_fmt = s->hwaccel_pix_fmt; +} else { +enum AVPixelFormat pix_fmts[] = { +s->avctx->pix_fmt, +AV_PIX_FMT_NONE, +}; +s->hwaccel_pix_fmt = ff_get_format(s->avctx, pix_fmts); +if (s->hwaccel_pix_fmt < 0) +return AVERROR(EINVAL); + +s->hwaccel_sw_pix_fmt = s->avctx->pix_fmt; +s->avctx->pix_fmt = s->hwaccel_pix_fmt; +} + if (s->avctx->skip_frame == AVDISCARD_ALL) { s->picture_ptr->pict_type = AV_PICTURE_TYPE_I; s->picture_ptr->key_frame = 1; @@ -683,6 +708,19 @@ unk_pixfmt: } memset(s->coefs_finished, 0, sizeof(s->coefs_finished)); } + +if (s->avctx->hwaccel) { +s->hwaccel_picture_private = +av_mallocz(s->avctx->hwaccel->frame_priv_data_size); +if (!s->hwaccel_picture_private) +return AVERROR(ENOMEM); + +ret = s->avctx->hwaccel->start_frame(s->avctx, s->raw_image_buffer, + s->raw_image_buffer_size); +if (ret < 0) +return ret; +} + return 0; } @@ -1510,7 +1548,6 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, } } -av_assert0(s->picture_ptr->data[0]); /* XXX: verify len field validity */ len = get_bits(>gb, 16); nb_components = get_bits(>gb, 8); @@ -1600,7 +1637,18 @@ next_field: for (i = 0; i < nb_components; i++) s->last_dc[i] = (4 << s->bits); -if (s->lossless) { +if (s->avctx->hwaccel) { +int bytes_to_start = get_bits_count(>gb) / 8; +av_assert0(bytes_to_start >= 0 && + s->raw_scan_buffer_size >= bytes_to_start); + +ret = s->avctx->hwaccel->decode_slice(s->avctx, + s->raw_scan_buffer + bytes_to_start, + s->raw_scan_buffer_size - bytes_to_start); +if (ret < 0) +return ret; + +} else if (s->lossless) { av_assert0(s->picture_ptr == s->picture); if (CONFIG_JPEGLS_DECODER && s->ls) { //for () { @@ -2278,6 +2326,8 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void
[FFmpeg-cvslog] hwcontext_vaapi: Fix frames context creation with external attributes
ffmpeg | branch: master | Mark Thompson| Mon Feb 19 20:04:25 2018 +| [193e43e6195eba669015098b4245a7287b7506b0] | committer: Mark Thompson hwcontext_vaapi: Fix frames context creation with external attributes > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=193e43e6195eba669015098b4245a7287b7506b0 --- libavutil/hwcontext_vaapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 68f88ecd6b..af9a136ef0 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -475,9 +475,9 @@ static int vaapi_frames_init(AVHWFramesContext *hwfc) int need_memory_type = !(hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE); int need_pixel_format = 1; for (i = 0; i < avfc->nb_attributes; i++) { -if (ctx->attributes[i].type == VASurfaceAttribMemoryType) +if (avfc->attributes[i].type == VASurfaceAttribMemoryType) need_memory_type = 0; -if (ctx->attributes[i].type == VASurfaceAttribPixelFormat) +if (avfc->attributes[i].type == VASurfaceAttribPixelFormat) need_pixel_format = 0; } ctx->nb_attributes = ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] hwcontext_vaapi: Add more surface formats
ffmpeg | branch: master | Mark Thompson| Mon Feb 19 20:03:08 2018 +| [fabcbfba3846667869e14a562bd84c7b4dd0c6a4] | committer: Mark Thompson hwcontext_vaapi: Add more surface formats Adds YUV 4:1:1, 4:4:0 and 4:4:4 - these will be needed for JPEG decoding. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fabcbfba3846667869e14a562bd84c7b4dd0c6a4 --- libavutil/hwcontext_vaapi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 29698d1b27..68f88ecd6b 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -110,6 +110,9 @@ static const struct { MAP(422H, YUV422, YUV422P), MAP(UYVY, YUV422, UYVY422), MAP(YUY2, YUV422, YUYV422), +MAP(411P, YUV411, YUV411P), +MAP(422V, YUV422, YUV440P), +MAP(444P, YUV444, YUV444P), MAP(Y800, YUV400, GRAY8), #ifdef VA_FOURCC_P010 MAP(P010, YUV420_10BPP, P010), ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] libavfilter/vf_fps: Add tests for start_time option
ffmpeg | branch: master | Calvin Walton| Mon Feb 19 19:54:35 2018 -0500| [ff0de964e7abba6df0d8923f70f93cbd6c242ec8] | committer: Michael Niedermayer libavfilter/vf_fps: Add tests for start_time option Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ff0de964e7abba6df0d8923f70f93cbd6c242ec8 --- tests/fate/filter-video.mak | 4 +++- tests/ref/fate/filter-fps-start-drop | 11 +++ tests/ref/fate/filter-fps-start-fill | 11 +++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index e3e128cf67..07572143a8 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -425,7 +425,7 @@ fate-filter-concat: CMD = framecrc -filter_complex_script $(TARGET_PATH)/tests/d FATE_FILTER-$(call ALLYES, TESTSRC2_FILTER FPS_FILTER MPDECIMATE_FILTER) += fate-filter-mpdecimate fate-filter-mpdecimate: CMD = framecrc -lavfi testsrc2=r=2:d=10,fps=3,mpdecimate -r 3 -pix_fmt yuv420p -FATE_FILTER-$(call ALLYES, FPS_FILTER TESTSRC2_FILTER) += fate-filter-fps-up fate-filter-fps-up-round-down fate-filter-fps-up-round-up fate-filter-fps-down fate-filter-fps-down-round-down fate-filter-fps-down-round-up fate-filter-fps-down-eof-pass +FATE_FILTER-$(call ALLYES, FPS_FILTER TESTSRC2_FILTER) += fate-filter-fps-up fate-filter-fps-up-round-down fate-filter-fps-up-round-up fate-filter-fps-down fate-filter-fps-down-round-down fate-filter-fps-down-round-up fate-filter-fps-down-eof-pass fate-filter-fps-start-drop fate-filter-fps-start-fill fate-filter-fps-up: CMD = framecrc -lavfi testsrc2=r=3:d=2,fps=7 fate-filter-fps-up-round-down: CMD = framecrc -lavfi testsrc2=r=3:d=2,fps=7:round=down fate-filter-fps-up-round-up: CMD = framecrc -lavfi testsrc2=r=3:d=2,fps=7:round=up @@ -433,6 +433,8 @@ fate-filter-fps-down: CMD = framecrc -lavfi testsrc2=r=7:d=3.5,fps=3 fate-filter-fps-down-round-down: CMD = framecrc -lavfi testsrc2=r=7:d=3.5,fps=3:round=down fate-filter-fps-down-round-up: CMD = framecrc -lavfi testsrc2=r=7:d=3.5,fps=3:round=up fate-filter-fps-down-eof-pass: CMD = framecrc -lavfi testsrc2=r=7:d=3.5,fps=3:eof_action=pass +fate-filter-fps-start-drop: CMD = framecrc -lavfi testsrc2=r=7:d=3.5,fps=3:start_time=1.5 +fate-filter-fps-start-fill: CMD = framecrc -lavfi testsrc2=r=7:d=1.5,setpts=PTS+14,fps=3:start_time=1.5 FATE_FILTER_SAMPLES-$(call ALLYES, MOV_DEMUXER FPS_FILTER QTRLE_DECODER) += fate-filter-fps-cfr fate-filter-fps fate-filter-fps-r fate-filter-fps-cfr: CMD = framecrc -i $(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -r 30 -vsync cfr -pix_fmt yuv420p diff --git a/tests/ref/fate/filter-fps-start-drop b/tests/ref/fate/filter-fps-start-drop new file mode 100644 index 00..cfa1c40997 --- /dev/null +++ b/tests/ref/fate/filter-fps-start-drop @@ -0,0 +1,11 @@ +#tb 0: 1/3 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 320x240 +#sar 0: 1/1 +0, 5, 5,1, 115200, 0x2d0ba5a4 +0, 6, 6,1, 115200, 0xc95a675e +0, 7, 7,1, 115200, 0xf040bf35 +0, 8, 8,1, 115200, 0x5635daa5 +0, 9, 9,1, 115200, 0x0caf7172 +0, 10, 10,1, 115200, 0xc8ce7fb1 diff --git a/tests/ref/fate/filter-fps-start-fill b/tests/ref/fate/filter-fps-start-fill new file mode 100644 index 00..c5efb42a8f --- /dev/null +++ b/tests/ref/fate/filter-fps-start-fill @@ -0,0 +1,11 @@ +#tb 0: 1/3 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 320x240 +#sar 0: 1/1 +0, 5, 5,1, 115200, 0x3744b3ed +0, 6, 6,1, 115200, 0x3744b3ed +0, 7, 7,1, 115200, 0x201b9db1 +0, 8, 8,1, 115200, 0x75e1a17b +0, 9, 9,1, 115200, 0xb73857e2 +0, 10, 10,1, 115200, 0x02b6ab21 ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avdevice: add android_camera indev
ffmpeg | branch: master | Felix Matouschek| Tue Feb 20 09:41:46 2018 +0100| [5ac3a309fddde79db1f70269fbcbd0ba4d94d30e] | committer: Michael Niedermayer avdevice: add android_camera indev This commit adds an indev for Android devices on API level 24+ which uses the Android NDK Camera2 API to capture video from builtin cameras Signed-off-by: Felix Matouschek Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5ac3a309fddde79db1f70269fbcbd0ba4d94d30e --- Changelog| 1 + MAINTAINERS | 1 + configure| 6 + doc/indevs.texi | 40 ++ libavdevice/Makefile | 1 + libavdevice/alldevices.c | 1 + libavdevice/android_camera.c | 871 +++ libavdevice/version.h| 2 +- 8 files changed, 922 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 2acdbbea30..56dedd1aea 100644 --- a/Changelog +++ b/Changelog @@ -39,6 +39,7 @@ version : - Removed the ffmenc and ffmdec muxer and demuxer - VideoToolbox HEVC encoder and hwaccel - VAAPI-accelerated ProcAmp (color balance), denoise and sharpness filters +- Add android_camera indev version 3.4: diff --git a/MAINTAINERS b/MAINTAINERS index b691bd56ec..bf1299bdbf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -281,6 +281,7 @@ libavdevice avfoundation.mThilo Borgmann + android_camera.c Felix Matouschek decklink* Marton Balint dshow.c Roger Pack (CC rogerdp...@gmail.com) fbdev_enc.c Lukasz Marek diff --git a/configure b/configure index 013308cfa4..fa5c530abe 100755 --- a/configure +++ b/configure @@ -3081,6 +3081,8 @@ xmv_demuxer_select="riffdec" xwma_demuxer_select="riffdec" # indevs / outdevs +android_camera_indev_deps="android camera2ndk mediandk pthreads" +android_camera_indev_extralibs="-landroid -lcamera2ndk -lmediandk" alsa_indev_deps="alsa" alsa_outdev_deps="alsa" avfoundation_indev_deps="avfoundation corevideo coremedia pthreads" @@ -5756,6 +5758,10 @@ check_lib shell32 "windows.h shellapi.h" CommandLineToArgvW -lshell32 check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom -ladvapi32 check_lib psapi"windows.h psapi.h"GetProcessMemoryInfo -lpsapi +check_lib android android/native_window.h ANativeWindow_acquire -landroid +check_lib mediandk "stdint.h media/NdkImage.h" AImage_delete -lmediandk +check_lib camera2ndk "stdbool.h stdint.h camera/NdkCameraManager.h" ACameraManager_create -lcamera2ndk + enabled appkit && check_apple_framework AppKit enabled audiotoolbox && check_apple_framework AudioToolbox enabled avfoundation && check_apple_framework AVFoundation diff --git a/doc/indevs.texi b/doc/indevs.texi index 0bc8e6a9b1..6951940a93 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -63,6 +63,46 @@ Set the number of channels. Default is 2. @end table +@section android_camera + +Android camera input device. + +This input devices uses the Android Camera2 NDK API which is +available on devices with API level 24+. The availability of +android_camera is autodetected during configuration. + +This device allows capturing from all cameras on an Android device, +which are integrated into the Camera2 NDK API. + +The available cameras are enumerated internally and can be selected +with the @var{camera_index} parameter. The input file string is +discarded. + +Generally the back facing camera has index 0 while the front facing +camera has index 1. + +@subsection Options + +@table @option + +@item video_size +Set the video size given as a string such as 640x480 or hd720. +Falls back to the first available configuration reported by +Android if requested video size is not available or by default. + +@item framerate +Set the video framerate. +Falls back to the first available configuration reported by +Android if requested framerate is not available or by default (-1). + +@item camera_index +Set the index of the camera to use. Default is 0. + +@item input_queue_size +Set the maximum number of frames to buffer. Default is 5. + +@end table + @section avfoundation AVFoundation input device. diff --git a/libavdevice/Makefile b/libavdevice/Makefile index 8228d62147..f11a6f2a86 100644 --- a/libavdevice/Makefile +++ b/libavdevice/Makefile @@ -14,6 +14,7 @@ OBJS-$(CONFIG_SHARED)+= reverse.o # input/output devices OBJS-$(CONFIG_ALSA_INDEV)+= alsa_dec.o alsa.o timefilter.o OBJS-$(CONFIG_ALSA_OUTDEV) += alsa_enc.o alsa.o +OBJS-$(CONFIG_ANDROID_CAMERA_INDEV) += android_camera.o OBJS-$(CONFIG_AVFOUNDATION_INDEV)+= avfoundation.o OBJS-$(CONFIG_BKTR_INDEV)+= bktr.o OBJS-$(CONFIG_CACA_OUTDEV) += caca.o diff --git
[FFmpeg-cvslog] avformat/mpegenc - log error msgs for unsupported LPCM streams
ffmpeg | branch: master | Gyan Doshi| Tue Feb 20 20:49:28 2018 +0530| [4f8c691040b026d001ff33d38c0e1516a35b946e] | committer: Michael Niedermayer avformat/mpegenc - log error msgs for unsupported LPCM streams The MPEG-PS muxer only accepts PCM streams having up to 8 channels and the following sampling rates: 32/44.1/48/96 kHz. Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4f8c691040b026d001ff33d38c0e1516a35b946e --- libavformat/mpegenc.c | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index c84dc52eb9..4c6fa67fb8 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -375,10 +375,19 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) if (lpcm_freq_tab[j] == st->codecpar->sample_rate) break; } -if (j == 4) +if (j == 4) { +int sr; +av_log(ctx, AV_LOG_ERROR, "Invalid sampling rate for PCM stream.\n"); +av_log(ctx, AV_LOG_INFO, "Allowed sampling rates:"); +for (sr = 0; sr < 4; sr++) + av_log(ctx, AV_LOG_INFO, " %d", lpcm_freq_tab[sr]); +av_log(ctx, AV_LOG_INFO, "\n"); goto fail; -if (st->codecpar->channels > 8) -return -1; +} +if (st->codecpar->channels > 8) { +av_log(ctx, AV_LOG_ERROR, "At most 8 channels allowed for LPCM streams.\n"); +goto fail; +} stream->lpcm_header[0] = 0x0c; stream->lpcm_header[1] = (st->codecpar->channels - 1) | (j << 4); stream->lpcm_header[2] = 0x80; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/cavsdec: Check alpha/beta offset
ffmpeg | branch: master | Michael Niedermayer| Tue Feb 20 23:11:01 2018 +0100| [ae2eb04648839bfc6c61c32cb0f124e91bb7ff8e] | committer: Michael Niedermayer avcodec/cavsdec: Check alpha/beta offset Fixes: Integer overflow Fixes: 6183/clusterfuzz-testcase-minimized-6269224436629504 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae2eb04648839bfc6c61c32cb0f124e91bb7ff8e --- libavcodec/cavsdec.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index 06c752735e..c7fff67c06 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -1067,6 +1067,11 @@ static int decode_pic(AVSContext *h) if (!h->loop_filter_disable && get_bits1(>gb)) { h->alpha_offset= get_se_golomb(>gb); h->beta_offset = get_se_golomb(>gb); +if ( h->alpha_offset < -64 || h->alpha_offset > 64 +|| h-> beta_offset < -64 || h-> beta_offset > 64) { +h->alpha_offset = h->beta_offset = 0; +return AVERROR_INVALIDDATA; +} } else { h->alpha_offset = h->beta_offset = 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit '6d5a6dde5301c81e221a37b3f39bb03149492b98'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 22:54:07 2018 +| [ecb3d6edc3b756cc1d40b1073f244b581ef5bcfb] | committer: Mark Thompson Merge commit '6d5a6dde5301c81e221a37b3f39bb03149492b98' * commit '6d5a6dde5301c81e221a37b3f39bb03149492b98': h264_metadata: Add option to delete filler data Fixes #6899. Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ecb3d6edc3b756cc1d40b1073f244b581ef5bcfb --- libavcodec/h264_metadata_bsf.c | 43 ++ 1 file changed, 43 insertions(+) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index 81cdcac5cf..89bdedfc69 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -63,6 +63,8 @@ typedef struct H264MetadataContext { const char *sei_user_data; int sei_first_au; + +int delete_filler; } H264MetadataContext; @@ -346,6 +348,44 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) } } +if (ctx->delete_filler) { +for (i = 0; i < au->nb_units; i++) { +if (au->units[i].type == H264_NAL_FILLER_DATA) { +// Filler NAL units. +err = ff_cbs_delete_unit(ctx->cbc, au, i); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to delete " + "filler NAL.\n"); +goto fail; +} +--i; +continue; +} + +if (au->units[i].type == H264_NAL_SEI) { +// Filler SEI messages. +H264RawSEI *sei = au->units[i].content; + +for (j = 0; j < sei->payload_count; j++) { +if (sei->payload[j].payload_type == +H264_SEI_TYPE_FILLER_PAYLOAD) { +err = ff_cbs_h264_delete_sei_message(ctx->cbc, au, + >units[i], j); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to delete " + "filler SEI message.\n"); +goto fail; +} +// Renumbering might have happened, start again at +// the same NAL unit position. +--i; +break; +} +} +} +} +} + err = ff_cbs_write_packet(ctx->cbc, out, au); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); @@ -465,6 +505,9 @@ static const AVOption h264_metadata_options[] = { { "sei_user_data", "Insert SEI user data (UUID+string)", OFFSET(sei_user_data), AV_OPT_TYPE_STRING, { .str = NULL } }, +{ "delete_filler", "Delete all filler (both NAL and SEI)", +OFFSET(delete_filler), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1 }, + { NULL } }; == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] h264_metadata: Add option to delete filler data
ffmpeg | branch: master | Mark Thompson| Mon Dec 11 00:30:54 2017 +| [6d5a6dde5301c81e221a37b3f39bb03149492b98] | committer: Mark Thompson h264_metadata: Add option to delete filler data Deletes both filler NAL units and filler SEI messages. (Annex B zero_bytes between NAL units are already discarded by the read/write process.) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6d5a6dde5301c81e221a37b3f39bb03149492b98 --- libavcodec/h264_metadata_bsf.c | 43 ++ 1 file changed, 43 insertions(+) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index d8d5487c99..7b51e8ee8b 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -63,6 +63,8 @@ typedef struct H264MetadataContext { const char *sei_user_data; int sei_first_au; + +int delete_filler; } H264MetadataContext; @@ -346,6 +348,44 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) } } +if (ctx->delete_filler) { +for (i = 0; i < au->nb_units; i++) { +if (au->units[i].type == H264_NAL_FILLER_DATA) { +// Filler NAL units. +err = ff_cbs_delete_unit(ctx->cbc, au, i); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to delete " + "filler NAL.\n"); +goto fail; +} +--i; +continue; +} + +if (au->units[i].type == H264_NAL_SEI) { +// Filler SEI messages. +H264RawSEI *sei = au->units[i].content; + +for (j = 0; j < sei->payload_count; j++) { +if (sei->payload[j].payload_type == +H264_SEI_TYPE_FILLER_PAYLOAD) { +err = ff_cbs_h264_delete_sei_message(ctx->cbc, au, + >units[i], j); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to delete " + "filler SEI message.\n"); +goto fail; +} +// Renumbering might have happened, start again at +// the same NAL unit position. +--i; +break; +} +} +} +} +} + err = ff_cbs_write_packet(ctx->cbc, out, au); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); @@ -465,6 +505,9 @@ static const AVOption h264_metadata_options[] = { { "sei_user_data", "Insert SEI user data (UUID+string)", OFFSET(sei_user_data), AV_OPT_TYPE_STRING, { .str = NULL } }, +{ "delete_filler", "Delete all filler (both NAL and SEI)", +OFFSET(delete_filler), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1 }, + { NULL } }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] cbs_h264: Add support for filler NAL units
ffmpeg | branch: master | Mark Thompson| Sun Feb 11 17:33:15 2018 +| [eccc03c8fbc603a0a3257df66f0705f74fe2581a] | committer: Mark Thompson cbs_h264: Add support for filler NAL units > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eccc03c8fbc603a0a3257df66f0705f74fe2581a --- libavcodec/cbs_h264.h | 6 ++ libavcodec/cbs_h2645.c| 21 + libavcodec/cbs_h264_syntax_template.c | 29 + 3 files changed, 56 insertions(+) diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index a59b7be1be..5a7dc27698 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -408,6 +408,12 @@ typedef struct H264RawSlice { AVBufferRef *data_ref; } H264RawSlice; +typedef struct H264RawFiller { +H264RawNALUnitHeader nal_unit_header; + +uint32_t filler_size; +} H264RawFiller; + typedef struct CodedBitstreamH264Context { // Reader/writer context in common with the H.265 implementation. diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index ebc02361d0..d6131a13e5 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -815,6 +815,19 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, } break; +case H264_NAL_FILLER_DATA: +{ +err = ff_cbs_alloc_unit_content(ctx, unit, +sizeof(H264RawFiller), NULL); +if (err < 0) +return err; + +err = cbs_h264_read_filler(ctx, , unit->content); +if (err < 0) +return err; +} +break; + default: return AVERROR(ENOSYS); } @@ -1070,6 +1083,14 @@ static int cbs_h264_write_nal_unit(CodedBitstreamContext *ctx, } break; +case H264_NAL_FILLER_DATA: +{ +err = cbs_h264_write_filler(ctx, pbc, unit->content); +if (err < 0) +return err; +} +break; + default: av_log(ctx->log_ctx, AV_LOG_ERROR, "Write unimplemented for " "NAL unit type %"PRIu32".\n", unit->type); diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 29e9735987..1aa7888584 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -1247,3 +1247,32 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } + +static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw, +H264RawFiller *current) +{ +av_unused int ff_byte = 0xff; +int err; + +HEADER("Filler Data"); + +CHECK(FUNC(nal_unit_header)(ctx, rw, >nal_unit_header, +1 << H264_NAL_FILLER_DATA)); + +#ifdef READ +while (bitstream_peek(rw, 8) == 0xff) { +xu(8, ff_byte, ff_byte, 0xff, 0xff); +++current->filler_size; +} +#else +{ +uint32_t i; +for (i = 0; i < current->filler_size; i++) +xu(8, ff_byte, ff_byte, 0xff, 0xff); +} +#endif + +CHECK(FUNC(rbsp_trailing_bits)(ctx, rw)); + +return 0; +} ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit 'eccc03c8fbc603a0a3257df66f0705f74fe2581a'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 22:43:13 2018 +| [fbeac5356c692b6f681a21749dee3a3e414f1230] | committer: Mark Thompson Merge commit 'eccc03c8fbc603a0a3257df66f0705f74fe2581a' * commit 'eccc03c8fbc603a0a3257df66f0705f74fe2581a': cbs_h264: Add support for filler NAL units Some bitstream -> get_bits. Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fbeac5356c692b6f681a21749dee3a3e414f1230 --- libavcodec/cbs_h264.h | 6 ++ libavcodec/cbs_h2645.c| 21 + libavcodec/cbs_h264_syntax_template.c | 29 + 3 files changed, 56 insertions(+) diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index 11dce87103..2219d9da8d 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -408,6 +408,12 @@ typedef struct H264RawSlice { AVBufferRef *data_ref; } H264RawSlice; +typedef struct H264RawFiller { +H264RawNALUnitHeader nal_unit_header; + +uint32_t filler_size; +} H264RawFiller; + typedef struct CodedBitstreamH264Context { // Reader/writer context in common with the H.265 implementation. diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index b717937e4a..5ad0f2b500 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -815,6 +815,19 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, } break; +case H264_NAL_FILLER_DATA: +{ +err = ff_cbs_alloc_unit_content(ctx, unit, +sizeof(H264RawFiller), NULL); +if (err < 0) +return err; + +err = cbs_h264_read_filler(ctx, , unit->content); +if (err < 0) +return err; +} +break; + default: return AVERROR(ENOSYS); } @@ -1070,6 +1083,14 @@ static int cbs_h264_write_nal_unit(CodedBitstreamContext *ctx, } break; +case H264_NAL_FILLER_DATA: +{ +err = cbs_h264_write_filler(ctx, pbc, unit->content); +if (err < 0) +return err; +} +break; + default: av_log(ctx->log_ctx, AV_LOG_ERROR, "Write unimplemented for " "NAL unit type %"PRIu32".\n", unit->type); diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 05370b81fa..f58dee8a25 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -1247,3 +1247,32 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } + +static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw, +H264RawFiller *current) +{ +av_unused int ff_byte = 0xff; +int err; + +HEADER("Filler Data"); + +CHECK(FUNC(nal_unit_header)(ctx, rw, >nal_unit_header, +1 << H264_NAL_FILLER_DATA)); + +#ifdef READ +while (show_bits(rw, 8) == 0xff) { +xu(8, ff_byte, ff_byte, 0xff, 0xff); +++current->filler_size; +} +#else +{ +uint32_t i; +for (i = 0; i < current->filler_size; i++) +xu(8, ff_byte, ff_byte, 0xff, 0xff); +} +#endif + +CHECK(FUNC(rbsp_trailing_bits)(ctx, rw)); + +return 0; +} == diff --cc libavcodec/cbs_h2645.c index b717937e4a,d6131a13e5..5ad0f2b500 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@@ -815,6 -815,19 +815,19 @@@ static int cbs_h264_read_nal_unit(Coded } break; + case H264_NAL_FILLER_DATA: + { + err = ff_cbs_alloc_unit_content(ctx, unit, + sizeof(H264RawFiller), NULL); + if (err < 0) + return err; + -err = cbs_h264_read_filler(ctx, , unit->content); ++err = cbs_h264_read_filler(ctx, , unit->content); + if (err < 0) + return err; + } + break; + default: return AVERROR(ENOSYS); } diff --cc libavcodec/cbs_h264_syntax_template.c index 05370b81fa,1aa7888584..f58dee8a25 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@@ -1247,3 -1247,32 +1247,32 @@@ static int FUNC(slice_header)(CodedBits return 0; } + + static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw, + H264RawFiller *current) + { + av_unused int ff_byte = 0xff; + int err; + + HEADER("Filler Data"); + + CHECK(FUNC(nal_unit_header)(ctx, rw, >nal_unit_header, + 1 << H264_NAL_FILLER_DATA)); + + #ifdef READ -while (bitstream_peek(rw, 8) == 0xff) { ++while (show_bits(rw, 8) == 0xff) { + xu(8, ff_byte, ff_byte, 0xff, 0xff); +
[FFmpeg-cvslog] Merge commit '7157d959264f3729da463725c6faa580d9394d19'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 22:41:00 2018 +| [ab6edb173b365d9a787c2df3a45e3a018d7843d7] | committer: Mark Thompson Merge commit '7157d959264f3729da463725c6faa580d9394d19' * commit '7157d959264f3729da463725c6faa580d9394d19': cbs_h264: Move slice_group_id array out of PPS structure Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ab6edb173b365d9a787c2df3a45e3a018d7843d7 --- libavcodec/cbs_h264.h | 4 +++- libavcodec/cbs_h2645.c| 10 +- libavcodec/cbs_h264_syntax_template.c | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index ae39fc7040..11dce87103 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -195,7 +195,9 @@ typedef struct H264RawPPS { uint8_t slice_group_change_direction_flag; uint16_t slice_group_change_rate_minus1; uint16_t pic_size_in_map_units_minus1; -uint8_t slice_group_id[H264_MAX_MB_PIC_SIZE]; + +uint8_t *slice_group_id; +AVBufferRef *slice_group_id_ref; uint8_t num_ref_idx_l0_default_active_minus1; uint8_t num_ref_idx_l1_default_active_minus1; diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 8c3705b6e1..b717937e4a 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -394,6 +394,13 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) #undef allocate +static void cbs_h264_free_pps(void *unit, uint8_t *content) +{ +H264RawPPS *pps = (H264RawPPS*)content; +av_buffer_unref(>slice_group_id_ref); +av_freep(); +} + static void cbs_h264_free_sei_payload(H264RawSEIPayload *payload) { switch (payload->payload_type) { @@ -725,7 +732,8 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, { H264RawPPS *pps; -err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*pps), NULL); +err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*pps), +_h264_free_pps); if (err < 0) return err; pps = unit->content; diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 267f35ccb7..05370b81fa 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -404,6 +404,9 @@ static int FUNC(pps)(CodedBitstreamContext *ctx, RWContext *rw, ue(slice_group_change_rate_minus1, 0, pic_size - 1); } else if (current->slice_group_map_type == 6) { ue(pic_size_in_map_units_minus1, pic_size - 1, pic_size - 1); + +allocate(current->slice_group_id, + current->pic_size_in_map_units_minus1 + 1); for (i = 0; i <= current->pic_size_in_map_units_minus1; i++) u(av_log2(2 * current->num_slice_groups_minus1 + 1), slice_group_id[i], 0, current->num_slice_groups_minus1); == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] cbs_h264: Move slice_group_id array out of PPS structure
ffmpeg | branch: master | Mark Thompson| Sun Feb 11 00:57:46 2018 +| [7157d959264f3729da463725c6faa580d9394d19] | committer: Mark Thompson cbs_h264: Move slice_group_id array out of PPS structure It's very large, and is only used in some FMO streams. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7157d959264f3729da463725c6faa580d9394d19 --- libavcodec/cbs_h264.h | 4 +++- libavcodec/cbs_h2645.c| 10 +- libavcodec/cbs_h264_syntax_template.c | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index 8c17680bb5..a59b7be1be 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -195,7 +195,9 @@ typedef struct H264RawPPS { uint8_t slice_group_change_direction_flag; uint16_t slice_group_change_rate_minus1; uint16_t pic_size_in_map_units_minus1; -uint8_t slice_group_id[H264_MAX_MB_PIC_SIZE]; + +uint8_t *slice_group_id; +AVBufferRef *slice_group_id_ref; uint8_t num_ref_idx_l0_default_active_minus1; uint8_t num_ref_idx_l1_default_active_minus1; diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 25bd33f162..ebc02361d0 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -394,6 +394,13 @@ static int cbs_h2645_read_more_rbsp_data(BitstreamContext *bc) #undef allocate +static void cbs_h264_free_pps(void *unit, uint8_t *content) +{ +H264RawPPS *pps = (H264RawPPS*)content; +av_buffer_unref(>slice_group_id_ref); +av_freep(); +} + static void cbs_h264_free_sei_payload(H264RawSEIPayload *payload) { switch (payload->payload_type) { @@ -725,7 +732,8 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, { H264RawPPS *pps; -err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*pps), NULL); +err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*pps), +_h264_free_pps); if (err < 0) return err; pps = unit->content; diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index c2fd546822..29e9735987 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -404,6 +404,9 @@ static int FUNC(pps)(CodedBitstreamContext *ctx, RWContext *rw, ue(slice_group_change_rate_minus1, 0, pic_size - 1); } else if (current->slice_group_map_type == 6) { ue(pic_size_in_map_units_minus1, pic_size - 1, pic_size - 1); + +allocate(current->slice_group_id, + current->pic_size_in_map_units_minus1 + 1); for (i = 0; i <= current->pic_size_in_map_units_minus1; i++) u(av_log2(2 * current->num_slice_groups_minus1 + 1), slice_group_id[i], 0, current->num_slice_groups_minus1); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit '78fa0b9033c0834c049e2aedf71a8c613fed87ab'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 22:40:08 2018 +| [7386b4ff39506b7a34b3689cc4b05993ed9b4a4f] | committer: Mark Thompson Merge commit '78fa0b9033c0834c049e2aedf71a8c613fed87ab' * commit '78fa0b9033c0834c049e2aedf71a8c613fed87ab': h264_metadata: Always add the SEI user data to the first access unit Mostly already present from a308872b049e33f69f4b629a06f47e3681906b93, one cosmetic change applied. Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7386b4ff39506b7a34b3689cc4b05993ed9b4a4f --- libavcodec/h264_metadata_bsf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index 20ac299bda..81cdcac5cf 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -288,7 +288,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) } } -// Insert the SEI in access units containing SPSs, and also +// Only insert the SEI in access units containing SPSs, and also // unconditionally in the first access unit we ever see. if (ctx->sei_user_data && (has_sps || !ctx->sei_first_au)) { H264RawSEIPayload payload = { == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] h264_metadata: Always add the SEI user data to the first access unit
ffmpeg | branch: master | Mark Thompson| Sun Feb 11 15:41:07 2018 +| [78fa0b9033c0834c049e2aedf71a8c613fed87ab] | committer: Mark Thompson h264_metadata: Always add the SEI user data to the first access unit This should be added even if the first access unit does not contain parameter sets. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=78fa0b9033c0834c049e2aedf71a8c613fed87ab --- libavcodec/h264_metadata_bsf.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index 356daef3ec..d8d5487c99 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -62,6 +62,7 @@ typedef struct H264MetadataContext { int crop_bottom; const char *sei_user_data; +int sei_first_au; } H264MetadataContext; @@ -287,14 +288,17 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) } } -// Only insert the SEI in access units containing SPSs. -if (has_sps && ctx->sei_user_data) { +// Only insert the SEI in access units containing SPSs, and also +// unconditionally in the first access unit we ever see. +if (ctx->sei_user_data && (has_sps || !ctx->sei_first_au)) { H264RawSEIPayload payload = { .payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED, }; H264RawSEIUserDataUnregistered *udu = _data_unregistered; +ctx->sei_first_au = 1; + for (i = j = 0; j < 32 && ctx->sei_user_data[i]; i++) { int c, v; c = ctx->sei_user_data[i]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Add -vf scale example for making pixels square
ffmpeg | branch: master | Tomas Härdin| Mon Feb 19 18:42:25 2018 +0100| [41317da325921d39834b65d8552a2ebb2f3e802b] | committer: Tomas Härdin Add -vf scale example for making pixels square This is a common use case. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=41317da325921d39834b65d8552a2ebb2f3e802b --- doc/filters.texi | 13 + 1 file changed, 13 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index bd93e0ab84..8a9b78d778 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -13721,6 +13721,19 @@ keeping the same aspect ratio as the input: @example scale=w='min(500\, iw*3/2):h=-1' @end example + +@item +Make pixels square by combining scale and setsar: +@example +scale='trunc(ih*dar):ih',setsar=1/1 +@end example + +@item +Make pixels square by combining scale and setsar, +making sure the resulting resolution is even (required by some codecs): +@example +scale='trunc(ih*dar/2)*2:trunc(ih/2)*2',setsar=1/1 +@end example @end itemize @subsection Commands ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit '69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 22:32:42 2018 +| [fd76e7be70c10861567ebefd0bc6864f223fb017] | committer: Mark Thompson Merge commit '69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb' * commit '69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb': h264_metadata: Use common SEI addition function Minor changes because the following patch is already present. Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fd76e7be70c10861567ebefd0bc6864f223fb017 --- libavcodec/h264_metadata_bsf.c | 72 +++--- 1 file changed, 19 insertions(+), 53 deletions(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index 62a5547fe0..20ac299bda 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -209,7 +209,6 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) AVPacket *in = NULL; CodedBitstreamFragment *au = >access_unit; int err, i, j, has_sps; -char *sei_udu_string = NULL; err = ff_bsf_get_packet(bsf, ); if (err < 0) @@ -292,45 +291,14 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) // Insert the SEI in access units containing SPSs, and also // unconditionally in the first access unit we ever see. if (ctx->sei_user_data && (has_sps || !ctx->sei_first_au)) { -H264RawSEI *sei; -H264RawSEIPayload *payload; -H264RawSEIUserDataUnregistered *udu; -int sei_pos, sei_new; +H264RawSEIPayload payload = { +.payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED, +}; +H264RawSEIUserDataUnregistered *udu = +_data_unregistered; ctx->sei_first_au = 1; -for (i = 0; i < au->nb_units; i++) { -if (au->units[i].type == H264_NAL_SEI || -au->units[i].type == H264_NAL_SLICE || -au->units[i].type == H264_NAL_IDR_SLICE) -break; -} -sei_pos = i; - -if (sei_pos < au->nb_units && -au->units[sei_pos].type == H264_NAL_SEI) { -sei_new = 0; -sei = au->units[sei_pos].content; -} else { -sei_new = 1; -sei = >sei_nal; -memset(sei, 0, sizeof(*sei)); - -sei->nal_unit_header.nal_unit_type = H264_NAL_SEI; - -err = ff_cbs_insert_unit_content(ctx->cbc, au, sei_pos, - H264_NAL_SEI, sei, NULL); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to insert SEI.\n"); -goto fail; -} -} - -payload = >payload[sei->payload_count]; - -payload->payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED; -udu = >payload.user_data_unregistered; - for (i = j = 0; j < 32 && ctx->sei_user_data[i]; i++) { int c, v; c = ctx->sei_user_data[i]; @@ -349,21 +317,25 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) ++j; } if (j == 32 && ctx->sei_user_data[i] == '+') { -sei_udu_string = av_strdup(ctx->sei_user_data + i + 1); -if (!sei_udu_string) { +size_t len = strlen(ctx->sei_user_data + i + 1); + +udu->data_ref = av_buffer_alloc(len + 1); +if (!udu->data_ref) { err = AVERROR(ENOMEM); -goto sei_fail; +goto fail; } -udu->data = sei_udu_string; -udu->data_length = strlen(sei_udu_string); +udu->data= udu->data_ref->data; +udu->data_length = len + 1; +memcpy(udu->data, ctx->sei_user_data + i + 1, len + 1); -payload->payload_size = 16 + udu->data_length; +payload.payload_size = 16 + udu->data_length; -if (!sei_new) { -// This will be freed by the existing internal -// reference in fragment_uninit(). -sei_udu_string = NULL; +err = ff_cbs_h264_add_sei_message(ctx->cbc, au, ); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to add user data SEI " + "message to access unit.\n"); +goto fail; } } else { @@ -371,12 +343,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) av_log(bsf, AV_LOG_ERROR, "Invalid user data: " "must be \"UUID+string\".\n"); err = AVERROR(EINVAL); -sei_fail: -memset(payload, 0, sizeof(*payload)); -goto fail; } - -++sei->payload_count; } err = ff_cbs_write_packet(ctx->cbc, out, au); @@ -392,7 +359,6 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) err = 0; fail: ff_cbs_fragment_uninit(ctx->cbc,
[FFmpeg-cvslog] h264_metadata: Use common SEI addition function
ffmpeg | branch: master | Mark Thompson| Sun Feb 11 15:38:02 2018 +| [69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb] | committer: Mark Thompson h264_metadata: Use common SEI addition function > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb --- libavcodec/h264_metadata_bsf.c | 72 +++--- 1 file changed, 19 insertions(+), 53 deletions(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index 6a1904e315..356daef3ec 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -208,7 +208,6 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) AVPacket *in = NULL; CodedBitstreamFragment *au = >access_unit; int err, i, j, has_sps; -char *sei_udu_string = NULL; err = ff_bsf_get_packet(bsf, ); if (err < 0) @@ -290,42 +289,11 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) // Only insert the SEI in access units containing SPSs. if (has_sps && ctx->sei_user_data) { -H264RawSEI *sei; -H264RawSEIPayload *payload; -H264RawSEIUserDataUnregistered *udu; -int sei_pos, sei_new; - -for (i = 0; i < au->nb_units; i++) { -if (au->units[i].type == H264_NAL_SEI || -au->units[i].type == H264_NAL_SLICE || -au->units[i].type == H264_NAL_IDR_SLICE) -break; -} -sei_pos = i; - -if (sei_pos < au->nb_units && -au->units[sei_pos].type == H264_NAL_SEI) { -sei_new = 0; -sei = au->units[sei_pos].content; -} else { -sei_new = 1; -sei = >sei_nal; -memset(sei, 0, sizeof(*sei)); - -sei->nal_unit_header.nal_unit_type = H264_NAL_SEI; - -err = ff_cbs_insert_unit_content(ctx->cbc, au, sei_pos, - H264_NAL_SEI, sei, NULL); -if (err < 0) { -av_log(bsf, AV_LOG_ERROR, "Failed to insert SEI.\n"); -goto fail; -} -} - -payload = >payload[sei->payload_count]; - -payload->payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED; -udu = >payload.user_data_unregistered; +H264RawSEIPayload payload = { +.payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED, +}; +H264RawSEIUserDataUnregistered *udu = +_data_unregistered; for (i = j = 0; j < 32 && ctx->sei_user_data[i]; i++) { int c, v; @@ -345,21 +313,25 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) ++j; } if (j == 32 && ctx->sei_user_data[i] == '+') { -sei_udu_string = av_strdup(ctx->sei_user_data + i + 1); -if (!sei_udu_string) { +size_t len = strlen(ctx->sei_user_data + i + 1); + +udu->data_ref = av_buffer_alloc(len + 1); +if (!udu->data_ref) { err = AVERROR(ENOMEM); -goto sei_fail; +goto fail; } -udu->data = sei_udu_string; -udu->data_length = strlen(sei_udu_string); +udu->data= udu->data_ref->data; +udu->data_length = len + 1; +memcpy(udu->data, ctx->sei_user_data + i + 1, len + 1); -payload->payload_size = 16 + udu->data_length; +payload.payload_size = 16 + udu->data_length; -if (!sei_new) { -// This will be freed by the existing internal -// reference in fragment_uninit(). -sei_udu_string = NULL; +err = ff_cbs_h264_add_sei_message(ctx->cbc, au, ); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to add user data SEI " + "message to access unit.\n"); +goto fail; } } else { @@ -367,12 +339,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) av_log(bsf, AV_LOG_ERROR, "Invalid user data: " "must be \"UUID+string\".\n"); err = AVERROR(EINVAL); -sei_fail: -memset(payload, 0, sizeof(*payload)); -goto fail; } - -++sei->payload_count; } err = ff_cbs_write_packet(ctx->cbc, out, au); @@ -388,7 +355,6 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) err = 0; fail: ff_cbs_fragment_uninit(ctx->cbc, au); -av_freep(_udu_string); av_packet_free(); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit 'a2ca8ed903b435446031a8a0792ca535e6ee2913'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 22:27:07 2018 +| [77eba7bd99355fc37a2bfc9d0224218f4022762c] | committer: Mark Thompson Merge commit 'a2ca8ed903b435446031a8a0792ca535e6ee2913' * commit 'a2ca8ed903b435446031a8a0792ca535e6ee2913': cbs_h264: Add utility functions to insert/delete SEI messages Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=77eba7bd99355fc37a2bfc9d0224218f4022762c --- libavcodec/cbs_h264.h | 19 ++ libavcodec/cbs_h2645.c | 95 ++ 2 files changed, 114 insertions(+) diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index 9c80e7215e..ae39fc7040 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -22,6 +22,7 @@ #include #include +#include "cbs.h" #include "cbs_h2645.h" #include "h264.h" @@ -428,4 +429,22 @@ typedef struct CodedBitstreamH264Context { } CodedBitstreamH264Context; +/** + * Add an SEI message to an access unit. + */ +int ff_cbs_h264_add_sei_message(CodedBitstreamContext *ctx, +CodedBitstreamFragment *access_unit, +const H264RawSEIPayload *payload); + +/** + * Delete an SEI message from an access unit. + * + * Deletes from nal_unit, which must be an SEI NAL unit. If this is the + * last message in nal_unit, also deletes it from access_unit. + */ +int ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, + CodedBitstreamFragment *access_unit, + CodedBitstreamUnit *nal_unit, + int position); + #endif /* AVCODEC_CBS_H264_H */ diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index c7949f1047..8c3705b6e1 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -1393,3 +1393,98 @@ const CodedBitstreamType ff_cbs_type_h265 = { .close = _h265_close, }; + +int ff_cbs_h264_add_sei_message(CodedBitstreamContext *ctx, +CodedBitstreamFragment *au, +const H264RawSEIPayload *payload) +{ +H264RawSEI *sei; +CodedBitstreamUnit *nal = NULL; +int err, i; + +// Find an existing SEI NAL unit to add to. +for (i = 0; i < au->nb_units; i++) { +if (au->units[i].type == H264_NAL_SEI) { +nal = >units[i]; +break; +} +} +if (nal) { +sei = nal->content; + +} else { +// Need to make a new SEI NAL unit. Insert it before the first +// slice data NAL unit; if no slice data, add at the end. +AVBufferRef *sei_ref; + +sei = av_mallocz(sizeof(*sei)); +if (!sei) +return AVERROR(ENOMEM); + +sei->nal_unit_header.nal_unit_type = H264_NAL_SEI; +sei->nal_unit_header.nal_ref_idc = 0; + +sei_ref = av_buffer_create((uint8_t*)sei, sizeof(*sei), + _h264_free_sei, ctx, 0); +if (!sei_ref) { +av_freep(); +return AVERROR(ENOMEM); +} + +for (i = 0; i < au->nb_units; i++) { +if (au->units[i].type == H264_NAL_SLICE || +au->units[i].type == H264_NAL_IDR_SLICE) +break; +} + +err = ff_cbs_insert_unit_content(ctx, au, i, H264_NAL_SEI, + sei, sei_ref); +av_buffer_unref(_ref); +if (err < 0) +return err; +} + +if (sei->payload_count >= H264_MAX_SEI_PAYLOADS) { +av_log(ctx->log_ctx, AV_LOG_ERROR, "Too many payloads in " + "SEI NAL unit.\n"); +return AVERROR(EINVAL); +} + +memcpy(>payload[sei->payload_count], payload, sizeof(*payload)); +++sei->payload_count; + +return 0; +} + +int ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, + CodedBitstreamFragment *au, + CodedBitstreamUnit *nal, + int position) +{ +H264RawSEI *sei = nal->content; + +av_assert0(nal->type == H264_NAL_SEI); +av_assert0(position >= 0 && position < sei->payload_count); + +if (position == 0 && sei->payload_count == 1) { +// Deleting NAL unit entirely. +int i; + +for (i = 0; i < au->nb_units; i++) { +if (>units[i] == nal) +break; +} +av_assert0(i < au->nb_units && "NAL unit not in access unit."); + +return ff_cbs_delete_unit(ctx, au, i); +} else { +cbs_h264_free_sei_payload(>payload[position]); + +--sei->payload_count; +memmove(sei->payload + position, +sei->payload + position + 1, +(sei->payload_count - position) * sizeof(*sei->payload)); + +return 0; +} +}
[FFmpeg-cvslog] cbs_h264: Add utility functions to insert/delete SEI messages
ffmpeg | branch: master | Mark Thompson| Sun Feb 11 15:37:34 2018 +| [a2ca8ed903b435446031a8a0792ca535e6ee2913] | committer: Mark Thompson cbs_h264: Add utility functions to insert/delete SEI messages > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a2ca8ed903b435446031a8a0792ca535e6ee2913 --- libavcodec/cbs_h264.h | 19 ++ libavcodec/cbs_h2645.c | 95 ++ 2 files changed, 114 insertions(+) diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index 14ea69ae28..8c17680bb5 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -22,6 +22,7 @@ #include #include +#include "cbs.h" #include "cbs_h2645.h" #include "h264.h" @@ -428,4 +429,22 @@ typedef struct CodedBitstreamH264Context { } CodedBitstreamH264Context; +/** + * Add an SEI message to an access unit. + */ +int ff_cbs_h264_add_sei_message(CodedBitstreamContext *ctx, +CodedBitstreamFragment *access_unit, +const H264RawSEIPayload *payload); + +/** + * Delete an SEI message from an access unit. + * + * Deletes from nal_unit, which must be an SEI NAL unit. If this is the + * last message in nal_unit, also deletes it from access_unit. + */ +int ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, + CodedBitstreamFragment *access_unit, + CodedBitstreamUnit *nal_unit, + int position); + #endif /* AVCODEC_CBS_H264_H */ diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 5b23d6104b..25bd33f162 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -1393,3 +1393,98 @@ const CodedBitstreamType ff_cbs_type_h265 = { .close = _h265_close, }; + +int ff_cbs_h264_add_sei_message(CodedBitstreamContext *ctx, +CodedBitstreamFragment *au, +const H264RawSEIPayload *payload) +{ +H264RawSEI *sei; +CodedBitstreamUnit *nal = NULL; +int err, i; + +// Find an existing SEI NAL unit to add to. +for (i = 0; i < au->nb_units; i++) { +if (au->units[i].type == H264_NAL_SEI) { +nal = >units[i]; +break; +} +} +if (nal) { +sei = nal->content; + +} else { +// Need to make a new SEI NAL unit. Insert it before the first +// slice data NAL unit; if no slice data, add at the end. +AVBufferRef *sei_ref; + +sei = av_mallocz(sizeof(*sei)); +if (!sei) +return AVERROR(ENOMEM); + +sei->nal_unit_header.nal_unit_type = H264_NAL_SEI; +sei->nal_unit_header.nal_ref_idc = 0; + +sei_ref = av_buffer_create((uint8_t*)sei, sizeof(*sei), + _h264_free_sei, ctx, 0); +if (!sei_ref) { +av_freep(); +return AVERROR(ENOMEM); +} + +for (i = 0; i < au->nb_units; i++) { +if (au->units[i].type == H264_NAL_SLICE || +au->units[i].type == H264_NAL_IDR_SLICE) +break; +} + +err = ff_cbs_insert_unit_content(ctx, au, i, H264_NAL_SEI, + sei, sei_ref); +av_buffer_unref(_ref); +if (err < 0) +return err; +} + +if (sei->payload_count >= H264_MAX_SEI_PAYLOADS) { +av_log(ctx->log_ctx, AV_LOG_ERROR, "Too many payloads in " + "SEI NAL unit.\n"); +return AVERROR(EINVAL); +} + +memcpy(>payload[sei->payload_count], payload, sizeof(*payload)); +++sei->payload_count; + +return 0; +} + +int ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, + CodedBitstreamFragment *au, + CodedBitstreamUnit *nal, + int position) +{ +H264RawSEI *sei = nal->content; + +av_assert0(nal->type == H264_NAL_SEI); +av_assert0(position >= 0 && position < sei->payload_count); + +if (position == 0 && sei->payload_count == 1) { +// Deleting NAL unit entirely. +int i; + +for (i = 0; i < au->nb_units; i++) { +if (>units[i] == nal) +break; +} +av_assert0(i < au->nb_units && "NAL unit not in access unit."); + +return ff_cbs_delete_unit(ctx, au, i); +} else { +cbs_h264_free_sei_payload(>payload[position]); + +--sei->payload_count; +memmove(sei->payload + position, +sei->payload + position + 1, +(sei->payload_count - position) * sizeof(*sei->payload)); + +return 0; +} +} ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit 'ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 22:22:54 2018 +| [0cc8e34a94c84132cf5b0f6472c5f61c8a66cee1] | committer: Mark Thompson Merge commit 'ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2' * commit 'ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2': cbs: Refcount all the things! Some changes for bitstream API. Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0cc8e34a94c84132cf5b0f6472c5f61c8a66cee1 --- libavcodec/cbs.c | 165 +--- libavcodec/cbs.h | 51 - libavcodec/cbs_h264.h | 4 + libavcodec/cbs_h2645.c | 340 +++-- libavcodec/cbs_h265.h | 2 + libavcodec/cbs_internal.h | 3 - libavcodec/cbs_mpeg2.c | 91 - libavcodec/cbs_mpeg2.h | 5 + libavcodec/cbs_mpeg2_syntax_template.c | 5 +- libavcodec/h264_metadata_bsf.c | 6 +- libavcodec/h265_metadata_bsf.c | 2 +- libavcodec/mpeg2_metadata_bsf.c| 3 +- libavcodec/vaapi_encode_h264.c | 2 +- libavcodec/vaapi_encode_h265.c | 2 +- libavcodec/vaapi_encode_mpeg2.c| 2 +- 15 files changed, 404 insertions(+), 279 deletions(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index 1dd82d2cdd..dcca6430c4 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -21,6 +21,7 @@ #include "config.h" #include "libavutil/avassert.h" +#include "libavutil/buffer.h" #include "libavutil/common.h" #include "cbs.h" @@ -95,11 +96,12 @@ void ff_cbs_close(CodedBitstreamContext **ctx_ptr) static void cbs_unit_uninit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit) { -if (ctx->codec->free_unit && unit->content && !unit->content_external) -ctx->codec->free_unit(unit); +av_buffer_unref(>content_ref); +unit->content = NULL; -av_freep(>data); -unit->data_size = 0; +av_buffer_unref(>data_ref); +unit->data = NULL; +unit->data_size= 0; unit->data_bit_padding = 0; } @@ -113,7 +115,8 @@ void ff_cbs_fragment_uninit(CodedBitstreamContext *ctx, av_freep(>units); frag->nb_units = 0; -av_freep(>data); +av_buffer_unref(>data_ref); +frag->data = NULL; frag->data_size= 0; frag->data_bit_padding = 0; } @@ -133,6 +136,9 @@ static int cbs_read_fragment_content(CodedBitstreamContext *ctx, continue; } +av_buffer_unref(>units[i].content_ref); +frag->units[i].content = NULL; + err = ctx->codec->read_unit(ctx, >units[i]); if (err == AVERROR(ENOSYS)) { av_log(ctx->log_ctx, AV_LOG_VERBOSE, @@ -169,6 +175,27 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx, return cbs_read_fragment_content(ctx, frag); } +static int cbs_fill_fragment_data(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const uint8_t *data, size_t size) +{ +av_assert0(!frag->data && !frag->data_ref); + +frag->data_ref = +av_buffer_alloc(size + AV_INPUT_BUFFER_PADDING_SIZE); +if (!frag->data_ref) +return AVERROR(ENOMEM); + +frag->data = frag->data_ref->data; +frag->data_size = size; + +memcpy(frag->data, data, size); +memset(frag->data + size, 0, + AV_INPUT_BUFFER_PADDING_SIZE); + +return 0; +} + int ff_cbs_read_packet(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVPacket *pkt) @@ -177,16 +204,24 @@ int ff_cbs_read_packet(CodedBitstreamContext *ctx, memset(frag, 0, sizeof(*frag)); -frag->data = pkt->data; -frag->data_size = pkt->size; +if (pkt->buf) { +frag->data_ref = av_buffer_ref(pkt->buf); +if (!frag->data_ref) +return AVERROR(ENOMEM); + +frag->data = pkt->data; +frag->data_size = pkt->size; + +} else { +err = cbs_fill_fragment_data(ctx, frag, pkt->data, pkt->size); +if (err < 0) +return err; +} err = ctx->codec->split_fragment(ctx, frag, 0); if (err < 0) return err; -frag->data = NULL; -frag->data_size = 0; - return cbs_read_fragment_content(ctx, frag); } @@ -198,17 +233,14 @@ int ff_cbs_read(CodedBitstreamContext *ctx, memset(frag, 0, sizeof(*frag)); -// (We won't write to this during split.) -frag->data = (uint8_t*)data; -frag->data_size = size; +err = cbs_fill_fragment_data(ctx, frag, data, size); +if (err < 0) +return err; err = ctx->codec->split_fragment(ctx, frag, 0); if (err < 0) return err; -frag->data = NULL; -frag->data_size = 0; - return cbs_read_fragment_content(ctx, frag); } @@ -219,17
[FFmpeg-cvslog] cbs: Refcount all the things!
ffmpeg | branch: master | Mark Thompson| Sun Feb 11 00:51:33 2018 +| [ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2] | committer: Mark Thompson cbs: Refcount all the things! This makes it easier for users of the CBS API to get alloc/free right - all subelements use the buffer API so that it's clear how to free them. It also allows eliding some redundant copies: the packet -> fragment copy disappears after this change if the input packet is refcounted, and more codec-specific cases are now possible (but not included in this patch). > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2 --- libavcodec/cbs.c | 165 +--- libavcodec/cbs.h | 51 - libavcodec/cbs_h264.h | 4 + libavcodec/cbs_h2645.c | 340 +++-- libavcodec/cbs_h265.h | 2 + libavcodec/cbs_internal.h | 3 - libavcodec/cbs_mpeg2.c | 91 - libavcodec/cbs_mpeg2.h | 5 + libavcodec/cbs_mpeg2_syntax_template.c | 5 +- libavcodec/h264_metadata_bsf.c | 6 +- libavcodec/h265_metadata_bsf.c | 2 +- libavcodec/mpeg2_metadata_bsf.c| 3 +- libavcodec/vaapi_encode_h264.c | 2 +- libavcodec/vaapi_encode_h265.c | 2 +- libavcodec/vaapi_encode_mpeg2.c| 2 +- 15 files changed, 404 insertions(+), 279 deletions(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index a8d252f6c2..04ad2dfc41 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -21,6 +21,7 @@ #include "config.h" #include "libavutil/avassert.h" +#include "libavutil/buffer.h" #include "libavutil/common.h" #include "cbs.h" @@ -95,11 +96,12 @@ void ff_cbs_close(CodedBitstreamContext **ctx_ptr) static void cbs_unit_uninit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit) { -if (ctx->codec->free_unit && unit->content && !unit->content_external) -ctx->codec->free_unit(unit); +av_buffer_unref(>content_ref); +unit->content = NULL; -av_freep(>data); -unit->data_size = 0; +av_buffer_unref(>data_ref); +unit->data = NULL; +unit->data_size= 0; unit->data_bit_padding = 0; } @@ -113,7 +115,8 @@ void ff_cbs_fragment_uninit(CodedBitstreamContext *ctx, av_freep(>units); frag->nb_units = 0; -av_freep(>data); +av_buffer_unref(>data_ref); +frag->data = NULL; frag->data_size= 0; frag->data_bit_padding = 0; } @@ -133,6 +136,9 @@ static int cbs_read_fragment_content(CodedBitstreamContext *ctx, continue; } +av_buffer_unref(>units[i].content_ref); +frag->units[i].content = NULL; + err = ctx->codec->read_unit(ctx, >units[i]); if (err == AVERROR(ENOSYS)) { av_log(ctx->log_ctx, AV_LOG_VERBOSE, @@ -169,6 +175,27 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx, return cbs_read_fragment_content(ctx, frag); } +static int cbs_fill_fragment_data(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const uint8_t *data, size_t size) +{ +av_assert0(!frag->data && !frag->data_ref); + +frag->data_ref = +av_buffer_alloc(size + AV_INPUT_BUFFER_PADDING_SIZE); +if (!frag->data_ref) +return AVERROR(ENOMEM); + +frag->data = frag->data_ref->data; +frag->data_size = size; + +memcpy(frag->data, data, size); +memset(frag->data + size, 0, + AV_INPUT_BUFFER_PADDING_SIZE); + +return 0; +} + int ff_cbs_read_packet(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVPacket *pkt) @@ -177,16 +204,24 @@ int ff_cbs_read_packet(CodedBitstreamContext *ctx, memset(frag, 0, sizeof(*frag)); -frag->data = pkt->data; -frag->data_size = pkt->size; +if (pkt->buf) { +frag->data_ref = av_buffer_ref(pkt->buf); +if (!frag->data_ref) +return AVERROR(ENOMEM); + +frag->data = pkt->data; +frag->data_size = pkt->size; + +} else { +err = cbs_fill_fragment_data(ctx, frag, pkt->data, pkt->size); +if (err < 0) +return err; +} err = ctx->codec->split_fragment(ctx, frag, 0); if (err < 0) return err; -frag->data = NULL; -frag->data_size = 0; - return cbs_read_fragment_content(ctx, frag); } @@ -198,17 +233,14 @@ int ff_cbs_read(CodedBitstreamContext *ctx, memset(frag, 0, sizeof(*frag)); -// (We won't write to this during split.) -frag->data = (uint8_t*)data; -frag->data_size = size; +err = cbs_fill_fragment_data(ctx, frag, data, size); +if (err < 0) +return err; err = ctx->codec->split_fragment(ctx,
[FFmpeg-cvslog] Merge commit '13ca5d34ba5c473211daaae0a101123bcaada3e6'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 22:05:15 2018 +| [b656fa710a34ec7c3b192c38344a2c470ff2eaf5] | committer: Mark Thompson Merge commit '13ca5d34ba5c473211daaae0a101123bcaada3e6' * commit '13ca5d34ba5c473211daaae0a101123bcaada3e6': cbs_h264: Add hack for pic_timing with no active SPS Partially fixes #6896 - the sample stream from that ticket now works, but more obscure cases can still fail. Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b656fa710a34ec7c3b192c38344a2c470ff2eaf5 --- libavcodec/cbs_h264_syntax_template.c | 16 1 file changed, 16 insertions(+) diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 2d60273506..267f35ccb7 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -561,6 +561,22 @@ static int FUNC(sei_pic_timing)(CodedBitstreamContext *ctx, RWContext *rw, sps = h264->active_sps; if (!sps) { +// If there is exactly one possible SPS but it is not yet active +// then just assume that it should be the active one. +int i, k = -1; +for (i = 0; i < H264_MAX_SPS_COUNT; i++) { +if (h264->sps[i]) { +if (k >= 0) { +k = -1; +break; +} +k = i; +} +} +if (k >= 0) +sps = h264->sps[k]; +} +if (!sps) { av_log(ctx->log_ctx, AV_LOG_ERROR, "No active SPS for pic_timing.\n"); return AVERROR_INVALIDDATA; == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] cbs_h264: Add hack for pic_timing with no active SPS
ffmpeg | branch: master | Mark Thompson| Mon Dec 11 00:22:42 2017 +| [13ca5d34ba5c473211daaae0a101123bcaada3e6] | committer: Mark Thompson cbs_h264: Add hack for pic_timing with no active SPS If there is exactly one possible SPS but it is not yet active then just assume that it should be the active one. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=13ca5d34ba5c473211daaae0a101123bcaada3e6 --- libavcodec/cbs_h264_syntax_template.c | 16 1 file changed, 16 insertions(+) diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 0fe18441c0..c2fd546822 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -561,6 +561,22 @@ static int FUNC(sei_pic_timing)(CodedBitstreamContext *ctx, RWContext *rw, sps = h264->active_sps; if (!sps) { +// If there is exactly one possible SPS but it is not yet active +// then just assume that it should be the active one. +int i, k = -1; +for (i = 0; i < H264_MAX_SPS_COUNT; i++) { +if (h264->sps[i]) { +if (k >= 0) { +k = -1; +break; +} +k = i; +} +} +if (k >= 0) +sps = h264->sps[k]; +} +if (!sps) { av_log(ctx->log_ctx, AV_LOG_ERROR, "No active SPS for pic_timing.\n"); return AVERROR_INVALIDDATA; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit '0e4c166cdd6446522a085dd9731967d09ac71f72'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 22:03:15 2018 +| [af3727e2399df83b57892c22011e4dd748516897] | committer: Mark Thompson Merge commit '0e4c166cdd6446522a085dd9731967d09ac71f72' * commit '0e4c166cdd6446522a085dd9731967d09ac71f72': cbs_h2645: Remove active ps references when it is replaced Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=af3727e2399df83b57892c22011e4dd748516897 --- libavcodec/cbs_h2645.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 2f96e4f20e..9864d67acb 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -674,6 +674,8 @@ static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \ " id : %d.\n", id); \ return AVERROR_INVALIDDATA; \ } \ +if (priv->ps_var[id] == priv->active_ ## ps_var) \ +priv->active_ ## ps_var = NULL ; \ av_freep(>ps_var[id]); \ priv->ps_var[id] = av_malloc(sizeof(*ps_var)); \ if (!priv->ps_var[id]) \ == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] cbs_h2645: Remove active ps references when it is replaced
ffmpeg | branch: master | Mark Thompson| Mon Dec 11 00:38:57 2017 +| [0e4c166cdd6446522a085dd9731967d09ac71f72] | committer: Mark Thompson cbs_h2645: Remove active ps references when it is replaced > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0e4c166cdd6446522a085dd9731967d09ac71f72 --- libavcodec/cbs_h2645.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index e3b5bf618a..9d05d59156 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -674,6 +674,8 @@ static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \ " id : %d.\n", id); \ return AVERROR_INVALIDDATA; \ } \ +if (priv->ps_var[id] == priv->active_ ## ps_var) \ +priv->active_ ## ps_var = NULL ; \ av_freep(>ps_var[id]); \ priv->ps_var[id] = av_malloc(sizeof(*ps_var)); \ if (!priv->ps_var[id]) \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit 'a3daecd6375279d9fdb863ac9db3545a33e97651'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 21:54:42 2018 +| [1325ac4c93f27dd56ebce37d8045d7ceb64dc645] | committer: Mark Thompson Merge commit 'a3daecd6375279d9fdb863ac9db3545a33e97651' * commit 'a3daecd6375279d9fdb863ac9db3545a33e97651': cbs: Demote the "decomposition unimplemented" warning Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1325ac4c93f27dd56ebce37d8045d7ceb64dc645 --- libavcodec/cbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index 97ab520c22..1dd82d2cdd 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -135,7 +135,7 @@ static int cbs_read_fragment_content(CodedBitstreamContext *ctx, err = ctx->codec->read_unit(ctx, >units[i]); if (err == AVERROR(ENOSYS)) { -av_log(ctx->log_ctx, AV_LOG_WARNING, +av_log(ctx->log_ctx, AV_LOG_VERBOSE, "Decomposition unimplemented for unit %d " "(type %"PRIu32").\n", i, frag->units[i].type); } else if (err < 0) { == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] cbs: Demote the "decomposition unimplemented" warning
ffmpeg | branch: master | Mark Thompson| Mon Dec 11 00:28:40 2017 +| [a3daecd6375279d9fdb863ac9db3545a33e97651] | committer: Mark Thompson cbs: Demote the "decomposition unimplemented" warning This is harmless and should not be a warning - unknown units are passed through to the write functions unchanged, and no other code will interact with them. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a3daecd6375279d9fdb863ac9db3545a33e97651 --- libavcodec/cbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index e5819afce3..a8d252f6c2 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -135,7 +135,7 @@ static int cbs_read_fragment_content(CodedBitstreamContext *ctx, err = ctx->codec->read_unit(ctx, >units[i]); if (err == AVERROR(ENOSYS)) { -av_log(ctx->log_ctx, AV_LOG_WARNING, +av_log(ctx->log_ctx, AV_LOG_VERBOSE, "Decomposition unimplemented for unit %d " "(type %"PRIu32").\n", i, frag->units[i].type); } else if (err < 0) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] vaapi_h265: Mark unused entries in RefPicList[01] as explicitly invalid
ffmpeg | branch: master | Mark Thompson| Sun Dec 17 19:50:29 2017 +| [67eb2b16daa77f6ba3e04a28ca18e53193723b7f] | committer: Mark Thompson vaapi_h265: Mark unused entries in RefPicList[01] as explicitly invalid The iHD driver looks at entries beyond num_ref_idx_l[01]_active_minus1 for unknown reasons. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=67eb2b16daa77f6ba3e04a28ca18e53193723b7f --- libavcodec/vaapi_encode_h265.c | 21 +++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 38c9e25212..52ac4a6875 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -767,8 +767,6 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, .num_ref_idx_l0_active_minus1 = sh->num_ref_idx_l0_active_minus1, .num_ref_idx_l1_active_minus1 = sh->num_ref_idx_l1_active_minus1, -.ref_pic_list0[0] = vpic->reference_frames[0], -.ref_pic_list1[0] = vpic->reference_frames[1], .luma_log2_weight_denom = sh->luma_log2_weight_denom, .delta_chroma_log2_weight_denom = sh->delta_chroma_log2_weight_denom, @@ -802,6 +800,25 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, }, }; +for (i = 0; i < FF_ARRAY_ELEMS(vslice->ref_pic_list0); i++) { +vslice->ref_pic_list0[i].picture_id = VA_INVALID_ID; +vslice->ref_pic_list0[i].flags = VA_PICTURE_HEVC_INVALID; +vslice->ref_pic_list1[i].picture_id = VA_INVALID_ID; +vslice->ref_pic_list1[i].flags = VA_PICTURE_HEVC_INVALID; +} + +av_assert0(pic->nb_refs <= 2); +if (pic->nb_refs >= 1) { +// Backward reference for P- or B-frame. +av_assert0(pic->type == PICTURE_TYPE_P || + pic->type == PICTURE_TYPE_B); +vslice->ref_pic_list0[0] = vpic->reference_frames[0]; +} +if (pic->nb_refs >= 2) { +// Forward reference for B-frame. +av_assert0(pic->type == PICTURE_TYPE_B); +vslice->ref_pic_list1[0] = vpic->reference_frames[1]; +} return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit '67eb2b16daa77f6ba3e04a28ca18e53193723b7f'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 21:52:20 2018 +| [f082dcab7cdf94b6268917a6dc472d594d7538f0] | committer: Mark Thompson Merge commit '67eb2b16daa77f6ba3e04a28ca18e53193723b7f' * commit '67eb2b16daa77f6ba3e04a28ca18e53193723b7f': vaapi_h265: Mark unused entries in RefPicList[01] as explicitly invalid Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f082dcab7cdf94b6268917a6dc472d594d7538f0 --- libavcodec/vaapi_encode_h265.c | 21 +++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index f3b4f6c7e2..5841ff7fbc 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -767,8 +767,6 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, .num_ref_idx_l0_active_minus1 = sh->num_ref_idx_l0_active_minus1, .num_ref_idx_l1_active_minus1 = sh->num_ref_idx_l1_active_minus1, -.ref_pic_list0[0] = vpic->reference_frames[0], -.ref_pic_list1[0] = vpic->reference_frames[1], .luma_log2_weight_denom = sh->luma_log2_weight_denom, .delta_chroma_log2_weight_denom = sh->delta_chroma_log2_weight_denom, @@ -802,6 +800,25 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, }, }; +for (i = 0; i < FF_ARRAY_ELEMS(vslice->ref_pic_list0); i++) { +vslice->ref_pic_list0[i].picture_id = VA_INVALID_ID; +vslice->ref_pic_list0[i].flags = VA_PICTURE_HEVC_INVALID; +vslice->ref_pic_list1[i].picture_id = VA_INVALID_ID; +vslice->ref_pic_list1[i].flags = VA_PICTURE_HEVC_INVALID; +} + +av_assert0(pic->nb_refs <= 2); +if (pic->nb_refs >= 1) { +// Backward reference for P- or B-frame. +av_assert0(pic->type == PICTURE_TYPE_P || + pic->type == PICTURE_TYPE_B); +vslice->ref_pic_list0[0] = vpic->reference_frames[0]; +} +if (pic->nb_refs >= 2) { +// Forward reference for B-frame. +av_assert0(pic->type == PICTURE_TYPE_B); +vslice->ref_pic_list1[0] = vpic->reference_frames[1]; +} return 0; } == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit '216c44dfc17252ec0681dcb0bbeeb45a9d14eca7'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 21:51:28 2018 +| [9e3e9a37289c1a9cdfdb6c7389a3ece3cfa4749c] | committer: Mark Thompson Merge commit '216c44dfc17252ec0681dcb0bbeeb45a9d14eca7' * commit '216c44dfc17252ec0681dcb0bbeeb45a9d14eca7': vaapi_encode: Destroy output buffer pool before VA context Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e3e9a37289c1a9cdfdb6c7389a3ece3cfa4749c --- libavcodec/vaapi_encode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index f552071802..f5785ce4c5 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1564,6 +1564,8 @@ av_cold int ff_vaapi_encode_close(AVCodecContext *avctx) vaapi_encode_free(avctx, pic); } +av_buffer_pool_uninit(>output_buffer_pool); + if (ctx->va_context != VA_INVALID_ID) { vaDestroyContext(ctx->hwctx->display, ctx->va_context); ctx->va_context = VA_INVALID_ID; @@ -1574,8 +1576,6 @@ av_cold int ff_vaapi_encode_close(AVCodecContext *avctx) ctx->va_config = VA_INVALID_ID; } -av_buffer_pool_uninit(>output_buffer_pool); - av_freep(>codec_sequence_params); av_freep(>codec_picture_params); == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] vaapi_encode: Destroy output buffer pool before VA context
ffmpeg | branch: master | Mark Thompson| Sun Dec 17 19:48:35 2017 +| [216c44dfc17252ec0681dcb0bbeeb45a9d14eca7] | committer: Mark Thompson vaapi_encode: Destroy output buffer pool before VA context The buffers are created associated with the context, so they should be destroyed before the context is. This is enforced by the iHD driver. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=216c44dfc17252ec0681dcb0bbeeb45a9d14eca7 --- libavcodec/vaapi_encode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index c6113b1de5..398b8e11f2 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1556,6 +1556,8 @@ av_cold int ff_vaapi_encode_close(AVCodecContext *avctx) vaapi_encode_free(avctx, pic); } +av_buffer_pool_uninit(>output_buffer_pool); + if (ctx->va_context != VA_INVALID_ID) { vaDestroyContext(ctx->hwctx->display, ctx->va_context); ctx->va_context = VA_INVALID_ID; @@ -1566,8 +1568,6 @@ av_cold int ff_vaapi_encode_close(AVCodecContext *avctx) ctx->va_config = VA_INVALID_ID; } -av_buffer_pool_uninit(>output_buffer_pool); - av_freep(>codec_sequence_params); av_freep(>codec_picture_params); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit 'c8e135ea9225137050a6315fd9ba9c0f242c90b6'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 21:46:09 2018 +| [fe1fb48e2bd1e5bddcde8b898084851cc8f6939c] | committer: Mark Thompson Merge commit 'c8e135ea9225137050a6315fd9ba9c0f242c90b6' * commit 'c8e135ea9225137050a6315fd9ba9c0f242c90b6': vaapi_encode: Allocate slice structures and parameter buffers dynamically Already present as e4a6eb70f471eda36592078e8fa1bad87fc9df73, one minor fix for libav merged. Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fe1fb48e2bd1e5bddcde8b898084851cc8f6939c --- libavcodec/vaapi_encode.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 550ea47991..f552071802 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -321,10 +321,12 @@ static int vaapi_encode_issue(AVCodecContext *avctx, } } -pic->slices = av_mallocz_array(pic->nb_slices, sizeof(*pic->slices)); -if (!pic->slices) { -err = AVERROR(ENOMEM); -goto fail; +if (pic->nb_slices > 0) { +pic->slices = av_mallocz_array(pic->nb_slices, sizeof(*pic->slices)); +if (!pic->slices) { +err = AVERROR(ENOMEM); +goto fail; +} } for (i = 0; i < pic->nb_slices; i++) { slice = >slices[i]; == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] vaapi_encode: Allocate slice structures and parameter buffers dynamically
ffmpeg | branch: master | Jun Zhao| Thu Aug 24 09:13:01 2017 +0800| [c8e135ea9225137050a6315fd9ba9c0f242c90b6] | committer: Mark Thompson vaapi_encode: Allocate slice structures and parameter buffers dynamically This removes the arbitrary limit on the allowed number of slices and parameter buffers. From ffmpeg commit e4a6eb70f471eda36592078e8fa1bad87fc9df73. Signed-off-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c8e135ea9225137050a6315fd9ba9c0f242c90b6 --- libavcodec/vaapi_encode.c | 40 ++-- libavcodec/vaapi_encode.h | 6 ++ 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 47795ba735..c6113b1de5 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -36,13 +36,17 @@ static int vaapi_encode_make_packed_header(AVCodecContext *avctx, VAAPIEncodeContext *ctx = avctx->priv_data; VAStatus vas; VABufferID param_buffer, data_buffer; +VABufferID *tmp; VAEncPackedHeaderParameterBuffer params = { .type = type, .bit_length = bit_len, .has_emulation_bytes = 1, }; -av_assert0(pic->nb_param_buffers + 2 <= MAX_PARAM_BUFFERS); +tmp = av_realloc_array(pic->param_buffers, sizeof(*tmp), pic->nb_param_buffers + 2); +if (!tmp) +return AVERROR(ENOMEM); +pic->param_buffers = tmp; vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context, VAEncPackedHeaderParameterBufferType, @@ -77,9 +81,13 @@ static int vaapi_encode_make_param_buffer(AVCodecContext *avctx, { VAAPIEncodeContext *ctx = avctx->priv_data; VAStatus vas; +VABufferID *tmp; VABufferID buffer; -av_assert0(pic->nb_param_buffers + 1 <= MAX_PARAM_BUFFERS); +tmp = av_realloc_array(pic->param_buffers, sizeof(*tmp), pic->nb_param_buffers + 1); +if (!tmp) +return AVERROR(ENOMEM); +pic->param_buffers = tmp; vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context, type, len, 1, data, ); @@ -313,15 +321,16 @@ static int vaapi_encode_issue(AVCodecContext *avctx, } } -av_assert0(pic->nb_slices <= MAX_PICTURE_SLICES); -for (i = 0; i < pic->nb_slices; i++) { -slice = av_mallocz(sizeof(*slice)); -if (!slice) { +if (pic->nb_slices > 0) { +pic->slices = av_mallocz_array(pic->nb_slices, sizeof(*pic->slices)); +if (!pic->slices) { err = AVERROR(ENOMEM); goto fail; } +} +for (i = 0; i < pic->nb_slices; i++) { +slice = >slices[i]; slice->index = i; -pic->slices[i] = slice; if (ctx->codec->slice_params_size > 0) { slice->codec_slice_params = av_mallocz(ctx->codec->slice_params_size); @@ -425,8 +434,16 @@ fail_with_picture: fail: for(i = 0; i < pic->nb_param_buffers; i++) vaDestroyBuffer(ctx->hwctx->display, pic->param_buffers[i]); +for (i = 0; i < pic->nb_slices; i++) { +if (pic->slices) { +av_freep(>slices[i].priv_data); +av_freep(>slices[i].codec_slice_params); +} +} fail_at_end: av_freep(>codec_picture_params); +av_freep(>param_buffers); +av_freep(>slices); av_frame_free(>recon_image); av_buffer_unref(>output_buffer_ref); pic->output_buffer = VA_INVALID_ID; @@ -535,15 +552,18 @@ static int vaapi_encode_free(AVCodecContext *avctx, vaapi_encode_discard(avctx, pic); for (i = 0; i < pic->nb_slices; i++) { -av_freep(>slices[i]->priv_data); -av_freep(>slices[i]->codec_slice_params); -av_freep(>slices[i]); +if (pic->slices) { +av_freep(>slices[i].priv_data); +av_freep(>slices[i].codec_slice_params); +} } av_freep(>codec_picture_params); av_frame_free(>input_image); av_frame_free(>recon_image); +av_freep(>param_buffers); +av_freep(>slices); // Output buffer should already be destroyed. av_assert0(pic->output_buffer == VA_INVALID_ID); diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index 1b0fed80e4..31c3790531 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -35,8 +35,6 @@ enum { MAX_CONFIG_ATTRIBUTES = 4, MAX_GLOBAL_PARAMS = 4, MAX_PICTURE_REFERENCES = 2, -MAX_PICTURE_SLICES = 112, -MAX_PARAM_BUFFERS = 128, MAX_REORDER_DELAY = 16, MAX_PARAM_BUFFER_SIZE = 1024, }; @@ -73,7 +71,7 @@ typedef struct VAAPIEncodePicture { VASurfaceID recon_surface; int nb_param_buffers; -VABufferID param_buffers[MAX_PARAM_BUFFERS]; +VABufferID *param_buffers; AVBufferRef*output_buffer_ref; VABufferID output_buffer; @@ -85,7 +83,7 @@ typedef struct VAAPIEncodePicture { struct
[FFmpeg-cvslog] doc/ffmpeg: document -dn option
ffmpeg | branch: master | Lou Logan| Wed Feb 21 12:32:23 2018 -0900| [d09368a40844e62d952c77cc0fa4f6992afb924e] | committer: Lou Logan doc/ffmpeg: document -dn option Also mention -map in the -vn, -an, and -sn options. Fixes #7036. Signed-off-by: Lou Logan > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d09368a40844e62d952c77cc0fa4f6992afb924e --- doc/ffmpeg.texi | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 25a0707dc1..86c6fd864c 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -413,6 +413,10 @@ they do not conflict with the standard, as in: ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg @end example +@item -dn (@emph{output}) +Disable data recording. For full manual control see the @code{-map} +option. + @item -dframes @var{number} (@emph{output}) Set the number of data frames to output. This is an obsolete alias for @code{-frames:d}, which you should use instead. @@ -571,7 +575,8 @@ stored at container level, but not the aspect ratio stored in encoded frames, if it exists. @item -vn (@emph{output}) -Disable video recording. +Disable video recording. For full manual control see the @code{-map} +option. @item -vcodec @var{codec} (@emph{output}) Set the video codec. This is an alias for @code{-codec:v}. @@ -886,7 +891,8 @@ default to the number of input audio channels. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options. @item -an (@emph{output}) -Disable audio recording. +Disable audio recording. For full manual control see the @code{-map} +option. @item -acodec @var{codec} (@emph{input/output}) Set the audio codec. This is an alias for @code{-codec:a}. @item -sample_fmt[:@var{stream_specifier}] @var{sample_fmt} (@emph{output,per-stream}) @@ -921,7 +927,8 @@ stereo but not 6 channels as 5.1. The default is to always try to guess. Use @item -scodec @var{codec} (@emph{input/output}) Set the subtitle codec. This is an alias for @code{-codec:s}. @item -sn (@emph{output}) -Disable subtitle recording. +Disable subtitle recording. For full manual control see the @code{-map} +option. @item -sbsf @var{bitstream_filter} Deprecated, see -bsf @end table ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit '254e728d207c173a3714e6a01c9d68fcb3af8b73'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 21:36:08 2018 +| [7dc8752e614a9aa5b3378be5185d97741ee7735f] | committer: Mark Thompson Merge commit '254e728d207c173a3714e6a01c9d68fcb3af8b73' * commit '254e728d207c173a3714e6a01c9d68fcb3af8b73': cbs: Minor comment fixes / cosmetics Mostly already present, one small fix. Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7dc8752e614a9aa5b3378be5185d97741ee7735f --- libavcodec/cbs_internal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h index ae0b417b43..e4fe70a16a 100644 --- a/libavcodec/cbs_internal.h +++ b/libavcodec/cbs_internal.h @@ -32,9 +32,9 @@ typedef struct CodedBitstreamType { // Split frag->data into coded bitstream units, creating the // frag->units array. Fill data but not content on each unit. -// header is set if the fragment came from a header block, which -// may require different parsing for some codecs (e.g. the AVCC -// header in H.264). +// The header argument should be set if the fragment came from +// a header block, which may require different parsing for some +// codecs (e.g. the AVCC header in H.264). int (*split_fragment)(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header); == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] cbs: Minor comment fixes / cosmetics
ffmpeg | branch: master | Mark Thompson| Thu Nov 9 01:04:15 2017 +| [254e728d207c173a3714e6a01c9d68fcb3af8b73] | committer: Mark Thompson cbs: Minor comment fixes / cosmetics > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=254e728d207c173a3714e6a01c9d68fcb3af8b73 --- libavcodec/cbs.h | 35 +++ libavcodec/cbs_internal.h | 3 +++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h index 85c7b55577..ffeca057ab 100644 --- a/libavcodec/cbs.h +++ b/libavcodec/cbs.h @@ -25,6 +25,19 @@ #include "avcodec.h" +/* + * This defines a framework for converting between a coded bitstream + * and structures defining all individual syntax elements found in + * such a stream. + * + * Conversion in both directions is possible. Given a coded bitstream + * (any meaningful fragment), it can be parsed and decomposed into + * syntax elements stored in a set of codec-specific structures. + * Similarly, given a set of those same codec-specific structures the + * syntax elements can be serialised and combined to create a coded + * bitstream. + */ + struct CodedBitstreamType; /** @@ -39,7 +52,7 @@ typedef uint32_t CodedBitstreamUnitType; /** * Coded bitstream unit structure. * - * A bitstream unit the the smallest element of a bitstream which + * A bitstream unit the smallest element of a bitstream which * is meaningful on its own. For example, an H.264 NAL unit. * * See the codec-specific header for the meaning of this for any @@ -52,7 +65,7 @@ typedef struct CodedBitstreamUnit { CodedBitstreamUnitType type; /** - * Pointer to the bitstream form of this unit. + * Pointer to the directly-parsable bitstream form of this unit. * * May be NULL if the unit currently only exists in decomposed form. */ @@ -114,7 +127,7 @@ typedef struct CodedBitstreamFragment { /** * Number of units in this fragment. * - * This may be zero if the fragment only exists in bistream form + * This may be zero if the fragment only exists in bitstream form * and has not been decomposed. */ int nb_units; @@ -162,7 +175,7 @@ typedef struct CodedBitstreamContext { /** * Length of the decompose_unit_types array. */ -intnb_decompose_unit_types; +int nb_decompose_unit_types; /** * Enable trace output during read/write operations. @@ -204,6 +217,10 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx, /** * Read the data bitstream from a packet into a fragment, then * split into units and decompose. + * + * This also updates the internal state of the coded bitstream context + * with any persistent data from the fragment which may be required to + * read following fragments (e.g. parameter sets). */ int ff_cbs_read_packet(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, @@ -212,6 +229,10 @@ int ff_cbs_read_packet(CodedBitstreamContext *ctx, /** * Read a bitstream from a memory region into a fragment, then * split into units and decompose. + * + * This also updates the internal state of the coded bitstream context + * with any persistent data from the fragment which may be required to + * read following fragments (e.g. parameter sets). */ int ff_cbs_read(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, @@ -225,12 +246,18 @@ int ff_cbs_read(CodedBitstreamContext *ctx, * data buffer. When modifying the content of decomposed units, this * can be used to regenerate the bitstream form of units or the whole * fragment so that it can be extracted for other use. + * + * This also updates the internal state of the coded bitstream context + * with any persistent data from the fragment which may be required to + * write following fragments (e.g. parameter sets). */ int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag); /** * Write the bitstream of a fragment to the extradata in codec parameters. + * + * This replaces any existing extradata in the structure. */ int ff_cbs_write_extradata(CodedBitstreamContext *ctx, AVCodecParameters *par, diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h index dddeae9d5b..1a1c22f068 100644 --- a/libavcodec/cbs_internal.h +++ b/libavcodec/cbs_internal.h @@ -32,6 +32,9 @@ typedef struct CodedBitstreamType { // Split frag->data into coded bitstream units, creating the // frag->units array. Fill data but not content on each unit. +// The header argument should be set if the fragment came from +// a header block, which may require different parsing for some +// codecs (e.g. the AVCC header in H.264). int (*split_fragment)(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int
[FFmpeg-cvslog] cbs: Add an explicit type for coded bitstream unit types
ffmpeg | branch: master | Mark Thompson| Thu Nov 9 01:04:02 2017 +| [1d12a545ce828eaf4fb3729548ea37635ab8] | committer: Mark Thompson cbs: Add an explicit type for coded bitstream unit types Also fix conversion specifiers used for the unit type. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1d12a545ce828eaf4fb3729548ea37635ab8 --- libavcodec/cbs.c | 12 +++- libavcodec/cbs.h | 19 +++ libavcodec/cbs_h2645.c | 2 +- libavcodec/cbs_mpeg2.c | 4 ++-- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index fd9baa2997..e5819afce3 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -137,10 +137,10 @@ static int cbs_read_fragment_content(CodedBitstreamContext *ctx, if (err == AVERROR(ENOSYS)) { av_log(ctx->log_ctx, AV_LOG_WARNING, "Decomposition unimplemented for unit %d " - "(type %d).\n", i, frag->units[i].type); + "(type %"PRIu32").\n", i, frag->units[i].type); } else if (err < 0) { av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to read unit %d " - "(type %d).\n", i, frag->units[i].type); + "(type %"PRIu32").\n", i, frag->units[i].type); return err; } } @@ -225,7 +225,7 @@ int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, err = ctx->codec->write_unit(ctx, >units[i]); if (err < 0) { av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to write unit %d " - "(type %d).\n", i, frag->units[i].type); + "(type %"PRIu32").\n", i, frag->units[i].type); return err; } } @@ -421,7 +421,8 @@ static int cbs_insert_unit(CodedBitstreamContext *ctx, int ff_cbs_insert_unit_content(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, - int position, uint32_t type, + int position, + CodedBitstreamUnitType type, void *content) { int err; @@ -443,7 +444,8 @@ int ff_cbs_insert_unit_content(CodedBitstreamContext *ctx, int ff_cbs_insert_unit_data(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, -int position, uint32_t type, +int position, +CodedBitstreamUnitType type, uint8_t *data, size_t data_size) { int err; diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h index 34ee78be32..85c7b55577 100644 --- a/libavcodec/cbs.h +++ b/libavcodec/cbs.h @@ -28,6 +28,15 @@ struct CodedBitstreamType; /** + * The codec-specific type of a bitstream unit. + * + * H.264 / AVC: nal_unit_type + * H.265 / HEVC: nal_unit_type + * MPEG-2: start code value (without prefix) + */ +typedef uint32_t CodedBitstreamUnitType; + +/** * Coded bitstream unit structure. * * A bitstream unit the the smallest element of a bitstream which @@ -40,7 +49,7 @@ typedef struct CodedBitstreamUnit { /** * Codec-specific type of this unit. */ -uint32_t type; +CodedBitstreamUnitType type; /** * Pointer to the bitstream form of this unit. @@ -149,7 +158,7 @@ typedef struct CodedBitstreamContext { * Types not in this list will be available in bitstream form only. * If NULL, all supported types will be decomposed. */ -uint32_t *decompose_unit_types; +CodedBitstreamUnitType *decompose_unit_types; /** * Length of the decompose_unit_types array. */ @@ -250,7 +259,8 @@ void ff_cbs_fragment_uninit(CodedBitstreamContext *ctx, */ int ff_cbs_insert_unit_content(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, - int position, uint32_t type, + int position, + CodedBitstreamUnitType type, void *content); /** @@ -260,7 +270,8 @@ int ff_cbs_insert_unit_content(CodedBitstreamContext *ctx, */ int ff_cbs_insert_unit_data(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, -int position, uint32_t type, +int position, +CodedBitstreamUnitType type, uint8_t *data, size_t data_size); /** diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 00eed0f283..e3b5bf618a 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -1213,7 +1213,7 @@ static int cbs_h265_write_nal_unit(CodedBitstreamContext *ctx, default: av_log(ctx->log_ctx, AV_LOG_ERROR, "Write unimplemented for " - "NAL unit type %d.\n", unit->type); + "NAL unit
[FFmpeg-cvslog] Merge commit '1d12a545ce828eaf4fb37295400008ea37635ab8'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 21:25:48 2018 +| [cacb47633c043a4bafb6872716dd8c4479dc4df1] | committer: Mark Thompson Merge commit '1d12a545ce828eaf4fb3729548ea37635ab8' * commit '1d12a545ce828eaf4fb3729548ea37635ab8': cbs: Add an explicit type for coded bitstream unit types Mostly already present from 6734eef6b8b464139fdc140ec9bc9e8d74173869, two minor message changes are merged. Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cacb47633c043a4bafb6872716dd8c4479dc4df1 --- libavcodec/cbs_mpeg2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c index 642a9c99b1..c721f5097e 100644 --- a/libavcodec/cbs_mpeg2.c +++ b/libavcodec/cbs_mpeg2.c @@ -220,7 +220,7 @@ static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx, START(0xb8, MPEG2RawGroupOfPicturesHeader, group_of_pictures_header); #undef START default: -av_log(ctx->log_ctx, AV_LOG_ERROR, "Unknown start code %"PRIx32".\n", +av_log(ctx->log_ctx, AV_LOG_ERROR, "Unknown start code %02"PRIx32".\n", unit->type); return AVERROR_INVALIDDATA; } @@ -248,7 +248,7 @@ static int cbs_mpeg2_write_header(CodedBitstreamContext *ctx, #undef START default: av_log(ctx->log_ctx, AV_LOG_ERROR, "Write unimplemented for start " - "code %02"PRIu32".\n", unit->type); + "code %02"PRIx32".\n", unit->type); return AVERROR_PATCHWELCOME; } == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit '2651352988212531038326c44754ece1728c4a3b'
ffmpeg | branch: master | Mark Thompson| Wed Feb 21 21:23:50 2018 +| [d28eb0e34d80f12b779c7b6befc5b350ffcdf476] | committer: Mark Thompson Merge commit '2651352988212531038326c44754ece1728c4a3b' * commit '2651352988212531038326c44754ece1728c4a3b': cbs: Allocate the context inside the init function This commit is a noop, see 6734eef6b8b464139fdc140ec9bc9e8d74173869 Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d28eb0e34d80f12b779c7b6befc5b350ffcdf476 --- ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] cbs: Allocate the context inside the init function
ffmpeg | branch: master | Mark Thompson| Thu Nov 9 01:03:57 2017 +| [2651352988212531038326c44754ece1728c4a3b] | committer: Mark Thompson cbs: Allocate the context inside the init function ... instead of making callers allocate it themselves. This is more consistent with other APIs in libav. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2651352988212531038326c44754ece1728c4a3b --- libavcodec/cbs.c| 20 +--- libavcodec/cbs.h| 6 +++--- libavcodec/h264_metadata_bsf.c | 20 ++-- libavcodec/h264_redundant_pps_bsf.c | 18 +- libavcodec/h265_metadata_bsf.c | 18 +- libavcodec/mpeg2_metadata_bsf.c | 16 libavcodec/trace_headers_bsf.c | 14 +++--- libavcodec/vaapi_encode_h264.c | 14 +++--- libavcodec/vaapi_encode_h265.c | 10 +- libavcodec/vaapi_encode_mpeg2.c | 10 +- 10 files changed, 80 insertions(+), 66 deletions(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index 3baa31a4dd..fd9baa2997 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -39,9 +39,10 @@ static const CodedBitstreamType *cbs_type_table[] = { #endif }; -int ff_cbs_init(CodedBitstreamContext *ctx, +int ff_cbs_init(CodedBitstreamContext **ctx_ptr, enum AVCodecID codec_id, void *log_ctx) { +CodedBitstreamContext *ctx; const CodedBitstreamType *type; int i; @@ -55,27 +56,40 @@ int ff_cbs_init(CodedBitstreamContext *ctx, if (!type) return AVERROR(EINVAL); +ctx = av_mallocz(sizeof(*ctx)); +if (!ctx) +return AVERROR(ENOMEM); + ctx->log_ctx = log_ctx; ctx->codec = type; ctx->priv_data = av_mallocz(ctx->codec->priv_data_size); -if (!ctx->priv_data) +if (!ctx->priv_data) { +av_freep(); return AVERROR(ENOMEM); +} ctx->decompose_unit_types = NULL; ctx->trace_enable = 0; ctx->trace_level = AV_LOG_TRACE; +*ctx_ptr = ctx; return 0; } -void ff_cbs_close(CodedBitstreamContext *ctx) +void ff_cbs_close(CodedBitstreamContext **ctx_ptr) { +CodedBitstreamContext *ctx = *ctx_ptr; + +if (!ctx) +return; + if (ctx->codec && ctx->codec->close) ctx->codec->close(ctx); av_freep(>priv_data); +av_freep(ctx_ptr); } static void cbs_unit_uninit(CodedBitstreamContext *ctx, diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h index 01b2239b7b..34ee78be32 100644 --- a/libavcodec/cbs.h +++ b/libavcodec/cbs.h @@ -169,15 +169,15 @@ typedef struct CodedBitstreamContext { /** - * Initialise a new context for the given codec. + * Create and initialise a new context for the given codec. */ -int ff_cbs_init(CodedBitstreamContext *ctx, +int ff_cbs_init(CodedBitstreamContext **ctx, enum AVCodecID codec_id, void *log_ctx); /** * Close a context and free all internal state. */ -void ff_cbs_close(CodedBitstreamContext *ctx); +void ff_cbs_close(CodedBitstreamContext **ctx); /** diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index ac0b9823b9..2b579e9d3d 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -35,7 +35,7 @@ enum { typedef struct H264MetadataContext { const AVClass *class; -CodedBitstreamContext cbc; +CodedBitstreamContext *cbc; CodedBitstreamFragment access_unit; H264RawAUD aud_nal; @@ -214,7 +214,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) if (err < 0) goto fail; -err = ff_cbs_read_packet(>cbc, au, in); +err = ff_cbs_read_packet(ctx->cbc, au, in); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); goto fail; @@ -229,7 +229,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) // If an AUD is present, it must be the first NAL unit. if (au->units[0].type == H264_NAL_AUD) { if (ctx->aud == REMOVE) -ff_cbs_delete_unit(>cbc, au, 0); +ff_cbs_delete_unit(ctx->cbc, au, 0); } else { if (ctx->aud == INSERT) { static const int primary_pic_type_table[] = { @@ -269,7 +269,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) aud->nal_unit_header.nal_unit_type = H264_NAL_AUD; aud->primary_pic_type = j; -err = ff_cbs_insert_unit_content(>cbc, au, +err = ff_cbs_insert_unit_content(ctx->cbc, au, 0, H264_NAL_AUD, aud); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n"); @@ -314,7 +314,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out) sei->nal_unit_header.nal_unit_type = H264_NAL_SEI; -err = ff_cbs_insert_unit_content(>cbc, au, +err =