[FFmpeg-devel] [PATCH v2 05/11] avcodec/cbs_h265: fix undef SEI_TYPE_X
--- libavcodec/cbs_h265_syntax_template.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index 48fae82d04..c0e94683a2 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -2197,7 +2197,9 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, 1, 0, alternative_transfer_characteristics); SEI_TYPE_N(ALPHA_CHANNEL_INFO, 1, 0, alpha_channel_info); -#undef SEI_TYPE +#undef SEI_TYPE_N +#undef SEI_TYPE_S +#undef SEI_TYPE_E default: { #ifdef READ -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/6] avcodec: add cbs for h266
On Tue, Dec 22, 2020 at 6:53 AM Mark Thompson wrote: > On 21/12/2020 06:07, Nuo Mi wrote: > > --- > > libavcodec/Makefile |1 + > > libavcodec/cbs.c |6 + > > libavcodec/cbs_h2645.c| 337 ++ > > libavcodec/cbs_h266.h | 711 > > libavcodec/cbs_h266_syntax_template.c | 1493 + > > libavcodec/cbs_internal.h |1 + > > 6 files changed, 2549 insertions(+) > > create mode 100644 libavcodec/cbs_h266.h > > create mode 100644 libavcodec/cbs_h266_syntax_template.c > > > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > > index 450781886d..4045c002b7 100644 > > --- a/libavcodec/Makefile > > +++ b/libavcodec/Makefile > > > > > > +#define FUNC(name) FUNC_H266(READWRITE, name) > > +#include "cbs_h266_syntax_template.c" > > +#undef FUNC > > + > > #undef READ > > #undef READWRITE > > #undef RWContext > > Please include the second time for write support as well. (With only read > this is incredibly hard to test.) > Done > > > > > +static int cbs_h266_read_nal_unit(CodedBitstreamContext *ctx, > > + CodedBitstreamUnit *unit) > > +{ > > +GetBitContext gbc; > > +int err; > > + > > +err = init_get_bits(, unit->data, 8 * unit->data_size); > > init_get_bits8() > Done > > > +if (err < 0) > > +return err; > > + > > +err = ff_cbs_alloc_unit_content2(ctx, unit); > > +if (err < 0) > > +return err; > > + > > +switch (unit->type) { > > +case H266_NAL_VPS: > > +{ > > +H266RawVPS *vps = unit->content; > > + > > +err = cbs_h266_read_vps(ctx, , vps); > > This isn't implemented, so don't include it here so it returns ENOSYS. > Done > > > > + > > +case H266_NAL_PPS: > > +{ > > +H266RawPPS *pps = unit->content; > > + > > +err = cbs_h266_read_pps(ctx, , pps); > > +if (err < 0) > > +return err; > > + > > +err = cbs_h266_replace_pps(ctx, unit); > > +if (err < 0) > > +return err; > > +} > > +break; > > + > > +case H266_NAL_TRAIL: > > +case H266_NAL_STSA: > > +case H266_NAL_RADL: > > Missing case H266_NUT_RASL. > Fixed > > > + > > +case H266_NAL_PREFIX_SEI: > > +case H266_NAL_SUFFIX_SEI: > > +{ > > +err = cbs_h266_read_sei(ctx, , unit->content, > > +unit->type == H266_NAL_PREFIX_SEI); > > + > > +if (err < 0) > > +return err; > > +} > > +break; > > Don't include SEI at all given that you haven't implemented it; just let > it return ENOSYS. Implemented. > > + > > +default: > > +return AVERROR(ENOSYS); > > +} > > +return 0; > > +} > > + > > static int cbs_h2645_write_slice_data(CodedBitstreamContext *ctx, > > PutBitContext *pbc, const > uint8_t *data, > > size_t data_size, int > data_bit_start) > > @@ -1207,6 +1328,120 @@ static int > cbs_h265_write_nal_unit(CodedBitstreamContext *ctx, > > return 0; > > } > > > > +static int cbs_h266_write_nal_unit(CodedBitstreamContext *ctx, > > + CodedBitstreamUnit *unit, > > + PutBitContext *pbc) > > +{ > > +printf("TODO: cbs_h266_write_nal_unit"); > > Yes. > Implemented. > > > > > +static void cbs_h266_close(CodedBitstreamContext *ctx) > > +{ > > +CodedBitstreamH266Context *h266 = ctx->priv_data; > > +int i; > > + > > +ff_h2645_packet_uninit(>common.read_packet); > > + > > +for (i = 0; i < FF_ARRAY_ELEMS(h266->vps); i++) > > +av_buffer_unref(>vps_ref[i]); > > +for (i = 0; i < FF_ARRAY_ELEMS(h266->sps); i++) > > +av_buffer_unref(>sps_ref[i]); > > +for (i = 0; i < FF_ARRAY_ELEMS(h266->pps); i++) > > +av_buffer_unref(>pps_ref[i]); > > These loops look like exactly what flush does. > Fixed, will call flush, I will send a separate patch for h264/h265 > > > +} > > + > > static void cbs_h264_free_sei_payload(H264RawSEIPayload *payload) > > { > > switch (payload->payload_type) { > > @@ -1506,6 +1778,55 @@ static const CodedBitstreamUnitTypeDescriptor > cbs_h265_unit_types[] = { > > CBS_UNIT_TYPE_END_OF_LIST > > }; > > > > +static void cbs_h266_free_sei(void *opaque, uint8_t *content) > > +{ > > +} > > + > > +static const CodedBitstreamUnitTypeDescriptor cbs_h266_unit_types[] = { > > +CBS_UNIT_TYPE_INTERNAL_REF(H266_NAL_VPS, H266RawVPS, > extension_data.data), > > +CBS_UNIT_TYPE_INTERNAL_REF(H266_NAL_SPS, H266RawSPS, > extension_data.data), > > +CBS_UNIT_TYPE_INTERNAL_REF(H266_NAL_PPS, H266RawPPS, > extension_data.data), > > + > > +CBS_UNIT_TYPE_POD(H266_NAL_AUD, H266RawAUD), > > + > > +{ > > +// Slices of non-IRAP pictures. > > +
Re: [FFmpeg-devel] [PATCH v2 11/11] avcodec: add vvdec H.266/VVC decoder
According to James and Lynne, merge this patch needs further discussion. I send out it just to make sure the metadata bsf workable. A basic bsf command like this need a workable decoder: "ffmpeg -i in.bin -c:v copy -bsf vvc_metadata out.266" On Sat, Jan 9, 2021 at 3:35 PM Nuo Mi wrote: > you can download test clips here: > > https://www.itu.int/wftp3/av-arch/jvet-site/bitstream_exchange/VVC/under_test/VTM-11.0/ > > 76.71% (191/249) clips are md5 matched with VTM 11: > > passed: > > 10b400_A_Bytedance_2.bit > 10b400_B_Bytedance_2.bit > 8b400_A_Bytedance_2.bit > 8b400_B_Bytedance_2.bit > 8b420_A_Bytedance_2.bit > 8b420_B_Bytedance_2.bit > ACTPIC_A_Huawei_3.bit > ACTPIC_B_Huawei_3.bit > ACTPIC_C_Huawei_3.bit > AFF_A_HUAWEI_2.bit > AFF_B_HUAWEI_2.bit > ALF_A_Huawei_3.bit > ALF_B_Huawei_3.bit > ALF_C_KDDI_2.bit > ALF_D_Qualcomm_2.bit > AMVR_A_HHI_3.bit > AMVR_B_HHI_3.bit > APSALF_A_Qualcomm_2.bit > APSLMCS_A_Dolby_3.bit > APSLMCS_B_Dolby_3.bit > APSLMCS_C_Dolby_2.bit > APSMULT_A_MediaTek_3.bit > APSMULT_B_MediaTek_3.bit > AUD_A_Broadcom_3.bit > BCW_A_MediaTek_3.bit > BCW_A_MediaTek_4.bit > BDOF_A_MediaTek_3.bit > BDOF_A_MediaTek_4.bit > BDPCM_A_Orange_2.bit > CCALF_A_Sharp_3.bit > CCALF_B_Sharp_3.bit > CCALF_C_Sharp_3.bit > CCALF_D_Sharp_3.bit > CCLM_A_KDDI_1.bit > CIIP_A_MediaTek_3.bit > CIIP_A_MediaTek_4.bit > CodingToolsSets_A_Tencent_2.bit > CodingToolsSets_B_Tencent_2.bit > CodingToolsSets_C_Tencent_2.bit > CodingToolsSets_D_Tencent_2.bit > CROP_A_Panasonic_3.bit > CROP_B_Panasonic_4.bit > CST_A_MediaTek_3.bit > CTU_A_MediaTek_3.bit > CTU_A_MediaTek_4.bit > CTU_B_MediaTek_3.bit > CTU_B_MediaTek_4.bit > CTU_C_MediaTek_3.bit > CTU_C_MediaTek_4.bit > CUBEMAP_A_MediaTek_3.bit > CUBEMAP_B_MediaTek_3.bit > CUBEMAP_C_MediaTek_3.bit > DEBLOCKING_A_Sharp_3.bit > DEBLOCKING_B_Sharp_2.bit > DEBLOCKING_C_Huawei_3.bit > DEBLOCKING_E_Ericsson_2.bit > DEBLOCKING_E_Ericsson_3.bit > DEBLOCKING_F_Ericsson_1.bit > DEBLOCKING_F_Ericsson_2.bit > DMVR_A_Huawei_3.bit > DMVR_B_KDDI_3.bit > DPB_A_Sharplabs_2.bit > DPB_B_Sharplabs_2.bit > DQ_A_HHI_3.bit > ENT444HIGHTIER_A_Sony_3.bit > ENT444HIGHTIER_B_Sony_3.bit > ENT444HIGHTIER_C_Sony_3.bit > ENT444HIGHTIER_D_Sony_3.bit > ENT444MAINTIER_A_Sony_3.bit > ENT444MAINTIER_B_Sony_3.bit > ENT444MAINTIER_C_Sony_3.bit > ENT444MAINTIER_D_Sony_3.bit > ENTHIGHTIER_A_Sony_3.bit > ENTHIGHTIER_B_Sony_3.bit > ENTHIGHTIER_C_Sony_3.bit > ENTHIGHTIER_D_Sony_3.bit > ENTMAINTIER_A_Sony_3.bit > ENTMAINTIER_B_Sony_3.bit > ENTMAINTIER_C_Sony_3.bit > ENTMAINTIER_D_Sony_3.bit > ENTROPY_A_Chipsnmedia_2.bit > ENTROPY_A_Qualcomm_2.bit > ENTROPY_B_Sharp_2.bit > ERP_A_MediaTek_3.bit > FILLER_A_Bytedance_1.bit > GPM_A_Alibaba_3.bit > HLG_A_NHK_2.bit > HLG_B_NHK_2.bit > HRD_A_Fujitsu_3.bit > HRD_B_Fujitsu_2.bit > IBC_A_Tencent_2.bit > IBC_B_Tencent_2.bit > IBC_C_Tencent_2.bit > IBC_D_Tencent_2.bit > IP_B_Nokia_1.bit > ISP_A_HHI_3.bit > ISP_B_HHI_3.bit > JCCR_A_Nokia_2.bit > JCCR_B_Nokia_2.bit > JCCR_C_HHI_3.bit > JCCR_E_Nokia_1.bit > JCCR_F_Nokia_1.bit > LFNST_A_LGE_3.bit > LFNST_B_LGE_3.bit > LFNST_C_HHI_3.bit > LMCS_A_Dolby_3.bit > LOSSLESS_A_HHI_3.bit > LOSSLESS_B_HHI_3.bit > LTRP_A_ERICSSON_2.bit > MERGE_A_Qualcomm_2.bit > MERGE_B_Qualcomm_2.bit > MERGE_C_Qualcomm_2.bit > MERGE_D_Qualcomm_2.bit > MERGE_E_Qualcomm_2.bit > MERGE_F_Qualcomm_2.bit > MERGE_G_Qualcomm_2.bit > MERGE_H_Qualcomm_2.bit > MERGE_I_Qualcomm_2.bit > MERGE_J_Qualcomm_2.bit > MIP_A_HHI_3.bit > MIP_B_HHI_3.bit > MPM_A_LGE_3.bit > MRLP_A_HHI_2.bit > MRLP_B_HHI_2.bit > MTS_A_LGE_3.bit > MTS_B_LGE_3.bit > MTS_LFNST_A_LGE_3.bit > MTS_LFNST_B_LGE_3.bit > MVCOMP_A_Sharp_2.bit > PDPC_A_Qualcomm_3.bit > PDPC_B_Qualcomm_3.bit > PDPC_C_Qualcomm_2.bit > PHSH_B_Sharp_1.bit > POC_A_Nokia_1.bit > POUT_A_Sharplabs_2.bit > PPS_B_Bytedance_1.bit > PPS_C_Bytedance_1.bit > PQ_A_Dolby_1.bit > PROF_A_Interdigital_3.bit > PROF_B_Interdigital_3.bit > PSEXT_A_Nokia_2.bit > PSEXT_B_Nokia_2.bit > QTBTT_A_MediaTek_3.bit > QTBTT_A_MediaTek_4.bit > QUANT_A_Huawei_2.bit > QUANT_B_Huawei_2.bit > QUANT_C_Huawei_2.bit > QUANT_D_Huawei_2.bit > RAP_C_HHI_1.bit > RAP_D_HHI_1.bit > RPL_A_ERICSSON_2.bit > SAO_A_SAMSUNG_3.bit > SAO_B_SAMSUNG_3.bit > SAO_C_SAMSUNG_3.bit > SbTMVP_A_Bytedance_3.bit > SbTMVP_B_Bytedance_3.bit > SBT_A_HUAWEI_2.bit > SCALING_A_InterDigital_1.bit > SCALING_B_InterDigital_1.bit > SCALING_C_InterDigital_1.bit > SDH_A_Dolby_2.bit > SLICES_A_HUAWEI_2.bit > SMVD_A_HUAWEI_2.bit > SPS_A_Bytedance_1.bit > SPS_B_Bytedance_1.bit > SPS_C_Bytedance_1.bit > TEMPSCAL_A_Panasonic_4.bit > TEMPSCAL_C_Panasonic_3.bit > TILE_A_Nokia_2.bit > TILE_B_Nokia_2.bit > TILE_C_Nokia_2.bit > TILE_D_Nokia_2.bit > TILE_E_Nokia_2.bit > TILE_F_Nokia_2.bit > TILE_G_Nokia_2.bit > TMVP_A_Chipsnmedia_3.bit > TMVP_B_Chipsnmedia_3.bit > TMVP_C_Chipsnmedia_3.bit > TMVP_D_Chipsnmedia_3.bit > TRANS_A_Chipsnmedia_2.bit > TRANS_B_Chipsnmedia_2.bit > TRANS_C_Chipsnmedia_2.bit > TRANS_D_Chipsnmedia_2.bit > WPP_A_Sharp_3.bit > WPP_B_Sharp_2.bit > WP_A_InterDigital_3.bit >
[FFmpeg-devel] [PATCH v2 00/11] add vvc raw demuxer, muxer, parser, metadata bsf, vvdec decoder
Nuo Mi (11): avcodec/vvc: add shared header for vvc avcodec: add vvc codec id and profiles avformat: add vvc raw demux avcodec: add SEI enum for vvc avcodec/cbs_h265: fix undef SEI_TYPE_X avcodec: add cbs for h266/vvc avcodec/h2645_parse: add nal header parser for h266/vvc avcodec: add vvc parser avformat: add h266/vvc muxer avcodec: add vvc metadata bsf avcodec: add vvdec H.266/VVC decoder configure |9 +- libavcodec/Makefile |4 + libavcodec/allcodecs.c|1 + libavcodec/avcodec.h |2 + libavcodec/bitstream_filters.c|1 + libavcodec/cbs.c |6 + libavcodec/cbs_h2645.c| 373 libavcodec/cbs_h265_syntax_template.c |4 +- libavcodec/cbs_h266.h | 840 libavcodec/cbs_h266_syntax_template.c | 2761 + libavcodec/cbs_internal.h |3 +- libavcodec/codec_desc.c |8 + libavcodec/codec_id.h |2 + libavcodec/h2645_parse.c | 74 +- libavcodec/libvvdec.cpp | 244 +++ libavcodec/parsers.c |1 + libavcodec/profiles.c |5 + libavcodec/profiles.h |1 + libavcodec/vvc.h | 124 ++ libavcodec/vvc_metadata_bsf.c | 243 +++ libavcodec/vvc_parser.c | 289 +++ libavcodec/vvc_sei.h | 47 + libavformat/Makefile |2 + libavformat/allformats.c |2 + libavformat/rawenc.c | 25 + libavformat/vvcdec.c | 61 + 26 files changed, 5126 insertions(+), 6 deletions(-) create mode 100644 libavcodec/cbs_h266.h create mode 100644 libavcodec/cbs_h266_syntax_template.c create mode 100644 libavcodec/libvvdec.cpp create mode 100644 libavcodec/vvc.h create mode 100644 libavcodec/vvc_metadata_bsf.c create mode 100644 libavcodec/vvc_parser.c create mode 100644 libavcodec/vvc_sei.h create mode 100644 libavformat/vvcdec.c -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/6] avcodec/h266: add shared header for h266
On Tue, Dec 22, 2020 at 4:49 AM Mark Thompson wrote: > On 21/12/2020 06:07, Nuo Mi wrote: > > --- > > libavcodec/h266.h | 121 ++ > > 1 file changed, 121 insertions(+) > > create mode 100644 libavcodec/h266.h > > > > diff --git a/libavcodec/h266.h b/libavcodec/h266.h > > new file mode 100644 > > index 00..d5793b76fc > > --- /dev/null > > +++ b/libavcodec/h266.h > > @@ -0,0 +1,121 @@ > > +/** > > + * Table 5 – NAL unit type codes and NAL unit type classes in > > + * T-REC-H.266-202008 > > + */ > > +enum H266NALUnitType { > > You don't use this type name anywhere. I don't think there is any use in > including it. > It just follows the hevc, maybe we need it in the native decoder. > > > +H266_NAL_TRAIL = 0, > > Probably clearer as H266_NAL_UNIT_TYPE_FOO or H266_NUT_FOO? > Done, I mapped spec name XXX to VVC_XXX > > > +H266_NAL_AUD = 20, > > +H266_NAL_EOS_NUT = 21, > > +H266_NAL_EOB_NUT = 22, > > The redundant _NUT suffixes are inconsistent. > Fixed, but spec names are inconsistent. > > > > + > > +enum H266SliceType { > > This type name too. > > > +H266_SLICE_B = 0, > > H266_SLICE_TYPE_B > Done > > > +H266_SLICE_P = 1, > > +H266_SLICE_I = 2, > > +}; > > + > > +enum { > > +H266_MAX_PLANES = 3, > > +//7.4.3.3 The value of vps_max_sublayers_minus1 shall be in the > range of 0 to 6, inclusive > > +H266_MAX_SUB_LAYERS = 7, > > + > > +// 7.3.2.3: vps_video_parameter_set_id is u(4). > > +H266_MAX_VPS_COUNT = 16, > > +// 7.3.2.4: sps_seq_parameter_set_id is in [0, 15]. > > It's u(4), not a stated constraint. (Unlike in H.264, where these ids > very ue(v) with a constraint in the text.) > done > > > +H266_MAX_SPS_COUNT = 16, > > +// 7.3.2.5: pps_pic_parameter_set_id is in [0, 63]. > > u(6) > Done > > > +H266_MAX_PPS_COUNT = 64, > > + > > +// A.4.2: MaxDpbSize is bounded above by 16. > > The definition in terms of maxDpbPicBuf is clearer than it was in H.265, > so I think say that rather than just the result. > Done > > > +H266_MAX_DPB_SIZE = 16, > > + > > +//7.4.3.4 sps_num_ref_pic_lists in range [0, 64] > > +H266_MAX_REF_PIC_LISTS = 64, > > + > > +//7.4.3.3 sps_num_points_in_qp_table_minus1[i] in range [0, 36 − > sps_qp_table_start_minus26[i]], > > +//sps_qp_table_start_minus26[i] in range > [sps_qp_table_start_minus26[i] −26 − QpBdOffset, 36] > > +//for 10 bitsQpBdOffset is 12, so > sps_num_points_in_qp_table_minus1[i] in range [0, 74] > > +H266_MAX_POINTS_IN_QP_TABLE = 75, > > + > > +// 7.4.6.1: hrd_cpb_cnt_minus1 is in [0, 31]. > > +H266_MAX_CPB_CNT = 32, > > + > > +// A.4.1: in table A.6 the highest level allows a MaxLumaPs of 35 > 651 584. > > Table A.1 is the reference for MaxLumaPs. (Table A.6 is only informative, > though this value does appear for 8K.) > Done > > > +H266_MAX_LUMA_PS = 35651584, > > +// A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples > are > > +// constrained to be not greater than sqrt(MaxLumaPs * 8). Hence > height/ > > +// width are bounded above by sqrt(8 * 35651584) = 16888.2 samples. > > +H266_MAX_WIDTH = 16888, > > +H266_MAX_HEIGHT = 16888, > > + > > +// A.4.1: table A.1 allows at most 20 tile rows for any level. > > No it doesn't? I don't see any reference to tile rows in table A.1. > changed to 440(MaxTilesPerAu), > > > +H266_MAX_TILE_ROWS= 20, > +// A.4.1: table A.1 allows at > most 20 tile columns for any level. > > +H266_MAX_TILE_COLUMNS = 20, > > + > > +// A.4.1 table A.1 allows at most 600 slice for any level. > > +H266_MAX_SLICES = 600, > > + > > +// 7.4.8: in the worst case (tiles_enabled_flag and > > +// entropy_coding_sync_enabled_flag are both set), entry points can > be > > +// placed at the beginning of every Ctb row in every tile, giving an > > +// upper bound of (num_tile_columns_minus1 + 1) * PicHeightInCtbsY > - 1. > > +// Only a stream with very high resolution and perverse parameters > could > > +// get near that, though, so set a lower limit here with the maximum > > +// possible value for 8K video (at most 135 32x32 Ctb rows). > > Is this text copied from H.265 still accurate? NumEntryPoints is > implicitly calculated rather than appearing in the bitstream here. > Yes, we use sps_log2_ctu_size_minus5 to signal ctu size. So the min ctu size is 1<<5 = 32. Suppose 8k is 7680 × 4320, we have 4320/32 = 135 rows in maximum. > > > +H266_MAX_ENTRY_POINT_OFFSETS = H266_MAX_TILE_COLUMNS * 135, > > +}; > > + > > +#endif /* AVCODEC_H266_H */ > > > > - Mark > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 5/6] avcodec: add h266 parser
On Sat, Jan 9, 2021 at 2:56 PM Nuo Mi wrote: > > > On Mon, Dec 21, 2020 at 11:15 PM James Almer wrote: > >> On 12/21/2020 3:07 AM, Nuo Mi wrote: >> > --- >> > configure| 3 + >> > libavcodec/Makefile | 1 + >> > libavcodec/h2645_parse.c | 73 +- >> > libavcodec/h266_parser.c | 284 +++ >> > libavcodec/parsers.c | 1 + >> > 5 files changed, 360 insertions(+), 2 deletions(-) >> > create mode 100644 libavcodec/h266_parser.c >> > >> > diff --git a/configure b/configure >> > index 90914752f1..77272948e3 100755 >> > --- a/configure >> > +++ b/configure >> > @@ -2354,6 +2354,7 @@ CONFIG_EXTRA=" >> > cbs_av1 >> > cbs_h264 >> > cbs_h265 >> > +cbs_h266 >> > cbs_jpeg >> > cbs_mpeg2 >> > cbs_vp9 >> > @@ -2622,6 +2623,7 @@ threads_if_any="$THREADS_LIST" >> > cbs_av1_select="cbs" >> > cbs_h264_select="cbs" >> > cbs_h265_select="cbs" >> > +cbs_h266_select="cbs" >> >> These two chunks belong to the previous patch adding cbs_h266. Otherwise >> CONFIG_CBS_H266 will not be defined for Makefile to use. >> > fixed > >> >> > >> > diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c >> > index 0f98b49fbe..2600371d3c 100644 >> > --- a/libavcodec/h2645_parse.c >> > +++ b/libavcodec/h2645_parse.c >> >> cbs_h266 needs the changes to this file you're adding here to split >> NALUs, so it should be done in a new separate patch applied before patch >> 4/6. >> > done > >> >> >> > +static int h266_parse_nal_header(H2645NAL *nal, void *logctx) >> > +{ >> > +GetBitContext *gb = >gb; >> > + >> > +if (get_bits1(gb) != 0) //forbidden_zero_bit >> > +return AVERROR_INVALIDDATA; >> > + >> > +if (get_bits1(gb) != 0) //nuh_reserved_zero_bit >> >> This one should be ignored, otherwise bitstreams compliant with an >> hypotetical future revision of the spec that defines this bit will not >> work, when they should. >> >> But current current cbs uses fixed to check the server value, like > fixed(24, general_reserved_zero_33bits, 0); > it always return error for none zero > >> >> > +ctx->key_frame = ph->ph_gdr_or_irap_pic_flag; >> >> Should a gdr pic also marked as keyframe? If not, this should also >> ensure ph->ph_gdr_pic_flag is 0. >> >> > + >> > +ctx->coded_width = pps->pps_pic_width_in_luma_samples; >> > +ctx->coded_height = pps->pps_pic_height_in_luma_samples; >> > +ctx->width= pps->pps_pic_width_in_luma_samples - >> pps->pps_conf_win_left_offset - pps->pps_conf_win_right_offset; >> > +ctx->height = pps->pps_pic_height_in_luma_samples - >> pps->pps_conf_win_top_offset - pps->pps_conf_win_bottom_offset; >> > +ctx->pict_type= get_pict_type(pu); >> > +ctx->format = get_format(sps); >> > +avctx->profile = sps->profile_tier_level.general_profile_idc; >> > +avctx->level= sps->profile_tier_level.general_level_idc; >> > + >> > + >> > + >> > +if(sps->sps_ptl_dpb_hrd_params_present_flag && >> sps->sps_timing_hrd_params_present_flag) { >> > +num = sps->sps_general_timing_hrd_parameters.num_units_in_tick; >> > +den = sps->sps_general_timing_hrd_parameters.time_scale; >> > +} else { >> > +av_log(avctx, AV_LOG_INFO, "No >> sps_timing_hrd_params_present_flag in sps, the fps may not right.\n"); >> >> No need for this warning. >> >> > +goto end; >> > +} >> > +if (num != 0 && den != 0) >> > +av_reduce(>framerate.den, >framerate.num, >> > + num, den, 1 << 30); >> > +end: >> > + >> > +ff_cbs_fragment_reset(pu); >> > +s->cbc->log_ctx = NULL; >> > +return 0; >> > +} >> > + >> > +static int h266_parser_parse(AVCodecParserContext *s, AVCodecContext >> *avctx, >> > + const uint8_t **poutbuf, int *poutbuf_size, >> > + const uint8_t *buf, int buf_size) >> > +{ >> > +int next; >> > +H266ParserContext *ctx = s->priv_data; >> > +ParseContext *pc = >pc; >> > +int is_dummy_buf = !buf_size; >> > +const uint8_t *dummy_buf = buf; >> > + >> > +if (avctx->extradata && !ctx->parsed_extradata) { >> > +av_log(avctx, AV_LOG_INFO, "extra data is not supported >> yet.\n"); >> > +return AVERROR_PATCHWELCOME; >> > +} >> > + >> > +if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { >> > +next = buf_size; >> > +} else { >> > +next = find_frame_end(s, buf, buf_size); >> > +if (ff_combine_frame(pc, next, , _size) < 0) { >> > +*poutbuf = NULL; >> > +*poutbuf_size = 0; >> > +return buf_size; >> > +} >> > +} >> > + >> > +is_dummy_buf &= (dummy_buf == buf); >> > + >> > +if (!is_dummy_buf) >> > +parse_nal_units(s, buf, buf_size, avctx); >> > + >> > +*poutbuf = buf; >> > +*poutbuf_size = buf_size; >> > +return next; >> > + >> > +} >> > + >> > +static const CodedBitstreamUnitType
[FFmpeg-devel] [PATCH v2 11/11] avcodec: add vvdec H.266/VVC decoder
you can download test clips here: https://www.itu.int/wftp3/av-arch/jvet-site/bitstream_exchange/VVC/under_test/VTM-11.0/ 76.71% (191/249) clips are md5 matched with VTM 11: passed: 10b400_A_Bytedance_2.bit 10b400_B_Bytedance_2.bit 8b400_A_Bytedance_2.bit 8b400_B_Bytedance_2.bit 8b420_A_Bytedance_2.bit 8b420_B_Bytedance_2.bit ACTPIC_A_Huawei_3.bit ACTPIC_B_Huawei_3.bit ACTPIC_C_Huawei_3.bit AFF_A_HUAWEI_2.bit AFF_B_HUAWEI_2.bit ALF_A_Huawei_3.bit ALF_B_Huawei_3.bit ALF_C_KDDI_2.bit ALF_D_Qualcomm_2.bit AMVR_A_HHI_3.bit AMVR_B_HHI_3.bit APSALF_A_Qualcomm_2.bit APSLMCS_A_Dolby_3.bit APSLMCS_B_Dolby_3.bit APSLMCS_C_Dolby_2.bit APSMULT_A_MediaTek_3.bit APSMULT_B_MediaTek_3.bit AUD_A_Broadcom_3.bit BCW_A_MediaTek_3.bit BCW_A_MediaTek_4.bit BDOF_A_MediaTek_3.bit BDOF_A_MediaTek_4.bit BDPCM_A_Orange_2.bit CCALF_A_Sharp_3.bit CCALF_B_Sharp_3.bit CCALF_C_Sharp_3.bit CCALF_D_Sharp_3.bit CCLM_A_KDDI_1.bit CIIP_A_MediaTek_3.bit CIIP_A_MediaTek_4.bit CodingToolsSets_A_Tencent_2.bit CodingToolsSets_B_Tencent_2.bit CodingToolsSets_C_Tencent_2.bit CodingToolsSets_D_Tencent_2.bit CROP_A_Panasonic_3.bit CROP_B_Panasonic_4.bit CST_A_MediaTek_3.bit CTU_A_MediaTek_3.bit CTU_A_MediaTek_4.bit CTU_B_MediaTek_3.bit CTU_B_MediaTek_4.bit CTU_C_MediaTek_3.bit CTU_C_MediaTek_4.bit CUBEMAP_A_MediaTek_3.bit CUBEMAP_B_MediaTek_3.bit CUBEMAP_C_MediaTek_3.bit DEBLOCKING_A_Sharp_3.bit DEBLOCKING_B_Sharp_2.bit DEBLOCKING_C_Huawei_3.bit DEBLOCKING_E_Ericsson_2.bit DEBLOCKING_E_Ericsson_3.bit DEBLOCKING_F_Ericsson_1.bit DEBLOCKING_F_Ericsson_2.bit DMVR_A_Huawei_3.bit DMVR_B_KDDI_3.bit DPB_A_Sharplabs_2.bit DPB_B_Sharplabs_2.bit DQ_A_HHI_3.bit ENT444HIGHTIER_A_Sony_3.bit ENT444HIGHTIER_B_Sony_3.bit ENT444HIGHTIER_C_Sony_3.bit ENT444HIGHTIER_D_Sony_3.bit ENT444MAINTIER_A_Sony_3.bit ENT444MAINTIER_B_Sony_3.bit ENT444MAINTIER_C_Sony_3.bit ENT444MAINTIER_D_Sony_3.bit ENTHIGHTIER_A_Sony_3.bit ENTHIGHTIER_B_Sony_3.bit ENTHIGHTIER_C_Sony_3.bit ENTHIGHTIER_D_Sony_3.bit ENTMAINTIER_A_Sony_3.bit ENTMAINTIER_B_Sony_3.bit ENTMAINTIER_C_Sony_3.bit ENTMAINTIER_D_Sony_3.bit ENTROPY_A_Chipsnmedia_2.bit ENTROPY_A_Qualcomm_2.bit ENTROPY_B_Sharp_2.bit ERP_A_MediaTek_3.bit FILLER_A_Bytedance_1.bit GPM_A_Alibaba_3.bit HLG_A_NHK_2.bit HLG_B_NHK_2.bit HRD_A_Fujitsu_3.bit HRD_B_Fujitsu_2.bit IBC_A_Tencent_2.bit IBC_B_Tencent_2.bit IBC_C_Tencent_2.bit IBC_D_Tencent_2.bit IP_B_Nokia_1.bit ISP_A_HHI_3.bit ISP_B_HHI_3.bit JCCR_A_Nokia_2.bit JCCR_B_Nokia_2.bit JCCR_C_HHI_3.bit JCCR_E_Nokia_1.bit JCCR_F_Nokia_1.bit LFNST_A_LGE_3.bit LFNST_B_LGE_3.bit LFNST_C_HHI_3.bit LMCS_A_Dolby_3.bit LOSSLESS_A_HHI_3.bit LOSSLESS_B_HHI_3.bit LTRP_A_ERICSSON_2.bit MERGE_A_Qualcomm_2.bit MERGE_B_Qualcomm_2.bit MERGE_C_Qualcomm_2.bit MERGE_D_Qualcomm_2.bit MERGE_E_Qualcomm_2.bit MERGE_F_Qualcomm_2.bit MERGE_G_Qualcomm_2.bit MERGE_H_Qualcomm_2.bit MERGE_I_Qualcomm_2.bit MERGE_J_Qualcomm_2.bit MIP_A_HHI_3.bit MIP_B_HHI_3.bit MPM_A_LGE_3.bit MRLP_A_HHI_2.bit MRLP_B_HHI_2.bit MTS_A_LGE_3.bit MTS_B_LGE_3.bit MTS_LFNST_A_LGE_3.bit MTS_LFNST_B_LGE_3.bit MVCOMP_A_Sharp_2.bit PDPC_A_Qualcomm_3.bit PDPC_B_Qualcomm_3.bit PDPC_C_Qualcomm_2.bit PHSH_B_Sharp_1.bit POC_A_Nokia_1.bit POUT_A_Sharplabs_2.bit PPS_B_Bytedance_1.bit PPS_C_Bytedance_1.bit PQ_A_Dolby_1.bit PROF_A_Interdigital_3.bit PROF_B_Interdigital_3.bit PSEXT_A_Nokia_2.bit PSEXT_B_Nokia_2.bit QTBTT_A_MediaTek_3.bit QTBTT_A_MediaTek_4.bit QUANT_A_Huawei_2.bit QUANT_B_Huawei_2.bit QUANT_C_Huawei_2.bit QUANT_D_Huawei_2.bit RAP_C_HHI_1.bit RAP_D_HHI_1.bit RPL_A_ERICSSON_2.bit SAO_A_SAMSUNG_3.bit SAO_B_SAMSUNG_3.bit SAO_C_SAMSUNG_3.bit SbTMVP_A_Bytedance_3.bit SbTMVP_B_Bytedance_3.bit SBT_A_HUAWEI_2.bit SCALING_A_InterDigital_1.bit SCALING_B_InterDigital_1.bit SCALING_C_InterDigital_1.bit SDH_A_Dolby_2.bit SLICES_A_HUAWEI_2.bit SMVD_A_HUAWEI_2.bit SPS_A_Bytedance_1.bit SPS_B_Bytedance_1.bit SPS_C_Bytedance_1.bit TEMPSCAL_A_Panasonic_4.bit TEMPSCAL_C_Panasonic_3.bit TILE_A_Nokia_2.bit TILE_B_Nokia_2.bit TILE_C_Nokia_2.bit TILE_D_Nokia_2.bit TILE_E_Nokia_2.bit TILE_F_Nokia_2.bit TILE_G_Nokia_2.bit TMVP_A_Chipsnmedia_3.bit TMVP_B_Chipsnmedia_3.bit TMVP_C_Chipsnmedia_3.bit TMVP_D_Chipsnmedia_3.bit TRANS_A_Chipsnmedia_2.bit TRANS_B_Chipsnmedia_2.bit TRANS_C_Chipsnmedia_2.bit TRANS_D_Chipsnmedia_2.bit WPP_A_Sharp_3.bit WPP_B_Sharp_2.bit WP_A_InterDigital_3.bit WP_B_InterDigital_3.bit WRAP_A_InterDigital_4.bit WRAP_B_InterDigital_4.bit WRAP_C_InterDigital_4.bit WRAP_D_InterDigital_4.bit --- configure | 5 +- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/libvvdec.cpp | 244 4 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 libavcodec/libvvdec.cpp diff --git a/configure b/configure index b41f2af151..cefdff75fe 100755 --- a/configure +++ b/configure @@ -285,6 +285,7 @@ External library support: --enable-libvorbis enable Vorbis en/decoding via libvorbis, native implementation exists [no] --enable-libvpx
[FFmpeg-devel] [PATCH v2 10/11] avcodec: add vvc metadata bsf
use following command to test: ffmpeg -i in.bin -c:v copy -bsf vvc_metadata -f vvc out.bin 79.11%(197/249) can bit match with original clips 6.83%(17/249) are not bit match, the original clips has redundant emulation prevent bytes other all failed since vvdec failed to decode the first frame --- configure | 1 + libavcodec/Makefile| 1 + libavcodec/bitstream_filters.c | 1 + libavcodec/vvc_metadata_bsf.c | 243 + 4 files changed, 246 insertions(+) create mode 100644 libavcodec/vvc_metadata_bsf.c diff --git a/configure b/configure index 5ff743d9c2..b41f2af151 100755 --- a/configure +++ b/configure @@ -3184,6 +3184,7 @@ mjpeg2jpeg_bsf_select="jpegtables" mpeg2_metadata_bsf_select="cbs_mpeg2" trace_headers_bsf_select="cbs" vp9_metadata_bsf_select="cbs_vp9" +vvc_metadata_bsf_select="cbs_h266" # external libraries aac_at_decoder_deps="audiotoolbox" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 30e9a92e9f..d4cd64e43c 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1166,6 +1166,7 @@ OBJS-$(CONFIG_VP9_METADATA_BSF) += vp9_metadata_bsf.o OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)+= vp9_raw_reorder_bsf.o OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF) += vp9_superframe_split_bsf.o +OBJS-$(CONFIG_VVC_METADATA_BSF) += vvc_metadata_bsf.o # thread libraries OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c index b26d6a910e..001a7bb3a4 100644 --- a/libavcodec/bitstream_filters.c +++ b/libavcodec/bitstream_filters.c @@ -60,6 +60,7 @@ extern const AVBitStreamFilter ff_vp9_metadata_bsf; extern const AVBitStreamFilter ff_vp9_raw_reorder_bsf; extern const AVBitStreamFilter ff_vp9_superframe_bsf; extern const AVBitStreamFilter ff_vp9_superframe_split_bsf; +extern const AVBitStreamFilter ff_vvc_metadata_bsf; #include "libavcodec/bsf_list.c" diff --git a/libavcodec/vvc_metadata_bsf.c b/libavcodec/vvc_metadata_bsf.c new file mode 100644 index 00..a7deced47c --- /dev/null +++ b/libavcodec/vvc_metadata_bsf.c @@ -0,0 +1,243 @@ +/* + * 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 Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/common.h" +#include "libavutil/opt.h" + +#include "bsf.h" +#include "bsf_internal.h" +#include "cbs.h" +#include "cbs_h266.h" +#include "vvc.h" + +enum { +PASS, +INSERT, +REMOVE, +}; + +typedef struct VVCMetadataContext { +const AVClass *class; + +CodedBitstreamContext *input; +CodedBitstreamContext *output; +CodedBitstreamFragment access_unit; + +H266RawAUD aud_nal; + +int aud; + +} VVCMetadataContext; + +static int vvc_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) +{ +VVCMetadataContext *ctx = bsf->priv_data; +CodedBitstreamFragment *au = >access_unit; +uint8_t *side_data; +int side_data_size; +int err; + +side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, +_data_size); +if (!side_data_size) +return 0; + +err = ff_cbs_read(ctx->input, au, side_data, side_data_size); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n"); +return err; +} + +err = ff_cbs_write_fragment_data(ctx->output, au); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n"); +return err; +} + +side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, au->data_size); +if (!side_data) +return AVERROR(ENOMEM); +memcpy(side_data, au->data, au->data_size); + +ff_cbs_fragment_reset(au); + +return 0; +} + +static int vvc_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) +{ +VVCMetadataContext *ctx = bsf->priv_data; +CodedBitstreamFragment *au = >access_unit; +int err, i; + +err = ff_bsf_get_packet_ref(bsf, pkt); +if (err < 0) +return err; + +err = vvc_metadata_update_side_data(bsf, pkt); +if (err < 0) +goto fail; + +err = ff_cbs_read_packet(ctx->input, au, pkt); +if (err < 0) { +
[FFmpeg-devel] [PATCH v2 09/11] avformat: add h266/vvc muxer
--- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/rawenc.c | 25 + 3 files changed, 27 insertions(+) diff --git a/libavformat/Makefile b/libavformat/Makefile index 4a5406da38..0253aa7d5a 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -564,6 +564,7 @@ OBJS-$(CONFIG_VPK_DEMUXER) += vpk.o OBJS-$(CONFIG_VPLAYER_DEMUXER) += vplayerdec.o subtitles.o OBJS-$(CONFIG_VQF_DEMUXER) += vqf.o OBJS-$(CONFIG_VVC_DEMUXER) += vvcdec.o rawdec.o +OBJS-$(CONFIG_VVC_MUXER) += rawenc.o OBJS-$(CONFIG_W64_DEMUXER) += wavdec.o w64.o pcm.o OBJS-$(CONFIG_W64_MUXER) += wavenc.o w64.o OBJS-$(CONFIG_WAV_DEMUXER) += wavdec.o pcm.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index fdbf424e31..ae9a98a18e 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -463,6 +463,7 @@ extern AVInputFormat ff_vpk_demuxer; extern AVInputFormat ff_vplayer_demuxer; extern AVInputFormat ff_vqf_demuxer; extern AVInputFormat ff_vvc_demuxer; +extern AVOutputFormat ff_vvc_muxer; extern AVInputFormat ff_w64_demuxer; extern AVOutputFormat ff_w64_muxer; extern AVInputFormat ff_wav_demuxer; diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c index 32704f9bfd..5eb95f069c 100644 --- a/libavformat/rawenc.c +++ b/libavformat/rawenc.c @@ -372,6 +372,31 @@ AVOutputFormat ff_hevc_muxer = { }; #endif +#if CONFIG_VVC_MUXER +static int vvc_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt) +{ +if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 && + AV_RB24(pkt->data) != 0x01) { +//TODO: fixed this after vvc codec defined in http://mp4ra.org/#/codecs +av_log(s, AV_LOG_ERROR, "vvc: mp4 to annexb is not supported\n"); +return AVERROR_PATCHWELCOME; +} +return 1; +} + +AVOutputFormat ff_vvc_muxer = { +.name = "vvc", +.long_name = NULL_IF_CONFIG_SMALL("raw VVC video"), +.extensions= "hevc,h266,266", +.audio_codec = AV_CODEC_ID_NONE, +.video_codec = AV_CODEC_ID_VVC, +.write_header = force_one_stream, +.write_packet = ff_raw_write_packet, +.check_bitstream = vvc_check_bitstream, +.flags = AVFMT_NOTIMESTAMPS, +}; +#endif + #if CONFIG_M4V_MUXER AVOutputFormat ff_m4v_muxer = { .name = "m4v", -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 08/11] avcodec: add vvc parser
--- configure | 1 + libavcodec/Makefile | 1 + libavcodec/parsers.c| 1 + libavcodec/vvc_parser.c | 289 4 files changed, 292 insertions(+) create mode 100644 libavcodec/vvc_parser.c diff --git a/configure b/configure index 4935625260..5ff743d9c2 100755 --- a/configure +++ b/configure @@ -3167,6 +3167,7 @@ mpegaudio_parser_select="mpegaudioheader" mpegvideo_parser_select="mpegvideo" mpeg4video_parser_select="h263dsp mpegvideo qpeldsp" vc1_parser_select="vc1dsp" +vcc_parser_select="cbs_h266" # bitstream_filters aac_adtstoasc_bsf_select="adts_header" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 4b406adfce..30e9a92e9f 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1123,6 +1123,7 @@ OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \ OBJS-$(CONFIG_VP3_PARSER) += vp3_parser.o OBJS-$(CONFIG_VP8_PARSER) += vp8_parser.o OBJS-$(CONFIG_VP9_PARSER) += vp9_parser.o +OBJS-$(CONFIG_VVC_PARSER) += vvc_parser.o OBJS-$(CONFIG_WEBP_PARSER) += webp_parser.o OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c index 83271d95a3..060c0931b6 100644 --- a/libavcodec/parsers.c +++ b/libavcodec/parsers.c @@ -70,6 +70,7 @@ extern AVCodecParser ff_vorbis_parser; extern AVCodecParser ff_vp3_parser; extern AVCodecParser ff_vp8_parser; extern AVCodecParser ff_vp9_parser; +extern AVCodecParser ff_vvc_parser; extern AVCodecParser ff_webp_parser; extern AVCodecParser ff_xma_parser; diff --git a/libavcodec/vvc_parser.c b/libavcodec/vvc_parser.c new file mode 100644 index 00..3e1ab29185 --- /dev/null +++ b/libavcodec/vvc_parser.c @@ -0,0 +1,289 @@ +/* + * VVC parser + * + * Copyright (C) 2029 Nuo Mi + * + * 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 Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "cbs.h" +#include "cbs_h266.h" +#include "internal.h" +#include "parser.h" + +#define START_CODE 0x01 ///< start_code_prefix_one_3bytes + +#define IS_SLICE(nut) (nut <= VVC_RASL_NUT || (nut >= VVC_IDR_W_RADL && nut <= VVC_GDR_NUT)) + +typedef struct VVCParserContext { +ParseContext pc; +CodedBitstreamContext *cbc; +CodedBitstreamFragment picture_unit; +int parsed_extradata; +} VVCParserContext; + +static const enum AVPixelFormat pix_fmts_8bit[] = { +AV_PIX_FMT_GRAY8, AV_PIX_FMT_YUV420P, +AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P +}; + +static const enum AVPixelFormat pix_fmts_10bit[] = { +AV_PIX_FMT_GRAY10, AV_PIX_FMT_YUV420P10, +AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10 +}; + +static int get_format(const H266RawSPS* sps) +{ +switch (sps->sps_bitdepth_minus8) { +case 0: +return pix_fmts_8bit[sps->sps_chroma_format_idc]; +case 2: +return pix_fmts_10bit[sps->sps_chroma_format_idc]; +} +return AV_PIX_FMT_NONE; +} + +/** + * Find the end of the current frame in the bitstream. + * @return the position of the first byte of the next frame, or END_NOT_FOUND + */ +static int find_frame_end(AVCodecParserContext *s, const uint8_t *buf, + int buf_size) +{ +VVCParserContext *ctx = s->priv_data; +ParseContext *pc = >pc; +int i; + +for (i = 0; i < buf_size; i++) { +int nut; + +pc->state64 = (pc->state64 << 8) | buf[i]; + +if (((pc->state64 >> 3 * 8) & 0xFF) != START_CODE) +continue; + +nut = (pc->state64 >> (8 + 3)) & 0x1F; +// Beginning of access unit +if ((nut >= VVC_OPI_NUT && nut <= VVC_EOB_NUT && nut != VVC_PH_NUT) || +nut == VVC_PREFIX_SEI_NUT || +(nut >= VVC_RSV_NVCL_26 && nut <= VVC_UNSPEC_31)) { +if (pc->frame_start_found) { +pc->frame_start_found = 0; +return i - 5; +} +} else if (nut == VVC_PH_NUT || IS_SLICE(nut)) { +int sh_picture_header_in_slice_header_flag = buf[i] >> 7; + +if (nut == VVC_PH_NUT || sh_picture_header_in_slice_header_flag) { +if (!pc->frame_start_found) { +pc->frame_start_found = 1; +} else { // First slice of next
[FFmpeg-devel] [PATCH v2 07/11] avcodec/h2645_parse: add nal header parser for h266/vvc
--- libavcodec/h2645_parse.c | 74 ++-- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c index a36ef4f5a0..35f9d035a9 100644 --- a/libavcodec/h2645_parse.c +++ b/libavcodec/h2645_parse.c @@ -1,5 +1,5 @@ /* - * H.264/HEVC common parsing code + * H.264/HEVC/VVC common parsing code * * This file is part of FFmpeg. * @@ -27,6 +27,7 @@ #include "libavutil/mem.h" #include "bytestream.h" +#include "vvc.h" #include "hevc.h" #include "h264.h" #include "h2645_parse.h" @@ -146,6 +147,47 @@ nsc: return si; } +static const char *const vvc_nal_type_name[32] = { +"TRAIL_NUT", // VVC_TRAIL_NUT +"STSA_NUT", // VVC_STSA_NUT +"RADL_NUT", // VVC_RADL_NUT +"RASL_NUT", // VVC_RASL_NUT +"RSV_VCL_4", // VVC_RSV_VCL_4 +"RSV_VCL_5", // VVC_RSV_VCL_5 +"RSV_VCL_6", // VVC_RSV_VCL_6 +"IDR_W_RADL", // VVC_IDR_W_RADL +"IDR_N_LP", // VVC_IDR_N_LP +"CRA_NUT", // VVC_CRA_NUT +"GDR_NUT", // VVC_GDR_NUT +"RSV_IRAP_11", // VVC_RSV_IRAP_11 +"OPI_NUT", // VVC_OPI_NUT +"DCI_NUT", // VVC_DCI_NUT +"VPS_NUT", // VVC_VPS_NUT +"SPS_NUT", // VVC_SPS_NUT +"PPS_NUT", // VVC_PPS_NUT +"PREFIX_APS_NUT",// VVC_PREFIX_APS_NUT +"SUFFIX_APS_NUT",// VVC_SUFFIX_APS_NUT +"PH_NUT", // VVC_PH_NUT +"AUD_NUT", // VVC_AUD_NUT +"EOS_NUT", // VVC_EOS_NUT +"EOB_NUT", // VVC_EOB_NUT +"PREFIX_SEI_NUT",// VVC_PREFIX_SEI_NUT +"SUFFIX_SEI_NUT",// VVC_SUFFIX_SEI_NUT +"FD_NUT", // VVC_FD_NUT +"RSV_NVCL_26", // VVC_RSV_NVCL_26 +"RSV_NVCL_27", // VVC_RSV_NVCL_27 +"UNSPEC_28", // VVC_UNSPEC_28 +"UNSPEC_29", // VVC_UNSPEC_29 +"UNSPEC_30", // VVC_UNSPEC_30 +"UNSPEC_31", // VVC_UNSPEC_31 +}; + +static const char *vvc_nal_unit_name(int nal_type) +{ +av_assert0(nal_type >= 0 && nal_type < 32); +return vvc_nal_type_name[nal_type]; +} + static const char *const hevc_nal_type_name[64] = { "TRAIL_N", // HEVC_NAL_TRAIL_N "TRAIL_R", // HEVC_NAL_TRAIL_R @@ -289,6 +331,31 @@ static int get_bit_length(H2645NAL *nal, int skip_trailing_zeros) * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit, * 0 otherwise */ +static int vvc_parse_nal_header(H2645NAL *nal, void *logctx) +{ +GetBitContext *gb = >gb; + +if (get_bits1(gb) != 0) //forbidden_zero_bit +return AVERROR_INVALIDDATA; + +skip_bits1(gb); //nuh_reserved_zero_bit + +nal->nuh_layer_id = get_bits(gb, 6); +nal->type = get_bits(gb, 5); +nal->temporal_id = get_bits(gb, 3) - 1; +if (nal->temporal_id < 0) +return AVERROR_INVALIDDATA; + +if ((nal->type >= VVC_IDR_W_RADL && nal->type <= VVC_RSV_IRAP_11) && nal->temporal_id) +return AVERROR_INVALIDDATA; + +av_log(logctx, AV_LOG_DEBUG, + "nal_unit_type: %d(%s), nuh_layer_id: %d, temporal_id: %d\n", + nal->type, vvc_nal_unit_name(nal->type), nal->nuh_layer_id, nal->temporal_id); + +return 0; +} + static int hevc_parse_nal_header(H2645NAL *nal, void *logctx) { GetBitContext *gb = >gb; @@ -503,8 +570,9 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, /* Reset type in case it contains a stale value from a previously parsed NAL */ nal->type = 0; - -if (codec_id == AV_CODEC_ID_HEVC) +if (codec_id == AV_CODEC_ID_VVC) +ret = vvc_parse_nal_header(nal, logctx); +else if (codec_id == AV_CODEC_ID_HEVC) ret = hevc_parse_nal_header(nal, logctx); else ret = h264_parse_nal_header(nal, logctx); -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 03/11] avformat: add vvc raw demux
--- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/vvcdec.c | 61 3 files changed, 63 insertions(+) create mode 100644 libavformat/vvcdec.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 3a8fbcbe5f..4a5406da38 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -563,6 +563,7 @@ OBJS-$(CONFIG_VOC_MUXER) += vocenc.o voc.o OBJS-$(CONFIG_VPK_DEMUXER) += vpk.o OBJS-$(CONFIG_VPLAYER_DEMUXER) += vplayerdec.o subtitles.o OBJS-$(CONFIG_VQF_DEMUXER) += vqf.o +OBJS-$(CONFIG_VVC_DEMUXER) += vvcdec.o rawdec.o OBJS-$(CONFIG_W64_DEMUXER) += wavdec.o w64.o pcm.o OBJS-$(CONFIG_W64_MUXER) += wavenc.o w64.o OBJS-$(CONFIG_WAV_DEMUXER) += wavdec.o pcm.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 0e0caaad39..fdbf424e31 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -462,6 +462,7 @@ extern AVOutputFormat ff_voc_muxer; extern AVInputFormat ff_vpk_demuxer; extern AVInputFormat ff_vplayer_demuxer; extern AVInputFormat ff_vqf_demuxer; +extern AVInputFormat ff_vvc_demuxer; extern AVInputFormat ff_w64_demuxer; extern AVOutputFormat ff_w64_muxer; extern AVInputFormat ff_wav_demuxer; diff --git a/libavformat/vvcdec.c b/libavformat/vvcdec.c new file mode 100644 index 00..149f39f28e --- /dev/null +++ b/libavformat/vvcdec.c @@ -0,0 +1,61 @@ +/* + * RAW VVC video demuxer + * Copyright (c) 2020 Nuo Mi + * + * 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 Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/vvc.h" + +#include "avformat.h" +#include "rawdec.h" + +static int vvc_probe(const AVProbeData *p) +{ +uint32_t code = -1; +int sps = 0, pps = 0, irap = 0; +int i; + +for (i = 0; i < p->buf_size - 1; i++) { +code = (code << 8) + p->buf[i]; +if ((code & 0xff00) == 0x100) { +uint8_t nal2 = p->buf[i + 1]; +int type = (nal2 & 0xF8) >> 3; + +if (code & 0xc0) // forbidden_zero_bit and nuh_reserved_zero_bit +return 0; + +if ((nal2 & 0x7) == 0) // nuh_temporal_id_plus1 +return 0; + +switch (type) { +case VVC_SPS_NUT: sps++; break; +case VVC_PPS_NUT: pps++; break; +case VVC_IDR_N_LP: +case VVC_IDR_W_RADL: +case VVC_CRA_NUT: +case VVC_GDR_NUT: irap++; break; +} +} +} + +if (sps && pps && irap) +return AVPROBE_SCORE_EXTENSION + 1; // 1 more than .mpg +return 0; +} + +FF_DEF_RAWVIDEO_DEMUXER(vvc, "raw VVC video", vvc_probe, "h266,266,vvc", AV_CODEC_ID_VVC) -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 02/11] avcodec: add vvc codec id and profiles
--- libavcodec/avcodec.h| 2 ++ libavcodec/codec_desc.c | 8 libavcodec/codec_id.h | 2 ++ libavcodec/profiles.c | 5 + libavcodec/profiles.h | 1 + 5 files changed, 18 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 1d3099d50a..13a3191b53 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1961,6 +1961,8 @@ typedef struct AVCodecContext { #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3 #define FF_PROFILE_HEVC_REXT4 +#define FF_PROFILE_VVC_MAIN_10 1 + #define FF_PROFILE_AV1_MAIN 0 #define FF_PROFILE_AV1_HIGH 1 #define FF_PROFILE_AV1_PROFESSIONAL 2 diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 14757bf31b..a7594f9004 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1426,6 +1426,14 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Microsoft Paint (MSP) version 2"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, }, +{ +.id= AV_CODEC_ID_VVC, +.type = AVMEDIA_TYPE_VIDEO, +.name = "vvc", +.long_name = NULL_IF_CONFIG_SMALL("H.266 / VVC (Versatile Video Coding)"), +.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_REORDER, +.profiles = NULL_IF_CONFIG_SMALL(ff_vvc_profiles), +}, { .id= AV_CODEC_ID_Y41P, .type = AVMEDIA_TYPE_VIDEO, diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 6133e03bb9..7a8a896bfe 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -244,6 +244,8 @@ enum AVCodecID { AV_CODEC_ID_PGX, AV_CODEC_ID_AVS3, AV_CODEC_ID_MSP2, +AV_CODEC_ID_VVC, +#define AV_CODEC_ID_H266 AV_CODEC_ID_VVC AV_CODEC_ID_Y41P = 0x8000, AV_CODEC_ID_AVRP, diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c index e59a3a5c12..6dd6594319 100644 --- a/libavcodec/profiles.c +++ b/libavcodec/profiles.c @@ -74,6 +74,11 @@ const AVProfile ff_h264_profiles[] = { { FF_PROFILE_UNKNOWN }, }; +const AVProfile ff_vvc_profiles[] = { +{ FF_PROFILE_VVC_MAIN_10, "Main 10" }, +{ FF_PROFILE_UNKNOWN }, +}; + const AVProfile ff_hevc_profiles[] = { { FF_PROFILE_HEVC_MAIN, "Main"}, { FF_PROFILE_HEVC_MAIN_10, "Main 10" }, diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h index 6baaba5701..41a19aa9ad 100644 --- a/libavcodec/profiles.h +++ b/libavcodec/profiles.h @@ -61,6 +61,7 @@ extern const AVProfile ff_dca_profiles[]; extern const AVProfile ff_dnxhd_profiles[]; extern const AVProfile ff_h264_profiles[]; extern const AVProfile ff_hevc_profiles[]; +extern const AVProfile ff_vvc_profiles[]; extern const AVProfile ff_jpeg2000_profiles[]; extern const AVProfile ff_mpeg2_video_profiles[]; extern const AVProfile ff_mpeg4_video_profiles[]; -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 5/6] avcodec: add h266 parser
On Mon, Dec 21, 2020 at 11:15 PM James Almer wrote: > On 12/21/2020 3:07 AM, Nuo Mi wrote: > > --- > > configure| 3 + > > libavcodec/Makefile | 1 + > > libavcodec/h2645_parse.c | 73 +- > > libavcodec/h266_parser.c | 284 +++ > > libavcodec/parsers.c | 1 + > > 5 files changed, 360 insertions(+), 2 deletions(-) > > create mode 100644 libavcodec/h266_parser.c > > > > diff --git a/configure b/configure > > index 90914752f1..77272948e3 100755 > > --- a/configure > > +++ b/configure > > @@ -2354,6 +2354,7 @@ CONFIG_EXTRA=" > > cbs_av1 > > cbs_h264 > > cbs_h265 > > +cbs_h266 > > cbs_jpeg > > cbs_mpeg2 > > cbs_vp9 > > @@ -2622,6 +2623,7 @@ threads_if_any="$THREADS_LIST" > > cbs_av1_select="cbs" > > cbs_h264_select="cbs" > > cbs_h265_select="cbs" > > +cbs_h266_select="cbs" > > These two chunks belong to the previous patch adding cbs_h266. Otherwise > CONFIG_CBS_H266 will not be defined for Makefile to use. > fixed > > > > > diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c > > index 0f98b49fbe..2600371d3c 100644 > > --- a/libavcodec/h2645_parse.c > > +++ b/libavcodec/h2645_parse.c > > cbs_h266 needs the changes to this file you're adding here to split > NALUs, so it should be done in a new separate patch applied before patch > 4/6. > done > > > > +static int h266_parse_nal_header(H2645NAL *nal, void *logctx) > > +{ > > +GetBitContext *gb = >gb; > > + > > +if (get_bits1(gb) != 0) //forbidden_zero_bit > > +return AVERROR_INVALIDDATA; > > + > > +if (get_bits1(gb) != 0) //nuh_reserved_zero_bit > > This one should be ignored, otherwise bitstreams compliant with an > hypotetical future revision of the spec that defines this bit will not > work, when they should. > > But current current cbs uses fixed to check the server value, like fixed(24, general_reserved_zero_33bits, 0); it always return error for none zero > > +return AVERROR_INVALIDDATA; > > + > > +nal->nuh_layer_id = get_bits(gb, 6); > > +nal->type = get_bits(gb, 5); > > +nal->temporal_id = get_bits(gb, 3) - 1; > > +if (nal->temporal_id < 0) > > +return AVERROR_INVALIDDATA; > > + > > +if ((nal->type >= H266_NAL_IDR_W_RADL && nal->type <= > H266_NAL_RSV_IRAP_11) && nal->temporal_id) > > +return AVERROR_INVALIDDATA; > > + > > +av_log(logctx, AV_LOG_DEBUG, > > + "nal_unit_type: %d(%s), nuh_layer_id: %d, temporal_id: %d\n", > > + nal->type, h266_nal_unit_name(nal->type), nal->nuh_layer_id, > nal->temporal_id); > > + > > +return 0; > > +} > > + > > static int hevc_parse_nal_header(H2645NAL *nal, void *logctx) > > { > > GetBitContext *gb = >gb; > > @@ -503,8 +571,9 @@ int ff_h2645_packet_split(H2645Packet *pkt, const > uint8_t *buf, int length, > > > > /* Reset type in case it contains a stale value from a > previously parsed NAL */ > > nal->type = 0; > > - > > -if (codec_id == AV_CODEC_ID_HEVC) > > +if (codec_id == AV_CODEC_ID_H266) > > +ret = h266_parse_nal_header(nal, logctx); > > +else if (codec_id == AV_CODEC_ID_HEVC) > > ret = hevc_parse_nal_header(nal, logctx); > > else > > ret = h264_parse_nal_header(nal, logctx); > > diff --git a/libavcodec/h266_parser.c b/libavcodec/h266_parser.c > > new file mode 100644 > > index 00..e472e51d59 > > --- /dev/null > > +++ b/libavcodec/h266_parser.c > > @@ -0,0 +1,284 @@ > > +/* > > + * h266 parser > > + * > > + * Copyright (C) 2029 Nuo Mi > > + * > > + * 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 Software > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > 02110-1301 USA > > + */ > > + > > +#include "cbs.h" > > +#include "cbs_h266.h" > > +#include "internal.h" > > +#include "parser.h" > > + > > +#define START_CODE 0x01 ///< start_code_prefix_one_3bytes > > + > > +#define IS_SLICE(nut) (nut <= H266_NAL_RASL || (nut >= > H266_NAL_IDR_W_RADL && nut <= H266_NAL_GDR_NUT)) > > + > > +typedef struct H266ParserContext { > > +ParseContext pc; > > +CodedBitstreamContext *cbc; > > +CodedBitstreamFragment picture_unit; > > +int parsed_extradata; > > +}
[FFmpeg-devel] [PATCH v4 3/3] avformat/mxfenc: prefer to use the configured metadta
From: Limin Wang The metadata company_name, product_name, product_version from input file will be deleted to avoid overwriting information Please to test with below command: ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf and ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy \ -metadata company_name="xxx" \ -metadata product_name="xxx" \ -metadata product_version="xxx" \ out.mxf Signed-off-by: Limin Wang --- fftools/ffmpeg_opt.c | 3 +++ libavformat/mxfenc.c | 12 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index c295514..493763b 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2650,6 +2650,9 @@ loop_end: if(o->recording_time != INT64_MAX) av_dict_set(>metadata, "duration", NULL, 0); av_dict_set(>metadata, "creation_time", NULL, 0); +av_dict_set(>metadata, "company_name", NULL, 0); +av_dict_set(>metadata, "product_name", NULL, 0); +av_dict_set(>metadata, "product_version", NULL, 0); } if (!o->metadata_streams_manual) for (i = of->ost_index; i < nb_output_streams; i++) { diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index d8678c9..5244211 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -722,16 +722,20 @@ static void mxf_write_identification(AVFormatContext *s) { MXFContext *mxf = s->priv_data; AVIOContext *pb = s->pb; -const char *company = "FFmpeg"; -const char *product = s->oformat != _mxf_opatom_muxer ? "OP1a Muxer" : "OPAtom Muxer"; -const char *version; +AVDictionaryEntry *com_entry = av_dict_get(s->metadata, "company_name", NULL, 0); +AVDictionaryEntry *product_entry = av_dict_get(s->metadata, "product_name", NULL, 0); +AVDictionaryEntry *version_entry = av_dict_get(s->metadata, "product_version", NULL, 0); +const char *company = com_entry ? com_entry->value : "FFmpeg"; +const char *product = product_entry ? product_entry->value : s->oformat != _mxf_opatom_muxer ? "OP1a Muxer" : "OPAtom Muxer"; +const char *version = NULL; +const char *product_version = version_entry ? version_entry->value : AV_STRINGIFY(LIBAVFORMAT_VERSION); int length; mxf_write_metadata_key(pb, 0x013000); PRINT_KEY(s, "identification key", pb->buf_ptr - 16); version = s->flags & AVFMT_FLAG_BITEXACT ? -"0.0.0" : AV_STRINGIFY(LIBAVFORMAT_VERSION); +"0.0.0" : product_version; length = 100 +mxf_utf16_local_tag_length(company) + mxf_utf16_local_tag_length(product) + mxf_utf16_local_tag_length(version); -- 1.8.3.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 2/3] avformat/udp: add memory alloc checks
From: Limin Wang Signed-off-by: Limin Wang --- libavformat/udp.c | 4 1 file changed, 4 insertions(+) diff --git a/libavformat/udp.c b/libavformat/udp.c index 088e30c..a7fbb94 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -903,6 +903,10 @@ static int udp_open(URLContext *h, const char *uri, int flags) if ((!is_output && s->circular_buffer_size) || (is_output && s->bitrate && s->circular_buffer_size)) { /* start the task going */ s->fifo = av_fifo_alloc(s->circular_buffer_size); +if (!s->fifo) { +ret = AVERROR(ENOMEM); +goto fail; +} ret = pthread_mutex_init(>mutex, NULL); if (ret != 0) { av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", strerror(ret)); -- 1.8.3.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 1/3] avformat/udp: return the error code instead of generic EIO
From: Limin Wang Signed-off-by: Limin Wang --- libavformat/udp.c | 61 --- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index 13c346a..088e30c 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -165,7 +165,7 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL, if (addr->sa_family == AF_INET) { if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , sizeof(mcastTTL)) < 0) { ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL)"); -return -1; +return ff_neterrno(); } } #endif @@ -173,7 +173,7 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL, if (addr->sa_family == AF_INET6) { if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, , sizeof(mcastTTL)) < 0) { ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_MULTICAST_HOPS)"); -return -1; +return ff_neterrno(); } } #endif @@ -193,7 +193,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr,struct soc mreq.imr_interface.s_addr = INADDR_ANY; if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *), sizeof(mreq)) < 0) { ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP)"); -return -1; +return ff_neterrno(); } } #endif @@ -206,7 +206,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr,struct soc mreq6.ipv6mr_interface = 0; if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, , sizeof(mreq6)) < 0) { ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP)"); -return -1; +return ff_neterrno(); } } #endif @@ -633,6 +633,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) char buf[256]; struct sockaddr_storage my_addr; socklen_t len; +int ret = AVERROR(EIO); h->is_streamed = 1; @@ -641,12 +642,12 @@ static int udp_open(URLContext *h, const char *uri, int flags) s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_RX_BUF_SIZE; if (s->sources) { -if (ff_ip_parse_sources(h, s->sources, >filters) < 0) +if ((ret = ff_ip_parse_sources(h, s->sources, >filters)) < 0) goto fail; } if (s->block) { -if (ff_ip_parse_blocks(h, s->block, >filters) < 0) +if ((ret = ff_ip_parse_blocks(h, s->block, >filters)) < 0) goto fail; } @@ -712,11 +713,11 @@ static int udp_open(URLContext *h, const char *uri, int flags) av_strlcpy(localaddr, buf, sizeof(localaddr)); } if (av_find_info_tag(buf, sizeof(buf), "sources", p)) { -if (ff_ip_parse_sources(h, buf, >filters) < 0) +if ((ret = ff_ip_parse_sources(h, buf, >filters)) < 0) goto fail; } if (av_find_info_tag(buf, sizeof(buf), "block", p)) { -if (ff_ip_parse_blocks(h, buf, >filters) < 0) +if ((ret = ff_ip_parse_blocks(h, buf, >filters)) < 0) goto fail; } if (!is_output && av_find_info_tag(buf, sizeof(buf), "timeout", p)) @@ -742,7 +743,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) if (!(flags & AVIO_FLAG_READ)) goto fail; } else { -if (ff_udp_set_remote_url(h, uri) < 0) +if ((ret = ff_udp_set_remote_url(h, uri)) < 0) goto fail; } @@ -763,15 +764,22 @@ static int udp_open(URLContext *h, const char *uri, int flags) */ if (s->reuse_socket > 0 || (s->is_multicast && s->reuse_socket < 0)) { s->reuse_socket = 1; -if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0) +if ((ret = setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket))) != 0) { +ret = ff_neterrno(); goto fail; +} } if (s->is_broadcast) { #ifdef SO_BROADCAST -if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), sizeof(s->is_broadcast)) != 0) +if ((ret = setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), sizeof(s->is_broadcast))) != 0) { +ret = ff_neterrno(); +goto fail; +} +#else +ret = AVERROR(EINVAL); +goto fail; #endif - goto fail; } /* Set the checksum coverage for UDP-Lite (RFC 3828) for sending and receiving. @@ -788,8 +796,10 @@ static int udp_open(URLContext *h, const char *uri, int flags) if (dscp >= 0) { dscp <<= 2; -if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , sizeof(dscp)) != 0) +if ((ret = setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , sizeof(dscp))) != 0) { +
Re: [FFmpeg-devel] [PATCH v3 3/3] avformat/mxfenc: prefer to use the existing metadata
On Sat, Jan 09, 2021 at 01:09:22AM +0100, Marton Balint wrote: > > > On Fri, 8 Jan 2021, Tobias Rapp wrote: > > > On 08.01.2021 11:01, lance.lmw...@gmail.com wrote: > > > On Fri, Jan 08, 2021 at 09:09:34AM +0100, Tobias Rapp wrote: > > > > On 08.01.2021 07:32, lance.lmw...@gmail.com wrote: > > > > > From: Limin Wang > > > > > > > > > > Please check metadata with below command: > > > > > ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy > > > > > out.mxf > > > > > ./ffmpeg -i out.mxf > > > > > > > > > > company_name: FFmpeg > > > > > product_name: OP1a Muxer > > > > > product_version : 58.65.101o > > > > > => > > > > > company_name: SONY > > > > > product_name: eVTR > > > > > product_version : 1.00 > > > > > > > > > > So need to update fate-mxf fate test. > > > > > > > > > > Signed-off-by: Limin Wang > > > > > --- > > > > > [...] > > > > > > > > In my opinion the MXF identification set should contain data about the > > > > application that wrote the current version of a file, not some > > > > previous > > file > > > > version. > > > > > > The example command shows what's change for the fate testing, if you > > > want > > to > > > update to use your own product version, please use -metadata > > product_version="x". > > > > It looks wrong that a MXF file that is muxed by FFmpeg pretends to be > > written by a SONY application. I see that with "-codec copy" you can > > avoid re-encoding of the video and audio streams, and thus might want to > > indicate the A/V encoder software info somewhere separate from the > > container format writer software. But this patch overrides both > > information. > > We might remove company_name, product_name and product_version metadata in > fftools/ffmpeg_opt.c similarly how creation_time is removed for automatic > metadata copy. This is good suggestion, I'll update the patch by this way to avoid overrides with input information. > > Regards, > Marton > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 1/3] avformat/udp: return the error code instead of generic EIO
On Sat, Jan 09, 2021 at 12:23:42AM +0100, Marton Balint wrote: > > > On Fri, 8 Jan 2021, lance.lmw...@gmail.com wrote: > > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavformat/udp.c | 42 ++ > > 1 file changed, 22 insertions(+), 20 deletions(-) > > > > diff --git a/libavformat/udp.c b/libavformat/udp.c > > index 13c346a..28987e0 100644 > > --- a/libavformat/udp.c > > +++ b/libavformat/udp.c > > @@ -633,6 +633,8 @@ static int udp_open(URLContext *h, const char *uri, int > > flags) > > char buf[256]; > > struct sockaddr_storage my_addr; > > socklen_t len; > > +int ret = AVERROR(EIO); > > +int net_ret = 0; > > > > h->is_streamed = 1; > > > > @@ -641,12 +643,12 @@ static int udp_open(URLContext *h, const char *uri, > > int flags) > > s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_RX_BUF_SIZE; > > > > if (s->sources) { > > -if (ff_ip_parse_sources(h, s->sources, >filters) < 0) > > +if ((ret = ff_ip_parse_sources(h, s->sources, >filters)) < 0) > > goto fail; > > } > > > > if (s->block) { > > -if (ff_ip_parse_blocks(h, s->block, >filters) < 0) > > +if ((ret = ff_ip_parse_blocks(h, s->block, >filters)) < 0) > > goto fail; > > } > > > > @@ -712,11 +714,11 @@ static int udp_open(URLContext *h, const char *uri, > > int flags) > > av_strlcpy(localaddr, buf, sizeof(localaddr)); > > } > > if (av_find_info_tag(buf, sizeof(buf), "sources", p)) { > > -if (ff_ip_parse_sources(h, buf, >filters) < 0) > > +if ((ret = ff_ip_parse_sources(h, buf, >filters)) < 0) > > goto fail; > > } > > if (av_find_info_tag(buf, sizeof(buf), "block", p)) { > > -if (ff_ip_parse_blocks(h, buf, >filters) < 0) > > +if ((ret = ff_ip_parse_blocks(h, buf, >filters)) < 0) > > goto fail; > > } > > if (!is_output && av_find_info_tag(buf, sizeof(buf), "timeout", p)) > > @@ -742,7 +744,7 @@ static int udp_open(URLContext *h, const char *uri, int > > flags) > > if (!(flags & AVIO_FLAG_READ)) > > goto fail; > > } else { > > -if (ff_udp_set_remote_url(h, uri) < 0) > > +if ((ret = ff_udp_set_remote_url(h, uri)) < 0) > > goto fail; > > } > > > > @@ -763,13 +765,13 @@ static int udp_open(URLContext *h, const char *uri, > > int flags) > > */ > > if (s->reuse_socket > 0 || (s->is_multicast && s->reuse_socket < 0)) { > > s->reuse_socket = 1; > > -if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, > > &(s->reuse_socket), sizeof(s->reuse_socket)) != 0) > > +if ((net_ret = setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, > > &(s->reuse_socket), sizeof(s->reuse_socket))) != 0) > > goto fail; > > } > > > > if (s->is_broadcast) { > > #ifdef SO_BROADCAST > > -if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, > > &(s->is_broadcast), sizeof(s->is_broadcast)) != 0) > > +if ((net_ret = setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, > > &(s->is_broadcast), sizeof(s->is_broadcast))) != 0) > > #endif > >goto fail; > > } > > @@ -788,7 +790,7 @@ static int udp_open(URLContext *h, const char *uri, int > > flags) > > > > if (dscp >= 0) { > > dscp <<= 2; > > -if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , sizeof(dscp)) > > != 0) > > +if ((net_ret = setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , > > sizeof(dscp))) != 0) > > goto fail; > > } > > > > @@ -802,7 +804,7 @@ static int udp_open(URLContext *h, const char *uri, int > > flags) > > /* bind to the local address if not multicast or if the multicast > > * bind failed */ > > /* the bind is needed to give a port to the socket now */ > > -if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)_addr, len) < 0) > > { > > +if (bind_ret < 0 && (net_ret = bind(udp_fd,(struct sockaddr > > *)_addr, len)) < 0) { > > ff_log_net_error(h, AV_LOG_ERROR, "bind failed"); > > goto fail; > > } > > @@ -814,28 +816,28 @@ static int udp_open(URLContext *h, const char *uri, > > int flags) > > if (s->is_multicast) { > > if (h->flags & AVIO_FLAG_WRITE) { > > /* output */ > > -if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr > > *)>dest_addr) < 0) > > +if ((net_ret = udp_set_multicast_ttl(udp_fd, s->ttl, (struct > > sockaddr *)>dest_addr)) < 0) > > I suggest you make this ret as well and change udp_set_multicast_ttl to > return ff_neterrno() instead of -1 on error. OK, will change by suggestion. > > > goto fail; > > } > > if (h->flags & AVIO_FLAG_READ) { > > /* input */ > > if (s->filters.nb_include_addrs) { > > -if (udp_set_multicast_sources(h, udp_fd, > > +if
Re: [FFmpeg-devel] [PATCH v3 3/3] avformat/mxfenc: prefer to use the existing metadata
On Fri, 8 Jan 2021, Tobias Rapp wrote: On 08.01.2021 11:01, lance.lmw...@gmail.com wrote: On Fri, Jan 08, 2021 at 09:09:34AM +0100, Tobias Rapp wrote: On 08.01.2021 07:32, lance.lmw...@gmail.com wrote: From: Limin Wang Please check metadata with below command: ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf ./ffmpeg -i out.mxf company_name: FFmpeg product_name: OP1a Muxer product_version : 58.65.101o => company_name: SONY product_name: eVTR product_version : 1.00 So need to update fate-mxf fate test. Signed-off-by: Limin Wang --- [...] In my opinion the MXF identification set should contain data about the application that wrote the current version of a file, not some previous file version. The example command shows what's change for the fate testing, if you want to update to use your own product version, please use -metadata product_version="x". It looks wrong that a MXF file that is muxed by FFmpeg pretends to be written by a SONY application. I see that with "-codec copy" you can avoid re-encoding of the video and audio streams, and thus might want to indicate the A/V encoder software info somewhere separate from the container format writer software. But this patch overrides both information. We might remove company_name, product_name and product_version metadata in fftools/ffmpeg_opt.c similarly how creation_time is removed for automatic metadata copy. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4] avcodec/libvpxenc: add a way to set VP9E_SET_SVC_REF_FRAME_CONFIG
On Fri, Jan 8, 2021 at 3:33 PM Wonkap Jang wrote: > In order to fine-control referencing schemes in VP9 encoding, there > is a need to use VP9E_SET_SVC_REF_FRAME_CONFIG method. This commit > provides a way to use the API through frame metadata. > --- > doc/encoders.texi | 32 > libavcodec/libvpxenc.c | 84 ++ > libavcodec/version.h | 2 +- > 3 files changed, 117 insertions(+), 1 deletion(-) > > diff --git a/doc/encoders.texi b/doc/encoders.texi > index 0b1c69e982..ef85fbb062 100644 > --- a/doc/encoders.texi > +++ b/doc/encoders.texi > @@ -2129,6 +2129,38 @@ midpoint is passed in rather than calculated for a > specific clip or chunk. > The valid range is [0, 1]. 0 (default) uses standard VBR. > @item enable-tpl @var{boolean} > Enable temporal dependency model. > +@item ref-frame-config > +Using per-frame metadata, set members of the structure > @code{vpx_svc_ref_frame_config_t} in @code{vpx/vp8cx.h} to fine-control > referencing schemes and frame buffer management. > +@*Use a :-separated list of key=value pairs. > +For example, > +@example > +av_dict_set(_frame->metadata, "ref-frame-config", \ > > +"rfc_update_buffer_slot=7:rfc_lst_fb_idx=0:rfc_gld_fb_idx=1:rfc_alt_fb_idx=2:rfc_reference_last=0:rfc_reference_golden=0:rfc_reference_alt_ref=0"); > +@end example > +@table @option > +@item rfc_update_buffer_slot > +Indicates the buffer slot number to update > +@item rfc_update_last > +Indicates whether to update the LAST frame > +@item rfc_update_golden > +Indicates whether to update GOLDEN frame > +@item rfc_update_alt_ref > +Indicates whether to update ALT_REF frame > +@item rfc_lst_fb_idx > +LAST frame buffer index > +@item rfc_gld_fb_idx > +GOLDEN frame buffer index > +@item rfc_alt_fb_idx > +ALT_REF frame buffer index > +@item rfc_reference_last > +Indicates whether to reference LAST frame > +@item rfc_reference_golden > +Indicates whether to reference GOLDEN frame > +@item rfc_reference_alt_ref > +Indicates whether to reference ALT_REF frame > +@item rfc_reference_duration > +Indicates frame duration > +@end table > @end table > > @end table > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > index a7c76eb835..80e677dbbc 100644 > --- a/libavcodec/libvpxenc.c > +++ b/libavcodec/libvpxenc.c > @@ -125,6 +125,10 @@ typedef struct VPxEncoderContext { > * encounter a frame with ROI side data. > */ > int roi_warned; > +#if CONFIG_LIBVPX_VP9_ENCODER && > defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) > +vpx_svc_ref_frame_config_t ref_frame_config; > +AVDictionary *vpx_ref_frame_config; > +#endif > } VPxContext; > > /** String mappings for enum vp8e_enc_control_id */ > @@ -152,6 +156,7 @@ static const char *const ctlidstr[] = { > [VP9E_SET_SVC_LAYER_ID]= "VP9E_SET_SVC_LAYER_ID", > #if VPX_ENCODER_ABI_VERSION >= 12 > [VP9E_SET_SVC_PARAMETERS] = "VP9E_SET_SVC_PARAMETERS", > +[VP9E_SET_SVC_REF_FRAME_CONFIG]= "VP9E_SET_SVC_REF_FRAME_CONFIG", > #endif > [VP9E_SET_SVC] = "VP9E_SET_SVC", > #if VPX_ENCODER_ABI_VERSION >= 11 > @@ -394,6 +399,21 @@ static void vp8_ts_parse_int_array(int *dest, char > *value, size_t value_len, int > } > } > > +#if CONFIG_LIBVPX_VP9_ENCODER && > defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) > +static void vp8_ts_parse_int64_array(int64_t *dest, char *value, size_t > value_len, int max_entries) > +{ > +int dest_idx = 0; > +char *saveptr = NULL; > +char *token = av_strtok(value, ",", ); > + > +while (token && dest_idx < max_entries) { > +dest[dest_idx++] = strtoull(token, NULL, 10); > +token = av_strtok(NULL, ",", ); > +} > +} > + > +#endif > + > static void set_temporal_layer_pattern(int layering_mode, > vpx_codec_enc_cfg_t *cfg, > int *layer_flags, int > *flag_periodicity) > { > @@ -541,6 +561,48 @@ static int vpx_ts_param_parse(VPxContext *ctx, struct > vpx_codec_enc_cfg *enccfg, > return 0; > } > > +#if CONFIG_LIBVPX_VP9_ENCODER && > defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) > +static int vpx_ref_frame_config_parse(VPxContext *ctx, const struct > vpx_codec_enc_cfg *enccfg, > + char *key, char *value, enum > AVCodecID codec_id) > +{ > +size_t value_len = strlen(value); > +int ss_number_layers = enccfg->ss_number_layers; > +vpx_svc_ref_frame_config_t *ref_frame_config = >ref_frame_config; > + > +if (!value_len) > +return -1; > + > +if (codec_id != AV_CODEC_ID_VP9) > +return -1; > + > +if (!strcmp(key, "rfc_update_buffer_slot")) { > +vp8_ts_parse_int_array(ref_frame_config->update_buffer_slot, > value, value_len, ss_number_layers); > +} else if (!strcmp(key, "rfc_update_last")) { > +vp8_ts_parse_int_array(ref_frame_config->update_last, value, > value_len, ss_number_layers); > +} else if (!strcmp(key,
[FFmpeg-devel] [PATCH v4] avcodec/libvpxenc: add a way to set VP9E_SET_SVC_REF_FRAME_CONFIG
In order to fine-control referencing schemes in VP9 encoding, there is a need to use VP9E_SET_SVC_REF_FRAME_CONFIG method. This commit provides a way to use the API through frame metadata. --- doc/encoders.texi | 32 libavcodec/libvpxenc.c | 84 ++ libavcodec/version.h | 2 +- 3 files changed, 117 insertions(+), 1 deletion(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 0b1c69e982..ef85fbb062 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2129,6 +2129,38 @@ midpoint is passed in rather than calculated for a specific clip or chunk. The valid range is [0, 1]. 0 (default) uses standard VBR. @item enable-tpl @var{boolean} Enable temporal dependency model. +@item ref-frame-config +Using per-frame metadata, set members of the structure @code{vpx_svc_ref_frame_config_t} in @code{vpx/vp8cx.h} to fine-control referencing schemes and frame buffer management. +@*Use a :-separated list of key=value pairs. +For example, +@example +av_dict_set(_frame->metadata, "ref-frame-config", \ +"rfc_update_buffer_slot=7:rfc_lst_fb_idx=0:rfc_gld_fb_idx=1:rfc_alt_fb_idx=2:rfc_reference_last=0:rfc_reference_golden=0:rfc_reference_alt_ref=0"); +@end example +@table @option +@item rfc_update_buffer_slot +Indicates the buffer slot number to update +@item rfc_update_last +Indicates whether to update the LAST frame +@item rfc_update_golden +Indicates whether to update GOLDEN frame +@item rfc_update_alt_ref +Indicates whether to update ALT_REF frame +@item rfc_lst_fb_idx +LAST frame buffer index +@item rfc_gld_fb_idx +GOLDEN frame buffer index +@item rfc_alt_fb_idx +ALT_REF frame buffer index +@item rfc_reference_last +Indicates whether to reference LAST frame +@item rfc_reference_golden +Indicates whether to reference GOLDEN frame +@item rfc_reference_alt_ref +Indicates whether to reference ALT_REF frame +@item rfc_reference_duration +Indicates frame duration +@end table @end table @end table diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index a7c76eb835..80e677dbbc 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -125,6 +125,10 @@ typedef struct VPxEncoderContext { * encounter a frame with ROI side data. */ int roi_warned; +#if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) +vpx_svc_ref_frame_config_t ref_frame_config; +AVDictionary *vpx_ref_frame_config; +#endif } VPxContext; /** String mappings for enum vp8e_enc_control_id */ @@ -152,6 +156,7 @@ static const char *const ctlidstr[] = { [VP9E_SET_SVC_LAYER_ID]= "VP9E_SET_SVC_LAYER_ID", #if VPX_ENCODER_ABI_VERSION >= 12 [VP9E_SET_SVC_PARAMETERS] = "VP9E_SET_SVC_PARAMETERS", +[VP9E_SET_SVC_REF_FRAME_CONFIG]= "VP9E_SET_SVC_REF_FRAME_CONFIG", #endif [VP9E_SET_SVC] = "VP9E_SET_SVC", #if VPX_ENCODER_ABI_VERSION >= 11 @@ -394,6 +399,21 @@ static void vp8_ts_parse_int_array(int *dest, char *value, size_t value_len, int } } +#if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) +static void vp8_ts_parse_int64_array(int64_t *dest, char *value, size_t value_len, int max_entries) +{ +int dest_idx = 0; +char *saveptr = NULL; +char *token = av_strtok(value, ",", ); + +while (token && dest_idx < max_entries) { +dest[dest_idx++] = strtoull(token, NULL, 10); +token = av_strtok(NULL, ",", ); +} +} + +#endif + static void set_temporal_layer_pattern(int layering_mode, vpx_codec_enc_cfg_t *cfg, int *layer_flags, int *flag_periodicity) { @@ -541,6 +561,48 @@ static int vpx_ts_param_parse(VPxContext *ctx, struct vpx_codec_enc_cfg *enccfg, return 0; } +#if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) +static int vpx_ref_frame_config_parse(VPxContext *ctx, const struct vpx_codec_enc_cfg *enccfg, + char *key, char *value, enum AVCodecID codec_id) +{ +size_t value_len = strlen(value); +int ss_number_layers = enccfg->ss_number_layers; +vpx_svc_ref_frame_config_t *ref_frame_config = >ref_frame_config; + +if (!value_len) +return -1; + +if (codec_id != AV_CODEC_ID_VP9) +return -1; + +if (!strcmp(key, "rfc_update_buffer_slot")) { +vp8_ts_parse_int_array(ref_frame_config->update_buffer_slot, value, value_len, ss_number_layers); +} else if (!strcmp(key, "rfc_update_last")) { +vp8_ts_parse_int_array(ref_frame_config->update_last, value, value_len, ss_number_layers); +} else if (!strcmp(key, "rfc_update_golden")) { +vp8_ts_parse_int_array(ref_frame_config->update_golden, value, value_len, ss_number_layers); +} else if (!strcmp(key, "rfc_update_alt_ref")) { +vp8_ts_parse_int_array(ref_frame_config->update_alt_ref, value, value_len, ss_number_layers); +} else if (!strcmp(key,
Re: [FFmpeg-devel] [PATCH v2] In order to fine-control referencing schemes in VP9 encoding, there is a need to use VP9E_SET_SVC_REF_FRAME_CONFIG method. This commit provides a way to use the API throu
On Mon, Dec 14, 2020 at 12:46 PM James Zern wrote: > Hi, > > > On Mon, Dec 14, 2020 at 11:54 AM Wonkap Jang wrote: > > > > > > > > On Mon, Dec 7, 2020 at 11:57 PM Wonkap Jang wrote: > >> > >> --- > >> doc/encoders.texi | 32 + > >> libavcodec/libvpxenc.c | 79 ++ > >> 2 files changed, 111 insertions(+) > >> > > Sorry I missed this when scanning the subjects. Please update the > commit message so it has a short 1 one line subject [1]. > > [1] > https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelines > > >> diff --git a/doc/encoders.texi b/doc/encoders.texi > >> index 0b1c69e982..aa3a2221b6 100644 > >> --- a/doc/encoders.texi > >> +++ b/doc/encoders.texi > >> @@ -2129,6 +2129,38 @@ midpoint is passed in rather than calculated for > a specific clip or chunk. > >> The valid range is [0, 1]. 0 (default) uses standard VBR. > >> @item enable-tpl @var{boolean} > >> Enable temporal dependency model. > >> +@item ref-frame-config > >> +Using per-frame metadata, set members of the structure > @code{vpx_svc_ref_frame_config_t} in @code{vpx/vp8cx.h} to fine-control > referencing schemes and frame buffer management. > >> +@*Use a :-separated list of key=value pairs. > >> +For example, > >> +@example > >> +av_dict_set(_frame->metadata, "ref-frame-config", \ > >> > +"rfc_update_buffer_slot=7:rfc_lst_fb_idx=0:rfc_gld_fb_idx=1:rfc_alt_fb_idx=2:rfc_reference_last=0:rfc_reference_golden=0:rfc_reference_alt_ref=0");} > >> +@end example > >> +@table @option > >> +@item rfc_update_buffer_slot > >> +Indicates the buffer slot number to update > >> +@item rfc_update_last > >> +Indicates whether to update the LAST frame > >> +@item rfc_update_golden > >> +Indicates whether to update GOLDEN frame > >> +@item rfc_update_alt_ref > >> +Indicates whether to update ALT_REF frame > >> +@item rfc_lst_fb_idx > >> +LAST frame buffer index > >> +@item rfc_gld_fb_idx > >> +GOLDEN frame buffer index > >> +@item rfc_alt_fb_idx > >> +ALT_REF frame buffer index > >> +@item rfc_reference_last > >> +Indicates whetehr to reference LAST frame > >> +@item rfc_reference_golden > >> +Indicates whether to reference GOLDEN frame > >> +@item rfc_reference_alt_ref > >> +Indicates whether to reference ALT_REF frame > >> +@item rfc_reference_duration > >> +Indicates frame duration > >> +@end table > >> @end table > >> > >> @end table > >> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > >> index a7c76eb835..345c71cd22 100644 > >> --- a/libavcodec/libvpxenc.c > >> +++ b/libavcodec/libvpxenc.c > >> @@ -125,6 +125,11 @@ typedef struct VPxEncoderContext { > >> * encounter a frame with ROI side data. > >> */ > >> int roi_warned; > >> + > >> +#if CONFIG_LIBVPX_VP9_ENCODER && defined > (VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) > > It would be better to just check the ABI version in this case since > it's a little confusing to use an unrelated control in the check. > > >> +vpx_svc_ref_frame_config_t ref_frame_config; > >> +AVDictionary *vpx_ref_frame_config; > >> +#endif > >> } VPxContext; > >> > >> /** String mappings for enum vp8e_enc_control_id */ > >> @@ -152,6 +157,9 @@ static const char *const ctlidstr[] = { > >> [VP9E_SET_SVC_LAYER_ID]= "VP9E_SET_SVC_LAYER_ID", > >> #if VPX_ENCODER_ABI_VERSION >= 12 > >> [VP9E_SET_SVC_PARAMETERS] = "VP9E_SET_SVC_PARAMETERS", > >> +#if defined (VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) > >> +[VP9E_SET_SVC_REF_FRAME_CONFIG]= > "VP9E_SET_SVC_REF_FRAME_CONFIG", > >> +#endif > >> #endif > >> [VP9E_SET_SVC] = "VP9E_SET_SVC", > >> #if VPX_ENCODER_ABI_VERSION >= 11 > >> @@ -394,6 +402,18 @@ static void vp8_ts_parse_int_array(int *dest, char > *value, size_t value_len, int > >> } > >> } > >> > >> +static void vp8_ts_parse_int64_array(int64_t *dest, char *value, > size_t value_len, int max_entries) > >> +{ > >> +int dest_idx = 0; > >> +char *saveptr = NULL; > >> +char *token = av_strtok(value, ",", ); > >> + > >> +while (token && dest_idx < max_entries) { > >> +dest[dest_idx++] = strtoull(token, NULL, 10); > >> +token = av_strtok(NULL, ",", ); > >> +} > >> +} > >> + > >> static void set_temporal_layer_pattern(int layering_mode, > vpx_codec_enc_cfg_t *cfg, > >> int *layer_flags, int > *flag_periodicity) > >> { > >> @@ -541,6 +561,48 @@ static int vpx_ts_param_parse(VPxContext *ctx, > struct vpx_codec_enc_cfg *enccfg, > >> return 0; > >> } > >> > >> +#if CONFIG_LIBVPX_VP9_ENCODER && defined > (VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) > >> +static int vpx_ref_frame_config_parse(VPxContext *ctx, const struct > vpx_codec_enc_cfg *enccfg, > >> + char *key, char *value, enum AVCodecID > codec_id) > >> +{ > >> +size_t value_len = strlen(value); > >> +int ss_number_layers = enccfg->ss_number_layers; > >> +
Re: [FFmpeg-devel] [PATCH v3 1/3] avformat/udp: return the error code instead of generic EIO
On Fri, 8 Jan 2021, lance.lmw...@gmail.com wrote: From: Limin Wang Signed-off-by: Limin Wang --- libavformat/udp.c | 42 ++ 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index 13c346a..28987e0 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -633,6 +633,8 @@ static int udp_open(URLContext *h, const char *uri, int flags) char buf[256]; struct sockaddr_storage my_addr; socklen_t len; +int ret = AVERROR(EIO); +int net_ret = 0; h->is_streamed = 1; @@ -641,12 +643,12 @@ static int udp_open(URLContext *h, const char *uri, int flags) s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_RX_BUF_SIZE; if (s->sources) { -if (ff_ip_parse_sources(h, s->sources, >filters) < 0) +if ((ret = ff_ip_parse_sources(h, s->sources, >filters)) < 0) goto fail; } if (s->block) { -if (ff_ip_parse_blocks(h, s->block, >filters) < 0) +if ((ret = ff_ip_parse_blocks(h, s->block, >filters)) < 0) goto fail; } @@ -712,11 +714,11 @@ static int udp_open(URLContext *h, const char *uri, int flags) av_strlcpy(localaddr, buf, sizeof(localaddr)); } if (av_find_info_tag(buf, sizeof(buf), "sources", p)) { -if (ff_ip_parse_sources(h, buf, >filters) < 0) +if ((ret = ff_ip_parse_sources(h, buf, >filters)) < 0) goto fail; } if (av_find_info_tag(buf, sizeof(buf), "block", p)) { -if (ff_ip_parse_blocks(h, buf, >filters) < 0) +if ((ret = ff_ip_parse_blocks(h, buf, >filters)) < 0) goto fail; } if (!is_output && av_find_info_tag(buf, sizeof(buf), "timeout", p)) @@ -742,7 +744,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) if (!(flags & AVIO_FLAG_READ)) goto fail; } else { -if (ff_udp_set_remote_url(h, uri) < 0) +if ((ret = ff_udp_set_remote_url(h, uri)) < 0) goto fail; } @@ -763,13 +765,13 @@ static int udp_open(URLContext *h, const char *uri, int flags) */ if (s->reuse_socket > 0 || (s->is_multicast && s->reuse_socket < 0)) { s->reuse_socket = 1; -if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0) +if ((net_ret = setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket))) != 0) goto fail; } if (s->is_broadcast) { #ifdef SO_BROADCAST -if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), sizeof(s->is_broadcast)) != 0) +if ((net_ret = setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), sizeof(s->is_broadcast))) != 0) #endif goto fail; } @@ -788,7 +790,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) if (dscp >= 0) { dscp <<= 2; -if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , sizeof(dscp)) != 0) +if ((net_ret = setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , sizeof(dscp))) != 0) goto fail; } @@ -802,7 +804,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) /* bind to the local address if not multicast or if the multicast * bind failed */ /* the bind is needed to give a port to the socket now */ -if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)_addr, len) < 0) { +if (bind_ret < 0 && (net_ret = bind(udp_fd,(struct sockaddr *)_addr, len)) < 0) { ff_log_net_error(h, AV_LOG_ERROR, "bind failed"); goto fail; } @@ -814,28 +816,28 @@ static int udp_open(URLContext *h, const char *uri, int flags) if (s->is_multicast) { if (h->flags & AVIO_FLAG_WRITE) { /* output */ -if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)>dest_addr) < 0) +if ((net_ret = udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)>dest_addr)) < 0) I suggest you make this ret as well and change udp_set_multicast_ttl to return ff_neterrno() instead of -1 on error. goto fail; } if (h->flags & AVIO_FLAG_READ) { /* input */ if (s->filters.nb_include_addrs) { -if (udp_set_multicast_sources(h, udp_fd, +if ((net_ret = udp_set_multicast_sources(h, udp_fd, This is ret as far as I see. (struct sockaddr *)>dest_addr, s->dest_addr_len, >local_addr_storage, s->filters.include_addrs, - s->filters.nb_include_addrs, 1) < 0) + s->filters.nb_include_addrs, 1)) < 0) goto fail; } else { -if (udp_join_multicast_group(udp_fd, (struct
Re: [FFmpeg-devel] [PATCH 1/7] avcodec/[e]ac3enc: Make encoders init-threadsafe, fix race
Andreas Rheinhardt: > ff_eac3_exponent_init() set values twice when initializing a static > table; ergo the initialization code must not run concurrently with > a running EAC-3 encoder. Yet this code is executed every time an EAC-3 > encoder is initialized. So use ff_thread_once() for this and also for a > similar initialization performed for all AC-3 encoders to make them all > init-threadsafe. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/ac3enc.c | 17 + > libavcodec/ac3enc_fixed.c | 2 +- > libavcodec/ac3enc_float.c | 2 +- > libavcodec/eac3enc.c | 2 +- > 4 files changed, 12 insertions(+), 11 deletions(-) > > diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c > index 37dc0fb2ef..3354bf6b45 100644 > --- a/libavcodec/ac3enc.c > +++ b/libavcodec/ac3enc.c > @@ -35,6 +35,7 @@ > #include "libavutil/crc.h" > #include "libavutil/internal.h" > #include "libavutil/opt.h" > +#include "libavutil/thread.h" > #include "avcodec.h" > #include "internal.h" > #include "me_cmp.h" > @@ -303,7 +304,7 @@ void ff_ac3_apply_rematrixing(AC3EncodeContext *s) > /* > * Initialize exponent tables. > */ > -static av_cold void exponent_init(AC3EncodeContext *s) > +static av_cold void exponent_init(void) > { > int expstr, i, grpsize; > > @@ -316,9 +317,6 @@ static av_cold void exponent_init(AC3EncodeContext *s) > } > /* LFE */ > exponent_group_tab[0][0][7] = 2; > - > -if (CONFIG_EAC3_ENCODER && s->eac3) > -ff_eac3_exponent_init(); > } > > > @@ -2408,6 +2406,7 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) > > av_cold int ff_ac3_encode_init(AVCodecContext *avctx) > { > +static AVOnce init_static_once = AV_ONCE_INIT; > AC3EncodeContext *s = avctx->priv_data; > int ret, frame_size_58; > > @@ -2447,15 +2446,15 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) > s->mdct_init= ff_ac3_float_mdct_init; > s->allocate_sample_buffers = > ff_ac3_float_allocate_sample_buffers; > } > -if (CONFIG_EAC3_ENCODER && s->eac3) > +if (CONFIG_EAC3_ENCODER && s->eac3) { > +static AVOnce init_static_once = AV_ONCE_INIT; > +ff_thread_once(_static_once, ff_eac3_exponent_init); > s->output_frame_header = ff_eac3_output_frame_header; > -else > +} else > s->output_frame_header = ac3_output_frame_header; > > set_bandwidth(s); > > -exponent_init(s); > - > bit_alloc_init(s); > > ret = s->mdct_init(s); > @@ -2472,5 +2471,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) > > dprint_options(s); > > +ff_thread_once(_static_once, exponent_init); > + > return 0; > } > diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c > index 428bbfb3c5..d2e67f3214 100644 > --- a/libavcodec/ac3enc_fixed.c > +++ b/libavcodec/ac3enc_fixed.c > @@ -155,7 +155,7 @@ AVCodec ff_ac3_fixed_encoder = { > .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16P, >AV_SAMPLE_FMT_NONE }, > .priv_class = _class, > -.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, > +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | > FF_CODEC_CAP_INIT_CLEANUP, > .supported_samplerates = ff_ac3_sample_rate_tab, > .channel_layouts = ff_ac3_channel_layouts, > .defaults= ac3_defaults, > diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c > index 99863a9722..571f603182 100644 > --- a/libavcodec/ac3enc_float.c > +++ b/libavcodec/ac3enc_float.c > @@ -153,5 +153,5 @@ AVCodec ff_ac3_encoder = { > .supported_samplerates = ff_ac3_sample_rate_tab, > .channel_layouts = ff_ac3_channel_layouts, > .defaults= ac3_defaults, > -.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, > +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | > FF_CODEC_CAP_INIT_CLEANUP, > }; > diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c > index 8e1032f268..00721aa645 100644 > --- a/libavcodec/eac3enc.c > +++ b/libavcodec/eac3enc.c > @@ -266,5 +266,5 @@ AVCodec ff_eac3_encoder = { > .supported_samplerates = ff_ac3_sample_rate_tab, > .channel_layouts = ff_ac3_channel_layouts, > .defaults= ac3_defaults, > -.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, > +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | > FF_CODEC_CAP_INIT_CLEANUP, > }; > Will apply this patchset tomorrow unless there are objections. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4] avcodec/libvpxenc: add a way to set VP9E_SET_SVC_REF_FRAME_CONFIG
On Thu, Jan 7, 2021 at 11:56 PM Wonkap Jang wrote: > > In order to fine-control referencing schemes in VP9 encoding, there > is a need to use VP9E_SET_SVC_REF_FRAME_CONFIG method. This commit > provides a way to use the API through frame metadata. > --- > doc/encoders.texi | 32 +++ > libavcodec/libvpxenc.c | 88 ++ > libavcodec/version.h | 2 +- > 3 files changed, 121 insertions(+), 1 deletion(-) > > [...] > +#if CONFIG_LIBVPX_VP9_ENCODER && > defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) > +en = av_dict_get(frame->metadata, "ref-frame-config", NULL, 0); > + > +if (en) { > +if (avctx->codec_id == AV_CODEC_ID_VP9) { > +AVDictionaryEntry* en2 = NULL; > +av_dict_parse_string(>vpx_ref_frame_config, > en->value, "=", ":", 0); > + > +while ((en2 = av_dict_get(ctx->vpx_ref_frame_config, "", > en2, AV_DICT_IGNORE_SUFFIX))) { > +if (vpx_ref_frame_config_parse(ctx, enccfg, > en2->key, en2->value, avctx->codec_id) < 0) > +av_log(avctx, AV_LOG_WARNING, > + "Error parsing option '%s = %s'.\n", > + en2->key, en2->value); > +} > + > +codecctl_intp(avctx, VP9E_SET_SVC_REF_FRAME_CONFIG, (int > *)>ref_frame_config); > +av_log(avctx, AV_LOG_WARNING, > + "Error parsing option '%s = %s'.\n", > + en2->key, en2->value); I think this should be removed, no? There's trailing whitespace here too, git diff --check or tools/patcheck can catch this. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libavcodec/hevcdsp: port SIMD idct functions from 32-bit.
From: Reimar Döffinger Makes SIMD-optimized 8x8 and 16x16 idcts for 8 and 10 bit depth available on aarch64. For a UHD HDR (10 bit) sample video these were consuming the most time and this optimization reduced overall decode time from 19.4s to 16.4s, approximately 15% speedup. Test sample was the first 300 frames of "LG 4K HDR Demo - New York.ts", running on Apple M1. --- libavcodec/aarch64/Makefile | 2 + libavcodec/aarch64/hevcdsp_idct_neon.S| 426 ++ libavcodec/aarch64/hevcdsp_init_aarch64.c | 45 +++ libavcodec/hevcdsp.c | 2 + libavcodec/hevcdsp.h | 1 + 5 files changed, 476 insertions(+) create mode 100644 libavcodec/aarch64/hevcdsp_idct_neon.S create mode 100644 libavcodec/aarch64/hevcdsp_init_aarch64.c diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile index f6434e4..2ea1d74 100644 --- a/libavcodec/aarch64/Makefile +++ b/libavcodec/aarch64/Makefile @@ -61,3 +61,5 @@ NEON-OBJS-$(CONFIG_VP9_DECODER) += aarch64/vp9itxfm_16bpp_neon.o \ aarch64/vp9lpf_neon.o \ aarch64/vp9mc_16bpp_neon.o \ aarch64/vp9mc_neon.o +NEON-OBJS-$(CONFIG_HEVC_DECODER)+= aarch64/hevcdsp_idct_neon.o \ + aarch64/hevcdsp_init_aarch64.o diff --git a/libavcodec/aarch64/hevcdsp_idct_neon.S b/libavcodec/aarch64/hevcdsp_idct_neon.S new file mode 100644 index 000..9f67e45 --- /dev/null +++ b/libavcodec/aarch64/hevcdsp_idct_neon.S @@ -0,0 +1,426 @@ +/* + * ARM NEON optimised IDCT functions for HEVC decoding + * Copyright (c) 2014 Seppo Tomperi + * Copyright (c) 2017 Alexandra Hájková + * + * Ported from arm/hevcdsp_idct_neon.S by + * Copyright (c) 2020 Reimar Döffinger + * + * 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 Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/aarch64/asm.S" + +const trans, align=4 +.short 64, 83, 64, 36 +.short 89, 75, 50, 18 +.short 90, 87, 80, 70 +.short 57, 43, 25, 9 +.short 90, 90, 88, 85 +.short 82, 78, 73, 67 +.short 61, 54, 46, 38 +.short 31, 22, 13, 4 +endconst + +.macro sum_sub out, in, c, op, p + .ifc \op, + +smlal\p \out, \in, \c + .else +smlsl\p \out, \in, \c + .endif +.endm + +.macro fixsqrshrn d, dt, n, m + .ifc \dt, .8H +sqrshrn2\d\dt, \n\().4S, \m + .else +sqrshrn \n\().4H, \n\().4S, \m +mov \d\().D[0], \n\().D[0] + .endif +.endm + +.macro tr_4x4_8 in0, in1, in2, in3, out0, out1, out2, out3, tmp0, tmp1, tmp2, tmp3, p1, p2 + sshll\p1 \tmp0, \in0, #6 + mov\tmp1, \tmp0 + smull\p1 \tmp2, \in1, v0.H[1] + smull\p1 \tmp3, \in1, v0.H[3] + smlal\p2 \tmp0, \in2, v0.H[0] //e0 + smlsl\p2 \tmp1, \in2, v0.H[0] //e1 + smlal\p2 \tmp2, \in3, v0.H[3] //o0 + smlsl\p2 \tmp3, \in3, v0.H[1] //o1 + + add\out0, \tmp0, \tmp2 + add\out1, \tmp1, \tmp3 + sub\out2, \tmp1, \tmp3 + sub\out3, \tmp0, \tmp2 +.endm + +.macro transpose8_4x4 r0, r1, r2, r3 +trn1v2.8H, \r0\().8H, \r1\().8H +trn2v3.8H, \r0\().8H, \r1\().8H +trn1v4.8H, \r2\().8H, \r3\().8H +trn2v5.8H, \r2\().8H, \r3\().8H +trn1\r0\().4S, v2.4S, v4.4S +trn2\r2\().4S, v2.4S, v4.4S +trn1\r1\().4S, v3.4S, v5.4S +trn2\r3\().4S, v3.4S, v5.4S +.endm + +.macro transpose_8x8 r0, r1, r2, r3, r4, r5, r6, r7 +transpose8_4x4 \r0, \r1, \r2, \r3 +transpose8_4x4 \r4, \r5, \r6, \r7 +.endm + +.macro tr_8x4 shift, in0,in0t, in1,in1t, in2,in2t, in3,in3t, in4,in4t, in5,in5t, in6,in6t, in7,in7t, p1, p2 +tr_4x4_8\in0\in0t, \in2\in2t, \in4\in4t, \in6\in6t, v24.4S, v25.4S, v26.4S, v27.4S, v28.4S, v29.4S, v30.4S, v31.4S, \p1, \p2 + +smull\p1v30.4S, \in1\in1t, v0.H[6] +smull\p1v28.4S, \in1\in1t,
Re: [FFmpeg-devel] [PATCH 1/2] avformat/utils: Change compute_chapters_end() from O(n²) to O(n log n)
On Fri, Dec 04, 2020 at 11:21:22AM +0100, Anton Khirnov wrote: > Quoting Michael Niedermayer (2020-11-22 16:37:32) > > Fixes: Timeout (49sec -> 9sec) > > Fixes: > > 27427/clusterfuzz-testcase-minimized-ffmpeg_dem_FFMETADATA_fuzzer-5140589838073856 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > Not objecting to the patch itself, but just wondering: do we actually > want to compute chapter ends when the file doesn't store them? > I can imagine users might want to distinguish whether the end time is > explicitly specified or not. seems noone had a comment so ill apply the patch thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/4] avcodec/rasc: Check frame before clearing
On Fri, Dec 04, 2020 at 01:07:05AM +0100, Michael Niedermayer wrote: > Fixes: null pointer dereference > Fixes: > 27737/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RASC_fuzzer-5769028685266944 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/rasc.c | 3 +++ > 1 file changed, 3 insertions(+) will apply remainder of the set [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship: All citizens are under surveillance, all their steps and actions recorded, for the politicians to enforce control. Democracy: All politicians are under surveillance, all their steps and actions recorded, for the citizens to enforce control. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/dolby_e: set constant frame_size
>De : ffmpeg-devel De la part de Lynne >Envoyé : mardi 5 janvier 2021 16:26 >À : FFmpeg development discussions and patches >Objet : Re: [FFmpeg-devel] [PATCH] avcodec/dolby_e: set constant frame_size > >Jan 5, 2021, 10:43 by nicolas.gaullier@cji.paris: > > De : Nicolas Gaullier Envoyé : mardi > 15 décembre 2020 18:13 À : ffmpeg-devel@ffmpeg.org Cc : Nicolas > Gaullier Objet : [PATCH] > avcodec/dolby_e: set constant frame_size > > Fixes pts generation. > > Setting frame_size in dolby_e_init() or get_audio_frame_duration() can > result in a bad duration value for the first packet if dolby_e is muxed > in a container having a different sample_rate (ex: > container @48KHz, DolbyE @44.8KHz). > Maybe adding a parser to dolby_e would fix the issue and makes it > possible to set frame_size at decoder init which seems the best place. > >> >I am not sure I understand this. It is suprising that you say that >> >frame_size cannot be set in dolby_e_init(), why does it matter? It can only >> >be FRAME_SAMPLES, no other values can happen. In that sense it is similar >> >to sample_fmt, which I also don't see why it is set in every decode call, >> >and not only once, in init. >> >> Yes, this is not easy to see because the current code does not make this >> problem show up, but my initial target is a patch serie to support dolby_e >> in the wav container, and it makes it very clear. >> Please look at : >> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20201019081929.1926- >> 9-nicolas.gaullier@cji.paris/ The issue is that the WAV container has >> typically a sample rate of 48000Hz which contains the s377m submux that >> embedd a 44800Hz stream ("pal"-DolbyE here) : all this is very typical, >> standard, DolbyE content, but there is a trick in compute_pkt_fields (if I >> remember correctly my testing) with early duration setting based on 48000Hz >> which results in a wrong value for the first frame. >> Maybe having a DolbyE parser would fix this (the 44800Hz would araise >> sooner), but currently the pts are broken. >> >> Here is the diff if I set frame_size at dolby_e_init: >> --- ./tests/ref/fate/s337m-wav 2020-12-15 18:02:28.166747900 +0100 >> +++ tests/data/fate/s337m-wav 2021-01-05 10:27:01.193976500 +0100 >> @@ -4,8 +4,8 @@ >> #sample_rate 0: 44800 >> #channel_layout 0: 63f >> #channel_layout_name 0: 7.1 >> -0, 0, 0, 1920,11496, 0x05a9c147 >> -0, 1920, 1920, 1920,11496, 0x1d44d2b4 >> -0, 3840, 3840, 1920,11496, 0x4e078953 >> -0, 5760, 5760, 1920,11496, 0x1c73b1a1 >> -0, 7680, 7680, 1920,11262, 0xfa179fc8 >> +0, 0, 0, 1792,11496, 0x05a9c147 >> +0, 1792, 1792, 1920,11496, 0x1d44d2b4 >> +0, 3712, 3712, 1920,11496, 0x4e078953 >> +0, 5632, 5632, 1920,11496, 0x1c73b1a1 >> +0, 7552, 7552, 1920,11262, 0xfa179fc8 >> > --- > libavcodec/dolby_e.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c index > 429612ec08..b0e6d6aee3 100644 > --- a/libavcodec/dolby_e.c > +++ b/libavcodec/dolby_e.c > @@ -577,6 +577,7 @@ static int filter_frame(DBEContext *s, AVFrame > *frame) reorder = ch_reorder_n; > > frame->nb_samples = FRAME_SAMPLES; > +s->avctx->frame_size = FRAME_SAMPLES; > >> >If you still believe that setting this is required in every decode call, >> >then I'd say it would be cleaner to set this at dolby_e_decode_frame where >> >other avctx parameters are also set. >> >>> >>> >> >Thanks, >> >Marton >> >> I agree with you that sample_fmt and frame_size are both "const" and should >> probably be set at the same place wherever it is, and preferably at >> dolby_e_init. >> I cannot set frame_size in dolby_e_init because of the trick and sample_fmt >> is already set at dolby_e_decode_frame (for an unknown reason), maybe I >> should set frame_size in dolby_e_decode_frame too. >> >> I have just tested setting frame_size at dolby_e_decode_frame, and I confirm >> : yes, it works. >> This is not ideal but in the very short term, I really cannot see any other >> option : will you approve the patch if I set frame_size at >> dolby_e_decode_frame instead of filter_frame ? Should I amend my commit msg? >> > >I still don't get it. It really does seem like a hack or a workaround to set >the frame size on every single frame. >In general, frame_size for decoders is read only. If something's touching it >apart from the decoder, then its an API misuse. Thank you for your quick feedback! Yes, you're right, it is somewhat a workaround and I suggested in the commit msg that adding a parser for dolby_e would fix the issue. For me, the switch-case in get_audio_frame_duration with hardcoded frame_sizes also already sounds like workarounds
Re: [FFmpeg-devel] [PATCH v3 3/3] avformat/mxfenc: prefer to use the existing metadata
On 08.01.2021 11:01, lance.lmw...@gmail.com wrote: On Fri, Jan 08, 2021 at 09:09:34AM +0100, Tobias Rapp wrote: On 08.01.2021 07:32, lance.lmw...@gmail.com wrote: From: Limin Wang Please check metadata with below command: ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf ./ffmpeg -i out.mxf company_name: FFmpeg product_name: OP1a Muxer product_version : 58.65.101o => company_name: SONY product_name: eVTR product_version : 1.00 So need to update fate-mxf fate test. Signed-off-by: Limin Wang --- [...] In my opinion the MXF identification set should contain data about the application that wrote the current version of a file, not some previous file version. The example command shows what's change for the fate testing, if you want to update to use your own product version, please use -metadata product_version="x". It looks wrong that a MXF file that is muxed by FFmpeg pretends to be written by a SONY application. I see that with "-codec copy" you can avoid re-encoding of the video and audio streams, and thus might want to indicate the A/V encoder software info somewhere separate from the container format writer software. But this patch overrides both information. Regards, Tobias ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 3/3] avformat/mxfenc: prefer to use the existing metadata
On Fri, Jan 08, 2021 at 09:09:34AM +0100, Tobias Rapp wrote: > On 08.01.2021 07:32, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > Please check metadata with below command: > > ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf > > ./ffmpeg -i out.mxf > > > > company_name: FFmpeg > > product_name: OP1a Muxer > > product_version : 58.65.101o > > => > > company_name: SONY > > product_name: eVTR > > product_version : 1.00 > > > > So need to update fate-mxf fate test. > > > > Signed-off-by: Limin Wang > > --- > > [...] > > In my opinion the MXF identification set should contain data about the > application that wrote the current version of a file, not some previous file > version. The example command shows what's change for the fate testing, if you want to update to use your own product version, please use -metadata product_version="x". > > Regards, > Tobias > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libavfilter/dnn: add batch mode for async execution
the default number of batch_size is 1 Signed-off-by: Xie, Lin Signed-off-by: Wu Zhiwen Signed-off-by: Guo, Yejun --- libavfilter/dnn/dnn_backend_openvino.c | 157 + libavfilter/dnn/dnn_backend_openvino.h | 1 + libavfilter/dnn/dnn_interface.c| 1 + libavfilter/dnn_interface.h| 2 + libavfilter/vf_dnn_processing.c| 36 +- 5 files changed, 173 insertions(+), 24 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index d27e451eea..cb1bc3d22d 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -37,6 +37,7 @@ typedef struct OVOptions{ char *device_type; int nireq; +int batch_size; } OVOptions; typedef struct OVContext { @@ -70,7 +71,8 @@ typedef struct TaskItem { typedef struct RequestItem { ie_infer_request_t *infer_request; -TaskItem *task; +TaskItem **tasks; +int task_count; ie_complete_call_back_t callback; } RequestItem; @@ -83,6 +85,7 @@ typedef struct RequestItem { static const AVOption dnn_openvino_options[] = { { "device", "device to run model", OFFSET(options.device_type), AV_OPT_TYPE_STRING, { .str = "CPU" }, 0, 0, FLAGS }, { "nireq", "number of request", OFFSET(options.nireq), AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, INT_MAX, FLAGS }, +{ "batch_size", "batch size per request", OFFSET(options.batch_size), AV_OPT_TYPE_INT,{ .i64 = 1 }, 1, 1000, FLAGS}, { NULL } }; @@ -100,7 +103,19 @@ static DNNDataType precision_to_datatype(precision_e precision) } } -static DNNReturnType fill_model_input_ov(OVModel *ov_model, TaskItem *task, RequestItem *request) +static int get_datatype_size(DNNDataType dt) +{ +switch (dt) +{ +case DNN_FLOAT: +return sizeof(float); +default: +av_assert0(!"not supported yet."); +return 1; +} +} + +static DNNReturnType fill_model_input_ov(OVModel *ov_model, RequestItem *request) { dimensions_t dims; precision_e precision; @@ -109,6 +124,7 @@ static DNNReturnType fill_model_input_ov(OVModel *ov_model, TaskItem *task, Requ IEStatusCode status; DNNData input; ie_blob_t *input_blob = NULL; +TaskItem *task = request->tasks[0]; status = ie_infer_request_get_blob(request->infer_request, task->input_name, _blob); if (status != OK) { @@ -134,12 +150,19 @@ static DNNReturnType fill_model_input_ov(OVModel *ov_model, TaskItem *task, Requ input.channels = dims.dims[1]; input.data = blob_buffer.buffer; input.dt = precision_to_datatype(precision); -if (task->do_ioproc) { -if (ov_model->model->pre_proc != NULL) { -ov_model->model->pre_proc(task->in_frame, , ov_model->model->filter_ctx); -} else { -proc_from_frame_to_dnn(task->in_frame, , ctx); + +av_assert0(request->task_count <= dims.dims[0]); +for (int i = 0; i < request->task_count; ++i) { +task = request->tasks[i]; +if (task->do_ioproc) { +if (ov_model->model->pre_proc != NULL) { +ov_model->model->pre_proc(task->in_frame, , ov_model->model->filter_ctx); +} else { +proc_from_frame_to_dnn(task->in_frame, , ctx); +} } +input.data = (uint8_t *)input.data + + input.width * input.height * input.channels * get_datatype_size(input.dt); } ie_blob_free(_blob); @@ -152,7 +175,7 @@ static void infer_completion_callback(void *args) precision_e precision; IEStatusCode status; RequestItem *request = args; -TaskItem *task = request->task; +TaskItem *task = request->tasks[0]; ie_blob_t *output_blob = NULL; ie_blob_buffer_t blob_buffer; DNNData output; @@ -194,41 +217,65 @@ static void infer_completion_callback(void *args) output.width= dims.dims[3]; output.dt = precision_to_datatype(precision); output.data = blob_buffer.buffer; -if (task->do_ioproc) { -if (task->ov_model->model->post_proc != NULL) { -task->ov_model->model->post_proc(task->out_frame, , task->ov_model->model->filter_ctx); + +av_assert0(request->task_count <= dims.dims[0]); +for (int i = 0; i < request->task_count; ++i) { +task = request->tasks[i]; +if (task->do_ioproc) { +if (task->ov_model->model->post_proc != NULL) { +task->ov_model->model->post_proc(task->out_frame, , task->ov_model->model->filter_ctx); +} else { +proc_from_dnn_to_frame(task->out_frame, , ctx); +} } else { -proc_from_dnn_to_frame(task->out_frame, , ctx); +task->out_frame->width = output.width; +task->out_frame->height = output.height; } -} else { -task->out_frame->width = output.width; -task->out_frame->height =
Re: [FFmpeg-devel] [PATCH v3 3/3] avformat/mxfenc: prefer to use the existing metadata
On 08.01.2021 07:32, lance.lmw...@gmail.com wrote: From: Limin Wang Please check metadata with below command: ./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf ./ffmpeg -i out.mxf company_name: FFmpeg product_name: OP1a Muxer product_version : 58.65.101o => company_name: SONY product_name: eVTR product_version : 1.00 So need to update fate-mxf fate test. Signed-off-by: Limin Wang --- [...] In my opinion the MXF identification set should contain data about the application that wrote the current version of a file, not some previous file version. Regards, Tobias ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".