diff options
Diffstat (limited to 'libs/ffvpx/libavcodec')
43 files changed, 1510 insertions, 618 deletions
diff --git a/libs/ffvpx/libavcodec/allcodecs.c b/libs/ffvpx/libavcodec/allcodecs.c index 4d4ef530e..d2f9a39ce 100644 --- a/libs/ffvpx/libavcodec/allcodecs.c +++ b/libs/ffvpx/libavcodec/allcodecs.c @@ -35,12 +35,14 @@ extern AVCodec ff_aasc_decoder; extern AVCodec ff_aic_decoder; extern AVCodec ff_alias_pix_encoder; extern AVCodec ff_alias_pix_decoder; +extern AVCodec ff_agm_decoder; extern AVCodec ff_amv_encoder; extern AVCodec ff_amv_decoder; extern AVCodec ff_anm_decoder; extern AVCodec ff_ansi_decoder; extern AVCodec ff_apng_encoder; extern AVCodec ff_apng_decoder; +extern AVCodec ff_arbc_decoder; extern AVCodec ff_asv1_encoder; extern AVCodec ff_asv1_decoder; extern AVCodec ff_asv2_encoder; @@ -58,6 +60,7 @@ extern AVCodec ff_ayuv_decoder; extern AVCodec ff_bethsoftvid_decoder; extern AVCodec ff_bfi_decoder; extern AVCodec ff_bink_decoder; +extern AVCodec ff_bitpacked_decoder; extern AVCodec ff_bmp_encoder; extern AVCodec ff_bmp_decoder; extern AVCodec ff_bmv_video_decoder; @@ -151,8 +154,10 @@ extern AVCodec ff_hq_hqa_decoder; extern AVCodec ff_hqx_decoder; extern AVCodec ff_huffyuv_encoder; extern AVCodec ff_huffyuv_decoder; +extern AVCodec ff_hymt_decoder; extern AVCodec ff_idcin_decoder; extern AVCodec ff_iff_ilbm_decoder; +extern AVCodec ff_imm4_decoder; extern AVCodec ff_indeo2_decoder; extern AVCodec ff_indeo3_decoder; extern AVCodec ff_indeo4_decoder; @@ -168,6 +173,7 @@ extern AVCodec ff_kmvc_decoder; extern AVCodec ff_lagarith_decoder; extern AVCodec ff_ljpeg_encoder; extern AVCodec ff_loco_decoder; +extern AVCodec ff_lscr_decoder; extern AVCodec ff_m101_decoder; extern AVCodec ff_magicyuv_encoder; extern AVCodec ff_magicyuv_decoder; @@ -211,6 +217,7 @@ extern AVCodec ff_mszh_decoder; extern AVCodec ff_mts2_decoder; extern AVCodec ff_mvc1_decoder; extern AVCodec ff_mvc2_decoder; +extern AVCodec ff_mwsc_decoder; extern AVCodec ff_mxpeg_decoder; extern AVCodec ff_nuv_decoder; extern AVCodec ff_paf_video_decoder; @@ -234,7 +241,7 @@ extern AVCodec ff_prores_encoder; extern AVCodec ff_prores_decoder; extern AVCodec ff_prores_aw_encoder; extern AVCodec ff_prores_ks_encoder; -extern AVCodec ff_prores_lgpl_decoder; +extern AVCodec ff_prosumer_decoder; extern AVCodec ff_psd_decoder; extern AVCodec ff_ptx_decoder; extern AVCodec ff_qdraw_decoder; @@ -245,6 +252,7 @@ extern AVCodec ff_r10k_encoder; extern AVCodec ff_r10k_decoder; extern AVCodec ff_r210_encoder; extern AVCodec ff_r210_decoder; +extern AVCodec ff_rasc_decoder; extern AVCodec ff_rawvideo_encoder; extern AVCodec ff_rawvideo_decoder; extern AVCodec ff_rl2_decoder; @@ -322,6 +330,7 @@ extern AVCodec ff_vcr1_decoder; extern AVCodec ff_vmdvideo_decoder; extern AVCodec ff_vmnc_decoder; extern AVCodec ff_vp3_decoder; +extern AVCodec ff_vp4_decoder; extern AVCodec ff_vp5_decoder; extern AVCodec ff_vp6_decoder; extern AVCodec ff_vp6a_decoder; @@ -334,8 +343,8 @@ extern AVCodec ff_vp9_decoder; extern AVCodec ff_vp9_rkmpp_decoder; extern AVCodec ff_vp9_v4l2m2m_decoder; extern AVCodec ff_vqa_decoder; -extern AVCodec ff_bitpacked_decoder; extern AVCodec ff_webp_decoder; +extern AVCodec ff_wcmv_decoder; extern AVCodec ff_wrapped_avframe_encoder; extern AVCodec ff_wrapped_avframe_decoder; extern AVCodec ff_wmv1_encoder; @@ -393,6 +402,7 @@ extern AVCodec ff_atrac3_decoder; extern AVCodec ff_atrac3al_decoder; extern AVCodec ff_atrac3p_decoder; extern AVCodec ff_atrac3pal_decoder; +extern AVCodec ff_atrac9_decoder; extern AVCodec ff_binkaudio_dct_decoder; extern AVCodec ff_binkaudio_rdft_decoder; extern AVCodec ff_bmv_audio_decoder; @@ -418,7 +428,9 @@ extern AVCodec ff_g723_1_decoder; extern AVCodec ff_g729_decoder; extern AVCodec ff_gsm_decoder; extern AVCodec ff_gsm_ms_decoder; +extern AVCodec ff_hcom_decoder; extern AVCodec ff_iac_decoder; +extern AVCodec ff_ilbc_decoder; extern AVCodec ff_imc_decoder; extern AVCodec ff_interplay_acm_decoder; extern AVCodec ff_mace3_decoder; @@ -488,6 +500,7 @@ extern AVCodec ff_xma2_decoder; extern AVCodec ff_pcm_alaw_encoder; extern AVCodec ff_pcm_alaw_decoder; extern AVCodec ff_pcm_bluray_decoder; +extern AVCodec ff_pcm_dvd_encoder; extern AVCodec ff_pcm_dvd_decoder; extern AVCodec ff_pcm_f16le_decoder; extern AVCodec ff_pcm_f24le_decoder; @@ -546,6 +559,8 @@ extern AVCodec ff_pcm_u32be_encoder; extern AVCodec ff_pcm_u32be_decoder; extern AVCodec ff_pcm_u32le_encoder; extern AVCodec ff_pcm_u32le_decoder; +extern AVCodec ff_pcm_vidc_encoder; +extern AVCodec ff_pcm_vidc_decoder; extern AVCodec ff_pcm_zork_decoder; /* DPCM codecs */ @@ -561,6 +576,7 @@ extern AVCodec ff_adpcm_4xm_decoder; extern AVCodec ff_adpcm_adx_encoder; extern AVCodec ff_adpcm_adx_decoder; extern AVCodec ff_adpcm_afc_decoder; +extern AVCodec ff_adpcm_agm_decoder; extern AVCodec ff_adpcm_aica_decoder; extern AVCodec ff_adpcm_ct_decoder; extern AVCodec ff_adpcm_dtk_decoder; @@ -665,9 +681,12 @@ extern AVCodec ff_qdmc_at_decoder; extern AVCodec ff_qdm2_at_decoder; extern AVCodec ff_libaom_av1_decoder; extern AVCodec ff_libaom_av1_encoder; +extern AVCodec ff_libaribb24_decoder; extern AVCodec ff_libcelt_decoder; extern AVCodec ff_libcodec2_encoder; extern AVCodec ff_libcodec2_decoder; +extern AVCodec ff_libdav1d_decoder; +extern AVCodec ff_libdavs2_decoder; extern AVCodec ff_libfdk_aac_encoder; extern AVCodec ff_libfdk_aac_decoder; extern AVCodec ff_libgsm_encoder; @@ -706,6 +725,7 @@ extern AVCodec ff_libx264_encoder; extern AVCodec ff_libx264rgb_encoder; extern AVCodec ff_libx265_encoder; extern AVCodec ff_libxavs_encoder; +extern AVCodec ff_libxavs2_encoder; extern AVCodec ff_libxvid_encoder; extern AVCodec ff_libzvbi_teletext_decoder; @@ -761,7 +781,15 @@ extern AVCodec ff_vp9_cuvid_decoder; extern AVCodec ff_vp9_mediacodec_decoder; extern AVCodec ff_vp9_vaapi_encoder; +// The iterate API is not usable with ossfuzz due to the excessive size of binaries created +#if CONFIG_OSSFUZZ +AVCodec * codec_list[] = { + NULL, + NULL +}; +#else #include "libavcodec/codec_list.c" +#endif static AVOnce av_codec_static_init = AV_ONCE_INIT; static void av_codec_init_static(void) diff --git a/libs/ffvpx/libavcodec/avcodec.h b/libs/ffvpx/libavcodec/avcodec.h index fb0c6fae7..d234271c5 100644 --- a/libs/ffvpx/libavcodec/avcodec.h +++ b/libs/ffvpx/libavcodec/avcodec.h @@ -409,6 +409,7 @@ enum AVCodecID { AV_CODEC_ID_DXV, AV_CODEC_ID_SCREENPRESSO, AV_CODEC_ID_RSCC, + AV_CODEC_ID_AVS2, AV_CODEC_ID_Y41P = 0x8000, AV_CODEC_ID_AVRP, @@ -446,6 +447,16 @@ enum AVCodecID { AV_CODEC_ID_SVG, AV_CODEC_ID_GDV, AV_CODEC_ID_FITS, + AV_CODEC_ID_IMM4, + AV_CODEC_ID_PROSUMER, + AV_CODEC_ID_MWSC, + AV_CODEC_ID_WCMV, + AV_CODEC_ID_RASC, + AV_CODEC_ID_HYMT, + AV_CODEC_ID_ARBC, + AV_CODEC_ID_AGM, + AV_CODEC_ID_LSCR, + AV_CODEC_ID_VP4, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs @@ -485,6 +496,7 @@ enum AVCodecID { AV_CODEC_ID_PCM_S64BE, AV_CODEC_ID_PCM_F16LE, AV_CODEC_ID_PCM_F24LE, + AV_CODEC_ID_PCM_VIDC, /* various ADPCM codecs */ AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, @@ -529,6 +541,7 @@ enum AVCodecID { AV_CODEC_ID_ADPCM_AICA, AV_CODEC_ID_ADPCM_IMA_DAT4, AV_CODEC_ID_ADPCM_MTAF, + AV_CODEC_ID_ADPCM_AGM, /* AMR */ AV_CODEC_ID_AMR_NB = 0x12000, @@ -637,6 +650,8 @@ enum AVCodecID { AV_CODEC_ID_APTX, AV_CODEC_ID_APTX_HD, AV_CODEC_ID_SBC, + AV_CODEC_ID_ATRAC9, + AV_CODEC_ID_HCOM, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. @@ -665,6 +680,8 @@ enum AVCodecID { AV_CODEC_ID_PJS, AV_CODEC_ID_ASS, AV_CODEC_ID_HDMV_TEXT_SUBTITLE, + AV_CODEC_ID_TTML, + AV_CODEC_ID_ARIB_CAPTION, /* other specific kind of codecs (generally used for attachments) */ AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. @@ -844,6 +861,11 @@ typedef struct RcOverride{ */ #define AV_CODEC_FLAG_QPEL (1 << 4) /** + * Don't output frames whose parameters differ from first + * decoded frame in stream. + */ +#define AV_CODEC_FLAG_DROPCHANGED (1 << 5) +/** * Use internal 2pass ratecontrol in first pass mode. */ #define AV_CODEC_FLAG_PASS1 (1 << 9) @@ -1063,6 +1085,13 @@ typedef struct RcOverride{ #define AV_CODEC_CAP_HYBRID (1 << 19) /** + * This codec takes the reordered_opaque field from input AVFrames + * and returns it in the corresponding field in AVCodecContext after + * encoding. + */ +#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20) + +/** * Pan Scan area. * This specifies the area which should be displayed. * Note there may be multiple such areas for one frame. @@ -1101,17 +1130,29 @@ typedef struct AVCPBProperties { * Maximum bitrate of the stream, in bits per second. * Zero if unknown or unspecified. */ +#if FF_API_UNSANITIZED_BITRATES int max_bitrate; +#else + int64_t max_bitrate; +#endif /** * Minimum bitrate of the stream, in bits per second. * Zero if unknown or unspecified. */ +#if FF_API_UNSANITIZED_BITRATES int min_bitrate; +#else + int64_t min_bitrate; +#endif /** * Average bitrate of the stream, in bits per second. * Zero if unknown or unspecified. */ +#if FF_API_UNSANITIZED_BITRATES int avg_bitrate; +#else + int64_t avg_bitrate; +#endif /** * The size of the buffer to which the ratecontrol is applied, in bits. @@ -1312,7 +1353,7 @@ enum AVPacketSideDataType { AV_PKT_DATA_METADATA_UPDATE, /** - * MPEGTS stream ID, this is required to pass the stream ID + * MPEGTS stream ID as uint8_t, this is required to pass the stream ID * information from the demuxer to the corresponding muxer. */ AV_PKT_DATA_MPEGTS_STREAM_ID, @@ -1358,6 +1399,12 @@ enum AVPacketSideDataType { AV_PKT_DATA_ENCRYPTION_INFO, /** + * Active Format Description data consisting of a single byte as specified + * in ETSI TS 101 154 using AVActiveFormatDescription enum. + */ + AV_PKT_DATA_AFD, + + /** * The number of side data types. * This is not part of the public API/ABI in the sense that it may * change when new side data types are added. @@ -1612,6 +1659,7 @@ typedef struct AVCodecContext { * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger * than extradata_size to avoid problems if it is read with the bitstream reader. * The bytewise contents of extradata must not depend on the architecture or CPU endianness. + * Must be allocated with the av_malloc() family of functions. * - encoding: Set/allocated/freed by libavcodec. * - decoding: Set/allocated/freed by user. */ @@ -2009,15 +2057,19 @@ typedef struct AVCodecContext { /** * custom intra quantization matrix - * - encoding: Set by user, can be NULL. - * - decoding: Set by libavcodec. + * Must be allocated with the av_malloc() family of functions, and will be freed in + * avcodec_free_context(). + * - encoding: Set/allocated by user, freed by libavcodec. Can be NULL. + * - decoding: Set/allocated/freed by libavcodec. */ uint16_t *intra_matrix; /** * custom inter quantization matrix - * - encoding: Set by user, can be NULL. - * - decoding: Set by libavcodec. + * Must be allocated with the av_malloc() family of functions, and will be freed in + * avcodec_free_context(). + * - encoding: Set/allocated by user, freed by libavcodec. Can be NULL. + * - decoding: Set/allocated/freed by libavcodec. */ uint16_t *inter_matrix; @@ -2661,7 +2713,10 @@ typedef struct AVCodecContext { /** * opaque 64-bit number (generally a PTS) that will be reordered and * output in AVFrame.reordered_opaque - * - encoding: unused + * - encoding: Set by libavcodec to the reordered_opaque of the input + * frame corresponding to the last returned packet. Only + * supported by encoders with the + * AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE capability. * - decoding: Set by user. */ int64_t reordered_opaque; @@ -2945,6 +3000,16 @@ typedef struct AVCodecContext { #define FF_PROFILE_SBC_MSBC 1 +#define FF_PROFILE_PRORES_PROXY 0 +#define FF_PROFILE_PRORES_LT 1 +#define FF_PROFILE_PRORES_STANDARD 2 +#define FF_PROFILE_PRORES_HQ 3 +#define FF_PROFILE_PRORES_4444 4 +#define FF_PROFILE_PRORES_XQ 5 + +#define FF_PROFILE_ARIB_PROFILE_A 0 +#define FF_PROFILE_ARIB_PROFILE_C 1 + /** * level * - encoding: Set by user. @@ -3297,6 +3362,14 @@ typedef struct AVCodecContext { * used as reference pictures). */ int extra_hw_frames; + + /** + * The percentage of damaged samples to discard a frame. + * + * - decoding: set by user + * - encoding: unused + */ + int discard_damaged_percentage; } AVCodecContext; #if FF_API_CODEC_GET_SET @@ -4349,7 +4422,7 @@ int av_grow_packet(AVPacket *pkt, int grow_by); * Initialize a reference-counted packet from av_malloc()ed data. * * @param pkt packet to be initialized. This function will set the data, size, - * buf and destruct fields, all others are left untouched. + * and buf fields, all others are left untouched. * @param data Data allocated by av_malloc() to be used as packet data. If this * function returns successfully, the data is owned by the underlying AVBuffer. * The caller may not access the data through other means. @@ -4855,6 +4928,9 @@ int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt); * AVERROR_EOF: the decoder has been fully flushed, and there will be * no more output frames * AVERROR(EINVAL): codec not opened, or it is an encoder + * AVERROR_INPUT_CHANGED: current decoded frame has changed parameters + * with respect to first decoded frame. Applicable + * when flag AV_CODEC_FLAG_DROPCHANGED is set. * other negative values: legitimate decoding errors */ int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame); @@ -5766,6 +5842,7 @@ typedef struct AVBitStreamFilter { int (*init)(AVBSFContext *ctx); int (*filter)(AVBSFContext *ctx, AVPacket *pkt); void (*close)(AVBSFContext *ctx); + void (*flush)(AVBSFContext *ctx); } AVBitStreamFilter; #if FF_API_OLD_BSF @@ -5893,6 +5970,11 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt); int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt); /** + * Reset the internal bitstream filter state / flush internal buffers. + */ +void av_bsf_flush(AVBSFContext *ctx); + +/** * Free a bitstream filter context and everything associated with it; write NULL * into the supplied pointer. */ diff --git a/libs/ffvpx/libavcodec/avpacket.c b/libs/ffvpx/libavcodec/avpacket.c index 99a0c1383..2b2006721 100644 --- a/libs/ffvpx/libavcodec/avpacket.c +++ b/libs/ffvpx/libavcodec/avpacket.c @@ -112,7 +112,7 @@ int av_grow_packet(AVPacket *pkt, int grow_by) av_assert0((unsigned)pkt->size <= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE); if ((unsigned)grow_by > INT_MAX - (pkt->size + AV_INPUT_BUFFER_PADDING_SIZE)) - return -1; + return AVERROR(ENOMEM); new_size = pkt->size + grow_by + AV_INPUT_BUFFER_PADDING_SIZE; if (pkt->buf) { @@ -124,7 +124,7 @@ int av_grow_packet(AVPacket *pkt, int grow_by) } else { data_offset = pkt->data - pkt->buf->data; if (data_offset > INT_MAX - new_size) - return -1; + return AVERROR(ENOMEM); } if (new_size + data_offset > pkt->buf->size) { @@ -375,6 +375,9 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type) case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix"; case AV_PKT_DATA_STEREO3D: return "Stereo 3D"; case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type"; + case AV_PKT_DATA_QUALITY_STATS: return "Quality stats"; + case AV_PKT_DATA_FALLBACK_TRACK: return "Fallback track"; + case AV_PKT_DATA_CPB_PROPERTIES: return "CPB properties"; case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples"; case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono"; case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata"; @@ -388,6 +391,9 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type) case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: return "Content light level metadata"; case AV_PKT_DATA_SPHERICAL: return "Spherical Mapping"; case AV_PKT_DATA_A53_CC: return "A53 Closed Captions"; + case AV_PKT_DATA_ENCRYPTION_INIT_INFO: return "Encryption initialization data"; + case AV_PKT_DATA_ENCRYPTION_INFO: return "Encryption info"; + case AV_PKT_DATA_AFD: return "Active Format Description data"; } return NULL; } @@ -516,11 +522,12 @@ fail: int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict) { - const uint8_t *end = data + size; + const uint8_t *end; int ret = 0; if (!dict || !data || !size) return ret; + end = data + size; if (size && end[-1]) return AVERROR_INVALIDDATA; while (data < end) { @@ -574,10 +581,10 @@ FF_ENABLE_DEPRECATION_WARNINGS dst->side_data = NULL; dst->side_data_elems = 0; for (i = 0; i < src->side_data_elems; i++) { - enum AVPacketSideDataType type = src->side_data[i].type; - int size = src->side_data[i].size; - uint8_t *src_data = src->side_data[i].data; - uint8_t *dst_data = av_packet_new_side_data(dst, type, size); + enum AVPacketSideDataType type = src->side_data[i].type; + int size = src->side_data[i].size; + uint8_t *src_data = src->side_data[i].data; + uint8_t *dst_data = av_packet_new_side_data(dst, type, size); if (!dst_data) { av_packet_free_side_data(dst); @@ -610,6 +617,7 @@ int av_packet_ref(AVPacket *dst, const AVPacket *src) ret = packet_alloc(&dst->buf, src->size); if (ret < 0) goto fail; + av_assert1(!src->size || src->data); if (src->size) memcpy(dst->buf->data, src->data, src->size); @@ -662,6 +670,7 @@ int av_packet_make_refcounted(AVPacket *pkt) ret = packet_alloc(&pkt->buf, pkt->size); if (ret < 0) return ret; + av_assert1(!pkt->size || pkt->data); if (pkt->size) memcpy(pkt->buf->data, pkt->data, pkt->size); @@ -681,6 +690,7 @@ int av_packet_make_writable(AVPacket *pkt) ret = packet_alloc(&buf, pkt->size); if (ret < 0) return ret; + av_assert1(!pkt->size || pkt->data); if (pkt->size) memcpy(buf->data, pkt->data, pkt->size); diff --git a/libs/ffvpx/libavcodec/bitstream.c b/libs/ffvpx/libavcodec/bitstream.c index ed528fe4a..53a2db745 100644 --- a/libs/ffvpx/libavcodec/bitstream.c +++ b/libs/ffvpx/libavcodec/bitstream.c @@ -162,9 +162,9 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, uint32_t code; volatile VLC_TYPE (* volatile table)[2]; // the double volatile is needed to prevent an internal compiler error in gcc 4.2 - table_size = 1 << table_nb_bits; if (table_nb_bits > 30) - return -1; + return AVERROR(EINVAL); + table_size = 1 << table_nb_bits; table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); ff_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size); if (table_index < 0) @@ -188,8 +188,9 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, } for (k = 0; k < nb; k++) { int bits = table[j][1]; + int oldsym = table[j][0]; ff_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); - if (bits != 0 && bits != n) { + if ((bits || oldsym) && (bits != n || oldsym != symbol)) { av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); return AVERROR_INVALIDDATA; } @@ -226,6 +227,10 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, /* note: realloc has been done, so reload tables */ table = (volatile VLC_TYPE (*)[2])&vlc->table[table_index]; table[j][0] = index; //code + if (table[j][0] != index) { + avpriv_request_sample(NULL, "strange codes"); + return AVERROR_PATCHWELCOME; + } i = k-1; } } @@ -306,7 +311,7 @@ int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, av_log(NULL, AV_LOG_ERROR, "Too long VLC (%d) in init_vlc\n", buf[j].bits);\ if (!(flags & INIT_VLC_USE_NEW_STATIC)) \ av_free(buf); \ - return -1; \ + return AVERROR(EINVAL); \ } \ GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \ if (buf[j].code >= (1LL<<buf[j].bits)) { \ @@ -314,7 +319,7 @@ int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, "init_vlc\n", buf[j].code, i); \ if (!(flags & INIT_VLC_USE_NEW_STATIC)) \ av_free(buf); \ - return -1; \ + return AVERROR(EINVAL); \ } \ if (flags & INIT_VLC_LE) \ buf[j].code = bitswap_32(buf[j].code); \ diff --git a/libs/ffvpx/libavcodec/bitstream_filters.c b/libs/ffvpx/libavcodec/bitstream_filters.c index 18b698a85..463003966 100644 --- a/libs/ffvpx/libavcodec/bitstream_filters.c +++ b/libs/ffvpx/libavcodec/bitstream_filters.c @@ -25,6 +25,8 @@ #include "bsf.h" extern const AVBitStreamFilter ff_aac_adtstoasc_bsf; +extern const AVBitStreamFilter ff_av1_frame_split_bsf; +extern const AVBitStreamFilter ff_av1_metadata_bsf; extern const AVBitStreamFilter ff_chomp_bsf; extern const AVBitStreamFilter ff_dump_extradata_bsf; extern const AVBitStreamFilter ff_dca_core_bsf; @@ -46,9 +48,12 @@ extern const AVBitStreamFilter ff_mpeg4_unpack_bframes_bsf; extern const AVBitStreamFilter ff_mov2textsub_bsf; extern const AVBitStreamFilter ff_noise_bsf; extern const AVBitStreamFilter ff_null_bsf; +extern const AVBitStreamFilter ff_prores_metadata_bsf; extern const AVBitStreamFilter ff_remove_extradata_bsf; extern const AVBitStreamFilter ff_text2movsub_bsf; extern const AVBitStreamFilter ff_trace_headers_bsf; +extern const AVBitStreamFilter ff_truehd_core_bsf; +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; @@ -77,6 +82,9 @@ const AVBitStreamFilter *av_bsf_get_by_name(const char *name) const AVBitStreamFilter *f = NULL; void *i = 0; + if (!name) + return NULL; + while ((f = av_bsf_iterate(&i))) { if (!strcmp(f->name, name)) return f; diff --git a/libs/ffvpx/libavcodec/bsf.c b/libs/ffvpx/libavcodec/bsf.c index bd611ea16..e17dc854f 100644 --- a/libs/ffvpx/libavcodec/bsf.c +++ b/libs/ffvpx/libavcodec/bsf.c @@ -47,7 +47,8 @@ void av_bsf_free(AVBSFContext **pctx) av_opt_free(ctx); - av_packet_free(&ctx->internal->buffer_pkt); + if (ctx->internal) + av_packet_free(&ctx->internal->buffer_pkt); av_freep(&ctx->internal); av_freep(&ctx->priv_data); @@ -172,6 +173,16 @@ int av_bsf_init(AVBSFContext *ctx) return 0; } +void av_bsf_flush(AVBSFContext *ctx) +{ + ctx->internal->eof = 0; + + av_packet_unref(ctx->internal->buffer_pkt); + + if (ctx->filter->flush) + ctx->filter->flush(ctx); +} + int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt) { int ret; @@ -340,6 +351,15 @@ static int bsf_list_filter(AVBSFContext *bsf, AVPacket *out) return ret; } +static void bsf_list_flush(AVBSFContext *bsf) +{ + BSFListContext *lst = bsf->priv_data; + + for (int i = 0; i < lst->nb_bsfs; i++) + av_bsf_flush(lst->bsfs[i]); + lst->idx = lst->flushed_idx = 0; +} + static void bsf_list_close(AVBSFContext *bsf) { BSFListContext *lst = bsf->priv_data; @@ -388,6 +408,7 @@ const AVBitStreamFilter ff_list_bsf = { .priv_class = &bsf_list_class, .init = bsf_list_init, .filter = bsf_list_filter, + .flush = bsf_list_flush, .close = bsf_list_close, }; diff --git a/libs/ffvpx/libavcodec/codec_desc.c b/libs/ffvpx/libavcodec/codec_desc.c index 79552a910..4d033c20f 100644 --- a/libs/ffvpx/libavcodec/codec_desc.c +++ b/libs/ffvpx/libavcodec/codec_desc.c @@ -81,6 +81,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Motion JPEG"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, .mime_types= MT("image/jpeg"), + .profiles = NULL_IF_CONFIG_SMALL(ff_mjpeg_profiles), }, { .id = AV_CODEC_ID_MJPEGB, @@ -722,7 +723,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .id = AV_CODEC_ID_GIF, .type = AVMEDIA_TYPE_VIDEO, .name = "gif", - .long_name = NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"), + .long_name = NULL_IF_CONFIG_SMALL("CompuServe GIF (Graphics Interchange Format)"), .props = AV_CODEC_PROP_LOSSLESS, .mime_types= MT("image/gif"), }, @@ -1077,6 +1078,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "prores", .long_name = NULL_IF_CONFIG_SMALL("Apple ProRes (iCodec Pro)"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, + .profiles = NULL_IF_CONFIG_SMALL(ff_prores_profiles), }, { .id = AV_CODEC_ID_JV, @@ -1395,6 +1397,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .props = AV_CODEC_PROP_LOSSLESS, }, { + .id = AV_CODEC_ID_AVS2, + .type = AVMEDIA_TYPE_VIDEO, + .name = "avs2", + .long_name = NULL_IF_CONFIG_SMALL("AVS2-P2/IEEE1857.4"), + .props = AV_CODEC_PROP_LOSSY, + }, + { .id = AV_CODEC_ID_Y41P, .type = AVMEDIA_TYPE_VIDEO, .name = "y41p", @@ -1516,7 +1525,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .type = AVMEDIA_TYPE_VIDEO, .name = "truemotion2rt", .long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 2.0 Real Time"), - .props = AV_CODEC_PROP_LOSSY, + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, { .id = AV_CODEC_ID_M101, @@ -1647,6 +1656,76 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("FITS (Flexible Image Transport System)"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, }, + { + .id = AV_CODEC_ID_IMM4, + .type = AVMEDIA_TYPE_VIDEO, + .name = "imm4", + .long_name = NULL_IF_CONFIG_SMALL("Infinity IMM4"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_PROSUMER, + .type = AVMEDIA_TYPE_VIDEO, + .name = "prosumer", + .long_name = NULL_IF_CONFIG_SMALL("Brooktree ProSumer Video"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_MWSC, + .type = AVMEDIA_TYPE_VIDEO, + .name = "mwsc", + .long_name = NULL_IF_CONFIG_SMALL("MatchWare Screen Capture Codec"), + .props = AV_CODEC_PROP_LOSSLESS, + }, + { + .id = AV_CODEC_ID_WCMV, + .type = AVMEDIA_TYPE_VIDEO, + .name = "wcmv", + .long_name = NULL_IF_CONFIG_SMALL("WinCAM Motion Video"), + .props = AV_CODEC_PROP_LOSSLESS, + }, + { + .id = AV_CODEC_ID_RASC, + .type = AVMEDIA_TYPE_VIDEO, + .name = "rasc", + .long_name = NULL_IF_CONFIG_SMALL("RemotelyAnywhere Screen Capture"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_HYMT, + .type = AVMEDIA_TYPE_VIDEO, + .name = "hymt", + .long_name = NULL_IF_CONFIG_SMALL("HuffYUV MT"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + }, + { + .id = AV_CODEC_ID_ARBC, + .type = AVMEDIA_TYPE_VIDEO, + .name = "arbc", + .long_name = NULL_IF_CONFIG_SMALL("Gryphon's Anim Compressor"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_AGM, + .type = AVMEDIA_TYPE_VIDEO, + .name = "agm", + .long_name = NULL_IF_CONFIG_SMALL("Amuse Graphics Movie"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_LSCR, + .type = AVMEDIA_TYPE_VIDEO, + .name = "lscr", + .long_name = NULL_IF_CONFIG_SMALL("LEAD Screen Capture"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_VP4, + .type = AVMEDIA_TYPE_VIDEO, + .name = "vp4", + .long_name = NULL_IF_CONFIG_SMALL("On2 VP4"), + .props = AV_CODEC_PROP_LOSSY, + }, /* various PCM "codecs" */ { @@ -1894,6 +1973,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("PCM 24.0 floating point little-endian"), .props = AV_CODEC_PROP_LOSSLESS, }, + { + .id = AV_CODEC_ID_PCM_VIDC, + .type = AVMEDIA_TYPE_AUDIO, + .name = "pcm_vidc", + .long_name = NULL_IF_CONFIG_SMALL("PCM Archimedes VIDC"), + .props = AV_CODEC_PROP_LOSSY, + }, /* various ADPCM codecs */ { @@ -2183,6 +2269,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("ADPCM MTAF"), .props = AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_ADPCM_AGM, + .type = AVMEDIA_TYPE_AUDIO, + .name = "adpcm_agm", + .long_name = NULL_IF_CONFIG_SMALL("ADPCM AmuseGraphics Movie AGM"), + .props = AV_CODEC_PROP_LOSSY, + }, /* AMR */ { @@ -2878,6 +2971,20 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("SBC (low-complexity subband codec)"), .props = AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_ATRAC9, + .type = AVMEDIA_TYPE_AUDIO, + .name = "atrac9", + .long_name = NULL_IF_CONFIG_SMALL("ATRAC9 (Adaptive TRansform Acoustic Coding 9)"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_HCOM, + .type = AVMEDIA_TYPE_AUDIO, + .name = "hcom", + .long_name = NULL_IF_CONFIG_SMALL("HCOM Audio"), + .props = AV_CODEC_PROP_LOSSY, + }, /* subtitle codecs */ { @@ -3047,6 +3154,21 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("HDMV Text subtitle"), .props = AV_CODEC_PROP_TEXT_SUB, }, + { + .id = AV_CODEC_ID_TTML, + .type = AVMEDIA_TYPE_SUBTITLE, + .name = "ttml", + .long_name = NULL_IF_CONFIG_SMALL("Timed Text Markup Language"), + .props = AV_CODEC_PROP_TEXT_SUB, + }, + { + .id = AV_CODEC_ID_ARIB_CAPTION, + .type = AVMEDIA_TYPE_SUBTITLE, + .name = "arib_caption", + .long_name = NULL_IF_CONFIG_SMALL("ARIB STD-B24 caption"), + .props = AV_CODEC_PROP_TEXT_SUB, + .profiles = NULL_IF_CONFIG_SMALL(ff_arib_caption_profiles), + }, /* other kind of codecs and pseudo-codecs */ { diff --git a/libs/ffvpx/libavcodec/decode.c b/libs/ffvpx/libavcodec/decode.c index 421a8f1a3..9a6c57b7b 100644 --- a/libs/ffvpx/libavcodec/decode.c +++ b/libs/ffvpx/libavcodec/decode.c @@ -36,6 +36,7 @@ #include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/intmath.h" +#include "libavutil/opt.h" #include "avcodec.h" #include "bytestream.h" @@ -181,7 +182,7 @@ static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame) return 0; } -static int bsfs_init(AVCodecContext *avctx) +int ff_decode_bsfs_init(AVCodecContext *avctx) { AVCodecInternal *avci = avctx->internal; DecodeFilterContext *s = &avci->filter; @@ -195,27 +196,33 @@ static int bsfs_init(AVCodecContext *avctx) while (bsfs_str && *bsfs_str) { AVBSFContext **tmp; const AVBitStreamFilter *filter; - char *bsf; + char *bsf, *bsf_options_str, *bsf_name; bsf = av_get_token(&bsfs_str, ","); if (!bsf) { ret = AVERROR(ENOMEM); goto fail; } + bsf_name = av_strtok(bsf, "=", &bsf_options_str); + if (!bsf_name) { + av_freep(&bsf); + ret = AVERROR(ENOMEM); + goto fail; + } - filter = av_bsf_get_by_name(bsf); + filter = av_bsf_get_by_name(bsf_name); if (!filter) { av_log(avctx, AV_LOG_ERROR, "A non-existing bitstream filter %s " "requested by a decoder. This is a bug, please report it.\n", - bsf); - ret = AVERROR_BUG; + bsf_name); av_freep(&bsf); + ret = AVERROR_BUG; goto fail; } - av_freep(&bsf); tmp = av_realloc_array(s->bsfs, s->nb_bsfs + 1, sizeof(*s->bsfs)); if (!tmp) { + av_freep(&bsf); ret = AVERROR(ENOMEM); goto fail; } @@ -223,8 +230,10 @@ static int bsfs_init(AVCodecContext *avctx) s->nb_bsfs++; ret = av_bsf_alloc(filter, &s->bsfs[s->nb_bsfs - 1]); - if (ret < 0) + if (ret < 0) { + av_freep(&bsf); goto fail; + } if (s->nb_bsfs == 1) { /* We do not currently have an API for passing the input timebase into decoders, @@ -238,12 +247,38 @@ static int bsfs_init(AVCodecContext *avctx) ret = avcodec_parameters_copy(s->bsfs[s->nb_bsfs - 1]->par_in, s->bsfs[s->nb_bsfs - 2]->par_out); } - if (ret < 0) + if (ret < 0) { + av_freep(&bsf); goto fail; + } + + if (bsf_options_str && filter->priv_class) { + const AVOption *opt = av_opt_next(s->bsfs[s->nb_bsfs - 1]->priv_data, NULL); + const char * shorthand[2] = {NULL}; + + if (opt) + shorthand[0] = opt->name; + + ret = av_opt_set_from_string(s->bsfs[s->nb_bsfs - 1]->priv_data, bsf_options_str, shorthand, "=", ":"); + if (ret < 0) { + if (ret != AVERROR(ENOMEM)) { + av_log(avctx, AV_LOG_ERROR, "Invalid options for bitstream filter %s " + "requested by the decoder. This is a bug, please report it.\n", + bsf_name); + ret = AVERROR_BUG; + } + av_freep(&bsf); + goto fail; + } + } + av_freep(&bsf); ret = av_bsf_init(s->bsfs[s->nb_bsfs - 1]); if (ret < 0) goto fail; + + if (*bsfs_str) + bsfs_str++; } return 0; @@ -653,10 +688,6 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacke if (avpkt && !avpkt->size && avpkt->data) return AVERROR(EINVAL); - ret = bsfs_init(avctx); - if (ret < 0) - return ret; - av_packet_unref(avci->buffer_pkt); if (avpkt && (avpkt->data || avpkt->side_data_elems)) { ret = av_packet_ref(avci->buffer_pkt, avpkt); @@ -709,17 +740,13 @@ static int apply_cropping(AVCodecContext *avctx, AVFrame *frame) int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame) { AVCodecInternal *avci = avctx->internal; - int ret; + int ret, changed; av_frame_unref(frame); if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec)) return AVERROR(EINVAL); - ret = bsfs_init(avctx); - if (ret < 0) - return ret; - if (avci->buffer_frame->buf[0]) { av_frame_move_ref(frame, avci->buffer_frame); } else { @@ -738,6 +765,51 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr avctx->frame_number++; + if (avctx->flags & AV_CODEC_FLAG_DROPCHANGED) { + + if (avctx->frame_number == 1) { + avci->initial_format = frame->format; + switch(avctx->codec_type) { + case AVMEDIA_TYPE_VIDEO: + avci->initial_width = frame->width; + avci->initial_height = frame->height; + break; + case AVMEDIA_TYPE_AUDIO: + avci->initial_sample_rate = frame->sample_rate ? frame->sample_rate : + avctx->sample_rate; + avci->initial_channels = frame->channels; + avci->initial_channel_layout = frame->channel_layout; + break; + } + } + + if (avctx->frame_number > 1) { + changed = avci->initial_format != frame->format; + + switch(avctx->codec_type) { + case AVMEDIA_TYPE_VIDEO: + changed |= avci->initial_width != frame->width || + avci->initial_height != frame->height; + break; + case AVMEDIA_TYPE_AUDIO: + changed |= avci->initial_sample_rate != frame->sample_rate || + avci->initial_sample_rate != avctx->sample_rate || + avci->initial_channels != frame->channels || + avci->initial_channel_layout != frame->channel_layout; + break; + } + + if (changed) { + avci->changed_frames_dropped++; + av_log(avctx, AV_LOG_INFO, "dropped changed frame #%d pts %"PRId64 + " drop count: %d \n", + avctx->frame_number, frame->pts, + avci->changed_frames_dropped); + av_frame_unref(frame); + return AVERROR_INPUT_CHANGED; + } + } + } return 0; } @@ -1351,6 +1423,7 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt) if (i == n) { av_log(avctx, AV_LOG_ERROR, "Invalid return from get_format(): " "%s not in possible list.\n", desc->name); + ret = AV_PIX_FMT_NONE; break; } @@ -1469,7 +1542,7 @@ static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame) tmpsize = av_image_fill_pointers(data, avctx->pix_fmt, h, NULL, linesize); if (tmpsize < 0) - return -1; + return tmpsize; for (i = 0; i < 3 && data[i + 1]; i++) size[i] = data[i + 1] - data[i]; @@ -1837,7 +1910,8 @@ static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags) int ret; if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { - if ((ret = av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) { + if ((unsigned)avctx->width > INT_MAX - STRIDE_ALIGN || + (ret = av_image_check_size2(FFALIGN(avctx->width, STRIDE_ALIGN), avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) { av_log(avctx, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n"); return AVERROR(EINVAL); } @@ -1943,6 +2017,14 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame) return ret; } +static void bsfs_flush(AVCodecContext *avctx) +{ + DecodeFilterContext *s = &avctx->internal->filter; + + for (int i = 0; i < s->nb_bsfs; i++) + av_bsf_flush(s->bsfs[i]); +} + void avcodec_flush_buffers(AVCodecContext *avctx) { avctx->internal->draining = 0; @@ -1963,7 +2045,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx) avctx->pts_correction_last_pts = avctx->pts_correction_last_dts = INT64_MIN; - ff_decode_bsfs_uninit(avctx); + bsfs_flush(avctx); if (!avctx->refcounted_frames) av_frame_unref(avctx->internal->to_free); diff --git a/libs/ffvpx/libavcodec/decode.h b/libs/ffvpx/libavcodec/decode.h index 15271c529..c3e0e82f4 100644 --- a/libs/ffvpx/libavcodec/decode.h +++ b/libs/ffvpx/libavcodec/decode.h @@ -64,6 +64,8 @@ typedef struct FrameDecodeData { */ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt); +int ff_decode_bsfs_init(AVCodecContext *avctx); + void ff_decode_bsfs_uninit(AVCodecContext *avctx); /** diff --git a/libs/ffvpx/libavcodec/dummy_funcs.c b/libs/ffvpx/libavcodec/dummy_funcs.c index 295ee84e1..f99702a0f 100644 --- a/libs/ffvpx/libavcodec/dummy_funcs.c +++ b/libs/ffvpx/libavcodec/dummy_funcs.c @@ -61,12 +61,14 @@ AVCodec ff_aasc_decoder; AVCodec ff_aic_decoder; AVCodec ff_alias_pix_encoder; AVCodec ff_alias_pix_decoder; +AVCodec ff_agm_decoder; AVCodec ff_amv_encoder; AVCodec ff_amv_decoder; AVCodec ff_anm_decoder; AVCodec ff_ansi_decoder; AVCodec ff_apng_encoder; AVCodec ff_apng_decoder; +AVCodec ff_arbc_decoder; AVCodec ff_asv1_encoder; AVCodec ff_asv1_decoder; AVCodec ff_asv2_encoder; @@ -84,6 +86,7 @@ AVCodec ff_ayuv_decoder; AVCodec ff_bethsoftvid_decoder; AVCodec ff_bfi_decoder; AVCodec ff_bink_decoder; +AVCodec ff_bitpacked_decoder; AVCodec ff_bmp_encoder; AVCodec ff_bmp_decoder; AVCodec ff_bmv_video_decoder; @@ -165,9 +168,11 @@ AVCodec ff_hq_hqa_decoder; AVCodec ff_hqx_decoder; AVCodec ff_huffyuv_encoder; AVCodec ff_huffyuv_decoder; +AVCodec ff_hymt_decoder; AVCodec ff_idcin_decoder; AVCodec ff_iff_byterun1_decoder; AVCodec ff_iff_ilbm_decoder; +AVCodec ff_imm4_decoder; AVCodec ff_indeo2_decoder; AVCodec ff_indeo3_decoder; AVCodec ff_indeo4_decoder; @@ -183,6 +188,7 @@ AVCodec ff_kmvc_decoder; AVCodec ff_lagarith_decoder; AVCodec ff_ljpeg_encoder; AVCodec ff_loco_decoder; +AVCodec ff_lscr_decoder; AVCodec ff_mdec_decoder; AVCodec ff_mimic_decoder; AVCodec ff_mjpeg_encoder; @@ -217,6 +223,7 @@ AVCodec ff_mszh_decoder; AVCodec ff_mts2_decoder; AVCodec ff_mvc1_decoder; AVCodec ff_mvc2_decoder; +AVCodec ff_mwsc_decoder; AVCodec ff_mxpeg_decoder; AVCodec ff_nuv_decoder; AVCodec ff_paf_video_decoder; @@ -239,7 +246,7 @@ AVCodec ff_prores_encoder; AVCodec ff_prores_decoder; AVCodec ff_prores_aw_encoder; AVCodec ff_prores_ks_encoder; -AVCodec ff_prores_lgpl_decoder; +AVCodec ff_prosumer_decoder; AVCodec ff_ptx_decoder; AVCodec ff_qdraw_decoder; AVCodec ff_qpeg_decoder; @@ -249,6 +256,7 @@ AVCodec ff_r10k_encoder; AVCodec ff_r10k_decoder; AVCodec ff_r210_encoder; AVCodec ff_r210_decoder; +AVCodec ff_rasc_decoder; AVCodec ff_rawvideo_encoder; AVCodec ff_rawvideo_decoder; AVCodec ff_rl2_decoder; @@ -316,6 +324,7 @@ AVCodec ff_vcr1_decoder; AVCodec ff_vmdvideo_decoder; AVCodec ff_vmnc_decoder; AVCodec ff_vp3_decoder; +AVCodec ff_vp4_decoder; AVCodec ff_vp5_decoder; AVCodec ff_vp6_decoder; AVCodec ff_vp6a_decoder; @@ -390,7 +399,9 @@ AVCodec ff_g723_1_decoder; AVCodec ff_g729_decoder; AVCodec ff_gsm_decoder; AVCodec ff_gsm_ms_decoder; +AVCodec ff_hcom_decoder; AVCodec ff_iac_decoder; +AVCodec ff_ilbc_decoder; AVCodec ff_imc_decoder; AVCodec ff_mace3_decoder; AVCodec ff_mace6_decoder; @@ -449,6 +460,7 @@ AVCodec ff_ws_snd1_decoder; AVCodec ff_pcm_alaw_encoder; AVCodec ff_pcm_alaw_decoder; AVCodec ff_pcm_bluray_decoder; +AVCodec ff_pcm_dvd_encoder; AVCodec ff_pcm_dvd_decoder; AVCodec ff_pcm_f32be_encoder; AVCodec ff_pcm_f32be_decoder; @@ -501,6 +513,8 @@ AVCodec ff_pcm_u32be_encoder; AVCodec ff_pcm_u32be_decoder; AVCodec ff_pcm_u32le_encoder; AVCodec ff_pcm_u32le_decoder; +AVCodec ff_pcm_vidc_encoder; +AVCodec ff_pcm_vidc_decoder; AVCodec ff_pcm_zork_decoder; AVCodec ff_interplay_dpcm_decoder; AVCodec ff_roq_dpcm_encoder; @@ -511,6 +525,7 @@ AVCodec ff_adpcm_4xm_decoder; AVCodec ff_adpcm_adx_encoder; AVCodec ff_adpcm_adx_decoder; AVCodec ff_adpcm_afc_decoder; +AVCodec ff_adpcm_agm_decoder; AVCodec ff_adpcm_ct_decoder; AVCodec ff_adpcm_dtk_decoder; AVCodec ff_adpcm_ea_decoder; @@ -629,6 +644,7 @@ AVCodec ff_libx264_encoder; AVCodec ff_libx264rgb_encoder; AVCodec ff_libx265_encoder; AVCodec ff_libxavs_encoder; +AVCodec ff_libxavs2_encoder; AVCodec ff_libxvid_encoder; AVCodec ff_libzvbi_teletext_decoder; AVCodec ff_libaacplus_encoder; @@ -669,6 +685,9 @@ AVCodec ff_h264_omx_encoder; AVCodec ff_h264_nvenc_encoder; AVCodec ff_h264_cuvid_decoder; AVCodec ff_qdm2_at_decoder; +AVCodec ff_libaribb24_decoder; +AVCodec ff_libdav1d_decoder; +AVCodec ff_libdavs2_decoder; AVCodec ff_qdmc_at_decoder; AVCodec ff_pcm_mulaw_at_decoder; AVCodec ff_pcm_mulaw_at_encoder; @@ -738,11 +757,12 @@ AVCodec ff_vp8_rkmpp_decoder; AVCodec ff_vp8_v4l2m2m_decoder; AVCodec ff_vp9_rkmpp_decoder; AVCodec ff_vp9_v4l2m2m_decoder; -AVCodec ff_bitpacked_decoder; +AVCodec ff_wcmv_decoder; AVCodec ff_wrapped_avframe_decoder; AVCodec ff_xpm_decoder; AVCodec ff_atrac3al_decoder; AVCodec ff_atrac3pal_decoder; +AVCodec ff_atrac9_decoder; AVCodec ff_dolby_e_decoder; AVCodec ff_opus_encoder; AVCodec ff_qdmc_decoder; diff --git a/libs/ffvpx/libavcodec/flac_parser.c b/libs/ffvpx/libavcodec/flac_parser.c index 272128646..db6765f34 100644 --- a/libs/ffvpx/libavcodec/flac_parser.c +++ b/libs/ffvpx/libavcodec/flac_parser.c @@ -55,6 +55,7 @@ /** largest possible size of flac header */ #define MAX_FRAME_HEADER_SIZE 16 +#define MAX_FRAME_VERIFY_SIZE (MAX_FRAME_HEADER_SIZE) typedef struct FLACHeaderMarker { int offset; /**< byte offset from start of FLACParseContext->buffer */ @@ -169,7 +170,7 @@ static int find_headers_search_validate(FLACParseContext *fpc, int offset) uint8_t *header_buf; int size = 0; header_buf = flac_fifo_read_wrap(fpc, offset, - MAX_FRAME_HEADER_SIZE, + MAX_FRAME_VERIFY_SIZE + AV_INPUT_BUFFER_PADDING_SIZE, &fpc->wrap_buf, &fpc->wrap_buf_allocated_size); if (frame_header_is_valid(fpc->avctx, header_buf, &fi)) { @@ -216,16 +217,20 @@ static int find_headers_search(FLACParseContext *fpc, uint8_t *buf, int buf_size uint32_t x; for (i = 0; i < mod_offset; i++) { - if ((AV_RB16(buf + i) & 0xFFFE) == 0xFFF8) - size = find_headers_search_validate(fpc, search_start + i); + if ((AV_RB16(buf + i) & 0xFFFE) == 0xFFF8) { + int ret = find_headers_search_validate(fpc, search_start + i); + size = FFMAX(size, ret); + } } for (; i < buf_size - 1; i += 4) { x = AV_RB32(buf + i); if (((x & ~(x + 0x01010101)) & 0x80808080)) { for (j = 0; j < 4; j++) { - if ((AV_RB16(buf + i + j) & 0xFFFE) == 0xFFF8) - size = find_headers_search_validate(fpc, search_start + i + j); + if ((AV_RB16(buf + i + j) & 0xFFFE) == 0xFFF8) { + int ret = find_headers_search_validate(fpc, search_start + i + j); + size = FFMAX(size, ret); + } } } } diff --git a/libs/ffvpx/libavcodec/flacdec.c b/libs/ffvpx/libavcodec/flacdec.c index c8eb45604..8de8ebd80 100644 --- a/libs/ffvpx/libavcodec/flacdec.c +++ b/libs/ffvpx/libavcodec/flacdec.c @@ -262,7 +262,7 @@ static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order) } else { int real_limit = tmp ? (INT_MAX >> tmp) + 2 : INT_MAX; for (; i < samples; i++) { - int v = get_sr_golomb_flac(&gb, tmp, real_limit, 0); + int v = get_sr_golomb_flac(&gb, tmp, real_limit, 1); if (v == 0x80000000){ av_log(s->avctx, AV_LOG_ERROR, "invalid residual\n"); return AVERROR_INVALIDDATA; diff --git a/libs/ffvpx/libavcodec/flacdsp_template.c b/libs/ffvpx/libavcodec/flacdsp_template.c index 776c78da7..892418cdd 100644 --- a/libs/ffvpx/libavcodec/flacdsp_template.c +++ b/libs/ffvpx/libavcodec/flacdsp_template.c @@ -66,8 +66,8 @@ static void FUNC(flac_decorrelate_ls_c)(uint8_t **out, int32_t **in, int i; for (i = 0; i < len; i++) { - int a = in[0][i]; - int b = in[1][i]; + unsigned a = in[0][i]; + unsigned b = in[1][i]; S(samples, 0, i) = a << shift; S(samples, 1, i) = (a - b) << shift; } @@ -80,8 +80,8 @@ static void FUNC(flac_decorrelate_rs_c)(uint8_t **out, int32_t **in, int i; for (i = 0; i < len; i++) { - int a = in[0][i]; - int b = in[1][i]; + unsigned a = in[0][i]; + unsigned b = in[1][i]; S(samples, 0, i) = (a + b) << shift; S(samples, 1, i) = b << shift; } @@ -94,7 +94,7 @@ static void FUNC(flac_decorrelate_ms_c)(uint8_t **out, int32_t **in, int i; for (i = 0; i < len; i++) { - int a = in[0][i]; + unsigned a = in[0][i]; int b = in[1][i]; a -= b >> 1; S(samples, 0, i) = (a + b) << shift; diff --git a/libs/ffvpx/libavcodec/frame_thread_encoder.h b/libs/ffvpx/libavcodec/frame_thread_encoder.h index 1f79553f2..fc85ba48b 100644 --- a/libs/ffvpx/libavcodec/frame_thread_encoder.h +++ b/libs/ffvpx/libavcodec/frame_thread_encoder.h @@ -23,6 +23,10 @@ #include "avcodec.h" +/** + * Initialize frame thread encoder. + * @note hardware encoders are not supported + */ int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options); void ff_frame_thread_encoder_free(AVCodecContext *avctx); int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet_ptr); diff --git a/libs/ffvpx/libavcodec/get_bits.h b/libs/ffvpx/libavcodec/get_bits.h index 56ef5f0cb..c4ab60774 100644 --- a/libs/ffvpx/libavcodec/get_bits.h +++ b/libs/ffvpx/libavcodec/get_bits.h @@ -1,5 +1,6 @@ /* - * copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> + * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> + * Copyright (c) 2016 Alexandra Hájková * * This file is part of FFmpeg. * @@ -53,13 +54,25 @@ #define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER #endif +#ifndef CACHED_BITSTREAM_READER +#define CACHED_BITSTREAM_READER 0 +#endif + typedef struct GetBitContext { const uint8_t *buffer, *buffer_end; +#if CACHED_BITSTREAM_READER + uint64_t cache; + unsigned bits_left; +#endif int index; int size_in_bits; int size_in_bits_plus8; } GetBitContext; +static inline unsigned int get_bits(GetBitContext *s, int n); +static inline void skip_bits(GetBitContext *s, int n); +static inline unsigned int show_bits(GetBitContext *s, int n); + /* Bitstream reader API docs: * name * arbitrary name which is used as prefix for the internal variables @@ -107,12 +120,16 @@ typedef struct GetBitContext { * For examples see get_bits, show_bits, skip_bits, get_vlc. */ -#ifdef LONG_BITSTREAM_READER +#if CACHED_BITSTREAM_READER +# define MIN_CACHE_BITS 64 +#elif defined LONG_BITSTREAM_READER # define MIN_CACHE_BITS 32 #else # define MIN_CACHE_BITS 25 #endif +#if !CACHED_BITSTREAM_READER + #define OPEN_READER_NOSIZE(name, gb) \ unsigned int name ## _index = (gb)->index; \ unsigned int av_unused name ## _cache @@ -197,10 +214,72 @@ typedef struct GetBitContext { #define GET_CACHE(name, gb) ((uint32_t) name ## _cache) +#endif + static inline int get_bits_count(const GetBitContext *s) { +#if CACHED_BITSTREAM_READER + return s->index - s->bits_left; +#else return s->index; +#endif +} + +#if CACHED_BITSTREAM_READER +static inline void refill_32(GetBitContext *s, int is_le) +{ +#if !UNCHECKED_BITSTREAM_READER + if (s->index >> 3 >= s->buffer_end - s->buffer) + return; +#endif + + if (is_le) + s->cache = (uint64_t)AV_RL32(s->buffer + (s->index >> 3)) << s->bits_left | s->cache; + else + s->cache = s->cache | (uint64_t)AV_RB32(s->buffer + (s->index >> 3)) << (32 - s->bits_left); + s->index += 32; + s->bits_left += 32; +} + +static inline void refill_64(GetBitContext *s, int is_le) +{ +#if !UNCHECKED_BITSTREAM_READER + if (s->index >> 3 >= s->buffer_end - s->buffer) + return; +#endif + + if (is_le) + s->cache = AV_RL64(s->buffer + (s->index >> 3)); + else + s->cache = AV_RB64(s->buffer + (s->index >> 3)); + s->index += 64; + s->bits_left = 64; +} + +static inline uint64_t get_val(GetBitContext *s, unsigned n, int is_le) +{ + uint64_t ret; + av_assert2(n>0 && n<=63); + if (is_le) { + ret = s->cache & ((UINT64_C(1) << n) - 1); + s->cache >>= n; + } else { + ret = s->cache >> (64 - n); + s->cache <<= n; + } + s->bits_left -= n; + return ret; +} + +static inline unsigned show_val(const GetBitContext *s, unsigned n) +{ +#ifdef BITSTREAM_READER_LE + return s->cache & ((UINT64_C(1) << n) - 1); +#else + return s->cache >> (64 - n); +#endif } +#endif /** * Skips the specified number of bits. @@ -211,13 +290,29 @@ static inline int get_bits_count(const GetBitContext *s) */ static inline void skip_bits_long(GetBitContext *s, int n) { +#if CACHED_BITSTREAM_READER + skip_bits(s, n); +#else #if UNCHECKED_BITSTREAM_READER s->index += n; #else s->index += av_clip(n, -s->index, s->size_in_bits_plus8 - s->index); #endif +#endif } +#if CACHED_BITSTREAM_READER +static inline void skip_remaining(GetBitContext *s, unsigned n) +{ +#ifdef BITSTREAM_READER_LE + s->cache >>= n; +#else + s->cache <<= n; +#endif + s->bits_left -= n; +} +#endif + /** * Read MPEG-1 dc-style VLC (sign bit + mantissa with no MSB). * if MSB not set it is negative @@ -225,6 +320,13 @@ static inline void skip_bits_long(GetBitContext *s, int n) */ static inline int get_xbits(GetBitContext *s, int n) { +#if CACHED_BITSTREAM_READER + int32_t cache = show_bits(s, 32); + int sign = ~cache >> 31; + skip_remaining(s, n); + + return ((((uint32_t)(sign ^ cache)) >> (32 - n)) ^ sign) - sign; +#else register int sign; register int32_t cache; OPEN_READER(re, s); @@ -235,8 +337,10 @@ static inline int get_xbits(GetBitContext *s, int n) LAST_SKIP_BITS(re, s, n); CLOSE_READER(re, s); return (NEG_USR32(sign ^ cache, n) ^ sign) - sign; +#endif } +#if !CACHED_BITSTREAM_READER static inline int get_xbits_le(GetBitContext *s, int n) { register int sign; @@ -250,16 +354,22 @@ static inline int get_xbits_le(GetBitContext *s, int n) CLOSE_READER(re, s); return (zero_extend(sign ^ cache, n) ^ sign) - sign; } +#endif static inline int get_sbits(GetBitContext *s, int n) { register int tmp; +#if CACHED_BITSTREAM_READER + av_assert2(n>0 && n<=25); + tmp = sign_extend(get_bits(s, n), n); +#else OPEN_READER(re, s); av_assert2(n>0 && n<=25); UPDATE_CACHE(re, s); tmp = SHOW_SBITS(re, s, n); LAST_SKIP_BITS(re, s, n); CLOSE_READER(re, s); +#endif return tmp; } @@ -268,13 +378,34 @@ static inline int get_sbits(GetBitContext *s, int n) */ static inline unsigned int get_bits(GetBitContext *s, int n) { - register int tmp; + register unsigned int tmp; +#if CACHED_BITSTREAM_READER + + av_assert2(n>0 && n<=32); + if (n > s->bits_left) { +#ifdef BITSTREAM_READER_LE + refill_32(s, 1); +#else + refill_32(s, 0); +#endif + if (s->bits_left < 32) + s->bits_left = n; + } + +#ifdef BITSTREAM_READER_LE + tmp = get_val(s, n, 1); +#else + tmp = get_val(s, n, 0); +#endif +#else OPEN_READER(re, s); av_assert2(n>0 && n<=25); UPDATE_CACHE(re, s); tmp = SHOW_UBITS(re, s, n); LAST_SKIP_BITS(re, s, n); CLOSE_READER(re, s); +#endif + av_assert2(tmp < UINT64_C(1) << n); return tmp; } @@ -288,6 +419,16 @@ static av_always_inline int get_bitsz(GetBitContext *s, int n) static inline unsigned int get_bits_le(GetBitContext *s, int n) { +#if CACHED_BITSTREAM_READER + av_assert2(n>0 && n<=32); + if (n > s->bits_left) { + refill_32(s, 1); + if (s->bits_left < 32) + s->bits_left = n; + } + + return get_val(s, n, 1); +#else register int tmp; OPEN_READER(re, s); av_assert2(n>0 && n<=25); @@ -296,6 +437,7 @@ static inline unsigned int get_bits_le(GetBitContext *s, int n) LAST_SKIP_BITS(re, s, n); CLOSE_READER(re, s); return tmp; +#endif } /** @@ -303,23 +445,72 @@ static inline unsigned int get_bits_le(GetBitContext *s, int n) */ static inline unsigned int show_bits(GetBitContext *s, int n) { - register int tmp; + register unsigned int tmp; +#if CACHED_BITSTREAM_READER + if (n > s->bits_left) +#ifdef BITSTREAM_READER_LE + refill_32(s, 1); +#else + refill_32(s, 0); +#endif + + tmp = show_val(s, n); +#else OPEN_READER_NOSIZE(re, s); av_assert2(n>0 && n<=25); UPDATE_CACHE(re, s); tmp = SHOW_UBITS(re, s, n); +#endif return tmp; } static inline void skip_bits(GetBitContext *s, int n) { +#if CACHED_BITSTREAM_READER + if (n < s->bits_left) + skip_remaining(s, n); + else { + n -= s->bits_left; + s->cache = 0; + s->bits_left = 0; + + if (n >= 64) { + unsigned skip = (n / 8) * 8; + + n -= skip; + s->index += skip; + } +#ifdef BITSTREAM_READER_LE + refill_64(s, 1); +#else + refill_64(s, 0); +#endif + if (n) + skip_remaining(s, n); + } +#else OPEN_READER(re, s); LAST_SKIP_BITS(re, s, n); CLOSE_READER(re, s); +#endif } static inline unsigned int get_bits1(GetBitContext *s) { +#if CACHED_BITSTREAM_READER + if (!s->bits_left) +#ifdef BITSTREAM_READER_LE + refill_64(s, 1); +#else + refill_64(s, 0); +#endif + +#ifdef BITSTREAM_READER_LE + return get_val(s, 1, 1); +#else + return get_val(s, 1, 0); +#endif +#else unsigned int index = s->index; uint8_t result = s->buffer[index >> 3]; #ifdef BITSTREAM_READER_LE @@ -336,6 +527,7 @@ static inline unsigned int get_bits1(GetBitContext *s) s->index = index; return result; +#endif } static inline unsigned int show_bits1(GetBitContext *s) @@ -356,6 +548,10 @@ static inline unsigned int get_bits_long(GetBitContext *s, int n) av_assert2(n>=0 && n<=32); if (!n) { return 0; +#if CACHED_BITSTREAM_READER + } + return get_bits(s, n); +#else } else if (n <= MIN_CACHE_BITS) { return get_bits(s, n); } else { @@ -367,6 +563,7 @@ static inline unsigned int get_bits_long(GetBitContext *s, int n) return ret | get_bits(s, n - 16); #endif } +#endif } /** @@ -422,16 +619,8 @@ static inline int check_marker(void *logctx, GetBitContext *s, const char *msg) return bit; } -/** - * Initialize GetBitContext. - * @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes - * larger than the actual read bits because some optimized bitstream - * readers read 32 or 64 bit at once and could read over the end - * @param bit_size the size of the buffer in bits - * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow. - */ -static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer, - int bit_size) +static inline int init_get_bits_xe(GetBitContext *s, const uint8_t *buffer, + int bit_size, int is_le) { int buffer_size; int ret = 0; @@ -450,6 +639,12 @@ static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer, s->buffer_end = buffer + buffer_size; s->index = 0; +#if CACHED_BITSTREAM_READER + s->cache = 0; + s->bits_left = 0; + refill_64(s, is_le); +#endif + return ret; } @@ -458,6 +653,24 @@ static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer, * @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes * larger than the actual read bits because some optimized bitstream * readers read 32 or 64 bit at once and could read over the end + * @param bit_size the size of the buffer in bits + * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow. + */ +static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer, + int bit_size) +{ +#ifdef BITSTREAM_READER_LE + return init_get_bits_xe(s, buffer, bit_size, 1); +#else + return init_get_bits_xe(s, buffer, bit_size, 0); +#endif +} + +/** + * Initialize GetBitContext. + * @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes + * larger than the actual read bits because some optimized bitstream + * readers read 32 or 64 bit at once and could read over the end * @param byte_size the size of the buffer in bytes * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow. */ @@ -469,6 +682,14 @@ static inline int init_get_bits8(GetBitContext *s, const uint8_t *buffer, return init_get_bits(s, buffer, byte_size * 8); } +static inline int init_get_bits8_le(GetBitContext *s, const uint8_t *buffer, + int byte_size) +{ + if (byte_size > INT_MAX / 8 || byte_size < 0) + byte_size = -1; + return init_get_bits_xe(s, buffer, byte_size * 8, 1); +} + static inline const uint8_t *align_get_bits(GetBitContext *s) { int n = -get_bits_count(s) & 7; @@ -551,6 +772,19 @@ static inline const uint8_t *align_get_bits(GetBitContext *s) SKIP_BITS(name, gb, n); \ } while (0) +/* Return the LUT element for the given bitstream configuration. */ +static inline int set_idx(GetBitContext *s, int code, int *n, int *nb_bits, + VLC_TYPE (*table)[2]) +{ + unsigned idx; + + *nb_bits = -*n; + idx = show_bits(s, *nb_bits) + code; + *n = table[idx][1]; + + return table[idx][0]; +} + /** * Parse a vlc code. * @param bits is the number of bits which will be read at once, must be @@ -563,6 +797,24 @@ static inline const uint8_t *align_get_bits(GetBitContext *s) static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth) { +#if CACHED_BITSTREAM_READER + int nb_bits; + unsigned idx = show_bits(s, bits); + int code = table[idx][0]; + int n = table[idx][1]; + + if (max_depth > 1 && n < 0) { + skip_remaining(s, bits); + code = set_idx(s, code, &n, &nb_bits, table); + if (max_depth > 2 && n < 0) { + skip_remaining(s, nb_bits); + code = set_idx(s, code, &n, &nb_bits, table); + } + } + skip_remaining(s, n); + + return code; +#else int code; OPEN_READER(re, s); @@ -573,6 +825,7 @@ static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], CLOSE_READER(re, s); return code; +#endif } static inline int decode012(GetBitContext *gb) diff --git a/libs/ffvpx/libavcodec/golomb.h b/libs/ffvpx/libavcodec/golomb.h index efb1eff8a..5cdfa0945 100644 --- a/libs/ffvpx/libavcodec/golomb.h +++ b/libs/ffvpx/libavcodec/golomb.h @@ -49,11 +49,30 @@ extern const uint8_t ff_interleaved_dirac_golomb_vlc_code[256]; /** * Read an unsigned Exp-Golomb code in the range 0 to 8190. + * + * @returns the read value or a negative error code. */ static inline int get_ue_golomb(GetBitContext *gb) { unsigned int buf; +#if CACHED_BITSTREAM_READER + buf = show_bits_long(gb, 32); + + if (buf >= (1 << 27)) { + buf >>= 32 - 9; + skip_bits_long(gb, ff_golomb_vlc_len[buf]); + + return ff_ue_golomb_vlc_code[buf]; + } else { + int log = 2 * av_log2(buf) - 31; + buf >>= log; + buf--; + skip_bits_long(gb, 32 - log); + + return buf; + } +#else OPEN_READER(re, gb); UPDATE_CACHE(re, gb); buf = GET_CACHE(re, gb); @@ -77,6 +96,7 @@ static inline int get_ue_golomb(GetBitContext *gb) return buf; } +#endif } /** @@ -101,6 +121,13 @@ static inline int get_ue_golomb_31(GetBitContext *gb) { unsigned int buf; +#if CACHED_BITSTREAM_READER + buf = show_bits_long(gb, 32); + + buf >>= 32 - 9; + skip_bits_long(gb, ff_golomb_vlc_len[buf]); +#else + OPEN_READER(re, gb); UPDATE_CACHE(re, gb); buf = GET_CACHE(re, gb); @@ -108,6 +135,7 @@ static inline int get_ue_golomb_31(GetBitContext *gb) buf >>= 32 - 9; LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]); CLOSE_READER(re, gb); +#endif return ff_ue_golomb_vlc_code[buf]; } @@ -116,6 +144,33 @@ static inline unsigned get_interleaved_ue_golomb(GetBitContext *gb) { uint32_t buf; +#if CACHED_BITSTREAM_READER + buf = show_bits_long(gb, 32); + + if (buf & 0xAA800000) { + buf >>= 32 - 8; + skip_bits_long(gb, ff_interleaved_golomb_vlc_len[buf]); + + return ff_interleaved_ue_golomb_vlc_code[buf]; + } else { + unsigned ret = 1; + + do { + buf >>= 32 - 8; + skip_bits_long(gb, FFMIN(ff_interleaved_golomb_vlc_len[buf], 8)); + + if (ff_interleaved_golomb_vlc_len[buf] != 9) { + ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1; + ret |= ff_interleaved_dirac_golomb_vlc_code[buf]; + break; + } + ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf]; + buf = show_bits_long(gb, 32); + } while (get_bits_left(gb) > 0); + + return ret - 1; + } +#else OPEN_READER(re, gb); UPDATE_CACHE(re, gb); buf = GET_CACHE(re, gb); @@ -147,6 +202,7 @@ static inline unsigned get_interleaved_ue_golomb(GetBitContext *gb) CLOSE_READER(re, gb); return ret - 1; } +#endif } /** @@ -184,6 +240,28 @@ static inline int get_se_golomb(GetBitContext *gb) { unsigned int buf; +#if CACHED_BITSTREAM_READER + buf = show_bits_long(gb, 32); + + if (buf >= (1 << 27)) { + buf >>= 32 - 9; + skip_bits_long(gb, ff_golomb_vlc_len[buf]); + + return ff_se_golomb_vlc_code[buf]; + } else { + int log = 2 * av_log2(buf) - 31; + buf >>= log; + + skip_bits_long(gb, 32 - log); + + if (buf & 1) + buf = -(buf >> 1); + else + buf = (buf >> 1); + + return buf; + } +#else OPEN_READER(re, gb); UPDATE_CACHE(re, gb); buf = GET_CACHE(re, gb); @@ -210,6 +288,7 @@ static inline int get_se_golomb(GetBitContext *gb) return buf; } +#endif } static inline int get_se_golomb_long(GetBitContext *gb) @@ -223,6 +302,30 @@ static inline int get_interleaved_se_golomb(GetBitContext *gb) { unsigned int buf; +#if CACHED_BITSTREAM_READER + buf = show_bits_long(gb, 32); + + if (buf & 0xAA800000) { + buf >>= 32 - 8; + skip_bits_long(gb, ff_interleaved_golomb_vlc_len[buf]); + + return ff_interleaved_se_golomb_vlc_code[buf]; + } else { + int log; + skip_bits(gb, 8); + buf |= 1 | show_bits_long(gb, 24); + + if ((buf & 0xAAAAAAAA) == 0) + return INVALID_VLC; + + for (log = 31; (buf & 0x80000000) == 0; log--) + buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30); + + skip_bits_long(gb, 63 - 2 * log - 8); + + return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1; + } +#else OPEN_READER(re, gb); UPDATE_CACHE(re, gb); buf = GET_CACHE(re, gb); @@ -250,6 +353,7 @@ static inline int get_interleaved_se_golomb(GetBitContext *gb) return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1; } +#endif } static inline int dirac_get_se_golomb(GetBitContext *gb) @@ -273,6 +377,24 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, unsigned int buf; int log; +#if CACHED_BITSTREAM_READER + buf = show_bits_long(gb, 32); + + log = av_log2(buf); + + if (log > 31 - limit) { + buf >>= log - k; + buf += (30 - log) << k; + skip_bits_long(gb, 32 + k - log); + + return buf; + } else { + skip_bits_long(gb, limit); + buf = get_bits_long(gb, esc_len); + + return buf + limit - 1; + } +#else OPEN_READER(re, gb); UPDATE_CACHE(re, gb); buf = GET_CACHE(re, gb); @@ -297,6 +419,7 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, return buf + limit - 1; } +#endif } /** @@ -308,6 +431,35 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, unsigned int buf; int log; +#if CACHED_BITSTREAM_READER + buf = show_bits_long(gb, 32); + + log = av_log2(buf); + + if (log - k >= 1 && 32 - log < limit) { + buf >>= log - k; + buf += (30 - log) << k; + skip_bits_long(gb, 32 + k - log); + + return buf; + } else { + int i; + for (i = 0; + i < limit && get_bits1(gb) == 0 && get_bits_left(gb) > 0; + i++); + + if (i < limit - 1) { + buf = get_bits_long(gb, k); + + return buf + (i << k); + } else if (i == limit - 1) { + buf = get_bits_long(gb, esc_len); + + return buf + 1; + } else + return -1; + } +#else OPEN_READER(re, gb); UPDATE_CACHE(re, gb); buf = GET_CACHE(re, gb); @@ -326,15 +478,19 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, return buf; } else { int i; - for (i = 0; i < limit && SHOW_UBITS(re, gb, 1) == 0; i++) { + for (i = 0; i + MIN_CACHE_BITS <= limit && SHOW_UBITS(re, gb, MIN_CACHE_BITS) == 0; i += MIN_CACHE_BITS) { if (gb->size_in_bits <= re_index) { CLOSE_READER(re, gb); return -1; } - LAST_SKIP_BITS(re, gb, 1); + LAST_SKIP_BITS(re, gb, MIN_CACHE_BITS); UPDATE_CACHE(re, gb); } - SKIP_BITS(re, gb, 1); + for (; i < limit && SHOW_UBITS(re, gb, 1) == 0; i++) { + SKIP_BITS(re, gb, 1); + } + LAST_SKIP_BITS(re, gb, 1); + UPDATE_CACHE(re, gb); if (i < limit - 1) { if (k) { @@ -364,6 +520,7 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, CLOSE_READER(re, gb); return buf; } +#endif } /** diff --git a/libs/ffvpx/libavcodec/h264dsp.h b/libs/ffvpx/libavcodec/h264dsp.h index bcd76abcc..cbea3173c 100644 --- a/libs/ffvpx/libavcodec/h264dsp.h +++ b/libs/ffvpx/libavcodec/h264dsp.h @@ -45,32 +45,32 @@ typedef struct H264DSPContext { h264_biweight_func biweight_h264_pixels_tab[4]; /* loop filter */ - void (*h264_v_loop_filter_luma)(uint8_t *pix /*align 16*/, int stride, + void (*h264_v_loop_filter_luma)(uint8_t *pix /*align 16*/, ptrdiff_t stride, int alpha, int beta, int8_t *tc0); - void (*h264_h_loop_filter_luma)(uint8_t *pix /*align 4 */, int stride, + void (*h264_h_loop_filter_luma)(uint8_t *pix /*align 4 */, ptrdiff_t stride, int alpha, int beta, int8_t *tc0); - void (*h264_h_loop_filter_luma_mbaff)(uint8_t *pix /*align 16*/, int stride, + void (*h264_h_loop_filter_luma_mbaff)(uint8_t *pix /*align 16*/, ptrdiff_t stride, int alpha, int beta, int8_t *tc0); /* v/h_loop_filter_luma_intra: align 16 */ - void (*h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride, + void (*h264_v_loop_filter_luma_intra)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta); - void (*h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride, + void (*h264_h_loop_filter_luma_intra)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta); void (*h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix /*align 16*/, - int stride, int alpha, int beta); - void (*h264_v_loop_filter_chroma)(uint8_t *pix /*align 8*/, int stride, + ptrdiff_t stride, int alpha, int beta); + void (*h264_v_loop_filter_chroma)(uint8_t *pix /*align 8*/, ptrdiff_t stride, int alpha, int beta, int8_t *tc0); - void (*h264_h_loop_filter_chroma)(uint8_t *pix /*align 4*/, int stride, + void (*h264_h_loop_filter_chroma)(uint8_t *pix /*align 4*/, ptrdiff_t stride, int alpha, int beta, int8_t *tc0); void (*h264_h_loop_filter_chroma_mbaff)(uint8_t *pix /*align 8*/, - int stride, int alpha, int beta, + ptrdiff_t stride, int alpha, int beta, int8_t *tc0); void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix /*align 8*/, - int stride, int alpha, int beta); + ptrdiff_t stride, int alpha, int beta); void (*h264_h_loop_filter_chroma_intra)(uint8_t *pix /*align 8*/, - int stride, int alpha, int beta); + ptrdiff_t stride, int alpha, int beta); void (*h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix /*align 8*/, - int stride, int alpha, int beta); + ptrdiff_t stride, int alpha, int beta); // h264_loop_filter_strength: simd only. the C version is inlined in h264_loopfilter.c void (*h264_loop_filter_strength)(int16_t bS[2][4][4], uint8_t nnz[40], int8_t ref[2][40], int16_t mv[2][40][2], diff --git a/libs/ffvpx/libavcodec/internal.h b/libs/ffvpx/libavcodec/internal.h index bb92873d7..5096ffa1d 100644 --- a/libs/ffvpx/libavcodec/internal.h +++ b/libs/ffvpx/libavcodec/internal.h @@ -83,7 +83,7 @@ #define FF_QSCALE_TYPE_H264 2 #define FF_QSCALE_TYPE_VP56 3 -#define FF_SANE_NB_CHANNELS 64U +#define FF_SANE_NB_CHANNELS 256U #define FF_SIGNBIT(x) ((x) >> CHAR_BIT * sizeof(x) - 1) @@ -218,6 +218,14 @@ typedef struct AVCodecInternal { /* to prevent infinite loop on errors when draining */ int nb_draining_errors; + + /* used when avctx flag AV_CODEC_FLAG_DROPCHANGED is set */ + int changed_frames_dropped; + int initial_format; + int initial_width, initial_height; + int initial_sample_rate; + int initial_channels; + uint64_t initial_channel_layout; } AVCodecInternal; struct AVCodecDefault { @@ -404,6 +412,18 @@ int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len, */ int64_t ff_guess_coded_bitrate(AVCodecContext *avctx); +/** + * Check if a value is in the list. If not, return the default value + * + * @param ctx Context for the log msg + * @param val_name Name of the checked value, for log msg + * @param array_valid_values Array of valid int, ended with INT_MAX + * @param default_value Value return if checked value is not in the array + * @return Value or default_value. + */ +int ff_int_from_list_or_default(void *ctx, const char * val_name, int val, + const int * array_valid_values, int default_value); + #if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avcodec) # define av_export_avcodec __declspec(dllimport) #else diff --git a/libs/ffvpx/libavcodec/moz.build b/libs/ffvpx/libavcodec/moz.build index 671da54db..01327e912 100644 --- a/libs/ffvpx/libavcodec/moz.build +++ b/libs/ffvpx/libavcodec/moz.build @@ -3,7 +3,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -# Due to duplicate file names, we compile libavutil/x86 in its own +# Due to duplicate file names, we compile libavcodec/x86 in its own # moz.build file. if CONFIG['FFVPX_ASFLAGS']: DIRS += ['x86'] @@ -33,6 +33,7 @@ SOURCES += [ 'null_bsf.c', 'options.c', 'parser.c', + 'parsers.c', 'profiles.c', 'pthread.c', 'pthread_frame.c', @@ -66,6 +67,9 @@ SOURCES += [ SYMBOLS_FILE = 'avcodec.symbols' NO_VISIBILITY_FLAGS = True +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wno-attributes'] + # GCC 10 defaults -fno-common, we don't care to solve this "properly" yet # so use GCC < 10 behavior. if CONFIG['GNU_CC'] and CONFIG['CC_VERSION'] >= '10.0.0': diff --git a/libs/ffvpx/libavcodec/mpegvideo.h b/libs/ffvpx/libavcodec/mpegvideo.h index 541909cbb..e1ff5f97d 100644 --- a/libs/ffvpx/libavcodec/mpegvideo.h +++ b/libs/ffvpx/libavcodec/mpegvideo.h @@ -369,7 +369,7 @@ typedef struct MpegEncContext { uint8_t *mb_info_ptr; int mb_info_size; int ehc_mode; - int rc_strategy; + int rc_strategy; ///< deprecated /* H.263+ specific */ int umvplus; ///< == H.263+ && unrestricted_mv @@ -455,6 +455,7 @@ typedef struct MpegEncContext { /* MPEG-2-specific - I wished not to have to support this mess. */ int progressive_sequence; int mpeg_f_code[2][2]; + int a53_cc; // picture structure defines are loaded from mpegutils.h int picture_structure; @@ -509,6 +510,8 @@ typedef struct MpegEncContext { int (*decode_mb)(struct MpegEncContext *s, int16_t block[12][64]); // used by some codecs to avoid a switch() int32_t (*block32)[12][64]; + int dpcm_direction; // 0 = DCT, 1 = DPCM top to bottom scan, -1 = DPCM bottom to top scan + int16_t (*dpcm_macroblock)[3][256]; #define SLICE_OK 0 #define SLICE_ERROR -1 @@ -587,12 +590,6 @@ typedef struct MpegEncContext { #define FF_MPV_FLAG_NAQ 0x0010 #define FF_MPV_FLAG_MV0 0x0020 -enum rc_strategy { - MPV_RC_STRATEGY_FFMPEG, - MPV_RC_STRATEGY_XVID, - NB_MPV_RC_STRATEGY -}; - #define FF_MPV_OPT_CMP_FUNC \ { "sad", "Sum of absolute differences, fast", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ { "sse", "Sum of squared errors", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ @@ -646,9 +643,9 @@ FF_MPV_OPT_CMP_FUNC, \ {"lmax", "maximum Lagrange factor (VBR)", FF_MPV_OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"ibias", "intra quant bias", FF_MPV_OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"pbias", "inter quant bias", FF_MPV_OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"rc_strategy", "ratecontrol method", FF_MPV_OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = MPV_RC_STRATEGY_FFMPEG }, 0, NB_MPV_RC_STRATEGY-1, FF_MPV_OPT_FLAGS, "rc_strategy" }, \ - { "ffmpeg", "default native rate control", 0, AV_OPT_TYPE_CONST, { .i64 = MPV_RC_STRATEGY_FFMPEG }, 0, 0, FF_MPV_OPT_FLAGS, "rc_strategy" }, \ - { "xvid", "libxvid (2 pass only)", 0, AV_OPT_TYPE_CONST, { .i64 = MPV_RC_STRATEGY_XVID }, 0, 0, FF_MPV_OPT_FLAGS, "rc_strategy" }, \ +{"rc_strategy", "ratecontrol method", FF_MPV_OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" }, \ + { "ffmpeg", "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" }, \ + { "xvid", "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" }, \ {"motion_est", "motion estimation algorithm", FF_MPV_OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, FF_MPV_OPT_FLAGS, "motion_est" }, \ { "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ { "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ @@ -667,6 +664,7 @@ FF_MPV_OPT_CMP_FUNC, \ {"ps", "RTP payload size in bytes", FF_MPV_OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", FF_MPV_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"mepre", "pre motion estimation", FF_MPV_OFFSET(me_pre), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"a53cc", "Use A53 Closed Captions (if available)", FF_MPV_OFFSET(a53_cc), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FF_MPV_OPT_FLAGS }, \ extern const AVOption ff_mpv_generic_options[]; diff --git a/libs/ffvpx/libavcodec/options.c b/libs/ffvpx/libavcodec/options.c index 41b60521c..35e8ac931 100644 --- a/libs/ffvpx/libavcodec/options.c +++ b/libs/ffvpx/libavcodec/options.c @@ -347,172 +347,3 @@ const AVClass *avcodec_get_subtitle_rect_class(void) { return &av_subtitle_rect_class; } - -#ifdef TEST -static int dummy_init(AVCodecContext *ctx) -{ - //TODO: this code should set every possible pointer that could be set by codec and is not an option; - ctx->extradata_size = 8; - ctx->extradata = av_malloc(ctx->extradata_size); - return 0; -} - -static int dummy_close(AVCodecContext *ctx) -{ - av_freep(&ctx->extradata); - ctx->extradata_size = 0; - return 0; -} - -static int dummy_encode(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) -{ - return AVERROR(ENOSYS); -} - -typedef struct Dummy12Context { - AVClass *av_class; - int num; - char* str; -} Dummy12Context; - -typedef struct Dummy3Context { - void *fake_av_class; - int num; - char* str; -} Dummy3Context; - -#define OFFSET(x) offsetof(Dummy12Context, x) -#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM -static const AVOption dummy_options[] = { - { "str", "set str", OFFSET(str), AV_OPT_TYPE_STRING, { .str = "i'm src default value" }, 0, 0, VE}, - { "num", "set num", OFFSET(num), AV_OPT_TYPE_INT, { .i64 = 1500100900 }, 0, INT_MAX, VE}, - { NULL }, -}; - -static const AVClass dummy_v1_class = { - .class_name = "dummy_v1_class", - .item_name = av_default_item_name, - .option = dummy_options, - .version = LIBAVUTIL_VERSION_INT, -}; - -static const AVClass dummy_v2_class = { - .class_name = "dummy_v2_class", - .item_name = av_default_item_name, - .option = dummy_options, - .version = LIBAVUTIL_VERSION_INT, -}; - -/* codec with options */ -static AVCodec dummy_v1_encoder = { - .name = "dummy_v1_codec", - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_NONE - 1, - .encode2 = dummy_encode, - .init = dummy_init, - .close = dummy_close, - .priv_class = &dummy_v1_class, - .priv_data_size = sizeof(Dummy12Context), -}; - -/* codec with options, different class */ -static AVCodec dummy_v2_encoder = { - .name = "dummy_v2_codec", - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_NONE - 2, - .encode2 = dummy_encode, - .init = dummy_init, - .close = dummy_close, - .priv_class = &dummy_v2_class, - .priv_data_size = sizeof(Dummy12Context), -}; - -/* codec with priv data, but no class */ -static AVCodec dummy_v3_encoder = { - .name = "dummy_v3_codec", - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_NONE - 3, - .encode2 = dummy_encode, - .init = dummy_init, - .close = dummy_close, - .priv_data_size = sizeof(Dummy3Context), -}; - -/* codec without priv data */ -static AVCodec dummy_v4_encoder = { - .name = "dummy_v4_codec", - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_NONE - 4, - .encode2 = dummy_encode, - .init = dummy_init, - .close = dummy_close, -}; - -static void test_copy_print_codec(const AVCodecContext *ctx) -{ - printf("%-14s: %dx%d prv: %s", - ctx->codec ? ctx->codec->name : "NULL", - ctx->width, ctx->height, - ctx->priv_data ? "set" : "null"); - if (ctx->codec && ctx->codec->priv_class && ctx->codec->priv_data_size) { - int64_t i64; - char *str = NULL; - av_opt_get_int(ctx->priv_data, "num", 0, &i64); - av_opt_get(ctx->priv_data, "str", 0, (uint8_t**)&str); - printf(" opts: %"PRId64" %s", i64, str); - av_free(str); - } - printf("\n"); -} - -static void test_copy(const AVCodec *c1, const AVCodec *c2) -{ - AVCodecContext *ctx1, *ctx2; - printf("%s -> %s\nclosed:\n", c1 ? c1->name : "NULL", c2 ? c2->name : "NULL"); - ctx1 = avcodec_alloc_context3(c1); - ctx2 = avcodec_alloc_context3(c2); - ctx1->width = ctx1->height = 128; - if (ctx2->codec && ctx2->codec->priv_class && ctx2->codec->priv_data_size) { - av_opt_set(ctx2->priv_data, "num", "667", 0); - av_opt_set(ctx2->priv_data, "str", "i'm dest value before copy", 0); - } - avcodec_copy_context(ctx2, ctx1); - test_copy_print_codec(ctx1); - test_copy_print_codec(ctx2); - if (ctx1->codec) { - printf("opened:\n"); - avcodec_open2(ctx1, ctx1->codec, NULL); - if (ctx2->codec && ctx2->codec->priv_class && ctx2->codec->priv_data_size) { - av_opt_set(ctx2->priv_data, "num", "667", 0); - av_opt_set(ctx2->priv_data, "str", "i'm dest value before copy", 0); - } - avcodec_copy_context(ctx2, ctx1); - test_copy_print_codec(ctx1); - test_copy_print_codec(ctx2); - avcodec_close(ctx1); - } - avcodec_free_context(&ctx1); - avcodec_free_context(&ctx2); -} - -int main(void) -{ - AVCodec *dummy_codec[] = { - &dummy_v1_encoder, - &dummy_v2_encoder, - &dummy_v3_encoder, - &dummy_v4_encoder, - NULL, - }; - int i, j; - - for (i = 0; dummy_codec[i]; i++) - avcodec_register(dummy_codec[i]); - - printf("testing avcodec_copy_context()\n"); - for (i = 0; i < FF_ARRAY_ELEMS(dummy_codec); i++) - for (j = 0; j < FF_ARRAY_ELEMS(dummy_codec); j++) - test_copy(dummy_codec[i], dummy_codec[j]); - return 0; -} -#endif diff --git a/libs/ffvpx/libavcodec/options_table.h b/libs/ffvpx/libavcodec/options_table.h index 099261e16..4a266eca1 100644 --- a/libs/ffvpx/libavcodec/options_table.h +++ b/libs/ffvpx/libavcodec/options_table.h @@ -67,6 +67,8 @@ static const AVOption avcodec_options[] = { {"ilme", "interlaced motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_INTERLACED_ME }, INT_MIN, INT_MAX, V|E, "flags"}, {"cgop", "closed GOP", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_CLOSED_GOP }, INT_MIN, INT_MAX, V|E, "flags"}, {"output_corrupt", "Output even potentially corrupted frames", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_OUTPUT_CORRUPT }, INT_MIN, INT_MAX, V|D, "flags"}, +{"drop_changed", "Drop frames whose parameters differ from first decoded frame", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_DROPCHANGED }, INT_MIN, INT_MAX, A|V|D, "flags"}, +{"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, UINT_MAX, V|A|E|D, "flags2"}, {"fast", "allow non-spec-compliant speedup tricks", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_FAST }, INT_MIN, INT_MAX, V|E, "flags2"}, {"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"}, {"ignorecrop", "ignore cropping information from sps", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_IGNORE_CROP }, INT_MIN, INT_MAX, V|D, "flags2"}, @@ -217,34 +219,11 @@ static const AVOption avcodec_options[] = { {"buffers", "picture buffer allocations", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_BUFFERS }, INT_MIN, INT_MAX, V|D, "debug"}, {"thread_ops", "threading operations", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_THREADS }, INT_MIN, INT_MAX, V|A|D, "debug"}, {"nomc", "skip motion compensation", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_NOMC }, INT_MIN, INT_MAX, V|A|D, "debug"}, -{"cmp", "full-pel ME compare function", OFFSET(me_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"subcmp", "sub-pel ME compare function", OFFSET(me_sub_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"mbcmp", "macroblock compare function", OFFSET(mb_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"ildctcmp", "interlaced DCT compare function", OFFSET(ildct_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_VSAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, {"dia_size", "diamond type & size for motion estimation", OFFSET(dia_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"last_pred", "amount of motion predictors from the previous frame", OFFSET(last_predictor_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, #if FF_API_PRIVATE_OPT {"preme", "pre motion estimation", OFFSET(pre_me), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, #endif -{"precmp", "pre motion estimation compare function", OFFSET(me_pre_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"sad", "sum of absolute differences, fast", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"sse", "sum of squared errors", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SSE }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"satd", "sum of absolute Hadamard transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SATD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"dct", "sum of absolute DCT transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"psnr", "sum of squared quantization errors (avoid, low quality)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_PSNR }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"bit", "number of bits needed for the block", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_BIT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"rd", "rate distortion optimal, slow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_RD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"zero", "0", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_ZERO }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"vsad", "sum of absolute vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"vsse", "sum of squared vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSSE }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"nsse", "noise preserving sum of squared differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_NSSE }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -#if CONFIG_SNOW_ENCODER -{"w53", "5/3 wavelet, only used in snow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_W53 }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"w97", "9/7 wavelet, only used in snow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_W97 }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -#endif -{"dctmax", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_CHROMA }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"msad", "sum of absolute differences, median predicted", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_MEDIAN_SAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, {"pre_dia_size", "diamond type & size for motion estimation pre-pass", OFFSET(pre_dia_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"subq", "sub-pel motion estimation quality", OFFSET(me_subpel_quality), AV_OPT_TYPE_INT, {.i64 = 8 }, INT_MIN, INT_MAX, V|E}, {"me_range", "limit motion vectors range (1023 for DivX player)", OFFSET(me_range), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, @@ -271,7 +250,6 @@ static const AVOption avcodec_options[] = { {"nr", "noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, #endif {"rc_init_occupancy", "number of bits which should be loaded into the rc buffer before decoding starts", OFFSET(rc_initial_buffer_occupancy), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, UINT_MAX, V|A|E|D, "flags2"}, {"threads", "set the number of threads", OFFSET(thread_count), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, INT_MAX, V|A|E|D, "threads"}, {"auto", "autodetect a suitable number of threads to use", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, INT_MIN, INT_MAX, V|E|D, "threads"}, {"dc", "intra_dc_precision", OFFSET(intra_dc_precision), AV_OPT_TYPE_INT, {.i64 = 0 }, -8, 16, V|E}, @@ -310,6 +288,29 @@ static const AVOption avcodec_options[] = { {"skip_exp", "frame skip exponent", OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"skipcmp", "frame skip compare function", OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, V|E, "cmp_func"}, #endif +{"cmp", "full-pel ME compare function", OFFSET(me_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"subcmp", "sub-pel ME compare function", OFFSET(me_sub_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"mbcmp", "macroblock compare function", OFFSET(mb_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"ildctcmp", "interlaced DCT compare function", OFFSET(ildct_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_VSAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"precmp", "pre motion estimation compare function", OFFSET(me_pre_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"sad", "sum of absolute differences, fast", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"sse", "sum of squared errors", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SSE }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"satd", "sum of absolute Hadamard transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SATD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"dct", "sum of absolute DCT transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"psnr", "sum of squared quantization errors (avoid, low quality)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_PSNR }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"bit", "number of bits needed for the block", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_BIT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"rd", "rate distortion optimal, slow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_RD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"zero", "0", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_ZERO }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"vsad", "sum of absolute vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"vsse", "sum of squared vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSSE }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"nsse", "noise preserving sum of squared differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_NSSE }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +#if CONFIG_SNOW_ENCODER +{"w53", "5/3 wavelet, only used in snow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_W53 }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"w97", "9/7 wavelet, only used in snow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_W97 }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +#endif +{"dctmax", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_CHROMA }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"msad", "sum of absolute differences, median predicted", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_MEDIAN_SAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, {"mblmin", "minimum macroblock Lagrange factor (VBR)", OFFSET(mb_lmin), AV_OPT_TYPE_INT, {.i64 = FF_QP2LAMBDA * 2 }, 1, FF_LAMBDA_MAX, V|E}, {"mblmax", "maximum macroblock Lagrange factor (VBR)", OFFSET(mb_lmax), AV_OPT_TYPE_INT, {.i64 = FF_QP2LAMBDA * 31 }, 1, FF_LAMBDA_MAX, V|E}, #if FF_API_PRIVATE_OPT @@ -479,6 +480,7 @@ static const AVOption avcodec_options[] = { {"allow_high_depth", "allow to output YUV pixel formats with a different chroma sampling than 4:2:0 and/or other than 8 bits per component", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH }, INT_MIN, INT_MAX, V | D, "hwaccel_flags"}, {"allow_profile_mismatch", "attempt to decode anyway if HW accelerated decoder's supported profiles do not exactly match the stream", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH }, INT_MIN, INT_MAX, V | D, "hwaccel_flags"}, {"extra_hw_frames", "Number of extra hardware frames to allocate for the user", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, V|D }, +{"discard_damaged_percentage", "Percentage of damaged samples to discard a frame", OFFSET(discard_damaged_percentage), AV_OPT_TYPE_INT, {.i64 = 95 }, 0, 100, V|D }, {NULL}, }; diff --git a/libs/ffvpx/libavcodec/parser.c b/libs/ffvpx/libavcodec/parser.c index f43b197d5..3e19810a9 100644 --- a/libs/ffvpx/libavcodec/parser.c +++ b/libs/ffvpx/libavcodec/parser.c @@ -27,95 +27,10 @@ #include "libavutil/avassert.h" #include "libavutil/internal.h" #include "libavutil/mem.h" -#include "libavutil/thread.h" #include "internal.h" #include "parser.h" -/* Parsers */ -extern AVCodecParser ff_aac_parser; -extern AVCodecParser ff_aac_latm_parser; -extern AVCodecParser ff_ac3_parser; -extern AVCodecParser ff_adx_parser; -extern AVCodecParser ff_bmp_parser; -extern AVCodecParser ff_cavsvideo_parser; -extern AVCodecParser ff_cook_parser; -extern AVCodecParser ff_dca_parser; -extern AVCodecParser ff_dirac_parser; -extern AVCodecParser ff_dnxhd_parser; -extern AVCodecParser ff_dpx_parser; -extern AVCodecParser ff_dvaudio_parser; -extern AVCodecParser ff_dvbsub_parser; -extern AVCodecParser ff_dvdsub_parser; -extern AVCodecParser ff_dvd_nav_parser; -extern AVCodecParser ff_flac_parser; -extern AVCodecParser ff_g729_parser; -extern AVCodecParser ff_gsm_parser; -extern AVCodecParser ff_h261_parser; -extern AVCodecParser ff_h263_parser; -extern AVCodecParser ff_h264_parser; -extern AVCodecParser ff_hevc_parser; -extern AVCodecParser ff_mjpeg_parser; -extern AVCodecParser ff_mlp_parser; -extern AVCodecParser ff_mpeg4video_parser; -extern AVCodecParser ff_mpegaudio_parser; -extern AVCodecParser ff_mpegvideo_parser; -extern AVCodecParser ff_opus_parser; -extern AVCodecParser ff_png_parser; -extern AVCodecParser ff_pnm_parser; -extern AVCodecParser ff_rv30_parser; -extern AVCodecParser ff_rv40_parser; -extern AVCodecParser ff_sbc_parser; -extern AVCodecParser ff_sipr_parser; -extern AVCodecParser ff_tak_parser; -extern AVCodecParser ff_vc1_parser; -extern AVCodecParser ff_vorbis_parser; -extern AVCodecParser ff_vp3_parser; -extern AVCodecParser ff_vp8_parser; -extern AVCodecParser ff_vp9_parser; -extern AVCodecParser ff_xma_parser; - -#include "libavcodec/parser_list.c" - -static AVOnce av_parser_next_init = AV_ONCE_INIT; - -static void av_parser_init_next(void) -{ - AVCodecParser *prev = NULL, *p; - int i = 0; - while ((p = (AVCodecParser*)parser_list[i++])) { - if (prev) - prev->next = p; - prev = p; - } -} - -AVCodecParser *av_parser_next(const AVCodecParser *p) -{ - ff_thread_once(&av_parser_next_init, av_parser_init_next); - - if (p) - return p->next; - else - return (AVCodecParser*)parser_list[0]; -} - -const AVCodecParser *av_parser_iterate(void **opaque) -{ - uintptr_t i = (uintptr_t)*opaque; - const AVCodecParser *p = parser_list[i]; - - if (p) - *opaque = (void*)(i + 1); - - return p; -} - -void av_register_codec_parser(AVCodecParser *parser) -{ - ff_thread_once(&av_parser_next_init, av_parser_init_next); -} - AVCodecParserContext *av_parser_init(int codec_id) { AVCodecParserContext *s = NULL; @@ -330,6 +245,9 @@ int ff_combine_frame(ParseContext *pc, int next, for (; pc->overread > 0; pc->overread--) pc->buffer[pc->index++] = pc->buffer[pc->overread_index++]; + if (next > *buf_size) + return AVERROR(EINVAL); + /* flush remaining if EOF */ if (!*buf_size && next == END_NOT_FOUND) next = 0; diff --git a/libs/ffvpx/libavcodec/parsers.c b/libs/ffvpx/libavcodec/parsers.c new file mode 100644 index 000000000..33a71de8a --- /dev/null +++ b/libs/ffvpx/libavcodec/parsers.c @@ -0,0 +1,110 @@ +/* + * 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 <stdint.h> + +#include "libavutil/thread.h" + +#include "avcodec.h" + +extern AVCodecParser ff_aac_parser; +extern AVCodecParser ff_aac_latm_parser; +extern AVCodecParser ff_ac3_parser; +extern AVCodecParser ff_adx_parser; +extern AVCodecParser ff_av1_parser; +extern AVCodecParser ff_avs2_parser; +extern AVCodecParser ff_bmp_parser; +extern AVCodecParser ff_cavsvideo_parser; +extern AVCodecParser ff_cook_parser; +extern AVCodecParser ff_dca_parser; +extern AVCodecParser ff_dirac_parser; +extern AVCodecParser ff_dnxhd_parser; +extern AVCodecParser ff_dpx_parser; +extern AVCodecParser ff_dvaudio_parser; +extern AVCodecParser ff_dvbsub_parser; +extern AVCodecParser ff_dvdsub_parser; +extern AVCodecParser ff_dvd_nav_parser; +extern AVCodecParser ff_flac_parser; +extern AVCodecParser ff_g723_1_parser; +extern AVCodecParser ff_g729_parser; +extern AVCodecParser ff_gif_parser; +extern AVCodecParser ff_gsm_parser; +extern AVCodecParser ff_h261_parser; +extern AVCodecParser ff_h263_parser; +extern AVCodecParser ff_h264_parser; +extern AVCodecParser ff_hevc_parser; +extern AVCodecParser ff_mjpeg_parser; +extern AVCodecParser ff_mlp_parser; +extern AVCodecParser ff_mpeg4video_parser; +extern AVCodecParser ff_mpegaudio_parser; +extern AVCodecParser ff_mpegvideo_parser; +extern AVCodecParser ff_opus_parser; +extern AVCodecParser ff_png_parser; +extern AVCodecParser ff_pnm_parser; +extern AVCodecParser ff_rv30_parser; +extern AVCodecParser ff_rv40_parser; +extern AVCodecParser ff_sbc_parser; +extern AVCodecParser ff_sipr_parser; +extern AVCodecParser ff_tak_parser; +extern AVCodecParser ff_vc1_parser; +extern AVCodecParser ff_vorbis_parser; +extern AVCodecParser ff_vp3_parser; +extern AVCodecParser ff_vp8_parser; +extern AVCodecParser ff_vp9_parser; +extern AVCodecParser ff_xma_parser; + +#include "libavcodec/parser_list.c" + +static AVOnce av_parser_next_init = AV_ONCE_INIT; + +static void av_parser_init_next(void) +{ + AVCodecParser *prev = NULL, *p; + int i = 0; + while ((p = (AVCodecParser*)parser_list[i++])) { + if (prev) + prev->next = p; + prev = p; + } +} + +AVCodecParser *av_parser_next(const AVCodecParser *p) +{ + ff_thread_once(&av_parser_next_init, av_parser_init_next); + + if (p) + return p->next; + else + return (AVCodecParser*)parser_list[0]; +} + +const AVCodecParser *av_parser_iterate(void **opaque) +{ + uintptr_t i = (uintptr_t)*opaque; + const AVCodecParser *p = parser_list[i]; + + if (p) + *opaque = (void*)(i + 1); + + return p; +} + +void av_register_codec_parser(AVCodecParser *parser) +{ + ff_thread_once(&av_parser_next_init, av_parser_init_next); +} diff --git a/libs/ffvpx/libavcodec/profiles.c b/libs/ffvpx/libavcodec/profiles.c index d7dc960f3..eaf0d68d3 100644 --- a/libs/ffvpx/libavcodec/profiles.c +++ b/libs/ffvpx/libavcodec/profiles.c @@ -30,7 +30,6 @@ const AVProfile ff_aac_profiles[] = { { FF_PROFILE_AAC_LD, "LD" }, { FF_PROFILE_AAC_ELD, "ELD" }, { FF_PROFILE_AAC_MAIN, "Main" }, - { FF_PROFILE_AAC_LOW, "LC" }, { FF_PROFILE_AAC_SSR, "SSR" }, { FF_PROFILE_AAC_LTP, "LTP" }, { FF_PROFILE_UNKNOWN }, @@ -152,4 +151,29 @@ const AVProfile ff_sbc_profiles[] = { { FF_PROFILE_UNKNOWN }, }; +const AVProfile ff_prores_profiles[] = { + { FF_PROFILE_PRORES_PROXY, "Proxy" }, + { FF_PROFILE_PRORES_LT, "LT" }, + { FF_PROFILE_PRORES_STANDARD, "Standard" }, + { FF_PROFILE_PRORES_HQ, "HQ" }, + { FF_PROFILE_PRORES_4444, "4444" }, + { FF_PROFILE_PRORES_XQ, "XQ" }, + { FF_PROFILE_UNKNOWN } +}; + +const AVProfile ff_mjpeg_profiles[] = { + { FF_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT, "Baseline" }, + { FF_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT, "Sequential" }, + { FF_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT, "Progressive" }, + { FF_PROFILE_MJPEG_HUFFMAN_LOSSLESS, "Lossless" }, + { FF_PROFILE_MJPEG_JPEG_LS, "JPEG LS" }, + { FF_PROFILE_UNKNOWN } +}; + +const AVProfile ff_arib_caption_profiles[] = { + { FF_PROFILE_ARIB_PROFILE_A, "Profile A" }, + { FF_PROFILE_ARIB_PROFILE_C, "Profile C" }, + { FF_PROFILE_UNKNOWN } +}; + #endif /* !CONFIG_SMALL */ diff --git a/libs/ffvpx/libavcodec/profiles.h b/libs/ffvpx/libavcodec/profiles.h index 9d7e211e1..a53b67e7f 100644 --- a/libs/ffvpx/libavcodec/profiles.h +++ b/libs/ffvpx/libavcodec/profiles.h @@ -33,5 +33,8 @@ extern const AVProfile ff_vc1_profiles[]; extern const AVProfile ff_vp9_profiles[]; extern const AVProfile ff_av1_profiles[]; extern const AVProfile ff_sbc_profiles[]; +extern const AVProfile ff_prores_profiles[]; +extern const AVProfile ff_mjpeg_profiles[]; +extern const AVProfile ff_arib_caption_profiles[]; #endif /* AVCODEC_PROFILES_H */ diff --git a/libs/ffvpx/libavcodec/pthread_frame.c b/libs/ffvpx/libavcodec/pthread_frame.c index 5104b1beb..36ac0ac1e 100644 --- a/libs/ffvpx/libavcodec/pthread_frame.c +++ b/libs/ffvpx/libavcodec/pthread_frame.c @@ -908,8 +908,7 @@ static int thread_get_buffer_internal(AVCodecContext *avctx, ThreadFrame *f, int } pthread_mutex_lock(&p->parent->buffer_mutex); - if (avctx->thread_safe_callbacks || - avctx->get_buffer2 == avcodec_default_get_buffer2) { + if (THREAD_SAFE_CALLBACKS(avctx)) { err = ff_get_buffer(avctx, f->f, flags); } else { pthread_mutex_lock(&p->progress_mutex); @@ -976,8 +975,7 @@ void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f) FrameThreadContext *fctx; AVFrame *dst, *tmp; int can_direct_free = !(avctx->active_thread_type & FF_THREAD_FRAME) || - avctx->thread_safe_callbacks || - avctx->get_buffer2 == avcodec_default_get_buffer2; + THREAD_SAFE_CALLBACKS(avctx); if (!f->f || !f->f->buf[0]) return; diff --git a/libs/ffvpx/libavcodec/raw.c b/libs/ffvpx/libavcodec/raw.c index 8da2a9735..b6fb91c1c 100644 --- a/libs/ffvpx/libavcodec/raw.c +++ b/libs/ffvpx/libavcodec/raw.c @@ -125,6 +125,8 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { AV_PIX_FMT_GRAY10BE, MKTAG(10 , 0 , '1', 'Y') }, { AV_PIX_FMT_GRAY12LE, MKTAG('Y', '1', 0 , 12 ) }, { AV_PIX_FMT_GRAY12BE, MKTAG(12 , 0 , '1', 'Y') }, + { AV_PIX_FMT_GRAY14LE, MKTAG('Y', '1', 0 , 14 ) }, + { AV_PIX_FMT_GRAY14BE, MKTAG(14 , 0 , '1', 'Y') }, { AV_PIX_FMT_GRAY16LE, MKTAG('Y', '1', 0 , 16 ) }, { AV_PIX_FMT_GRAY16BE, MKTAG(16 , 0 , '1', 'Y') }, { AV_PIX_FMT_YUV420P9LE, MKTAG('Y', '3', 11 , 9 ) }, @@ -175,6 +177,10 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { AV_PIX_FMT_YUVA422P10BE, MKTAG(10 , 10 , '4', 'Y') }, { AV_PIX_FMT_YUVA444P10LE, MKTAG('Y', '4', 0 , 10 ) }, { AV_PIX_FMT_YUVA444P10BE, MKTAG(10 , 0 , '4', 'Y') }, + { AV_PIX_FMT_YUVA422P12LE, MKTAG('Y', '4', 10 , 12 ) }, + { AV_PIX_FMT_YUVA422P12BE, MKTAG(12 , 10 , '4', 'Y') }, + { AV_PIX_FMT_YUVA444P12LE, MKTAG('Y', '4', 0 , 12 ) }, + { AV_PIX_FMT_YUVA444P12BE, MKTAG(12 , 0 , '4', 'Y') }, { AV_PIX_FMT_YUVA420P16LE, MKTAG('Y', '4', 11 , 16 ) }, { AV_PIX_FMT_YUVA420P16BE, MKTAG(16 , 11 , '4', 'Y') }, { AV_PIX_FMT_YUVA422P16LE, MKTAG('Y', '4', 10 , 16 ) }, diff --git a/libs/ffvpx/libavcodec/unary.h b/libs/ffvpx/libavcodec/unary.h index 908dc9350..d57f9f70c 100644 --- a/libs/ffvpx/libavcodec/unary.h +++ b/libs/ffvpx/libavcodec/unary.h @@ -28,7 +28,20 @@ * @param gb GetBitContext * @param[in] stop The bitstop value (unary code of 1's or 0's) * @param[in] len Maximum length - * @return Unary length/index + * @return unary 0 based code index. This is also the length in bits of the + * code excluding the stop bit. + * (in case len=1) + * 1 0 + * 0 1 + * (in case len=2) + * 1 0 + * 01 1 + * 00 2 + * (in case len=3) + * 1 0 + * 01 1 + * 001 2 + * 000 3 */ static inline int get_unary(GetBitContext *gb, int stop, int len) { diff --git a/libs/ffvpx/libavcodec/utils.c b/libs/ffvpx/libavcodec/utils.c index 59d41ccbb..bdd9a60c3 100644 --- a/libs/ffvpx/libavcodec/utils.c +++ b/libs/ffvpx/libavcodec/utils.c @@ -214,6 +214,8 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, case AV_PIX_FMT_YUVA422P9BE: case AV_PIX_FMT_YUVA422P10LE: case AV_PIX_FMT_YUVA422P10BE: + case AV_PIX_FMT_YUVA422P12LE: + case AV_PIX_FMT_YUVA422P12BE: case AV_PIX_FMT_YUVA422P16LE: case AV_PIX_FMT_YUVA422P16BE: case AV_PIX_FMT_YUV440P10LE: @@ -234,6 +236,8 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, case AV_PIX_FMT_YUVA444P9BE: case AV_PIX_FMT_YUVA444P10LE: case AV_PIX_FMT_YUVA444P10BE: + case AV_PIX_FMT_YUVA444P12LE: + case AV_PIX_FMT_YUVA444P12BE: case AV_PIX_FMT_YUVA444P16LE: case AV_PIX_FMT_YUVA444P16BE: case AV_PIX_FMT_GBRP9LE: @@ -288,6 +292,16 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, w_align = 8; h_align = 8; } + if (s->codec_id == AV_CODEC_ID_MJPEG || + s->codec_id == AV_CODEC_ID_MJPEGB || + s->codec_id == AV_CODEC_ID_LJPEG || + s->codec_id == AV_CODEC_ID_SMVJPEG || + s->codec_id == AV_CODEC_ID_AMV || + s->codec_id == AV_CODEC_ID_SP5X || + s->codec_id == AV_CODEC_ID_JPEGLS) { + w_align = 8; + h_align = 2*8; + } break; case AV_PIX_FMT_BGR24: if ((s->codec_id == AV_CODEC_ID_MSZH) || @@ -408,7 +422,7 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, void ff_color_frame(AVFrame *frame, const int c[4]) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); - int p, y, x; + int p, y; av_assert0(desc->flags & AV_PIX_FMT_FLAG_PLANAR); @@ -417,13 +431,19 @@ void ff_color_frame(AVFrame *frame, const int c[4]) int is_chroma = p == 1 || p == 2; int bytes = is_chroma ? AV_CEIL_RSHIFT(frame->width, desc->log2_chroma_w) : frame->width; int height = is_chroma ? AV_CEIL_RSHIFT(frame->height, desc->log2_chroma_h) : frame->height; - for (y = 0; y < height; y++) { - if (desc->comp[0].depth >= 9) { - for (x = 0; x<bytes; x++) - ((uint16_t*)dst)[x] = c[p]; - }else - memset(dst, c[p], bytes); + if (desc->comp[0].depth >= 9) { + ((uint16_t*)dst)[0] = c[p]; + av_memcpy_backptr(dst + 2, 2, bytes - 2); dst += frame->linesize[p]; + for (y = 1; y < height; y++) { + memcpy(dst, frame->data[p], 2*bytes); + dst += frame->linesize[p]; + } + } else { + for (y = 0; y < height; y++) { + memset(dst, c[p], bytes); + dst += frame->linesize[p]; + } } } } @@ -501,7 +521,14 @@ static int64_t get_bit_rate(AVCodecContext *ctx) break; case AVMEDIA_TYPE_AUDIO: bits_per_sample = av_get_bits_per_sample(ctx->codec_id); - bit_rate = bits_per_sample ? ctx->sample_rate * (int64_t)ctx->channels * bits_per_sample : ctx->bit_rate; + if (bits_per_sample) { + bit_rate = ctx->sample_rate * (int64_t)ctx->channels; + if (bit_rate > INT64_MAX / bits_per_sample) { + bit_rate = 0; + } else + bit_rate *= bits_per_sample; + } else + bit_rate = ctx->bit_rate; break; default: bit_rate = 0; @@ -538,6 +565,7 @@ int attribute_align_arg ff_codec_open2_recursive(AVCodecContext *avctx, const AV int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options) { int ret = 0; + int codec_init_ok = 0; AVDictionary *tmp = NULL; const AVPixFmtDescriptor *pixdesc; @@ -673,7 +701,18 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code if (av_codec_is_decoder(codec)) av_freep(&avctx->subtitle_header); - if (avctx->channels > FF_SANE_NB_CHANNELS) { + if (avctx->channels > FF_SANE_NB_CHANNELS || avctx->channels < 0) { + av_log(avctx, AV_LOG_ERROR, "Too many or invalid channels: %d\n", avctx->channels); + ret = AVERROR(EINVAL); + goto free_and_end; + } + if (avctx->sample_rate < 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid sample rate: %d\n", avctx->sample_rate); + ret = AVERROR(EINVAL); + goto free_and_end; + } + if (avctx->block_align < 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid block align: %d\n", avctx->block_align); ret = AVERROR(EINVAL); goto free_and_end; } @@ -726,6 +765,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code goto free_and_end; } + if (av_codec_is_decoder(avctx->codec)) { + ret = ff_decode_bsfs_init(avctx); + if (ret < 0) + goto free_and_end; + } + if (HAVE_THREADS && !(avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) { ret = ff_thread_init(avctx); @@ -924,6 +969,7 @@ FF_ENABLE_DEPRECATION_WARNINGS if (ret < 0) { goto free_and_end; } + codec_init_ok = 1; } ret=0; @@ -951,6 +997,10 @@ FF_ENABLE_DEPRECATION_WARNINGS ret = AVERROR(EINVAL); goto free_and_end; } + if (avctx->bits_per_coded_sample < 0) { + ret = AVERROR(EINVAL); + goto free_and_end; + } if (avctx->sub_charenc) { if (avctx->codec_type != AVMEDIA_TYPE_SUBTITLE) { av_log(avctx, AV_LOG_ERROR, "Character encoding is only " @@ -1007,10 +1057,14 @@ end: return ret; free_and_end: - if (avctx->codec && - (avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP)) + if (avctx->codec && avctx->codec->close && + (codec_init_ok || + (avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP))) avctx->codec->close(avctx); + if (HAVE_THREADS && avctx->internal->thread_ctx) + ff_thread_free(avctx); + if (codec->priv_class && codec->priv_data_size) av_opt_free(avctx->priv_data); av_opt_free(avctx); @@ -1023,6 +1077,7 @@ FF_ENABLE_DEPRECATION_WARNINGS av_dict_free(&tmp); av_freep(&avctx->priv_data); + av_freep(&avctx->subtitle_header); if (avctx->internal) { av_frame_free(&avctx->internal->to_free); av_frame_free(&avctx->internal->compat_decode_frame); @@ -1031,6 +1086,7 @@ FF_ENABLE_DEPRECATION_WARNINGS av_packet_free(&avctx->internal->last_pkt_props); av_packet_free(&avctx->internal->ds.in_pkt); + ff_decode_bsfs_uninit(avctx); av_freep(&avctx->internal->pool); } @@ -1389,10 +1445,8 @@ const char *avcodec_profile_name(enum AVCodecID codec_id, int profile) unsigned avcodec_version(void) { -// av_assert0(AV_CODEC_ID_V410==164); av_assert0(AV_CODEC_ID_PCM_S8_PLANAR==65563); av_assert0(AV_CODEC_ID_ADPCM_G722==69660); -// av_assert0(AV_CODEC_ID_BMV_AUDIO==86071); av_assert0(AV_CODEC_ID_SRT==94216); av_assert0(LIBAVCODEC_VERSION_MICRO >= 100); @@ -1430,6 +1484,7 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id) case AV_CODEC_ID_DSD_MSBF_PLANAR: case AV_CODEC_ID_PCM_ALAW: case AV_CODEC_ID_PCM_MULAW: + case AV_CODEC_ID_PCM_VIDC: case AV_CODEC_ID_PCM_S8: case AV_CODEC_ID_PCM_S8_PLANAR: case AV_CODEC_ID_PCM_U8: @@ -1536,7 +1591,11 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, case AV_CODEC_ID_GSM_MS: return 320; case AV_CODEC_ID_MP1: return 384; case AV_CODEC_ID_ATRAC1: return 512; - case AV_CODEC_ID_ATRAC3: return 1024 * framecount; + case AV_CODEC_ID_ATRAC9: + case AV_CODEC_ID_ATRAC3: + if (framecount > INT_MAX/1024) + return 0; + return 1024 * framecount; case AV_CODEC_ID_ATRAC3P: return 2048; case AV_CODEC_ID_MP2: case AV_CODEC_ID_MUSEPACK7: return 1152; @@ -1552,8 +1611,11 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, if (ch > 0) { /* calc from sample rate and channels */ - if (id == AV_CODEC_ID_BINKAUDIO_DCT) + if (id == AV_CODEC_ID_BINKAUDIO_DCT) { + if (sr / 22050 > 22) + return 0; return (480 << (sr / 22050)) / ch; + } } if (id == AV_CODEC_ID_MP3) @@ -1585,8 +1647,6 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, return 256 * (frame_bytes / 64); if (id == AV_CODEC_ID_RA_144) return 160 * (frame_bytes / 20); - if (id == AV_CODEC_ID_G723_1) - return 240 * (frame_bytes / 24); if (bps > 0) { /* calc from frame_bytes and bits_per_coded_sample */ @@ -1601,7 +1661,10 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, return frame_bytes / (9 * ch) * 16; case AV_CODEC_ID_ADPCM_PSX: case AV_CODEC_ID_ADPCM_DTK: - return frame_bytes / (16 * ch) * 28; + frame_bytes /= 16 * ch; + if (frame_bytes > INT_MAX / 28) + return 0; + return frame_bytes * 28; case AV_CODEC_ID_ADPCM_4XM: case AV_CODEC_ID_ADPCM_IMA_DAT4: case AV_CODEC_ID_ADPCM_IMA_ISS: @@ -1613,7 +1676,7 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, case AV_CODEC_ID_ADPCM_THP: case AV_CODEC_ID_ADPCM_THP_LE: if (extradata) - return frame_bytes * 14 / (8 * ch); + return frame_bytes * 14LL / (8 * ch); break; case AV_CODEC_ID_ADPCM_XA: return (frame_bytes / 128) * 224 / ch; @@ -1647,21 +1710,33 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, if (ba > 0) { /* calc from frame_bytes, channels, and block_align */ int blocks = frame_bytes / ba; + int64_t tmp = 0; switch (id) { case AV_CODEC_ID_ADPCM_IMA_WAV: if (bps < 2 || bps > 5) return 0; - return blocks * (1 + (ba - 4 * ch) / (bps * ch) * 8); + tmp = blocks * (1LL + (ba - 4 * ch) / (bps * ch) * 8); + break; case AV_CODEC_ID_ADPCM_IMA_DK3: - return blocks * (((ba - 16) * 2 / 3 * 4) / ch); + tmp = blocks * (((ba - 16LL) * 2 / 3 * 4) / ch); + break; case AV_CODEC_ID_ADPCM_IMA_DK4: - return blocks * (1 + (ba - 4 * ch) * 2 / ch); + tmp = blocks * (1 + (ba - 4LL * ch) * 2 / ch); + break; case AV_CODEC_ID_ADPCM_IMA_RAD: - return blocks * ((ba - 4 * ch) * 2 / ch); + tmp = blocks * ((ba - 4LL * ch) * 2 / ch); + break; case AV_CODEC_ID_ADPCM_MS: - return blocks * (2 + (ba - 7 * ch) * 2 / ch); + tmp = blocks * (2 + (ba - 7LL * ch) * 2LL / ch); + break; case AV_CODEC_ID_ADPCM_MTAF: - return blocks * (ba - 16) * 2 / ch; + tmp = blocks * (ba - 16LL) * 2 / ch; + break; + } + if (tmp) { + if (tmp != (int)tmp) + return 0; + return tmp; } } @@ -1699,20 +1774,22 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) { - return get_audio_frame_duration(avctx->codec_id, avctx->sample_rate, + int duration = get_audio_frame_duration(avctx->codec_id, avctx->sample_rate, avctx->channels, avctx->block_align, avctx->codec_tag, avctx->bits_per_coded_sample, avctx->bit_rate, avctx->extradata, avctx->frame_size, frame_bytes); + return FFMAX(0, duration); } int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes) { - return get_audio_frame_duration(par->codec_id, par->sample_rate, + int duration = get_audio_frame_duration(par->codec_id, par->sample_rate, par->channels, par->block_align, par->codec_tag, par->bits_per_coded_sample, par->bit_rate, par->extradata, par->frame_size, frame_bytes); + return FFMAX(0, duration); } #if !HAVE_THREADS @@ -2195,3 +2272,22 @@ int64_t ff_guess_coded_bitrate(AVCodecContext *avctx) return bitrate; } + +int ff_int_from_list_or_default(void *ctx, const char * val_name, int val, + const int * array_valid_values, int default_value) +{ + int i = 0, ref_val; + + while (1) { + ref_val = array_valid_values[i]; + if (ref_val == INT_MAX) + break; + if (val == ref_val) + return val; + i++; + } + /* val is not a valid value */ + av_log(ctx, AV_LOG_DEBUG, + "%s %d are not supported. Set to default value : %d\n", val_name, val, default_value); + return default_value; +} diff --git a/libs/ffvpx/libavcodec/version.h b/libs/ffvpx/libavcodec/version.h index 6895f1a46..3331d4730 100644 --- a/libs/ffvpx/libavcodec/version.h +++ b/libs/ffvpx/libavcodec/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 58 -#define LIBAVCODEC_VERSION_MINOR 18 +#define LIBAVCODEC_VERSION_MINOR 54 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ @@ -132,6 +132,9 @@ #ifndef FF_API_NEXT #define FF_API_NEXT (LIBAVCODEC_VERSION_MAJOR < 59) #endif +#ifndef FF_API_UNSANITIZED_BITRATES +#define FF_API_UNSANITIZED_BITRATES (LIBAVCODEC_VERSION_MAJOR < 59) +#endif #endif /* AVCODEC_VERSION_H */ diff --git a/libs/ffvpx/libavcodec/videodsp_template.c b/libs/ffvpx/libavcodec/videodsp_template.c index 94c1b7188..55123a584 100644 --- a/libs/ffvpx/libavcodec/videodsp_template.c +++ b/libs/ffvpx/libavcodec/videodsp_template.c @@ -44,7 +44,8 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, src_y = 1 - block_h; } if (src_x >= w) { - src += (w - 1 - src_x) * sizeof(pixel); + // The subtracted expression has an unsigned type and must thus not be negative + src -= (1 + src_x - w) * sizeof(pixel); src_x = w - 1; } else if (src_x <= -block_w) { src += (1 - block_w - src_x) * sizeof(pixel); diff --git a/libs/ffvpx/libavcodec/vp3dsp.h b/libs/ffvpx/libavcodec/vp3dsp.h index 2fdad162c..32b2cad0e 100644 --- a/libs/ffvpx/libavcodec/vp3dsp.h +++ b/libs/ffvpx/libavcodec/vp3dsp.h @@ -45,9 +45,18 @@ typedef struct VP3DSPContext { void (*h_loop_filter)(uint8_t *src, ptrdiff_t stride, int *bounding_values); } VP3DSPContext; +void ff_vp3dsp_v_loop_filter_12(uint8_t *first_pixel, ptrdiff_t stride, int *bounding_values); +void ff_vp3dsp_h_loop_filter_12(uint8_t *first_pixel, ptrdiff_t stride, int *bounding_values); + +void ff_vp3dsp_idct10_put(uint8_t *dest, ptrdiff_t stride, int16_t *block); +void ff_vp3dsp_idct10_add(uint8_t *dest, ptrdiff_t stride, int16_t *block); + void ff_vp3dsp_init(VP3DSPContext *c, int flags); void ff_vp3dsp_init_arm(VP3DSPContext *c, int flags); void ff_vp3dsp_init_ppc(VP3DSPContext *c, int flags); void ff_vp3dsp_init_x86(VP3DSPContext *c, int flags); +void ff_vp3dsp_init_mips(VP3DSPContext *c, int flags); + +void ff_vp3dsp_set_bounding_values(int * bound_values_array, int filter_limit); #endif /* AVCODEC_VP3DSP_H */ diff --git a/libs/ffvpx/libavcodec/vp56.h b/libs/ffvpx/libavcodec/vp56.h index b8dda9e73..65cf46870 100644 --- a/libs/ffvpx/libavcodec/vp56.h +++ b/libs/ffvpx/libavcodec/vp56.h @@ -89,6 +89,7 @@ typedef struct VP56RangeCoder { const uint8_t *buffer; const uint8_t *end; unsigned int code_word; + int end_reached; } VP56RangeCoder; typedef struct VP56RefDc { @@ -105,6 +106,7 @@ typedef struct VP56Macroblock { typedef struct VP56Model { uint8_t coeff_reorder[64]; /* used in vp6 only */ uint8_t coeff_index_to_pos[64]; /* used in vp6 only */ + uint8_t coeff_index_to_idct_selector[64]; /* used in vp6 only */ uint8_t vector_sig[2]; /* delta sign */ uint8_t vector_dct[2]; /* delta coding types */ uint8_t vector_pdi[2][2]; /* predefined delta init */ @@ -157,6 +159,7 @@ struct vp56_context { VP56mb mb_type; VP56Macroblock *macroblocks; DECLARE_ALIGNED(16, int16_t, block_coeff)[6][64]; + int idct_selector[6]; /* motion vectors */ VP56mv mv[6]; /* vectors for each block in MB */ @@ -170,6 +173,7 @@ struct vp56_context { int filter_mode; int max_vector_length; int sample_variance_threshold; + DECLARE_ALIGNED(8, int, bounding_values_array)[256]; uint8_t coeff_ctx[4][64]; /* used in vp5 only */ uint8_t coeff_ctx_last[4]; /* used in vp5 only */ @@ -227,6 +231,16 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, extern const uint8_t ff_vp56_norm_shift[256]; int ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size); +/** + * vp5689 returns 1 if the end of the stream has been reached, 0 otherwise. + */ +static av_always_inline int vpX_rac_is_end(VP56RangeCoder *c) +{ + if (c->end <= c->buffer && c->bits >= 0) + c->end_reached ++; + return c->end_reached > 10; +} + static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c) { int shift = ff_vp56_norm_shift[c->high]; diff --git a/libs/ffvpx/libavcodec/vp56rac.c b/libs/ffvpx/libavcodec/vp56rac.c index e70302bf8..64fb6a99b 100644 --- a/libs/ffvpx/libavcodec/vp56rac.c +++ b/libs/ffvpx/libavcodec/vp56rac.c @@ -43,6 +43,7 @@ int ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_si c->bits = -16; c->buffer = buf; c->end = buf + buf_size; + c->end_reached = 0; if (buf_size < 1) return AVERROR_INVALIDDATA; c->code_word = bytestream_get_be24(&c->buffer); diff --git a/libs/ffvpx/libavcodec/vp8.c b/libs/ffvpx/libavcodec/vp8.c index 62b9f8bc2..4b07ea806 100644 --- a/libs/ffvpx/libavcodec/vp8.c +++ b/libs/ffvpx/libavcodec/vp8.c @@ -492,9 +492,11 @@ static void fade(uint8_t *dst, ptrdiff_t dst_linesize, { int i, j; for (j = 0; j < height; j++) { + const uint8_t *src2 = src + j * src_linesize; + uint8_t *dst2 = dst + j * dst_linesize; for (i = 0; i < width; i++) { - uint8_t y = src[j * src_linesize + i]; - dst[j * dst_linesize + i] = av_clip_uint8(y + ((y * beta) >> 8) + alpha); + uint8_t y = src2[i]; + dst2[i] = av_clip_uint8(y + ((y * beta) >> 8) + alpha); } } } @@ -505,6 +507,9 @@ static int vp7_fade_frame(VP8Context *s, VP56RangeCoder *c) int beta = (int8_t) vp8_rac_get_uint(c, 8); int ret; + if (c->end <= c->buffer && c->bits >= 0) + return AVERROR_INVALIDDATA; + if (!s->keyframe && (alpha || beta)) { int width = s->mb_width * 16; int height = s->mb_height * 16; @@ -656,7 +661,7 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si s->fade_present = vp8_rac_get(c); } - if (c->end <= c->buffer && c->bits >= 0) + if (vpX_rac_is_end(c)) return AVERROR_INVALIDDATA; /* E. Fading information for previous frame */ if (s->fade_present && vp8_rac_get(c)) { @@ -2263,7 +2268,7 @@ void filter_mb_simple(VP8Context *s, uint8_t *dst, VP8FilterStrength *f, #define MARGIN (16 << 2) static av_always_inline -void vp78_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe, +int vp78_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe, VP8Frame *prev_frame, int is_vp7) { VP8Context *s = avctx->priv_data; @@ -2280,7 +2285,11 @@ void vp78_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe, s->mv_bounds.mv_min.x = -MARGIN; s->mv_bounds.mv_max.x = ((s->mb_width - 1) << 6) + MARGIN; + for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) { + if (vpX_rac_is_end(&s->c)) { + return AVERROR_INVALIDDATA; + } if (mb_y == 0) AV_WN32A((mb - s->mb_width - 1)->intra4x4_pred_mode_top, DC_PRED * 0x01010101); @@ -2293,18 +2302,19 @@ void vp78_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe, s->mv_bounds.mv_min.y -= 64; s->mv_bounds.mv_max.y -= 64; } + return 0; } -static void vp7_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame, +static int vp7_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame, VP8Frame *prev_frame) { - vp78_decode_mv_mb_modes(avctx, cur_frame, prev_frame, IS_VP7); + return vp78_decode_mv_mb_modes(avctx, cur_frame, prev_frame, IS_VP7); } -static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame, +static int vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame, VP8Frame *prev_frame) { - vp78_decode_mv_mb_modes(avctx, cur_frame, prev_frame, IS_VP8); + return vp78_decode_mv_mb_modes(avctx, cur_frame, prev_frame, IS_VP8); } #if HAVE_THREADS @@ -2362,7 +2372,7 @@ static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void curframe->tf.f->data[2] + 8 * mb_y * s->uvlinesize }; - if (c->end <= c->buffer && c->bits >= 0) + if (vpX_rac_is_end(c)) return AVERROR_INVALIDDATA; if (mb_y == 0) @@ -2393,7 +2403,7 @@ static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void td->mv_bounds.mv_max.x = ((s->mb_width - 1) << 6) + MARGIN; for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) { - if (c->end <= c->buffer && c->bits >= 0) + if (vpX_rac_is_end(c)) return AVERROR_INVALIDDATA; // Wait for previous thread to read mb_x+2, and reach mb_y-1. if (prev_td != td) { @@ -2739,9 +2749,11 @@ int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, !s->segmentation.update_map) ff_thread_await_progress(&prev_frame->tf, 1, 0); if (is_vp7) - vp7_decode_mv_mb_modes(avctx, curframe, prev_frame); + ret = vp7_decode_mv_mb_modes(avctx, curframe, prev_frame); else - vp8_decode_mv_mb_modes(avctx, curframe, prev_frame); + ret = vp8_decode_mv_mb_modes(avctx, curframe, prev_frame); + if (ret < 0) + goto err; } if (avctx->active_thread_type == FF_THREAD_FRAME) diff --git a/libs/ffvpx/libavcodec/vp8_parser.c b/libs/ffvpx/libavcodec/vp8_parser.c index e2d91b271..7ce35e753 100644 --- a/libs/ffvpx/libavcodec/vp8_parser.c +++ b/libs/ffvpx/libavcodec/vp8_parser.c @@ -70,8 +70,6 @@ static int parse(AVCodecParserContext *s, s->coded_height = FFALIGN(height, 16); } - *poutbuf = buf; - *poutbuf_size = buf_size; return buf_size; } diff --git a/libs/ffvpx/libavcodec/vp8dsp.c b/libs/ffvpx/libavcodec/vp8dsp.c index fed5c67a9..4ff63d078 100644 --- a/libs/ffvpx/libavcodec/vp8dsp.c +++ b/libs/ffvpx/libavcodec/vp8dsp.c @@ -673,6 +673,8 @@ av_cold void ff_vp78dsp_init(VP8DSPContext *dsp) VP78_BILINEAR_MC_FUNC(1, 8); VP78_BILINEAR_MC_FUNC(2, 4); + if (ARCH_AARCH64) + ff_vp78dsp_init_aarch64(dsp); if (ARCH_ARM) ff_vp78dsp_init_arm(dsp); if (ARCH_PPC) @@ -733,6 +735,8 @@ av_cold void ff_vp8dsp_init(VP8DSPContext *dsp) dsp->vp8_v_loop_filter_simple = vp8_v_loop_filter_simple_c; dsp->vp8_h_loop_filter_simple = vp8_h_loop_filter_simple_c; + if (ARCH_AARCH64) + ff_vp8dsp_init_aarch64(dsp); if (ARCH_ARM) ff_vp8dsp_init_arm(dsp); if (ARCH_X86) diff --git a/libs/ffvpx/libavcodec/vp8dsp.h b/libs/ffvpx/libavcodec/vp8dsp.h index eaae4aed6..cfe1524b0 100644 --- a/libs/ffvpx/libavcodec/vp8dsp.h +++ b/libs/ffvpx/libavcodec/vp8dsp.h @@ -91,11 +91,13 @@ void ff_put_vp8_pixels4_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride, void ff_vp7dsp_init(VP8DSPContext *c); void ff_vp78dsp_init(VP8DSPContext *c); +void ff_vp78dsp_init_aarch64(VP8DSPContext *c); void ff_vp78dsp_init_arm(VP8DSPContext *c); void ff_vp78dsp_init_ppc(VP8DSPContext *c); void ff_vp78dsp_init_x86(VP8DSPContext *c); void ff_vp8dsp_init(VP8DSPContext *c); +void ff_vp8dsp_init_aarch64(VP8DSPContext *c); void ff_vp8dsp_init_arm(VP8DSPContext *c); void ff_vp8dsp_init_x86(VP8DSPContext *c); void ff_vp8dsp_init_mips(VP8DSPContext *c); diff --git a/libs/ffvpx/libavcodec/vp9.c b/libs/ffvpx/libavcodec/vp9.c index b1178c9c0..f16462b1e 100644 --- a/libs/ffvpx/libavcodec/vp9.c +++ b/libs/ffvpx/libavcodec/vp9.c @@ -353,7 +353,7 @@ static av_always_inline int inv_recenter_nonneg(int v, int m) // differential forward probability updates static int update_prob(VP56RangeCoder *c, int p) { - static const int inv_map_table[255] = { + static const uint8_t inv_map_table[255] = { 7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176, 189, 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, @@ -1306,6 +1306,9 @@ static int decode_tiles(AVCodecContext *avctx, decode_sb_mem(td, row, col, lflvl_ptr, yoff2, uvoff2, BL_64X64); } else { + if (vpX_rac_is_end(td->c)) { + return AVERROR_INVALIDDATA; + } decode_sb(td, row, col, lflvl_ptr, yoff2, uvoff2, BL_64X64); } diff --git a/libs/ffvpx/libavcodec/vp9_parser.c b/libs/ffvpx/libavcodec/vp9_parser.c index 9531f34a3..c957a7566 100644 --- a/libs/ffvpx/libavcodec/vp9_parser.c +++ b/libs/ffvpx/libavcodec/vp9_parser.c @@ -36,12 +36,16 @@ static int parse(AVCodecParserContext *ctx, *out_data = data; *out_size = size; - if ((res = init_get_bits8(&gb, data, size)) < 0) + if (!size || (res = init_get_bits8(&gb, data, size)) < 0) return size; // parsers can't return errors get_bits(&gb, 2); // frame marker profile = get_bits1(&gb); profile |= get_bits1(&gb) << 1; if (profile == 3) profile += get_bits1(&gb); + if (profile > 3) + return size; + + avctx->profile = profile; if (get_bits1(&gb)) { keyframe = 0; diff --git a/libs/ffvpx/libavcodec/vp9_superframe_split_bsf.c b/libs/ffvpx/libavcodec/vp9_superframe_split_bsf.c index 9c4aa33dc..13e85c3ca 100644 --- a/libs/ffvpx/libavcodec/vp9_superframe_split_bsf.c +++ b/libs/ffvpx/libavcodec/vp9_superframe_split_bsf.c @@ -30,7 +30,7 @@ #include "get_bits.h" typedef struct VP9SFSplitContext { - AVPacket buffer_pkt; + AVPacket *buffer_pkt; int nb_frames; int next_frame; @@ -43,13 +43,13 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) VP9SFSplitContext *s = ctx->priv_data; AVPacket *in; int i, j, ret, marker; - int is_superframe = !!s->buffer_pkt.data; + int is_superframe = !!s->buffer_pkt->data; - if (!s->buffer_pkt.data) { - ret = ff_bsf_get_packet_ref(ctx, &s->buffer_pkt); + if (!s->buffer_pkt->data) { + ret = ff_bsf_get_packet_ref(ctx, s->buffer_pkt); if (ret < 0) return ret; - in = &s->buffer_pkt; + in = s->buffer_pkt; marker = in->data[in->size - 1]; if ((marker & 0xe0) == 0xc0) { @@ -90,7 +90,7 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) GetBitContext gb; int profile, invisible = 0; - ret = av_packet_ref(out, &s->buffer_pkt); + ret = av_packet_ref(out, s->buffer_pkt); if (ret < 0) goto fail; @@ -101,7 +101,7 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) s->next_frame++; if (s->next_frame >= s->nb_frames) - av_packet_unref(&s->buffer_pkt); + av_packet_unref(s->buffer_pkt); ret = init_get_bits8(&gb, out->data, out->size); if (ret < 0) @@ -121,26 +121,45 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) out->pts = AV_NOPTS_VALUE; } else { - av_packet_move_ref(out, &s->buffer_pkt); + av_packet_move_ref(out, s->buffer_pkt); } return 0; fail: if (ret < 0) av_packet_unref(out); - av_packet_unref(&s->buffer_pkt); + av_packet_unref(s->buffer_pkt); return ret; } +static int vp9_superframe_split_init(AVBSFContext *ctx) +{ + VP9SFSplitContext *s = ctx->priv_data; + + s->buffer_pkt = av_packet_alloc(); + if (!s->buffer_pkt) + return AVERROR(ENOMEM); + + return 0; +} + +static void vp9_superframe_split_flush(AVBSFContext *ctx) +{ + VP9SFSplitContext *s = ctx->priv_data; + av_packet_unref(s->buffer_pkt); +} + static void vp9_superframe_split_uninit(AVBSFContext *ctx) { VP9SFSplitContext *s = ctx->priv_data; - av_packet_unref(&s->buffer_pkt); + av_packet_free(&s->buffer_pkt); } const AVBitStreamFilter ff_vp9_superframe_split_bsf = { .name = "vp9_superframe_split", .priv_data_size = sizeof(VP9SFSplitContext), + .init = vp9_superframe_split_init, + .flush = vp9_superframe_split_flush, .close = vp9_superframe_split_uninit, .filter = vp9_superframe_split_filter, .codec_ids = (const enum AVCodecID []){ AV_CODEC_ID_VP9, AV_CODEC_ID_NONE }, diff --git a/libs/ffvpx/libavcodec/vp9dsp_template.c b/libs/ffvpx/libavcodec/vp9dsp_template.c index bb54561a6..9b1166170 100644 --- a/libs/ffvpx/libavcodec/vp9dsp_template.c +++ b/libs/ffvpx/libavcodec/vp9dsp_template.c @@ -1138,7 +1138,7 @@ static void type_a##_##type_b##_##sz##x##sz##_add_c(uint8_t *_dst, \ for (j = 0; j < sz; j++) \ dst[j * stride] = av_clip_pixel(dst[j * stride] + \ (bits ? \ - (t + (1 << (bits - 1))) >> bits : \ + (int)(t + (1U << (bits - 1))) >> bits : \ t)); \ dst++; \ } \ @@ -1153,7 +1153,7 @@ static void type_a##_##type_b##_##sz##x##sz##_add_c(uint8_t *_dst, \ for (j = 0; j < sz; j++) \ dst[j * stride] = av_clip_pixel(dst[j * stride] + \ (bits ? \ - (out[j] + (1 << (bits - 1))) >> bits : \ + (int)(out[j] + (1U << (bits - 1))) >> bits : \ out[j])); \ dst++; \ } \ @@ -1260,25 +1260,25 @@ static av_always_inline void iadst8_1d(const dctcoef *in, ptrdiff_t stride, t6 = (t2a - t6a + (1 << 13)) >> 14; t7 = (t3a - t7a + (1 << 13)) >> 14; - t4a = 15137 * t4 + 6270 * t5; - t5a = 6270 * t4 - 15137 * t5; - t6a = 15137 * t7 - 6270 * t6; - t7a = 6270 * t7 + 15137 * t6; + t4a = 15137U * t4 + 6270U * t5; + t5a = 6270U * t4 - 15137U * t5; + t6a = 15137U * t7 - 6270U * t6; + t7a = 6270U * t7 + 15137U * t6; out[0] = t0 + t2; out[7] = -(t1 + t3); t2 = t0 - t2; t3 = t1 - t3; - out[1] = -((t4a + t6a + (1 << 13)) >> 14); - out[6] = (t5a + t7a + (1 << 13)) >> 14; - t6 = (t4a - t6a + (1 << 13)) >> 14; - t7 = (t5a - t7a + (1 << 13)) >> 14; + out[1] = -((dctint)((1U << 13) + t4a + t6a) >> 14); + out[6] = (dctint)((1U << 13) + t5a + t7a) >> 14; + t6 = (dctint)((1U << 13) + t4a - t6a) >> 14; + t7 = (dctint)((1U << 13) + t5a - t7a) >> 14; - out[3] = -(((t2 + t3) * 11585 + (1 << 13)) >> 14); - out[4] = ((t2 - t3) * 11585 + (1 << 13)) >> 14; - out[2] = ((t6 + t7) * 11585 + (1 << 13)) >> 14; - out[5] = -(((t6 - t7) * 11585 + (1 << 13)) >> 14); + out[3] = -((dctint)((t2 + t3) * 11585U + (1 << 13)) >> 14); + out[4] = (dctint)((t2 - t3) * 11585U + (1 << 13)) >> 14; + out[2] = (dctint)((t6 + t7) * 11585U + (1 << 13)) >> 14; + out[5] = -((dctint)((t6 - t7) * 11585U + (1 << 13)) >> 14); } itxfm_wrap(8, 5) @@ -1290,22 +1290,22 @@ static av_always_inline void idct16_1d(const dctcoef *in, ptrdiff_t stride, dctint t0a, t1a, t2a, t3a, t4a, t5a, t6a, t7a; dctint t8a, t9a, t10a, t11a, t12a, t13a, t14a, t15a; - t0a = ((IN(0) + IN(8)) * 11585 + (1 << 13)) >> 14; - t1a = ((IN(0) - IN(8)) * 11585 + (1 << 13)) >> 14; - t2a = (IN(4) * 6270 - IN(12) * 15137 + (1 << 13)) >> 14; - t3a = (IN(4) * 15137 + IN(12) * 6270 + (1 << 13)) >> 14; - t4a = (IN(2) * 3196 - IN(14) * 16069 + (1 << 13)) >> 14; - t7a = (IN(2) * 16069 + IN(14) * 3196 + (1 << 13)) >> 14; - t5a = (IN(10) * 13623 - IN(6) * 9102 + (1 << 13)) >> 14; - t6a = (IN(10) * 9102 + IN(6) * 13623 + (1 << 13)) >> 14; - t8a = (IN(1) * 1606 - IN(15) * 16305 + (1 << 13)) >> 14; - t15a = (IN(1) * 16305 + IN(15) * 1606 + (1 << 13)) >> 14; - t9a = (IN(9) * 12665 - IN(7) * 10394 + (1 << 13)) >> 14; - t14a = (IN(9) * 10394 + IN(7) * 12665 + (1 << 13)) >> 14; - t10a = (IN(5) * 7723 - IN(11) * 14449 + (1 << 13)) >> 14; - t13a = (IN(5) * 14449 + IN(11) * 7723 + (1 << 13)) >> 14; - t11a = (IN(13) * 15679 - IN(3) * 4756 + (1 << 13)) >> 14; - t12a = (IN(13) * 4756 + IN(3) * 15679 + (1 << 13)) >> 14; + t0a = (dctint)((IN(0) + IN(8)) * 11585U + (1 << 13)) >> 14; + t1a = (dctint)((IN(0) - IN(8)) * 11585U + (1 << 13)) >> 14; + t2a = (dctint)(IN(4) * 6270U - IN(12) * 15137U + (1 << 13)) >> 14; + t3a = (dctint)(IN(4) * 15137U + IN(12) * 6270U + (1 << 13)) >> 14; + t4a = (dctint)(IN(2) * 3196U - IN(14) * 16069U + (1 << 13)) >> 14; + t7a = (dctint)(IN(2) * 16069U + IN(14) * 3196U + (1 << 13)) >> 14; + t5a = (dctint)(IN(10) * 13623U - IN(6) * 9102U + (1 << 13)) >> 14; + t6a = (dctint)(IN(10) * 9102U + IN(6) * 13623U + (1 << 13)) >> 14; + t8a = (dctint)(IN(1) * 1606U - IN(15) * 16305U + (1 << 13)) >> 14; + t15a = (dctint)(IN(1) * 16305U + IN(15) * 1606U + (1 << 13)) >> 14; + t9a = (dctint)(IN(9) * 12665U - IN(7) * 10394U + (1 << 13)) >> 14; + t14a = (dctint)(IN(9) * 10394U + IN(7) * 12665U + (1 << 13)) >> 14; + t10a = (dctint)(IN(5) * 7723U - IN(11) * 14449U + (1 << 13)) >> 14; + t13a = (dctint)(IN(5) * 14449U + IN(11) * 7723U + (1 << 13)) >> 14; + t11a = (dctint)(IN(13) * 15679U - IN(3) * 4756U + (1 << 13)) >> 14; + t12a = (dctint)(IN(13) * 4756U + IN(3) * 15679U + (1 << 13)) >> 14; t0 = t0a + t3a; t1 = t1a + t2a; @@ -1324,12 +1324,12 @@ static av_always_inline void idct16_1d(const dctcoef *in, ptrdiff_t stride, t14 = t15a - t14a; t15 = t15a + t14a; - t5a = ((t6 - t5) * 11585 + (1 << 13)) >> 14; - t6a = ((t6 + t5) * 11585 + (1 << 13)) >> 14; - t9a = ( t14 * 6270 - t9 * 15137 + (1 << 13)) >> 14; - t14a = ( t14 * 15137 + t9 * 6270 + (1 << 13)) >> 14; - t10a = (-(t13 * 15137 + t10 * 6270) + (1 << 13)) >> 14; - t13a = ( t13 * 6270 - t10 * 15137 + (1 << 13)) >> 14; + t5a = (dctint)((t6 - t5) * 11585U + (1 << 13)) >> 14; + t6a = (dctint)((t6 + t5) * 11585U + (1 << 13)) >> 14; + t9a = (dctint)( t14 * 6270U - t9 * 15137U + (1 << 13)) >> 14; + t14a = (dctint)( t14 * 15137U + t9 * 6270U + (1 << 13)) >> 14; + t10a = (dctint)(-(t13 * 15137U + t10 * 6270U) + (1 << 13)) >> 14; + t13a = (dctint)( t13 * 6270U - t10 * 15137U + (1 << 13)) >> 14; t0a = t0 + t7; t1a = t1 + t6a; @@ -1348,10 +1348,10 @@ static av_always_inline void idct16_1d(const dctcoef *in, ptrdiff_t stride, t14 = t14a + t13a; t15a = t15 + t12; - t10a = ((t13 - t10) * 11585 + (1 << 13)) >> 14; - t13a = ((t13 + t10) * 11585 + (1 << 13)) >> 14; - t11 = ((t12a - t11a) * 11585 + (1 << 13)) >> 14; - t12 = ((t12a + t11a) * 11585 + (1 << 13)) >> 14; + t10a = (dctint)((t13 - t10) * 11585U + (1 << 13)) >> 14; + t13a = (dctint)((t13 + t10) * 11585U + (1 << 13)) >> 14; + t11 = (dctint)((t12a - t11a) * 11585U + (1 << 13)) >> 14; + t12 = (dctint)((t12a + t11a) * 11585U + (1 << 13)) >> 14; out[ 0] = t0a + t15a; out[ 1] = t1a + t14; @@ -1378,48 +1378,48 @@ static av_always_inline void iadst16_1d(const dctcoef *in, ptrdiff_t stride, dctint t0a, t1a, t2a, t3a, t4a, t5a, t6a, t7a; dctint t8a, t9a, t10a, t11a, t12a, t13a, t14a, t15a; - t0 = IN(15) * 16364 + IN(0) * 804; - t1 = IN(15) * 804 - IN(0) * 16364; - t2 = IN(13) * 15893 + IN(2) * 3981; - t3 = IN(13) * 3981 - IN(2) * 15893; - t4 = IN(11) * 14811 + IN(4) * 7005; - t5 = IN(11) * 7005 - IN(4) * 14811; - t6 = IN(9) * 13160 + IN(6) * 9760; - t7 = IN(9) * 9760 - IN(6) * 13160; - t8 = IN(7) * 11003 + IN(8) * 12140; - t9 = IN(7) * 12140 - IN(8) * 11003; - t10 = IN(5) * 8423 + IN(10) * 14053; - t11 = IN(5) * 14053 - IN(10) * 8423; - t12 = IN(3) * 5520 + IN(12) * 15426; - t13 = IN(3) * 15426 - IN(12) * 5520; - t14 = IN(1) * 2404 + IN(14) * 16207; - t15 = IN(1) * 16207 - IN(14) * 2404; - - t0a = (t0 + t8 + (1 << 13)) >> 14; - t1a = (t1 + t9 + (1 << 13)) >> 14; - t2a = (t2 + t10 + (1 << 13)) >> 14; - t3a = (t3 + t11 + (1 << 13)) >> 14; - t4a = (t4 + t12 + (1 << 13)) >> 14; - t5a = (t5 + t13 + (1 << 13)) >> 14; - t6a = (t6 + t14 + (1 << 13)) >> 14; - t7a = (t7 + t15 + (1 << 13)) >> 14; - t8a = (t0 - t8 + (1 << 13)) >> 14; - t9a = (t1 - t9 + (1 << 13)) >> 14; - t10a = (t2 - t10 + (1 << 13)) >> 14; - t11a = (t3 - t11 + (1 << 13)) >> 14; - t12a = (t4 - t12 + (1 << 13)) >> 14; - t13a = (t5 - t13 + (1 << 13)) >> 14; - t14a = (t6 - t14 + (1 << 13)) >> 14; - t15a = (t7 - t15 + (1 << 13)) >> 14; - - t8 = t8a * 16069 + t9a * 3196; - t9 = t8a * 3196 - t9a * 16069; - t10 = t10a * 9102 + t11a * 13623; - t11 = t10a * 13623 - t11a * 9102; - t12 = t13a * 16069 - t12a * 3196; - t13 = t13a * 3196 + t12a * 16069; - t14 = t15a * 9102 - t14a * 13623; - t15 = t15a * 13623 + t14a * 9102; + t0 = IN(15) * 16364U + IN(0) * 804U; + t1 = IN(15) * 804U - IN(0) * 16364U; + t2 = IN(13) * 15893U + IN(2) * 3981U; + t3 = IN(13) * 3981U - IN(2) * 15893U; + t4 = IN(11) * 14811U + IN(4) * 7005U; + t5 = IN(11) * 7005U - IN(4) * 14811U; + t6 = IN(9) * 13160U + IN(6) * 9760U; + t7 = IN(9) * 9760U - IN(6) * 13160U; + t8 = IN(7) * 11003U + IN(8) * 12140U; + t9 = IN(7) * 12140U - IN(8) * 11003U; + t10 = IN(5) * 8423U + IN(10) * 14053U; + t11 = IN(5) * 14053U - IN(10) * 8423U; + t12 = IN(3) * 5520U + IN(12) * 15426U; + t13 = IN(3) * 15426U - IN(12) * 5520U; + t14 = IN(1) * 2404U + IN(14) * 16207U; + t15 = IN(1) * 16207U - IN(14) * 2404U; + + t0a = (dctint)((1U << 13) + t0 + t8 ) >> 14; + t1a = (dctint)((1U << 13) + t1 + t9 ) >> 14; + t2a = (dctint)((1U << 13) + t2 + t10) >> 14; + t3a = (dctint)((1U << 13) + t3 + t11) >> 14; + t4a = (dctint)((1U << 13) + t4 + t12) >> 14; + t5a = (dctint)((1U << 13) + t5 + t13) >> 14; + t6a = (dctint)((1U << 13) + t6 + t14) >> 14; + t7a = (dctint)((1U << 13) + t7 + t15) >> 14; + t8a = (dctint)((1U << 13) + t0 - t8 ) >> 14; + t9a = (dctint)((1U << 13) + t1 - t9 ) >> 14; + t10a = (dctint)((1U << 13) + t2 - t10) >> 14; + t11a = (dctint)((1U << 13) + t3 - t11) >> 14; + t12a = (dctint)((1U << 13) + t4 - t12) >> 14; + t13a = (dctint)((1U << 13) + t5 - t13) >> 14; + t14a = (dctint)((1U << 13) + t6 - t14) >> 14; + t15a = (dctint)((1U << 13) + t7 - t15) >> 14; + + t8 = t8a * 16069U + t9a * 3196U; + t9 = t8a * 3196U - t9a * 16069U; + t10 = t10a * 9102U + t11a * 13623U; + t11 = t10a * 13623U - t11a * 9102U; + t12 = t13a * 16069U - t12a * 3196U; + t13 = t13a * 3196U + t12a * 16069U; + t14 = t15a * 9102U - t14a * 13623U; + t15 = t15a * 13623U + t14a * 9102U; t0 = t0a + t4a; t1 = t1a + t5a; @@ -1429,49 +1429,49 @@ static av_always_inline void iadst16_1d(const dctcoef *in, ptrdiff_t stride, t5 = t1a - t5a; t6 = t2a - t6a; t7 = t3a - t7a; - t8a = (t8 + t12 + (1 << 13)) >> 14; - t9a = (t9 + t13 + (1 << 13)) >> 14; - t10a = (t10 + t14 + (1 << 13)) >> 14; - t11a = (t11 + t15 + (1 << 13)) >> 14; - t12a = (t8 - t12 + (1 << 13)) >> 14; - t13a = (t9 - t13 + (1 << 13)) >> 14; - t14a = (t10 - t14 + (1 << 13)) >> 14; - t15a = (t11 - t15 + (1 << 13)) >> 14; - - t4a = t4 * 15137 + t5 * 6270; - t5a = t4 * 6270 - t5 * 15137; - t6a = t7 * 15137 - t6 * 6270; - t7a = t7 * 6270 + t6 * 15137; - t12 = t12a * 15137 + t13a * 6270; - t13 = t12a * 6270 - t13a * 15137; - t14 = t15a * 15137 - t14a * 6270; - t15 = t15a * 6270 + t14a * 15137; + t8a = (dctint)((1U << 13) + t8 + t12) >> 14; + t9a = (dctint)((1U << 13) + t9 + t13) >> 14; + t10a = (dctint)((1U << 13) + t10 + t14) >> 14; + t11a = (dctint)((1U << 13) + t11 + t15) >> 14; + t12a = (dctint)((1U << 13) + t8 - t12) >> 14; + t13a = (dctint)((1U << 13) + t9 - t13) >> 14; + t14a = (dctint)((1U << 13) + t10 - t14) >> 14; + t15a = (dctint)((1U << 13) + t11 - t15) >> 14; + + t4a = t4 * 15137U + t5 * 6270U; + t5a = t4 * 6270U - t5 * 15137U; + t6a = t7 * 15137U - t6 * 6270U; + t7a = t7 * 6270U + t6 * 15137U; + t12 = t12a * 15137U + t13a * 6270U; + t13 = t12a * 6270U - t13a * 15137U; + t14 = t15a * 15137U - t14a * 6270U; + t15 = t15a * 6270U + t14a * 15137U; out[ 0] = t0 + t2; out[15] = -(t1 + t3); t2a = t0 - t2; t3a = t1 - t3; - out[ 3] = -((t4a + t6a + (1 << 13)) >> 14); - out[12] = (t5a + t7a + (1 << 13)) >> 14; - t6 = (t4a - t6a + (1 << 13)) >> 14; - t7 = (t5a - t7a + (1 << 13)) >> 14; + out[ 3] = -((dctint)((1U << 13) + t4a + t6a) >> 14); + out[12] = (dctint)((1U << 13) + t5a + t7a) >> 14; + t6 = (dctint)((1U << 13) + t4a - t6a) >> 14; + t7 = (dctint)((1U << 13) + t5a - t7a) >> 14; out[ 1] = -(t8a + t10a); out[14] = t9a + t11a; t10 = t8a - t10a; t11 = t9a - t11a; - out[ 2] = (t12 + t14 + (1 << 13)) >> 14; - out[13] = -((t13 + t15 + (1 << 13)) >> 14); - t14a = (t12 - t14 + (1 << 13)) >> 14; - t15a = (t13 - t15 + (1 << 13)) >> 14; + out[ 2] = (dctint)((1U << 13) + t12 + t14) >> 14; + out[13] = -((dctint)((1U << 13) + t13 + t15) >> 14); + t14a = (dctint)((1U << 13) + t12 - t14) >> 14; + t15a = (dctint)((1U << 13) + t13 - t15) >> 14; - out[ 7] = ((t2a + t3a) * -11585 + (1 << 13)) >> 14; - out[ 8] = ((t2a - t3a) * 11585 + (1 << 13)) >> 14; - out[ 4] = ((t7 + t6) * 11585 + (1 << 13)) >> 14; - out[11] = ((t7 - t6) * 11585 + (1 << 13)) >> 14; - out[ 6] = ((t11 + t10) * 11585 + (1 << 13)) >> 14; - out[ 9] = ((t11 - t10) * 11585 + (1 << 13)) >> 14; - out[ 5] = ((t14a + t15a) * -11585 + (1 << 13)) >> 14; - out[10] = ((t14a - t15a) * 11585 + (1 << 13)) >> 14; + out[ 7] = (dctint)(-(t2a + t3a) * 11585U + (1 << 13)) >> 14; + out[ 8] = (dctint)( (t2a - t3a) * 11585U + (1 << 13)) >> 14; + out[ 4] = (dctint)( (t7 + t6) * 11585U + (1 << 13)) >> 14; + out[11] = (dctint)( (t7 - t6) * 11585U + (1 << 13)) >> 14; + out[ 6] = (dctint)( (t11 + t10) * 11585U + (1 << 13)) >> 14; + out[ 9] = (dctint)( (t11 - t10) * 11585U + (1 << 13)) >> 14; + out[ 5] = (dctint)(-(t14a + t15a) * 11585U + (1 << 13)) >> 14; + out[10] = (dctint)( (t14a - t15a) * 11585U + (1 << 13)) >> 14; } itxfm_wrap(16, 6) @@ -1479,38 +1479,38 @@ itxfm_wrap(16, 6) static av_always_inline void idct32_1d(const dctcoef *in, ptrdiff_t stride, dctcoef *out, int pass) { - dctint t0a = ((IN(0) + IN(16)) * 11585 + (1 << 13)) >> 14; - dctint t1a = ((IN(0) - IN(16)) * 11585 + (1 << 13)) >> 14; - dctint t2a = (IN( 8) * 6270 - IN(24) * 15137 + (1 << 13)) >> 14; - dctint t3a = (IN( 8) * 15137 + IN(24) * 6270 + (1 << 13)) >> 14; - dctint t4a = (IN( 4) * 3196 - IN(28) * 16069 + (1 << 13)) >> 14; - dctint t7a = (IN( 4) * 16069 + IN(28) * 3196 + (1 << 13)) >> 14; - dctint t5a = (IN(20) * 13623 - IN(12) * 9102 + (1 << 13)) >> 14; - dctint t6a = (IN(20) * 9102 + IN(12) * 13623 + (1 << 13)) >> 14; - dctint t8a = (IN( 2) * 1606 - IN(30) * 16305 + (1 << 13)) >> 14; - dctint t15a = (IN( 2) * 16305 + IN(30) * 1606 + (1 << 13)) >> 14; - dctint t9a = (IN(18) * 12665 - IN(14) * 10394 + (1 << 13)) >> 14; - dctint t14a = (IN(18) * 10394 + IN(14) * 12665 + (1 << 13)) >> 14; - dctint t10a = (IN(10) * 7723 - IN(22) * 14449 + (1 << 13)) >> 14; - dctint t13a = (IN(10) * 14449 + IN(22) * 7723 + (1 << 13)) >> 14; - dctint t11a = (IN(26) * 15679 - IN( 6) * 4756 + (1 << 13)) >> 14; - dctint t12a = (IN(26) * 4756 + IN( 6) * 15679 + (1 << 13)) >> 14; - dctint t16a = (IN( 1) * 804 - IN(31) * 16364 + (1 << 13)) >> 14; - dctint t31a = (IN( 1) * 16364 + IN(31) * 804 + (1 << 13)) >> 14; - dctint t17a = (IN(17) * 12140 - IN(15) * 11003 + (1 << 13)) >> 14; - dctint t30a = (IN(17) * 11003 + IN(15) * 12140 + (1 << 13)) >> 14; - dctint t18a = (IN( 9) * 7005 - IN(23) * 14811 + (1 << 13)) >> 14; - dctint t29a = (IN( 9) * 14811 + IN(23) * 7005 + (1 << 13)) >> 14; - dctint t19a = (IN(25) * 15426 - IN( 7) * 5520 + (1 << 13)) >> 14; - dctint t28a = (IN(25) * 5520 + IN( 7) * 15426 + (1 << 13)) >> 14; - dctint t20a = (IN( 5) * 3981 - IN(27) * 15893 + (1 << 13)) >> 14; - dctint t27a = (IN( 5) * 15893 + IN(27) * 3981 + (1 << 13)) >> 14; - dctint t21a = (IN(21) * 14053 - IN(11) * 8423 + (1 << 13)) >> 14; - dctint t26a = (IN(21) * 8423 + IN(11) * 14053 + (1 << 13)) >> 14; - dctint t22a = (IN(13) * 9760 - IN(19) * 13160 + (1 << 13)) >> 14; - dctint t25a = (IN(13) * 13160 + IN(19) * 9760 + (1 << 13)) >> 14; - dctint t23a = (IN(29) * 16207 - IN( 3) * 2404 + (1 << 13)) >> 14; - dctint t24a = (IN(29) * 2404 + IN( 3) * 16207 + (1 << 13)) >> 14; + dctint t0a = (dctint)((IN(0) + IN(16)) * 11585U + (1 << 13)) >> 14; + dctint t1a = (dctint)((IN(0) - IN(16)) * 11585U + (1 << 13)) >> 14; + dctint t2a = (dctint)(IN( 8) * 6270U - IN(24) * 15137U + (1 << 13)) >> 14; + dctint t3a = (dctint)(IN( 8) * 15137U + IN(24) * 6270U + (1 << 13)) >> 14; + dctint t4a = (dctint)(IN( 4) * 3196U - IN(28) * 16069U + (1 << 13)) >> 14; + dctint t7a = (dctint)(IN( 4) * 16069U + IN(28) * 3196U + (1 << 13)) >> 14; + dctint t5a = (dctint)(IN(20) * 13623U - IN(12) * 9102U + (1 << 13)) >> 14; + dctint t6a = (dctint)(IN(20) * 9102U + IN(12) * 13623U + (1 << 13)) >> 14; + dctint t8a = (dctint)(IN( 2) * 1606U - IN(30) * 16305U + (1 << 13)) >> 14; + dctint t15a = (dctint)(IN( 2) * 16305U + IN(30) * 1606U + (1 << 13)) >> 14; + dctint t9a = (dctint)(IN(18) * 12665U - IN(14) * 10394U + (1 << 13)) >> 14; + dctint t14a = (dctint)(IN(18) * 10394U + IN(14) * 12665U + (1 << 13)) >> 14; + dctint t10a = (dctint)(IN(10) * 7723U - IN(22) * 14449U + (1 << 13)) >> 14; + dctint t13a = (dctint)(IN(10) * 14449U + IN(22) * 7723U + (1 << 13)) >> 14; + dctint t11a = (dctint)(IN(26) * 15679U - IN( 6) * 4756U + (1 << 13)) >> 14; + dctint t12a = (dctint)(IN(26) * 4756U + IN( 6) * 15679U + (1 << 13)) >> 14; + dctint t16a = (dctint)(IN( 1) * 804U - IN(31) * 16364U + (1 << 13)) >> 14; + dctint t31a = (dctint)(IN( 1) * 16364U + IN(31) * 804U + (1 << 13)) >> 14; + dctint t17a = (dctint)(IN(17) * 12140U - IN(15) * 11003U + (1 << 13)) >> 14; + dctint t30a = (dctint)(IN(17) * 11003U + IN(15) * 12140U + (1 << 13)) >> 14; + dctint t18a = (dctint)(IN( 9) * 7005U - IN(23) * 14811U + (1 << 13)) >> 14; + dctint t29a = (dctint)(IN( 9) * 14811U + IN(23) * 7005U + (1 << 13)) >> 14; + dctint t19a = (dctint)(IN(25) * 15426U - IN( 7) * 5520U + (1 << 13)) >> 14; + dctint t28a = (dctint)(IN(25) * 5520U + IN( 7) * 15426U + (1 << 13)) >> 14; + dctint t20a = (dctint)(IN( 5) * 3981U - IN(27) * 15893U + (1 << 13)) >> 14; + dctint t27a = (dctint)(IN( 5) * 15893U + IN(27) * 3981U + (1 << 13)) >> 14; + dctint t21a = (dctint)(IN(21) * 14053U - IN(11) * 8423U + (1 << 13)) >> 14; + dctint t26a = (dctint)(IN(21) * 8423U + IN(11) * 14053U + (1 << 13)) >> 14; + dctint t22a = (dctint)(IN(13) * 9760U - IN(19) * 13160U + (1 << 13)) >> 14; + dctint t25a = (dctint)(IN(13) * 13160U + IN(19) * 9760U + (1 << 13)) >> 14; + dctint t23a = (dctint)(IN(29) * 16207U - IN( 3) * 2404U + (1 << 13)) >> 14; + dctint t24a = (dctint)(IN(29) * 2404U + IN( 3) * 16207U + (1 << 13)) >> 14; dctint t0 = t0a + t3a; dctint t1 = t1a + t2a; @@ -1545,20 +1545,20 @@ static av_always_inline void idct32_1d(const dctcoef *in, ptrdiff_t stride, dctint t30 = t31a - t30a; dctint t31 = t31a + t30a; - t5a = ((t6 - t5) * 11585 + (1 << 13)) >> 14; - t6a = ((t6 + t5) * 11585 + (1 << 13)) >> 14; - t9a = ( t14 * 6270 - t9 * 15137 + (1 << 13)) >> 14; - t14a = ( t14 * 15137 + t9 * 6270 + (1 << 13)) >> 14; - t10a = (-(t13 * 15137 + t10 * 6270) + (1 << 13)) >> 14; - t13a = ( t13 * 6270 - t10 * 15137 + (1 << 13)) >> 14; - t17a = ( t30 * 3196 - t17 * 16069 + (1 << 13)) >> 14; - t30a = ( t30 * 16069 + t17 * 3196 + (1 << 13)) >> 14; - t18a = (-(t29 * 16069 + t18 * 3196) + (1 << 13)) >> 14; - t29a = ( t29 * 3196 - t18 * 16069 + (1 << 13)) >> 14; - t21a = ( t26 * 13623 - t21 * 9102 + (1 << 13)) >> 14; - t26a = ( t26 * 9102 + t21 * 13623 + (1 << 13)) >> 14; - t22a = (-(t25 * 9102 + t22 * 13623) + (1 << 13)) >> 14; - t25a = ( t25 * 13623 - t22 * 9102 + (1 << 13)) >> 14; + t5a = (dctint)((t6 - t5) * 11585U + (1 << 13)) >> 14; + t6a = (dctint)((t6 + t5) * 11585U + (1 << 13)) >> 14; + t9a = (dctint)( t14 * 6270U - t9 * 15137U + (1 << 13)) >> 14; + t14a = (dctint)( t14 * 15137U + t9 * 6270U + (1 << 13)) >> 14; + t10a = (dctint)(-(t13 * 15137U + t10 * 6270U) + (1 << 13)) >> 14; + t13a = (dctint)( t13 * 6270U - t10 * 15137U + (1 << 13)) >> 14; + t17a = (dctint)( t30 * 3196U - t17 * 16069U + (1 << 13)) >> 14; + t30a = (dctint)( t30 * 16069U + t17 * 3196U + (1 << 13)) >> 14; + t18a = (dctint)(-(t29 * 16069U + t18 * 3196U) + (1 << 13)) >> 14; + t29a = (dctint)( t29 * 3196U - t18 * 16069U + (1 << 13)) >> 14; + t21a = (dctint)( t26 * 13623U - t21 * 9102U + (1 << 13)) >> 14; + t26a = (dctint)( t26 * 9102U + t21 * 13623U + (1 << 13)) >> 14; + t22a = (dctint)(-(t25 * 9102U + t22 * 13623U) + (1 << 13)) >> 14; + t25a = (dctint)( t25 * 13623U - t22 * 9102U + (1 << 13)) >> 14; t0a = t0 + t7; t1a = t1 + t6a; @@ -1593,18 +1593,18 @@ static av_always_inline void idct32_1d(const dctcoef *in, ptrdiff_t stride, t30 = t30a + t29a; t31a = t31 + t28; - t10a = ((t13 - t10) * 11585 + (1 << 13)) >> 14; - t13a = ((t13 + t10) * 11585 + (1 << 13)) >> 14; - t11 = ((t12a - t11a) * 11585 + (1 << 13)) >> 14; - t12 = ((t12a + t11a) * 11585 + (1 << 13)) >> 14; - t18a = ( t29 * 6270 - t18 * 15137 + (1 << 13)) >> 14; - t29a = ( t29 * 15137 + t18 * 6270 + (1 << 13)) >> 14; - t19 = ( t28a * 6270 - t19a * 15137 + (1 << 13)) >> 14; - t28 = ( t28a * 15137 + t19a * 6270 + (1 << 13)) >> 14; - t20 = (-(t27a * 15137 + t20a * 6270) + (1 << 13)) >> 14; - t27 = ( t27a * 6270 - t20a * 15137 + (1 << 13)) >> 14; - t21a = (-(t26 * 15137 + t21 * 6270) + (1 << 13)) >> 14; - t26a = ( t26 * 6270 - t21 * 15137 + (1 << 13)) >> 14; + t10a = (dctint)((t13 - t10) * 11585U + (1 << 13)) >> 14; + t13a = (dctint)((t13 + t10) * 11585U + (1 << 13)) >> 14; + t11 = (dctint)((t12a - t11a) * 11585U + (1 << 13)) >> 14; + t12 = (dctint)((t12a + t11a) * 11585U + (1 << 13)) >> 14; + t18a = (dctint)( t29 * 6270U - t18 * 15137U + (1 << 13)) >> 14; + t29a = (dctint)( t29 * 15137U + t18 * 6270U + (1 << 13)) >> 14; + t19 = (dctint)( t28a * 6270U - t19a * 15137U + (1 << 13)) >> 14; + t28 = (dctint)( t28a * 15137U + t19a * 6270U + (1 << 13)) >> 14; + t20 = (dctint)(-(t27a * 15137U + t20a * 6270U) + (1 << 13)) >> 14; + t27 = (dctint)( t27a * 6270U - t20a * 15137U + (1 << 13)) >> 14; + t21a = (dctint)(-(t26 * 15137U + t21 * 6270U) + (1 << 13)) >> 14; + t26a = (dctint)( t26 * 6270U - t21 * 15137U + (1 << 13)) >> 14; t0 = t0a + t15a; t1 = t1a + t14; @@ -1639,14 +1639,14 @@ static av_always_inline void idct32_1d(const dctcoef *in, ptrdiff_t stride, t30a = t30 + t25; t31 = t31a + t24a; - t20 = ((t27a - t20a) * 11585 + (1 << 13)) >> 14; - t27 = ((t27a + t20a) * 11585 + (1 << 13)) >> 14; - t21a = ((t26 - t21 ) * 11585 + (1 << 13)) >> 14; - t26a = ((t26 + t21 ) * 11585 + (1 << 13)) >> 14; - t22 = ((t25a - t22a) * 11585 + (1 << 13)) >> 14; - t25 = ((t25a + t22a) * 11585 + (1 << 13)) >> 14; - t23a = ((t24 - t23 ) * 11585 + (1 << 13)) >> 14; - t24a = ((t24 + t23 ) * 11585 + (1 << 13)) >> 14; + t20 = (dctint)((t27a - t20a) * 11585U + (1 << 13)) >> 14; + t27 = (dctint)((t27a + t20a) * 11585U + (1 << 13)) >> 14; + t21a = (dctint)((t26 - t21 ) * 11585U + (1 << 13)) >> 14; + t26a = (dctint)((t26 + t21 ) * 11585U + (1 << 13)) >> 14; + t22 = (dctint)((t25a - t22a) * 11585U + (1 << 13)) >> 14; + t25 = (dctint)((t25a + t22a) * 11585U + (1 << 13)) >> 14; + t23a = (dctint)((t24 - t23 ) * 11585U + (1 << 13)) >> 14; + t24a = (dctint)((t24 + t23 ) * 11585U + (1 << 13)) >> 14; out[ 0] = t0 + t31; out[ 1] = t1 + t30a; |