diff -Nru ffmpeg-2.7.1~trusty~ppa1/arch.mak ffmpeg-2.7.2~trusty~ppa1/arch.mak --- ffmpeg-2.7.1~trusty~ppa1/arch.mak 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/arch.mak 2015-07-07 17:20:03.000000000 +0000 @@ -8,7 +8,7 @@ OBJS-$(HAVE_MIPSDSPR1) += $(MIPSDSPR1-OBJS) $(MIPSDSPR1-OBJS-yes) OBJS-$(HAVE_MIPSDSPR2) += $(MIPSDSPR2-OBJS) $(MIPSDSPR2-OBJS-yes) OBJS-$(HAVE_MSA) += $(MSA-OBJS) $(MSA-OBJS-yes) -OBJS-$(HAVE_LOONGSON3) += $(LOONGSON3-OBJS) $(LOONGSON3-OBJS-yes) +OBJS-$(HAVE_MMI) += $(MMI-OBJS) $(MMI-OBJS-yes) OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes) OBJS-$(HAVE_VSX) += $(VSX-OBJS) $(VSX-OBJS-yes) diff -Nru ffmpeg-2.7.1~trusty~ppa1/Changelog ffmpeg-2.7.2~trusty~ppa1/Changelog --- ffmpeg-2.7.1~trusty~ppa1/Changelog 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/Changelog 2015-08-03 17:20:02.000000000 +0000 @@ -2,27 +2,34 @@ releases are sorted from youngest to oldest. version : - -version 2.7.1: -- postproc: fix unaligned access -- avformat: clarify what package needs to be compiled with SSL support -- avcodec/libx264: Avoid reconfig on equivalent aspect ratios -- avcodec/flacenc: Fix Invalid Rice order -- tls_gnutls: fix hang on disconnection -- avcodec/hevc_ps: Only discard overread VPS if a previous is available -- ffmpeg: Free last_frame instead of just unref -- avcodec/ffv1enc: fix bps for >8bit yuv when not explicitly set -- avio: fix potential crashes when combining ffio_ensure_seekback + crc -- examples/demuxing_decoding: use properties from frame instead of video_dec_ctx -- h264: er: Copy from the previous reference only if compatible -- doc: fix spelling errors -- configure: only disable VSX for !ppc64el -- ffmpeg_opt: Check for localtime() failure -- avformat/singlejpeg: fix standalone compilation -- configure: Disable VSX on unspecified / generic CPUs -- avformat: Fix bug in parse_rps for HEVC. -- takdec: ensure chan2 is a valid channel index -- avcodec/h264_slice: Use AVFrame dimensions for grayscale handling +- colorkey video filter +- BFSTM/BCSTM demuxer +- little-endian ADPCM_THP decoder +- Hap decoder and encoder +- DirectDraw Surface image/texture decoder +- ssim filter +- rewritten ASF demuxer +- showvolume filter +- Many improvements to the JPEG 2000 decoder +- Go2Meeting decoding support +- adrawgraph audio and drawgraph video filter +- removegrain video filter +- Intel QSV-accelerated MPEG-2 video and HEVC encoding +- Intel QSV-accelerated MPEG-2 video and HEVC decoding +- Intel QSV-accelerated VC-1 video decoding +- libkvazaar HEVC encoder +- erosion, dilation, deflate and inflate video filters +- Dynamic Audio Normalizer as dynaudnorm filter +- Reverse video and areverse audio filter +- Random filter +- deband filter +- AAC fixed-point decoding +- sidechaincompress audio filter +- bitstream filter for converting HEVC from MP4 to Annex B +- acrossfade audio filter +- allyuv video source +- atadenoise video filter +- OS X VideoToolbox support version 2.7: diff -Nru ffmpeg-2.7.1~trusty~ppa1/cmdutils.c ffmpeg-2.7.2~trusty~ppa1/cmdutils.c --- ffmpeg-2.7.1~trusty~ppa1/cmdutils.c 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/cmdutils.c 2015-07-28 17:20:07.000000000 +0000 @@ -1324,12 +1324,12 @@ if (c->type == AVMEDIA_TYPE_VIDEO || c->type == AVMEDIA_TYPE_AUDIO) { printf(" Threading capabilities: "); - switch (c->capabilities & (CODEC_CAP_FRAME_THREADS | - CODEC_CAP_SLICE_THREADS)) { - case CODEC_CAP_FRAME_THREADS | - CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break; - case CODEC_CAP_FRAME_THREADS: printf("frame"); break; - case CODEC_CAP_SLICE_THREADS: printf("slice"); break; + switch (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_SLICE_THREADS)) { + case AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break; + case AV_CODEC_CAP_FRAME_THREADS: printf("frame"); break; + case AV_CODEC_CAP_SLICE_THREADS: printf("slice"); break; default: printf("no"); break; } printf("\n"); @@ -1503,11 +1503,11 @@ while ((codec = next_codec_for_id(desc->id, codec, encoder))) { printf(" %c", get_media_type_char(desc->type)); - printf((codec->capabilities & CODEC_CAP_FRAME_THREADS) ? "F" : "."); - printf((codec->capabilities & CODEC_CAP_SLICE_THREADS) ? "S" : "."); - printf((codec->capabilities & CODEC_CAP_EXPERIMENTAL) ? "X" : "."); - printf((codec->capabilities & CODEC_CAP_DRAW_HORIZ_BAND)?"B" : "."); - printf((codec->capabilities & CODEC_CAP_DR1) ? "D" : "."); + printf((codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ? "F" : "."); + printf((codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ? "S" : "."); + printf((codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) ? "X" : "."); + printf((codec->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)?"B" : "."); + printf((codec->capabilities & AV_CODEC_CAP_DR1) ? "D" : "."); printf(" %-20s %s", codec->name, codec->long_name ? codec->long_name : ""); if (strcmp(codec->name, desc->name)) @@ -1875,64 +1875,6 @@ return yesno; } -int cmdutils_read_file(const char *filename, char **bufptr, size_t *size) -{ - int64_t ret; - FILE *f = av_fopen_utf8(filename, "rb"); - - if (!f) { - ret = AVERROR(errno); - av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename, - strerror(errno)); - return ret; - } - - ret = fseek(f, 0, SEEK_END); - if (ret == -1) { - ret = AVERROR(errno); - goto out; - } - - ret = ftell(f); - if (ret < 0) { - ret = AVERROR(errno); - goto out; - } - *size = ret; - - ret = fseek(f, 0, SEEK_SET); - if (ret == -1) { - ret = AVERROR(errno); - goto out; - } - - *bufptr = av_malloc(*size + 1); - if (!*bufptr) { - av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n"); - ret = AVERROR(ENOMEM); - goto out; - } - ret = fread(*bufptr, 1, *size, f); - if (ret < *size) { - av_free(*bufptr); - if (ferror(f)) { - ret = AVERROR(errno); - av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n", - filename, strerror(errno)); - } else - ret = AVERROR_EOF; - } else { - ret = 0; - (*bufptr)[(*size)++] = '\0'; - } - -out: - if (ret < 0) - av_log(NULL, AV_LOG_ERROR, "IO error: %s\n", av_err2str(ret)); - fclose(f); - return ret; -} - FILE *get_preset_file(char *filename, size_t filename_size, const char *preset_name, int is_path, const char *codec_name) diff -Nru ffmpeg-2.7.1~trusty~ppa1/cmdutils.h ffmpeg-2.7.2~trusty~ppa1/cmdutils.h --- ffmpeg-2.7.1~trusty~ppa1/cmdutils.h 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/cmdutils.h 2015-07-19 17:20:03.000000000 +0000 @@ -530,18 +530,6 @@ int read_yesno(void); /** - * Read the file with name filename, and put its content in a newly - * allocated 0-terminated buffer. - * - * @param filename file to read from - * @param bufptr location where pointer to buffer is returned - * @param size location where size of buffer is returned - * @return >= 0 in case of success, a negative value corresponding to an - * AVERROR error code in case of failure. - */ -int cmdutils_read_file(const char *filename, char **bufptr, size_t *size); - -/** * Get a file corresponding to a preset file. * * If is_path is non-zero, look for the file in the path preset_name. diff -Nru ffmpeg-2.7.1~trusty~ppa1/common.mak ffmpeg-2.7.2~trusty~ppa1/common.mak --- ffmpeg-2.7.1~trusty~ppa1/common.mak 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/common.mak 2015-07-22 17:20:04.000000000 +0000 @@ -118,8 +118,9 @@ TOOLS := $(TOOLS:%=tools/%$(EXESUF)) HEADERS += $(HEADERS-yes) -PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME)) -DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib))) +PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(2)LIBNAME)) +DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib),$(CONFIG_SHARED:yes=S))) +STATIC_DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib))) SRC_DIR := $(SRC_PATH)/lib$(NAME) ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h)) diff -Nru ffmpeg-2.7.1~trusty~ppa1/compat/windows/mslink ffmpeg-2.7.2~trusty~ppa1/compat/windows/mslink --- ffmpeg-2.7.1~trusty~ppa1/compat/windows/mslink 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/compat/windows/mslink 2015-07-25 17:20:02.000000000 +0000 @@ -0,0 +1,9 @@ +#!/bin/sh + +LINK_EXE_PATH=$(dirname "$(command -v cl)")/link +if [ -x "$LINK_EXE_PATH" ]; then + "$LINK_EXE_PATH" $@ +else + link $@ +fi +exit $? diff -Nru ffmpeg-2.7.1~trusty~ppa1/config.log ffmpeg-2.7.2~trusty~ppa1/config.log --- ffmpeg-2.7.1~trusty~ppa1/config.log 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/config.log 2012-03-21 19:04:19.000000000 +0000 @@ -0,0 +1,4789 @@ +# ./configure --disable-everything +ACODEC_TESTS='ac3_fixed_test +adpcm_adx_test +adpcm_ima_qt_test +adpcm_ima_wav_test +adpcm_ms_test +adpcm_swf_test +adpcm_yam_test +alac_test +aref_test +flac_test +g722_test +g723_1_test +g726_test +mp2_test +pcm_alaw_test +pcm_f32be_test +pcm_f32le_test +pcm_f64be_test +pcm_f64le_test +pcm_mulaw_test +pcm_s16be_test +pcm_s16le_test +pcm_s24be_test +pcm_s24daud_test +pcm_s24le_test +pcm_s32be_test +pcm_s32le_test +pcm_s8_test +pcm_u8_test' +ALL_COMPONENTS=' + aac_adtstoasc_bsf +chomp_bsf +dump_extradata_bsf +h264_mp4toannexb_bsf +imx_dump_header_bsf +mjpeg2jpeg_bsf +mjpega_dump_header_bsf +mp3_header_compress_bsf +mp3_header_decompress_bsf +mov2textsub_bsf +noise_bsf +remove_extradata_bsf +text2movsub_bsf + aasc_decoder +amv_decoder +anm_decoder +ansi_decoder +asv1_decoder +asv2_decoder +aura_decoder +aura2_decoder +avrp_decoder +avs_decoder +ayuv_decoder +bethsoftvid_decoder +bfi_decoder +bink_decoder +bmp_decoder +bmv_video_decoder +c93_decoder +cavs_decoder +cdgraphics_decoder +cdxl_decoder +cinepak_decoder +cljr_decoder +cscd_decoder +cyuv_decoder +dfa_decoder +dirac_decoder +dnxhd_decoder +dpx_decoder +dsicinvideo_decoder +dvvideo_decoder +dxa_decoder +dxtory_decoder +eacmv_decoder +eamad_decoder +eatgq_decoder +eatgv_decoder +eatqi_decoder +eightbps_decoder +eightsvx_exp_decoder +eightsvx_fib_decoder +escape124_decoder +escape130_decoder +ffv1_decoder +ffvhuff_decoder +flashsv_decoder +flashsv2_decoder +flic_decoder +flv_decoder +fourxm_decoder +fraps_decoder +frwu_decoder +gif_decoder +h261_decoder +h263_decoder +h263i_decoder +h264_decoder +h264_crystalhd_decoder +h264_vdpau_decoder +huffyuv_decoder +idcin_decoder +iff_byterun1_decoder +iff_ilbm_decoder +indeo2_decoder +indeo3_decoder +indeo4_decoder +indeo5_decoder +interplay_video_decoder +jpeg2000_decoder +jpegls_decoder +jv_decoder +kgv1_decoder +kmvc_decoder +lagarith_decoder +loco_decoder +mdec_decoder +mimic_decoder +mjpeg_decoder +mjpegb_decoder +mmvideo_decoder +motionpixels_decoder +mpeg_xvmc_decoder +mpeg1video_decoder +mpeg2video_decoder +mpeg4_decoder +mpeg4_crystalhd_decoder +mpeg4_vdpau_decoder +mpegvideo_decoder +mpeg_vdpau_decoder +mpeg1_vdpau_decoder +mpeg2_crystalhd_decoder +msmpeg4_crystalhd_decoder +msmpeg4v1_decoder +msmpeg4v2_decoder +msmpeg4v3_decoder +msrle_decoder +msvideo1_decoder +mszh_decoder +mxpeg_decoder +nuv_decoder +pam_decoder +pbm_decoder +pcx_decoder +pgm_decoder +pgmyuv_decoder +pictor_decoder +png_decoder +ppm_decoder +prores_decoder +prores_lgpl_decoder +ptx_decoder +qdraw_decoder +qpeg_decoder +qtrle_decoder +r10k_decoder +r210_decoder +rawvideo_decoder +rl2_decoder +roq_decoder +rpza_decoder +rv10_decoder +rv20_decoder +rv30_decoder +rv40_decoder +s302m_decoder +sgi_decoder +smacker_decoder +smc_decoder +snow_decoder +sp5x_decoder +sunrast_decoder +svq1_decoder +svq3_decoder +targa_decoder +theora_decoder +thp_decoder +tiertexseqvideo_decoder +tiff_decoder +tmv_decoder +truemotion1_decoder +truemotion2_decoder +tscc_decoder +txd_decoder +ulti_decoder +utvideo_decoder +v210_decoder +v210x_decoder +v308_decoder +v408_decoder +v410_decoder +vb_decoder +vble_decoder +vc1_decoder +vc1_crystalhd_decoder +vc1_vdpau_decoder +vc1image_decoder +vcr1_decoder +vmdvideo_decoder +vmnc_decoder +vp3_decoder +vp5_decoder +vp6_decoder +vp6a_decoder +vp6f_decoder +vp8_decoder +vqa_decoder +wmv1_decoder +wmv2_decoder +wmv3_decoder +wmv3_crystalhd_decoder +wmv3_vdpau_decoder +wmv3image_decoder +wnv1_decoder +xan_wc3_decoder +xan_wc4_decoder +xl_decoder +xwd_decoder +y41p_decoder +yop_decoder +yuv4_decoder +zerocodec_decoder +zlib_decoder +zmbv_decoder +aac_decoder +aac_latm_decoder +ac3_decoder +alac_decoder +als_decoder +amrnb_decoder +amrwb_decoder +ape_decoder +atrac1_decoder +atrac3_decoder +binkaudio_dct_decoder +binkaudio_rdft_decoder +bmv_audio_decoder +cook_decoder +dca_decoder +dsicinaudio_decoder +eac3_decoder +ffwavesynth_decoder +flac_decoder +g723_1_decoder +g729_decoder +gsm_decoder +gsm_ms_decoder +imc_decoder +mace3_decoder +mace6_decoder +mlp_decoder +mp1_decoder +mp1float_decoder +mp2_decoder +mp2float_decoder +mp3_decoder +mp3float_decoder +mp3adu_decoder +mp3adufloat_decoder +mp3on4_decoder +mp3on4float_decoder +mpc7_decoder +mpc8_decoder +nellymoser_decoder +qcelp_decoder +qdm2_decoder +ra_144_decoder +ra_288_decoder +ralf_decoder +shorten_decoder +sipr_decoder +smackaud_decoder +sonic_decoder +truehd_decoder +truespeech_decoder +tta_decoder +twinvq_decoder +vmdaudio_decoder +vorbis_decoder +wavpack_decoder +wmalossless_decoder +wmapro_decoder +wmav1_decoder +wmav2_decoder +wmavoice_decoder +ws_snd1_decoder +pcm_alaw_decoder +pcm_bluray_decoder +pcm_dvd_decoder +pcm_f32be_decoder +pcm_f32le_decoder +pcm_f64be_decoder +pcm_f64le_decoder +pcm_lxf_decoder +pcm_mulaw_decoder +pcm_s8_decoder +pcm_s8_planar_decoder +pcm_s16be_decoder +pcm_s16le_decoder +pcm_s16le_planar_decoder +pcm_s24be_decoder +pcm_s24daud_decoder +pcm_s24le_decoder +pcm_s32be_decoder +pcm_s32le_decoder +pcm_u8_decoder +pcm_u16be_decoder +pcm_u16le_decoder +pcm_u24be_decoder +pcm_u24le_decoder +pcm_u32be_decoder +pcm_u32le_decoder +pcm_zork_decoder +interplay_dpcm_decoder +roq_dpcm_decoder +sol_dpcm_decoder +xan_dpcm_decoder +adpcm_4xm_decoder +adpcm_adx_decoder +adpcm_ct_decoder +adpcm_ea_decoder +adpcm_ea_maxis_xa_decoder +adpcm_ea_r1_decoder +adpcm_ea_r2_decoder +adpcm_ea_r3_decoder +adpcm_ea_xas_decoder +adpcm_g722_decoder +adpcm_g726_decoder +adpcm_ima_amv_decoder +adpcm_ima_apc_decoder +adpcm_ima_dk3_decoder +adpcm_ima_dk4_decoder +adpcm_ima_ea_eacs_decoder +adpcm_ima_ea_sead_decoder +adpcm_ima_iss_decoder +adpcm_ima_qt_decoder +adpcm_ima_smjpeg_decoder +adpcm_ima_wav_decoder +adpcm_ima_ws_decoder +adpcm_ms_decoder +adpcm_sbpro_2_decoder +adpcm_sbpro_3_decoder +adpcm_sbpro_4_decoder +adpcm_swf_decoder +adpcm_thp_decoder +adpcm_xa_decoder +adpcm_yamaha_decoder +ass_decoder +dvbsub_decoder +dvdsub_decoder +pgssub_decoder +srt_decoder +xsub_decoder +libcelt_decoder +libdirac_decoder +libgsm_decoder +libgsm_ms_decoder +libopencore_amrnb_decoder +libopencore_amrwb_decoder +libopenjpeg_decoder +libschroedinger_decoder +libspeex_decoder +libstagefright_h264_decoder +libutvideo_decoder +libvpx_decoder +bintext_decoder +xbin_decoder +idf_decoder + aac_demuxer +ac3_demuxer +act_demuxer +adf_demuxer +adx_demuxer +aea_demuxer +aiff_demuxer +amr_demuxer +anm_demuxer +apc_demuxer +ape_demuxer +asf_demuxer +ass_demuxer +au_demuxer +avi_demuxer +avisynth_demuxer +avs_demuxer +bethsoftvid_demuxer +bfi_demuxer +bintext_demuxer +bink_demuxer +bit_demuxer +bmv_demuxer +c93_demuxer +caf_demuxer +cavsvideo_demuxer +cdg_demuxer +cdxl_demuxer +daud_demuxer +dfa_demuxer +dirac_demuxer +dnxhd_demuxer +dsicin_demuxer +dts_demuxer +dv_demuxer +dxa_demuxer +ea_demuxer +ea_cdata_demuxer +eac3_demuxer +ffm_demuxer +ffmetadata_demuxer +filmstrip_demuxer +flac_demuxer +flic_demuxer +flv_demuxer +fourxm_demuxer +g722_demuxer +g723_1_demuxer +g729_demuxer +gsm_demuxer +gxf_demuxer +h261_demuxer +h263_demuxer +h264_demuxer +hls_demuxer +ico_demuxer +idcin_demuxer +idf_demuxer +iff_demuxer +image2_demuxer +image2pipe_demuxer +ingenient_demuxer +ipmovie_demuxer +iss_demuxer +iv8_demuxer +ivf_demuxer +jv_demuxer +latm_demuxer +lmlm4_demuxer +loas_demuxer +lxf_demuxer +m4v_demuxer +matroska_demuxer +microdvd_demuxer +mjpeg_demuxer +mlp_demuxer +mm_demuxer +mmf_demuxer +mov_demuxer +mp3_demuxer +mpc_demuxer +mpc8_demuxer +mpegps_demuxer +mpegts_demuxer +mpegtsraw_demuxer +mpegvideo_demuxer +msnwc_tcp_demuxer +mtv_demuxer +mvi_demuxer +mxf_demuxer +mxg_demuxer +nc_demuxer +nsv_demuxer +nut_demuxer +nuv_demuxer +ogg_demuxer +oma_demuxer +pcm_alaw_demuxer +pcm_mulaw_demuxer +pcm_f64be_demuxer +pcm_f64le_demuxer +pcm_f32be_demuxer +pcm_f32le_demuxer +pcm_s32be_demuxer +pcm_s32le_demuxer +pcm_s24be_demuxer +pcm_s24le_demuxer +pcm_s16be_demuxer +pcm_s16le_demuxer +pcm_s8_demuxer +pcm_u32be_demuxer +pcm_u32le_demuxer +pcm_u24be_demuxer +pcm_u24le_demuxer +pcm_u16be_demuxer +pcm_u16le_demuxer +pcm_u8_demuxer +pmp_demuxer +pva_demuxer +qcp_demuxer +r3d_demuxer +rawvideo_demuxer +rl2_demuxer +rm_demuxer +roq_demuxer +rpl_demuxer +rso_demuxer +rtp_demuxer +rtsp_demuxer +sap_demuxer +sbg_demuxer +sdp_demuxer +segafilm_demuxer +shorten_demuxer +siff_demuxer +smacker_demuxer +smjpeg_demuxer +sol_demuxer +sox_demuxer +spdif_demuxer +srt_demuxer +str_demuxer +swf_demuxer +thp_demuxer +tiertexseq_demuxer +tmv_demuxer +truehd_demuxer +tta_demuxer +txd_demuxer +tty_demuxer +vc1_demuxer +vc1t_demuxer +vmd_demuxer +voc_demuxer +vqf_demuxer +w64_demuxer +wav_demuxer +wc3_demuxer +wsaud_demuxer +wsvqa_demuxer +wtv_demuxer +wv_demuxer +xa_demuxer +xbin_demuxer +xmv_demuxer +xwma_demuxer +yop_demuxer +yuv4mpegpipe_demuxer +libmodplug_demuxer +libnut_demuxer + a64multi_encoder +a64multi5_encoder +amv_encoder +asv1_encoder +asv2_encoder +avrp_encoder +ayuv_encoder +bmp_encoder +cljr_encoder +dnxhd_encoder +dpx_encoder +dvvideo_encoder +ffv1_encoder +ffvhuff_encoder +flashsv_encoder +flashsv2_encoder +flv_encoder +gif_encoder +h261_encoder +h263_encoder +h263p_encoder +huffyuv_encoder +jpeg2000_encoder +jpegls_encoder +ljpeg_encoder +mjpeg_encoder +mpeg1video_encoder +mpeg2video_encoder +mpeg4_encoder +msmpeg4v2_encoder +msmpeg4v3_encoder +msvideo1_encoder +pam_encoder +pbm_encoder +pcx_encoder +pgm_encoder +pgmyuv_encoder +png_encoder +ppm_encoder +prores_encoder +prores_anatoliy_encoder +prores_kostya_encoder +qtrle_encoder +r10k_encoder +r210_encoder +rawvideo_encoder +roq_encoder +rv10_encoder +rv20_encoder +sgi_encoder +snow_encoder +sunrast_encoder +svq1_encoder +targa_encoder +tiff_encoder +v210_encoder +v308_encoder +v408_encoder +v410_encoder +wmv1_encoder +wmv2_encoder +xbm_encoder +xwd_encoder +y41p_encoder +yuv4_encoder +zlib_encoder +zmbv_encoder +aac_encoder +ac3_encoder +ac3_fixed_encoder +alac_encoder +dca_encoder +eac3_encoder +flac_encoder +g723_1_encoder +mp2_encoder +nellymoser_encoder +ra_144_encoder +sonic_encoder +sonic_ls_encoder +vorbis_encoder +wmav1_encoder +wmav2_encoder +pcm_alaw_encoder +pcm_f32be_encoder +pcm_f32le_encoder +pcm_f64be_encoder +pcm_f64le_encoder +pcm_mulaw_encoder +pcm_s8_encoder +pcm_s16be_encoder +pcm_s16le_encoder +pcm_s24be_encoder +pcm_s24daud_encoder +pcm_s24le_encoder +pcm_s32be_encoder +pcm_s32le_encoder +pcm_u8_encoder +pcm_u16be_encoder +pcm_u16le_encoder +pcm_u24be_encoder +pcm_u24le_encoder +pcm_u32be_encoder +pcm_u32le_encoder +roq_dpcm_encoder +adpcm_adx_encoder +adpcm_g722_encoder +adpcm_g726_encoder +adpcm_ima_qt_encoder +adpcm_ima_wav_encoder +adpcm_ms_encoder +adpcm_swf_encoder +adpcm_yamaha_encoder +ass_encoder +dvbsub_encoder +dvdsub_encoder +srt_encoder +xsub_encoder +libaacplus_encoder +libfaac_encoder +libgsm_encoder +libgsm_ms_encoder +libmp3lame_encoder +libopencore_amrnb_encoder +libopenjpeg_encoder +libschroedinger_encoder +libspeex_encoder +libtheora_encoder +libutvideo_encoder +libvo_aacenc_encoder +libvo_amrwbenc_encoder +libvorbis_encoder +libvpx_encoder +libx264_encoder +libx264rgb_encoder +libxavs_encoder +libxvid_encoder + aconvert_filter +aformat_filter +amerge_filter +anull_filter +aresample_filter +ashowinfo_filter +asplit_filter +astreamsync_filter +earwax_filter +pan_filter +silencedetect_filter +volume_filter +abuffer_filter +aevalsrc_filter +amovie_filter +anullsrc_filter +abuffersink_filter +anullsink_filter +ass_filter +bbox_filter +blackdetect_filter +blackframe_filter +boxblur_filter +copy_filter +crop_filter +cropdetect_filter +delogo_filter +deshake_filter +drawbox_filter +drawtext_filter +fade_filter +fieldorder_filter +fifo_filter +format_filter +frei0r_filter +gradfun_filter +hflip_filter +hqdn3d_filter +lut_filter +lutrgb_filter +lutyuv_filter +mp_filter +negate_filter +noformat_filter +null_filter +ocv_filter +overlay_filter +pad_filter +pixdesctest_filter +scale_filter +select_filter +setdar_filter +setfield_filter +setpts_filter +setsar_filter +settb_filter +showinfo_filter +slicify_filter +split_filter +swapuv_filter +thumbnail_filter +tile_filter +tinterlace_filter +transpose_filter +unsharp_filter +vflip_filter +yadif_filter +cellauto_filter +color_filter +frei0r_src_filter +life_filter +mandelbrot_filter +movie_filter +mptestsrc_filter +nullsrc_filter +rgbtestsrc_filter +testsrc_filter +buffersink_filter +nullsink_filter + h263_vaapi_hwaccel +h264_dxva2_hwaccel +h264_vaapi_hwaccel +h264_vda_hwaccel +mpeg1_vdpau_hwaccel +mpeg2_dxva2_hwaccel +mpeg2_vaapi_hwaccel +mpeg2_vdpau_hwaccel +mpeg4_vaapi_hwaccel +vc1_dxva2_hwaccel +vc1_vaapi_hwaccel +wmv3_dxva2_hwaccel +wmv3_vaapi_hwaccel + alsa_indev +bktr_indev +dshow_indev +dv1394_indev +fbdev_indev +jack_indev +lavfi_indev +openal_indev +oss_indev +pulse_indev +sndio_indev +v4l2_indev +vfwcap_indev +x11_grab_device_indev +libcdio_indev +libdc1394_indev + a64_muxer +ac3_muxer +adts_muxer +adx_muxer +aiff_muxer +amr_muxer +asf_muxer +ass_muxer +asf_stream_muxer +au_muxer +avi_muxer +avm2_muxer +bit_muxer +caf_muxer +cavsvideo_muxer +crc_muxer +daud_muxer +dirac_muxer +dnxhd_muxer +dts_muxer +dv_muxer +eac3_muxer +ffm_muxer +ffmetadata_muxer +filmstrip_muxer +flac_muxer +flv_muxer +framecrc_muxer +framemd5_muxer +g722_muxer +g723_1_muxer +gif_muxer +gxf_muxer +h261_muxer +h263_muxer +h264_muxer +image2_muxer +image2pipe_muxer +ipod_muxer +ismv_muxer +ivf_muxer +latm_muxer +m4v_muxer +md5_muxer +matroska_muxer +matroska_audio_muxer +microdvd_muxer +mjpeg_muxer +mlp_muxer +mmf_muxer +mov_muxer +mp2_muxer +mp3_muxer +mp4_muxer +mpeg1system_muxer +mpeg1vcd_muxer +mpeg1video_muxer +mpeg2dvd_muxer +mpeg2svcd_muxer +mpeg2video_muxer +mpeg2vob_muxer +mpegts_muxer +mpjpeg_muxer +mxf_muxer +mxf_d10_muxer +null_muxer +nut_muxer +ogg_muxer +oma_muxer +pcm_alaw_muxer +pcm_mulaw_muxer +pcm_f64be_muxer +pcm_f64le_muxer +pcm_f32be_muxer +pcm_f32le_muxer +pcm_s32be_muxer +pcm_s32le_muxer +pcm_s24be_muxer +pcm_s24le_muxer +pcm_s16be_muxer +pcm_s16le_muxer +pcm_s8_muxer +pcm_u32be_muxer +pcm_u32le_muxer +pcm_u24be_muxer +pcm_u24le_muxer +pcm_u16be_muxer +pcm_u16le_muxer +pcm_u8_muxer +psp_muxer +rawvideo_muxer +rm_muxer +roq_muxer +rso_muxer +rtp_muxer +rtsp_muxer +sap_muxer +segment_muxer +smjpeg_muxer +sox_muxer +spdif_muxer +srt_muxer +swf_muxer +tg2_muxer +tgp_muxer +mkvtimestamp_v2_muxer +truehd_muxer +vc1t_muxer +voc_muxer +wav_muxer +webm_muxer +wtv_muxer +yuv4mpegpipe_muxer +libnut_muxer + alsa_outdev +oss_outdev +sdl_outdev +sndio_outdev + aac_parser +aac_latm_parser +ac3_parser +adx_parser +cavsvideo_parser +dca_parser +dirac_parser +dnxhd_parser +dvbsub_parser +dvdsub_parser +flac_parser +gsm_parser +h261_parser +h263_parser +h264_parser +mjpeg_parser +mlp_parser +mpeg4video_parser +mpegaudio_parser +mpegvideo_parser +pnm_parser +rv30_parser +rv40_parser +vc1_parser +vorbis_parser +vp3_parser +vp8_parser + applehttp_protocol +bluray_protocol +cache_protocol +concat_protocol +crypto_protocol +file_protocol +gopher_protocol +hls_protocol +http_protocol +httpproxy_protocol +https_protocol +mmsh_protocol +mmst_protocol +md5_protocol +pipe_protocol +rtmp_protocol +rtp_protocol +tcp_protocol +tls_protocol +udp_protocol +librtmp_protocol +librtmpe_protocol +librtmps_protocol +librtmpt_protocol +librtmpte_protocol +' +ALL_TESTS='ac3_fixed_test +adpcm_adx_test +adpcm_ima_qt_test +adpcm_ima_wav_test +adpcm_ms_test +adpcm_swf_test +adpcm_yam_test +alac_test +aref_test +flac_test +g722_test +g723_1_test +g726_test +mp2_test +pcm_alaw_test +pcm_f32be_test +pcm_f32le_test +pcm_f64be_test +pcm_f64le_test +pcm_mulaw_test +pcm_s16be_test +pcm_s16le_test +pcm_s24be_test +pcm_s24daud_test +pcm_s24le_test +pcm_s32be_test +pcm_s32le_test +pcm_s8_test +pcm_u8_test amv_test +asv1_test +asv2_test +cljr_test +dnxhd_1080i_test +dnxhd_720p_test +dnxhd_720p_10bit_test +dnxhd_720p_rd_test +dv_test +dv50_test +dv_411_test +error_test +ffv1_test +ffvhuff_test +flashsv_test +flashsv2_test +flv_test +h261_test +h263_test +h263p_test +huffyuv_test +jpeg2000_test +jpegls_test +ljpeg_test +mjpeg_test +mpeg_test +mpeg1b_test +mpeg2_test +mpeg2_422_test +mpeg2_idct_int_test +mpeg2_ilace_test +mpeg2_ivlc_qprd_test +mpeg2thread_test +mpeg2thread_ilace_test +mpeg4_test +mpeg4_adap_test +mpeg4_qpel_test +mpeg4_qprd_test +mpeg4adv_test +mpeg4nr_test +mpeg4thread_test +mpng_test +msmpeg4_test +msmpeg4v2_test +msvideo1_test +prores_test +prores_kostya_test +qtrle_test +qtrlegray_test +r210_test +rc_test +rgb_test +roq_test +rv10_test +rv20_test +snow_test +snowll_test +svq1_test +v210_test +v308_test +vref_test +wmv1_test +wmv2_test +y41p_test +yuv_test +yuv4_test +zlib_test +zmbv_test ogg_vp3_test aiff_test +alaw_test +asf_test +au_test +avi_test +bmp_test +caf_test +dpx_test +dv_fmt_test +ffm_test +flv_fmt_test +gif_test +gxf_test +ismv_test +jpg_test +mkv_test +mmf_test +mov_test +mpg_test +mulaw_test +mxf_test +mxf_d10_test +nut_test +ogg_test +pam_test +pbmpipe_test +pcx_test +pgm_test +pgmpipe_test +pixfmt_test +png_test +ppm_test +ppmpipe_test +rm_test +rso_test +sgi_test +sox_test +sunrast_test +swf_test +tga_test +tiff_test +ts_test +voc_test +voc_s16_test +wav_test +wtv_test +xwd_test +yuv4mpeg_test crop_test +crop_scale_test +crop_scale_vflip_test +crop_vflip_test +drawbox_test +fade_test +life_test +null_test +overlay_test +pad_test +pixdesc_test +pixfmts_copy_test +pixfmts_crop_test +pixfmts_hflip_test +pixfmts_null_test +pixfmts_pad_test +pixfmts_scale_test +pixfmts_vflip_test +pp_test +pp2_test +pp3_test +pp4_test +pp5_test +pp6_test +scale200_test +scale500_test +select_test +setdar_test +setsar_test +testsrc_test +thumbnail_test +transpose_test +unsharp_test +vflip_test +vflip_crop_test +vflip_vflip_test seek_ac3_ac3_test +seek_adpcm_ima_wav_test +seek_adpcm_ms_wav_test +seek_adpcm_qt_aiff_test +seek_adpcm_swf_flv_test +seek_adpcm_yam_wav_test +seek_alac_m4a_test +seek_asv1_avi_test +seek_asv2_avi_test +seek_dnxhd_1080i_mov_test +seek_dnxhd_720p_dnxhd_test +seek_dnxhd_720p_rd_dnxhd_test +seek_dv411_dv_test +seek_dv50_dv_test +seek_dv_dv_test +seek_error_mpeg4_adv_avi_test +seek_ffv1_avi_test +seek_flac_flac_test +seek_flashsv_flv_test +seek_flv_flv_test +seek_g726_wav_test +seek_h261_avi_test +seek_h263_avi_test +seek_h263p_avi_test +seek_huffyuv_avi_test +seek_image_bmp_test +seek_image_jpg_test +seek_image_pcx_test +seek_image_pgm_test +seek_image_ppm_test +seek_image_sgi_test +seek_image_tga_test +seek_image_tiff_test +seek_jpegls_avi_test +seek_lavf_aif_test +seek_lavf_al_test +seek_lavf_asf_test +seek_lavf_au_test +seek_lavf_avi_test +seek_lavf_dv_test +seek_lavf_ffm_test +seek_lavf_flv_test +seek_lavf_gif_test +seek_lavf_gxf_test +seek_lavf_mkv_test +seek_lavf_mmf_test +seek_lavf_mov_test +seek_lavf_mpg_test +seek_lavf_mxf_test +seek_lavf_mxf_d10_test +seek_lavf_nut_test +seek_lavf_ogg_test +seek_lavf_rm_test +seek_lavf_swf_test +seek_lavf_ts_test +seek_lavf_ul_test +seek_lavf_voc_test +seek_lavf_wav_test +seek_lavf_wtv_test +seek_lavf_y4m_test +seek_ljpeg_avi_test +seek_mjpeg_avi_test +seek_mp2_mp2_test +seek_mpeg1_mpg_test +seek_mpeg1b_mpg_test +seek_mpeg2_422_mpg_test +seek_mpeg2_idct_int_mpg_test +seek_mpeg2i_mpg_test +seek_mpeg2ivlc_qprd_mpg_test +seek_mpeg2reuse_mpg_test +seek_mpeg2thread_mpg_test +seek_mpeg2threadivlc_mpg_test +seek_mpeg4_adap_avi_test +seek_mpeg4_adv_avi_test +seek_mpeg4_nr_avi_test +seek_mpeg4_qprd_avi_test +seek_mpeg4_rc_avi_test +seek_mpeg4_thread_avi_test +seek_msmpeg4_avi_test +seek_msmpeg4v2_avi_test +seek_odivx_mp4_test +seek_pbmpipe_pbm_test +seek_pcm_alaw_wav_test +seek_pcm_f32be_au_test +seek_pcm_f32le_wav_test +seek_pcm_f64be_au_test +seek_pcm_f64le_wav_test +seek_pcm_mulaw_wav_test +seek_pcm_s16be_mov_test +seek_pcm_s16le_wav_test +seek_pcm_s24be_mov_test +seek_pcm_s24daud_302_test +seek_pcm_s24le_wav_test +seek_pcm_s32be_mov_test +seek_pcm_s32le_wav_test +seek_pcm_s8_mov_test +seek_pcm_u8_wav_test +seek_pgmpipe_pgm_test +seek_ppmpipe_ppm_test +seek_rgb_avi_test +seek_roqav_roq_test +seek_rv10_rm_test +seek_rv20_rm_test +seek_snow53_avi_test +seek_snow_avi_test +seek_svq1_mov_test +seek_wmv1_avi_test +seek_wmv2_avi_test +seek_yuv_avi_test' +ALT_PP_VER=51.2.101 +ALT_PP_VER_MAJOR=51 +ALT_PP_VER_MICRO=101 +ALT_PP_VER_MINOR=2 +ARCH_EXT_LIST=' + altivec + amd3dnow + amd3dnowext + armv5te + armv6 + armv6t2 + armvfp + avx + mmi + mmx + mmx2 + neon + ppc4xx + sse + ssse3 + vfpv3 + vis +' +ARCH_LIST=' + alpha + arm + avr32 + avr32_ap + avr32_uc + bfin + ia64 + m68k + mips + mips64 + parisc + ppc + ppc64 + s390 + sh4 + sparc + sparc64 + tomi + x86 + x86_32 + x86_64 +' +AS_O='-o $@' +BASH=/bin/sh +BASH_ARGC=([0]="1") +BASH_ARGV=([0]="--disable-everything") +BASH_LINENO=([0]="0") +BASH_SOURCE=([0]="./configure") +BASH_VERSINFO=([0]="3" [1]="1" [2]="17" [3]="2" [4]="release" [5]="i486-slackware-linux-gnu") +BASH_VERSION='3.1.17(2)-release' +BSF_LIST='aac_adtstoasc_bsf +chomp_bsf +dump_extradata_bsf +h264_mp4toannexb_bsf +imx_dump_header_bsf +mjpeg2jpeg_bsf +mjpega_dump_header_bsf +mp3_header_compress_bsf +mp3_header_decompress_bsf +mov2textsub_bsf +noise_bsf +remove_extradata_bsf +text2movsub_bsf' +CC_O='-o $@' +CMDLINE_APPEND=' + extra_cflags + extra_cxxflags +' +CMDLINE_SELECT=' + + altivec + amd3dnow + amd3dnowext + armv5te + armv6 + armv6t2 + armvfp + avx + mmi + mmx + mmx2 + neon + ppc4xx + sse + ssse3 + vfpv3 + vis + + + + bsfs + decoders + demuxers + encoders + filters + hwaccels + indevs + muxers + outdevs + parsers + protocols + + + ffplay + ffprobe + ffserver + ffmpeg + + avplay + avprobe + avserver + aandct + ac3dsp + avcodec + avdevice + avfilter + avformat + avisynth + bzlib + crystalhd + dct + doc + dwt + dxva2 + fastdiv + fft + frei0r + gnutls + golomb + gpl + gray + h264chroma + h264dsp + h264pred + hardcoded_tables + huffman + libaacplus + libass + libbluray + libcdio + libcelt + libdc1394 + libdirac + libfaac + libfreetype + libgsm + libmodplug + libmp3lame + libnut + libopencore_amrnb + libopencore_amrwb + libopencv + libopenjpeg + libpulse + librtmp + libschroedinger + libspeex + libstagefright_h264 + libtheora + libutvideo + libv4l2 + libvo_aacenc + libvo_amrwbenc + libvorbis + libvpx + libx264 + libxavs + libxvid + lpc + lsp + mdct + memalign_hack + mpegaudiodsp + network + nonfree + openal + openssl + pic + postproc + rdft + rtpdec + runtime_cpudetect + safe_bitstream_reader + shared + sinewin + small + sram + static + swresample + swscale + swscale_alpha + thumb + vaapi + vda + vdpau + version3 + xmm_clobber_test + x11grab + zlib + + + pthreads + w32threads + os2threads + + asm + coverage + cross_compile + debug + extra_warnings + logging + optimizations + stripping + symver + yasm +' +CMDLINE_SET=' + + bindir + datadir + incdir + libdir + mandir + prefix + shlibdir + + ar + arch + as + build_suffix + cc + cpu + cross_prefix + cxx + dep_cc + extra_version + host_cc + host_cflags + host_ldflags + host_libs + host_os + install + ld + logfile + malloc_prefix + nm + optflags + pkg_config + postproc_version + progs_suffix + samples + strip + sysinclude + sysroot + target_exec + target_os + target_path + valgrind + yasmexe +' +COMPONENT_LIST=' + bsfs + decoders + demuxers + encoders + filters + hwaccels + indevs + muxers + outdevs + parsers + protocols +' +CONFIG_EXTRA=' + avutil + gplv3 + lgplv3 +' +CONFIG_LIST=' + + bsfs + decoders + demuxers + encoders + filters + hwaccels + indevs + muxers + outdevs + parsers + protocols + + + ffplay + ffprobe + ffserver + ffmpeg + + avplay + avprobe + avserver + aandct + ac3dsp + avcodec + avdevice + avfilter + avformat + avisynth + bzlib + crystalhd + dct + doc + dwt + dxva2 + fastdiv + fft + frei0r + gnutls + golomb + gpl + gray + h264chroma + h264dsp + h264pred + hardcoded_tables + huffman + libaacplus + libass + libbluray + libcdio + libcelt + libdc1394 + libdirac + libfaac + libfreetype + libgsm + libmodplug + libmp3lame + libnut + libopencore_amrnb + libopencore_amrwb + libopencv + libopenjpeg + libpulse + librtmp + libschroedinger + libspeex + libstagefright_h264 + libtheora + libutvideo + libv4l2 + libvo_aacenc + libvo_amrwbenc + libvorbis + libvpx + libx264 + libxavs + libxvid + lpc + lsp + mdct + memalign_hack + mpegaudiodsp + network + nonfree + openal + openssl + pic + postproc + rdft + rtpdec + runtime_cpudetect + safe_bitstream_reader + shared + sinewin + small + sram + static + swresample + swscale + swscale_alpha + thumb + vaapi + vda + vdpau + version3 + xmm_clobber_test + x11grab + zlib +' +CXX_O='-o $@' +DECODER_LIST='aasc_decoder +amv_decoder +anm_decoder +ansi_decoder +asv1_decoder +asv2_decoder +aura_decoder +aura2_decoder +avrp_decoder +avs_decoder +ayuv_decoder +bethsoftvid_decoder +bfi_decoder +bink_decoder +bmp_decoder +bmv_video_decoder +c93_decoder +cavs_decoder +cdgraphics_decoder +cdxl_decoder +cinepak_decoder +cljr_decoder +cscd_decoder +cyuv_decoder +dfa_decoder +dirac_decoder +dnxhd_decoder +dpx_decoder +dsicinvideo_decoder +dvvideo_decoder +dxa_decoder +dxtory_decoder +eacmv_decoder +eamad_decoder +eatgq_decoder +eatgv_decoder +eatqi_decoder +eightbps_decoder +eightsvx_exp_decoder +eightsvx_fib_decoder +escape124_decoder +escape130_decoder +ffv1_decoder +ffvhuff_decoder +flashsv_decoder +flashsv2_decoder +flic_decoder +flv_decoder +fourxm_decoder +fraps_decoder +frwu_decoder +gif_decoder +h261_decoder +h263_decoder +h263i_decoder +h264_decoder +h264_crystalhd_decoder +h264_vdpau_decoder +huffyuv_decoder +idcin_decoder +iff_byterun1_decoder +iff_ilbm_decoder +indeo2_decoder +indeo3_decoder +indeo4_decoder +indeo5_decoder +interplay_video_decoder +jpeg2000_decoder +jpegls_decoder +jv_decoder +kgv1_decoder +kmvc_decoder +lagarith_decoder +loco_decoder +mdec_decoder +mimic_decoder +mjpeg_decoder +mjpegb_decoder +mmvideo_decoder +motionpixels_decoder +mpeg_xvmc_decoder +mpeg1video_decoder +mpeg2video_decoder +mpeg4_decoder +mpeg4_crystalhd_decoder +mpeg4_vdpau_decoder +mpegvideo_decoder +mpeg_vdpau_decoder +mpeg1_vdpau_decoder +mpeg2_crystalhd_decoder +msmpeg4_crystalhd_decoder +msmpeg4v1_decoder +msmpeg4v2_decoder +msmpeg4v3_decoder +msrle_decoder +msvideo1_decoder +mszh_decoder +mxpeg_decoder +nuv_decoder +pam_decoder +pbm_decoder +pcx_decoder +pgm_decoder +pgmyuv_decoder +pictor_decoder +png_decoder +ppm_decoder +prores_decoder +prores_lgpl_decoder +ptx_decoder +qdraw_decoder +qpeg_decoder +qtrle_decoder +r10k_decoder +r210_decoder +rawvideo_decoder +rl2_decoder +roq_decoder +rpza_decoder +rv10_decoder +rv20_decoder +rv30_decoder +rv40_decoder +s302m_decoder +sgi_decoder +smacker_decoder +smc_decoder +snow_decoder +sp5x_decoder +sunrast_decoder +svq1_decoder +svq3_decoder +targa_decoder +theora_decoder +thp_decoder +tiertexseqvideo_decoder +tiff_decoder +tmv_decoder +truemotion1_decoder +truemotion2_decoder +tscc_decoder +txd_decoder +ulti_decoder +utvideo_decoder +v210_decoder +v210x_decoder +v308_decoder +v408_decoder +v410_decoder +vb_decoder +vble_decoder +vc1_decoder +vc1_crystalhd_decoder +vc1_vdpau_decoder +vc1image_decoder +vcr1_decoder +vmdvideo_decoder +vmnc_decoder +vp3_decoder +vp5_decoder +vp6_decoder +vp6a_decoder +vp6f_decoder +vp8_decoder +vqa_decoder +wmv1_decoder +wmv2_decoder +wmv3_decoder +wmv3_crystalhd_decoder +wmv3_vdpau_decoder +wmv3image_decoder +wnv1_decoder +xan_wc3_decoder +xan_wc4_decoder +xl_decoder +xwd_decoder +y41p_decoder +yop_decoder +yuv4_decoder +zerocodec_decoder +zlib_decoder +zmbv_decoder +aac_decoder +aac_latm_decoder +ac3_decoder +alac_decoder +als_decoder +amrnb_decoder +amrwb_decoder +ape_decoder +atrac1_decoder +atrac3_decoder +binkaudio_dct_decoder +binkaudio_rdft_decoder +bmv_audio_decoder +cook_decoder +dca_decoder +dsicinaudio_decoder +eac3_decoder +ffwavesynth_decoder +flac_decoder +g723_1_decoder +g729_decoder +gsm_decoder +gsm_ms_decoder +imc_decoder +mace3_decoder +mace6_decoder +mlp_decoder +mp1_decoder +mp1float_decoder +mp2_decoder +mp2float_decoder +mp3_decoder +mp3float_decoder +mp3adu_decoder +mp3adufloat_decoder +mp3on4_decoder +mp3on4float_decoder +mpc7_decoder +mpc8_decoder +nellymoser_decoder +qcelp_decoder +qdm2_decoder +ra_144_decoder +ra_288_decoder +ralf_decoder +shorten_decoder +sipr_decoder +smackaud_decoder +sonic_decoder +truehd_decoder +truespeech_decoder +tta_decoder +twinvq_decoder +vmdaudio_decoder +vorbis_decoder +wavpack_decoder +wmalossless_decoder +wmapro_decoder +wmav1_decoder +wmav2_decoder +wmavoice_decoder +ws_snd1_decoder +pcm_alaw_decoder +pcm_bluray_decoder +pcm_dvd_decoder +pcm_f32be_decoder +pcm_f32le_decoder +pcm_f64be_decoder +pcm_f64le_decoder +pcm_lxf_decoder +pcm_mulaw_decoder +pcm_s8_decoder +pcm_s8_planar_decoder +pcm_s16be_decoder +pcm_s16le_decoder +pcm_s16le_planar_decoder +pcm_s24be_decoder +pcm_s24daud_decoder +pcm_s24le_decoder +pcm_s32be_decoder +pcm_s32le_decoder +pcm_u8_decoder +pcm_u16be_decoder +pcm_u16le_decoder +pcm_u24be_decoder +pcm_u24le_decoder +pcm_u32be_decoder +pcm_u32le_decoder +pcm_zork_decoder +interplay_dpcm_decoder +roq_dpcm_decoder +sol_dpcm_decoder +xan_dpcm_decoder +adpcm_4xm_decoder +adpcm_adx_decoder +adpcm_ct_decoder +adpcm_ea_decoder +adpcm_ea_maxis_xa_decoder +adpcm_ea_r1_decoder +adpcm_ea_r2_decoder +adpcm_ea_r3_decoder +adpcm_ea_xas_decoder +adpcm_g722_decoder +adpcm_g726_decoder +adpcm_ima_amv_decoder +adpcm_ima_apc_decoder +adpcm_ima_dk3_decoder +adpcm_ima_dk4_decoder +adpcm_ima_ea_eacs_decoder +adpcm_ima_ea_sead_decoder +adpcm_ima_iss_decoder +adpcm_ima_qt_decoder +adpcm_ima_smjpeg_decoder +adpcm_ima_wav_decoder +adpcm_ima_ws_decoder +adpcm_ms_decoder +adpcm_sbpro_2_decoder +adpcm_sbpro_3_decoder +adpcm_sbpro_4_decoder +adpcm_swf_decoder +adpcm_thp_decoder +adpcm_xa_decoder +adpcm_yamaha_decoder +ass_decoder +dvbsub_decoder +dvdsub_decoder +pgssub_decoder +srt_decoder +xsub_decoder +libcelt_decoder +libdirac_decoder +libgsm_decoder +libgsm_ms_decoder +libopencore_amrnb_decoder +libopencore_amrwb_decoder +libopenjpeg_decoder +libschroedinger_decoder +libspeex_decoder +libstagefright_h264_decoder +libutvideo_decoder +libvpx_decoder +bintext_decoder +xbin_decoder +idf_decoder' +DEMUXER_LIST='aac_demuxer +ac3_demuxer +act_demuxer +adf_demuxer +adx_demuxer +aea_demuxer +aiff_demuxer +amr_demuxer +anm_demuxer +apc_demuxer +ape_demuxer +asf_demuxer +ass_demuxer +au_demuxer +avi_demuxer +avisynth_demuxer +avs_demuxer +bethsoftvid_demuxer +bfi_demuxer +bintext_demuxer +bink_demuxer +bit_demuxer +bmv_demuxer +c93_demuxer +caf_demuxer +cavsvideo_demuxer +cdg_demuxer +cdxl_demuxer +daud_demuxer +dfa_demuxer +dirac_demuxer +dnxhd_demuxer +dsicin_demuxer +dts_demuxer +dv_demuxer +dxa_demuxer +ea_demuxer +ea_cdata_demuxer +eac3_demuxer +ffm_demuxer +ffmetadata_demuxer +filmstrip_demuxer +flac_demuxer +flic_demuxer +flv_demuxer +fourxm_demuxer +g722_demuxer +g723_1_demuxer +g729_demuxer +gsm_demuxer +gxf_demuxer +h261_demuxer +h263_demuxer +h264_demuxer +hls_demuxer +ico_demuxer +idcin_demuxer +idf_demuxer +iff_demuxer +image2_demuxer +image2pipe_demuxer +ingenient_demuxer +ipmovie_demuxer +iss_demuxer +iv8_demuxer +ivf_demuxer +jv_demuxer +latm_demuxer +lmlm4_demuxer +loas_demuxer +lxf_demuxer +m4v_demuxer +matroska_demuxer +microdvd_demuxer +mjpeg_demuxer +mlp_demuxer +mm_demuxer +mmf_demuxer +mov_demuxer +mp3_demuxer +mpc_demuxer +mpc8_demuxer +mpegps_demuxer +mpegts_demuxer +mpegtsraw_demuxer +mpegvideo_demuxer +msnwc_tcp_demuxer +mtv_demuxer +mvi_demuxer +mxf_demuxer +mxg_demuxer +nc_demuxer +nsv_demuxer +nut_demuxer +nuv_demuxer +ogg_demuxer +oma_demuxer +pcm_alaw_demuxer +pcm_mulaw_demuxer +pcm_f64be_demuxer +pcm_f64le_demuxer +pcm_f32be_demuxer +pcm_f32le_demuxer +pcm_s32be_demuxer +pcm_s32le_demuxer +pcm_s24be_demuxer +pcm_s24le_demuxer +pcm_s16be_demuxer +pcm_s16le_demuxer +pcm_s8_demuxer +pcm_u32be_demuxer +pcm_u32le_demuxer +pcm_u24be_demuxer +pcm_u24le_demuxer +pcm_u16be_demuxer +pcm_u16le_demuxer +pcm_u8_demuxer +pmp_demuxer +pva_demuxer +qcp_demuxer +r3d_demuxer +rawvideo_demuxer +rl2_demuxer +rm_demuxer +roq_demuxer +rpl_demuxer +rso_demuxer +rtp_demuxer +rtsp_demuxer +sap_demuxer +sbg_demuxer +sdp_demuxer +segafilm_demuxer +shorten_demuxer +siff_demuxer +smacker_demuxer +smjpeg_demuxer +sol_demuxer +sox_demuxer +spdif_demuxer +srt_demuxer +str_demuxer +swf_demuxer +thp_demuxer +tiertexseq_demuxer +tmv_demuxer +truehd_demuxer +tta_demuxer +txd_demuxer +tty_demuxer +vc1_demuxer +vc1t_demuxer +vmd_demuxer +voc_demuxer +vqf_demuxer +w64_demuxer +wav_demuxer +wc3_demuxer +wsaud_demuxer +wsvqa_demuxer +wtv_demuxer +wv_demuxer +xa_demuxer +xbin_demuxer +xmv_demuxer +xwma_demuxer +yop_demuxer +yuv4mpegpipe_demuxer +libmodplug_demuxer +libnut_demuxer' +DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)' +DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM' +DIRSTACK=() +E1=0 +E2=1 +ENCODER_LIST='a64multi_encoder +a64multi5_encoder +amv_encoder +asv1_encoder +asv2_encoder +avrp_encoder +ayuv_encoder +bmp_encoder +cljr_encoder +dnxhd_encoder +dpx_encoder +dvvideo_encoder +ffv1_encoder +ffvhuff_encoder +flashsv_encoder +flashsv2_encoder +flv_encoder +gif_encoder +h261_encoder +h263_encoder +h263p_encoder +huffyuv_encoder +jpeg2000_encoder +jpegls_encoder +ljpeg_encoder +mjpeg_encoder +mpeg1video_encoder +mpeg2video_encoder +mpeg4_encoder +msmpeg4v2_encoder +msmpeg4v3_encoder +msvideo1_encoder +pam_encoder +pbm_encoder +pcx_encoder +pgm_encoder +pgmyuv_encoder +png_encoder +ppm_encoder +prores_encoder +prores_anatoliy_encoder +prores_kostya_encoder +qtrle_encoder +r10k_encoder +r210_encoder +rawvideo_encoder +roq_encoder +rv10_encoder +rv20_encoder +sgi_encoder +snow_encoder +sunrast_encoder +svq1_encoder +targa_encoder +tiff_encoder +v210_encoder +v308_encoder +v408_encoder +v410_encoder +wmv1_encoder +wmv2_encoder +xbm_encoder +xwd_encoder +y41p_encoder +yuv4_encoder +zlib_encoder +zmbv_encoder +aac_encoder +ac3_encoder +ac3_fixed_encoder +alac_encoder +dca_encoder +eac3_encoder +flac_encoder +g723_1_encoder +mp2_encoder +nellymoser_encoder +ra_144_encoder +sonic_encoder +sonic_ls_encoder +vorbis_encoder +wmav1_encoder +wmav2_encoder +pcm_alaw_encoder +pcm_f32be_encoder +pcm_f32le_encoder +pcm_f64be_encoder +pcm_f64le_encoder +pcm_mulaw_encoder +pcm_s8_encoder +pcm_s16be_encoder +pcm_s16le_encoder +pcm_s24be_encoder +pcm_s24daud_encoder +pcm_s24le_encoder +pcm_s32be_encoder +pcm_s32le_encoder +pcm_u8_encoder +pcm_u16be_encoder +pcm_u16le_encoder +pcm_u24be_encoder +pcm_u24le_encoder +pcm_u32be_encoder +pcm_u32le_encoder +roq_dpcm_encoder +adpcm_adx_encoder +adpcm_g722_encoder +adpcm_g726_encoder +adpcm_ima_qt_encoder +adpcm_ima_wav_encoder +adpcm_ms_encoder +adpcm_swf_encoder +adpcm_yamaha_encoder +ass_encoder +dvbsub_encoder +dvdsub_encoder +srt_encoder +xsub_encoder +libaacplus_encoder +libfaac_encoder +libgsm_encoder +libgsm_ms_encoder +libmp3lame_encoder +libopencore_amrnb_encoder +libopenjpeg_encoder +libschroedinger_encoder +libspeex_encoder +libtheora_encoder +libutvideo_encoder +libvo_aacenc_encoder +libvo_amrwbenc_encoder +libvorbis_encoder +libvpx_encoder +libx264_encoder +libx264rgb_encoder +libxavs_encoder +libxvid_encoder' +EUID=1004 +FFMPEG_CONFIGURATION=' --disable-everything' +FFSERVERLDFLAGS=-Wl,-E +FILTER_LIST='aconvert_filter +aformat_filter +amerge_filter +anull_filter +aresample_filter +ashowinfo_filter +asplit_filter +astreamsync_filter +earwax_filter +pan_filter +silencedetect_filter +volume_filter +abuffer_filter +aevalsrc_filter +amovie_filter +anullsrc_filter +abuffersink_filter +anullsink_filter +ass_filter +bbox_filter +blackdetect_filter +blackframe_filter +boxblur_filter +copy_filter +crop_filter +cropdetect_filter +delogo_filter +deshake_filter +drawbox_filter +drawtext_filter +fade_filter +fieldorder_filter +fifo_filter +format_filter +frei0r_filter +gradfun_filter +hflip_filter +hqdn3d_filter +lut_filter +lutrgb_filter +lutyuv_filter +mp_filter +negate_filter +noformat_filter +null_filter +ocv_filter +overlay_filter +pad_filter +pixdesctest_filter +scale_filter +select_filter +setdar_filter +setfield_filter +setpts_filter +setsar_filter +settb_filter +showinfo_filter +slicify_filter +split_filter +swapuv_filter +thumbnail_filter +tile_filter +tinterlace_filter +transpose_filter +unsharp_filter +vflip_filter +yadif_filter +cellauto_filter +color_filter +frei0r_src_filter +life_filter +mandelbrot_filter +movie_filter +mptestsrc_filter +nullsrc_filter +rgbtestsrc_filter +testsrc_filter +buffersink_filter +nullsink_filter' +FULLNAME='$(NAME)$(BUILDSUF)' +GROUPS=() +HAVE_LIST=' + + altivec + amd3dnow + amd3dnowext + armv5te + armv6 + armv6t2 + armvfp + avx + mmi + mmx + mmx2 + neon + ppc4xx + sse + ssse3 + vfpv3 + vis + + + bigendian + fast_unaligned + + + pthreads + w32threads + os2threads + + aligned_stack + alsa_asoundlib_h + altivec_h + arpa_inet_h + asm_mod_y + asm_types_h + attribute_may_alias + attribute_packed + cbrtf + closesocket + cmov + dcbzl + dev_bktr_ioctl_bt848_h + dev_bktr_ioctl_meteor_h + dev_ic_bt8xx_h + dev_video_bktr_ioctl_bt848_h + dev_video_meteor_ioctl_meteor_h + dlfcn_h + dlopen + dos_paths + ebp_available + ebx_available + exp2 + exp2f + fast_64bit + fast_clz + fast_cmov + fcntl + fork + getaddrinfo + gethrtime + GetProcessAffinityMask + GetProcessMemoryInfo + GetProcessTimes + getrusage + gnu_as + ibm_asm + inet_aton + inline_asm + isatty + kbhit + ldbrx + libdc1394_1 + libdc1394_2 + llrint + llrintf + local_aligned_16 + local_aligned_8 + localtime_r + log2 + log2f + loongson + lrint + lrintf + lzo1x_999_compress + machine_ioctl_bt848_h + machine_ioctl_meteor_h + makeinfo + malloc_h + MapViewOfFile + memalign + mkstemp + mmap + PeekNamedPipe + poll_h + posix_memalign + round + roundf + sched_getaffinity + sdl + sdl_video_size + setmode + setrlimit + sndio_h + socklen_t + soundcard_h + strerror_r + strptime + struct_addrinfo + struct_ipv6_mreq + struct_rusage_ru_maxrss + struct_sockaddr_in6 + struct_sockaddr_sa_len + struct_sockaddr_storage + struct_v4l2_frmivalenum_discrete + symver + symver_asm_label + symver_gnu_asm + sysconf + sysctl + sys_mman_h + sys_param_h + sys_resource_h + sys_select_h + sys_soundcard_h + sys_videoio_h + termios_h + threads + trunc + truncf + vfp_args + VirtualAlloc + winsock2_h + xform_asm + xmm_clobbers + yasm +' +HAVE_LIST_PUB=' + bigendian + fast_unaligned +' +HOME=/home/ffcron +HOSTNAME=avserver.banki.hu +HOSTTYPE=i486 +HWACCEL_LIST='h263_vaapi_hwaccel +h264_dxva2_hwaccel +h264_vaapi_hwaccel +h264_vda_hwaccel +mpeg1_vdpau_hwaccel +mpeg2_dxva2_hwaccel +mpeg2_vaapi_hwaccel +mpeg2_vdpau_hwaccel +mpeg4_vaapi_hwaccel +vc1_dxva2_hwaccel +vc1_vaapi_hwaccel +wmv3_dxva2_hwaccel +wmv3_vaapi_hwaccel' +IFS=' +' +INDEV_LIST='alsa_indev +bktr_indev +dshow_indev +dv1394_indev +fbdev_indev +jack_indev +lavfi_indev +openal_indev +oss_indev +pulse_indev +sndio_indev +v4l2_indev +vfwcap_indev +x11_grab_device_indev +libcdio_indev +libdc1394_indev' +LANG=en_US +LAVFI_TESTS='crop_test +crop_scale_test +crop_scale_vflip_test +crop_vflip_test +drawbox_test +fade_test +life_test +null_test +overlay_test +pad_test +pixdesc_test +pixfmts_copy_test +pixfmts_crop_test +pixfmts_hflip_test +pixfmts_null_test +pixfmts_pad_test +pixfmts_scale_test +pixfmts_vflip_test +pp_test +pp2_test +pp3_test +pp4_test +pp5_test +pp6_test +scale200_test +scale500_test +select_test +setdar_test +setsar_test +testsrc_test +thumbnail_test +transpose_test +unsharp_test +vflip_test +vflip_crop_test +vflip_vflip_test' +LAVF_FATE_TESTS=ogg_vp3_test +LAVF_TESTS='aiff_test +alaw_test +asf_test +au_test +avi_test +bmp_test +caf_test +dpx_test +dv_fmt_test +ffm_test +flv_fmt_test +gif_test +gxf_test +ismv_test +jpg_test +mkv_test +mmf_test +mov_test +mpg_test +mulaw_test +mxf_test +mxf_d10_test +nut_test +ogg_test +pam_test +pbmpipe_test +pcx_test +pgm_test +pgmpipe_test +pixfmt_test +png_test +ppm_test +ppmpipe_test +rm_test +rso_test +sgi_test +sox_test +sunrast_test +swf_test +tga_test +tiff_test +ts_test +voc_test +voc_s16_test +wav_test +wtv_test +xwd_test +yuv4mpeg_test' +LC_ALL=C +LC_COLLATE=C +LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)' +LIBPREF=lib +LIBSUF=.a +LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"' +LOGNAME=root +LS_COLORS= +MACHTYPE=i486-slackware-linux-gnu +MUXER_LIST='a64_muxer +ac3_muxer +adts_muxer +adx_muxer +aiff_muxer +amr_muxer +asf_muxer +ass_muxer +asf_stream_muxer +au_muxer +avi_muxer +avm2_muxer +bit_muxer +caf_muxer +cavsvideo_muxer +crc_muxer +daud_muxer +dirac_muxer +dnxhd_muxer +dts_muxer +dv_muxer +eac3_muxer +ffm_muxer +ffmetadata_muxer +filmstrip_muxer +flac_muxer +flv_muxer +framecrc_muxer +framemd5_muxer +g722_muxer +g723_1_muxer +gif_muxer +gxf_muxer +h261_muxer +h263_muxer +h264_muxer +image2_muxer +image2pipe_muxer +ipod_muxer +ismv_muxer +ivf_muxer +latm_muxer +m4v_muxer +md5_muxer +matroska_muxer +matroska_audio_muxer +microdvd_muxer +mjpeg_muxer +mlp_muxer +mmf_muxer +mov_muxer +mp2_muxer +mp3_muxer +mp4_muxer +mpeg1system_muxer +mpeg1vcd_muxer +mpeg1video_muxer +mpeg2dvd_muxer +mpeg2svcd_muxer +mpeg2video_muxer +mpeg2vob_muxer +mpegts_muxer +mpjpeg_muxer +mxf_muxer +mxf_d10_muxer +null_muxer +nut_muxer +ogg_muxer +oma_muxer +pcm_alaw_muxer +pcm_mulaw_muxer +pcm_f64be_muxer +pcm_f64le_muxer +pcm_f32be_muxer +pcm_f32le_muxer +pcm_s32be_muxer +pcm_s32le_muxer +pcm_s24be_muxer +pcm_s24le_muxer +pcm_s16be_muxer +pcm_s16le_muxer +pcm_s8_muxer +pcm_u32be_muxer +pcm_u32le_muxer +pcm_u24be_muxer +pcm_u24le_muxer +pcm_u16be_muxer +pcm_u16le_muxer +pcm_u8_muxer +psp_muxer +rawvideo_muxer +rm_muxer +roq_muxer +rso_muxer +rtp_muxer +rtsp_muxer +sap_muxer +segment_muxer +smjpeg_muxer +sox_muxer +spdif_muxer +srt_muxer +swf_muxer +tg2_muxer +tgp_muxer +mkvtimestamp_v2_muxer +truehd_muxer +vc1t_muxer +voc_muxer +wav_muxer +webm_muxer +wtv_muxer +yuv4mpegpipe_muxer +libnut_muxer' +OPTERR=1 +OPTIND=1 +OSTYPE=linux-gnu +OUTDEV_LIST='alsa_outdev +oss_outdev +sdl_outdev +sndio_outdev' +PARSER_LIST='aac_parser +aac_latm_parser +ac3_parser +adx_parser +cavsvideo_parser +dca_parser +dirac_parser +dnxhd_parser +dvbsub_parser +dvdsub_parser +flac_parser +gsm_parser +h261_parser +h263_parser +h264_parser +mjpeg_parser +mlp_parser +mpeg4video_parser +mpegaudio_parser +mpegvideo_parser +pnm_parser +rv30_parser +rv40_parser +vc1_parser +vorbis_parser +vp3_parser +vp8_parser' +PATH=/usr/local/bin:/bin:/usr/bin +PATHS_LIST=' + bindir + datadir + incdir + libdir + mandir + prefix + shlibdir +' +PIPESTATUS=([0]="0") +POSIXLY_CORRECT=y +PPID=24387 +PROGRAM_LIST=' + ffplay + ffprobe + ffserver + ffmpeg +' +PROTOCOL_LIST='applehttp_protocol +bluray_protocol +cache_protocol +concat_protocol +crypto_protocol +file_protocol +gopher_protocol +hls_protocol +http_protocol +httpproxy_protocol +https_protocol +mmsh_protocol +mmst_protocol +md5_protocol +pipe_protocol +rtmp_protocol +rtp_protocol +tcp_protocol +tls_protocol +udp_protocol +librtmp_protocol +librtmpe_protocol +librtmps_protocol +librtmpt_protocol +librtmpte_protocol' +PS4='+ ' +PWD=/home/ffcron/ffgit4cron/ffmpeg +SEEK_TESTS='seek_ac3_ac3_test +seek_adpcm_ima_wav_test +seek_adpcm_ms_wav_test +seek_adpcm_qt_aiff_test +seek_adpcm_swf_flv_test +seek_adpcm_yam_wav_test +seek_alac_m4a_test +seek_asv1_avi_test +seek_asv2_avi_test +seek_dnxhd_1080i_mov_test +seek_dnxhd_720p_dnxhd_test +seek_dnxhd_720p_rd_dnxhd_test +seek_dv411_dv_test +seek_dv50_dv_test +seek_dv_dv_test +seek_error_mpeg4_adv_avi_test +seek_ffv1_avi_test +seek_flac_flac_test +seek_flashsv_flv_test +seek_flv_flv_test +seek_g726_wav_test +seek_h261_avi_test +seek_h263_avi_test +seek_h263p_avi_test +seek_huffyuv_avi_test +seek_image_bmp_test +seek_image_jpg_test +seek_image_pcx_test +seek_image_pgm_test +seek_image_ppm_test +seek_image_sgi_test +seek_image_tga_test +seek_image_tiff_test +seek_jpegls_avi_test +seek_lavf_aif_test +seek_lavf_al_test +seek_lavf_asf_test +seek_lavf_au_test +seek_lavf_avi_test +seek_lavf_dv_test +seek_lavf_ffm_test +seek_lavf_flv_test +seek_lavf_gif_test +seek_lavf_gxf_test +seek_lavf_mkv_test +seek_lavf_mmf_test +seek_lavf_mov_test +seek_lavf_mpg_test +seek_lavf_mxf_test +seek_lavf_mxf_d10_test +seek_lavf_nut_test +seek_lavf_ogg_test +seek_lavf_rm_test +seek_lavf_swf_test +seek_lavf_ts_test +seek_lavf_ul_test +seek_lavf_voc_test +seek_lavf_wav_test +seek_lavf_wtv_test +seek_lavf_y4m_test +seek_ljpeg_avi_test +seek_mjpeg_avi_test +seek_mp2_mp2_test +seek_mpeg1_mpg_test +seek_mpeg1b_mpg_test +seek_mpeg2_422_mpg_test +seek_mpeg2_idct_int_mpg_test +seek_mpeg2i_mpg_test +seek_mpeg2ivlc_qprd_mpg_test +seek_mpeg2reuse_mpg_test +seek_mpeg2thread_mpg_test +seek_mpeg2threadivlc_mpg_test +seek_mpeg4_adap_avi_test +seek_mpeg4_adv_avi_test +seek_mpeg4_nr_avi_test +seek_mpeg4_qprd_avi_test +seek_mpeg4_rc_avi_test +seek_mpeg4_thread_avi_test +seek_msmpeg4_avi_test +seek_msmpeg4v2_avi_test +seek_odivx_mp4_test +seek_pbmpipe_pbm_test +seek_pcm_alaw_wav_test +seek_pcm_f32be_au_test +seek_pcm_f32le_wav_test +seek_pcm_f64be_au_test +seek_pcm_f64le_wav_test +seek_pcm_mulaw_wav_test +seek_pcm_s16be_mov_test +seek_pcm_s16le_wav_test +seek_pcm_s24be_mov_test +seek_pcm_s24daud_302_test +seek_pcm_s24le_wav_test +seek_pcm_s32be_mov_test +seek_pcm_s32le_wav_test +seek_pcm_s8_mov_test +seek_pcm_u8_wav_test +seek_pgmpipe_pgm_test +seek_ppmpipe_ppm_test +seek_rgb_avi_test +seek_roqav_roq_test +seek_rv10_rm_test +seek_rv20_rm_test +seek_snow53_avi_test +seek_snow_avi_test +seek_svq1_mov_test +seek_wmv1_avi_test +seek_wmv2_avi_test +seek_yuv_avi_test' +SHELL=/bin/bash +SHELLOPTS=braceexpand:hashall:interactive-comments:posix +SHFLAGS='-shared -Wl,-soname,$$(@F)' +SHLVL=4 +SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)' +SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)' +SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)' +SLIBPREF=lib +SLIBSUF=.so +SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)' +SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)' +SUDO_COMMAND=/bin/su +SUDO_GID=100 +SUDO_UID=1001 +SUDO_USER=michael +TERM=rxvt-unicode +THREADS_LIST=' + pthreads + w32threads + os2threads +' +UID=1004 +USER=root +USERNAME=root +VCODEC_TESTS='amv_test +asv1_test +asv2_test +cljr_test +dnxhd_1080i_test +dnxhd_720p_test +dnxhd_720p_10bit_test +dnxhd_720p_rd_test +dv_test +dv50_test +dv_411_test +error_test +ffv1_test +ffvhuff_test +flashsv_test +flashsv2_test +flv_test +h261_test +h263_test +h263p_test +huffyuv_test +jpeg2000_test +jpegls_test +ljpeg_test +mjpeg_test +mpeg_test +mpeg1b_test +mpeg2_test +mpeg2_422_test +mpeg2_idct_int_test +mpeg2_ilace_test +mpeg2_ivlc_qprd_test +mpeg2thread_test +mpeg2thread_ilace_test +mpeg4_test +mpeg4_adap_test +mpeg4_qpel_test +mpeg4_qprd_test +mpeg4adv_test +mpeg4nr_test +mpeg4thread_test +mpng_test +msmpeg4_test +msmpeg4v2_test +msvideo1_test +prores_test +prores_kostya_test +qtrle_test +qtrlegray_test +r210_test +rc_test +rgb_test +roq_test +rv10_test +rv20_test +snow_test +snowll_test +svq1_test +v210_test +v308_test +vref_test +wmv1_test +wmv2_test +y41p_test +yuv_test +yuv4_test +zlib_test +zmbv_test' +_='# ./configure --disable-everything' +aac_decoder_select='mdct sinewin' +aac_encoder_select='mdct sinewin' +aac_latm_decoder_select='aac_decoder aac_latm_parser' +ac3_decoder_select='mdct ac3dsp ac3_parser' +ac3_demuxer_select=ac3_parser +ac3_encoder_select='mdct ac3dsp' +ac3_fixed_encoder_select='mdct ac3dsp' +ac3_fixed_test=yes +ac3_fixed_test_deps='ac3_fixed_encoder ac3_decoder' +aconvert_filter_deps=swresample +adpcm_adx_test=yes +adpcm_ima_qt_test=yes +adpcm_ima_qt_test_deps=' adpcm_ima_qt_encoder adpcm_ima_qt_decoder' +adpcm_ima_wav_test=yes +adpcm_ima_wav_test_deps=' adpcm_ima_wav_encoder adpcm_ima_wav_decoder' +adpcm_ms_test=yes +adpcm_ms_test_deps=' adpcm_ms_encoder adpcm_ms_decoder' +adpcm_swf_test=yes +adpcm_swf_test_deps=' adpcm_swf_encoder adpcm_swf_decoder' +adpcm_yam_test=yes +adpcm_yam_test_deps=' adpcm_yamaha_encoder adpcm_yamaha_decoder' +aiff_test=yes +aiff_test_deps=' aiff_muxer aiff_demuxer' +alac_encoder_select=lpc +alac_test=yes +alac_test_deps=' alac_encoder alac_decoder' +alaw_test=yes +alaw_test_deps=' pcm_alaw_muxer pcm_alaw_demuxer' +aligned_stack_if_any='ppc x86' +alsa_indev_deps='alsa_asoundlib_h snd_pcm_htimestamp' +alsa_outdev_deps=alsa_asoundlib_h +altivec=yes +altivec_deps=ppc +amd3dnow=yes +amd3dnow_deps=mmx +amd3dnowext=yes +amd3dnowext_deps=amd3dnow +amovie_filter_deps='avcodec avformat' +amrnb_decoder_select=lsp +amrwb_decoder_select=lsp +amv_test=yes +ar_default=ar +arch_default=i686 +aref_test=yes +aresample_filter_deps=swresample +armv5te=yes +armv5te_deps=arm +armv6=yes +armv6_deps=arm +armv6t2=yes +armv6t2_deps=arm +armvfp=yes +armvfp_deps=arm +asf_stream_muxer_select=asf_muxer +asf_test=yes +asf_test_deps=' asf_muxer asf_demuxer' +asm=yes +ass_filter_deps=libass +asv1_test=yes +asv1_test_deps=' asv1_encoder asv1_decoder' +asv2_test=yes +asv2_test_deps=' asv2_encoder asv2_decoder' +atrac1_decoder_select='mdct sinewin' +atrac3_decoder_select=mdct +au_test=yes +au_test_deps=' au_muxer au_demuxer' +avcodec=yes +avdevice=yes +avdevice_deps='avcodec avformat' +avfilter=yes +avformat=yes +avformat_deps=avcodec +avi_test=yes +avi_test_deps=' avi_muxer avi_demuxer' +avisynth_demuxer_deps=avisynth +avutil=yes +avx=yes +avx_deps=ssse3 +bindir_default='${prefix}/bin' +binkaudio_dct_decoder_select='mdct rdft dct sinewin' +binkaudio_rdft_decoder_select='mdct rdft sinewin' +bktr_indev_deps_any='dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h' +blackframe_filter_deps=gpl +bluray_protocol_deps=libbluray +bmp_test=yes +bmp_test_deps=' bmp_encoder bmp_decoder' +boxblur_filter_deps=gpl +bsfs_if_any='aac_adtstoasc_bsf +chomp_bsf +dump_extradata_bsf +h264_mp4toannexb_bsf +imx_dump_header_bsf +mjpeg2jpeg_bsf +mjpega_dump_header_bsf +mp3_header_compress_bsf +mp3_header_decompress_bsf +mov2textsub_bsf +noise_bsf +remove_extradata_bsf +text2movsub_bsf' +caf_test=yes +cavs_decoder_select=golomb +cc_default=gcc +cc_version='"unknown"' +cljr_test=yes +cook_decoder_select='mdct sinewin' +cpu=generic +crop_scale_test=yes +crop_scale_vflip_test=yes +crop_test=yes +crop_vflip_test=yes +cropdetect_filter_deps=gpl +crystalhd_deps=libcrystalhd_libcrystalhd_if_h +cscd_decoder_suggest=zlib +cxx_default=g++ +datadir_default='${prefix}/share/ffmpeg' +dca_decoder_select=mdct +dct_select=rdft +debug=yes +decoders_if_any='aasc_decoder +amv_decoder +anm_decoder +ansi_decoder +asv1_decoder +asv2_decoder +aura_decoder +aura2_decoder +avrp_decoder +avs_decoder +ayuv_decoder +bethsoftvid_decoder +bfi_decoder +bink_decoder +bmp_decoder +bmv_video_decoder +c93_decoder +cavs_decoder +cdgraphics_decoder +cdxl_decoder +cinepak_decoder +cljr_decoder +cscd_decoder +cyuv_decoder +dfa_decoder +dirac_decoder +dnxhd_decoder +dpx_decoder +dsicinvideo_decoder +dvvideo_decoder +dxa_decoder +dxtory_decoder +eacmv_decoder +eamad_decoder +eatgq_decoder +eatgv_decoder +eatqi_decoder +eightbps_decoder +eightsvx_exp_decoder +eightsvx_fib_decoder +escape124_decoder +escape130_decoder +ffv1_decoder +ffvhuff_decoder +flashsv_decoder +flashsv2_decoder +flic_decoder +flv_decoder +fourxm_decoder +fraps_decoder +frwu_decoder +gif_decoder +h261_decoder +h263_decoder +h263i_decoder +h264_decoder +h264_crystalhd_decoder +h264_vdpau_decoder +huffyuv_decoder +idcin_decoder +iff_byterun1_decoder +iff_ilbm_decoder +indeo2_decoder +indeo3_decoder +indeo4_decoder +indeo5_decoder +interplay_video_decoder +jpeg2000_decoder +jpegls_decoder +jv_decoder +kgv1_decoder +kmvc_decoder +lagarith_decoder +loco_decoder +mdec_decoder +mimic_decoder +mjpeg_decoder +mjpegb_decoder +mmvideo_decoder +motionpixels_decoder +mpeg_xvmc_decoder +mpeg1video_decoder +mpeg2video_decoder +mpeg4_decoder +mpeg4_crystalhd_decoder +mpeg4_vdpau_decoder +mpegvideo_decoder +mpeg_vdpau_decoder +mpeg1_vdpau_decoder +mpeg2_crystalhd_decoder +msmpeg4_crystalhd_decoder +msmpeg4v1_decoder +msmpeg4v2_decoder +msmpeg4v3_decoder +msrle_decoder +msvideo1_decoder +mszh_decoder +mxpeg_decoder +nuv_decoder +pam_decoder +pbm_decoder +pcx_decoder +pgm_decoder +pgmyuv_decoder +pictor_decoder +png_decoder +ppm_decoder +prores_decoder +prores_lgpl_decoder +ptx_decoder +qdraw_decoder +qpeg_decoder +qtrle_decoder +r10k_decoder +r210_decoder +rawvideo_decoder +rl2_decoder +roq_decoder +rpza_decoder +rv10_decoder +rv20_decoder +rv30_decoder +rv40_decoder +s302m_decoder +sgi_decoder +smacker_decoder +smc_decoder +snow_decoder +sp5x_decoder +sunrast_decoder +svq1_decoder +svq3_decoder +targa_decoder +theora_decoder +thp_decoder +tiertexseqvideo_decoder +tiff_decoder +tmv_decoder +truemotion1_decoder +truemotion2_decoder +tscc_decoder +txd_decoder +ulti_decoder +utvideo_decoder +v210_decoder +v210x_decoder +v308_decoder +v408_decoder +v410_decoder +vb_decoder +vble_decoder +vc1_decoder +vc1_crystalhd_decoder +vc1_vdpau_decoder +vc1image_decoder +vcr1_decoder +vmdvideo_decoder +vmnc_decoder +vp3_decoder +vp5_decoder +vp6_decoder +vp6a_decoder +vp6f_decoder +vp8_decoder +vqa_decoder +wmv1_decoder +wmv2_decoder +wmv3_decoder +wmv3_crystalhd_decoder +wmv3_vdpau_decoder +wmv3image_decoder +wnv1_decoder +xan_wc3_decoder +xan_wc4_decoder +xl_decoder +xwd_decoder +y41p_decoder +yop_decoder +yuv4_decoder +zerocodec_decoder +zlib_decoder +zmbv_decoder +aac_decoder +aac_latm_decoder +ac3_decoder +alac_decoder +als_decoder +amrnb_decoder +amrwb_decoder +ape_decoder +atrac1_decoder +atrac3_decoder +binkaudio_dct_decoder +binkaudio_rdft_decoder +bmv_audio_decoder +cook_decoder +dca_decoder +dsicinaudio_decoder +eac3_decoder +ffwavesynth_decoder +flac_decoder +g723_1_decoder +g729_decoder +gsm_decoder +gsm_ms_decoder +imc_decoder +mace3_decoder +mace6_decoder +mlp_decoder +mp1_decoder +mp1float_decoder +mp2_decoder +mp2float_decoder +mp3_decoder +mp3float_decoder +mp3adu_decoder +mp3adufloat_decoder +mp3on4_decoder +mp3on4float_decoder +mpc7_decoder +mpc8_decoder +nellymoser_decoder +qcelp_decoder +qdm2_decoder +ra_144_decoder +ra_288_decoder +ralf_decoder +shorten_decoder +sipr_decoder +smackaud_decoder +sonic_decoder +truehd_decoder +truespeech_decoder +tta_decoder +twinvq_decoder +vmdaudio_decoder +vorbis_decoder +wavpack_decoder +wmalossless_decoder +wmapro_decoder +wmav1_decoder +wmav2_decoder +wmavoice_decoder +ws_snd1_decoder +pcm_alaw_decoder +pcm_bluray_decoder +pcm_dvd_decoder +pcm_f32be_decoder +pcm_f32le_decoder +pcm_f64be_decoder +pcm_f64le_decoder +pcm_lxf_decoder +pcm_mulaw_decoder +pcm_s8_decoder +pcm_s8_planar_decoder +pcm_s16be_decoder +pcm_s16le_decoder +pcm_s16le_planar_decoder +pcm_s24be_decoder +pcm_s24daud_decoder +pcm_s24le_decoder +pcm_s32be_decoder +pcm_s32le_decoder +pcm_u8_decoder +pcm_u16be_decoder +pcm_u16le_decoder +pcm_u24be_decoder +pcm_u24le_decoder +pcm_u32be_decoder +pcm_u32le_decoder +pcm_zork_decoder +interplay_dpcm_decoder +roq_dpcm_decoder +sol_dpcm_decoder +xan_dpcm_decoder +adpcm_4xm_decoder +adpcm_adx_decoder +adpcm_ct_decoder +adpcm_ea_decoder +adpcm_ea_maxis_xa_decoder +adpcm_ea_r1_decoder +adpcm_ea_r2_decoder +adpcm_ea_r3_decoder +adpcm_ea_xas_decoder +adpcm_g722_decoder +adpcm_g726_decoder +adpcm_ima_amv_decoder +adpcm_ima_apc_decoder +adpcm_ima_dk3_decoder +adpcm_ima_dk4_decoder +adpcm_ima_ea_eacs_decoder +adpcm_ima_ea_sead_decoder +adpcm_ima_iss_decoder +adpcm_ima_qt_decoder +adpcm_ima_smjpeg_decoder +adpcm_ima_wav_decoder +adpcm_ima_ws_decoder +adpcm_ms_decoder +adpcm_sbpro_2_decoder +adpcm_sbpro_3_decoder +adpcm_sbpro_4_decoder +adpcm_swf_decoder +adpcm_thp_decoder +adpcm_xa_decoder +adpcm_yamaha_decoder +ass_decoder +dvbsub_decoder +dvdsub_decoder +pgssub_decoder +srt_decoder +xsub_decoder +libcelt_decoder +libdirac_decoder +libgsm_decoder +libgsm_ms_decoder +libopencore_amrnb_decoder +libopencore_amrwb_decoder +libopenjpeg_decoder +libschroedinger_decoder +libspeex_decoder +libstagefright_h264_decoder +libutvideo_decoder +libvpx_decoder +bintext_decoder +xbin_decoder +idf_decoder' +delogo_filter_deps=gpl +demuxers_if_any='aac_demuxer +ac3_demuxer +act_demuxer +adf_demuxer +adx_demuxer +aea_demuxer +aiff_demuxer +amr_demuxer +anm_demuxer +apc_demuxer +ape_demuxer +asf_demuxer +ass_demuxer +au_demuxer +avi_demuxer +avisynth_demuxer +avs_demuxer +bethsoftvid_demuxer +bfi_demuxer +bintext_demuxer +bink_demuxer +bit_demuxer +bmv_demuxer +c93_demuxer +caf_demuxer +cavsvideo_demuxer +cdg_demuxer +cdxl_demuxer +daud_demuxer +dfa_demuxer +dirac_demuxer +dnxhd_demuxer +dsicin_demuxer +dts_demuxer +dv_demuxer +dxa_demuxer +ea_demuxer +ea_cdata_demuxer +eac3_demuxer +ffm_demuxer +ffmetadata_demuxer +filmstrip_demuxer +flac_demuxer +flic_demuxer +flv_demuxer +fourxm_demuxer +g722_demuxer +g723_1_demuxer +g729_demuxer +gsm_demuxer +gxf_demuxer +h261_demuxer +h263_demuxer +h264_demuxer +hls_demuxer +ico_demuxer +idcin_demuxer +idf_demuxer +iff_demuxer +image2_demuxer +image2pipe_demuxer +ingenient_demuxer +ipmovie_demuxer +iss_demuxer +iv8_demuxer +ivf_demuxer +jv_demuxer +latm_demuxer +lmlm4_demuxer +loas_demuxer +lxf_demuxer +m4v_demuxer +matroska_demuxer +microdvd_demuxer +mjpeg_demuxer +mlp_demuxer +mm_demuxer +mmf_demuxer +mov_demuxer +mp3_demuxer +mpc_demuxer +mpc8_demuxer +mpegps_demuxer +mpegts_demuxer +mpegtsraw_demuxer +mpegvideo_demuxer +msnwc_tcp_demuxer +mtv_demuxer +mvi_demuxer +mxf_demuxer +mxg_demuxer +nc_demuxer +nsv_demuxer +nut_demuxer +nuv_demuxer +ogg_demuxer +oma_demuxer +pcm_alaw_demuxer +pcm_mulaw_demuxer +pcm_f64be_demuxer +pcm_f64le_demuxer +pcm_f32be_demuxer +pcm_f32le_demuxer +pcm_s32be_demuxer +pcm_s32le_demuxer +pcm_s24be_demuxer +pcm_s24le_demuxer +pcm_s16be_demuxer +pcm_s16le_demuxer +pcm_s8_demuxer +pcm_u32be_demuxer +pcm_u32le_demuxer +pcm_u24be_demuxer +pcm_u24le_demuxer +pcm_u16be_demuxer +pcm_u16le_demuxer +pcm_u8_demuxer +pmp_demuxer +pva_demuxer +qcp_demuxer +r3d_demuxer +rawvideo_demuxer +rl2_demuxer +rm_demuxer +roq_demuxer +rpl_demuxer +rso_demuxer +rtp_demuxer +rtsp_demuxer +sap_demuxer +sbg_demuxer +sdp_demuxer +segafilm_demuxer +shorten_demuxer +siff_demuxer +smacker_demuxer +smjpeg_demuxer +sol_demuxer +sox_demuxer +spdif_demuxer +srt_demuxer +str_demuxer +swf_demuxer +thp_demuxer +tiertexseq_demuxer +tmv_demuxer +truehd_demuxer +tta_demuxer +txd_demuxer +tty_demuxer +vc1_demuxer +vc1t_demuxer +vmd_demuxer +voc_demuxer +vqf_demuxer +w64_demuxer +wav_demuxer +wc3_demuxer +wsaud_demuxer +wsvqa_demuxer +wtv_demuxer +wv_demuxer +xa_demuxer +xbin_demuxer +xmv_demuxer +xwma_demuxer +yop_demuxer +yuv4mpegpipe_demuxer +libmodplug_demuxer +libnut_demuxer' +dep=yuv4mpegpipe +dirac_demuxer_select=dirac_parser +dnxhd_1080i_test=yes +dnxhd_1080i_test_deps=' dnxhd_encoder dnxhd_decoder' +dnxhd_720p_10bit_test=yes +dnxhd_720p_rd_test=yes +dnxhd_720p_rd_test_deps=' dnxhd_encoder dnxhd_decoder' +dnxhd_720p_test=yes +dnxhd_720p_test_deps=' dnxhd_encoder dnxhd_decoder' +dnxhd_encoder_select=aandct +doc=yes +doc_deps=texi2html +dpx_test=yes +drawbox_test=yes +drawtext_filter_deps=libfreetype +dshow_indev_deps=IBaseFilter +dshow_indev_extralibs='-lpsapi -lole32 -lstrmiids -luuid' +dv1394_indev_deps='dv1394 dv_demuxer' +dv50_test=yes +dv50_test_deps=' dvvideo_encoder dvvideo_decoder' +dv_411_test=yes +dv_411_test_deps=' dvvideo_encoder dvvideo_decoder' +dv_fmt_test=yes +dv_fmt_test_deps=' dv_muxer dv_demuxer' +dv_test=yes +dv_test_deps=' dvvideo_encoder dvvideo_decoder' +dxa_decoder_select=zlib +eac3_decoder_select=ac3_decoder +eac3_demuxer_select=ac3_parser +eac3_encoder_select='mdct ac3dsp' +eamad_decoder_select=aandct +eatgq_decoder_select=aandct +eatqi_decoder_select=aandct +encoders_if_any='a64multi_encoder +a64multi5_encoder +amv_encoder +asv1_encoder +asv2_encoder +avrp_encoder +ayuv_encoder +bmp_encoder +cljr_encoder +dnxhd_encoder +dpx_encoder +dvvideo_encoder +ffv1_encoder +ffvhuff_encoder +flashsv_encoder +flashsv2_encoder +flv_encoder +gif_encoder +h261_encoder +h263_encoder +h263p_encoder +huffyuv_encoder +jpeg2000_encoder +jpegls_encoder +ljpeg_encoder +mjpeg_encoder +mpeg1video_encoder +mpeg2video_encoder +mpeg4_encoder +msmpeg4v2_encoder +msmpeg4v3_encoder +msvideo1_encoder +pam_encoder +pbm_encoder +pcx_encoder +pgm_encoder +pgmyuv_encoder +png_encoder +ppm_encoder +prores_encoder +prores_anatoliy_encoder +prores_kostya_encoder +qtrle_encoder +r10k_encoder +r210_encoder +rawvideo_encoder +roq_encoder +rv10_encoder +rv20_encoder +sgi_encoder +snow_encoder +sunrast_encoder +svq1_encoder +targa_encoder +tiff_encoder +v210_encoder +v308_encoder +v408_encoder +v410_encoder +wmv1_encoder +wmv2_encoder +xbm_encoder +xwd_encoder +y41p_encoder +yuv4_encoder +zlib_encoder +zmbv_encoder +aac_encoder +ac3_encoder +ac3_fixed_encoder +alac_encoder +dca_encoder +eac3_encoder +flac_encoder +g723_1_encoder +mp2_encoder +nellymoser_encoder +ra_144_encoder +sonic_encoder +sonic_ls_encoder +vorbis_encoder +wmav1_encoder +wmav2_encoder +pcm_alaw_encoder +pcm_f32be_encoder +pcm_f32le_encoder +pcm_f64be_encoder +pcm_f64le_encoder +pcm_mulaw_encoder +pcm_s8_encoder +pcm_s16be_encoder +pcm_s16le_encoder +pcm_s24be_encoder +pcm_s24daud_encoder +pcm_s24le_encoder +pcm_s32be_encoder +pcm_s32le_encoder +pcm_u8_encoder +pcm_u16be_encoder +pcm_u16le_encoder +pcm_u24be_encoder +pcm_u24le_encoder +pcm_u32be_encoder +pcm_u32le_encoder +roq_dpcm_encoder +adpcm_adx_encoder +adpcm_g722_encoder +adpcm_g726_encoder +adpcm_ima_qt_encoder +adpcm_ima_wav_encoder +adpcm_ms_encoder +adpcm_swf_encoder +adpcm_yamaha_encoder +ass_encoder +dvbsub_encoder +dvdsub_encoder +srt_encoder +xsub_encoder +libaacplus_encoder +libfaac_encoder +libgsm_encoder +libgsm_ms_encoder +libmp3lame_encoder +libopencore_amrnb_encoder +libopenjpeg_encoder +libschroedinger_encoder +libspeex_encoder +libtheora_encoder +libutvideo_encoder +libvo_aacenc_encoder +libvo_amrwbenc_encoder +libvorbis_encoder +libvpx_encoder +libx264_encoder +libx264rgb_encoder +libxavs_encoder +libxvid_encoder' +error_test=yes +error_test_deps=' mpeg4_encoder mpeg4_decoder' +fade_test=yes +fast_64bit_if_any='alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64' +fast_clz_if_any='alpha armv5te avr32 mips ppc x86' +fast_unaligned_if_any='armv6 ppc x86' +fastdiv=yes +fbdev_indev_deps=linux_fb_h +ffm_test=yes +ffm_test_deps=' ffm_muxer ffm_demuxer' +ffmpeg=yes +ffmpeg_deps='avcodec avformat swscale swresample' +ffmpeg_select=buffersink_filter +ffplay=yes +ffplay_deps='avcodec avformat swscale swresample sdl' +ffplay_select='buffersink_filter rdft' +ffprobe=yes +ffprobe_deps='avcodec avformat' +ffserver=yes +ffserver_deps='avformat ffm_muxer fork rtp_protocol rtsp_demuxer' +ffserver_extralibs='$ldl' +ffv1_decoder_select=golomb +ffv1_test=yes +ffv1_test_deps=' ffv1_encoder ffv1_decoder' +ffvhuff_test=yes +filters_if_any='aconvert_filter +aformat_filter +amerge_filter +anull_filter +aresample_filter +ashowinfo_filter +asplit_filter +astreamsync_filter +earwax_filter +pan_filter +silencedetect_filter +volume_filter +abuffer_filter +aevalsrc_filter +amovie_filter +anullsrc_filter +abuffersink_filter +anullsink_filter +ass_filter +bbox_filter +blackdetect_filter +blackframe_filter +boxblur_filter +copy_filter +crop_filter +cropdetect_filter +delogo_filter +deshake_filter +drawbox_filter +drawtext_filter +fade_filter +fieldorder_filter +fifo_filter +format_filter +frei0r_filter +gradfun_filter +hflip_filter +hqdn3d_filter +lut_filter +lutrgb_filter +lutyuv_filter +mp_filter +negate_filter +noformat_filter +null_filter +ocv_filter +overlay_filter +pad_filter +pixdesctest_filter +scale_filter +select_filter +setdar_filter +setfield_filter +setpts_filter +setsar_filter +settb_filter +showinfo_filter +slicify_filter +split_filter +swapuv_filter +thumbnail_filter +tile_filter +tinterlace_filter +transpose_filter +unsharp_filter +vflip_filter +yadif_filter +cellauto_filter +color_filter +frei0r_src_filter +life_filter +mandelbrot_filter +movie_filter +mptestsrc_filter +nullsrc_filter +rgbtestsrc_filter +testsrc_filter +buffersink_filter +nullsink_filter' +flac_decoder_select=golomb +flac_demuxer_select=flac_parser +flac_encoder_select='golomb lpc' +flac_test=yes +flac_test_deps=' flac_encoder flac_decoder' +flashsv2_decoder_select=zlib +flashsv2_encoder_select=zlib +flashsv2_test=yes +flashsv2_test_deps=zlib +flashsv_decoder_select=zlib +flashsv_encoder_select=zlib +flashsv_test=yes +flashsv_test_deps=' flashsv_encoder flashsv_decoder' +flv_decoder_select=h263_decoder +flv_encoder_select=h263_encoder +flv_fmt_test=yes +flv_fmt_test_deps=' flv_muxer flv_demuxer' +flv_test=yes +flv_test_deps=' flv_encoder flv_decoder' +fraps_decoder_select=huffman +frei0r_filter_deps='frei0r dlopen' +frei0r_src_filter_deps='frei0r dlopen' +g722_test=yes +g723_1_test=yes +g726_test=yes +g726_test_deps=' adpcm_g726_encoder adpcm_g726_decoder' +gif_test=yes +gif_test_deps=' gif_encoder gif_decoder' +gopher_protocol_deps=network +gxf_test=yes +gxf_test_deps=' gxf_muxer gxf_demuxer' +h261_encoder_select=aandct +h261_test=yes +h261_test_deps=' h261_encoder h261_decoder' +h263_decoder_select=h263_parser +h263_encoder_select=aandct +h263_test=yes +h263_test_deps=' h263_encoder h263_decoder' +h263_vaapi_hwaccel_select='vaapi h263_decoder' +h263i_decoder_select=h263_decoder +h263p_encoder_select=h263_encoder +h263p_test=yes +h263p_test_deps=' h263_encoder h263_decoder' +h264_crystalhd_decoder_select='crystalhd h264_mp4toannexb_bsf h264_parser' +h264_decoder_select='golomb h264chroma h264dsp h264pred' +h264_dxva2_hwaccel_deps=dxva2api_h +h264_dxva2_hwaccel_select='dxva2 h264_decoder' +h264_parser_select='golomb h264chroma h264dsp h264pred' +h264_vaapi_hwaccel_select='vaapi h264_decoder' +h264_vda_hwaccel_deps='VideoDecodeAcceleration_VDADecoder_h pthreads' +h264_vda_hwaccel_select='vda h264_decoder' +h264_vdpau_decoder_select='vdpau h264_decoder' +host_cc_default=gcc +host_cflags='-D_ISOC99_SOURCE -O3 -g' +host_libs=-lm +host_os=linux +hqdn3d_filter_deps=gpl +http_protocol_deps=network +http_protocol_select=tcp_protocol +httpproxy_protocol_deps=network +httpproxy_protocol_select=tcp_protocol +https_protocol_select=tls_protocol +huffyuv_test=yes +huffyuv_test_deps=' huffyuv_encoder huffyuv_decoder' +hwaccels_if_any='h263_vaapi_hwaccel +h264_dxva2_hwaccel +h264_vaapi_hwaccel +h264_vda_hwaccel +mpeg1_vdpau_hwaccel +mpeg2_dxva2_hwaccel +mpeg2_vaapi_hwaccel +mpeg2_vdpau_hwaccel +mpeg4_vaapi_hwaccel +vc1_dxva2_hwaccel +vc1_vaapi_hwaccel +wmv3_dxva2_hwaccel +wmv3_vaapi_hwaccel' +imc_decoder_select='fft mdct sinewin' +incdir_default='${prefix}/include' +indevs_if_any='alsa_indev +bktr_indev +dshow_indev +dv1394_indev +fbdev_indev +jack_indev +lavfi_indev +openal_indev +oss_indev +pulse_indev +sndio_indev +v4l2_indev +vfwcap_indev +x11_grab_device_indev +libcdio_indev +libdc1394_indev' +inline_asm_deps='!tms470' +install=install +ipod_muxer_select=mov_muxer +ismv_test=yes +ismv_test_deps=' mov_muxer mov_demuxer' +jack_indev_deps='jack_jack_h sem_timedwait' +jpeg2000_test=yes +jpegls_decoder_select=golomb +jpegls_encoder_select=golomb +jpegls_test=yes +jpegls_test_deps=' jpegls_encoder jpegls_decoder' +jpg_test=yes +jpg_test_deps=' mjpeg_encoder mjpeg_decoder' +l= +lavfi_indev_deps=avfilter +libaacplus_encoder_deps=libaacplus +libcdio_indev_deps=libcdio +libcelt_decoder_deps=libcelt +libdc1394_indev_deps=libdc1394 +libdir_default='${prefix}/lib' +libdirac_decoder_deps='libdirac !libschroedinger' +libfaac_encoder_deps=libfaac +libgsm_decoder_deps=libgsm +libgsm_encoder_deps=libgsm +libgsm_ms_decoder_deps=libgsm +libgsm_ms_encoder_deps=libgsm +libmodplug_demuxer_deps=libmodplug +libmp3lame_encoder_deps=libmp3lame +libnut_demuxer_deps=libnut +libnut_muxer_deps=libnut +libopencore_amrnb_decoder_deps=libopencore_amrnb +libopencore_amrnb_encoder_deps=libopencore_amrnb +libopencore_amrwb_decoder_deps=libopencore_amrwb +libopenjpeg_decoder_deps=libopenjpeg +libopenjpeg_encoder_deps=libopenjpeg +librtmp_protocol_deps=librtmp +librtmpe_protocol_deps=librtmp +librtmps_protocol_deps=librtmp +librtmpt_protocol_deps=librtmp +librtmpte_protocol_deps=librtmp +libschroedinger_decoder_deps=libschroedinger +libschroedinger_encoder_deps=libschroedinger +libspeex_decoder_deps=libspeex +libspeex_encoder_deps=libspeex +libstagefright_h264_decoder_deps=libstagefright_h264 +libtheora_encoder_deps=libtheora +libutvideo_decoder_deps=libutvideo +libutvideo_encoder_deps=libutvideo +libv4l2_indev_deps=libv4l2 +libvo_aacenc_encoder_deps=libvo_aacenc +libvo_amrwbenc_encoder_deps=libvo_amrwbenc +libvorbis_encoder_deps=libvorbis +libvpx_decoder_deps=libvpx +libvpx_encoder_deps=libvpx +libx264_encoder_deps=libx264 +libx264rgb_encoder_deps=libx264 +libxavs_encoder_deps=libxavs +libxvid_encoder_deps=libxvid +life_test=yes +ljpeg_encoder_select=aandct +ljpeg_test=yes +ljpeg_test_deps=' mjpeg_encoder mjpeg_decoder' +ln_s='ln -sf' +loco_decoder_select=golomb +logfile=config.log +m='eval unset \${$(toupper ${v%s})_LIST}' +mandir_default='${prefix}/share/man' +matroska_audio_muxer_select=matroska_muxer +matroska_demuxer_suggest='zlib bzlib' +mdct_select=fft +mjpeg_encoder_select=aandct +mjpeg_test=yes +mjpeg_test_deps=' mjpeg_encoder mjpeg_decoder' +mkv_test=yes +mkv_test_deps=' matroska_muxer matroska_demuxer' +mlp_decoder_select=mlp_parser +mmf_test=yes +mmf_test_deps=' mmf_muxer mmf_demuxer' +mmi=yes +mmi_deps=mips +mmsh_protocol_select=http_protocol +mmst_protocol_deps=network +mmx=yes +mmx2=yes +mmx2_deps=mmx +mmx_deps=x86 +mov_demuxer_suggest=zlib +mov_test=yes +mov_test_deps=' mov_muxer mov_demuxer' +movie_filter_deps='avcodec avformat' +mp1_decoder_select=mpegaudiodsp +mp1float_decoder_select=mpegaudiodsp +mp2_decoder_select=mpegaudiodsp +mp2_test=yes +mp2_test_deps=' mp2_encoder mp2_decoder' +mp2float_decoder_select=mpegaudiodsp +mp3_decoder_select=mpegaudiodsp +mp3_demuxer_select=mpegaudio_parser +mp3adu_decoder_select=mpegaudiodsp +mp3adufloat_decoder_select=mpegaudiodsp +mp3float_decoder_select=mpegaudiodsp +mp3on4_decoder_select=mpegaudiodsp +mp3on4float_decoder_select=mpegaudiodsp +mp4_muxer_select=mov_muxer +mp_filter_deps='gpl avcodec swscale postproc' +mpc7_decoder_select=mpegaudiodsp +mpc8_decoder_select=mpegaudiodsp +mpeg1_vdpau_decoder_select='vdpau mpeg1video_decoder' +mpeg1_vdpau_hwaccel_select='vdpau mpeg1video_decoder' +mpeg1b_test=yes +mpeg1b_test_deps=' mpeg1video_encoder mpeg1video_decoder' +mpeg1video_encoder_select=aandct +mpeg2_422_test=yes +mpeg2_422_test_deps=' mpeg2video_encoder mpeg2video_decoder' +mpeg2_crystalhd_decoder_select=crystalhd +mpeg2_dxva2_hwaccel_deps=dxva2api_h +mpeg2_dxva2_hwaccel_select='dxva2 mpeg2video_decoder' +mpeg2_idct_int_test=yes +mpeg2_idct_int_test_deps=' mpeg2video_encoder mpeg2video_decoder' +mpeg2_ilace_test=yes +mpeg2_ilace_test_deps=' mpeg2video_encoder mpeg2video_decoder' +mpeg2_ivlc_qprd_test=yes +mpeg2_ivlc_qprd_test_deps=' mpeg2video_encoder mpeg2video_decoder' +mpeg2_test=yes +mpeg2_test_deps=' mpeg2video_encoder mpeg2video_decoder' +mpeg2_vaapi_hwaccel_select='vaapi mpeg2video_decoder' +mpeg2_vdpau_hwaccel_select='vdpau mpeg2video_decoder' +mpeg2thread_ilace_test=yes +mpeg2thread_ilace_test_deps=' mpeg2video_encoder mpeg2video_decoder' +mpeg2thread_test=yes +mpeg2thread_test_deps=' mpeg2video_encoder mpeg2video_decoder' +mpeg2video_encoder_select=aandct +mpeg4_adap_test=yes +mpeg4_adap_test_deps=' mpeg4_encoder mpeg4_decoder' +mpeg4_crystalhd_decoder_select=crystalhd +mpeg4_decoder_select='h263_decoder mpeg4video_parser' +mpeg4_encoder_select=h263_encoder +mpeg4_qpel_test=yes +mpeg4_qpel_test_deps=' mpeg4_encoder mpeg4_decoder' +mpeg4_qprd_test=yes +mpeg4_qprd_test_deps=' mpeg4_encoder mpeg4_decoder' +mpeg4_test=yes +mpeg4_test_deps=' mpeg4_encoder mpeg4_decoder' +mpeg4_vaapi_hwaccel_select='vaapi mpeg4_decoder' +mpeg4_vdpau_decoder_select='vdpau mpeg4_decoder' +mpeg4adv_test=yes +mpeg4adv_test_deps=' mpeg4_encoder mpeg4_decoder' +mpeg4nr_test=yes +mpeg4nr_test_deps=' mpeg4_encoder mpeg4_decoder' +mpeg4thread_test=yes +mpeg4thread_test_deps=' mpeg4_encoder mpeg4_decoder' +mpeg_test=yes +mpeg_test_deps=' mpeg1video_encoder mpeg1video_decoder' +mpeg_vdpau_decoder_select='vdpau mpegvideo_decoder' +mpeg_xvmc_decoder_deps=X11_extensions_XvMClib_h +mpeg_xvmc_decoder_select=mpegvideo_decoder +mpegaudiodsp_select=dct +mpegtsraw_demuxer_select=mpegts_demuxer +mpg_test=yes +mpg_test_deps='mpeg1system_muxer mpegps_demuxer' +mpng_test=yes +mpng_test_deps=zlib +mptestsrc_filter_deps=gpl +msmpeg4_crystalhd_decoder_select=crystalhd +msmpeg4_test=yes +msmpeg4_test_deps=' msmpeg4v3_encoder msmpeg4v3_decoder' +msmpeg4v1_decoder_select=h263_decoder +msmpeg4v1_encoder_select=h263_encoder +msmpeg4v2_decoder_select=h263_decoder +msmpeg4v2_encoder_select=h263_encoder +msmpeg4v2_test=yes +msmpeg4v2_test_deps=' msmpeg4v2_encoder msmpeg4v2_decoder' +msmpeg4v3_decoder_select=h263_decoder +msmpeg4v3_encoder_select=h263_encoder +msvideo1_test=yes +mulaw_test=yes +mulaw_test_deps=' pcm_mulaw_muxer pcm_mulaw_demuxer' +muxers_if_any='a64_muxer +ac3_muxer +adts_muxer +adx_muxer +aiff_muxer +amr_muxer +asf_muxer +ass_muxer +asf_stream_muxer +au_muxer +avi_muxer +avm2_muxer +bit_muxer +caf_muxer +cavsvideo_muxer +crc_muxer +daud_muxer +dirac_muxer +dnxhd_muxer +dts_muxer +dv_muxer +eac3_muxer +ffm_muxer +ffmetadata_muxer +filmstrip_muxer +flac_muxer +flv_muxer +framecrc_muxer +framemd5_muxer +g722_muxer +g723_1_muxer +gif_muxer +gxf_muxer +h261_muxer +h263_muxer +h264_muxer +image2_muxer +image2pipe_muxer +ipod_muxer +ismv_muxer +ivf_muxer +latm_muxer +m4v_muxer +md5_muxer +matroska_muxer +matroska_audio_muxer +microdvd_muxer +mjpeg_muxer +mlp_muxer +mmf_muxer +mov_muxer +mp2_muxer +mp3_muxer +mp4_muxer +mpeg1system_muxer +mpeg1vcd_muxer +mpeg1video_muxer +mpeg2dvd_muxer +mpeg2svcd_muxer +mpeg2video_muxer +mpeg2vob_muxer +mpegts_muxer +mpjpeg_muxer +mxf_muxer +mxf_d10_muxer +null_muxer +nut_muxer +ogg_muxer +oma_muxer +pcm_alaw_muxer +pcm_mulaw_muxer +pcm_f64be_muxer +pcm_f64le_muxer +pcm_f32be_muxer +pcm_f32le_muxer +pcm_s32be_muxer +pcm_s32le_muxer +pcm_s24be_muxer +pcm_s24le_muxer +pcm_s16be_muxer +pcm_s16le_muxer +pcm_s8_muxer +pcm_u32be_muxer +pcm_u32le_muxer +pcm_u24be_muxer +pcm_u24le_muxer +pcm_u16be_muxer +pcm_u16le_muxer +pcm_u8_muxer +psp_muxer +rawvideo_muxer +rm_muxer +roq_muxer +rso_muxer +rtp_muxer +rtsp_muxer +sap_muxer +segment_muxer +smjpeg_muxer +sox_muxer +spdif_muxer +srt_muxer +swf_muxer +tg2_muxer +tgp_muxer +mkvtimestamp_v2_muxer +truehd_muxer +vc1t_muxer +voc_muxer +wav_muxer +webm_muxer +wtv_muxer +yuv4mpegpipe_muxer +libnut_muxer' +mxf_d10_muxer_select=mxf_muxer +mxf_d10_test=yes +mxf_d10_test_deps='avfilter mxf_muxer mxf_demuxer' +mxf_test=yes +mxf_test_deps=' mxf_muxer mxf_demuxer' +n=protocols +name=yuv4mpeg +need_memalign='altivec neon sse' +negate_filter_deps=lut_filter +nellymoser_decoder_select='mdct sinewin' +nellymoser_encoder_select='mdct sinewin' +neon=yes +neon_deps=arm +network=yes +nm_default=nm +nm_opts=-g +nogas=: +null_test=yes +nut_test=yes +nut_test_deps=' nut_muxer nut_demuxer' +objformat=elf +ocv_filter_deps=libopencv +ogg_demuxer_select=golomb +ogg_test=yes +ogg_test_deps=' ogg_muxer ogg_demuxer' +ogg_vp3_test=yes +ogg_vp3_test_deps=' ogg_muxer ogg_demuxer' +op== +openal_indev_deps=openal +opt=--disable-everything +optimizations=yes +optval=--disable-everything +oss_indev_deps_any='soundcard_h sys_soundcard_h' +oss_outdev_deps_any='soundcard_h sys_soundcard_h' +outdevs_if_any='alsa_outdev +oss_outdev +sdl_outdev +sndio_outdev' +overlay_test=yes +pad_test=yes +pam_test=yes +pan_filter_deps=swresample +parsers_if_any='aac_parser +aac_latm_parser +ac3_parser +adx_parser +cavsvideo_parser +dca_parser +dirac_parser +dnxhd_parser +dvbsub_parser +dvdsub_parser +flac_parser +gsm_parser +h261_parser +h263_parser +h264_parser +mjpeg_parser +mlp_parser +mpeg4video_parser +mpegaudio_parser +mpegvideo_parser +pnm_parser +rv30_parser +rv40_parser +vc1_parser +vorbis_parser +vp3_parser +vp8_parser' +pbmpipe_test=yes +pbmpipe_test_deps=' pbm_encoder pbm_decoder' +pcm_alaw_test=yes +pcm_f32be_test=yes +pcm_f32le_test=yes +pcm_f64be_test=yes +pcm_f64le_test=yes +pcm_mulaw_test=yes +pcm_s16be_test=yes +pcm_s16le_test=yes +pcm_s24be_test=yes +pcm_s24daud_test=yes +pcm_s24le_test=yes +pcm_s32be_test=yes +pcm_s32le_test=yes +pcm_s8_test=yes +pcm_test_deps='pcm_alaw_decoder pcm_alaw_encoder +pcm_f32be_decoder pcm_f32be_encoder +pcm_f32le_decoder pcm_f32le_encoder +pcm_f64be_decoder pcm_f64be_encoder +pcm_f64le_decoder pcm_f64le_encoder +pcm_mulaw_decoder pcm_mulaw_encoder +pcm_s8_decoder pcm_s8_encoder +pcm_s16be_decoder pcm_s16be_encoder +pcm_s16le_decoder pcm_s16le_encoder +pcm_s24be_decoder pcm_s24be_encoder +pcm_s24daud_decoder pcm_s24daud_encoder +pcm_s24le_decoder pcm_s24le_encoder +pcm_s32be_decoder pcm_s32be_encoder +pcm_s32le_decoder pcm_s32le_encoder +pcm_u8_decoder pcm_u8_encoder +pcm_u16be_decoder pcm_u16be_encoder +pcm_u16le_decoder pcm_u16le_encoder +pcm_u24be_decoder pcm_u24be_encoder +pcm_u24le_decoder pcm_u24le_encoder +pcm_u32be_decoder pcm_u32be_encoder +pcm_u32le_decoder pcm_u32le_encoder' +pcm_u8_test=yes +pcx_test=yes +pcx_test_deps=' pcx_encoder pcx_decoder' +pgm_test=yes +pgm_test_deps=' pgm_encoder pgm_decoder' +pgmpipe_test=yes +pgmpipe_test_deps=' pgm_encoder pgm_decoder' +pixdesc_test=yes +pixfmt_test=yes +pixfmt_test_deps=' rawvideo_muxer rawvideo_demuxer' +pixfmts_copy_test=yes +pixfmts_crop_test=yes +pixfmts_hflip_test=yes +pixfmts_null_test=yes +pixfmts_pad_test=yes +pixfmts_scale_test=yes +pixfmts_vflip_test=yes +pkg_config_default=pkg-config +png_decoder_select=zlib +png_encoder_select=zlib +png_test=yes +png_test_deps=' png_encoder png_decoder' +postproc=yes +postproc_deps=gpl +postproc_version_default=current +pp2_test=yes +pp2_test_deps=mp_filter +pp3_test=yes +pp3_test_deps=mp_filter +pp4_test=yes +pp4_test_deps=mp_filter +pp5_test=yes +pp5_test_deps=mp_filter +pp6_test=yes +pp6_test_deps=mp_filter +pp_test=yes +pp_test_deps=mp_filter +ppc4xx=yes +ppc4xx_deps=ppc +ppm_test=yes +ppm_test_deps=' ppm_encoder ppm_decoder' +ppmpipe_test=yes +ppmpipe_test_deps=' ppm_encoder ppm_decoder' +prefix_default=/usr/local +prores_kostya_test=yes +prores_test=yes +protocols_if_any='applehttp_protocol +bluray_protocol +cache_protocol +concat_protocol +crypto_protocol +file_protocol +gopher_protocol +hls_protocol +http_protocol +httpproxy_protocol +https_protocol +mmsh_protocol +mmst_protocol +md5_protocol +pipe_protocol +rtmp_protocol +rtp_protocol +tcp_protocol +tls_protocol +udp_protocol +librtmp_protocol +librtmpe_protocol +librtmps_protocol +librtmpt_protocol +librtmpte_protocol' +psp_muxer_select=mov_muxer +pulse_indev_deps=libpulse +qcelp_decoder_select=lsp +qdm2_decoder_select='mdct rdft mpegaudiodsp' +qtrle_test=yes +qtrlegray_test=yes +quotes='""' +r=--disable-everything +r210_test=yes +ra_144_encoder_select=lpc +ranlib=ranlib +rc_test=yes +rc_test_deps=' mpeg4_encoder mpeg4_decoder' +rdft_select=fft +rgb_test=yes +rgb_test_deps=' rawvideo_encoder rawvideo_decoder' +rm_test=yes +rm_test_deps=' rm_muxer rm_demuxer' +roq_test=yes +roq_test_deps=' roq_encoder roq_decoder' +rso_test=yes +rtmp_protocol_deps='!librtmp_protocol' +rtmp_protocol_select=tcp_protocol +rtp_demuxer_select=sdp_demuxer +rtp_protocol_select=udp_protocol +rtpdec_select='asf_demuxer rm_demuxer rtp_protocol mpegts_demuxer mov_demuxer' +rtsp_demuxer_select='http_protocol rtpdec' +rtsp_muxer_select='rtp_muxer http_protocol rtp_protocol' +rv10_decoder_select=h263_decoder +rv10_encoder_select=h263_encoder +rv10_test=yes +rv10_test_deps=' rv10_encoder rv10_decoder' +rv20_decoder_select=h263_decoder +rv20_encoder_select=h263_encoder +rv20_test=yes +rv20_test_deps=' rv20_encoder rv20_decoder' +rv30_decoder_select='golomb h264chroma h264pred' +rv40_decoder_select='golomb h264chroma h264pred' +safe_bitstream_reader=yes +sap_demuxer_select=sdp_demuxer +sap_muxer_select='rtp_muxer rtp_protocol' +scale200_test=yes +scale500_test=yes +scale_filter_deps=swscale +sdl_outdev_deps=sdl +sdp_demuxer_select=rtpdec +seek_ac3_ac3_test=yes +seek_adpcm_ima_wav_test=yes +seek_adpcm_ms_wav_test=yes +seek_adpcm_qt_aiff_test=yes +seek_adpcm_swf_flv_test=yes +seek_adpcm_yam_wav_test=yes +seek_alac_m4a_test=yes +seek_asv1_avi_test=yes +seek_asv2_avi_test=yes +seek_dnxhd_1080i_mov_test=yes +seek_dnxhd_720p_dnxhd_test=yes +seek_dnxhd_720p_rd_dnxhd_test=yes +seek_dv411_dv_test=yes +seek_dv50_dv_test=yes +seek_dv_dv_test=yes +seek_error_mpeg4_adv_avi_test=yes +seek_ffv1_avi_test=yes +seek_flac_flac_test=yes +seek_flashsv_flv_test=yes +seek_flv_flv_test=yes +seek_g726_wav_test=yes +seek_h261_avi_test=yes +seek_h263_avi_test=yes +seek_h263p_avi_test=yes +seek_huffyuv_avi_test=yes +seek_image_bmp_test=yes +seek_image_jpg_test=yes +seek_image_pcx_test=yes +seek_image_pgm_test=yes +seek_image_ppm_test=yes +seek_image_sgi_test=yes +seek_image_tga_test=yes +seek_image_tiff_test=yes +seek_jpegls_avi_test=yes +seek_lavf_aif_test=yes +seek_lavf_al_test=yes +seek_lavf_asf_test=yes +seek_lavf_au_test=yes +seek_lavf_avi_test=yes +seek_lavf_dv_test=yes +seek_lavf_ffm_test=yes +seek_lavf_flv_test=yes +seek_lavf_gif_test=yes +seek_lavf_gxf_test=yes +seek_lavf_mkv_test=yes +seek_lavf_mmf_test=yes +seek_lavf_mov_test=yes +seek_lavf_mpg_test=yes +seek_lavf_mxf_d10_test=yes +seek_lavf_mxf_d10_test_deps=mxf_d10_test +seek_lavf_mxf_test=yes +seek_lavf_nut_test=yes +seek_lavf_ogg_test=yes +seek_lavf_rm_test=yes +seek_lavf_swf_test=yes +seek_lavf_ts_test=yes +seek_lavf_ul_test=yes +seek_lavf_voc_test=yes +seek_lavf_wav_test=yes +seek_lavf_wtv_test=yes +seek_lavf_y4m_test=yes +seek_ljpeg_avi_test=yes +seek_mjpeg_avi_test=yes +seek_mp2_mp2_test=yes +seek_mpeg1_mpg_test=yes +seek_mpeg1b_mpg_test=yes +seek_mpeg2_422_mpg_test=yes +seek_mpeg2_idct_int_mpg_test=yes +seek_mpeg2i_mpg_test=yes +seek_mpeg2ivlc_qprd_mpg_test=yes +seek_mpeg2reuse_mpg_test=yes +seek_mpeg2thread_mpg_test=yes +seek_mpeg2threadivlc_mpg_test=yes +seek_mpeg4_adap_avi_test=yes +seek_mpeg4_adv_avi_test=yes +seek_mpeg4_nr_avi_test=yes +seek_mpeg4_qprd_avi_test=yes +seek_mpeg4_rc_avi_test=yes +seek_mpeg4_thread_avi_test=yes +seek_msmpeg4_avi_test=yes +seek_msmpeg4v2_avi_test=yes +seek_odivx_mp4_test=yes +seek_pbmpipe_pbm_test=yes +seek_pcm_alaw_wav_test=yes +seek_pcm_f32be_au_test=yes +seek_pcm_f32le_wav_test=yes +seek_pcm_f64be_au_test=yes +seek_pcm_f64le_wav_test=yes +seek_pcm_mulaw_wav_test=yes +seek_pcm_s16be_mov_test=yes +seek_pcm_s16le_wav_test=yes +seek_pcm_s24be_mov_test=yes +seek_pcm_s24daud_302_test=yes +seek_pcm_s24le_wav_test=yes +seek_pcm_s32be_mov_test=yes +seek_pcm_s32le_wav_test=yes +seek_pcm_s8_mov_test=yes +seek_pcm_u8_wav_test=yes +seek_pgmpipe_pgm_test=yes +seek_ppmpipe_ppm_test=yes +seek_rgb_avi_test=yes +seek_roqav_roq_test=yes +seek_rv10_rm_test=yes +seek_rv20_rm_test=yes +seek_snow53_avi_test=yes +seek_snow_avi_test=yes +seek_svq1_mov_test=yes +seek_wmv1_avi_test=yes +seek_wmv2_avi_test=yes +seek_yuv_avi_test=yes +select_test=yes +setdar_test=yes +setsar_test=yes +sgi_test=yes +sgi_test_deps=' sgi_encoder sgi_decoder' +shlibdir_default='${prefix}/lib' +shorten_decoder_select=golomb +sipr_decoder_select=lsp +sndio_indev_deps=sndio_h +sndio_outdev_deps=sndio_h +snow_decoder_select=dwt +snow_encoder_select='aandct dwt' +snow_test=yes +snow_test_deps=' snow_encoder snow_decoder' +snowll_test=yes +snowll_test_deps=' snow_encoder snow_decoder' +sonic_decoder_select=golomb +sonic_encoder_select=golomb +sonic_ls_encoder_select=golomb +source_path=. +sox_test=yes +spdif_muxer_select=aac_parser +sse=yes +sse_deps=mmx +ssse3=yes +ssse3_deps=sse +static=yes +strip_default=strip +stripping=yes +suf1=_muxer +suf2=_demuxer +sunrast_test=yes +svq1_encoder_select=aandct +svq1_test=yes +svq1_test_deps=' svq1_encoder svq1_decoder' +svq3_decoder_select='golomb h264chroma h264dsp h264pred' +svq3_decoder_suggest=zlib +swf_test=yes +swf_test_deps=' swf_muxer swf_demuxer' +swresample=yes +swscale=yes +swscale_alpha=yes +symver_if_any='symver_asm_label symver_gnu_asm' +target_os_default=linux +target_path='$(CURDIR)' +tcp_protocol_deps=network +tests=yuv4mpeg +testsrc_test=yes +tg2_muxer_select=mov_muxer +tga_test=yes +tga_test_deps=' targa_encoder targa_decoder' +tgp_muxer_select=mov_muxer +theora_decoder_select=vp3_decoder +thumbnail_test=yes +tiff_decoder_suggest=zlib +tiff_encoder_suggest=zlib +tiff_test=yes +tiff_test_deps=' tiff_encoder tiff_decoder' +tinterlace_filter_deps=gpl +tls_protocol_deps_any='openssl gnutls' +tls_protocol_select=tcp_protocol +transpose_test=yes +truehd_decoder_select=mlp_decoder +ts_test=yes +ts_test_deps=' mpegts_muxer mpegts_demuxer' +tscc_decoder_select=zlib +twinvq_decoder_select='mdct lsp sinewin' +udp_protocol_deps=network +unsharp_test=yes +v=protocols +v210_test=yes +v308_test=yes +v4l2_indev_deps_any='linux_videodev2_h sys_videoio_h' +v4l_indev_deps=linux_videodev_h +vaapi_deps=va_va_h +value=yes +var=seek_yuv_avi_test +vc1_crystalhd_decoder_select=crystalhd +vc1_decoder_select='h263_decoder h264chroma' +vc1_dxva2_hwaccel_deps=dxva2api_h +vc1_dxva2_hwaccel_select='dxva2 vc1_decoder' +vc1_vaapi_hwaccel_select='vaapi vc1_decoder' +vc1_vdpau_decoder_select='vdpau vc1_decoder' +vc1image_decoder_select=vc1_decoder +vda_deps='VideoDecodeAcceleration_VDADecoder_h pthreads' +vdpau_deps='vdpau_vdpau_h vdpau_vdpau_x11_h' +vflip_crop_test=yes +vflip_test=yes +vflip_vflip_test=yes +vfpv3=yes +vfpv3_deps=armvfp +vfwcap_indev_deps='capCreateCaptureWindow vfwcap_defines' +vfwcap_indev_extralibs=-lavicap32 +vis=yes +vis_deps=sparc +voc_s16_test=yes +voc_test=yes +voc_test_deps=' voc_muxer voc_demuxer' +vorbis_decoder_select=mdct +vorbis_encoder_select=mdct +vp6_decoder_select=huffman +vp6a_decoder_select=vp6_decoder +vp6f_decoder_select=vp6_decoder +vp8_decoder_select=h264pred +vref_test=yes +w64_demuxer_deps=wav_demuxer +wav_test=yes +wav_test_deps=' wav_muxer wav_demuxer' +wmapro_decoder_select='mdct sinewin' +wmav1_decoder_select='mdct sinewin' +wmav1_encoder_select='mdct sinewin' +wmav1_test_deps=' wmav1_encoder wmav1_decoder' +wmav2_decoder_select='mdct sinewin' +wmav2_encoder_select='mdct sinewin' +wmav2_test_deps=' wmav2_encoder wmav2_decoder' +wmavoice_decoder_select='lsp rdft dct mdct sinewin' +wmv1_decoder_select=h263_decoder +wmv1_encoder_select=h263_encoder +wmv1_test=yes +wmv1_test_deps=' wmv1_encoder wmv1_decoder' +wmv2_decoder_select=h263_decoder +wmv2_encoder_select=h263_encoder +wmv2_test=yes +wmv2_test_deps=' wmv2_encoder wmv2_decoder' +wmv3_crystalhd_decoder_select=crystalhd +wmv3_decoder_select=vc1_decoder +wmv3_dxva2_hwaccel_select=vc1_dxva2_hwaccel +wmv3_vaapi_hwaccel_select=vc1_vaapi_hwaccel +wmv3_vdpau_decoder_select=vc1_vdpau_decoder +wmv3image_decoder_select=wmv3_decoder +wtv_test=yes +x11_grab_device_indev_deps='x11grab XShmCreateImage' +x11_grab_device_indev_extralibs='-lX11 -lXext -lXfixes' +x86_64_suggest='cmov fast_cmov' +xwd_test=yes +y41p_test=yes +yadif_filter_deps=gpl +yasmexe_default=yasm +yuv4_test=yes +yuv4mpeg_test=yes +yuv4mpeg_test_deps=' yuv4mpegpipe_muxer yuv4mpegpipe_demuxer' +yuv_test=yes +yuv_test_deps=' rawvideo_encoder rawvideo_decoder' +zerocodec_decoder_select=zlib +zlib_decoder_select=zlib +zlib_encoder_select=zlib +zlib_test=yes +zlib_test_deps=zlib +zmbv_decoder_select=zlib +zmbv_encoder_select=zlib +zmbv_test=yes +zmbv_test_deps=zlib +mktemp -u XXXXXX +8VtECo +./configure: /tmp/ffconf.XXNQGlls.sh: /bin/sh: bad interpreter: Permission denied +Sanity test failed. diff -Nru ffmpeg-2.7.1~trusty~ppa1/configure ffmpeg-2.7.2~trusty~ppa1/configure --- ffmpeg-2.7.1~trusty~ppa1/configure 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/configure 2015-08-04 17:20:03.000000000 +0000 @@ -155,6 +155,7 @@ --disable-vaapi disable VAAPI code [autodetect] --disable-vda disable VDA code [autodetect] --disable-vdpau disable VDPAU code [autodetect] + --enable-videotoolbox enable VideoToolbox code [autodetect] Individual component options: --disable-everything disable all components listed below @@ -222,6 +223,7 @@ --enable-libgsm enable GSM de/encoding via libgsm [no] --enable-libiec61883 enable iec61883 via libiec61883 [no] --enable-libilbc enable iLBC de/encoding via libilbc [no] + --enable-libkvazaar enable HEVC encoding via libkvazaar [no] --enable-libmfx enable HW acceleration through libmfx --enable-libmodplug enable ModPlug via libmodplug [no] --enable-libmp3lame enable MP3 encoding via libmp3lame [no] @@ -239,6 +241,7 @@ --enable-libschroedinger enable Dirac de/encoding via libschroedinger [no] --enable-libshine enable fixed-point MP3 encoding via libshine [no] --enable-libsmbclient enable Samba protocol via libsmbclient [no] + --enable-libsnappy enable Snappy compression, needed for hap encoding [no] --enable-libsoxr enable Include libsoxr resampling [no] --enable-libspeex enable Speex de/encoding via libspeex [no] --enable-libssh enable SFTP protocol via libssh [no] @@ -321,6 +324,7 @@ --extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS [$CXXFLAGS] --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS] --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS] + --extra-ldlibflags=ELDFLAGS add ELDFLAGS to LDLIBFLAGS [$LDLIBFLAGS] --extra-libs=ELIBS add ELIBS [$ELIBS] --extra-version=STRING version string suffix [] --optflags=OPTFLAGS override optimization-related compiler flags @@ -373,7 +377,7 @@ --disable-mipsdspr2 disable MIPS DSP ASE R2 optimizations --disable-msa disable MSA optimizations --disable-mipsfpu disable floating point MIPS optimizations - --disable-loongson3 disable Loongson-3 SIMD optimizations + --disable-mmi disable Loongson SIMD optimizations --disable-fast-unaligned consider unaligned accesses slow Developer options (useful when working on FFmpeg itself): @@ -475,7 +479,7 @@ } cleanws(){ - echo "$@" | sed 's/^ *//;s/ */ /g;s/ *$//;s/\\r//g' + echo "$@" | sed 's/^ *//;s/[[:space:]][[:space:]]*/ /g;s/ *$//' } filter(){ @@ -791,6 +795,10 @@ append LDEXEFLAGS $($ldflags_filter "$@") } +add_ldlibflags(){ + append LDLIBFLAGS $($ldflags_filter "$@") +} + add_stripflags(){ append ASMSTRIPFLAGS "$@" } @@ -1380,6 +1388,7 @@ libgsm libiec61883 libilbc + libkvazaar libmfx libmodplug libmp3lame @@ -1396,6 +1405,7 @@ libschroedinger libshine libsmbclient + libsnappy libsoxr libspeex libssh @@ -1461,6 +1471,7 @@ vaapi vda vdpau + videotoolbox xvmc " @@ -1589,7 +1600,9 @@ " ARCH_EXT_LIST_LOONGSON=" + loongson2 loongson3 + mmi " ARCH_EXT_LIST_X86_SIMD=" @@ -1719,7 +1732,9 @@ atan2f cbrt cbrtf + copysign cosf + erf exp2 exp2f expf @@ -1785,6 +1800,7 @@ pthread_cancel sched_getaffinity SetConsoleTextAttribute + SetConsoleCtrlHandler setmode setrlimit Sleep @@ -1824,6 +1840,7 @@ CONDITION_VARIABLE_Ptr socklen_t struct_addrinfo + struct_dcadec_exss_info_matrix_encoding struct_group_source_req struct_ip_mreq_source struct_ipv6_mreq @@ -1887,8 +1904,10 @@ faandct faanidct fdctdsp + flacdsp fmtconvert frame_thread_encoder + g722dsp gcrypt gmp golomb @@ -1906,7 +1925,9 @@ iirfilter imdct15 intrax8 + ividsp jpegtables + libx262 lgplv3 llauddsp llviddsp @@ -1917,6 +1938,7 @@ mpegaudiodsp mpegvideo mpegvideoenc + mss34dsp pixblockdsp qpeldsp qsv @@ -1927,12 +1949,19 @@ riffenc rtpdec rtpenc_chain + rv34dsp sinewin + snappy startcode + texturedsp + texturedspenc tpeldsp videodsp vp3dsp + vp56dsp + vp8dsp wma_freqs + wmv2dsp " CMDLINE_SELECT=" @@ -2040,7 +2069,7 @@ mips32r5_deps="mips" mips64r6_deps="mips" msa_deps="mips" -loongson3_deps="mips" +mmi_deps="mips" altivec_deps="ppc" dcbzl_deps="ppc" @@ -2119,12 +2148,15 @@ # decoders / encoders aac_decoder_select="imdct15 mdct sinewin" +aac_fixed_decoder_select="mdct sinewin" aac_encoder_select="audio_frame_queue iirfilter mdct sinewin" aac_latm_decoder_select="aac_decoder aac_latm_parser" ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct" ac3_fixed_decoder_select="ac3_parser ac3dsp bswapdsp mdct" ac3_encoder_select="ac3dsp audiodsp mdct me_cmp" ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp" +adpcm_g722_decoder_select="g722dsp" +adpcm_g722_encoder_select="g722dsp" aic_decoder_select="golomb idctdsp" alac_encoder_select="lpc" als_decoder_select="bswapdsp" @@ -2153,6 +2185,7 @@ cscd_decoder_select="lzo" cscd_decoder_suggest="zlib" dca_decoder_select="fmtconvert mdct" +dds_decoder_select="texturedsp" dirac_decoder_select="dwt golomb videodsp mpegvideoenc" dnxhd_decoder_select="blockdsp idctdsp" dnxhd_encoder_select="aandcttables blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp" @@ -2170,8 +2203,8 @@ ffvhuff_decoder_select="huffyuv_decoder" ffvhuff_encoder_select="huffyuv_encoder" fic_decoder_select="golomb" -flac_decoder_select="golomb" -flac_encoder_select="bswapdsp golomb lpc" +flac_decoder_select="flacdsp golomb" +flac_encoder_select="bswapdsp flacdsp golomb lpc" flashsv_decoder_select="zlib" flashsv_encoder_select="zlib" flashsv2_encoder_select="zlib" @@ -2195,12 +2228,21 @@ h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec h264_qsv_hwaccel" h264_qsv_encoder_deps="libmfx" h264_qsv_encoder_select="qsvenc" +hap_decoder_select="snappy texturedsp" +hap_encoder_deps="libsnappy" +hap_encoder_select="texturedspenc" hevc_decoder_select="bswapdsp cabac golomb videodsp" +hevc_qsv_encoder_deps="libmfx" +hevc_qsv_decoder_deps="libmfx" +hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser qsvdec hevc_qsv_hwaccel" +hevc_qsv_encoder_select="qsvenc" huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp" huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llviddsp" iac_decoder_select="imc_decoder" imc_decoder_select="bswapdsp fft mdct sinewin" indeo3_decoder_select="hpeldsp" +indeo4_decoder_select="ividsp" +indeo5_decoder_select="ividsp" interplay_video_decoder_select="hpeldsp" jpegls_decoder_select="golomb mjpeg_decoder" jpegls_encoder_select="golomb" @@ -2235,14 +2277,20 @@ mpeg1video_encoder_select="aandcttables mpegvideoenc h263dsp" mpeg2video_decoder_select="error_resilience mpeg_er mpegvideo" mpeg2video_encoder_select="aandcttables mpegvideoenc h263dsp" +mpeg2_qsv_decoder_deps="libmfx" +mpeg2_qsv_decoder_select="qsvdec mpeg2_qsv_hwaccel" +mpeg2_qsv_encoder_deps="libmfx" +mpeg2_qsv_encoder_select="qsvenc" mpeg4_decoder_select="h263_decoder mpeg4video_parser" mpeg4_encoder_select="h263_encoder" +msa1_decoder_select="mss34dsp" msmpeg4v1_decoder_select="h263_decoder" msmpeg4v2_decoder_select="h263_decoder" msmpeg4v2_encoder_select="h263_encoder" msmpeg4v3_decoder_select="h263_decoder" msmpeg4v3_encoder_select="h263_encoder" mss2_decoder_select="error_resilience mpeg_er qpeldsp vc1_decoder" +mts2_decoder_select="mss34dsp" mxpeg_decoder_select="mjpeg_decoder" nellymoser_decoder_select="mdct sinewin" nellymoser_encoder_select="audio_frame_queue mdct sinewin" @@ -2265,8 +2313,8 @@ rv10_encoder_select="h263_encoder" rv20_decoder_select="error_resilience h263_decoder h263dsp mpeg_er" rv20_encoder_select="h263_encoder" -rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo videodsp" -rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo videodsp" +rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo rv34dsp videodsp" +rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo rv34dsp videodsp" shorten_decoder_select="golomb" sipr_decoder_select="lsp" snow_decoder_select="dwt h264qpel hpeldsp me_cmp rangecoder videodsp" @@ -2290,20 +2338,23 @@ truespeech_decoder_select="bswapdsp" tscc_decoder_select="zlib" twinvq_decoder_select="mdct lsp sinewin" +txd_decoder_select="texturedsp" utvideo_decoder_select="bswapdsp" utvideo_encoder_select="bswapdsp huffman huffyuvencdsp" vble_decoder_select="huffyuvdsp" vc1_decoder_select="blockdsp error_resilience h263_decoder h264chroma h264qpel intrax8 mpeg_er qpeldsp startcode" vc1image_decoder_select="vc1_decoder" +vc1_qsv_decoder_deps="libmfx" +vc1_qsv_decoder_select="qsvdec vc1_qsv_hwaccel" vorbis_decoder_select="mdct" vorbis_encoder_select="mdct" vp3_decoder_select="hpeldsp vp3dsp videodsp" -vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp" -vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp" +vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp vp56dsp" +vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp vp56dsp" vp6a_decoder_select="vp6_decoder" vp6f_decoder_select="vp6_decoder" -vp7_decoder_select="h264pred videodsp" -vp8_decoder_select="h264pred videodsp" +vp7_decoder_select="h264pred videodsp vp8dsp" +vp8_decoder_select="h264pred videodsp vp8dsp" vp9_decoder_select="videodsp vp9_parser" webp_decoder_select="vp8_decoder" wmalossless_decoder_select="llauddsp" @@ -2315,8 +2366,8 @@ wmavoice_decoder_select="lsp rdft dct mdct sinewin" wmv1_decoder_select="h263_decoder" wmv1_encoder_select="h263_encoder" -wmv2_decoder_select="blockdsp h263_decoder idctdsp intrax8 videodsp" -wmv2_encoder_select="h263_encoder" +wmv2_decoder_select="blockdsp h263_decoder idctdsp intrax8 videodsp wmv2dsp" +wmv2_encoder_select="h263_encoder wmv2dsp" wmv3_decoder_select="vc1_decoder" wmv3image_decoder_select="wmv3_decoder" zerocodec_decoder_select="zlib" @@ -2331,14 +2382,18 @@ dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode" vaapi_deps="va_va_h" vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads" -vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore" +vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore -framework CoreServices" vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h" +videotoolbox_deps="VideoToolbox_VideoToolbox_h pthreads" +videotoolbox_extralibs="-framework CoreFoundation -framework VideoToolbox -framework CoreMedia -framework QuartzCore -framework CoreServices" xvmc_deps="X11_extensions_XvMClib_h" h263_vaapi_hwaccel_deps="vaapi" h263_vaapi_hwaccel_select="h263_decoder" h263_vdpau_hwaccel_deps="vdpau" h263_vdpau_hwaccel_select="h263_decoder" +h263_videotoolbox_hwaccel_deps="videotoolbox" +h263_videotoolbox_hwaccel_select="h263_decoder" h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser" h264_d3d11va_hwaccel_deps="d3d11va" h264_d3d11va_hwaccel_select="h264_decoder" @@ -2361,10 +2416,15 @@ h264_vdpau_decoder_select="h264_decoder" h264_vdpau_hwaccel_deps="vdpau" h264_vdpau_hwaccel_select="h264_decoder" +h264_videotoolbox_hwaccel_deps="videotoolbox" +h264_videotoolbox_hwaccel_select="h264_decoder" hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC" hevc_d3d11va_hwaccel_select="hevc_decoder" hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" hevc_dxva2_hwaccel_select="hevc_decoder" +hevc_qsv_hwaccel_deps="libmfx" +hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC" +hevc_vdpau_hwaccel_select="hevc_decoder" mpeg_vdpau_decoder_deps="vdpau" mpeg_vdpau_decoder_select="mpeg2video_decoder" mpeg_xvmc_hwaccel_deps="xvmc" @@ -2373,6 +2433,8 @@ mpeg1_vdpau_decoder_select="mpeg1video_decoder" mpeg1_vdpau_hwaccel_deps="vdpau" mpeg1_vdpau_hwaccel_select="mpeg1video_decoder" +mpeg1_videotoolbox_hwaccel_deps="videotoolbox" +mpeg1_videotoolbox_hwaccel_select="mpeg1video_decoder" mpeg1_xvmc_hwaccel_deps="xvmc" mpeg1_xvmc_hwaccel_select="mpeg1video_decoder" mpeg2_crystalhd_decoder_select="crystalhd" @@ -2380,10 +2442,14 @@ mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder" mpeg2_dxva2_hwaccel_deps="dxva2" mpeg2_dxva2_hwaccel_select="mpeg2video_decoder" +mpeg2_qsv_hwaccel_deps="libmfx" +mpeg2_qsv_hwaccel_select="qsvdec_mpeg2" mpeg2_vaapi_hwaccel_deps="vaapi" mpeg2_vaapi_hwaccel_select="mpeg2video_decoder" mpeg2_vdpau_hwaccel_deps="vdpau" mpeg2_vdpau_hwaccel_select="mpeg2video_decoder" +mpeg2_videotoolbox_hwaccel_deps="videotoolbox" +mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder" mpeg2_xvmc_hwaccel_deps="xvmc" mpeg2_xvmc_hwaccel_select="mpeg2video_decoder" mpeg4_crystalhd_decoder_select="crystalhd" @@ -2393,6 +2459,8 @@ mpeg4_vdpau_decoder_select="mpeg4_decoder" mpeg4_vdpau_hwaccel_deps="vdpau" mpeg4_vdpau_hwaccel_select="mpeg4_decoder" +mpeg4_videotoolbox_hwaccel_deps="videotoolbox" +mpeg4_videotoolbox_hwaccel_select="mpeg4_decoder" msmpeg4_crystalhd_decoder_select="crystalhd" vc1_crystalhd_decoder_select="crystalhd" vc1_d3d11va_hwaccel_deps="d3d11va" @@ -2405,6 +2473,8 @@ vc1_vdpau_decoder_select="vc1_decoder" vc1_vdpau_hwaccel_deps="vdpau" vc1_vdpau_hwaccel_select="vc1_decoder" +vc1_qsv_hwaccel_deps="libmfx" +vc1_qsv_hwaccel_select="qsvdec_vc1" wmv3_crystalhd_decoder_select="crystalhd" wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel" wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel" @@ -2414,7 +2484,7 @@ # parsers h264_parser_select="h264_decoder" -hevc_parser_select="hevc_decoder" +hevc_parser_select="golomb" mpegvideo_parser_select="mpegvideo" mpeg4video_parser_select="error_resilience h263dsp mpeg_er mpegvideo qpeldsp" vc1_parser_select="mpegvideo startcode vc1_decoder" @@ -2438,6 +2508,7 @@ libgsm_ms_encoder_deps="libgsm" libilbc_decoder_deps="libilbc" libilbc_encoder_deps="libilbc" +libkvazaar_encoder_deps="libkvazaar" libmodplug_demuxer_deps="libmodplug" libmp3lame_encoder_deps="libmp3lame" libmp3lame_encoder_select="audio_frame_queue" @@ -2475,6 +2546,7 @@ libwavpack_encoder_deps="libwavpack" libwebp_encoder_deps="libwebp" libwebp_anim_encoder_deps="libwebp" +libx262_encoder_deps="libx262" libx264_encoder_deps="libx264" libx264rgb_encoder_deps="libx264" libx264rgb_encoder_select="libx264_encoder" @@ -2491,6 +2563,7 @@ # demuxers / muxers ac3_demuxer_select="ac3_parser" asf_demuxer_select="riffdec" +asf_o_demuxer_select="riffdec" asf_muxer_select="riffenc" asf_stream_muxer_select="asf_muxer" avi_demuxer_select="riffdec exif" @@ -2608,6 +2681,7 @@ x11grab_xcb_indev_deps="libxcb" # protocols +async_protocol_deps="pthreads" bluray_protocol_deps="libbluray" ffrtmpcrypt_protocol_deps="!librtmp_protocol" ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl" @@ -2671,6 +2745,7 @@ delogo_filter_deps="gpl" deshake_filter_select="pixelutils" drawtext_filter_deps="libfreetype" +dynaudnorm_filter_deps="copysign erf" ebur128_filter_deps="gpl" eq_filter_deps="gpl" fftfilt_filter_deps="avcodec" @@ -2800,11 +2875,7 @@ nm_default="nm -g" objformat="elf" pkg_config_default=pkg-config -if ranlib 2>&1 | grep -q "\-D "; then - ranlib_default="ranlib -D" -else - ranlib_default="ranlib" -fi +ranlib_default="ranlib" strip_default="strip" yasmexe_default="yasm" windres_default="windres" @@ -2845,7 +2916,7 @@ set_default sws_max_filter_size # Enable hwaccels by default. -enable d3d11va dxva2 vaapi vda vdpau xvmc +enable d3d11va dxva2 vaapi vda vdpau videotoolbox xvmc enable xlib # build settings @@ -2999,6 +3070,9 @@ --extra-ldexeflags=*) add_ldexeflags $optval ;; + --extra-ldlibflags=*) + add_ldlibflags $optval + ;; --extra-libs=*) add_extralibs $optval ;; @@ -3134,9 +3208,14 @@ else cc_default="c99wrap cl" fi - ld_default="link" + ld_default="$source_path/compat/windows/mslink" nm_default="dumpbin -symbols" ar_default="lib" + case "$arch" in + arm*) + as_default="armasm" + ;; + esac target_os_default="win32" # Use a relative path for TMPDIR. This makes sure all the # ffconf temp files are written with a relative path, avoiding @@ -3178,7 +3257,11 @@ cxx_default="${cross_prefix}${cxx_default}" nm_default="${cross_prefix}${nm_default}" pkg_config_default="${cross_prefix}${pkg_config_default}" -ranlib_default="${cross_prefix}${ranlib_default}" +if ${cross_prefix}${ranlib_default} 2>&1 | grep -q "\-D "; then + ranlib_default="${cross_prefix}${ranlib_default} -D" +else + ranlib_default="${cross_prefix}${ranlib_default}" +fi strip_default="${cross_prefix}${strip_default}" windres_default="${cross_prefix}${windres_default}" @@ -3329,6 +3412,7 @@ -lavifil32) echo vfw32.lib ;; -lavicap32) echo vfw32.lib user32.lib ;; -l*) echo ${flag#-l}.lib ;; + -LARGEADDRESSAWARE) echo $flag ;; -L*) echo -libpath:${flag#-L} ;; *) echo $flag ;; esac @@ -3467,8 +3551,8 @@ true # no-op to avoid reading stdin in following checks elif $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then _type=llvm_gcc - gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)') - _ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver" + gcc_extra_ver=$(expr "$($_cc --version 2>/dev/null | head -n1)" : '.*\((.*)\)') + _ident="llvm-gcc $($_cc -dumpversion 2>/dev/null) $gcc_extra_ver" _depflags='-MMD -MF $(@:.o=.d) -MT $@' _cflags_speed='-O3' _cflags_size='-Os' @@ -3532,7 +3616,7 @@ _flags_filter=tms470_flags elif $_cc -v 2>&1 | grep -q clang; then _type=clang - _ident=$($_cc --version | head -n1) + _ident=$($_cc --version 2>/dev/null | head -n1) _depflags='-MMD -MF $(@:.o=.d) -MT $@' _cflags_speed='-O3' _cflags_size='-Os' @@ -3595,16 +3679,16 @@ _flags='-nologo -Qdiag-error:4044,10157' # -Qvec- -Qsimd- to prevent miscompilation, -GS, fp:precise for consistency # with MSVC which enables it by default. - _cflags='-D_USE_MATH_DEFINES -FIstdlib.h -Dstrtoll=_strtoi64 -Qms0 -Qvec- -Qsimd- -GS -fp:precise' + _cflags='-D_USE_MATH_DEFINES -Qms0 -Qvec- -Qsimd- -GS -fp:precise' disable stripping - elif $_cc 2>&1 | grep -q Microsoft; then + elif $_cc -nologo- 2>&1 | grep -q Microsoft; then _type=msvc _ident=$($_cc 2>&1 | head -n1) _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' _cflags_speed="-O2" _cflags_size="-O1" - if $_cc 2>&1 | grep -q Linker; then + if $_cc -nologo- 2>&1 | grep -q Linker; then _ld_o='-out:$@' else _ld_o='-Fe$@' @@ -3615,7 +3699,7 @@ _ld_lib='lib%.a' _ld_path='-libpath:' _flags='-nologo' - _cflags='-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64' + _cflags='-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS' disable stripping elif $_cc --version 2>/dev/null | grep -q ^cparser; then _type=cparser @@ -3950,7 +4034,7 @@ check_cflags "-mtune=i6400 -mabi=64" check_ldflags "-mabi=64" ;; - loongson3*) + loongson*) disable mipsfpu disable mips32r2 disable mips32r5 @@ -3958,14 +4042,24 @@ disable mipsdspr1 disable mipsdspr2 disable msa - enable local_aligned_8 local_aligned_16 + enable local_aligned_8 local_aligned_16 local_aligned_32 enable simd_align_16 enable fast_64bit enable fast_clz enable fast_cmov enable fast_unaligned disable aligned_stack - cpuflags="-march=loongson3a -mhard-float" + case $cpu in + loongson3*) + cpuflags="-march=loongson3a -mhard-float -fno-expensive-optimizations" + ;; + loongson2e) + cpuflags="-march=loongson2e -mhard-float -fno-expensive-optimizations" + ;; + loongson2f) + cpuflags="-march=loongson2f -mhard-float -fno-expensive-optimizations" + ;; + esac ;; generic) disable mips32r5 @@ -4238,6 +4332,8 @@ else target_os=mingw32 fi + decklink_outdev_extralibs="$decklink_outdev_extralibs -lole32 -loleaut32" + decklink_indev_extralibs="$decklink_indev_extralibs -lole32 -loleaut32" LIBTARGET=i386 if enabled x86_64; then LIBTARGET="i386:x86-64" @@ -4446,8 +4542,19 @@ # in such new versions and producing binaries requiring windows 7.0. # Therefore explicitly set the default to XP unless the user has # set something else on the command line. + # Don't do this if WINAPI_FAMILY is set and is set to a non-desktop + # family. For these cases, configure is free to use any functions + # found in the SDK headers by default. (Alternatively, we could force + # _WIN32_WINNT to 0x0602 in that case.) check_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" || - add_${pfx}cppflags -D_WIN32_WINNT=0x0502 + { check_${pfx}cpp < +#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#error not desktop +#endif +#endif +EOF elif check_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then eval ${pfx}libc_type=klibc elif check_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then @@ -4676,6 +4783,8 @@ elif enabled arm; then + enabled msvc && check_cpp_condition stddef.h "defined _M_ARMT" && enable thumb + check_cpp_condition stddef.h "defined __thumb__" && check_cc <= 30"; then + enable vfp_args elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then case "${cross_prefix:-$cc}" in *hardfloat*) enable vfp_args; fpabi=vfp ;; @@ -4723,11 +4834,15 @@ elif enabled mips; then + enabled loongson2 && check_inline_asm loongson2 '"dmult.g $8, $9, $10"' + enabled loongson3 && check_inline_asm loongson3 '"gsldxc1 $f0, 0($2, $3)"' + enabled mmi && check_inline_asm mmi '"punpcklhw $f0, $f0, $f0"' + # Enable minimum ISA based on selected options if enabled mips64 && (enabled mipsdspr1 || enabled mipsdspr2); then add_cflags "-mips64r2" add_asflags "-mips64r2" - elif enabled mips64 && enabled mipsfpu && disabled loongson3; then + elif enabled mips64 && enabled mipsfpu && disabled loongson2 && disabled loongson3; then add_cflags "-mips64" add_asflags "-mips64" elif enabled mipsdspr1 || enabled mipsdspr2; then @@ -4752,7 +4867,6 @@ check_inline_asm mipsfpu '"madd.d $f0, $f2, $f4, $f6"' enabled msa && check_cflags "-mmsa" && check_ldflags "-mmsa" && check_inline_asm msa '"addvi.b $w0, $w1, 1"' - enabled loongson3 && check_inline_asm loongson3 '"gsldxc1 $f0, 0($2, $3)"' enabled mips32r5 && add_asflags "-mips32r5 -mfp64" enabled mips64r6 && add_asflags "-mips64r6 -mfp64" @@ -4977,6 +5091,7 @@ check_func_headers windows.h MapViewOfFile check_func_headers windows.h PeekNamedPipe check_func_headers windows.h SetConsoleTextAttribute +check_func_headers windows.h SetConsoleCtrlHandler check_func_headers windows.h Sleep check_func_headers windows.h VirtualAlloc check_struct windows.h "CONDITION_VARIABLE" Ptr @@ -5007,6 +5122,7 @@ check_header vdpau/vdpau.h check_header vdpau/vdpau_x11.h check_header VideoDecodeAcceleration/VDADecoder.h +check_header VideoToolbox/VideoToolbox.h check_header windows.h check_header X11/extensions/XvMClib.h check_header asm/types.h @@ -5017,9 +5133,11 @@ check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss -check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" +check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0 check_type "windows.h d3d11.h" "ID3D11VideoDecoder" -check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0600 +check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602 + +check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC" if ! disabled w32threads && ! enabled pthreads; then check_func_headers "windows.h process.h" _beginthreadex && @@ -5062,6 +5180,7 @@ disabled crystalhd || check_lib libcrystalhd/libcrystalhd_if.h DtsCrystalHDVersion -lcrystalhd || disable crystalhd atan2f_args=2 +copysign_args=2 ldexpf_args=2 powf_args=2 @@ -5089,7 +5208,8 @@ { check_lib celt/celt.h celt_decoder_create_custom -lcelt0 || die "ERROR: libcelt must be installed and version must be >= 0.11.0."; } enabled libcaca && require_pkg_config caca caca.h caca_create_canvas -enabled libdcadec && require_pkg_config dcadec libdcadec/dca_context.h dcadec_context_create +enabled libdcadec && require_pkg_config dcadec libdcadec/dca_context.h dcadec_context_create && + check_struct libdcadec/dca_context.h "struct dcadec_exss_info" matrix_encoding enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac enabled libfdk_aac && { use_pkg_config fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen || { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac && @@ -5105,6 +5225,7 @@ check_lib "${gsm_hdr}" gsm_create -lgsm && break; done || die "ERROR: libgsm not found"; } enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc +enabled libkvazaar && require2 libkvazaar kvazaar.h kvz_api_get -lkvazaar enabled libmfx && require_pkg_config libmfx "mfx/mfxvideo.h" MFXInit enabled libmodplug && require_pkg_config libmodplug libmodplug/modplug.h ModPlug_Load enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame @@ -5125,6 +5246,7 @@ enabled libshine && require_pkg_config shine shine/layer3.h shine_encode_buffer enabled libsmbclient && { use_pkg_config smbclient libsmbclient.h smbc_init || require smbclient libsmbclient.h smbc_init -lsmbclient; } +enabled libsnappy && require snappy snappy-c.h snappy_compress -lsnappy enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr enabled libssh && require_pkg_config libssh libssh/sftp.h sftp_init enabled libspeex && require_pkg_config speex speex/speex.h speex_decoder_init -lspeex @@ -5141,13 +5263,33 @@ enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg + enabled libvpx && { - enabled libvpx_vp8_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx || - die "ERROR: libvpx decoder version must be >=0.9.1"; } - enabled libvpx_vp8_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VP8E_SET_MAX_INTRA_BITRATE_PCT" -lvpx || - die "ERROR: libvpx encoder version must be >=0.9.7"; } - enabled libvpx_vp9_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || disable libvpx_vp9_decoder; } - enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VP9E_SET_AQ_MODE" -lvpx || disable libvpx_vp9_encoder; } } + enabled libvpx_vp8_decoder && { + use_pkg_config "vpx >= 0.9.1" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp8_dx || + check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx || + die "ERROR: libvpx decoder version must be >=0.9.1"; + } + enabled libvpx_vp8_encoder && { + use_pkg_config "vpx >= 0.9.7" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp8_cx || + check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VP8E_SET_MAX_INTRA_BITRATE_PCT" -lvpx || + die "ERROR: libvpx encoder version must be >=0.9.7"; + } + enabled libvpx_vp9_decoder && { + use_pkg_config "vpx >= 1.3.0" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx || + check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || + disable libvpx_vp9_decoder; + } + enabled libvpx_vp9_encoder && { + use_pkg_config "vpx >= 1.3.0" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx || + check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VP9E_SET_AQ_MODE" -lvpx || + disable libvpx_vp9_encoder; + } + if disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder libvpx_vp9_encoder; then + die "libvpx enabled but no supported decoders found" + fi +} + enabled libwavpack && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput -lwavpack enabled libwebp && { enabled libwebp_encoder && require_pkg_config "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion @@ -5156,8 +5298,10 @@ { require libx264 x264.h x264_encoder_encode -lx264 && warn "using libx264 without pkg-config"; } } && { check_cpp_condition x264.h "X264_BUILD >= 118" || - die "ERROR: libx264 must be installed and version must be >= 0.118."; } -enabled libx265 && require_pkg_config x265 x265.h x265_encoder_encode && + die "ERROR: libx264 must be installed and version must be >= 0.118."; } && + { check_cpp_condition x264.h "X264_MPEG2" && + enable libx262; } +enabled libx265 && require_pkg_config x265 x265.h x265_api_get && { check_cpp_condition x265.h "X265_BUILD >= 57" || die "ERROR: libx265 version must be >= 57."; } enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs @@ -5394,6 +5538,7 @@ check_ldflags -Wl,--warn-common check_ldflags -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample enabled rpath && add_ldexeflags -Wl,-rpath,$libdir +enabled rpath && add_ldlibflags -Wl,-rpath,$libdir test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic # add some strip flags @@ -5560,8 +5705,30 @@ fi # msvcrt10 x64 incorrectly enables log2, only msvcrt12 (MSVC 2013) onwards actually has log2. check_cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION >= 12" || disable log2 + # The CRT headers contain __declspec(restrict) in a few places, but if redefining + # restrict, this might break. MSVC 2010 and 2012 fail with __declspec(__restrict) + # (as it ends up if the restrict redefine is done before including stdlib.h), while + # MSVC 2013 and newer can handle it fine. + # If this declspec fails, force including stdlib.h before the restrict redefinition + # happens in config.h. + if [ $_restrict != restrict ]; then + check_cc < doc/config.texi print_config ARCH_ "$config_files" $ARCH_LIST diff -Nru ffmpeg-2.7.1~trusty~ppa1/debian/changelog ffmpeg-2.7.2~trusty~ppa1/debian/changelog --- ffmpeg-2.7.1~trusty~ppa1/debian/changelog 2015-06-21 08:16:31.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/debian/changelog 2015-08-05 17:23:18.000000000 +0000 @@ -1,8 +1,8 @@ -ffmpeg (2.7.1~trusty~ppa1) trusty; urgency=medium +ffmpeg (2.7.2~trusty~ppa1) trusty; urgency=medium - * New source, 2.7.1 + * new upstream version - -- Rog131 Sun, 21 Jun 2015 11:16:01 +0300 + -- Alexander Grothe Wed, 05 Aug 2015 19:17:10 +0200 ffmpeg (2.7~trusty~ppa1) trusty; urgency=medium diff -Nru ffmpeg-2.7.1~trusty~ppa1/debian/docs ffmpeg-2.7.2~trusty~ppa1/debian/docs --- ffmpeg-2.7.1~trusty~ppa1/debian/docs 2014-07-20 10:46:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/debian/docs 2015-08-05 17:42:51.000000000 +0000 @@ -7,6 +7,6 @@ LICENSE.md MAINTAINERS RELEASE -RELEASE_NOTES +#RELEASE_NOTES VERSION debian/copyrigh2 diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/APIchanges ffmpeg-2.7.2~trusty~ppa1/doc/APIchanges --- ffmpeg-2.7.1~trusty~ppa1/doc/APIchanges 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/APIchanges 2015-08-02 17:20:02.000000000 +0000 @@ -15,6 +15,29 @@ API changes, most recent first: +2015-xx-xx - lavu 54.30.0 + xxxxxxx - Add av_blowfish_alloc(). + xxxxxxx - Add av_rc4_alloc(). + xxxxxxx - Add av_xtea_alloc(). + xxxxxxx - Add av_des_alloc(). + +2015-xx-xx - lavc 56.35.0 - avcodec.h + xxxxxxxxx - Rename CODEC_FLAG* defines to AV_CODEC_FLAG*. + xxxxxxxxx - Rename CODEC_CAP_* defines to AV_CODEC_CAP_*. + xxxxxxxxx - Rename FF_INPUT_BUFFER_PADDING_SIZE and FF_MIN_BUFFER_SIZE + to AV_INPUT_BUFFER_PADDING_SIZE and AV_INPUT_BUFFER_MIN_SIZE. + +2015-07-22 - c40ecff - lavc 56.51.100 - avcodec.h + Add AV_PKT_DATA_QUALITY_STATS to export the quality value, PSNR, and pict_type + of an AVPacket. + +2015-07-16 - 8dad213 - lavc 56.49.100 + Add av_codec_get_codec_properties(), FF_CODEC_PROPERTY_LOSSLESS + and FF_CODEC_PROPERTY_CLOSED_CAPTIONS + +2015-07-03 - d563e13 / 83212943 - lavu 54.28.100 / 56.15.0 + Add av_version_info(). + -------- 8< --------- FFmpeg 2.7 was cut here -------- 8< --------- 2015-06-04 - cc17b43 - lswr 1.2.100 @@ -692,6 +715,9 @@ av_ripemd_update() av_ripemd_final() +2013-06-10 - 82ef670 - lavu 52.35.101 - hmac.h + Add AV_HMAC_SHA224, AV_HMAC_SHA256, AV_HMAC_SHA384, AV_HMAC_SHA512 + 2013-06-04 - 30b491f / fc962d4 - lavu 52.35.100 / 52.13.0 - mem.h Add av_realloc_array and av_reallocp_array diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/avoptions_codec.texi ffmpeg-2.7.2~trusty~ppa1/doc/avoptions_codec.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/avoptions_codec.texi 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/avoptions_codec.texi 2013-03-12 18:45:53.000000000 +0000 @@ -0,0 +1,902 @@ +@c DO NOT EDIT THIS FILE! +@c It was generated by print_options. + +@section Codec AVOptions +@table @option +@item -b[:stream_specifier] @var{integer} (@emph{output,audio,video}) +set bitrate (in bits/s) +@item -ab[:stream_specifier] @var{integer} (@emph{output,audio}) +set bitrate (in bits/s) +@item -bt[:stream_specifier] @var{integer} (@emph{output,video}) +Set video bitrate tolerance (in bits/s). In 1-pass mode, bitrate tolerance specifies how far ratecontrol is willing to deviate from the target average bitrate value. This is not related to minimum/maximum bitrate. Lowering tolerance too much has an adverse effect on quality. +@item -flags[:stream_specifier] @var{flags} (@emph{input/output,audio,video,subtitles}) + +Possible values: +@table @samp +@item mv4 +use four motion vectors per macroblock (MPEG-4) +@item qpel +use 1/4-pel motion compensation +@item loop +use loop filter +@item qscale +use fixed qscale +@item gmc +use gmc +@item mv0 +always try a mb with mv=<0,0> +@item input_preserved + +@item pass1 +use internal 2-pass ratecontrol in first pass mode +@item pass2 +use internal 2-pass ratecontrol in second pass mode +@item gray +only decode/encode grayscale +@item emu_edge +do not draw edges +@item psnr +error[?] variables will be set during encoding +@item truncated + +@item naq +normalize adaptive quantization +@item ildct +use interlaced DCT +@item low_delay +force low delay +@item global_header +place global headers in extradata instead of every keyframe +@item bitexact +use only bitexact functions (except (I)DCT) +@item aic +H.263 advanced intra coding / MPEG-4 AC prediction +@item ilme +interlaced motion estimation +@item cgop +closed GOP +@end table +@item -me_method[:stream_specifier] @var{integer} (@emph{output,video}) +set motion estimation method + +Possible values: +@table @samp +@item zero +zero motion estimation (fastest) +@item full +full motion estimation (slowest) +@item epzs +EPZS motion estimation (default) +@item esa +esa motion estimation (alias for full) +@item tesa +tesa motion estimation +@item dia +diamond motion estimation (alias for EPZS) +@item log +log motion estimation +@item phods +phods motion estimation +@item x1 +X1 motion estimation +@item hex +hex motion estimation +@item umh +umh motion estimation +@item iter +iter motion estimation +@end table +@item -extradata_size[:stream_specifier] @var{integer} (@emph{}) +@item -time_base[:stream_specifier] @var{rational number} (@emph{}) +@item -g[:stream_specifier] @var{integer} (@emph{output,video}) +set the group of picture (GOP) size +@item -ar[:stream_specifier] @var{integer} (@emph{input/output,audio}) +set audio sampling rate (in Hz) +@item -ac[:stream_specifier] @var{integer} (@emph{input/output,audio}) +set number of audio channels +@item -cutoff[:stream_specifier] @var{integer} (@emph{output,audio}) +set cutoff bandwidth +@item -frame_size[:stream_specifier] @var{integer} (@emph{output,audio}) +@item -frame_number[:stream_specifier] @var{integer} (@emph{}) +@item -delay[:stream_specifier] @var{integer} (@emph{}) +@item -qcomp[:stream_specifier] @var{float} (@emph{output,video}) +video quantizer scale compression (VBR). Constant of ratecontrol equation. Recommended range for default rc_eq: 0.0-1.0 +@item -qblur[:stream_specifier] @var{float} (@emph{output,video}) +video quantizer scale blur (VBR) +@item -qmin[:stream_specifier] @var{integer} (@emph{output,video}) +minimum video quantizer scale (VBR) +@item -qmax[:stream_specifier] @var{integer} (@emph{output,video}) +maximum video quantizer scale (VBR) +@item -qdiff[:stream_specifier] @var{integer} (@emph{output,video}) +maximum difference between the quantizer scales (VBR) +@item -bf[:stream_specifier] @var{integer} (@emph{output,video}) +use 'frames' B frames +@item -b_qfactor[:stream_specifier] @var{float} (@emph{output,video}) +QP factor between P- and B-frames +@item -rc_strategy[:stream_specifier] @var{integer} (@emph{output,video}) +ratecontrol method +@item -b_strategy[:stream_specifier] @var{integer} (@emph{output,video}) +strategy to choose between I/P/B-frames +@item -ps[:stream_specifier] @var{integer} (@emph{output,video}) +RTP payload size in bytes +@item -mv_bits[:stream_specifier] @var{integer} (@emph{}) +@item -header_bits[:stream_specifier] @var{integer} (@emph{}) +@item -i_tex_bits[:stream_specifier] @var{integer} (@emph{}) +@item -p_tex_bits[:stream_specifier] @var{integer} (@emph{}) +@item -i_count[:stream_specifier] @var{integer} (@emph{}) +@item -p_count[:stream_specifier] @var{integer} (@emph{}) +@item -skip_count[:stream_specifier] @var{integer} (@emph{}) +@item -misc_bits[:stream_specifier] @var{integer} (@emph{}) +@item -frame_bits[:stream_specifier] @var{integer} (@emph{}) +@item -codec_tag[:stream_specifier] @var{integer} (@emph{}) +@item -bug[:stream_specifier] @var{flags} (@emph{input,video}) +work around not autodetected encoder bugs + +Possible values: +@table @samp +@item autodetect + +@item old_msmpeg4 +some old lavc-generated MSMPEG4v3 files (no autodetection) +@item xvid_ilace +Xvid interlacing bug (autodetected if FOURCC == XVIX) +@item ump4 +(autodetected if FOURCC == UMP4) +@item no_padding +padding bug (autodetected) +@item amv + +@item ac_vlc +illegal VLC bug (autodetected per FOURCC) +@item qpel_chroma + +@item std_qpel +old standard qpel (autodetected per FOURCC/version) +@item qpel_chroma2 + +@item direct_blocksize +direct-qpel-blocksize bug (autodetected per FOURCC/version) +@item edge +edge padding bug (autodetected per FOURCC/version) +@item hpel_chroma + +@item dc_clip + +@item ms +work around various bugs in Microsoft's broken decoders +@item trunc +truncated frames +@end table +@item -strict[:stream_specifier] @var{integer} (@emph{input/output,audio,video}) +how strictly to follow the standards + +Possible values: +@table @samp +@item very +strictly conform to a older more strict version of the spec or reference software +@item strict +strictly conform to all the things in the spec no matter what the consequences +@item normal + +@item unofficial +allow unofficial extensions +@item experimental +allow non-standardized experimental things +@end table +@item -b_qoffset[:stream_specifier] @var{float} (@emph{output,video}) +QP offset between P- and B-frames +@item -err_detect[:stream_specifier] @var{flags} (@emph{input,audio,video}) +set error detection flags + +Possible values: +@table @samp +@item crccheck +verify embedded CRCs +@item bitstream +detect bitstream specification deviations +@item buffer +detect improper bitstream length +@item explode +abort decoding on minor error detection +@item careful +consider things that violate the spec and have not been seen in the wild as errors +@item compliant +consider all spec non compliancies as errors +@item aggressive +consider things that a sane encoder should not do as an error +@end table +@item -has_b_frames[:stream_specifier] @var{integer} (@emph{}) +@item -block_align[:stream_specifier] @var{integer} (@emph{}) +@item -mpeg_quant[:stream_specifier] @var{integer} (@emph{output,video}) +use MPEG quantizers instead of H.263 +@item -qsquish[:stream_specifier] @var{float} (@emph{output,video}) +how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function) +@item -rc_qmod_amp[:stream_specifier] @var{float} (@emph{output,video}) +experimental quantizer modulation +@item -rc_qmod_freq[:stream_specifier] @var{integer} (@emph{output,video}) +experimental quantizer modulation +@item -rc_override_count[:stream_specifier] @var{integer} (@emph{}) +@item -rc_eq[:stream_specifier] @var{string} (@emph{output,video}) +Set rate control equation. When computing the expression, besides the standard functions defined in the section 'Expression Evaluation', the following functions are available: bits2qp(bits), qp2bits(qp). Also the following constants are available: iTex pTex tex mv fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex avgTex. +@item -maxrate[:stream_specifier] @var{integer} (@emph{output,audio,video}) +Set maximum bitrate tolerance (in bits/s). Requires bufsize to be set. +@item -minrate[:stream_specifier] @var{integer} (@emph{output,audio,video}) +Set minimum bitrate tolerance (in bits/s). Most useful in setting up a CBR encode. It is of little use otherwise. +@item -bufsize[:stream_specifier] @var{integer} (@emph{output,audio,video}) +set ratecontrol buffer size (in bits) +@item -rc_buf_aggressivity[:stream_specifier] @var{float} (@emph{output,video}) +currently useless +@item -i_qfactor[:stream_specifier] @var{float} (@emph{output,video}) +QP factor between P- and I-frames +@item -i_qoffset[:stream_specifier] @var{float} (@emph{output,video}) +QP offset between P- and I-frames +@item -rc_init_cplx[:stream_specifier] @var{float} (@emph{output,video}) +initial complexity for 1-pass encoding +@item -dct[:stream_specifier] @var{integer} (@emph{output,video}) +DCT algorithm + +Possible values: +@table @samp +@item auto +autoselect a good one (default) +@item fastint +fast integer +@item int +accurate integer +@item mmx + +@item altivec + +@item faan +floating point AAN DCT +@end table +@item -lumi_mask[:stream_specifier] @var{float} (@emph{output,video}) +compresses bright areas stronger than medium ones +@item -tcplx_mask[:stream_specifier] @var{float} (@emph{output,video}) +temporal complexity masking +@item -scplx_mask[:stream_specifier] @var{float} (@emph{output,video}) +spatial complexity masking +@item -p_mask[:stream_specifier] @var{float} (@emph{output,video}) +inter masking +@item -dark_mask[:stream_specifier] @var{float} (@emph{output,video}) +compresses dark areas stronger than medium ones +@item -idct[:stream_specifier] @var{integer} (@emph{input/output,video}) +select IDCT implementation + +Possible values: +@table @samp +@item auto + +@item int + +@item simple + +@item simplemmx + +@item libmpeg2mmx + +@item arm + +@item altivec + +@item sh4 + +@item simplearm + +@item simplearmv5te + +@item simplearmv6 + +@item simpleneon + +@item simplealpha + +@item ipp + +@item xvidmmx + +@item faani +floating point AAN IDCT +@end table +@item -slice_count[:stream_specifier] @var{integer} (@emph{}) +@item -ec[:stream_specifier] @var{flags} (@emph{input,video}) +set error concealment strategy + +Possible values: +@table @samp +@item guess_mvs +iterative motion vector (MV) search (slow) +@item deblock +use strong deblock filter for damaged MBs +@end table +@item -bits_per_coded_sample[:stream_specifier] @var{integer} (@emph{}) +@item -pred[:stream_specifier] @var{integer} (@emph{output,video}) +prediction method + +Possible values: +@table @samp +@item left + +@item plane + +@item median + +@end table +@item -aspect[:stream_specifier] @var{rational number} (@emph{output,video}) +sample aspect ratio +@item -debug[:stream_specifier] @var{flags} (@emph{input/output,audio,video,subtitles}) +print specific debug info + +Possible values: +@table @samp +@item pict +picture info +@item rc +rate control +@item bitstream + +@item mb_type +macroblock (MB) type +@item qp +per-block quantization parameter (QP) +@item mv +motion vector +@item dct_coeff + +@item skip + +@item startcode + +@item pts + +@item er +error recognition +@item mmco +memory management control operations (H.264) +@item bugs + +@item vis_qp +visualize quantization parameter (QP), lower QP are tinted greener +@item vis_mb_type +visualize block types +@item buffers +picture buffer allocations +@item thread_ops +threading operations +@end table +@item -vismv[:stream_specifier] @var{integer} (@emph{input,video}) +visualize motion vectors (MVs) + +Possible values: +@table @samp +@item pf +forward predicted MVs of P-frames +@item bf +forward predicted MVs of B-frames +@item bb +backward predicted MVs of B-frames +@end table +@item -cmp[:stream_specifier] @var{integer} (@emph{output,video}) +full-pel ME compare function + +Possible values: +@table @samp +@item sad +sum of absolute differences, fast (default) +@item sse +sum of squared errors +@item satd +sum of absolute Hadamard transformed differences +@item dct +sum of absolute DCT transformed differences +@item psnr +sum of squared quantization errors (avoid, low quality) +@item bit +number of bits needed for the block +@item rd +rate distortion optimal, slow +@item zero +0 +@item vsad +sum of absolute vertical differences +@item vsse +sum of squared vertical differences +@item nsse +noise preserving sum of squared differences +@item w53 +5/3 wavelet, only used in snow +@item w97 +9/7 wavelet, only used in snow +@item dctmax + +@item chroma + +@end table +@item -subcmp[:stream_specifier] @var{integer} (@emph{output,video}) +sub-pel ME compare function + +Possible values: +@table @samp +@item sad +sum of absolute differences, fast (default) +@item sse +sum of squared errors +@item satd +sum of absolute Hadamard transformed differences +@item dct +sum of absolute DCT transformed differences +@item psnr +sum of squared quantization errors (avoid, low quality) +@item bit +number of bits needed for the block +@item rd +rate distortion optimal, slow +@item zero +0 +@item vsad +sum of absolute vertical differences +@item vsse +sum of squared vertical differences +@item nsse +noise preserving sum of squared differences +@item w53 +5/3 wavelet, only used in snow +@item w97 +9/7 wavelet, only used in snow +@item dctmax + +@item chroma + +@end table +@item -mbcmp[:stream_specifier] @var{integer} (@emph{output,video}) +macroblock compare function + +Possible values: +@table @samp +@item sad +sum of absolute differences, fast (default) +@item sse +sum of squared errors +@item satd +sum of absolute Hadamard transformed differences +@item dct +sum of absolute DCT transformed differences +@item psnr +sum of squared quantization errors (avoid, low quality) +@item bit +number of bits needed for the block +@item rd +rate distortion optimal, slow +@item zero +0 +@item vsad +sum of absolute vertical differences +@item vsse +sum of squared vertical differences +@item nsse +noise preserving sum of squared differences +@item w53 +5/3 wavelet, only used in snow +@item w97 +9/7 wavelet, only used in snow +@item dctmax + +@item chroma + +@end table +@item -ildctcmp[:stream_specifier] @var{integer} (@emph{output,video}) +interlaced DCT compare function + +Possible values: +@table @samp +@item sad +sum of absolute differences, fast (default) +@item sse +sum of squared errors +@item satd +sum of absolute Hadamard transformed differences +@item dct +sum of absolute DCT transformed differences +@item psnr +sum of squared quantization errors (avoid, low quality) +@item bit +number of bits needed for the block +@item rd +rate distortion optimal, slow +@item zero +0 +@item vsad +sum of absolute vertical differences +@item vsse +sum of squared vertical differences +@item nsse +noise preserving sum of squared differences +@item w53 +5/3 wavelet, only used in snow +@item w97 +9/7 wavelet, only used in snow +@item dctmax + +@item chroma + +@end table +@item -dia_size[:stream_specifier] @var{integer} (@emph{output,video}) +diamond type & size for motion estimation +@item -last_pred[:stream_specifier] @var{integer} (@emph{output,video}) +amount of motion predictors from the previous frame +@item -preme[:stream_specifier] @var{integer} (@emph{output,video}) +pre motion estimation +@item -precmp[:stream_specifier] @var{integer} (@emph{output,video}) +pre motion estimation compare function + +Possible values: +@table @samp +@item sad +sum of absolute differences, fast (default) +@item sse +sum of squared errors +@item satd +sum of absolute Hadamard transformed differences +@item dct +sum of absolute DCT transformed differences +@item psnr +sum of squared quantization errors (avoid, low quality) +@item bit +number of bits needed for the block +@item rd +rate distortion optimal, slow +@item zero +0 +@item vsad +sum of absolute vertical differences +@item vsse +sum of squared vertical differences +@item nsse +noise preserving sum of squared differences +@item w53 +5/3 wavelet, only used in snow +@item w97 +9/7 wavelet, only used in snow +@item dctmax + +@item chroma + +@end table +@item -pre_dia_size[:stream_specifier] @var{integer} (@emph{output,video}) +diamond type & size for motion estimation pre-pass +@item -subq[:stream_specifier] @var{integer} (@emph{output,video}) +sub-pel motion estimation quality +@item -dtg_active_format[:stream_specifier] @var{integer} (@emph{}) +@item -me_range[:stream_specifier] @var{integer} (@emph{output,video}) +limit motion vectors range (1023 for DivX player) +@item -ibias[:stream_specifier] @var{integer} (@emph{output,video}) +intra quant bias +@item -pbias[:stream_specifier] @var{integer} (@emph{output,video}) +inter quant bias +@item -global_quality[:stream_specifier] @var{integer} (@emph{output,audio,video}) +@item -coder[:stream_specifier] @var{integer} (@emph{output,video}) + +Possible values: +@table @samp +@item vlc +variable length coder / Huffman coder +@item ac +arithmetic coder +@item raw +raw (no encoding) +@item rle +run-length coder +@item deflate +deflate-based coder +@end table +@item -context[:stream_specifier] @var{integer} (@emph{output,video}) +context model +@item -slice_flags[:stream_specifier] @var{integer} (@emph{}) +@item -xvmc_acceleration[:stream_specifier] @var{integer} (@emph{}) +@item -mbd[:stream_specifier] @var{integer} (@emph{output,video}) +macroblock decision algorithm (high quality mode) + +Possible values: +@table @samp +@item simple +use mbcmp (default) +@item bits +use fewest bits +@item rd +use best rate distortion +@end table +@item -stream_codec_tag[:stream_specifier] @var{integer} (@emph{}) +@item -sc_threshold[:stream_specifier] @var{integer} (@emph{output,video}) +scene change threshold +@item -lmin[:stream_specifier] @var{integer} (@emph{output,video}) +minimum Lagrange factor (VBR) +@item -lmax[:stream_specifier] @var{integer} (@emph{output,video}) +maximum Lagrange factor (VBR) +@item -nr[:stream_specifier] @var{integer} (@emph{output,video}) +noise reduction +@item -rc_init_occupancy[:stream_specifier] @var{integer} (@emph{output,video}) +number of bits which should be loaded into the rc buffer before decoding starts +@item -flags2[:stream_specifier] @var{flags} (@emph{input/output,audio,video}) + +Possible values: +@table @samp +@item fast +allow non-spec-compliant speedup tricks +@item noout +skip bitstream encoding +@item ignorecrop +ignore cropping information from sps +@item local_header +place global headers at every keyframe instead of in extradata +@item chunks +Frame data might be split into multiple chunks +@item showall +Show all frames before the first keyframe +@end table +@item -error[:stream_specifier] @var{integer} (@emph{output,video}) +@item -threads[:stream_specifier] @var{integer} (@emph{input/output,video}) + +Possible values: +@table @samp +@item auto +autodetect a suitable number of threads to use +@end table +@item -me_threshold[:stream_specifier] @var{integer} (@emph{output,video}) +motion estimation threshold +@item -mb_threshold[:stream_specifier] @var{integer} (@emph{output,video}) +macroblock threshold +@item -dc[:stream_specifier] @var{integer} (@emph{output,video}) +intra_dc_precision +@item -nssew[:stream_specifier] @var{integer} (@emph{output,video}) +nsse weight +@item -skip_top[:stream_specifier] @var{integer} (@emph{input,video}) +number of macroblock rows at the top which are skipped +@item -skip_bottom[:stream_specifier] @var{integer} (@emph{input,video}) +number of macroblock rows at the bottom which are skipped +@item -profile[:stream_specifier] @var{integer} (@emph{output,audio,video}) + +Possible values: +@table @samp +@item unknown + +@item aac_main + +@item aac_low + +@item aac_ssr + +@item aac_ltp + +@item aac_he + +@item aac_he_v2 + +@item aac_ld + +@item aac_eld + +@item dts + +@item dts_es + +@item dts_96_24 + +@item dts_hd_hra + +@item dts_hd_ma + +@end table +@item -level[:stream_specifier] @var{integer} (@emph{output,audio,video}) + +Possible values: +@table @samp +@item unknown + +@end table +@item -lowres[:stream_specifier] @var{integer} (@emph{input,audio,video}) +decode at 1= 1/2, 2=1/4, 3=1/8 resolutions +@item -skip_threshold[:stream_specifier] @var{integer} (@emph{output,video}) +frame skip threshold +@item -skip_factor[:stream_specifier] @var{integer} (@emph{output,video}) +frame skip factor +@item -skip_exp[:stream_specifier] @var{integer} (@emph{output,video}) +frame skip exponent +@item -skipcmp[:stream_specifier] @var{integer} (@emph{output,video}) +frame skip compare function + +Possible values: +@table @samp +@item sad +sum of absolute differences, fast (default) +@item sse +sum of squared errors +@item satd +sum of absolute Hadamard transformed differences +@item dct +sum of absolute DCT transformed differences +@item psnr +sum of squared quantization errors (avoid, low quality) +@item bit +number of bits needed for the block +@item rd +rate distortion optimal, slow +@item zero +0 +@item vsad +sum of absolute vertical differences +@item vsse +sum of squared vertical differences +@item nsse +noise preserving sum of squared differences +@item w53 +5/3 wavelet, only used in snow +@item w97 +9/7 wavelet, only used in snow +@item dctmax + +@item chroma + +@end table +@item -border_mask[:stream_specifier] @var{float} (@emph{output,video}) +increase the quantizer for macroblocks close to borders +@item -mblmin[:stream_specifier] @var{integer} (@emph{output,video}) +minimum macroblock Lagrange factor (VBR) +@item -mblmax[:stream_specifier] @var{integer} (@emph{output,video}) +maximum macroblock Lagrange factor (VBR) +@item -mepc[:stream_specifier] @var{integer} (@emph{output,video}) +motion estimation bitrate penalty compensation (1.0 = 256) +@item -skip_loop_filter[:stream_specifier] @var{integer} (@emph{input,video}) + +Possible values: +@table @samp +@item none + +@item default + +@item noref + +@item bidir + +@item nokey + +@item all + +@end table +@item -skip_idct[:stream_specifier] @var{integer} (@emph{input,video}) + +Possible values: +@table @samp +@item none + +@item default + +@item noref + +@item bidir + +@item nokey + +@item all + +@end table +@item -skip_frame[:stream_specifier] @var{integer} (@emph{input,video}) + +Possible values: +@table @samp +@item none + +@item default + +@item noref + +@item bidir + +@item nokey + +@item all + +@end table +@item -bidir_refine[:stream_specifier] @var{integer} (@emph{output,video}) +refine the two motion vectors used in bidirectional macroblocks +@item -brd_scale[:stream_specifier] @var{integer} (@emph{output,video}) +downscale frames for dynamic B-frame decision +@item -keyint_min[:stream_specifier] @var{integer} (@emph{output,video}) +minimum interval between IDR-frames +@item -refs[:stream_specifier] @var{integer} (@emph{output,video}) +reference frames to consider for motion compensation +@item -chromaoffset[:stream_specifier] @var{integer} (@emph{output,video}) +chroma QP offset from luma +@item -trellis[:stream_specifier] @var{integer} (@emph{output,audio,video}) +rate-distortion optimal quantization +@item -sc_factor[:stream_specifier] @var{integer} (@emph{output,video}) +multiplied by qscale for each frame and added to scene_change_score +@item -mv0_threshold[:stream_specifier] @var{integer} (@emph{output,video}) +@item -b_sensitivity[:stream_specifier] @var{integer} (@emph{output,video}) +adjust sensitivity of b_frame_strategy 1 +@item -compression_level[:stream_specifier] @var{integer} (@emph{output,audio,video}) +@item -min_prediction_order[:stream_specifier] @var{integer} (@emph{output,audio}) +@item -max_prediction_order[:stream_specifier] @var{integer} (@emph{output,audio}) +@item -timecode_frame_start[:stream_specifier] @var{integer} (@emph{output,video}) +GOP timecode frame start number, in non-drop-frame format +@item -request_channels[:stream_specifier] @var{integer} (@emph{input,audio}) +set desired number of audio channels +@item -bits_per_raw_sample[:stream_specifier] @var{integer} (@emph{}) +@item -channel_layout[:stream_specifier] @var{integer} (@emph{input/output,audio}) + +Possible values: +@table @samp +@end table +@item -request_channel_layout[:stream_specifier] @var{integer} (@emph{input,audio}) + +Possible values: +@table @samp +@end table +@item -rc_max_vbv_use[:stream_specifier] @var{float} (@emph{output,video}) +@item -rc_min_vbv_use[:stream_specifier] @var{float} (@emph{output,video}) +@item -ticks_per_frame[:stream_specifier] @var{integer} (@emph{input/output,audio,video}) +@item -color_primaries[:stream_specifier] @var{integer} (@emph{input/output,video}) +@item -color_trc[:stream_specifier] @var{integer} (@emph{input/output,video}) +@item -colorspace[:stream_specifier] @var{integer} (@emph{input/output,video}) +@item -color_range[:stream_specifier] @var{integer} (@emph{input/output,video}) +@item -chroma_sample_location[:stream_specifier] @var{integer} (@emph{input/output,video}) +@item -log_level_offset[:stream_specifier] @var{integer} (@emph{}) +set the log level offset +@item -slices[:stream_specifier] @var{integer} (@emph{output,video}) +number of slices, used in parallelized encoding +@item -thread_type[:stream_specifier] @var{flags} (@emph{input/output,video}) +select multithreading type + +Possible values: +@table @samp +@item slice + +@item frame + +@end table +@item -audio_service_type[:stream_specifier] @var{integer} (@emph{output,audio}) +audio service type + +Possible values: +@table @samp +@item ma +Main Audio Service +@item ef +Effects +@item vi +Visually Impaired +@item hi +Hearing Impaired +@item di +Dialogue +@item co +Commentary +@item em +Emergency +@item vo +Voice Over +@item ka +Karaoke +@end table +@item -request_sample_fmt[:stream_specifier] @var{value} (@emph{input,audio}) +sample format audio decoders should prefer + +Possible values: +@table @samp +@end table +@item -pkt_timebase[:stream_specifier] @var{rational number} (@emph{}) +@item -sub_charenc[:stream_specifier] @var{string} (@emph{input,subtitles}) +set input text subtitles character encoding +@item -sub_charenc_mode[:stream_specifier] @var{flags} (@emph{input,subtitles}) +set input text subtitles character encoding mode + +Possible values: +@table @samp +@item do_nothing + +@item auto + +@item pre_decoder + +@end table +@item -refcounted_frames[:stream_specifier] @var{integer} (@emph{input,audio,video}) +@end table diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/avoptions_format.texi ffmpeg-2.7.2~trusty~ppa1/doc/avoptions_format.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/avoptions_format.texi 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/avoptions_format.texi 2013-03-12 18:45:53.000000000 +0000 @@ -0,0 +1,118 @@ +@c DO NOT EDIT THIS FILE! +@c It was generated by print_options. + +@section Format AVOptions +@table @option +@item -avioflags @var{flags} (@emph{input/output}) + +Possible values: +@table @samp +@item direct +reduce buffering +@end table +@item -probesize @var{integer} (@emph{input}) +set probing size +@item -packetsize @var{integer} (@emph{output}) +set packet size +@item -fflags @var{flags} (@emph{input/output}) + +Possible values: +@table @samp +@item ignidx +ignore index +@item genpts +generate pts +@item nofillin +do not fill in missing values that can be exactly calculated +@item noparse +disable AVParsers, this needs nofillin too +@item igndts +ignore dts +@item discardcorrupt +discard corrupted frames +@item sortdts +try to interleave outputted packets by dts +@item keepside +dont merge side data +@item latm +enable RTP MP4A-LATM payload +@item nobuffer +reduce the latency introduced by optional buffering +@end table +@item -seek2any @var{integer} (@emph{input}) +forces seeking to enable seek to any mode +@item -analyzeduration @var{integer} (@emph{input}) +specify how many microseconds are analyzed to probe the input +@item -cryptokey @var{hexadecimal string} (@emph{input}) +decryption key +@item -indexmem @var{integer} (@emph{input}) +max memory used for timestamp index (per stream) +@item -rtbufsize @var{integer} (@emph{input}) +max memory used for buffering real-time frames +@item -fdebug @var{flags} (@emph{input/output}) +print specific debug info + +Possible values: +@table @samp +@item ts + +@end table +@item -max_delay @var{integer} (@emph{input/output}) +maximum muxing or demuxing delay in microseconds +@item -fpsprobesize @var{integer} (@emph{input}) +number of frames used to probe fps +@item -audio_preload @var{integer} (@emph{output}) +microseconds by which audio packets should be interleaved earlier +@item -chunk_duration @var{integer} (@emph{output}) +microseconds for each chunk +@item -chunk_size @var{integer} (@emph{output}) +size in bytes for each chunk +@item -f_err_detect @var{flags} (@emph{input}) +set error detection flags (deprecated; use err_detect, save via avconv) + +Possible values: +@table @samp +@item crccheck +verify embedded CRCs +@item bitstream +detect bitstream specification deviations +@item buffer +detect improper bitstream length +@item explode +abort decoding on minor error detection +@item careful +consider things that violate the spec and have not been seen in the wild as errors +@item compliant +consider all spec non compliancies as errors +@item aggressive +consider things that a sane encoder shouldnt do as an error +@end table +@item -err_detect @var{flags} (@emph{input}) +set error detection flags + +Possible values: +@table @samp +@item crccheck +verify embedded CRCs +@item bitstream +detect bitstream specification deviations +@item buffer +detect improper bitstream length +@item explode +abort decoding on minor error detection +@item careful +consider things that violate the spec and have not been seen in the wild as errors +@item compliant +consider all spec non compliancies as errors +@item aggressive +consider things that a sane encoder shouldnt do as an error +@end table +@item -use_wallclock_as_timestamps @var{integer} (@emph{input}) +use wallclock as timestamps +@item -avoid_negative_ts @var{integer} (@emph{output}) +shift timestamps to make them positive. 1 enables, 0 disables, default of -1 enables when required by target format. +@item -skip_initial_bytes @var{integer} (@emph{input}) +skip initial bytes +@item -correct_ts_overflow @var{integer} (@emph{input}) +correct single timestamp overflows +@end table diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/codecs.texi ffmpeg-2.7.2~trusty~ppa1/doc/codecs.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/codecs.texi 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/codecs.texi 2015-07-01 17:20:03.000000000 +0000 @@ -475,6 +475,9 @@ motion vector @item dct_coeff +@item green_metadata +display complexity metadata for the upcoming frame, GoP or for a given duration. + @item skip @item startcode diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/config.texi ffmpeg-2.7.2~trusty~ppa1/doc/config.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/config.texi 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/config.texi 2015-08-04 17:21:01.000000000 +0000 @@ -0,0 +1,9 @@ +@set config-avcodec yes +@set config-avdevice yes +@set config-avfilter yes +@set config-avformat yes +@set config-avresample yes +@set config-avutil yes +@set config-postproc yes +@set config-swresample yes +@set config-swscale yes diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/decoders.texi ffmpeg-2.7.2~trusty~ppa1/doc/decoders.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/decoders.texi 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/decoders.texi 2015-08-04 17:20:03.000000000 +0000 @@ -25,6 +25,13 @@ A description of some of the currently available video decoders follows. +@section hevc + +HEVC / H.265 decoder. + +Note: the @option{skip_loop_filter} option has effect only at level +@code{all}. + @section rawvideo Raw video decoder. @@ -188,6 +195,25 @@ @chapter Subtitles Decoders @c man begin SUBTILES DECODERS +@section dvbsub + +@subsection Options + +@table @option +@item compute_clut +@table @option +@item -1 +Compute clut if no matching CLUT is in the stream. +@item 0 +Never compute CLUT +@item 1 +Always compute CLUT and override the one provided in the stream. +@end table +@item dvb_substream +Selects the dvb substream, or all substreams if -1 which is default. + +@end table + @section dvdsub This codec decodes the bitmap subtitles used in DVDs; the same subtitles can diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/demuxers.texi ffmpeg-2.7.2~trusty~ppa1/doc/demuxers.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/demuxers.texi 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/demuxers.texi 2015-07-17 17:20:02.000000000 +0000 @@ -112,6 +112,47 @@ If the duration is set for all files, then it is possible to seek in the whole concatenated video. +@item @code{inpoint @var{timestamp}} +In point of the file. When the demuxer opens the file it instantly seeks to the +specified timestamp. Seeking is done so that all streams can be presented +successfully at In point. + +This directive works best with intra frame codecs, because for non-intra frame +ones you will usually get extra packets before the actual In point and the +decoded content will most likely contain frames before In point too. + +For each file, packets before the file In point will have timestamps less than +the calculated start timestamp of the file (negative in case of the first +file), and the duration of the files (if not specified by the @code{duration} +directive) will be reduced based on their specified In point. + +Because of potential packets before the specified In point, packet timestamps +may overlap between two concatenated files. + +@item @code{outpoint @var{timestamp}} +Out point of the file. When the demuxer reaches the specified decoding +timestamp in any of the streams, it handles it as an end of file condition and +skips the current and all the remaining packets from all streams. + +Out point is exclusive, which means that the demuxer will not output packets +with a decoding timestamp greater or equal to Out point. + +This directive works best with intra frame codecs and formats where all streams +are tightly interleaved. For non-intra frame codecs you will usually get +additional packets with presentation timestamp after Out point therefore the +decoded content will most likely contain frames after Out point too. If your +streams are not tightly interleaved you may not get all the packets from all +streams before Out point and you may only will be able to decode the earliest +stream until Out point. + +The duration of the files (if not specified by the @code{duration} +directive) will be reduced based on their specified Out point. + +@item @code{file_packet_metadata @var{key=value}} +Metadata of the packets of the file. The specified metadata will be set for +each file packet. You can specify this directive multiple times to add multiple +metadata entries. + @item @code{stream} Introduce a stream in the virtual file. All subsequent stream-related directives apply to the last introduced diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/developer.texi ffmpeg-2.7.2~trusty~ppa1/doc/developer.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/developer.texi 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/developer.texi 2015-07-19 17:20:03.000000000 +0000 @@ -544,6 +544,10 @@ amounts of memory when fed damaged data. @item +Did you test your decoder or demuxer against sample files? +Samples may be obtained at @url{http://samples.ffmpeg.org}. + +@item Does the patch not mix functional and cosmetic changes? @item diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/Doxyfile ffmpeg-2.7.2~trusty~ppa1/doc/Doxyfile --- ffmpeg-2.7.1~trusty~ppa1/doc/Doxyfile 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/Doxyfile 2015-06-10 17:20:02.000000000 +0000 @@ -31,7 +31,7 @@ # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 2.7.1 +PROJECT_NUMBER = # With the PROJECT_LOGO tag one can specify a logo or icon that is included # in the documentation. The maximum height of the logo should not exceed 55 diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/encoders.texi ffmpeg-2.7.2~trusty~ppa1/doc/encoders.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/encoders.texi 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/encoders.texi 2015-07-15 17:20:03.000000000 +0000 @@ -1342,6 +1342,21 @@ A description of some of the currently available video encoders follows. +@section jpeg2000 + +The native jpeg 2000 encoder is lossy by default, the @code{-q:v} +option can be used to set the encoding quality. Lossless encoding +can be selected with @code{-pred 1}. + +@subsection Options + +@table @option +@item format +Can be set to either @code{j2k} or @code{jp2} (the default) that +allows to store non-rgb pix_fmts. + +@end table + @section libtheora libtheora Theora encoder wrapper. @@ -1416,113 +1431,153 @@ @subsection Options -Mapping from FFmpeg to libvpx options with conversion notes in parentheses. +The following options are supported by the libvpx wrapper. The +@command{vpxenc}-equivalent options or values are listed in parentheses +for easy migration. -@table @option +To reduce the duplication of documentation, only the private options +and some others requiring special attention are documented here. For +the documentation of the undocumented generic options, see +@ref{codec-options,,the Codec Options chapter}. -@item threads -g_threads +To get more documentation of the libvpx options, invoke the command +@command{ffmpeg -h encoder=libvpx}, @command{ffmpeg -h encoder=libvpx-vp9} or +@command{vpxenc --help}. Further information is available in the libvpx API +documentation. -@item profile -g_profile +@table @option -@item vb -rc_target_bitrate +@item b (@emph{target-bitrate}) +Set bitrate in bits/s. Note that FFmpeg's @option{b} option is +expressed in bits/s, while @command{vpxenc}'s @option{target-bitrate} is in +kilobits/s. -@item g -kf_max_dist +@item g (@emph{kf-max-dist}) -@item keyint_min -kf_min_dist +@item keyint_min (@emph{kf-min-dist}) -@item qmin -rc_min_quantizer +@item qmin (@emph{min-q}) -@item qmax -rc_max_quantizer +@item qmax (@emph{max-q}) -@item bufsize, vb -rc_buf_sz -@code{(bufsize * 1000 / vb)} +@item bufsize (@emph{buf-sz}, @emph{buf-optimal-sz}) +Set ratecontrol buffer size (in bits). Note @command{vpxenc}'s options are +specified in milliseconds, the libvpx wrapper converts this value as follows: +@code{buf-sz = bufsize * 1000 / bitrate}, +@code{buf-optimal-sz = bufsize * 1000 / bitrate * 5 / 6}. -rc_buf_optimal_sz -@code{(bufsize * 1000 / vb * 5 / 6)} +@item rc_init_occupancy (@emph{buf-initial-sz}) +Set number of bits which should be loaded into the rc buffer before decoding +starts. Note @command{vpxenc}'s option is specified in milliseconds, the libvpx +wrapper converts this value as follows: +@code{rc_init_occupancy * 1000 / bitrate}. -@item rc_init_occupancy, vb -rc_buf_initial_sz -@code{(rc_init_occupancy * 1000 / vb)} +@item undershoot-pct +Set datarate undershoot (min) percentage of the target bitrate. -@item rc_buffer_aggressivity -rc_undershoot_pct +@item overshoot-pct +Set datarate overshoot (max) percentage of the target bitrate. -@item skip_threshold -rc_dropframe_thresh +@item skip_threshold (@emph{drop-frame}) -@item qcomp -rc_2pass_vbr_bias_pct +@item qcomp (@emph{bias-pct}) -@item maxrate, vb -rc_2pass_vbr_maxsection_pct -@code{(maxrate * 100 / vb)} +@item maxrate (@emph{maxsection-pct}) +Set GOP max bitrate in bits/s. Note @command{vpxenc}'s option is specified as a +percentage of the target bitrate, the libvpx wrapper converts this value as +follows: @code{(maxrate * 100 / bitrate)}. -@item minrate, vb -rc_2pass_vbr_minsection_pct -@code{(minrate * 100 / vb)} +@item minrate (@emph{minsection-pct}) +Set GOP min bitrate in bits/s. Note @command{vpxenc}'s option is specified as a +percentage of the target bitrate, the libvpx wrapper converts this value as +follows: @code{(minrate * 100 / bitrate)}. -@item minrate, maxrate, vb -@code{VPX_CBR} -@code{(minrate == maxrate == vb)} +@item minrate, maxrate, b @emph{end-usage=cbr} +@code{(minrate == maxrate == bitrate)}. -@item crf -@code{VPX_CQ}, @code{VP8E_SET_CQ_LEVEL} +@item crf (@emph{end-usage=cq}, @emph{cq-level}) -@item quality -@table @option -@item @var{best} -@code{VPX_DL_BEST_QUALITY} -@item @var{good} -@code{VPX_DL_GOOD_QUALITY} -@item @var{realtime} -@code{VPX_DL_REALTIME} +@item quality, deadline (@emph{deadline}) +@table @samp +@item best +Use best quality deadline. Poorly named and quite slow, this option should be +avoided as it may give worse quality output than good. +@item good +Use good quality deadline. This is a good trade-off between speed and quality +when used with the @option{cpu-used} option. +@item realtime +Use realtime quality deadline. @end table -@item speed -@code{VP8E_SET_CPUUSED} +@item speed, cpu-used (@emph{cpu-used}) +Set quality/speed ratio modifier. Higher values speed up the encode at the cost +of quality. -@item nr -@code{VP8E_SET_NOISE_SENSITIVITY} +@item nr (@emph{noise-sensitivity}) -@item mb_threshold -@code{VP8E_SET_STATIC_THRESHOLD} +@item static-thresh +Set a change threshold on blocks below which they will be skipped by the +encoder. -@item slices -@code{VP8E_SET_TOKEN_PARTITIONS} +@item slices (@emph{token-parts}) +Note that FFmpeg's @option{slices} option gives the total number of partitions, +while @command{vpxenc}'s @option{token-parts} is given as +@code{log2(partitions)}. @item max-intra-rate -@code{VP8E_SET_MAX_INTRA_BITRATE_PCT} +Set maximum I-frame bitrate as a percentage of the target bitrate. A value of 0 +means unlimited. @item force_key_frames @code{VPX_EFLAG_FORCE_KF} @item Alternate reference frame related @table @option -@item vp8flags altref -@code{VP8E_SET_ENABLEAUTOALTREF} -@item @var{arnr_max_frames} -@code{VP8E_SET_ARNR_MAXFRAMES} -@item @var{arnr_type} -@code{VP8E_SET_ARNR_TYPE} -@item @var{arnr_strength} -@code{VP8E_SET_ARNR_STRENGTH} -@item @var{rc_lookahead} -g_lag_in_frames +@item auto-alt-ref +Enable use of alternate reference frames (2-pass only). +@item arnr-max-frames +Set altref noise reduction max frame count. +@item arnr-type +Set altref noise reduction filter type: backward, forward, centered. +@item arnr-strength +Set altref noise reduction filter strength. +@item rc-lookahead, lag-in-frames (@emph{lag-in-frames}) +Set number of frames to look ahead for frametype and ratecontrol. @end table -@item vp8flags error_resilient -g_error_resilient +@item error-resilient +Enable error resiliency features. -@item aq_mode -@code{VP9E_SET_AQ_MODE} +@item VP9-specific options +@table @option +@item lossless +Enable lossless mode. +@item tile-columns +Set number of tile columns to use. Note this is given as +@code{log2(tile_columns)}. For example, 8 tile columns would be requested by +setting the @option{tile-columns} option to 3. +@item tile-rows +Set number of tile rows to use. Note this is given as @code{log2(tile_rows)}. +For example, 4 tile rows would be requested by setting the @option{tile-rows} +option to 2. +@item frame-parallel +Enable frame parallel decodability features. +@item aq-mode +Set adaptive quantization mode (0: off (default), 1: variance 2: complexity, 3: +cyclic refresh). +@item colorspace @emph{color-space} +Set input color space. The VP9 bitstream supports signaling the following +colorspaces: +@table @option +@item @samp{rgb} @emph{sRGB} +@item @samp{bt709} @emph{bt709} +@item @samp{unspecified} @emph{unknown} +@item @samp{bt470bg} @emph{bt601} +@item @samp{smpte170m} @emph{smpte170} +@item @samp{smpte240m} @emph{smpte240} +@item @samp{bt2020_ncl} @emph{bt2020} +@end table +@end table @end table @@ -2260,6 +2315,30 @@ For the fastest encoding speed set the @option{qscale} parameter (4 is the recommended value) and do not set a size constraint. +@section libkvazaar + +Kvazaar H.265/HEVC encoder. + +Requires the presence of the libkvazaar headers and library during +configuration. You need to explicitly configure the build with +@option{--enable-libkvazaar}. + +@subsection Options + +@table @option + +@item b +Set target video bitrate in bit/s and enable rate control. + +@item threads +Set number of encoding threads. + +@item kvazaar-params +Set kvazaar parameters as a list of @var{name}=@var{value} pairs separated +by commas (,). See kvazaar documentation for a list of options. + +@end table + @c man end VIDEO ENCODERS @chapter Subtitles Encoders diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/examples/decoding_encoding.c ffmpeg-2.7.2~trusty~ppa1/doc/examples/decoding_encoding.c --- ffmpeg-2.7.1~trusty~ppa1/doc/examples/decoding_encoding.c 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/examples/decoding_encoding.c 2015-07-28 17:20:07.000000000 +0000 @@ -245,7 +245,7 @@ AVCodecContext *c= NULL; int len; FILE *f, *outfile; - uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; + uint8_t inbuf[AUDIO_INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; AVPacket avpkt; AVFrame *decoded_frame = NULL; @@ -521,7 +521,7 @@ /* the picture is allocated by the decoder, no need to free it */ snprintf(buf, sizeof(buf), outfilename, *frame_count); pgm_save(frame->data[0], frame->linesize[0], - avctx->width, avctx->height, buf); + frame->width, frame->height, buf); (*frame_count)++; } if (pkt->data) { @@ -538,13 +538,13 @@ int frame_count; FILE *f; AVFrame *frame; - uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; + uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; AVPacket avpkt; av_init_packet(&avpkt); /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */ - memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE); printf("Decode video file %s to %s\n", filename, outfilename); @@ -561,8 +561,8 @@ exit(1); } - if(codec->capabilities&CODEC_CAP_TRUNCATED) - c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */ + if (codec->capabilities & AV_CODEC_CAP_TRUNCATED) + c->flags |= AV_CODEC_FLAG_TRUNCATED; // we do not send complete frames /* For some codecs, such as msmpeg4 and mpeg4, width and height MUST be initialized there because this information is not diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/examples/http_multiclient.c ffmpeg-2.7.2~trusty~ppa1/doc/examples/http_multiclient.c --- ffmpeg-2.7.1~trusty~ppa1/doc/examples/http_multiclient.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/examples/http_multiclient.c 2015-08-01 17:20:02.000000000 +0000 @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2015 Stephan Holljes + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * @file + * libavformat multi-client network API usage example. + * + * @example http_multiclient.c + * This example will serve a file without decoding or demuxing it over http. + * Multiple clients can connect and will receive the same file. + */ + +#include +#include +#include + +void process_client(AVIOContext *client, const char *in_uri) +{ + AVIOContext *input = NULL; + uint8_t buf[1024]; + int ret, n, reply_code; + char *resource = NULL; + while ((ret = avio_handshake(client)) > 0) { + av_opt_get(client, "resource", AV_OPT_SEARCH_CHILDREN, &resource); + // check for strlen(resource) is necessary, because av_opt_get() + // may return empty string. + if (resource && strlen(resource)) + break; + } + if (ret < 0) + goto end; + av_log(client, AV_LOG_TRACE, "resource=%p\n", resource); + if (resource && resource[0] == '/' && !strcmp((resource + 1), in_uri)) { + reply_code = 200; + } else { + reply_code = AVERROR_HTTP_NOT_FOUND; + } + if ((ret = av_opt_set_int(client, "reply_code", reply_code, AV_OPT_SEARCH_CHILDREN)) < 0) { + av_log(client, AV_LOG_ERROR, "Failed to set reply_code: %s.\n", av_err2str(ret)); + goto end; + } + av_log(client, AV_LOG_TRACE, "Set reply code to %d\n", reply_code); + + while ((ret = avio_handshake(client)) > 0); + + if (ret < 0) + goto end; + + fprintf(stderr, "Handshake performed.\n"); + if (reply_code != 200) + goto end; + fprintf(stderr, "Opening input file.\n"); + if ((ret = avio_open2(&input, in_uri, AVIO_FLAG_READ, NULL, NULL)) < 0) { + av_log(input, AV_LOG_ERROR, "Failed to open input: %s: %s.\n", in_uri, + av_err2str(ret)); + goto end; + } + for(;;) { + n = avio_read(input, buf, sizeof(buf)); + if (n < 0) { + if (n == AVERROR_EOF) + break; + av_log(input, AV_LOG_ERROR, "Error reading from input: %s.\n", + av_err2str(n)); + break; + } + avio_write(client, buf, n); + avio_flush(client); + } +end: + fprintf(stderr, "Flushing client\n"); + avio_flush(client); + fprintf(stderr, "Closing client\n"); + avio_close(client); + fprintf(stderr, "Closing input\n"); + avio_close(input); +} + +int main(int argc, char **argv) +{ + av_log_set_level(AV_LOG_TRACE); + AVDictionary *options = NULL; + AVIOContext *client = NULL, *server = NULL; + const char *in_uri, *out_uri; + int ret, pid; + if (argc < 3) { + printf("usage: %s input http://hostname[:port]\n" + "API example program to serve http to multiple clients.\n" + "\n", argv[0]); + return 1; + } + + in_uri = argv[1]; + out_uri = argv[2]; + + av_register_all(); + avformat_network_init(); + + if ((ret = av_dict_set(&options, "listen", "2", 0)) < 0) { + fprintf(stderr, "Failed to set listen mode for server: %s\n", av_err2str(ret)); + return ret; + } + if ((ret = avio_open2(&server, out_uri, AVIO_FLAG_WRITE, NULL, &options)) < 0) { + fprintf(stderr, "Failed to open server: %s\n", av_err2str(ret)); + return ret; + } + fprintf(stderr, "Entering main loop.\n"); + for(;;) { + if ((ret = avio_accept(server, &client)) < 0) + goto end; + fprintf(stderr, "Accepted client, forking process.\n"); + // XXX: Since we don't reap our children and don't ignore signals + // this produces zombie processes. + pid = fork(); + if (pid < 0) { + perror("Fork failed"); + ret = AVERROR(errno); + goto end; + } + if (pid == 0) { + fprintf(stderr, "In child.\n"); + process_client(client, in_uri); + avio_close(server); + exit(0); + } + if (pid > 0) + avio_close(client); + } +end: + avio_close(server); + if (ret < 0 && ret != AVERROR_EOF) { + fprintf(stderr, "Some errors occured: %s\n", av_err2str(ret)); + return 1; + } + return 0; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/examples/Makefile ffmpeg-2.7.2~trusty~ppa1/doc/examples/Makefile --- ffmpeg-2.7.1~trusty~ppa1/doc/examples/Makefile 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/examples/Makefile 2015-08-01 17:20:02.000000000 +0000 @@ -18,6 +18,7 @@ extract_mvs \ filtering_video \ filtering_audio \ + http_multiclient \ metadata \ muxing \ remuxing \ diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/examples/muxing.c ffmpeg-2.7.2~trusty~ppa1/doc/examples/muxing.c --- ffmpeg-2.7.1~trusty~ppa1/doc/examples/muxing.c 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/examples/muxing.c 2015-07-28 17:20:07.000000000 +0000 @@ -172,7 +172,7 @@ /* Some formats want stream headers to be separate. */ if (oc->oformat->flags & AVFMT_GLOBALHEADER) - c->flags |= CODEC_FLAG_GLOBAL_HEADER; + c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; } /**************************************************************/ @@ -230,7 +230,7 @@ /* increment frequency by 110 Hz per second */ ost->tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate; - if (c->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE) + if (c->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) nb_samples = 10000; else nb_samples = c->frame_size; diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/examples/qsvdec.c ffmpeg-2.7.2~trusty~ppa1/doc/examples/qsvdec.c --- ffmpeg-2.7.1~trusty~ppa1/doc/examples/qsvdec.c 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/examples/qsvdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -405,7 +405,7 @@ decoder_ctx->codec_id = AV_CODEC_ID_H264; if (video_st->codec->extradata_size) { decoder_ctx->extradata = av_mallocz(video_st->codec->extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!decoder_ctx->extradata) { ret = AVERROR(ENOMEM); goto finish; diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/examples/remuxing.c ffmpeg-2.7.2~trusty~ppa1/doc/examples/remuxing.c --- ffmpeg-2.7.1~trusty~ppa1/doc/examples/remuxing.c 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/examples/remuxing.c 2015-07-28 17:20:07.000000000 +0000 @@ -101,7 +101,7 @@ } out_stream->codec->codec_tag = 0; if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) - out_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; + out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; } av_dump_format(ofmt_ctx, 0, out_filename, 1); diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/examples/transcode_aac.c ffmpeg-2.7.2~trusty~ppa1/doc/examples/transcode_aac.c --- ffmpeg-2.7.1~trusty~ppa1/doc/examples/transcode_aac.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/examples/transcode_aac.c 2015-07-28 17:20:07.000000000 +0000 @@ -192,7 +192,7 @@ * Mark the encoder so that it behaves accordingly. */ if ((*output_format_context)->oformat->flags & AVFMT_GLOBALHEADER) - (*output_codec_context)->flags |= CODEC_FLAG_GLOBAL_HEADER; + (*output_codec_context)->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; /** Open the encoder for the audio stream to use it later. */ if ((error = avcodec_open2(*output_codec_context, output_codec, NULL)) < 0) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/examples/transcoding.c ffmpeg-2.7.2~trusty~ppa1/doc/examples/transcoding.c --- ffmpeg-2.7.1~trusty~ppa1/doc/examples/transcoding.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/examples/transcoding.c 2015-07-28 17:20:07.000000000 +0000 @@ -161,7 +161,7 @@ } if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) - enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER; + enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; } av_dump_format(ofmt_ctx, 0, filename, 1); @@ -449,7 +449,7 @@ int got_frame; if (!(ofmt_ctx->streams[stream_index]->codec->codec->capabilities & - CODEC_CAP_DELAY)) + AV_CODEC_CAP_DELAY)) return 0; while (1) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/ffmpeg.texi ffmpeg-2.7.2~trusty~ppa1/doc/ffmpeg.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/ffmpeg.texi 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/ffmpeg.texi 2015-07-29 17:20:04.000000000 +0000 @@ -307,6 +307,11 @@ @var{position} may be either in seconds or in @code{hh:mm:ss[.xxx]} form. +@item -sseof @var{position} (@emph{input/output}) + +Like the @code{-ss} option but relative to the "end of file". That is negative +values are earlier in the file, 0 is at EOF. + @item -itsoffset @var{offset} (@emph{input}) Set the input time offset. @@ -1299,47 +1304,6 @@ @c man end OPTIONS -@chapter Tips -@c man begin TIPS - -@itemize -@item -For streaming at very low bitrates, use a low frame rate -and a small GOP size. This is especially true for RealVideo where -the Linux player does not seem to be very fast, so it can miss -frames. An example is: - -@example -ffmpeg -g 3 -r 3 -t 10 -b:v 50k -s qcif -f rv10 /tmp/b.rm -@end example - -@item -The parameter 'q' which is displayed while encoding is the current -quantizer. The value 1 indicates that a very good quality could -be achieved. The value 31 indicates the worst quality. If q=31 appears -too often, it means that the encoder cannot compress enough to meet -your bitrate. You must either increase the bitrate, decrease the -frame rate or decrease the frame size. - -@item -If your computer is not fast enough, you can speed up the -compression at the expense of the compression ratio. You can use -'-me zero' to speed up motion estimation, and '-g 0' to disable -motion estimation completely (you have only I-frames, which means it -is about as good as JPEG compression). - -@item -To have very low audio bitrates, reduce the sampling frequency -(down to 22050 Hz for MPEG audio, 22050 or 11025 for AC-3). - -@item -To have a constant quality (but a variable bitrate), use the option -'-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst -quality). - -@end itemize -@c man end TIPS - @chapter Examples @c man begin EXAMPLES diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/filters.texi ffmpeg-2.7.2~trusty~ppa1/doc/filters.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/filters.texi 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/filters.texi 2015-08-02 17:20:02.000000000 +0000 @@ -318,6 +318,54 @@ Below is a description of the currently available audio filters. +@section acrossfade + +Apply cross fade from one input audio stream to another input audio stream. +The cross fade is applied for specified duration near the end of first stream. + +The filter accepts the following options: + +@table @option +@item nb_samples, ns +Specify the number of samples for which the cross fade effect has to last. +At the end of the cross fade effect the first input audio will be completely +silent. Default is 44100. + +@item duration, d +Specify the duration of the cross fade effect. See +@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils} +for the accepted syntax. +By default the duration is determined by @var{nb_samples}. +If set this option is used instead of @var{nb_samples}. + +@item overlap, o +Should first stream end overlap with second stream start. Default is enabled. + +@item curve1 +Set curve for cross fade transition for first stream. + +@item curve2 +Set curve for cross fade transition for second stream. + +For description of available curve types see @ref{afade} filter description. +@end table + +@subsection Examples + +@itemize +@item +Cross fade from one input to another: +@example +ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:c1=exp:c2=exp output.flac +@end example + +@item +Cross fade from one input to another but without overlapping: +@example +ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:o=0:c1=exp:c2=exp output.flac +@end example +@end itemize + @section adelay Delay one or more audio channels. @@ -469,6 +517,7 @@ @end example @end itemize +@anchor{afade} @section afade Apply fade-in/out effect to input audio. @@ -522,7 +571,7 @@ select exponential sine wave @item log select logarithmic -@item par +@item ipar select inverted parabola @item qua select quadratic @@ -532,6 +581,18 @@ select square root @item cbr select cubic root +@item par +select parabola +@item exp +select exponential +@item iqsin +select inverted quarter of sine wave +@item ihsin +select inverted half of sine wave +@item dese +select double-exponential seat +@item desi +select double-exponential sigmoid @end table @end table @@ -610,6 +671,7 @@ Specify the band-width of a filter in width_type units. @end table +@anchor{amerge} @section amerge Merge two or more audio streams into a single multi-channel stream. @@ -929,6 +991,52 @@ @item length Short window length in seconds, used for peak and trough RMS measurement. Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}. + +@item metadata + +Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X}, +where @code{X} is channel number starting from 1 or string @code{Overall}. Default is +disabled. + +Available keys for each channel are: +DC_offset +Min_level +Max_level +Min_difference +Max_difference +Mean_difference +Peak_level +RMS_peak +RMS_trough +Crest_factor +Flat_factor +Peak_count +Bit_depth + +and for Overall: +DC_offset +Min_level +Max_level +Min_difference +Max_difference +Mean_difference +Peak_level +RMS_level +RMS_peak +RMS_trough +Flat_factor +Peak_count +Bit_depth +Number_of_samples + +For example full key look like this @code{lavfi.astats.1.DC_offset} or +this @code{lavfi.astats.Overall.Peak_count}. + +For description what each key means read bellow. + +@item reset +Set number of frame after which stats are going to be recalculated. +Default is disabled. @end table A description of each shown parameter follows: @@ -943,6 +1051,16 @@ @item Max level Maximal sample level. +@item Min difference +Minimal difference between two consecutive samples. + +@item Max difference +Maximal difference between two consecutive samples. + +@item Mean difference +Mean difference between two consecutive samples. +The average of each difference between two consecutive samples. + @item Peak level dB @item RMS level dB Standard peak and RMS level measured in dBFS. @@ -961,6 +1079,9 @@ @item Peak count Number of occasions (not the number of samples) that the signal attained either @var{Min level} or @var{Max level}. + +@item Bit depth +Overall bit depth of audio. Number of bits used for each sample. @end table @section astreamsync @@ -1291,7 +1412,7 @@ To fix a 5.1 WAV improperly encoded in AAC's native channel order @example -ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:channel_layout=5.1' out.wav +ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav @end example @section channelsplit @@ -1391,6 +1512,8 @@ shorter than the decay time, because the human ear is more sensitive to sudden loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and a typical value for decay is 0.8 seconds. +If specified number of attacks & decays is lower than number of channels, the last +set attack/decay will be used for all remaining channels. @item points A list of points for the transfer function, specified in dB relative to the @@ -1436,6 +1559,11 @@ compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2 @end example +Another example for audio with whisper and explosion parts: +@example +compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0 +@end example + @item A noise gate for when the noise is at a lower level than the signal: @example @@ -1468,6 +1596,164 @@ used to prevent clipping. @end table +@section dynaudnorm +Dynamic Audio Normalizer. + +This filter applies a certain amount of gain to the input audio in order +to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in +contrast to more "simple" normalization algorithms, the Dynamic Audio +Normalizer *dynamically* re-adjusts the gain factor to the input audio. +This allows for applying extra gain to the "quiet" sections of the audio +while avoiding distortions or clipping the "loud" sections. In other words: +The Dynamic Audio Normalizer will "even out" the volume of quiet and loud +sections, in the sense that the volume of each section is brought to the +same target level. Note, however, that the Dynamic Audio Normalizer achieves +this goal *without* applying "dynamic range compressing". It will retain 100% +of the dynamic range *within* each section of the audio file. + +@table @option +@item f +Set the frame length in milliseconds. In range from 10 to 8000 milliseconds. +Default is 500 milliseconds. +The Dynamic Audio Normalizer processes the input audio in small chunks, +referred to as frames. This is required, because a peak magnitude has no +meaning for just a single sample value. Instead, we need to determine the +peak magnitude for a contiguous sequence of sample values. While a "standard" +normalizer would simply use the peak magnitude of the complete file, the +Dynamic Audio Normalizer determines the peak magnitude individually for each +frame. The length of a frame is specified in milliseconds. By default, the +Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has +been found to give good results with most files. +Note that the exact frame length, in number of samples, will be determined +automatically, based on the sampling rate of the individual input audio file. + +@item g +Set the Gaussian filter window size. In range from 3 to 301, must be odd +number. Default is 31. +Probably the most important parameter of the Dynamic Audio Normalizer is the +@code{window size} of the Gaussian smoothing filter. The filter's window size +is specified in frames, centered around the current frame. For the sake of +simplicity, this must be an odd number. Consequently, the default value of 31 +takes into account the current frame, as well as the 15 preceding frames and +the 15 subsequent frames. Using a larger window results in a stronger +smoothing effect and thus in less gain variation, i.e. slower gain +adaptation. Conversely, using a smaller window results in a weaker smoothing +effect and thus in more gain variation, i.e. faster gain adaptation. +In other words, the more you increase this value, the more the Dynamic Audio +Normalizer will behave like a "traditional" normalization filter. On the +contrary, the more you decrease this value, the more the Dynamic Audio +Normalizer will behave like a dynamic range compressor. + +@item p +Set the target peak value. This specifies the highest permissible magnitude +level for the normalized audio input. This filter will try to approach the +target peak magnitude as closely as possible, but at the same time it also +makes sure that the normalized signal will never exceed the peak magnitude. +A frame's maximum local gain factor is imposed directly by the target peak +magnitude. The default value is 0.95 and thus leaves a headroom of 5%*. +It is not recommended to go above this value. + +@item m +Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0. +The Dynamic Audio Normalizer determines the maximum possible (local) gain +factor for each input frame, i.e. the maximum gain factor that does not +result in clipping or distortion. The maximum gain factor is determined by +the frame's highest magnitude sample. However, the Dynamic Audio Normalizer +additionally bounds the frame's maximum gain factor by a predetermined +(global) maximum gain factor. This is done in order to avoid excessive gain +factors in "silent" or almost silent frames. By default, the maximum gain +factor is 10.0, For most inputs the default value should be sufficient and +it usually is not recommended to increase this value. Though, for input +with an extremely low overall volume level, it may be necessary to allow even +higher gain factors. Note, however, that the Dynamic Audio Normalizer does +not simply apply a "hard" threshold (i.e. cut off values above the threshold). +Instead, a "sigmoid" threshold function will be applied. This way, the +gain factors will smoothly approach the threshold value, but never exceed that +value. + +@item r +Set the target RMS. In range from 0.0 to 1.0. Default is 0.0 - disabled. +By default, the Dynamic Audio Normalizer performs "peak" normalization. +This means that the maximum local gain factor for each frame is defined +(only) by the frame's highest magnitude sample. This way, the samples can +be amplified as much as possible without exceeding the maximum signal +level, i.e. without clipping. Optionally, however, the Dynamic Audio +Normalizer can also take into account the frame's root mean square, +abbreviated RMS. In electrical engineering, the RMS is commonly used to +determine the power of a time-varying signal. It is therefore considered +that the RMS is a better approximation of the "perceived loudness" than +just looking at the signal's peak magnitude. Consequently, by adjusting all +frames to a constant RMS value, a uniform "perceived loudness" can be +established. If a target RMS value has been specified, a frame's local gain +factor is defined as the factor that would result in exactly that RMS value. +Note, however, that the maximum local gain factor is still restricted by the +frame's highest magnitude sample, in order to prevent clipping. + +@item n +Enable channels coupling. By default is enabled. +By default, the Dynamic Audio Normalizer will amplify all channels by the same +amount. This means the same gain factor will be applied to all channels, i.e. +the maximum possible gain factor is determined by the "loudest" channel. +However, in some recordings, it may happen that the volume of the different +channels is uneven, e.g. one channel may be "quieter" than the other one(s). +In this case, this option can be used to disable the channel coupling. This way, +the gain factor will be determined independently for each channel, depending +only on the individual channel's highest magnitude sample. This allows for +harmonizing the volume of the different channels. + +@item c +Enable DC bias correction. By default is disabled. +An audio signal (in the time domain) is a sequence of sample values. +In the Dynamic Audio Normalizer these sample values are represented in the +-1.0 to 1.0 range, regardless of the original input format. Normally, the +audio signal, or "waveform", should be centered around the zero point. +That means if we calculate the mean value of all samples in a file, or in a +single frame, then the result should be 0.0 or at least very close to that +value. If, however, there is a significant deviation of the mean value from +0.0, in either positive or negative direction, this is referred to as a +DC bias or DC offset. Since a DC bias is clearly undesirable, the Dynamic +Audio Normalizer provides optional DC bias correction. +With DC bias correction enabled, the Dynamic Audio Normalizer will determine +the mean value, or "DC correction" offset, of each input frame and subtract +that value from all of the frame's sample values which ensures those samples +are centered around 0.0 again. Also, in order to avoid "gaps" at the frame +boundaries, the DC correction offset values will be interpolated smoothly +between neighbouring frames. + +@item b +Enable alternative boundary mode. By default is disabled. +The Dynamic Audio Normalizer takes into account a certain neighbourhood +around each frame. This includes the preceding frames as well as the +subsequent frames. However, for the "boundary" frames, located at the very +beginning and at the very end of the audio file, not all neighbouring +frames are available. In particular, for the first few frames in the audio +file, the preceding frames are not known. And, similarly, for the last few +frames in the audio file, the subsequent frames are not known. Thus, the +question arises which gain factors should be assumed for the missing frames +in the "boundary" region. The Dynamic Audio Normalizer implements two modes +to deal with this situation. The default boundary mode assumes a gain factor +of exactly 1.0 for the missing frames, resulting in a smooth "fade in" and +"fade out" at the beginning and at the end of the input, respectively. + +@item s +Set the compress factor. In range from 0.0 to 30.0. Default is 0.0. +By default, the Dynamic Audio Normalizer does not apply "traditional" +compression. This means that signal peaks will not be pruned and thus the +full dynamic range will be retained within each local neighbourhood. However, +in some cases it may be desirable to combine the Dynamic Audio Normalizer's +normalization algorithm with a more "traditional" compression. +For this purpose, the Dynamic Audio Normalizer provides an optional compression +(thresholding) function. If (and only if) the compression feature is enabled, +all input frames will be processed by a soft knee thresholding function prior +to the actual normalization process. Put simply, the thresholding function is +going to prune all samples whose magnitude exceeds a certain threshold value. +However, the Dynamic Audio Normalizer does not simply apply a fixed threshold +value. Instead, the threshold value will be adjusted for each individual +frame. +In general, smaller parameters result in stronger compression, and vice versa. +Values below 3.0 are not recommended, because audible distortion may appear. +@end table + @section earwax Make audio easier to listen to on headphones. @@ -1784,6 +2070,7 @@ The default is 0.707q and gives a Butterworth response. @end table +@anchor{pan} @section pan Mix channels with specific gain levels. The filter accepts the output @@ -1885,6 +2172,66 @@ Convert the audio sample format, sample rate and channel layout. It is not meant to be used directly. +@section sidechaincompress + +This filter acts like normal compressor but has the ability to compress +detected signal using second input signal. +It needs two input streams and returns one output stream. +First input stream will be processed depending on second stream signal. +The filtered signal then can be filtered with other filters in later stages of +processing. See @ref{pan} and @ref{amerge} filter. + +The filter accepts the following options: + +@table @option +@item threshold +If a signal of second stream raises above this level it will affect the gain +reduction of first stream. +By default is 0.125. Range is between 0.00097563 and 1. + +@item ratio +Set a ratio about which the signal is reduced. 1:2 means that if the level +raised 4dB above the threshold, it will be only 2dB above after the reduction. +Default is 2. Range is between 1 and 20. + +@item attack +Amount of milliseconds the signal has to rise above the threshold before gain +reduction starts. Default is 20. Range is between 0.01 and 2000. + +@item release +Amount of milliseconds the signal has to fall bellow the threshold before +reduction is decreased again. Default is 250. Range is between 0.01 and 9000. + +@item makeup +Set the amount by how much signal will be amplified after processing. +Default is 2. Range is from 1 and 64. + +@item knee +Curve the sharp knee around the threshold to enter gain reduction more softly. +Default is 2.82843. Range is between 1 and 8. + +@item link +Choose if the @code{average} level between all channels of side-chain stream +or the louder(@code{maximum}) channel of side-chain stream affects the +reduction. Default is @code{average}. + +@item detection +Should the exact signal be taken in case of @code{peak} or an RMS one in case +of @code{rms}. Default is @code{rms} which is mainly smoother. +@end table + +@subsection Examples + +@itemize +@item +Full ffmpeg example taking 2 audio inputs, 1st input to be compressed +depending on the signal of 2nd input and later compressed signal to be +merged with 2nd input: +@example +ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge" +@end example +@end itemize + @section silencedetect Detect silence in an audio stream. @@ -2620,6 +2967,44 @@ The default is @code{auto}. @end table +@section atadenoise +Apply an Adaptive Temporal Averaging Denoiser to the video input. + +The filter accepts the following options: + +@table @option +@item 0a +Set threshold A for 1st plane. Default is 0.02. +Valid range is 0 to 0.3. + +@item 0b +Set threshold B for 1st plane. Default is 0.04. +Valid range is 0 to 5. + +@item 1a +Set threshold A for 2nd plane. Default is 0.02. +Valid range is 0 to 0.3. + +@item 1b +Set threshold B for 2nd plane. Default is 0.04. +Valid range is 0 to 5. + +@item 2a +Set threshold A for 3rd plane. Default is 0.02. +Valid range is 0 to 0.3. + +@item 2b +Set threshold B for 3rd plane. Default is 0.04. +Valid range is 0 to 5. + +Threshold A is designed to react on abrupt changes in the input signal and +threshold B is designed to react on continuous changes in the input signal. + +@item s +Set number of frames filter will use for averaging. Default is 33. Must be odd +number in range [5, 129]. +@end table + @section bbox Compute the bounding box for the non-black pixels in the input frame @@ -3029,6 +3414,45 @@ @end example @end itemize +@section colorkey +RGB colorspace color keying. + +The filter accepts the following options: + +@table @option +@item color +The color which will be replaced with transparency. + +@item similarity +Similarity percentage with the key color. + +0.01 matches only the exact key color, while 1.0 matches everything. + +@item blend +Blend percentage. + +0.0 makes pixels either fully transparent, or not transparent at all. + +Higher values result in semi-transparent pixels, with a higher transparency +the more similar the pixels color is to the key color. +@end table + +@subsection Examples + +@itemize +@item +Make every green pixel in the input image transparent: +@example +ffmpeg -i input.png -vf colorkey=green out.png +@end example + +@item +Overlay a greenscreen-video on top of a static background image. +@example +ffmpeg -i background.png -i video.mp4 -filter_complex "[1:v]colorkey=0x3BBD1E:0.3:0.2[ckout];[0:v][ckout]overlay[out]" -map "[out]" output.flv +@end example +@end itemize + @section colorlevels Adjust video input frames using levels. @@ -3206,12 +3630,12 @@ @item w, out_w The width of the output video. It defaults to @code{iw}. This expression is evaluated only once during the filter -configuration. +configuration, or when the @samp{w} or @samp{out_w} command is sent. @item h, out_h The height of the output video. It defaults to @code{ih}. This expression is evaluated only once during the filter -configuration. +configuration, or when the @samp{h} or @samp{out_h} command is sent. @item x The horizontal position, in the input video, of the left edge of the output @@ -3371,6 +3795,22 @@ @end example @end itemize +@subsection Commands + +This filter supports the following commands: +@table @option +@item w, out_w +@item h, out_h +@item x +@item y +Set width/height of the output video and the horizontal/vertical position +in the input video. +The command accepts the same syntax of the corresponding option. + +If the specified expression is not valid, it is kept at its current +value. +@end table + @section cropdetect Auto-detect the crop size. @@ -3587,6 +4027,43 @@ dctdnoiz=15:n=4 @end example +@section deband + +Remove banding artifacts from input video. +It works by replacing banded pixels with average value of referenced pixels. + +The filter accepts the following options: + +@table @option +@item 1thr +@item 2thr +@item 3thr +@item 4thr +Set banding detection threshold for each plane. Default is 0.02. +Valid range is 0.00003 to 0.5. +If difference between current pixel and reference pixel is less than threshold, +it will be considered as banded. + +@item range, r +Banding detection range in pixels. Default is 16. If positive, random number +in range 0 to set value will be used. If negative, exact absolute value +will be used. +The range defines square of four pixels around current pixel. + +@item direction, d +Set direction in radians from which four pixel will be compared. If positive, +random direction from 0 to set direction will be picked. If negative, exact of +absolute value will be picked. For example direction 0, -PI or -2*PI radians +will pick only pixels on same row and -PI/2 will pick only pixels on same +column. + +@item blur +If enabled, current pixel is compared with average value of all four +surrounding pixels. The default is enabled. If disabled current pixel is +compared with all four surrounding pixels. The pixel is considered banded +if only all four differences with surrounding pixels are less than threshold. +@end table + @anchor{decimate} @section decimate @@ -3627,6 +4104,24 @@ @code{1}. @end table +@section deflate + +Apply deflate effect to the video. + +This filter replaces the pixel by the local(3x3) average by taking into account +only values lower than the pixel. + +It accepts the following options: + +@table @option +@item threshold0 +@item threshold1 +@item threshold2 +@item threshold3 +Allows to limit the maximum change for each plane, default is 65535. +If 0, plane will remain unchanged. +@end table + @section dejudder Remove judder produced by partially interlaced telecined content. @@ -3813,6 +4308,33 @@ pattern. This is to be used if the stream is cut. The default value is @code{0}. @end table +@section dilation + +Apply dilation effect to the video. + +This filter replaces the pixel by the local(3x3) maximum. + +It accepts the following options: + +@table @option +@item threshold0 +@item threshold1 +@item threshold2 +@item threshold3 +Allows to limit the maximum change for each plane, default is 65535. +If 0, plane will remain unchanged. + +@item coordinates +Flag which specifies the pixel to refer to. Default is 255 i.e. all eight +pixels are used. + +Flags to local 3x3 coordinates maps like this: + + 1 2 3 + 4 5 + 6 7 8 +@end table + @section drawbox Draw a colored box on the input image. @@ -3909,6 +4431,105 @@ @end example @end itemize +@section drawgraph, adrawgraph + +Draw a graph using input video or audio metadata. + +It accepts the following parameters: + +@table @option +@item m1 +Set 1st frame metadata key from which metadata values will be used to draw a graph. + +@item fg1 +Set 1st foreground color expression. + +@item m2 +Set 2nd frame metadata key from which metadata values will be used to draw a graph. + +@item fg2 +Set 2nd foreground color expression. + +@item m3 +Set 3rd frame metadata key from which metadata values will be used to draw a graph. + +@item fg3 +Set 3rd foreground color expression. + +@item m4 +Set 4th frame metadata key from which metadata values will be used to draw a graph. + +@item fg4 +Set 4th foreground color expression. + +@item min +Set minimal value of metadata value. + +@item max +Set maximal value of metadata value. + +@item bg +Set graph background color. Default is white. + +@item mode +Set graph mode. + +Available values for mode is: +@table @samp +@item bar +@item dot +@item line +@end table + +Default is @code{line}. + +@item slide +Set slide mode. + +Available values for slide is: +@table @samp +@item frame +Draw new frame when right border is reached. + +@item replace +Replace old columns with new ones. + +@item scroll +Scroll from right to left. +@end table + +Default is @code{frame}. + +@item size +Set size of graph video. For the syntax of this option, check the +@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}. +The default value is @code{900x256}. + +The foreground color expressions can use the following variables: +@table @option +@item MIN +Minimal value of metadata value. + +@item MAX +Maximal value of metadata value. + +@item VAL +Current metadata key value. +@end table + +The color is defined as 0xAABBGGRR. +@end table + +Example using metadata from @ref{signalstats} filter: +@example +signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255 +@end example + +Example using metadata from @ref{ebur128} filter: +@example +ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5 +@end example + @section drawgrid Draw a grid on the input image. @@ -4569,6 +5190,33 @@ @end table +@section erosion + +Apply erosion effect to the video. + +This filter replaces the pixel by the local(3x3) minimum. + +It accepts the following options: + +@table @option +@item threshold0 +@item threshold1 +@item threshold2 +@item threshold3 +Allows to limit the maximum change for each plane, default is 65535. +If 0, plane will remain unchanged. + +@item coordinates +Flag which specifies the pixel to refer to. Default is 255 i.e. all eight +pixels are used. + +Flags to local 3x3 coordinates maps like this: + + 1 2 3 + 4 5 + 6 7 8 +@end table + @section extractplanes Extract color channel components from input video stream into @@ -6166,6 +6814,24 @@ Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}. @end table +@section inflate + +Apply inflate effect to the video. + +This filter replaces the pixel by the local(3x3) average by taking into account +only values higher than the pixel. + +It accepts the following options: + +@table @option +@item threshold0 +@item threshold1 +@item threshold2 +@item threshold3 +Allows to limit the maximum change for each plane, default is 65535. +If 0, plane will remain unchanged. +@end table + @section interlace Simple interlacing filter from progressive contents. This interleaves upper (or @@ -7815,6 +8481,128 @@ @end example @end itemize +@section random + +Flush video frames from internal cache of frames into a random order. +No frame is discarded. +Inspired by @ref{frei0r} nervous filter. + +@table @option +@item frames +Set size in number of frames of internal cache, in range from @code{2} to +@code{512}. Default is @code{30}. + +@item seed +Set seed for random number generator, must be an integer included between +@code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to +less than @code{0}, the filter will try to use a good random seed on a +best effort basis. +@end table + +@section removegrain + +The removegrain filter is a spatial denoiser for progressive video. + +@table @option +@item m0 +Set mode for the first plane. + +@item m1 +Set mode for the second plane. + +@item m2 +Set mode for the third plane. + +@item m3 +Set mode for the fourth plane. +@end table + +Range of mode is from 0 to 24. Description of each mode follows: + +@table @var +@item 0 +Leave input plane unchanged. Default. + +@item 1 +Clips the pixel with the minimum and maximum of the 8 neighbour pixels. + +@item 2 +Clips the pixel with the second minimum and maximum of the 8 neighbour pixels. + +@item 3 +Clips the pixel with the third minimum and maximum of the 8 neighbour pixels. + +@item 4 +Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels. +This is equivalent to a median filter. + +@item 5 +Line-sensitive clipping giving the minimal change. + +@item 6 +Line-sensitive clipping, intermediate. + +@item 7 +Line-sensitive clipping, intermediate. + +@item 8 +Line-sensitive clipping, intermediate. + +@item 9 +Line-sensitive clipping on a line where the neighbours pixels are the closest. + +@item 10 +Replaces the target pixel with the closest neighbour. + +@item 11 +[1 2 1] horizontal and vertical kernel blur. + +@item 12 +Same as mode 11. + +@item 13 +Bob mode, interpolates top field from the line where the neighbours +pixels are the closest. + +@item 14 +Bob mode, interpolates bottom field from the line where the neighbours +pixels are the closest. + +@item 15 +Bob mode, interpolates top field. Same as 13 but with a more complicated +interpolation formula. + +@item 16 +Bob mode, interpolates bottom field. Same as 14 but with a more complicated +interpolation formula. + +@item 17 +Clips the pixel with the minimum and maximum of respectively the maximum and +minimum of each pair of opposite neighbour pixels. + +@item 18 +Line-sensitive clipping using opposite neighbours whose greatest distance from +the current pixel is minimal. + +@item 19 +Replaces the pixel with the average of its 8 neighbours. + +@item 20 +Averages the 9 pixels ([1 1 1] horizontal and vertical blur). + +@item 21 +Clips pixels using the averages of opposite neighbour. + +@item 22 +Same as mode 21 but simpler and faster. + +@item 23 +Small edge and halo removal, but reputed useless. + +@item 24 +Similar as 23. +@end table + @section removelogo Suppress a TV station logo, using an image file to determine which @@ -7850,6 +8638,23 @@ This filter uses the repeat_field flag from the Video ES headers and hard repeats fields based on its value. +@section reverse, areverse + +Reverse a clip. + +Warning: This filter requires memory to buffer the entire clip, so trimming +is suggested. + +@subsection Examples + +@itemize +@item +Take the first 5 seconds of a clip, and reverse it. +@example +trim=end=5,reverse +@end example +@end itemize + @section rotate Rotate video by an arbitrary angle expressed in radians. @@ -8304,6 +9109,19 @@ @end example @end itemize +@subsection Commands + +This filter supports the following commands: +@table @option +@item width, w +@item height, h +Set the output video dimension expression. +The command accepts the same syntax of the corresponding option. + +If the specified expression is not valid, it is kept at its current +value. +@end table + @section separatefields The @code{separatefields} takes a frame-based video input and splits @@ -8548,6 +9366,7 @@ ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT @end example +@anchor{signalstats} @section signalstats Evaluate various visual metrics that assist in determining issues associated with the digitization of analog video media. @@ -8778,6 +9597,64 @@ If a chroma option is not explicitly set, the corresponding luma value is set. +@section ssim + +Obtain the SSIM (Structural SImilarity Metric) between two input videos. + +This filter takes in input two input videos, the first input is +considered the "main" source and is passed unchanged to the +output. The second input is used as a "reference" video for computing +the SSIM. + +Both video inputs must have the same resolution and pixel format for +this filter to work correctly. Also it assumes that both inputs +have the same number of frames, which are compared one by one. + +The filter stores the calculated SSIM of each frame. + +The description of the accepted parameters follows. + +@table @option +@item stats_file, f +If specified the filter will use the named file to save the SSIM of +each individual frame. +@end table + +The file printed if @var{stats_file} is selected, contains a sequence of +key/value pairs of the form @var{key}:@var{value} for each compared +couple of frames. + +A description of each shown parameter follows: + +@table @option +@item n +sequential number of the input frame, starting from 1 + +@item Y, U, V, R, G, B +SSIM of the compared frames for the component specified by the suffix. + +@item All +SSIM of the compared frames for the whole frame. + +@item dB +Same as above but in dB representation. +@end table + +For example: +@example +movie=ref_movie.mpg, setpts=PTS-STARTPTS [main]; +[main][ref] ssim="stats_file=stats.log" [out] +@end example + +On this example the input file being processed is compared with the +reference file @file{ref_movie.mpg}. The SSIM of each individual frame +is stored in @file{stats.log}. + +Another example with both psnr and ssim at same time: +@example +ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null - +@end example + @section stereo3d Convert between different stereoscopic image formats. @@ -10149,6 +11026,12 @@ @example zoompan=z='min(zoom+0.0015,1.5)':d=700:x='if(gte(zoom,1.5),x,x+1/a)':y='if(gte(zoom,1.5),y,y+1)':s=640x360 @end example + +@item +Zoom-in up to 1.5 and pan always at center of picture: +@example +zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)' +@end example @end itemize @c man end VIDEO FILTERS @@ -10624,6 +11507,7 @@ @end example @end itemize +@anchor{allyuv} @anchor{color} @anchor{haldclutsrc} @anchor{nullsrc} @@ -10631,7 +11515,9 @@ @anchor{smptebars} @anchor{smptehdbars} @anchor{testsrc} -@section color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc +@section allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc + +The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors. The @code{color} source provides an uniformly colored input. @@ -10914,6 +11800,7 @@ @end itemize +@anchor{ebur128} @section ebur128 EBU R128 scanner filter. This filter takes an audio stream as input and outputs @@ -11872,6 +12759,45 @@ @end example @end itemize +@section showvolume + +Convert input audio volume to a video output. + +The filter accepts the following options: + +@table @option +@item rate, r +Set video rate. + +@item b +Set border width, allowed range is [0, 5]. Default is 1. + +@item w +Set channel width, allowed range is [40, 1080]. Default is 400. + +@item h +Set channel height, allowed range is [1, 100]. Default is 20. + +@item f +Set fade, allowed range is [1, 255]. Default is 20. + +@item c +Set volume color expression. + +The expression can use the following variables: + +@table @option +@item VOLUME +Current max volume of channel in dB. + +@item CHANNEL +Current channel number, starting from 0. +@end table + +@item t +If set, displays channel names. Default is enabled. +@end table + @section showwaves Convert input audio to a video output, representing the samples waves. diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/general.texi ffmpeg-2.7.2~trusty~ppa1/doc/general.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/general.texi 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/general.texi 2015-07-23 17:20:03.000000000 +0000 @@ -145,6 +145,14 @@ details), you must upgrade FFmpeg's license to GPL in order to use it. @end float +@section kvazaar + +FFmpeg can make use of the kvazaar library for HEVC encoding. + +Go to @url{https://github.com/ultravideo/kvazaar} and follow the +instructions for installing the library. Then pass +@code{--enable-libkvazaar} to configure to enable it. + @section libilbc iLBC is a narrowband speech codec that has been made freely available @@ -192,6 +200,17 @@ installed to use AviSynth scripts (obviously). @end float +@section Intel QuickSync Video + +FFmpeg can use Intel QuickSync Video (QSV) for accelerated encoding and decoding +of multiple codecs. To use QSV, FFmpeg must be linked against the @code{libmfx} +dispatcher, which loads the actual decoding libraries. + +The dispatcher is open source and can be downloaded from +@url{https://github.com/lu-zero/mfx_dispatch.git}. FFmpeg needs to be configured +with the @code{--enable-libmfx} option and @code{pkg-config} needs to be able to +locate the dispatcher's @code{.pc} files. + @chapter Supported File Formats, Codecs or Features @@ -207,6 +226,8 @@ @item 4xm @tab @tab X @tab 4X Technologies format, used in some games. @item 8088flex TMV @tab @tab X +@item AAX @tab @tab X + @tab Audible Enhanced Audio format, used in audiobooks. @item ACT Voice @tab @tab X @tab contains G.729 audio @item Adobe Filmstrip @tab X @tab X @@ -243,6 +264,8 @@ @tab Used in Z and Z95 games. @item Brute Force & Ignorance @tab @tab X @tab Used in the game Flash Traffic: City of Angels. +@item BFSTM @tab @tab X + @tab Audio format used on the Nintendo WiiU (based on BRSTM). @item BRSTM @tab @tab X @tab Audio format used on the Nintendo Wii. @item BWF @tab X @tab X @@ -273,6 +296,7 @@ @item Deluxe Paint Animation @tab @tab X @item DFA @tab @tab X @tab This format is used in Chronomaster game +@item DirectDraw Surface @tab @tab X @item DSD Stream File (DSF) @tab @tab X @item DV video @tab X @tab X @item DXA @tab @tab X @@ -477,6 +501,7 @@ @tab Tiertex .seq files used in the DOS CD-ROM version of the game Flashback. @item True Audio @tab @tab X @item VC-1 test bitstream @tab X @tab X +@item Vidvox Hap @tab X @tab X @item Vivo @tab @tab X @item WAV @tab X @tab X @item WavPack @tab X @tab X @@ -663,6 +688,8 @@ @tab Sorenson H.263 used in Flash @item Forward Uncompressed @tab @tab X @item Fraps @tab @tab X +@item Go2Meeting @tab @tab X + @tab fourcc: G2M2, G2M3 @item Go2Webinar @tab @tab X @tab fourcc: G2M4 @item H.261 @tab X @tab X @@ -671,7 +698,7 @@ @item H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 @tab E @tab X @tab encoding supported through external library libx264 and OpenH264 @item HEVC @tab X @tab X - @tab encoding supported through the external library libx265 + @tab encoding supported through external library libx265 and libkvazaar @item HNM version 4 @tab @tab X @item HuffYUV @tab X @tab X @item HuffYUV FFmpeg variant @tab X @tab X @@ -836,7 +863,7 @@ @item Name @tab Encoding @tab Decoding @tab Comments @item 8SVX exponential @tab @tab X @item 8SVX fibonacci @tab @tab X -@item AAC+ @tab E @tab X +@item AAC+ @tab E @tab IX @tab encoding supported through external library libaacplus @item AAC @tab E @tab X @tab encoding supported through external library libfaac and libvo-aacenc @@ -876,7 +903,7 @@ @item ADPCM MS IMA @tab X @tab X @item ADPCM Nintendo Gamecube AFC @tab @tab X @item ADPCM Nintendo Gamecube DTK @tab @tab X -@item ADPCM Nintendo Gamecube THP @tab @tab X +@item ADPCM Nintendo THP @tab @tab X @item ADPCM QT IMA @tab X @tab X @item ADPCM SEGA CRI ADX @tab X @tab X @tab Used in Sega Dreamcast games. diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/git-howto.texi ffmpeg-2.7.2~trusty~ppa1/doc/git-howto.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/git-howto.texi 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/git-howto.texi 2015-08-04 17:20:03.000000000 +0000 @@ -326,10 +326,12 @@ @section Pushing changes to remote trees @example -git push +git push origin master --dry-run @end example -Will push the changes to the default remote (@var{origin}). +Will simulate a push of the local master branch to the default remote +(@var{origin}). And list which branches and ranges or commits would have been +pushed. Git will prevent you from pushing changes if the local and remote trees are out of sync. Refer to @ref{Updating the source tree to the latest revision}. diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/mips.txt ffmpeg-2.7.2~trusty~ppa1/doc/mips.txt --- ffmpeg-2.7.1~trusty~ppa1/doc/mips.txt 2015-06-18 18:54:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/mips.txt 2015-07-23 17:20:03.000000000 +0000 @@ -47,12 +47,16 @@ * libavutil/mips/ float_dsp_mips.c libm_mips.h + softfloat_tables.h * libavcodec/ fft_fixed_32.c fft_init_table.c fft_table.h mdct_fixed_32.c * libavcodec/mips/ + aacdec_fixed.c + aacsbr_fixed.c + aacsbr_template.c aaccoder_mips.c aacpsy_mips.h ac3dsp_mips.c diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/multithreading.txt ffmpeg-2.7.2~trusty~ppa1/doc/multithreading.txt --- ffmpeg-2.7.1~trusty~ppa1/doc/multithreading.txt 2015-03-15 02:45:56.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/multithreading.txt 2015-07-28 17:20:07.000000000 +0000 @@ -54,7 +54,7 @@ If the codec allocates writable tables in its init(), add an init_thread_copy() which re-allocates them for other threads. -Add CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little +Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little speed gain at this point but it should work. If there are inter-frame dependencies, so the codec calls diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/muxers.texi ffmpeg-2.7.2~trusty~ppa1/doc/muxers.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/muxers.texi 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/muxers.texi 2015-07-20 17:20:03.000000000 +0000 @@ -263,6 +263,62 @@ This example will produce the playlist, @file{out.m3u8}, and segment files: @file{file000.ts}, @file{file001.ts}, @file{file002.ts}, etc. +@item hls_key_info_file @var{key_info_file} +Use the information in @var{key_info_file} for segment encryption. The first +line of @var{key_info_file} specifies the key URI written to the playlist. The +key URL is used to access the encryption key during playback. The second line +specifies the path to the key file used to obtain the key during the encryption +process. The key file is read as a single packed array of 16 octets in binary +format. The optional third line specifies the initialization vector (IV) as a +hexadecimal string to be used instead of the segment sequence number (default) +for encryption. Changes to @var{key_info_file} will result in segment +encryption with the new key/IV and an entry in the playlist for the new key +URI/IV. + +Key info file format: +@example +@var{key URI} +@var{key file path} +@var{IV} (optional) +@end example + +Example key URIs: +@example +http://server/file.key +/path/to/file.key +file.key +@end example + +Example key file paths: +@example +file.key +/path/to/file.key +@end example + +Example IV: +@example +0123456789ABCDEF0123456789ABCDEF +@end example + +Key info file example: +@example +http://server/file.key +/path/to/file.key +0123456789ABCDEF0123456789ABCDEF +@end example + +Example shell script: +@example +#!/bin/sh +BASE_URL=$@{1:-'.'@} +openssl rand 16 > file.key +echo $BASE_URL/file.key > file.keyinfo +echo file.key >> file.keyinfo +echo $(openssl rand -hex 16) >> file.keyinfo +ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags delete_segments \ + -hls_key_info_file file.keyinfo out.m3u8 +@end example + @item hls_flags single_file If this flag is set, the muxer will store all segments in a single MPEG-TS file, and will use byte ranges in the playlist. HLS playlists generated with @@ -611,6 +667,13 @@ ffmpeg -re @var{} -movflags isml+frag_keyframe -f ismv http://server/publishingpoint.isml/Streams(Encoder1) @end example +@subsection Audible AAX + +Audible AAX files are encrypted M4B files, and they can be decrypted by specifying a 4 byte activation secret. +@example +ffmpeg -activation_bytes 1CEB00DA -i test.aax -vn -c:a copy output.mp4 +@end example + @section mp3 The MP3 muxer writes a raw MP3 stream with the following optional features: @@ -703,6 +766,10 @@ @item -pcr_period @var{numer} Override the default PCR retransmission time (default 20ms), ignored if variable muxrate is selected. +@item pat_period @var{number} +Maximal time in seconds between PAT/PMT tables. +@item sdt_period @var{number} +Maximal time in seconds between SDT tables. @item -pes_payload_size @var{number} Set minimum PES packet payload in bytes. @item -mpegts_flags @var{flags} @@ -754,6 +821,8 @@ Reemit PAT/PMT before writing the next packet. @item latm Use LATM packetization for AAC. +@item pat_pmt_at_frames +Reemit PAT and PMT at each video frame. @end table @subsection Example @@ -908,13 +977,6 @@ Allow live-friendly file generation. @end table -@item segment_list_type @var{type} -Select the listing format. -@table @option -@item @var{flat} use a simple flat list of entries. -@item @var{hls} use a m3u8-like structure. -@end table - @item segment_list_size @var{size} Update the list file so that it contains at most @var{size} segments. If 0 the list file will contain all the segments. Default @@ -924,6 +986,9 @@ Prepend @var{prefix} to each entry. Useful to generate absolute paths. By default no prefix is applied. +@item segment_list_type @var{type} +Select the listing format. + The following values are recognized: @table @samp @item flat diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/platform.texi ffmpeg-2.7.2~trusty~ppa1/doc/platform.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/platform.texi 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/platform.texi 2015-07-27 17:20:04.000000000 +0000 @@ -175,12 +175,6 @@ @itemize -@item It is possible that coreutils' @code{link.exe} conflicts with MSVC's linker. -You can find out by running @code{which link} to see which @code{link.exe} you -are using. If it is located at @code{/bin/link.exe}, then you have the wrong one -in your @code{PATH}. Either move or remove that copy, or make sure MSVC's -@code{link.exe} takes precedence in your @code{PATH} over coreutils'. - @item If you wish to build with zlib support, you will have to grab a compatible zlib binary from somewhere, with an MSVC import lib, or if you wish to link statically, you can follow the instructions below to build a compatible diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/protocols.texi ffmpeg-2.7.2~trusty~ppa1/doc/protocols.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/protocols.texi 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/protocols.texi 2015-08-01 17:20:02.000000000 +0000 @@ -19,6 +19,18 @@ A description of the currently available protocols follows. +@section async + +Asynchronous data filling wrapper for input stream. + +Fill data in a background thread, to decouple I/O operation from demux thread. + +@example +async:@var{URL} +async:http://host/resource +async:cache:http://host/resource +@end example + @section bluray Read BluRay playlist. @@ -292,6 +304,8 @@ If set to 1 enables experimental HTTP server. This can be used to send data when used as an output option, or read data from a client with HTTP POST when used as an input option. +If set to 2 enables experimental mutli-client HTTP server. This is not yet implemented +in ffmpeg.c or ffserver.c and thus must not be used as a command line option. @example # Server side (sending): ffmpeg -i somefile.ogg -c copy -listen 1 -f ogg http://@var{server}:@var{port} diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/texi2pod.pl ffmpeg-2.7.2~trusty~ppa1/doc/texi2pod.pl --- ffmpeg-2.7.1~trusty~ppa1/doc/texi2pod.pl 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/texi2pod.pl 2015-07-06 17:20:03.000000000 +0000 @@ -384,7 +384,7 @@ # @* is also impossible in .pod; we discard it and any newline that # follows it. Similarly, our macro @gol must be discarded. - s/\@anchor{(?:[^\}]*)\}//g; + s/\@anchor\{(?:[^\}]*)\}//g; s/\(?\@xref\{(?:[^\}]*)\}(?:[^.<]|(?:<[^<>]*>))*\.\)?//g; s/\s+\(\@pxref\{(?:[^\}]*)\}\)//g; s/;\s+\@pxref\{(?:[^\}]*)\}//g; diff -Nru ffmpeg-2.7.1~trusty~ppa1/doc/utils.texi ffmpeg-2.7.2~trusty~ppa1/doc/utils.texi --- ffmpeg-2.7.1~trusty~ppa1/doc/utils.texi 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/doc/utils.texi 2015-07-21 17:20:03.000000000 +0000 @@ -238,6 +238,14 @@ 480x320 @item qhd 960x540 +@item 2kdci +2048x1080 +@item 4kdci +4096x2160 +@item uhd2160 +3840x2160 +@item uhd4320 +7680x4320 @end table @anchor{video rate syntax} diff -Nru ffmpeg-2.7.1~trusty~ppa1/ffmpeg.c ffmpeg-2.7.2~trusty~ppa1/ffmpeg.c --- ffmpeg-2.7.1~trusty~ppa1/ffmpeg.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/ffmpeg.c 2015-07-31 17:20:05.000000000 +0000 @@ -49,6 +49,7 @@ #include "libavutil/parseutils.h" #include "libavutil/samplefmt.h" #include "libavutil/fifo.h" +#include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/dict.h" #include "libavutil/mathematics.h" @@ -79,6 +80,10 @@ #include #include #endif +#if HAVE_SETCONSOLECTRLHANDLER +#include +#endif + #if HAVE_SYS_SELECT_H #include @@ -132,8 +137,6 @@ static uint8_t *subtitle_out; -#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass" - InputStream **input_streams = NULL; int nb_input_streams = 0; InputFile **input_files = NULL; @@ -313,6 +316,7 @@ static volatile int received_sigterm = 0; static volatile int received_nb_signals = 0; static volatile int transcode_init_done = 0; +static volatile int ffmpeg_exited = 0; static int main_return_code = 0; static void @@ -321,9 +325,45 @@ received_sigterm = sig; received_nb_signals++; term_exit_sigsafe(); - if(received_nb_signals > 3) + if(received_nb_signals > 3) { + write(2/*STDERR_FILENO*/, "Received > 3 system signals, hard exiting\n", + strlen("Received > 3 system signals, hard exiting\n")); + exit(123); + } +} + +#if HAVE_SETCONSOLECTRLHANDLER +static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) +{ + av_log(NULL, AV_LOG_DEBUG, "\nReceived windows signal %ld\n", fdwCtrlType); + + switch (fdwCtrlType) + { + case CTRL_C_EVENT: + case CTRL_BREAK_EVENT: + sigterm_handler(SIGINT); + return TRUE; + + case CTRL_CLOSE_EVENT: + case CTRL_LOGOFF_EVENT: + case CTRL_SHUTDOWN_EVENT: + sigterm_handler(SIGTERM); + /* Basically, with these 3 events, when we return from this method the + process is hard terminated, so stall as long as we need to + to try and let the main thread(s) clean up and gracefully terminate + (we have at most 5 seconds, but should be done far before that). */ + while (!ffmpeg_exited) { + Sleep(0); + } + return TRUE; + + default: + av_log(NULL, AV_LOG_ERROR, "Received unknown windows signal %ld\n", fdwCtrlType); + return FALSE; + } } +#endif void term_init(void) { @@ -358,6 +398,9 @@ #ifdef SIGXCPU signal(SIGXCPU, sigterm_handler); #endif +#if HAVE_SETCONSOLECTRLHANDLER + SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE); +#endif } /* read a key without blocking */ @@ -429,7 +472,7 @@ if (do_benchmark) { int maxrss = getmaxrss() / 1024; - printf("bench: maxrss=%ikB\n", maxrss); + av_log(NULL, AV_LOG_INFO, "bench: maxrss=%ikB\n", maxrss); } for (i = 0; i < nb_filtergraphs; i++) { @@ -456,7 +499,10 @@ /* close files */ for (i = 0; i < nb_output_files; i++) { OutputFile *of = output_files[i]; - AVFormatContext *s = of->ctx; + AVFormatContext *s; + if (!of) + continue; + s = of->ctx; if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE)) avio_closep(&s->pb); avformat_free_context(s); @@ -466,7 +512,12 @@ } for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; - AVBitStreamFilterContext *bsfc = ost->bitstream_filters; + AVBitStreamFilterContext *bsfc; + + if (!ost) + continue; + + bsfc = ost->bitstream_filters; while (bsfc) { AVBitStreamFilterContext *next = bsfc->next; av_bitstream_filter_close(bsfc); @@ -527,12 +578,13 @@ avformat_network_deinit(); if (received_sigterm) { - av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n", + av_log(NULL, AV_LOG_INFO, "Exiting normally, received signal %d.\n", (int) received_sigterm); } else if (ret && transcode_init_done) { av_log(NULL, AV_LOG_INFO, "Conversion failed!\n"); } term_exit(); + ffmpeg_exited = 1; } void remove_avoptions(AVDictionary **a, AVDictionary *b) @@ -569,7 +621,7 @@ va_start(va, fmt); vsnprintf(buf, sizeof(buf), fmt, va); va_end(va); - printf("bench: %8"PRIu64" %s \n", t - current_time, buf); + av_log(NULL, AV_LOG_INFO, "bench: %8"PRIu64" %s \n", t - current_time, buf); } current_time = t; } @@ -591,7 +643,7 @@ int ret; if (!ost->st->codec->extradata_size && ost->enc_ctx->extradata_size) { - ost->st->codec->extradata = av_mallocz(ost->enc_ctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + ost->st->codec->extradata = av_mallocz(ost->enc_ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (ost->st->codec->extradata) { memcpy(ost->st->codec->extradata, ost->enc_ctx->extradata, ost->enc_ctx->extradata_size); ost->st->codec->extradata_size = ost->enc_ctx->extradata_size; @@ -616,6 +668,20 @@ } ost->frame_number++; } + if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { + int i; + uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, + NULL); + ost->quality = sd ? AV_RL32(sd) : -1; + ost->pict_type = sd ? sd[4] : AV_PICTURE_TYPE_NONE; + + for (i = 0; ierror); i++) { + if (sd && i < sd[5]) + ost->error[i] = AV_RL64(sd + 8 + 8*i); + else + ost->error[i] = -1; + } + } if (bsfc) av_packet_split_side_data(pkt); @@ -631,10 +697,10 @@ pkt->data, pkt->size, pkt->flags & AV_PKT_FLAG_KEY); if(a == 0 && new_pkt.data != pkt->data && new_pkt.destruct) { - uint8_t *t = av_malloc(new_pkt.size + FF_INPUT_BUFFER_PADDING_SIZE); //the new should be a subset of the old so cannot overflow + uint8_t *t = av_malloc(new_pkt.size + AV_INPUT_BUFFER_PADDING_SIZE); //the new should be a subset of the old so cannot overflow if(t) { memcpy(t, new_pkt.data, new_pkt.size); - memset(t + new_pkt.size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(t + new_pkt.size, 0, AV_INPUT_BUFFER_PADDING_SIZE); new_pkt.data = t; new_pkt.buf = NULL; a = 1; @@ -650,6 +716,7 @@ if (!new_pkt.buf) exit_program(1); } else if (a < 0) { + new_pkt = *pkt; av_log(NULL, AV_LOG_ERROR, "Failed to open bitstream filter %s for stream %d with codec %s", bsfc->filter->name, pkt->stream_index, avctx->codec ? avctx->codec->name : "copy"); @@ -1061,7 +1128,7 @@ int got_packet, forced_keyframe = 0; double pts_time; - if (enc->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) && + if (enc->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) && ost->top_field_first >= 0) in_picture->top_field_first = !!ost->top_field_first; @@ -1140,7 +1207,7 @@ av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &enc->time_base)); } - if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & CODEC_CAP_DELAY)) + if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & AV_CODEC_CAP_DELAY)) pkt.pts = ost->sync_opts; av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base); @@ -1176,7 +1243,7 @@ if (!ost->last_frame) ost->last_frame = av_frame_alloc(); av_frame_unref(ost->last_frame); - if (next_picture) + if (next_picture && ost->last_frame) av_frame_ref(ost->last_frame, next_picture); else av_frame_free(&ost->last_frame); @@ -1205,9 +1272,11 @@ enc = ost->enc_ctx; if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { frame_number = ost->st->nb_frames; - fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, enc->coded_frame ? enc->coded_frame->quality / (float)FF_QP2LAMBDA : 0); - if (enc->coded_frame && (enc->flags&CODEC_FLAG_PSNR)) - fprintf(vstats_file, "PSNR= %6.2f ", psnr(enc->coded_frame->error[0] / (enc->width * enc->height * 255.0 * 255.0))); + fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, + ost->quality / (float)FF_QP2LAMBDA); + + if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR)) + fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / (enc->width * enc->height * 255.0 * 255.0))); fprintf(vstats_file,"f_size= %6d ", frame_size); /* compute pts value */ @@ -1219,7 +1288,7 @@ avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0; fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate); - fprintf(vstats_file, "type= %c\n", enc->coded_frame ? av_get_picture_type_char(enc->coded_frame->pict_type) : 'I'); + fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(ost->pict_type)); } } @@ -1317,7 +1386,7 @@ do_video_out(of->ctx, ost, filtered_frame, float_pts); break; case AVMEDIA_TYPE_AUDIO: - if (!(enc->codec->capabilities & CODEC_CAP_PARAM_CHANGE) && + if (!(enc->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE) && enc->channels != av_frame_get_channels(filtered_frame)) { av_log(NULL, AV_LOG_ERROR, "Audio filter graph output is not normalized and encoder does not support parameter changes\n"); @@ -1356,8 +1425,8 @@ } extra_size += ost->enc_ctx->extradata_size; data_size += ost->data_size; - if ( (ost->enc_ctx->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2)) - != CODEC_FLAG_PASS1) + if ( (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2)) + != AV_CODEC_FLAG_PASS1) pass1_used = 0; } @@ -1496,8 +1565,9 @@ float q = -1; ost = output_streams[i]; enc = ost->enc_ctx; - if (!ost->stream_copy && enc->coded_frame) - q = enc->coded_frame->quality / (float)FF_QP2LAMBDA; + if (!ost->stream_copy) + q = ost->quality / (float) FF_QP2LAMBDA; + if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q); av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n", @@ -1524,7 +1594,8 @@ for (j = 0; j < 32; j++) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log2(qp_histogram[j] + 1))); } - if ((enc->flags&CODEC_FLAG_PSNR) && (enc->coded_frame || is_last_report)) { + + if ((enc->flags & AV_CODEC_FLAG_PSNR) && (ost->pict_type != AV_PICTURE_TYPE_NONE || is_last_report)) { int j; double error, error_sum = 0; double scale, scale_sum = 0; @@ -1536,7 +1607,7 @@ error = enc->error[j]; scale = enc->width * enc->height * 255.0 * 255.0 * frame_number; } else { - error = enc->coded_frame->error[j]; + error = ost->error[j]; scale = enc->width * enc->height * 255.0 * 255.0; } if (j) @@ -1865,20 +1936,14 @@ ret = AVERROR_INVALIDDATA; } - if (*got_output || ret<0 || pkt->size) + if (*got_output || ret<0) decode_error_stat[ret<0] ++; - if (!*got_output || ret < 0) { - if (!pkt->size) { - for (i = 0; i < ist->nb_filters; i++) -#if 1 - av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0); -#else - av_buffersrc_add_frame(ist->filters[i]->filter, NULL); -#endif - } + if (ret < 0 && exit_on_error) + exit_program(1); + + if (!*got_output || ret < 0) return ret; - } ist->samples_decoded += decoded_frame->nb_samples; ist->frames_decoded++; @@ -2010,9 +2075,12 @@ ); } - if (*got_output || ret<0 || pkt->size) + if (*got_output || ret<0) decode_error_stat[ret<0] ++; + if (ret < 0 && exit_on_error) + exit_program(1); + if (*got_output && ret >= 0) { if (ist->dec_ctx->width != decoded_frame->width || ist->dec_ctx->height != decoded_frame->height || @@ -2027,17 +2095,8 @@ } } - if (!*got_output || ret < 0) { - if (!pkt->size) { - for (i = 0; i < ist->nb_filters; i++) -#if 1 - av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0); -#else - av_buffersrc_add_frame(ist->filters[i]->filter, NULL); -#endif - } + if (!*got_output || ret < 0) return ret; - } if(ist->top_field_first>=0) decoded_frame->top_field_first = ist->top_field_first; @@ -2128,9 +2187,12 @@ int i, ret = avcodec_decode_subtitle2(ist->dec_ctx, &subtitle, got_output, pkt); - if (*got_output || ret<0 || pkt->size) + if (*got_output || ret<0) decode_error_stat[ret<0] ++; + if (ret < 0 && exit_on_error) + exit_program(1); + if (ret < 0 || !*got_output) { if (!pkt->size) sub2video_flush(ist); @@ -2182,6 +2244,21 @@ return ret; } +static int send_filter_eof(InputStream *ist) +{ + int i, ret; + for (i = 0; i < ist->nb_filters; i++) { +#if 1 + ret = av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0); +#else + ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL); +#endif + if (ret < 0) + return ret; + } + return 0; +} + /* pkt = NULL means EOF (needed to flush decoder buffers) */ static int process_input_packet(InputStream *ist, const AVPacket *pkt) { @@ -2229,7 +2306,7 @@ ist->dts = ist->next_dts; if (avpkt.size && avpkt.size != pkt->size && - !(ist->dec->capabilities & CODEC_CAP_SUBFRAMES)) { + !(ist->dec->capabilities & AV_CODEC_CAP_SUBFRAMES)) { av_log(NULL, ist->showed_multi_packet_warning ? AV_LOG_VERBOSE : AV_LOG_WARNING, "Multiple frames in a packet from stream %d\n", pkt->stream_index); ist->showed_multi_packet_warning = 1; @@ -2266,8 +2343,13 @@ return -1; } - if (ret < 0) - return ret; + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n", + ist->file_index, ist->st->index, av_err2str(ret)); + if (exit_on_error) + exit_program(1); + break; + } avpkt.dts= avpkt.pts= AV_NOPTS_VALUE; @@ -2286,6 +2368,15 @@ break; } + /* after flushing, send an EOF on all the filter inputs attached to the stream */ + if (!pkt && ist->decoding_needed && !got_output) { + int ret = send_filter_eof(ist); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n"); + exit_program(1); + } + } + /* handle stream copy */ if (!ist->decoding_needed) { ist->dts = ist->next_dts; @@ -2477,6 +2568,71 @@ return va < vb ? -1 : va > vb ? +1 : 0; } +static int init_output_stream(OutputStream *ost, char *error, int error_len) +{ + int ret = 0; + + if (ost->encoding_needed) { + AVCodec *codec = ost->enc; + AVCodecContext *dec = NULL; + InputStream *ist; + + if ((ist = get_input_stream(ost))) + dec = ist->dec_ctx; + if (dec && dec->subtitle_header) { + /* ASS code assumes this buffer is null terminated so add extra byte. */ + ost->enc_ctx->subtitle_header = av_mallocz(dec->subtitle_header_size + 1); + if (!ost->enc_ctx->subtitle_header) + return AVERROR(ENOMEM); + memcpy(ost->enc_ctx->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); + ost->enc_ctx->subtitle_header_size = dec->subtitle_header_size; + } + if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0)) + av_dict_set(&ost->encoder_opts, "threads", "auto", 0); + av_dict_set(&ost->encoder_opts, "side_data_only_packets", "1", 0); + + if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) { + if (ret == AVERROR_EXPERIMENTAL) + abort_codec_experimental(codec, 1); + snprintf(error, error_len, + "Error while opening encoder for output stream #%d:%d - " + "maybe incorrect parameters such as bit_rate, rate, width or height", + ost->file_index, ost->index); + return ret; + } + if (ost->enc->type == AVMEDIA_TYPE_AUDIO && + !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) + av_buffersink_set_frame_size(ost->filter->filter, + ost->enc_ctx->frame_size); + assert_avoptions(ost->encoder_opts); + if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000) + av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." + " It takes bits/s as argument, not kbits/s\n"); + + ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, + "Error initializing the output stream codec context.\n"); + exit_program(1); + } + + // copy timebase while removing common factors + ost->st->time_base = av_add_q(ost->enc_ctx->time_base, (AVRational){0, 1}); + ost->st->codec->codec= ost->enc_ctx->codec; + } else { + ret = av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, + "Error setting up codec context options.\n"); + return ret; + } + // copy timebase while removing common factors + ost->st->time_base = av_add_q(ost->st->codec->time_base, (AVRational){0, 1}); + } + + return ret; +} + static void parse_forced_key_frames(char *kf, OutputStream *ost, AVCodecContext *avctx) { @@ -2587,7 +2743,7 @@ if (!encoder_string) exit_program(1); - if (!(format_flags & AVFMT_FLAG_BITEXACT) && !(codec_flags & CODEC_FLAG_BITEXACT)) + if (!(format_flags & AVFMT_FLAG_BITEXACT) && !(codec_flags & AV_CODEC_FLAG_BITEXACT)) av_strlcpy(encoder_string, LIBAVCODEC_IDENT " ", encoder_string_len); else av_strlcpy(encoder_string, "Lavc ", encoder_string_len); @@ -2628,21 +2784,6 @@ input_streams[j + ifile->ist_index]->start = av_gettime_relative(); } - /* output stream init */ - for (i = 0; i < nb_output_files; i++) { - oc = output_files[i]->ctx; - if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) { - av_dump_format(oc, i, oc->filename, 1); - av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", i); - return AVERROR(EINVAL); - } - } - - /* init complex filtergraphs */ - for (i = 0; i < nb_filtergraphs; i++) - if ((ret = avfilter_graph_config(filtergraphs[i]->graph, NULL)) < 0) - return ret; - /* for each output stream, we compute the right encoding parameters */ for (i = 0; i < nb_output_streams; i++) { AVCodecContext *enc_ctx; @@ -2679,7 +2820,7 @@ av_assert0(ist && !ost->filter); - extra_size = (uint64_t)dec_ctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; + extra_size = (uint64_t)dec_ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) { return AVERROR(EINVAL); @@ -2851,10 +2992,6 @@ goto dump_format; } - if (ist) - ist->decoding_needed |= DECODING_FOR_OST; - ost->encoding_needed = 1; - set_encoder_id(output_files[ost->file_index], ost); if (!ost->filter && @@ -2983,39 +3120,6 @@ abort(); break; } - /* two pass mode */ - if (enc_ctx->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2)) { - char logfilename[1024]; - FILE *f; - - snprintf(logfilename, sizeof(logfilename), "%s-%d.log", - ost->logfile_prefix ? ost->logfile_prefix : - DEFAULT_PASS_LOGFILENAME_PREFIX, - i); - if (!strcmp(ost->enc->name, "libx264")) { - av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE); - } else { - if (enc_ctx->flags & CODEC_FLAG_PASS2) { - char *logbuffer; - size_t logbuffer_size; - if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { - av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n", - logfilename); - exit_program(1); - } - enc_ctx->stats_in = logbuffer; - } - if (enc_ctx->flags & CODEC_FLAG_PASS1) { - f = av_fopen_utf8(logfilename, "wb"); - if (!f) { - av_log(NULL, AV_LOG_FATAL, "Cannot write log file '%s' for pass-1 encoding: %s\n", - logfilename, strerror(errno)); - exit_program(1); - } - ost->logfile = f; - } - } - } } if (ost->disposition) { @@ -3052,63 +3156,9 @@ /* open each encoder */ for (i = 0; i < nb_output_streams; i++) { - ost = output_streams[i]; - if (ost->encoding_needed) { - AVCodec *codec = ost->enc; - AVCodecContext *dec = NULL; - - if ((ist = get_input_stream(ost))) - dec = ist->dec_ctx; - if (dec && dec->subtitle_header) { - /* ASS code assumes this buffer is null terminated so add extra byte. */ - ost->enc_ctx->subtitle_header = av_mallocz(dec->subtitle_header_size + 1); - if (!ost->enc_ctx->subtitle_header) { - ret = AVERROR(ENOMEM); - goto dump_format; - } - memcpy(ost->enc_ctx->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); - ost->enc_ctx->subtitle_header_size = dec->subtitle_header_size; - } - if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0)) - av_dict_set(&ost->encoder_opts, "threads", "auto", 0); - av_dict_set(&ost->encoder_opts, "side_data_only_packets", "1", 0); - - if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) { - if (ret == AVERROR_EXPERIMENTAL) - abort_codec_experimental(codec, 1); - snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height", - ost->file_index, ost->index); - goto dump_format; - } - if (ost->enc->type == AVMEDIA_TYPE_AUDIO && - !(ost->enc->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) - av_buffersink_set_frame_size(ost->filter->filter, - ost->enc_ctx->frame_size); - assert_avoptions(ost->encoder_opts); - if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000) - av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." - " It takes bits/s as argument, not kbits/s\n"); - - ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx); - if (ret < 0) { - av_log(NULL, AV_LOG_FATAL, - "Error initializing the output stream codec context.\n"); - exit_program(1); - } - - // copy timebase while removing common factors - ost->st->time_base = av_add_q(ost->enc_ctx->time_base, (AVRational){0, 1}); - ost->st->codec->codec= ost->enc_ctx->codec; - } else { - ret = av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts); - if (ret < 0) { - av_log(NULL, AV_LOG_FATAL, - "Error setting up codec context options.\n"); - return ret; - } - // copy timebase while removing common factors - ost->st->time_base = av_add_q(ost->st->codec->time_base, (AVRational){0, 1}); - } + ret = init_output_stream(output_streams[i], error, sizeof(error)); + if (ret < 0) + goto dump_format; } /* init input streams */ @@ -3458,7 +3508,7 @@ InputFile *f = input_files[i]; AVPacket pkt; - if (!f->in_thread_queue) + if (!f || !f->in_thread_queue) continue; av_thread_message_queue_set_err_send(f->in_thread_queue, AVERROR_EOF); while (av_thread_message_queue_recv(f->in_thread_queue, &pkt, 0) >= 0) @@ -3761,13 +3811,7 @@ sub2video_heartbeat(ist, pkt.pts); - ret = process_input_packet(ist, &pkt); - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n", - ist->file_index, ist->st->index, av_err2str(ret)); - if (exit_on_error) - exit_program(1); - } + process_input_packet(ist, &pkt); discard_packet: av_free_packet(&pkt); @@ -4094,7 +4138,7 @@ exit_program(1); ti = getutime() - ti; if (do_benchmark) { - printf("bench: utime=%0.3fs\n", ti / 1000000.0); + av_log(NULL, AV_LOG_INFO, "bench: utime=%0.3fs\n", ti / 1000000.0); } av_log(NULL, AV_LOG_DEBUG, "%"PRIu64" frames successfully decoded, %"PRIu64" decoding errors\n", decode_error_stat[0], decode_error_stat[1]); diff -Nru ffmpeg-2.7.1~trusty~ppa1/ffmpeg_filter.c ffmpeg-2.7.2~trusty~ppa1/ffmpeg_filter.c --- ffmpeg-2.7.1~trusty~ppa1/ffmpeg_filter.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/ffmpeg_filter.c 2015-07-28 17:20:07.000000000 +0000 @@ -85,7 +85,7 @@ break; } if (*p == -1) { - if((codec->capabilities & CODEC_CAP_LOSSLESS) && av_get_sample_fmt_name(st->codec->sample_fmt) > av_get_sample_fmt_name(codec->sample_fmts[0])) + if((codec->capabilities & AV_CODEC_CAP_LOSSLESS) && av_get_sample_fmt_name(st->codec->sample_fmt) > av_get_sample_fmt_name(codec->sample_fmts[0])) av_log(NULL, AV_LOG_ERROR, "Conversion will not be lossless.\n"); if(av_get_sample_fmt_name(st->codec->sample_fmt)) av_log(NULL, AV_LOG_WARNING, @@ -289,6 +289,45 @@ ist->filters[ist->nb_filters - 1] = fg->inputs[fg->nb_inputs - 1]; } +int init_complex_filtergraph(FilterGraph *fg) +{ + AVFilterInOut *inputs, *outputs, *cur; + AVFilterGraph *graph; + int ret = 0; + + /* this graph is only used for determining the kinds of inputs + * and outputs we have, and is discarded on exit from this function */ + graph = avfilter_graph_alloc(); + if (!graph) + return AVERROR(ENOMEM); + + ret = avfilter_graph_parse2(graph, fg->graph_desc, &inputs, &outputs); + if (ret < 0) + goto fail; + + for (cur = inputs; cur; cur = cur->next) + init_input_filter(fg, cur); + + for (cur = outputs; cur;) { + GROW_ARRAY(fg->outputs, fg->nb_outputs); + fg->outputs[fg->nb_outputs - 1] = av_mallocz(sizeof(*fg->outputs[0])); + if (!fg->outputs[fg->nb_outputs - 1]) + exit_program(1); + + fg->outputs[fg->nb_outputs - 1]->graph = fg; + fg->outputs[fg->nb_outputs - 1]->out_tmp = cur; + fg->outputs[fg->nb_outputs - 1]->type = avfilter_pad_get_type(cur->filter_ctx->output_pads, + cur->pad_idx); + cur = cur->next; + fg->outputs[fg->nb_outputs - 1]->out_tmp->next = NULL; + } + +fail: + avfilter_inout_free(&inputs); + avfilter_graph_free(&graph); + return ret; +} + static int insert_trim(int64_t start_time, int64_t duration, AVFilterContext **last_filter, int *pad_idx, const char *filter_name) @@ -602,6 +641,11 @@ av_freep(&ofilter->name); DESCRIBE_FILTER_LINK(ofilter, out, 0); + if (!ofilter->ost) { + av_log(NULL, AV_LOG_FATAL, "Filter %s has a unconnected output\n", ofilter->name); + exit_program(1); + } + switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) { case AVMEDIA_TYPE_VIDEO: return configure_output_video_filter(fg, ofilter, out); case AVMEDIA_TYPE_AUDIO: return configure_output_audio_filter(fg, ofilter, out); @@ -688,7 +732,7 @@ ist->resample_height, ist->hwaccel_retrieve_data ? ist->hwaccel_retrieved_pix_fmt : ist->resample_pix_fmt, tb.num, tb.den, sar.num, sar.den, - SWS_BILINEAR + ((ist->dec_ctx->flags&CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0)); + SWS_BILINEAR + ((ist->dec_ctx->flags&AV_CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0)); if (fr.num && fr.den) av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den); snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index, @@ -904,7 +948,7 @@ int configure_filtergraph(FilterGraph *fg) { AVFilterInOut *inputs, *outputs, *cur; - int ret, i, init = !fg->graph, simple = !fg->graph_desc; + int ret, i, simple = !fg->graph_desc; const char *graph_desc = simple ? fg->outputs[0]->ost->avfilter : fg->graph_desc; @@ -947,14 +991,30 @@ return ret; if (simple && (!inputs || inputs->next || !outputs || outputs->next)) { - av_log(NULL, AV_LOG_ERROR, "Simple filtergraph '%s' does not have " - "exactly one input and output.\n", graph_desc); + const char *num_inputs; + const char *num_outputs; + if (!outputs) { + num_outputs = "0"; + } else if (outputs->next) { + num_outputs = ">1"; + } else { + num_outputs = "1"; + } + if (!inputs) { + num_inputs = "0"; + } else if (inputs->next) { + num_inputs = ">1"; + } else { + num_inputs = "1"; + } + av_log(NULL, AV_LOG_ERROR, "Simple filtergraph '%s' was expected " + "to have exactly 1 input and 1 output." + " However, it had %s input(s) and %s output(s)." + " Please adjust, or use a complex filtergraph (-filter_complex) instead.\n", + graph_desc, num_inputs, num_outputs); return AVERROR(EINVAL); } - for (cur = inputs; !simple && init && cur; cur = cur->next) - init_input_filter(fg, cur); - for (cur = inputs, i = 0; cur; cur = cur->next, i++) if ((ret = configure_input_filter(fg, fg->inputs[i], cur)) < 0) { avfilter_inout_free(&inputs); @@ -963,27 +1023,12 @@ } avfilter_inout_free(&inputs); - if (!init || simple) { - /* we already know the mappings between lavfi outputs and output streams, - * so we can finish the setup */ - for (cur = outputs, i = 0; cur; cur = cur->next, i++) - configure_output_filter(fg, fg->outputs[i], cur); - avfilter_inout_free(&outputs); + for (cur = outputs, i = 0; cur; cur = cur->next, i++) + configure_output_filter(fg, fg->outputs[i], cur); + avfilter_inout_free(&outputs); - if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0) - return ret; - } else { - /* wait until output mappings are processed */ - for (cur = outputs; cur;) { - GROW_ARRAY(fg->outputs, fg->nb_outputs); - if (!(fg->outputs[fg->nb_outputs - 1] = av_mallocz(sizeof(*fg->outputs[0])))) - exit_program(1); - fg->outputs[fg->nb_outputs - 1]->graph = fg; - fg->outputs[fg->nb_outputs - 1]->out_tmp = cur; - cur = cur->next; - fg->outputs[fg->nb_outputs - 1]->out_tmp->next = NULL; - } - } + if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0) + return ret; fg->reconfiguration = 1; @@ -991,7 +1036,7 @@ OutputStream *ost = fg->outputs[i]->ost; if (ost && ost->enc->type == AVMEDIA_TYPE_AUDIO && - !(ost->enc->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) + !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) av_buffersink_set_frame_size(ost->filter->filter, ost->enc_ctx->frame_size); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/ffmpeg.h ffmpeg-2.7.2~trusty~ppa1/ffmpeg.h --- ffmpeg-2.7.1~trusty~ppa1/ffmpeg.h 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/ffmpeg.h 2015-08-03 17:20:02.000000000 +0000 @@ -63,6 +63,7 @@ HWACCEL_VDPAU, HWACCEL_DXVA2, HWACCEL_VDA, + HWACCEL_VIDEOTOOLBOX, }; typedef struct HWAccel { @@ -92,6 +93,7 @@ /* input/output options */ int64_t start_time; + int64_t start_time_eof; int seek_timestamp; const char *format; @@ -229,6 +231,7 @@ /* temporary storage until stream maps are processed */ AVFilterInOut *out_tmp; + enum AVMediaType type; } OutputFilter; typedef struct FilterGraph { @@ -455,6 +458,15 @@ // number of frames/samples sent to the encoder uint64_t frames_encoded; uint64_t samples_encoded; + + /* packet quality factor */ + int quality; + + /* packet picture type */ + int pict_type; + + /* frame encode sum of squared error values */ + int64_t error[4]; } OutputStream; typedef struct OutputFile { @@ -509,6 +521,7 @@ extern AVIOContext *progress_avio; extern float max_error_rate; extern int vdpau_api_ver; +extern char *videotoolbox_pixfmt; extern const AVIOInterruptCB int_cb; @@ -536,11 +549,13 @@ int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out); int ist_in_filtergraph(FilterGraph *fg, InputStream *ist); FilterGraph *init_simple_filtergraph(InputStream *ist, OutputStream *ost); +int init_complex_filtergraph(FilterGraph *fg); int ffmpeg_parse_options(int argc, char **argv); int vdpau_init(AVCodecContext *s); int dxva2_init(AVCodecContext *s); int vda_init(AVCodecContext *s); +int videotoolbox_init(AVCodecContext *s); #endif /* FFMPEG_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/ffmpeg_opt.c ffmpeg-2.7.2~trusty~ppa1/ffmpeg_opt.c --- ffmpeg-2.7.1~trusty~ppa1/ffmpeg_opt.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/ffmpeg_opt.c 2015-08-03 17:20:02.000000000 +0000 @@ -40,6 +40,9 @@ #include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" #include "libavutil/pixfmt.h" +#include "libavutil/time_internal.h" + +#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass" #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\ {\ @@ -71,7 +74,10 @@ { "dxva2", dxva2_init, HWACCEL_DXVA2, AV_PIX_FMT_DXVA2_VLD }, #endif #if CONFIG_VDA - { "vda", vda_init, HWACCEL_VDA, AV_PIX_FMT_VDA }, + { "vda", videotoolbox_init, HWACCEL_VDA, AV_PIX_FMT_VDA }, +#endif +#if CONFIG_VIDEOTOOLBOX + { "videotoolbox", videotoolbox_init, HWACCEL_VIDEOTOOLBOX, AV_PIX_FMT_VIDEOTOOLBOX }, #endif { 0 }, }; @@ -153,6 +159,7 @@ o->stop_time = INT64_MAX; o->mux_max_delay = 0.7; o->start_time = AV_NOPTS_VALUE; + o->start_time_eof = AV_NOPTS_VALUE; o->recording_time = INT64_MAX; o->limit_filesize = UINT64_MAX; o->chapters_input_file = INT_MAX; @@ -230,6 +237,7 @@ int sync_file_idx = -1, sync_stream_idx = 0; char *p, *sync; char *map; + char *allow_unused; if (*arg == '-') { negative = 1; @@ -274,6 +282,8 @@ exit_program(1); } } else { + if (allow_unused = strchr(map, '?')) + *allow_unused = 0; file_idx = strtol(map, &p, 0); if (file_idx >= nb_input_files || file_idx < 0) { av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx); @@ -311,8 +321,13 @@ } if (!m) { - av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n", arg); - exit_program(1); + if (allow_unused) { + av_log(NULL, AV_LOG_VERBOSE, "Stream map '%s' matches no streams; ignoring.\n", arg); + } else { + av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n" + "To ignore this, add a trailing '?' to the map.\n", arg); + exit_program(1); + } } av_freep(&map); @@ -922,6 +937,12 @@ } } + if (o->start_time_eof != AV_NOPTS_VALUE) { + if (ic->duration>0) { + o->start_time = o->start_time_eof + ic->duration; + } else + av_log(NULL, AV_LOG_WARNING, "Cannot use -sseof, duration of %s not known\n", filename); + } timestamp = (o->start_time == AV_NOPTS_VALUE) ? 0 : o->start_time; /* add the stream start time */ if (!o->seek_timestamp && ic->start_time != AV_NOPTS_VALUE) @@ -1203,12 +1224,13 @@ uint32_t tag = strtol(codec_tag, &next, 0); if (*next) tag = AV_RL32(codec_tag); + ost->st->codec->codec_tag = ost->enc_ctx->codec_tag = tag; } MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st); if (qscale >= 0) { - ost->enc_ctx->flags |= CODEC_FLAG_QSCALE; + ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE; ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale; } @@ -1216,7 +1238,7 @@ ost->disposition = av_strdup(ost->disposition); if (oc->oformat->flags & AVFMT_GLOBALHEADER) - ost->enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER; + ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; av_opt_get_int(o->g->sws_opts, "sws_flags", 0, &ost->sws_flags); @@ -1438,17 +1460,17 @@ video_enc->rc_override_count = i; if (do_psnr) - video_enc->flags|= CODEC_FLAG_PSNR; + video_enc->flags|= AV_CODEC_FLAG_PSNR; /* two pass mode */ MATCH_PER_STREAM_OPT(pass, i, do_pass, oc, st); if (do_pass) { if (do_pass & 1) { - video_enc->flags |= CODEC_FLAG_PASS1; + video_enc->flags |= AV_CODEC_FLAG_PASS1; av_dict_set(&ost->encoder_opts, "flags", "+pass1", AV_DICT_APPEND); } if (do_pass & 2) { - video_enc->flags |= CODEC_FLAG_PASS2; + video_enc->flags |= AV_CODEC_FLAG_PASS2; av_dict_set(&ost->encoder_opts, "flags", "+pass2", AV_DICT_APPEND); } } @@ -1458,6 +1480,40 @@ !(ost->logfile_prefix = av_strdup(ost->logfile_prefix))) exit_program(1); + if (do_pass) { + char logfilename[1024]; + FILE *f; + + snprintf(logfilename, sizeof(logfilename), "%s-%d.log", + ost->logfile_prefix ? ost->logfile_prefix : + DEFAULT_PASS_LOGFILENAME_PREFIX, + i); + if (!strcmp(ost->enc->name, "libx264")) { + av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE); + } else { + if (video_enc->flags & AV_CODEC_FLAG_PASS2) { + char *logbuffer = read_file(logfilename); + + if (!logbuffer) { + av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n", + logfilename); + exit_program(1); + } + video_enc->stats_in = logbuffer; + } + if (video_enc->flags & AV_CODEC_FLAG_PASS1) { + f = av_fopen_utf8(logfilename, "wb"); + if (!f) { + av_log(NULL, AV_LOG_FATAL, + "Cannot write log file '%s' for pass-1 encoding: %s\n", + logfilename, strerror(errno)); + exit_program(1); + } + ost->logfile = f; + } + } + } + MATCH_PER_STREAM_OPT(forced_key_frames, str, ost->forced_keyframes, oc, st); if (ost->forced_keyframes) ost->forced_keyframes = av_strdup(ost->forced_keyframes); @@ -1736,8 +1792,7 @@ { OutputStream *ost; - switch (avfilter_pad_get_type(ofilter->out_tmp->filter_ctx->output_pads, - ofilter->out_tmp->pad_idx)) { + switch (ofilter->type) { case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(o, oc, -1); break; case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(o, oc, -1); break; default: @@ -1770,13 +1825,21 @@ exit_program(1); } - if (configure_output_filter(ofilter->graph, ofilter, ofilter->out_tmp) < 0) { - av_log(NULL, AV_LOG_FATAL, "Error configuring filter.\n"); - exit_program(1); - } avfilter_inout_free(&ofilter->out_tmp); } +static int init_complex_filters(void) +{ + int i, ret = 0; + + for (i = 0; i < nb_filtergraphs; i++) { + ret = init_complex_filtergraph(filtergraphs[i]); + if (ret < 0) + return ret; + } + return 0; +} + static int configure_complex_filters(void) { int i, ret = 0; @@ -1799,10 +1862,6 @@ AVDictionary *unused_opts = NULL; AVDictionaryEntry *e = NULL; - if (configure_complex_filters() < 0) { - av_log(NULL, AV_LOG_FATAL, "Error configuring filters.\n"); - exit_program(1); - } if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) { o->stop_time = INT64_MAX; @@ -1857,8 +1916,7 @@ if (!ofilter->out_tmp || ofilter->out_tmp->name) continue; - switch (avfilter_pad_get_type(ofilter->out_tmp->filter_ctx->output_pads, - ofilter->out_tmp->pad_idx)) { + switch (ofilter->type) { case AVMEDIA_TYPE_VIDEO: o->video_disable = 1; break; case AVMEDIA_TYPE_AUDIO: o->audio_disable = 1; break; case AVMEDIA_TYPE_SUBTITLE: o->subtitle_disable = 1; break; @@ -1917,7 +1975,7 @@ for (i = 0; i < nb_input_streams; i++) { int new_area; ist = input_streams[i]; - new_area = ist->st->codec->width * ist->st->codec->height; + new_area = ist->st->codec->width * ist->st->codec->height + 100000000*!!ist->st->codec_info_nb_frames; if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) new_area = 1; if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && @@ -2026,6 +2084,7 @@ if(o-> data_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_DATA) continue; + ost = NULL; switch (ist->st->codec->codec_type) { case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (o, oc, src_idx); break; case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream (o, oc, src_idx); break; @@ -2049,6 +2108,9 @@ exit_program(1); } } + if (ost) + ost->sync_ist = input_streams[ input_files[map->sync_file_index]->ist_index + + map->sync_stream_index]; } } } @@ -2078,7 +2140,7 @@ avio_read(pb, attachment, len); ost = new_attachment_stream(o, oc, -1); - ost->stream_copy = 0; + ost->stream_copy = 1; ost->attachment_filename = o->attachments[i]; ost->finished = 1; ost->st->codec->extradata = attachment; @@ -2100,6 +2162,12 @@ exit_program(1); } + if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) { + av_dump_format(oc, nb_output_files - 1, oc->filename, 1); + av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", nb_output_files - 1); + exit_program(1); + } + /* check if all codec options have been used */ unused_opts = strip_specifiers(o->g->codec_opts); for (i = of->ost_index; i < nb_output_streams; i++) { @@ -2142,6 +2210,17 @@ } av_dict_free(&unused_opts); + /* set the encoding/decoding_needed flags */ + for (i = of->ost_index; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + + ost->encoding_needed = !ost->stream_copy; + if (ost->encoding_needed && ost->source_index >= 0) { + InputStream *ist = input_streams[ost->source_index]; + ist->decoding_needed |= DECODING_FOR_OST; + } + } + /* check filename in case of an image number is expected */ if (oc->oformat->flags & AVFMT_NEEDNUMBER) { if (!av_filename_number_test(oc->filename)) { @@ -2237,6 +2316,7 @@ char type, *val; const char *stream_spec; int index = 0, j, ret = 0; + char now_time[256]; val = strchr(o->metadata[i].u.str, '='); if (!val) { @@ -2246,6 +2326,17 @@ } *val++ = 0; + if (!strcmp(o->metadata[i].u.str, "creation_time") && + !strcmp(val, "now")) { + time_t now = time(0); + struct tm *ptm, tmbuf; + ptm = localtime_r(&now, &tmbuf); + if (ptm) { + if (strftime(now_time, sizeof(now_time), "%Y-%m-%d %H:%M:%S", ptm)) + val = now_time; + } + } + parse_meta_type(o->metadata[i].specifier, &type, &index, &stream_spec); if (type == 's') { for (j = 0; j < oc->nb_streams; j++) { @@ -2438,8 +2529,10 @@ time_t today2 = time(NULL); struct tm *today = localtime(&today2); - if (!today) - return AVERROR(errno); + if (!today) { // maybe tomorrow + av_log(NULL, AV_LOG_FATAL, "Unable to get current time: %s\n", strerror(errno)); + exit_program(1); + } snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min, today->tm_sec); @@ -2841,6 +2934,13 @@ goto fail; } + /* create the complex filtergraphs */ + ret = init_complex_filters(); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "Error initializing complex filters.\n"); + goto fail; + } + /* open output files */ ret = open_files(&octx.groups[GROUP_OUTFILE], "output", open_output_file); if (ret < 0) { @@ -2848,6 +2948,13 @@ goto fail; } + /* configure the complex filtergraphs */ + ret = configure_complex_filters(); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "Error configuring complex filters.\n"); + goto fail; + } + fail: uninit_parse_context(&octx); if (ret < 0) { @@ -2922,6 +3029,9 @@ { "ss", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(start_time) }, "set the start time offset", "time_off" }, + { "sseof", HAS_ARG | OPT_TIME | OPT_OFFSET | + OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(start_time_eof) }, + "set the start time offset relative to EOF", "time_off" }, { "seek_timestamp", HAS_ARG | OPT_INT | OPT_OFFSET | OPT_INPUT, { .off = OFFSET(seek_timestamp) }, "enable/disable seeking by timestamp with -ss" }, @@ -3126,6 +3236,9 @@ #if HAVE_VDPAU_X11 { "vdpau_api_ver", HAS_ARG | OPT_INT | OPT_EXPERT, { &vdpau_api_ver }, "" }, #endif +#if CONFIG_VDA || CONFIG_VIDEOTOOLBOX + { "videotoolbox_pixfmt", HAS_ARG | OPT_STRING | OPT_EXPERT, { &videotoolbox_pixfmt}, "" }, +#endif { "autorotate", HAS_ARG | OPT_BOOL | OPT_SPEC | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(autorotate) }, "automatically insert correct rotate filters" }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/ffmpeg_vda.c ffmpeg-2.7.2~trusty~ppa1/ffmpeg_vda.c --- ffmpeg-2.7.1~trusty~ppa1/ffmpeg_vda.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/ffmpeg_vda.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,134 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libavcodec/avcodec.h" -#include "libavcodec/vda.h" -#include "libavutil/imgutils.h" - -#include "ffmpeg.h" - -typedef struct VDAContext { - AVFrame *tmp_frame; -} VDAContext; - -static int vda_retrieve_data(AVCodecContext *s, AVFrame *frame) -{ - InputStream *ist = s->opaque; - VDAContext *vda = ist->hwaccel_ctx; - CVPixelBufferRef pixbuf = (CVPixelBufferRef)frame->data[3]; - OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf); - CVReturn err; - uint8_t *data[4] = { 0 }; - int linesize[4] = { 0 }; - int planes, ret, i; - - av_frame_unref(vda->tmp_frame); - - switch (pixel_format) { - case kCVPixelFormatType_420YpCbCr8Planar: vda->tmp_frame->format = AV_PIX_FMT_YUV420P; break; - case kCVPixelFormatType_422YpCbCr8: vda->tmp_frame->format = AV_PIX_FMT_UYVY422; break; - default: - av_log(NULL, AV_LOG_ERROR, - "Unsupported pixel format: %u\n", pixel_format); - return AVERROR(ENOSYS); - } - - vda->tmp_frame->width = frame->width; - vda->tmp_frame->height = frame->height; - ret = av_frame_get_buffer(vda->tmp_frame, 32); - if (ret < 0) - return ret; - - err = CVPixelBufferLockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly); - if (err != kCVReturnSuccess) { - av_log(NULL, AV_LOG_ERROR, "Error locking the pixel buffer.\n"); - return AVERROR_UNKNOWN; - } - - if (CVPixelBufferIsPlanar(pixbuf)) { - - planes = CVPixelBufferGetPlaneCount(pixbuf); - for (i = 0; i < planes; i++) { - data[i] = CVPixelBufferGetBaseAddressOfPlane(pixbuf, i); - linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(pixbuf, i); - } - } else { - data[0] = CVPixelBufferGetBaseAddress(pixbuf); - linesize[0] = CVPixelBufferGetBytesPerRow(pixbuf); - } - - av_image_copy(vda->tmp_frame->data, vda->tmp_frame->linesize, - (const uint8_t **)data, linesize, vda->tmp_frame->format, - frame->width, frame->height); - - ret = av_frame_copy_props(vda->tmp_frame, frame); - if (ret < 0) - return ret; - - av_frame_unref(frame); - av_frame_move_ref(frame, vda->tmp_frame); - - return 0; -} - -static void vda_uninit(AVCodecContext *s) -{ - InputStream *ist = s->opaque; - VDAContext *vda = ist->hwaccel_ctx; - - ist->hwaccel_uninit = NULL; - ist->hwaccel_retrieve_data = NULL; - - av_frame_free(&vda->tmp_frame); - - av_vda_default_free(s); - av_freep(&ist->hwaccel_ctx); -} - -int vda_init(AVCodecContext *s) -{ - InputStream *ist = s->opaque; - int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; - VDAContext *vda; - int ret; - - vda = av_mallocz(sizeof(*vda)); - if (!vda) - return AVERROR(ENOMEM); - - ist->hwaccel_ctx = vda; - ist->hwaccel_uninit = vda_uninit; - ist->hwaccel_retrieve_data = vda_retrieve_data; - - vda->tmp_frame = av_frame_alloc(); - if (!vda->tmp_frame) { - ret = AVERROR(ENOMEM); - goto fail; - } - - ret = av_vda_default_init(s); - if (ret < 0) { - av_log(NULL, loglevel, "Error creating VDA decoder.\n"); - goto fail; - } - - return 0; -fail: - vda_uninit(s); - return ret; -} diff -Nru ffmpeg-2.7.1~trusty~ppa1/ffmpeg_videotoolbox.c ffmpeg-2.7.2~trusty~ppa1/ffmpeg_videotoolbox.c --- ffmpeg-2.7.1~trusty~ppa1/ffmpeg_videotoolbox.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/ffmpeg_videotoolbox.c 2015-08-03 17:20:02.000000000 +0000 @@ -0,0 +1,187 @@ +/* + * 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 + +#include "config.h" +#include "libavcodec/avcodec.h" +#if CONFIG_VDA +# include "libavcodec/vda.h" +#endif +#if CONFIG_VIDEOTOOLBOX +# include "libavcodec/videotoolbox.h" +#endif +#include "libavutil/imgutils.h" +#include "ffmpeg.h" + +typedef struct VTContext { + AVFrame *tmp_frame; +} VTContext; + +char *videotoolbox_pixfmt; + +static int videotoolbox_retrieve_data(AVCodecContext *s, AVFrame *frame) +{ + InputStream *ist = s->opaque; + VTContext *vt = ist->hwaccel_ctx; + CVPixelBufferRef pixbuf = (CVPixelBufferRef)frame->data[3]; + OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf); + CVReturn err; + uint8_t *data[4] = { 0 }; + int linesize[4] = { 0 }; + int planes, ret, i; + char codec_str[32]; + + av_frame_unref(vt->tmp_frame); + + switch (pixel_format) { + case kCVPixelFormatType_420YpCbCr8Planar: vt->tmp_frame->format = AV_PIX_FMT_YUV420P; break; + case kCVPixelFormatType_422YpCbCr8: vt->tmp_frame->format = AV_PIX_FMT_UYVY422; break; + case kCVPixelFormatType_32BGRA: vt->tmp_frame->format = AV_PIX_FMT_BGRA; break; +#ifdef kCFCoreFoundationVersionNumber10_7 + case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange: vt->tmp_frame->format = AV_PIX_FMT_NV12; break; +#endif + default: + av_get_codec_tag_string(codec_str, sizeof(codec_str), s->codec_tag); + av_log(NULL, AV_LOG_ERROR, + "%s: Unsupported pixel format: %s\n", codec_str, videotoolbox_pixfmt); + return AVERROR(ENOSYS); + } + + vt->tmp_frame->width = frame->width; + vt->tmp_frame->height = frame->height; + ret = av_frame_get_buffer(vt->tmp_frame, 32); + if (ret < 0) + return ret; + + err = CVPixelBufferLockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly); + if (err != kCVReturnSuccess) { + av_log(NULL, AV_LOG_ERROR, "Error locking the pixel buffer.\n"); + return AVERROR_UNKNOWN; + } + + if (CVPixelBufferIsPlanar(pixbuf)) { + + planes = CVPixelBufferGetPlaneCount(pixbuf); + for (i = 0; i < planes; i++) { + data[i] = CVPixelBufferGetBaseAddressOfPlane(pixbuf, i); + linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(pixbuf, i); + } + } else { + data[0] = CVPixelBufferGetBaseAddress(pixbuf); + linesize[0] = CVPixelBufferGetBytesPerRow(pixbuf); + } + + av_image_copy(vt->tmp_frame->data, vt->tmp_frame->linesize, + (const uint8_t **)data, linesize, vt->tmp_frame->format, + frame->width, frame->height); + + ret = av_frame_copy_props(vt->tmp_frame, frame); + CVPixelBufferUnlockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly); + if (ret < 0) + return ret; + + av_frame_unref(frame); + av_frame_move_ref(frame, vt->tmp_frame); + + return 0; +} + +static void videotoolbox_uninit(AVCodecContext *s) +{ + InputStream *ist = s->opaque; + VTContext *vt = ist->hwaccel_ctx; + + ist->hwaccel_uninit = NULL; + ist->hwaccel_retrieve_data = NULL; + + av_frame_free(&vt->tmp_frame); + + if (ist->hwaccel_id == HWACCEL_VIDEOTOOLBOX) { +#if CONFIG_VIDEOTOOLBOX + av_videotoolbox_default_free(s); +#endif + } else { +#if CONFIG_VDA + av_vda_default_free(s); +#endif + } + av_freep(&ist->hwaccel_ctx); +} + +int videotoolbox_init(AVCodecContext *s) +{ + InputStream *ist = s->opaque; + int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; + int ret = 0; + VTContext *vt; + + vt = av_mallocz(sizeof(*vt)); + if (!vt) + return AVERROR(ENOMEM); + + ist->hwaccel_ctx = vt; + ist->hwaccel_uninit = videotoolbox_uninit; + ist->hwaccel_retrieve_data = videotoolbox_retrieve_data; + + vt->tmp_frame = av_frame_alloc(); + if (!vt->tmp_frame) { + ret = AVERROR(ENOMEM); + goto fail; + } + + if (ist->hwaccel_id == HWACCEL_VIDEOTOOLBOX) { +#if CONFIG_VIDEOTOOLBOX + if (!videotoolbox_pixfmt) { + ret = av_videotoolbox_default_init(s); + } else { + AVVideotoolboxContext *vtctx = av_videotoolbox_alloc_context(); + CFStringRef pixfmt_str = CFStringCreateWithCString(kCFAllocatorDefault, + videotoolbox_pixfmt, + kCFStringEncodingUTF8); + vtctx->cv_pix_fmt_type = UTGetOSTypeFromString(pixfmt_str); + ret = av_videotoolbox_default_init2(s, vtctx); + CFRelease(pixfmt_str); + } +#endif + } else { +#if CONFIG_VDA + if (!videotoolbox_pixfmt) { + ret = av_vda_default_init(s); + } else { + AVVDAContext *vdactx = av_vda_alloc_context(); + CFStringRef pixfmt_str = CFStringCreateWithCString(kCFAllocatorDefault, + videotoolbox_pixfmt, + kCFStringEncodingUTF8); + vdactx->cv_pix_fmt_type = UTGetOSTypeFromString(pixfmt_str); + ret = av_vda_default_init2(s, vdactx); + CFRelease(pixfmt_str); + } +#endif + } + if (ret < 0) { + av_log(NULL, loglevel, + "Error creating %s decoder.\n", ist->hwaccel_id == HWACCEL_VIDEOTOOLBOX ? "Videotoolbox" : "VDA"); + goto fail; + } + + return 0; +fail: + videotoolbox_uninit(s); + return ret; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/ffplay.c ffmpeg-2.7.2~trusty~ppa1/ffplay.c --- ffmpeg-2.7.1~trusty~ppa1/ffplay.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/ffplay.c 2015-07-29 17:20:04.000000000 +0000 @@ -223,6 +223,9 @@ Decoder viddec; Decoder subdec; + int viddec_width; + int viddec_height; + int audio_stream; int av_sync_type; @@ -278,6 +281,7 @@ #if !CONFIG_AVFILTER struct SwsContext *img_convert_ctx; #endif + struct SwsContext *sub_convert_ctx; SDL_Rect last_display_rect; int eof; @@ -829,229 +833,50 @@ #define ALPHA_BLEND(a, oldp, newp, s)\ ((((oldp << s) * (255 - (a))) + (newp * (a))) / (255 << s)) -#define RGBA_IN(r, g, b, a, s)\ -{\ - unsigned int v = ((const uint32_t *)(s))[0];\ - a = (v >> 24) & 0xff;\ - r = (v >> 16) & 0xff;\ - g = (v >> 8) & 0xff;\ - b = v & 0xff;\ -} - -#define YUVA_IN(y, u, v, a, s, pal)\ -{\ - unsigned int val = ((const uint32_t *)(pal))[*(const uint8_t*)(s)];\ - a = (val >> 24) & 0xff;\ - y = (val >> 16) & 0xff;\ - u = (val >> 8) & 0xff;\ - v = val & 0xff;\ -} - -#define YUVA_OUT(d, y, u, v, a)\ -{\ - ((uint32_t *)(d))[0] = (a << 24) | (y << 16) | (u << 8) | v;\ -} #define BPP 1 static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, int imgh) { - int wrap, wrap3, width2, skip2; - int y, u, v, a, u1, v1, a1, w, h; + int x, y, Y, U, V, A; uint8_t *lum, *cb, *cr; - const uint8_t *p; - const uint32_t *pal; int dstx, dsty, dstw, dsth; + const AVPicture *src = &rect->pict; dstw = av_clip(rect->w, 0, imgw); dsth = av_clip(rect->h, 0, imgh); dstx = av_clip(rect->x, 0, imgw - dstw); dsty = av_clip(rect->y, 0, imgh - dsth); - lum = dst->data[0] + dsty * dst->linesize[0]; - cb = dst->data[1] + (dsty >> 1) * dst->linesize[1]; - cr = dst->data[2] + (dsty >> 1) * dst->linesize[2]; - - width2 = ((dstw + 1) >> 1) + (dstx & ~dstw & 1); - skip2 = dstx >> 1; - wrap = dst->linesize[0]; - wrap3 = rect->pict.linesize[0]; - p = rect->pict.data[0]; - pal = (const uint32_t *)rect->pict.data[1]; /* Now in YCrCb! */ - - if (dsty & 1) { - lum += dstx; - cb += skip2; - cr += skip2; - - if (dstx & 1) { - YUVA_IN(y, u, v, a, p, pal); - lum[0] = ALPHA_BLEND(a, lum[0], y, 0); - cb[0] = ALPHA_BLEND(a >> 2, cb[0], u, 0); - cr[0] = ALPHA_BLEND(a >> 2, cr[0], v, 0); - cb++; - cr++; - lum++; - p += BPP; - } - for (w = dstw - (dstx & 1); w >= 2; w -= 2) { - YUVA_IN(y, u, v, a, p, pal); - u1 = u; - v1 = v; - a1 = a; - lum[0] = ALPHA_BLEND(a, lum[0], y, 0); - - YUVA_IN(y, u, v, a, p + BPP, pal); - u1 += u; - v1 += v; - a1 += a; - lum[1] = ALPHA_BLEND(a, lum[1], y, 0); - cb[0] = ALPHA_BLEND(a1 >> 2, cb[0], u1, 1); - cr[0] = ALPHA_BLEND(a1 >> 2, cr[0], v1, 1); - cb++; - cr++; - p += 2 * BPP; - lum += 2; - } - if (w) { - YUVA_IN(y, u, v, a, p, pal); - lum[0] = ALPHA_BLEND(a, lum[0], y, 0); - cb[0] = ALPHA_BLEND(a >> 2, cb[0], u, 0); - cr[0] = ALPHA_BLEND(a >> 2, cr[0], v, 0); - p++; + lum = dst->data[0] + dstx + dsty * dst->linesize[0]; + cb = dst->data[1] + dstx/2 + (dsty >> 1) * dst->linesize[1]; + cr = dst->data[2] + dstx/2 + (dsty >> 1) * dst->linesize[2]; + + for (y = 0; ydata[0][x + y*src->linesize[0]]; + A = src->data[3][x + y*src->linesize[3]]; + lum[0] = ALPHA_BLEND(A, lum[0], Y, 0); lum++; } - p += wrap3 - dstw * BPP; - lum += wrap - dstw - dstx; - cb += dst->linesize[1] - width2 - skip2; - cr += dst->linesize[2] - width2 - skip2; - } - for (h = dsth - (dsty & 1); h >= 2; h -= 2) { - lum += dstx; - cb += skip2; - cr += skip2; - - if (dstx & 1) { - YUVA_IN(y, u, v, a, p, pal); - u1 = u; - v1 = v; - a1 = a; - lum[0] = ALPHA_BLEND(a, lum[0], y, 0); - p += wrap3; - lum += wrap; - YUVA_IN(y, u, v, a, p, pal); - u1 += u; - v1 += v; - a1 += a; - lum[0] = ALPHA_BLEND(a, lum[0], y, 0); - cb[0] = ALPHA_BLEND(a1 >> 2, cb[0], u1, 1); - cr[0] = ALPHA_BLEND(a1 >> 2, cr[0], v1, 1); - cb++; - cr++; - p += -wrap3 + BPP; - lum += -wrap + 1; - } - for (w = dstw - (dstx & 1); w >= 2; w -= 2) { - YUVA_IN(y, u, v, a, p, pal); - u1 = u; - v1 = v; - a1 = a; - lum[0] = ALPHA_BLEND(a, lum[0], y, 0); - - YUVA_IN(y, u, v, a, p + BPP, pal); - u1 += u; - v1 += v; - a1 += a; - lum[1] = ALPHA_BLEND(a, lum[1], y, 0); - p += wrap3; - lum += wrap; - - YUVA_IN(y, u, v, a, p, pal); - u1 += u; - v1 += v; - a1 += a; - lum[0] = ALPHA_BLEND(a, lum[0], y, 0); - - YUVA_IN(y, u, v, a, p + BPP, pal); - u1 += u; - v1 += v; - a1 += a; - lum[1] = ALPHA_BLEND(a, lum[1], y, 0); - - cb[0] = ALPHA_BLEND(a1 >> 2, cb[0], u1, 2); - cr[0] = ALPHA_BLEND(a1 >> 2, cr[0], v1, 2); + lum += dst->linesize[0] - dstw; + } + for (y = 0; ydata[1][x + y*src->linesize[1]]; + V = src->data[2][x + y*src->linesize[2]]; + A = src->data[3][2*x + 2*y *src->linesize[3]] + + src->data[3][2*x + 1 + 2*y *src->linesize[3]] + + src->data[3][2*x + 1 + (2*y+1)*src->linesize[3]] + + src->data[3][2*x + (2*y+1)*src->linesize[3]]; + cb[0] = ALPHA_BLEND(A>>2, cb[0], U, 0); + cr[0] = ALPHA_BLEND(A>>2, cr[0], V, 0); cb++; cr++; - p += -wrap3 + 2 * BPP; - lum += -wrap + 2; - } - if (w) { - YUVA_IN(y, u, v, a, p, pal); - u1 = u; - v1 = v; - a1 = a; - lum[0] = ALPHA_BLEND(a, lum[0], y, 0); - p += wrap3; - lum += wrap; - YUVA_IN(y, u, v, a, p, pal); - u1 += u; - v1 += v; - a1 += a; - lum[0] = ALPHA_BLEND(a, lum[0], y, 0); - cb[0] = ALPHA_BLEND(a1 >> 2, cb[0], u1, 1); - cr[0] = ALPHA_BLEND(a1 >> 2, cr[0], v1, 1); - cb++; - cr++; - p += -wrap3 + BPP; - lum += -wrap + 1; - } - p += wrap3 + (wrap3 - dstw * BPP); - lum += wrap + (wrap - dstw - dstx); - cb += dst->linesize[1] - width2 - skip2; - cr += dst->linesize[2] - width2 - skip2; - } - /* handle odd height */ - if (h) { - lum += dstx; - cb += skip2; - cr += skip2; - - if (dstx & 1) { - YUVA_IN(y, u, v, a, p, pal); - lum[0] = ALPHA_BLEND(a, lum[0], y, 0); - cb[0] = ALPHA_BLEND(a >> 2, cb[0], u, 0); - cr[0] = ALPHA_BLEND(a >> 2, cr[0], v, 0); - cb++; - cr++; - lum++; - p += BPP; - } - for (w = dstw - (dstx & 1); w >= 2; w -= 2) { - YUVA_IN(y, u, v, a, p, pal); - u1 = u; - v1 = v; - a1 = a; - lum[0] = ALPHA_BLEND(a, lum[0], y, 0); - - YUVA_IN(y, u, v, a, p + BPP, pal); - u1 += u; - v1 += v; - a1 += a; - lum[1] = ALPHA_BLEND(a, lum[1], y, 0); - cb[0] = ALPHA_BLEND(a1 >> 2, cb[0], u, 1); - cr[0] = ALPHA_BLEND(a1 >> 2, cr[0], v, 1); - cb++; - cr++; - p += 2 * BPP; - lum += 2; - } - if (w) { - YUVA_IN(y, u, v, a, p, pal); - lum[0] = ALPHA_BLEND(a, lum[0], y, 0); - cb[0] = ALPHA_BLEND(a >> 2, cb[0], u, 0); - cr[0] = ALPHA_BLEND(a >> 2, cr[0], v, 0); } + cb += dst->linesize[1] - dstw/2; + cr += dst->linesize[2] - dstw/2; } } @@ -1306,6 +1131,7 @@ #if !CONFIG_AVFILTER sws_freeContext(is->img_convert_ctx); #endif + sws_freeContext(is->sub_convert_ctx); av_free(is); } @@ -1893,6 +1719,9 @@ frame->sample_aspect_ratio = av_guess_sample_aspect_ratio(is->ic, is->video_st, frame); + is->viddec_width = frame->width; + is->viddec_height = frame->height; + if (framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) { if (frame->pts != AV_NOPTS_VALUE) { double diff = dpts - get_master_clock(is); @@ -2328,8 +2157,7 @@ Frame *sp; int got_subtitle; double pts; - int i, j; - int r, g, b, y, u, v, a; + int i; for (;;) { if (!(sp = frame_queue_peek_writable(&is->subpq))) @@ -2348,14 +2176,41 @@ for (i = 0; i < sp->sub.num_rects; i++) { - for (j = 0; j < sp->sub.rects[i]->nb_colors; j++) - { - RGBA_IN(r, g, b, a, (uint32_t*)sp->sub.rects[i]->pict.data[1] + j); - y = RGB_TO_Y_CCIR(r, g, b); - u = RGB_TO_U_CCIR(r, g, b, 0); - v = RGB_TO_V_CCIR(r, g, b, 0); - YUVA_OUT((uint32_t*)sp->sub.rects[i]->pict.data[1] + j, y, u, v, a); + int in_w = sp->sub.rects[i]->w; + int in_h = sp->sub.rects[i]->h; + int subw = is->subdec.avctx->width ? is->subdec.avctx->width : is->viddec_width; + int subh = is->subdec.avctx->height ? is->subdec.avctx->height : is->viddec_height; + int out_w = is->viddec_width ? in_w * is->viddec_width / subw : in_w; + int out_h = is->viddec_height ? in_h * is->viddec_height / subh : in_h; + AVPicture newpic; + + //can not use avpicture_alloc as it is not compatible with avsubtitle_free() + av_image_fill_linesizes(newpic.linesize, AV_PIX_FMT_YUVA420P, out_w); + newpic.data[0] = av_malloc(newpic.linesize[0] * out_h); + newpic.data[3] = av_malloc(newpic.linesize[3] * out_h); + newpic.data[1] = av_malloc(newpic.linesize[1] * ((out_h+1)/2)); + newpic.data[2] = av_malloc(newpic.linesize[2] * ((out_h+1)/2)); + + is->sub_convert_ctx = sws_getCachedContext(is->sub_convert_ctx, + in_w, in_h, AV_PIX_FMT_PAL8, out_w, out_h, + AV_PIX_FMT_YUVA420P, sws_flags, NULL, NULL, NULL); + if (!is->sub_convert_ctx || !newpic.data[0] || !newpic.data[3] || + !newpic.data[1] || !newpic.data[2] + ) { + av_log(NULL, AV_LOG_FATAL, "Cannot initialize the sub conversion context\n"); + exit(1); } + sws_scale(is->sub_convert_ctx, + (void*)sp->sub.rects[i]->pict.data, sp->sub.rects[i]->pict.linesize, + 0, in_h, newpic.data, newpic.linesize); + + av_free(sp->sub.rects[i]->pict.data[0]); + av_free(sp->sub.rects[i]->pict.data[1]); + sp->sub.rects[i]->pict = newpic; + sp->sub.rects[i]->w = out_w; + sp->sub.rects[i]->h = out_h; + sp->sub.rects[i]->x = sp->sub.rects[i]->x * out_w / in_w; + sp->sub.rects[i]->y = sp->sub.rects[i]->y * out_h / in_h; } /* now we can update the picture count */ @@ -2696,8 +2551,9 @@ av_codec_set_lowres(avctx, stream_lowres); if(stream_lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE; - if (fast) avctx->flags2 |= CODEC_FLAG2_FAST; - if(codec->capabilities & CODEC_CAP_DR1) + if (fast) + avctx->flags2 |= AV_CODEC_FLAG2_FAST; + if(codec->capabilities & AV_CODEC_CAP_DR1) avctx->flags |= CODEC_FLAG_EMU_EDGE; opts = filter_codec_opts(codec_opts, avctx->codec_id, ic, ic->streams[stream_index], codec); @@ -2771,6 +2627,9 @@ is->video_stream = stream_index; is->video_st = ic->streams[stream_index]; + is->viddec_width = avctx->width; + is->viddec_height = avctx->height; + decoder_init(&is->viddec, avctx, &is->videoq, is->continue_read_thread); decoder_start(&is->viddec, video_thread, is); is->queue_attachments_req = 1; diff -Nru ffmpeg-2.7.1~trusty~ppa1/ffprobe.c ffmpeg-2.7.2~trusty~ppa1/ffprobe.c --- ffmpeg-2.7.1~trusty~ppa1/ffprobe.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/ffprobe.c 2015-06-13 17:20:02.000000000 +0000 @@ -2831,6 +2831,9 @@ char *buf = av_asprintf("format=%s", arg); int ret; + if (!buf) + return AVERROR(ENOMEM); + av_log(NULL, AV_LOG_WARNING, "Option '%s' is deprecated, use '-show_entries format=%s' instead\n", opt, arg); diff -Nru ffmpeg-2.7.1~trusty~ppa1/ffserver.c ffmpeg-2.7.2~trusty~ppa1/ffserver.c --- ffmpeg-2.7.1~trusty~ppa1/ffserver.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/ffserver.c 2015-07-28 17:20:07.000000000 +0000 @@ -31,7 +31,7 @@ #include #include #include "libavformat/avformat.h" -// FIXME those are internal headers, ffserver _really_ shouldn't use them +/* FIXME: those are internal headers, ffserver _really_ shouldn't use them */ #include "libavformat/ffm.h" #include "libavformat/network.h" #include "libavformat/os_support.h" @@ -209,6 +209,7 @@ /* HTTP handling */ static int handle_connection(HTTPContext *c); +static inline void print_stream_params(AVIOContext *pb, FFServerStream *stream); static void compute_status(HTTPContext *c); static int open_input_stream(HTTPContext *c, const char *info); static int http_parse_request(HTTPContext *c); @@ -250,7 +251,8 @@ static uint64_t current_bandwidth; -static int64_t cur_time; // Making this global saves on passing it around everywhere +/* Making this global saves on passing it around everywhere */ +static int64_t cur_time; static AVLFG random_state; @@ -314,12 +316,12 @@ static void http_vlog(const char *fmt, va_list vargs) { static int print_prefix = 1; + char buf[32]; if (!logfile) return; if (print_prefix) { - char buf[32]; ctime1(buf, sizeof(buf)); fprintf(logfile, "%s ", buf); } @@ -504,8 +506,7 @@ random1 = av_lfg_get(&random_state); /* open the RTP connection */ - snprintf(session_id, sizeof(session_id), "%08x%08x", - random0, random1); + snprintf(session_id, sizeof(session_id), "%08x%08x", random0, random1); /* choose a port if none given */ if (stream->multicast_port == 0) { @@ -630,9 +631,8 @@ poll_entry++; } else { /* when ffserver is doing the timing, we work by - looking at which packet needs to be sent every - 10 ms */ - /* one tick wait XXX: 10 ms assumed */ + * looking at which packet needs to be sent every + * 10 ms (one tick wait XXX: 10 ms assumed) */ if (delay > 10) delay = 10; } @@ -655,7 +655,7 @@ } /* wait for an event on one connection. We poll at least every - second to handle timeouts */ + * second to handle timeouts */ do { ret = poll(poll_table, poll_entry - poll_table, delay); if (ret < 0 && ff_neterrno() != AVERROR(EAGAIN) && @@ -703,13 +703,9 @@ c->buffer_ptr = c->buffer; c->buffer_end = c->buffer + c->buffer_size - 1; /* leave room for '\0' */ - if (is_rtsp) { - c->timeout = cur_time + RTSP_REQUEST_TIMEOUT; - c->state = RTSPSTATE_WAIT_REQUEST; - } else { - c->timeout = cur_time + HTTP_REQUEST_TIMEOUT; - c->state = HTTPSTATE_WAIT_REQUEST; - } + c->state = is_rtsp ? RTSPSTATE_WAIT_REQUEST : HTTPSTATE_WAIT_REQUEST; + c->timeout = cur_time + + (is_rtsp ? RTSP_REQUEST_TIMEOUT : HTTP_REQUEST_TIMEOUT); } static void http_send_too_busy_reply(int fd) @@ -787,7 +783,6 @@ HTTPContext **cp, *c1; int i, nb_streams; AVFormatContext *ctx; - URLContext *h; AVStream *st; /* remove connection from list */ @@ -832,9 +827,7 @@ av_freep(&ctx->streams[0]); av_freep(&ctx); } - h = c->rtp_handles[i]; - if (h) - ffurl_close(h); + ffurl_close(c->rtp_handles[i]); } ctx = &c->fmt_ctx; @@ -903,11 +896,11 @@ if ((ptr >= c->buffer + 2 && !memcmp(ptr-2, "\n\n", 2)) || (ptr >= c->buffer + 4 && !memcmp(ptr-4, "\r\n\r\n", 4))) { /* request found : parse it and reply */ - if (c->state == HTTPSTATE_WAIT_REQUEST) { + if (c->state == HTTPSTATE_WAIT_REQUEST) ret = http_parse_request(c); - } else { + else ret = rtsp_parse_request(c); - } + if (ret < 0) return -1; } else if (ptr >= c->buffer_end) { @@ -952,8 +945,8 @@ case HTTPSTATE_SEND_DATA_HEADER: case HTTPSTATE_SEND_DATA_TRAILER: /* for packetized output, we consider we can always write (the - input streams set the speed). It may be better to verify - that we do not rely too much on the kernel queues */ + * input streams set the speed). It may be better to verify + * that we do not rely too much on the kernel queues */ if (!c->is_packetized) { if (c->poll_entry->revents & (POLLERR | POLLHUP)) return -1; @@ -1166,8 +1159,10 @@ break; } - if (c->switch_feed_streams[i] >= 0 && c->switch_feed_streams[i] != c->feed_streams[i]) + if (c->switch_feed_streams[i] >= 0 && + c->switch_feed_streams[i] != c->feed_streams[i]) { action_required = 1; + } } return action_required; @@ -1271,17 +1266,17 @@ if (stream->dynamic_acl[0]) { acl = parse_dynamic_acl(stream, c); - ret = validate_acl_list(acl, c); - free_acl_list(acl); } return ret; } -/* compute the real filename of a file by matching it without its - extensions to all the stream's filenames */ +/** + * compute the real filename of a file by matching it without its + * extensions to all the stream's filenames + */ static void compute_real_filename(char *filename, int max_size) { char file1[1024]; @@ -1399,7 +1394,7 @@ compute_real_filename(filename, sizeof(filename) - 1); } - // "redirect" / request to index.html + /* "redirect" request to index.html */ if (!strlen(filename)) av_strlcpy(filename, "index.html", sizeof(filename) - 1); @@ -1738,8 +1733,9 @@ return 0; send_status: compute_status(c); - c->http_error = 200; /* horrible : we use this value to avoid - going to the send data state */ + /* horrible: we use this value to avoid + * going to the send data state */ + c->http_error = 200; c->state = HTTPSTATE_SEND_HEADER; return 0; } @@ -1754,6 +1750,52 @@ avio_printf(pb, "%"PRId64"%c", count, *s); } +static inline void print_stream_params(AVIOContext *pb, FFServerStream *stream) +{ + int i, stream_no; + const char *type = "unknown"; + char parameters[64]; + AVStream *st; + AVCodec *codec; + + stream_no = stream->nb_streams; + + avio_printf(pb, "
Stream" + "typekbits/scodec" + "Parameters\n"); + + for (i = 0; i < stream_no; i++) { + st = stream->streams[i]; + codec = avcodec_find_encoder(st->codec->codec_id); + + parameters[0] = 0; + + switch(st->codec->codec_type) { + case AVMEDIA_TYPE_AUDIO: + type = "audio"; + snprintf(parameters, sizeof(parameters), "%d channel(s), %d Hz", + st->codec->channels, st->codec->sample_rate); + break; + case AVMEDIA_TYPE_VIDEO: + type = "video"; + snprintf(parameters, sizeof(parameters), + "%dx%d, q=%d-%d, fps=%d", st->codec->width, + st->codec->height, st->codec->qmin, st->codec->qmax, + st->codec->time_base.den / st->codec->time_base.num); + break; + default: + abort(); + } + + avio_printf(pb, "
%d%s%d" + "%s%s\n", + i, type, st->codec->bit_rate/1000, + codec ? codec->name : "", parameters); + } + + avio_printf(pb, "
\n"); +} + static void compute_status(HTTPContext *c) { HTTPContext *c1; @@ -1804,8 +1846,8 @@ strcpy(eosf - 3, ".ram"); else if (stream->fmt && !strcmp(stream->fmt->name, "rtp")) { /* generate a sample RTSP director if - unicast. Generate an SDP redirector if - multicast */ + * unicast. Generate an SDP redirector if + * multicast */ eosf = strrchr(sfilename, '.'); if (!eosf) eosf = sfilename + strlen(sfilename); @@ -1924,42 +1966,7 @@ avio_printf(pb, "

"); } - avio_printf(pb, "
Stream" - "typekbits/scodec" - "Parameters\n"); - - for (i = 0; i < stream->nb_streams; i++) { - AVStream *st = stream->streams[i]; - AVCodec *codec = avcodec_find_encoder(st->codec->codec_id); - const char *type = "unknown"; - char parameters[64]; - - parameters[0] = 0; - - switch(st->codec->codec_type) { - case AVMEDIA_TYPE_AUDIO: - type = "audio"; - snprintf(parameters, sizeof(parameters), "%d channel(s), %d Hz", - st->codec->channels, st->codec->sample_rate); - break; - case AVMEDIA_TYPE_VIDEO: - type = "video"; - snprintf(parameters, sizeof(parameters), - "%dx%d, q=%d-%d, fps=%d", st->codec->width, - st->codec->height, st->codec->qmin, st->codec->qmax, - st->codec->time_base.den / st->codec->time_base.num); - break; - default: - abort(); - } - - avio_printf(pb, "
%d%s%d" - "%s%s\n", - i, type, st->codec->bit_rate/1000, - codec ? codec->name : "", parameters); - } - - avio_printf(pb, "
\n"); + print_stream_params(pb, stream); stream = stream->next; } @@ -2111,8 +2118,7 @@ return (cur_time - c->start_time) * 1000; } -/* return the estimated time at which the current packet must be sent - (in us) */ +/* return the estimated time (in us) at which the current packet must be sent */ static int64_t get_packet_send_clock(HTTPContext *c) { int bytes_left, bytes_sent, frame_bytes; @@ -2120,11 +2126,10 @@ frame_bytes = c->cur_frame_bytes; if (frame_bytes <= 0) return c->cur_pts; - else { - bytes_left = c->buffer_end - c->buffer_ptr; - bytes_sent = frame_bytes - bytes_left; - return c->cur_pts + (c->cur_frame_duration * bytes_sent) / frame_bytes; - } + + bytes_left = c->buffer_end - c->buffer_ptr; + bytes_sent = frame_bytes - bytes_left; + return c->cur_pts + (c->cur_frame_duration * bytes_sent) / frame_bytes; } @@ -2151,7 +2156,8 @@ AVStream *src; c->fmt_ctx.streams[i] = av_mallocz(sizeof(AVStream)); - /* if file or feed, then just take streams from FFServerStream struct */ + /* if file or feed, then just take streams from FFServerStream + * struct */ if (!c->stream->feed || c->stream->feed == c->stream) src = c->stream->streams[i]; @@ -2216,23 +2222,23 @@ if (ret < 0) { if (c->stream->feed) { /* if coming from feed, it means we reached the end of the - ffm file, so must wait for more data */ + * ffm file, so must wait for more data */ c->state = HTTPSTATE_WAIT_FEED; return 1; /* state changed */ - } else if (ret == AVERROR(EAGAIN)) { + } + if (ret == AVERROR(EAGAIN)) { /* input not ready, come back later */ return 0; + } + if (c->stream->loop) { + avformat_close_input(&c->fmt_in); + if (open_input_stream(c, "") < 0) + goto no_loop; + goto redo; } else { - if (c->stream->loop) { - avformat_close_input(&c->fmt_in); - if (open_input_stream(c, "") < 0) - goto no_loop; - goto redo; - } else { no_loop: /* must send trailer now because EOF or error */ c->state = HTTPSTATE_SEND_DATA_TRAILER; - } } } else { int source_index = pkt.stream_index; @@ -2303,9 +2309,9 @@ max_packet_size = c->rtp_handles[c->packet_stream_index]->max_packet_size; ret = ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size); - } else { + } else ret = avio_open_dyn_buf(&ctx->pb); - } + if (ret < 0) { /* XXX: potential leak */ return -1; @@ -2368,7 +2374,8 @@ /* should convert the format at the same time */ /* send data starting at c->buffer_ptr to the output connection - * (either UDP or TCP) */ + * (either UDP or TCP) + */ static int http_send_data(HTTPContext *c) { int len, ret; @@ -2449,8 +2456,8 @@ rtsp_c->packet_buffer_ptr += len; if (rtsp_c->packet_buffer_ptr < rtsp_c->packet_buffer_end) { /* if we could not send all the data, we will - send it later, so a new state is needed to - "lock" the RTSP TCP connection */ + * send it later, so a new state is needed to + * "lock" the RTSP TCP connection */ rtsp_c->state = RTSPSTATE_SEND_PACKET; break; } else @@ -2534,9 +2541,8 @@ http_log("Error reading write index from feed file '%s': %s\n", c->stream->feed_filename, strerror(errno)); return ret; - } else { - c->stream->feed_write_index = ret; } + c->stream->feed_write_index = ret; } c->stream->feed_write_index = FFMAX(ffm_read_write_index(fd), @@ -2578,12 +2584,11 @@ goto fail; c->buffer_ptr = c->buffer; break; - } else if (++loop_run > 10) { + } else if (++loop_run > 10) /* no chunk header, abort */ goto fail; - } else { + else c->buffer_ptr++; - } } if (c->buffer_end > c->buffer_ptr) { @@ -2616,7 +2621,7 @@ if (c->buffer_ptr >= c->buffer_end) { FFServerStream *feed = c->stream; /* a packet has been received : write it in the store, except - if header */ + * if header */ if (c->data_count > FFM_PACKET_SIZE) { /* XXX: use llseek or url_seek * XXX: Should probably fail? */ @@ -2822,10 +2827,10 @@ the_end: len = avio_close_dyn_buf(c->pb, &c->pb_buffer); c->pb = NULL; /* safety */ - if (len < 0) { + if (len < 0) /* XXX: cannot do more */ return -1; - } + c->buffer_ptr = c->pb_buffer; c->buffer_end = c->pb_buffer + len; c->state = RTSPSTATE_SEND_REPLY; @@ -2844,9 +2849,9 @@ *pbuffer = NULL; avc = avformat_alloc_context(); - if (!avc || !rtp_format) { + if (!avc || !rtp_format) return -1; - } + avc->oformat = rtp_format; av_dict_set(&avc->metadata, "title", entry ? entry->value : "No Title", 0); @@ -2855,9 +2860,8 @@ snprintf(avc->filename, 1024, "rtp://%s:%d?multicast=1?ttl=%d", inet_ntoa(stream->multicast_ip), stream->multicast_port, stream->multicast_ttl); - } else { + } else snprintf(avc->filename, 1024, "rtp://0.0.0.0"); - } avc->streams = av_malloc_array(avc->nb_streams, sizeof(*avc->streams)); if (!avc->streams) @@ -2887,7 +2891,7 @@ static void rtsp_cmd_options(HTTPContext *c, const char *url) { -// rtsp_reply_header(c, RTSP_STATUS_OK); + /* rtsp_reply_header(c, RTSP_STATUS_OK); */ avio_printf(c->pb, "RTSP/1.0 %d %s\r\n", RTSP_STATUS_OK, "OK"); avio_printf(c->pb, "CSeq: %d\r\n", c->seq); avio_printf(c->pb, "Public: %s\r\n", @@ -3054,7 +3058,7 @@ } /* test if stream is OK (test needed because several SETUP needs - to be done for a given file) */ + * to be done for a given file) */ if (rtp_c->stream != stream) { rtsp_reply_error(c, RTSP_STATUS_SERVICE); return; @@ -3115,8 +3119,10 @@ } -/* find an RTP connection by using the session ID. Check consistency - with filename */ +/** + * find an RTP connection by using the session ID. Check consistency + * with filename + */ static HTTPContext *find_rtp_session_with_url(const char *url, const char *session_id) { @@ -3139,10 +3145,10 @@ for(s=0; sstream->nb_streams; ++s) { snprintf(buf, sizeof(buf), "%s/streamid=%d", rtp_c->stream->filename, s); - if(!strncmp(path, buf, sizeof(buf))) { - // XXX: Should we reply with RTSP_STATUS_ONLY_AGGREGATE if nb_streams>1? + if(!strncmp(path, buf, sizeof(buf))) + /* XXX: Should we reply with RTSP_STATUS_ONLY_AGGREGATE + * if nb_streams>1? */ return rtp_c; - } } len = strlen(path); if (len > 0 && path[len - 1] == '/' && @@ -3220,7 +3226,7 @@ const char *proto_str; /* XXX: should output a warning page when coming - close to the connection limit */ + * close to the connection limit */ if (nb_connections >= config.nb_max_connections) goto fail; @@ -3275,9 +3281,11 @@ return NULL; } -/* add a new RTP stream in an RTP connection (used in RTSP SETUP - command). If RTP/TCP protocol is used, TCP connection 'rtsp_c' is - used. */ +/** + * add a new RTP stream in an RTP connection (used in RTSP SETUP + * command). If RTP/TCP protocol is used, TCP connection 'rtsp_c' is + * used. + */ static int rtp_new_av_stream(HTTPContext *c, int stream_index, struct sockaddr_in *dest_addr, HTTPContext *rtsp_c) @@ -3355,10 +3363,10 @@ /* normally, no packets should be output here, but the packet size may * be checked */ - if (ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) { + if (ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) /* XXX: close stream */ goto fail; - } + if (avformat_write_header(ctx, NULL) < 0) { fail: if (h) @@ -3395,12 +3403,12 @@ return NULL; } avcodec_copy_context(fst->codec, codec); - } else { + } else /* live streams must use the actual feed's codec since it may be * updated later to carry extradata needed by them. */ fst->codec = codec; - } + fst->priv_data = av_mallocz(sizeof(FeedData)); fst->index = stream->nb_streams; avpriv_set_pts_info(fst, 33, 1, 90000); @@ -3502,7 +3510,7 @@ if (p[0] == 0x00 && p[1] == 0x00 && p[2] == 0x01 && p[3] == 0xb6) { size = p - pkt.data; - st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE); + st->codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); st->codec->extradata_size = size; memcpy(st->codec->extradata, pkt.data, size); break; @@ -3532,7 +3540,7 @@ /* open stream */ if (stream->fmt && !strcmp(stream->fmt->name, "rtp")) { /* specific case : if transport stream output to RTP, - we use a raw transport stream reader */ + * we use a raw transport stream reader */ av_dict_set(&stream->in_opts, "mpeg2ts_compute_pcr", "1", 0); } @@ -3554,7 +3562,7 @@ remove_stream(stream); } else { /* find all the AVStreams inside and reference them in - 'stream' */ + * 'stream' */ if (avformat_find_stream_info(infile, NULL) < 0) { http_log("Could not find codec parameters from '%s'\n", stream->feed_filename); @@ -3581,16 +3589,17 @@ /* gather all streams */ for(stream = config.first_stream; stream; stream = stream->next) { feed = stream->feed; - if (feed) { - if (stream->is_feed) { - for(i=0;inb_streams;i++) - stream->feed_streams[i] = i; - } else { - /* we handle a stream coming from a feed */ - for(i=0;inb_streams;i++) - stream->feed_streams[i] = add_av_stream(feed, - stream->streams[i]); - } + if (!feed) + continue; + + if (stream->is_feed) { + for(i=0;inb_streams;i++) + stream->feed_streams[i] = i; + } else { + /* we handle a stream coming from a feed */ + for(i=0;inb_streams;i++) + stream->feed_streams[i] = add_av_stream(feed, + stream->streams[i]); } } @@ -3757,24 +3766,24 @@ static void handle_child_exit(int sig) { pid_t pid; - int status; + int status, uptime; while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { FFServerStream *feed; for (feed = config.first_feed; feed; feed = feed->next) { - if (feed->pid == pid) { - int uptime = time(0) - feed->pid_start; + if (feed->pid != pid) + continue; - feed->pid = 0; - fprintf(stderr, - "%s: Pid %d exited with status %d after %d seconds\n", - feed->filename, pid, status, uptime); - - if (uptime < 30) - /* Turn off any more restarts */ - ffserver_free_child_args(&feed->child_argv); - } + uptime = time(0) - feed->pid_start; + feed->pid = 0; + fprintf(stderr, + "%s: Pid %d exited with status %d after %d seconds\n", + feed->filename, pid, status, uptime); + + if (uptime < 30) + /* Turn off any more restarts */ + ffserver_free_child_args(&feed->child_argv); } } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/012v.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/012v.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/012v.c 2015-06-18 18:54:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/012v.c 2015-07-28 17:20:07.000000000 +0000 @@ -151,5 +151,5 @@ .id = AV_CODEC_ID_012V, .init = zero12v_decode_init, .decode = zero12v_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/4xm.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/4xm.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/4xm.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/4xm.c 2015-07-28 17:20:07.000000000 +0000 @@ -559,7 +559,7 @@ idct(block[i]); } - if (!(f->avctx->flags & CODEC_FLAG_GRAY)) { + if (!(f->avctx->flags & AV_CODEC_FLAG_GRAY)) { for (i = 4; i < 6; i++) idct(block[i]); } @@ -883,11 +883,11 @@ } cfrm = &f->cfrm[i]; - if (data_size > UINT_MAX - cfrm->size - FF_INPUT_BUFFER_PADDING_SIZE) + if (data_size > UINT_MAX - cfrm->size - AV_INPUT_BUFFER_PADDING_SIZE) return AVERROR_INVALIDDATA; cfrm->data = av_fast_realloc(cfrm->data, &cfrm->allocated_size, - cfrm->size + data_size + FF_INPUT_BUFFER_PADDING_SIZE); + cfrm->size + data_size + AV_INPUT_BUFFER_PADDING_SIZE); // explicit check needed as memcpy below might not catch a NULL if (!cfrm->data) { av_log(f->avctx, AV_LOG_ERROR, "realloc failure\n"); @@ -1026,5 +1026,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/8bps.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/8bps.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/8bps.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/8bps.c 2015-07-28 17:20:07.000000000 +0000 @@ -184,5 +184,5 @@ .priv_data_size = sizeof(EightBpsContext), .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/8svx.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/8svx.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/8svx.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/8svx.c 2015-07-28 17:20:07.000000000 +0000 @@ -194,7 +194,7 @@ .init = eightsvx_decode_init, .decode = eightsvx_decode_frame, .close = eightsvx_decode_close, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_NONE }, }; @@ -209,7 +209,7 @@ .init = eightsvx_decode_init, .decode = eightsvx_decode_frame, .close = eightsvx_decode_close, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/a64multienc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/a64multienc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/a64multienc.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/a64multienc.c 2015-07-28 17:20:07.000000000 +0000 @@ -66,7 +66,8 @@ //static const int mc_colors[5]={0x0,0x8,0xa,0xf,0x7}; //static const int mc_colors[5]={0x0,0x9,0x8,0xa,0x3}; -static void to_meta_with_crop(AVCodecContext *avctx, const AVFrame *p, int *dest) +static void to_meta_with_crop(AVCodecContext *avctx, + const AVFrame *p, int *dest) { int blockx, blocky, x, y; int luma = 0; @@ -234,7 +235,7 @@ } /* set up extradata */ - if (!(avctx->extradata = av_mallocz(8 * 4 + FF_INPUT_BUFFER_PADDING_SIZE))) { + if (!(avctx->extradata = av_mallocz(8 * 4 + AV_INPUT_BUFFER_PADDING_SIZE))) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate memory for extradata.\n"); return AVERROR(ENOMEM); } @@ -327,7 +328,7 @@ /* any frames to encode? */ if (c->mc_lifetime) { int alloc_size = charset_size + c->mc_lifetime*(screen_size + colram_size); - if ((ret = ff_alloc_packet2(avctx, pkt, alloc_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, alloc_size, 0)) < 0) return ret; buf = pkt->data; @@ -405,7 +406,7 @@ .encode2 = a64multi_encode_frame, .close = a64multi_close_encoder, .pix_fmts = (const enum AVPixelFormat[]) {AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE}, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, }; #endif #if CONFIG_A64MULTI5_ENCODER @@ -419,6 +420,6 @@ .encode2 = a64multi_encode_frame, .close = a64multi_close_encoder, .pix_fmts = (const enum AVPixelFormat[]) {AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE}, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac_adtstoasc_bsf.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac_adtstoasc_bsf.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac_adtstoasc_bsf.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac_adtstoasc_bsf.c 2015-07-28 17:20:07.000000000 +0000 @@ -89,7 +89,7 @@ } av_free(avctx->extradata); avctx->extradata_size = 2 + pce_size; - avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { avctx->extradata_size = 0; return AVERROR(ENOMEM); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aaccoder.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aaccoder.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aaccoder.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aaccoder.c 2015-08-01 17:20:02.000000000 +0000 @@ -39,12 +39,28 @@ #include "aac.h" #include "aacenc.h" #include "aactab.h" +#include "aac_tablegen_decl.h" /** Frequency in Hz for lower limit of noise substitution **/ -#define NOISE_LOW_LIMIT 4000 +#define NOISE_LOW_LIMIT 4500 + +/* Energy spread threshold value below which no PNS is used, this corresponds to + * typically around 17Khz, after which PNS usage decays ending at 19Khz */ +#define NOISE_SPREAD_THRESHOLD 0.5f + +/* This constant gets divided by lambda to return ~1.65 which when multiplied + * by the band->threshold and compared to band->energy is the boundary between + * excessive PNS and little PNS usage. */ +#define NOISE_LAMBDA_NUMERATOR 252.1f + +/** Frequency in Hz for lower limit of intensity stereo **/ +#define INT_STEREO_LOW_LIMIT 6100 /** Total number of usable codebooks **/ -#define CB_TOT 13 +#define CB_TOT 12 + +/** Total number of codebooks, including special ones **/ +#define CB_TOT_ALL 15 /** bits needed to code codebook run value for long windows */ static const uint8_t run_value_bits_long[64] = { @@ -63,30 +79,33 @@ run_value_bits_long, run_value_bits_short }; +#define ROUND_STANDARD 0.4054f +#define ROUND_TO_ZERO 0.1054f + /** Map to convert values from BandCodingPath index to a codebook index **/ -static const uint8_t aac_cb_out_map[CB_TOT] = {0,1,2,3,4,5,6,7,8,9,10,11,13}; +static const uint8_t aac_cb_out_map[CB_TOT_ALL] = {0,1,2,3,4,5,6,7,8,9,10,11,13,14,15}; /** Inverse map to convert from codebooks to BandCodingPath indices **/ -static const uint8_t aac_cb_in_map[CB_TOT+1] = {0,1,2,3,4,5,6,7,8,9,10,11,0,12}; +static const uint8_t aac_cb_in_map[CB_TOT_ALL+1] = {0,1,2,3,4,5,6,7,8,9,10,11,0,12,13,14}; /** * Quantize one coefficient. * @return absolute value of the quantized coefficient * @see 3GPP TS26.403 5.6.2 "Scalefactor determination" */ -static av_always_inline int quant(float coef, const float Q) +static av_always_inline int quant(float coef, const float Q, const float rounding) { float a = coef * Q; - return sqrtf(a * sqrtf(a)) + 0.4054; + return sqrtf(a * sqrtf(a)) + rounding; } static void quantize_bands(int *out, const float *in, const float *scaled, - int size, float Q34, int is_signed, int maxval) + int size, float Q34, int is_signed, int maxval, const float rounding) { int i; double qc; for (i = 0; i < size; i++) { qc = scaled[i] * Q34; - out[i] = (int)FFMIN(qc + 0.4054, (double)maxval); + out[i] = (int)FFMIN(qc + rounding, (double)maxval); if (is_signed && in[i] < 0.0f) { out[i] = -out[i]; } @@ -118,7 +137,8 @@ const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, int BT_ZERO, int BT_UNSIGNED, - int BT_PAIR, int BT_ESC, int BT_NOISE) + int BT_PAIR, int BT_ESC, int BT_NOISE, int BT_STEREO, + const float ROUNDING) { const int q_idx = POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512; const float Q = ff_aac_pow2sf_tab [q_idx]; @@ -131,14 +151,7 @@ int resbits = 0; int off; - if (BT_ZERO) { - for (i = 0; i < size; i++) - cost += in[i]*in[i]; - if (bits) - *bits = 0; - return cost * lambda; - } - if (BT_NOISE) { + if (BT_ZERO || BT_NOISE || BT_STEREO) { for (i = 0; i < size; i++) cost += in[i]*in[i]; if (bits) @@ -149,7 +162,7 @@ abs_pow34_v(s->scoefs, in, size); scaled = s->scoefs; } - quantize_bands(s->qcoefs, in, scaled, size, Q34, !BT_UNSIGNED, aac_cb_maxval[cb]); + quantize_bands(s->qcoefs, in, scaled, size, Q34, !BT_UNSIGNED, aac_cb_maxval[cb], ROUNDING); if (BT_UNSIGNED) { off = 0; } else { @@ -176,7 +189,7 @@ di = t - CLIPPED_ESCAPE; curbits += 21; } else { - int c = av_clip_uintp2(quant(t, Q), 13); + int c = av_clip_uintp2(quant(t, Q, ROUNDING), 13); di = t - c*cbrtf(c)*IQ; curbits += av_log2(c)*2 - 4 + 1; } @@ -206,7 +219,7 @@ if (BT_ESC) { for (j = 0; j < 2; j++) { if (ff_aac_codebook_vectors[cb-1][curidx*2+j] == 64.0f) { - int coef = av_clip_uintp2(quant(fabsf(in[i+j]), Q), 13); + int coef = av_clip_uintp2(quant(fabsf(in[i+j]), Q, ROUNDING), 13); int len = av_log2(coef); put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) - 2); @@ -231,26 +244,29 @@ return 0.0f; } -#define QUANTIZE_AND_ENCODE_BAND_COST_FUNC(NAME, BT_ZERO, BT_UNSIGNED, BT_PAIR, BT_ESC, BT_NOISE) \ -static float quantize_and_encode_band_cost_ ## NAME( \ - struct AACEncContext *s, \ - PutBitContext *pb, const float *in, \ - const float *scaled, int size, int scale_idx, \ - int cb, const float lambda, const float uplim, \ - int *bits) { \ - return quantize_and_encode_band_cost_template( \ - s, pb, in, scaled, size, scale_idx, \ - BT_ESC ? ESC_BT : cb, lambda, uplim, bits, \ - BT_ZERO, BT_UNSIGNED, BT_PAIR, BT_ESC, BT_NOISE); \ -} - -QUANTIZE_AND_ENCODE_BAND_COST_FUNC(ZERO, 1, 0, 0, 0, 0) -QUANTIZE_AND_ENCODE_BAND_COST_FUNC(SQUAD, 0, 0, 0, 0, 0) -QUANTIZE_AND_ENCODE_BAND_COST_FUNC(UQUAD, 0, 1, 0, 0, 0) -QUANTIZE_AND_ENCODE_BAND_COST_FUNC(SPAIR, 0, 0, 1, 0, 0) -QUANTIZE_AND_ENCODE_BAND_COST_FUNC(UPAIR, 0, 1, 1, 0, 0) -QUANTIZE_AND_ENCODE_BAND_COST_FUNC(ESC, 0, 1, 1, 1, 0) -QUANTIZE_AND_ENCODE_BAND_COST_FUNC(NOISE, 0, 0, 0, 0, 1) +#define QUANTIZE_AND_ENCODE_BAND_COST_FUNC(NAME, BT_ZERO, BT_UNSIGNED, BT_PAIR, BT_ESC, BT_NOISE, BT_STEREO, ROUNDING) \ +static float quantize_and_encode_band_cost_ ## NAME( \ + struct AACEncContext *s, \ + PutBitContext *pb, const float *in, \ + const float *scaled, int size, int scale_idx, \ + int cb, const float lambda, const float uplim, \ + int *bits) { \ + return quantize_and_encode_band_cost_template( \ + s, pb, in, scaled, size, scale_idx, \ + BT_ESC ? ESC_BT : cb, lambda, uplim, bits, \ + BT_ZERO, BT_UNSIGNED, BT_PAIR, BT_ESC, BT_NOISE, BT_STEREO, \ + ROUNDING); \ +} + +QUANTIZE_AND_ENCODE_BAND_COST_FUNC(ZERO, 1, 0, 0, 0, 0, 0, ROUND_STANDARD) +QUANTIZE_AND_ENCODE_BAND_COST_FUNC(SQUAD, 0, 0, 0, 0, 0, 0, ROUND_STANDARD) +QUANTIZE_AND_ENCODE_BAND_COST_FUNC(UQUAD, 0, 1, 0, 0, 0, 0, ROUND_STANDARD) +QUANTIZE_AND_ENCODE_BAND_COST_FUNC(SPAIR, 0, 0, 1, 0, 0, 0, ROUND_STANDARD) +QUANTIZE_AND_ENCODE_BAND_COST_FUNC(UPAIR, 0, 1, 1, 0, 0, 0, ROUND_STANDARD) +QUANTIZE_AND_ENCODE_BAND_COST_FUNC(ESC, 0, 1, 1, 1, 0, 0, ROUND_STANDARD) +QUANTIZE_AND_ENCODE_BAND_COST_FUNC(ESC_RTZ, 0, 1, 1, 1, 0, 0, ROUND_TO_ZERO) +QUANTIZE_AND_ENCODE_BAND_COST_FUNC(NOISE, 0, 0, 0, 0, 1, 0, ROUND_STANDARD) +QUANTIZE_AND_ENCODE_BAND_COST_FUNC(STEREO,0, 0, 0, 0, 0, 1, ROUND_STANDARD) static float (*const quantize_and_encode_band_cost_arr[])( struct AACEncContext *s, @@ -272,30 +288,56 @@ quantize_and_encode_band_cost_ESC, quantize_and_encode_band_cost_NONE, /* CB 12 doesn't exist */ quantize_and_encode_band_cost_NOISE, + quantize_and_encode_band_cost_STEREO, + quantize_and_encode_band_cost_STEREO, +}; + +static float (*const quantize_and_encode_band_cost_rtz_arr[])( + struct AACEncContext *s, + PutBitContext *pb, const float *in, + const float *scaled, int size, int scale_idx, + int cb, const float lambda, const float uplim, + int *bits) = { + quantize_and_encode_band_cost_ZERO, + quantize_and_encode_band_cost_SQUAD, + quantize_and_encode_band_cost_SQUAD, + quantize_and_encode_band_cost_UQUAD, + quantize_and_encode_band_cost_UQUAD, + quantize_and_encode_band_cost_SPAIR, + quantize_and_encode_band_cost_SPAIR, + quantize_and_encode_band_cost_UPAIR, + quantize_and_encode_band_cost_UPAIR, + quantize_and_encode_band_cost_UPAIR, + quantize_and_encode_band_cost_UPAIR, + quantize_and_encode_band_cost_ESC_RTZ, + quantize_and_encode_band_cost_NONE, /* CB 12 doesn't exist */ + quantize_and_encode_band_cost_NOISE, + quantize_and_encode_band_cost_STEREO, + quantize_and_encode_band_cost_STEREO, }; #define quantize_and_encode_band_cost( \ s, pb, in, scaled, size, scale_idx, cb, \ - lambda, uplim, bits) \ - quantize_and_encode_band_cost_arr[cb]( \ + lambda, uplim, bits, rtz) \ + ((rtz) ? quantize_and_encode_band_cost_rtz_arr : quantize_and_encode_band_cost_arr)[cb]( \ s, pb, in, scaled, size, scale_idx, cb, \ lambda, uplim, bits) static float quantize_band_cost(struct AACEncContext *s, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, - int *bits) + int *bits, int rtz) { return quantize_and_encode_band_cost(s, NULL, in, scaled, size, scale_idx, - cb, lambda, uplim, bits); + cb, lambda, uplim, bits, rtz); } static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, const float *in, int size, int scale_idx, - int cb, const float lambda) + int cb, const float lambda, int rtz) { quantize_and_encode_band_cost(s, pb, in, NULL, size, scale_idx, cb, lambda, - INFINITY, NULL); + INFINITY, NULL, rtz); } static float find_max_val(int group_len, int swb_size, const float *scaled) { @@ -339,7 +381,7 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda) { - BandCodingPath path[120][CB_TOT]; + BandCodingPath path[120][CB_TOT_ALL]; int w, swb, cb, start, size; int i, j; const int max_sfb = sce->ics.max_sfb; @@ -352,7 +394,7 @@ abs_pow34_v(s->scoefs, sce->coeffs, 1024); start = win*128; - for (cb = 0; cb < CB_TOT; cb++) { + for (cb = 0; cb < CB_TOT_ALL; cb++) { path[0][cb].cost = 0.0f; path[0][cb].prev_idx = -1; path[0][cb].run = 0; @@ -360,7 +402,7 @@ for (swb = 0; swb < max_sfb; swb++) { size = sce->ics.swb_sizes[swb]; if (sce->zeroes[win*16 + swb]) { - for (cb = 0; cb < CB_TOT; cb++) { + for (cb = 0; cb < CB_TOT_ALL; cb++) { path[swb+1][cb].prev_idx = cb; path[swb+1][cb].cost = path[swb][cb].cost; path[swb+1][cb].run = path[swb][cb].run + 1; @@ -370,15 +412,22 @@ int mincb = next_mincb; next_minrd = INFINITY; next_mincb = 0; - for (cb = 0; cb < CB_TOT; cb++) { + for (cb = 0; cb < CB_TOT_ALL; cb++) { float cost_stay_here, cost_get_here; float rd = 0.0f; + if (cb >= 12 && sce->band_type[win*16+swb] < aac_cb_out_map[cb] || + cb < aac_cb_in_map[sce->band_type[win*16+swb]] && sce->band_type[win*16+swb] > aac_cb_out_map[cb]) { + path[swb+1][cb].prev_idx = -1; + path[swb+1][cb].cost = INFINITY; + path[swb+1][cb].run = path[swb][cb].run + 1; + continue; + } for (w = 0; w < group_len; w++) { FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(win+w)*16+swb]; rd += quantize_band_cost(s, sce->coeffs + start + w*128, s->scoefs + start + w*128, size, sce->sf_idx[(win+w)*16+swb], aac_cb_out_map[cb], - lambda / band->threshold, INFINITY, NULL); + lambda / band->threshold, INFINITY, NULL, 0); } cost_stay_here = path[swb][cb].cost + rd; cost_get_here = minrd + rd + run_bits + 4; @@ -406,11 +455,12 @@ //convert resulting path from backward-linked list stack_len = 0; idx = 0; - for (cb = 1; cb < CB_TOT; cb++) + for (cb = 1; cb < CB_TOT_ALL; cb++) if (path[max_sfb][cb].cost < path[max_sfb][idx].cost) idx = cb; ppos = max_sfb; while (ppos > 0) { + av_assert1(idx >= 0); cb = idx; stackrun[stack_len] = path[ppos][cb].run; stackcb [stack_len] = cb; @@ -441,7 +491,7 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda) { - BandCodingPath path[120][CB_TOT]; + BandCodingPath path[120][CB_TOT_ALL]; int w, swb, cb, start, size; int i, j; const int max_sfb = sce->ics.max_sfb; @@ -454,7 +504,7 @@ abs_pow34_v(s->scoefs, sce->coeffs, 1024); start = win*128; - for (cb = 0; cb < CB_TOT; cb++) { + for (cb = 0; cb < CB_TOT_ALL; cb++) { path[0][cb].cost = run_bits+4; path[0][cb].prev_idx = -1; path[0][cb].run = 0; @@ -478,7 +528,7 @@ } next_minbits = path[swb+1][0].cost; next_mincb = 0; - for (cb = 1; cb < CB_TOT; cb++) { + for (cb = 1; cb < CB_TOT_ALL; cb++) { path[swb+1][cb].cost = 61450; path[swb+1][cb].prev_idx = -1; path[swb+1][cb].run = 0; @@ -495,10 +545,10 @@ path[swb+1][cb].prev_idx = -1; path[swb+1][cb].run = 0; } - for (cb = startcb; cb < CB_TOT; cb++) { + for (cb = startcb; cb < CB_TOT_ALL; cb++) { float cost_stay_here, cost_get_here; float bits = 0.0f; - if (cb == 12 && sce->band_type[win*16+swb] != NOISE_BT) { + if (cb >= 12 && sce->band_type[win*16+swb] != aac_cb_out_map[cb]) { path[swb+1][cb].cost = 61450; path[swb+1][cb].prev_idx = -1; path[swb+1][cb].run = 0; @@ -507,9 +557,9 @@ for (w = 0; w < group_len; w++) { bits += quantize_band_cost(s, sce->coeffs + start + w*128, s->scoefs + start + w*128, size, - sce->sf_idx[(win+w)*16+swb], + sce->sf_idx[win*16+swb], aac_cb_out_map[cb], - 0, INFINITY, NULL); + 0, INFINITY, NULL, 0); } cost_stay_here = path[swb][cb].cost + bits; cost_get_here = minbits + bits + run_bits + 4; @@ -537,7 +587,7 @@ //convert resulting path from backward-linked list stack_len = 0; idx = 0; - for (cb = 1; cb < CB_TOT; cb++) + for (cb = 1; cb < CB_TOT_ALL; cb++) if (path[max_sfb][cb].cost < path[max_sfb][idx].cost) idx = cb; ppos = max_sfb; @@ -588,6 +638,43 @@ #define TRELLIS_STAGES 121 #define TRELLIS_STATES (SCALE_MAX_DIFF+1) +static void set_special_band_scalefactors(AACEncContext *s, SingleChannelElement *sce) +{ + int w, g, start = 0; + int minscaler_n = sce->sf_idx[0], minscaler_i = sce->sf_idx[0]; + int bands = 0; + + for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { + start = 0; + for (g = 0; g < sce->ics.num_swb; g++) { + if (sce->band_type[w*16+g] == INTENSITY_BT || sce->band_type[w*16+g] == INTENSITY_BT2) { + sce->sf_idx[w*16+g] = av_clip(ceilf(log2f(sce->is_ener[w*16+g])*2), -155, 100); + minscaler_i = FFMIN(minscaler_i, sce->sf_idx[w*16+g]); + bands++; + } else if (sce->band_type[w*16+g] == NOISE_BT) { + sce->sf_idx[w*16+g] = av_clip(4+log2f(sce->pns_ener[w*16+g])*2, -100, 155); + minscaler_n = FFMIN(minscaler_n, sce->sf_idx[w*16+g]); + bands++; + } + start += sce->ics.swb_sizes[g]; + } + } + + if (!bands) + return; + + /* Clip the scalefactor indices */ + for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { + for (g = 0; g < sce->ics.num_swb; g++) { + if (sce->band_type[w*16+g] == INTENSITY_BT || sce->band_type[w*16+g] == INTENSITY_BT2) { + sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler_i, minscaler_i + SCALE_MAX_DIFF); + } else if (sce->band_type[w*16+g] == NOISE_BT) { + sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler_n, minscaler_n + SCALE_MAX_DIFF); + } + } + } +} + static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, const float lambda) @@ -692,7 +779,7 @@ for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; dist += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g], - q + q0, cb, lambda / band->threshold, INFINITY, NULL); + q + q0, cb, lambda / band->threshold, INFINITY, NULL, 0); } minrd = FFMIN(minrd, dist); @@ -748,11 +835,9 @@ { int start = 0, i, w, w2, g; int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels * (lambda / 120.f); - const float freq_mult = avctx->sample_rate/(1024.0f/sce->ics.num_windows)/2.0f; float dists[128] = { 0 }, uplims[128] = { 0 }; float maxvals[128]; - int noise_sf[128] = { 0 }; - int fflag, minscaler, minscaler_n; + int fflag, minscaler; int its = 0; int allz = 0; float minthr = INFINITY; @@ -763,13 +848,12 @@ //XXX: some heuristic to determine initial quantizers will reduce search time //determine zero bands and upper limits for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { - start = 0; for (g = 0; g < sce->ics.num_swb; g++) { int nz = 0; float uplim = 0.0f, energy = 0.0f; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; - uplim += band->threshold; + uplim += band->threshold; energy += band->energy; if (band->energy <= band->threshold || band->threshold == 0.0f) { sce->zeroes[(w+w2)*16+g] = 1; @@ -778,18 +862,10 @@ nz = 1; } uplims[w*16+g] = uplim *512; - if (s->options.pns && start*freq_mult > NOISE_LOW_LIMIT && energy < uplim * 1.2f) { - noise_sf[w*16+g] = av_clip(4+FFMIN(log2f(energy)*2,255), -100, 155); - sce->band_type[w*16+g] = NOISE_BT; - nz= 1; - } else { /** Band type will be determined by the twoloop algorithm */ - sce->band_type[w*16+g] = 0; - } sce->zeroes[w*16+g] = !nz; if (nz) minthr = FFMIN(minthr, uplim); allz |= nz; - start += sce->ics.swb_sizes[g]; } } for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { @@ -820,7 +896,6 @@ do { int tbits, qstep; minscaler = sce->sf_idx[0]; - minscaler_n = sce->sf_idx[0]; //inner loop - quantize spectrum to fit into given number of bits qstep = its ? 1 : 32; do { @@ -835,11 +910,7 @@ int cb; float dist = 0.0f; - if (sce->band_type[w*16+g] == NOISE_BT) { - minscaler_n = FFMIN(minscaler_n, noise_sf[w*16+g]); - start += sce->ics.swb_sizes[g]; - continue; - } else if (sce->zeroes[w*16+g] || sce->sf_idx[w*16+g] >= 218) { + if (sce->zeroes[w*16+g] || sce->sf_idx[w*16+g] >= 218) { start += sce->ics.swb_sizes[g]; continue; } @@ -854,7 +925,8 @@ cb, 1.0f, INFINITY, - &b); + &b, + 0); bits += b; } dists[w*16+g] = dist - bits; @@ -883,16 +955,9 @@ fflag = 0; minscaler = av_clip(minscaler, 60, 255 - SCALE_MAX_DIFF); - for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) - for (g = 0; g < sce->ics.num_swb; g++) - if (sce->band_type[w*16+g] == NOISE_BT) - sce->sf_idx[w*16+g] = av_clip(noise_sf[w*16+g], minscaler_n, minscaler_n + SCALE_MAX_DIFF); - for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { for (g = 0; g < sce->ics.num_swb; g++) { int prevsc = sce->sf_idx[w*16+g]; - if (sce->band_type[w*16+g] == NOISE_BT) - continue; if (dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60) { if (find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]-1)) sce->sf_idx[w*16+g]--; @@ -1027,11 +1092,12 @@ ESC_BT, lambda, INFINITY, - &b); + &b, + 0); dist -= b; } dist *= 1.0f / 512.0f / lambda; - quant_max = quant(maxq[w*16+g], ff_aac_pow2sf_tab[POW_SF2_ZERO - scf + SCALE_ONE_POS - SCALE_DIV_512]); + quant_max = quant(maxq[w*16+g], ff_aac_pow2sf_tab[POW_SF2_ZERO - scf + SCALE_ONE_POS - SCALE_DIV_512], ROUND_STANDARD); if (quant_max >= 8191) { // too much, return to the previous quantizer sce->sf_idx[w*16+g] = prev_scf; break; @@ -1111,19 +1177,155 @@ sce->sf_idx[(w+w2)*16+g] = sce->sf_idx[w*16+g]; } -static void search_for_ms(AACEncContext *s, ChannelElement *cpe, - const float lambda) +static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce) +{ + int start = 0, w, w2, g; + const float lambda = s->lambda; + const float freq_mult = avctx->sample_rate/(1024.0f/sce->ics.num_windows)/2.0f; + const float spread_threshold = NOISE_SPREAD_THRESHOLD*(lambda/120.f); + const float thr_mult = NOISE_LAMBDA_NUMERATOR/lambda; + + /* Coders !twoloop don't reset the band_types */ + for (w = 0; w < 128; w++) + if (sce->band_type[w] == NOISE_BT) + sce->band_type[w] = 0; + + for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { + start = 0; + for (g = 0; g < sce->ics.num_swb; g++) { + if (start*freq_mult > NOISE_LOW_LIMIT*(lambda/170.0f)) { + float energy = 0.0f, threshold = 0.0f, spread = 0.0f; + for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { + FFPsyBand *band = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g]; + energy += band->energy; + threshold += band->threshold; + spread += band->spread; + } + if (spread > spread_threshold*sce->ics.group_len[w] && + ((sce->zeroes[w*16+g] && energy >= threshold) || + energy < threshold*thr_mult*sce->ics.group_len[w])) { + sce->band_type[w*16+g] = NOISE_BT; + sce->pns_ener[w*16+g] = energy / sce->ics.group_len[w]; + sce->zeroes[w*16+g] = 0; + } + } + start += sce->ics.swb_sizes[g]; + } + } +} + +static void search_for_is(AACEncContext *s, AVCodecContext *avctx, ChannelElement *cpe) +{ + float IS[128]; + float *L34 = s->scoefs + 128*0, *R34 = s->scoefs + 128*1; + float *I34 = s->scoefs + 128*2; + SingleChannelElement *sce0 = &cpe->ch[0]; + SingleChannelElement *sce1 = &cpe->ch[1]; + int start = 0, count = 0, i, w, w2, g; + const float freq_mult = avctx->sample_rate/(1024.0f/sce0->ics.num_windows)/2.0f; + const float lambda = s->lambda; + + for (w = 0; w < 128; w++) + if (sce1->band_type[w] >= INTENSITY_BT2) + sce1->band_type[w] = 0; + + if (!cpe->common_window) + return; + for (w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]) { + start = 0; + for (g = 0; g < sce0->ics.num_swb; g++) { + if (start*freq_mult > INT_STEREO_LOW_LIMIT*(lambda/170.0f) && + cpe->ch[0].band_type[w*16+g] != NOISE_BT && !cpe->ch[0].zeroes[w*16+g] && + cpe->ch[1].band_type[w*16+g] != NOISE_BT && !cpe->ch[1].zeroes[w*16+g]) { + int phase = 0; + float ener0 = 0.0f, ener1 = 0.0f, ener01 = 0.0f; + float dist1 = 0.0f, dist2 = 0.0f; + for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) { + for (i = 0; i < sce0->ics.swb_sizes[g]; i++) { + float coef0 = sce0->pcoeffs[start+(w+w2)*128+i]; + float coef1 = sce1->pcoeffs[start+(w+w2)*128+i]; + phase += coef0*coef1 >= 0.0f ? 1 : -1; + ener0 += coef0*coef0; + ener1 += coef1*coef1; + ener01 += (coef0 + coef1)*(coef0 + coef1); + } + } + if (!phase) { /* Too much phase difference between channels */ + start += sce0->ics.swb_sizes[g]; + continue; + } + phase = av_clip(phase, -1, 1); + for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) { + FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g]; + FFPsyBand *band1 = &s->psy.ch[s->cur_channel+1].psy_bands[(w+w2)*16+g]; + int is_band_type, is_sf_idx = FFMAX(1, sce0->sf_idx[(w+w2)*16+g]-4); + float e01_34 = phase*pow(sqrt(ener1/ener0), 3.0/4.0); + float maxval, dist_spec_err = 0.0f; + float minthr = FFMIN(band0->threshold, band1->threshold); + for (i = 0; i < sce0->ics.swb_sizes[g]; i++) + IS[i] = (sce0->pcoeffs[start+(w+w2)*128+i] + phase*sce1->pcoeffs[start+(w+w2)*128+i]) * sqrt(ener0/ener01); + abs_pow34_v(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]); + abs_pow34_v(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]); + abs_pow34_v(I34, IS, sce0->ics.swb_sizes[g]); + maxval = find_max_val(1, sce0->ics.swb_sizes[g], I34); + is_band_type = find_min_book(maxval, is_sf_idx); + dist1 += quantize_band_cost(s, sce0->coeffs + start + (w+w2)*128, + L34, + sce0->ics.swb_sizes[g], + sce0->sf_idx[(w+w2)*16+g], + sce0->band_type[(w+w2)*16+g], + lambda / band0->threshold, INFINITY, NULL, 0); + dist1 += quantize_band_cost(s, sce1->coeffs + start + (w+w2)*128, + R34, + sce1->ics.swb_sizes[g], + sce1->sf_idx[(w+w2)*16+g], + sce1->band_type[(w+w2)*16+g], + lambda / band1->threshold, INFINITY, NULL, 0); + dist2 += quantize_band_cost(s, IS, + I34, + sce0->ics.swb_sizes[g], + is_sf_idx, + is_band_type, + lambda / minthr, INFINITY, NULL, 0); + for (i = 0; i < sce0->ics.swb_sizes[g]; i++) { + dist_spec_err += (L34[i] - I34[i])*(L34[i] - I34[i]); + dist_spec_err += (R34[i] - I34[i]*e01_34)*(R34[i] - I34[i]*e01_34); + } + dist_spec_err *= lambda / minthr; + dist2 += dist_spec_err; + } + if (dist2 <= dist1) { + cpe->is_mask[w*16+g] = 1; + cpe->ms_mask[w*16+g] = 0; + cpe->ch[0].is_ener[w*16+g] = sqrt(ener0/ener01); + cpe->ch[1].is_ener[w*16+g] = ener0/ener1; + if (phase) + cpe->ch[1].band_type[w*16+g] = INTENSITY_BT; + else + cpe->ch[1].band_type[w*16+g] = INTENSITY_BT2; + count++; + } + } + start += sce0->ics.swb_sizes[g]; + } + } + cpe->is_mode = !!count; +} + +static void search_for_ms(AACEncContext *s, ChannelElement *cpe) { int start = 0, i, w, w2, g; float M[128], S[128]; float *L34 = s->scoefs, *R34 = s->scoefs + 128, *M34 = s->scoefs + 128*2, *S34 = s->scoefs + 128*3; + const float lambda = s->lambda; SingleChannelElement *sce0 = &cpe->ch[0]; SingleChannelElement *sce1 = &cpe->ch[1]; if (!cpe->common_window) return; for (w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]) { + start = 0; for (g = 0; g < sce0->ics.num_swb; g++) { - if (!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g]) { + if (!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g] && !cpe->is_mask[w*16+g]) { float dist1 = 0.0f, dist2 = 0.0f; for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) { FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g]; @@ -1131,39 +1333,39 @@ float minthr = FFMIN(band0->threshold, band1->threshold); float maxthr = FFMAX(band0->threshold, band1->threshold); for (i = 0; i < sce0->ics.swb_sizes[g]; i++) { - M[i] = (sce0->pcoeffs[start+w2*128+i] - + sce1->pcoeffs[start+w2*128+i]) * 0.5; + M[i] = (sce0->pcoeffs[start+(w+w2)*128+i] + + sce1->pcoeffs[start+(w+w2)*128+i]) * 0.5; S[i] = M[i] - - sce1->pcoeffs[start+w2*128+i]; + - sce1->pcoeffs[start+(w+w2)*128+i]; } - abs_pow34_v(L34, sce0->coeffs+start+w2*128, sce0->ics.swb_sizes[g]); - abs_pow34_v(R34, sce1->coeffs+start+w2*128, sce0->ics.swb_sizes[g]); + abs_pow34_v(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]); + abs_pow34_v(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]); abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]); abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]); - dist1 += quantize_band_cost(s, sce0->coeffs + start + w2*128, + dist1 += quantize_band_cost(s, sce0->coeffs + start + (w+w2)*128, L34, sce0->ics.swb_sizes[g], sce0->sf_idx[(w+w2)*16+g], sce0->band_type[(w+w2)*16+g], - lambda / band0->threshold, INFINITY, NULL); - dist1 += quantize_band_cost(s, sce1->coeffs + start + w2*128, + lambda / band0->threshold, INFINITY, NULL, 0); + dist1 += quantize_band_cost(s, sce1->coeffs + start + (w+w2)*128, R34, sce1->ics.swb_sizes[g], sce1->sf_idx[(w+w2)*16+g], sce1->band_type[(w+w2)*16+g], - lambda / band1->threshold, INFINITY, NULL); + lambda / band1->threshold, INFINITY, NULL, 0); dist2 += quantize_band_cost(s, M, M34, sce0->ics.swb_sizes[g], sce0->sf_idx[(w+w2)*16+g], sce0->band_type[(w+w2)*16+g], - lambda / maxthr, INFINITY, NULL); + lambda / maxthr, INFINITY, NULL, 0); dist2 += quantize_band_cost(s, S, S34, sce1->ics.swb_sizes[g], sce1->sf_idx[(w+w2)*16+g], sce1->band_type[(w+w2)*16+g], - lambda / minthr, INFINITY, NULL); + lambda / minthr, INFINITY, NULL, 0); } cpe->ms_mask[w*16+g] = dist2 < dist1; } @@ -1177,24 +1379,36 @@ search_for_quantizers_faac, encode_window_bands_info, quantize_and_encode_band, + set_special_band_scalefactors, + search_for_pns, search_for_ms, + search_for_is, }, [AAC_CODER_ANMR] = { search_for_quantizers_anmr, encode_window_bands_info, quantize_and_encode_band, + set_special_band_scalefactors, + search_for_pns, search_for_ms, + search_for_is, }, [AAC_CODER_TWOLOOP] = { search_for_quantizers_twoloop, codebook_trellis_rate, quantize_and_encode_band, + set_special_band_scalefactors, + search_for_pns, search_for_ms, + search_for_is, }, [AAC_CODER_FAST] = { search_for_quantizers_fast, encode_window_bands_info, quantize_and_encode_band, + set_special_band_scalefactors, + search_for_pns, search_for_ms, + search_for_is, }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacdec.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacdec.c 2015-08-03 17:20:02.000000000 +0000 @@ -32,54 +32,9 @@ * @author Maxim Gavrilov ( maxim.gavrilov gmail com ) */ -/* - * supported tools - * - * Support? Name - * N (code in SoC repo) gain control - * Y block switching - * Y window shapes - standard - * N window shapes - Low Delay - * Y filterbank - standard - * N (code in SoC repo) filterbank - Scalable Sample Rate - * Y Temporal Noise Shaping - * Y Long Term Prediction - * Y intensity stereo - * Y channel coupling - * Y frequency domain prediction - * Y Perceptual Noise Substitution - * Y Mid/Side stereo - * N Scalable Inverse AAC Quantization - * N Frequency Selective Switch - * N upsampling filter - * Y quantization & coding - AAC - * N quantization & coding - TwinVQ - * N quantization & coding - BSAC - * N AAC Error Resilience tools - * N Error Resilience payload syntax - * N Error Protection tool - * N CELP - * N Silence Compression - * N HVXC - * N HVXC 4kbits/s VR - * N Structured Audio tools - * N Structured Audio Sample Bank Format - * N MIDI - * N Harmonic and Individual Lines plus Noise - * N Text-To-Speech Interface - * Y Spectral Band Replication - * Y (not in this code) Layer-1 - * Y (not in this code) Layer-2 - * Y (not in this code) Layer-3 - * N SinuSoidal Coding (Transient, Sinusoid, Noise) - * Y Parametric Stereo - * N Direct Stream Transfer - * Y Enhanced AAC Low Delay (ER AAC ELD) - * - * Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication. - * - HE AAC v2 comprises LC AAC with Spectral Band Replication and - Parametric Stereo. - */ +#define FFT_FLOAT 1 +#define FFT_FIXED_32 0 +#define USE_FIXED 0 #include "libavutil/float_dsp.h" #include "libavutil/opt.h" @@ -113,1445 +68,14 @@ # include "mips/aacdec_mips.h" #endif -static VLC vlc_scalefactors; -static VLC vlc_spectral[11]; - -static int output_configure(AACContext *ac, - uint8_t layout_map[MAX_ELEM_ID*4][3], int tags, - enum OCStatus oc_type, int get_new_frame); - -#define overread_err "Input buffer exhausted before END element found\n" - -static int count_channels(uint8_t (*layout)[3], int tags) -{ - int i, sum = 0; - for (i = 0; i < tags; i++) { - int syn_ele = layout[i][0]; - int pos = layout[i][2]; - sum += (1 + (syn_ele == TYPE_CPE)) * - (pos != AAC_CHANNEL_OFF && pos != AAC_CHANNEL_CC); - } - return sum; -} - -/** - * Check for the channel element in the current channel position configuration. - * If it exists, make sure the appropriate element is allocated and map the - * channel order to match the internal FFmpeg channel layout. - * - * @param che_pos current channel position configuration - * @param type channel element type - * @param id channel element id - * @param channels count of the number of channels in the configuration - * - * @return Returns error status. 0 - OK, !0 - error - */ -static av_cold int che_configure(AACContext *ac, - enum ChannelPosition che_pos, - int type, int id, int *channels) -{ - if (*channels >= MAX_CHANNELS) - return AVERROR_INVALIDDATA; - if (che_pos) { - if (!ac->che[type][id]) { - if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement)))) - return AVERROR(ENOMEM); - ff_aac_sbr_ctx_init(ac, &ac->che[type][id]->sbr); - } - if (type != TYPE_CCE) { - if (*channels >= MAX_CHANNELS - (type == TYPE_CPE || (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1))) { - av_log(ac->avctx, AV_LOG_ERROR, "Too many channels\n"); - return AVERROR_INVALIDDATA; - } - ac->output_element[(*channels)++] = &ac->che[type][id]->ch[0]; - if (type == TYPE_CPE || - (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1)) { - ac->output_element[(*channels)++] = &ac->che[type][id]->ch[1]; - } - } - } else { - if (ac->che[type][id]) - ff_aac_sbr_ctx_close(&ac->che[type][id]->sbr); - av_freep(&ac->che[type][id]); - } - return 0; -} - -static int frame_configure_elements(AVCodecContext *avctx) -{ - AACContext *ac = avctx->priv_data; - int type, id, ch, ret; - - /* set channel pointers to internal buffers by default */ - for (type = 0; type < 4; type++) { - for (id = 0; id < MAX_ELEM_ID; id++) { - ChannelElement *che = ac->che[type][id]; - if (che) { - che->ch[0].ret = che->ch[0].ret_buf; - che->ch[1].ret = che->ch[1].ret_buf; - } - } - } - - /* get output buffer */ - av_frame_unref(ac->frame); - if (!avctx->channels) - return 1; - - ac->frame->nb_samples = 2048; - if ((ret = ff_get_buffer(avctx, ac->frame, 0)) < 0) - return ret; - - /* map output channel pointers to AVFrame data */ - for (ch = 0; ch < avctx->channels; ch++) { - if (ac->output_element[ch]) - ac->output_element[ch]->ret = (float *)ac->frame->extended_data[ch]; - } - - return 0; -} - -struct elem_to_channel { - uint64_t av_position; - uint8_t syn_ele; - uint8_t elem_id; - uint8_t aac_position; -}; - -static int assign_pair(struct elem_to_channel e2c_vec[MAX_ELEM_ID], - uint8_t (*layout_map)[3], int offset, uint64_t left, - uint64_t right, int pos) -{ - if (layout_map[offset][0] == TYPE_CPE) { - e2c_vec[offset] = (struct elem_to_channel) { - .av_position = left | right, - .syn_ele = TYPE_CPE, - .elem_id = layout_map[offset][1], - .aac_position = pos - }; - return 1; - } else { - e2c_vec[offset] = (struct elem_to_channel) { - .av_position = left, - .syn_ele = TYPE_SCE, - .elem_id = layout_map[offset][1], - .aac_position = pos - }; - e2c_vec[offset + 1] = (struct elem_to_channel) { - .av_position = right, - .syn_ele = TYPE_SCE, - .elem_id = layout_map[offset + 1][1], - .aac_position = pos - }; - return 2; - } -} - -static int count_paired_channels(uint8_t (*layout_map)[3], int tags, int pos, - int *current) -{ - int num_pos_channels = 0; - int first_cpe = 0; - int sce_parity = 0; - int i; - for (i = *current; i < tags; i++) { - if (layout_map[i][2] != pos) - break; - if (layout_map[i][0] == TYPE_CPE) { - if (sce_parity) { - if (pos == AAC_CHANNEL_FRONT && !first_cpe) { - sce_parity = 0; - } else { - return -1; - } - } - num_pos_channels += 2; - first_cpe = 1; - } else { - num_pos_channels++; - sce_parity ^= 1; - } - } - if (sce_parity && - ((pos == AAC_CHANNEL_FRONT && first_cpe) || pos == AAC_CHANNEL_SIDE)) - return -1; - *current = i; - return num_pos_channels; -} - -static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags) -{ - int i, n, total_non_cc_elements; - struct elem_to_channel e2c_vec[4 * MAX_ELEM_ID] = { { 0 } }; - int num_front_channels, num_side_channels, num_back_channels; - uint64_t layout; - - if (FF_ARRAY_ELEMS(e2c_vec) < tags) - return 0; - - i = 0; - num_front_channels = - count_paired_channels(layout_map, tags, AAC_CHANNEL_FRONT, &i); - if (num_front_channels < 0) - return 0; - num_side_channels = - count_paired_channels(layout_map, tags, AAC_CHANNEL_SIDE, &i); - if (num_side_channels < 0) - return 0; - num_back_channels = - count_paired_channels(layout_map, tags, AAC_CHANNEL_BACK, &i); - if (num_back_channels < 0) - return 0; - - if (num_side_channels == 0 && num_back_channels >= 4) { - num_side_channels = 2; - num_back_channels -= 2; - } - - i = 0; - if (num_front_channels & 1) { - e2c_vec[i] = (struct elem_to_channel) { - .av_position = AV_CH_FRONT_CENTER, - .syn_ele = TYPE_SCE, - .elem_id = layout_map[i][1], - .aac_position = AAC_CHANNEL_FRONT - }; - i++; - num_front_channels--; - } - if (num_front_channels >= 4) { - i += assign_pair(e2c_vec, layout_map, i, - AV_CH_FRONT_LEFT_OF_CENTER, - AV_CH_FRONT_RIGHT_OF_CENTER, - AAC_CHANNEL_FRONT); - num_front_channels -= 2; - } - if (num_front_channels >= 2) { - i += assign_pair(e2c_vec, layout_map, i, - AV_CH_FRONT_LEFT, - AV_CH_FRONT_RIGHT, - AAC_CHANNEL_FRONT); - num_front_channels -= 2; - } - while (num_front_channels >= 2) { - i += assign_pair(e2c_vec, layout_map, i, - UINT64_MAX, - UINT64_MAX, - AAC_CHANNEL_FRONT); - num_front_channels -= 2; - } - - if (num_side_channels >= 2) { - i += assign_pair(e2c_vec, layout_map, i, - AV_CH_SIDE_LEFT, - AV_CH_SIDE_RIGHT, - AAC_CHANNEL_FRONT); - num_side_channels -= 2; - } - while (num_side_channels >= 2) { - i += assign_pair(e2c_vec, layout_map, i, - UINT64_MAX, - UINT64_MAX, - AAC_CHANNEL_SIDE); - num_side_channels -= 2; - } - - while (num_back_channels >= 4) { - i += assign_pair(e2c_vec, layout_map, i, - UINT64_MAX, - UINT64_MAX, - AAC_CHANNEL_BACK); - num_back_channels -= 2; - } - if (num_back_channels >= 2) { - i += assign_pair(e2c_vec, layout_map, i, - AV_CH_BACK_LEFT, - AV_CH_BACK_RIGHT, - AAC_CHANNEL_BACK); - num_back_channels -= 2; - } - if (num_back_channels) { - e2c_vec[i] = (struct elem_to_channel) { - .av_position = AV_CH_BACK_CENTER, - .syn_ele = TYPE_SCE, - .elem_id = layout_map[i][1], - .aac_position = AAC_CHANNEL_BACK - }; - i++; - num_back_channels--; - } - - if (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) { - e2c_vec[i] = (struct elem_to_channel) { - .av_position = AV_CH_LOW_FREQUENCY, - .syn_ele = TYPE_LFE, - .elem_id = layout_map[i][1], - .aac_position = AAC_CHANNEL_LFE - }; - i++; - } - while (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) { - e2c_vec[i] = (struct elem_to_channel) { - .av_position = UINT64_MAX, - .syn_ele = TYPE_LFE, - .elem_id = layout_map[i][1], - .aac_position = AAC_CHANNEL_LFE - }; - i++; - } - - // Must choose a stable sort - total_non_cc_elements = n = i; - do { - int next_n = 0; - for (i = 1; i < n; i++) - if (e2c_vec[i - 1].av_position > e2c_vec[i].av_position) { - FFSWAP(struct elem_to_channel, e2c_vec[i - 1], e2c_vec[i]); - next_n = i; - } - n = next_n; - } while (n > 0); - - layout = 0; - for (i = 0; i < total_non_cc_elements; i++) { - layout_map[i][0] = e2c_vec[i].syn_ele; - layout_map[i][1] = e2c_vec[i].elem_id; - layout_map[i][2] = e2c_vec[i].aac_position; - if (e2c_vec[i].av_position != UINT64_MAX) { - layout |= e2c_vec[i].av_position; - } - } - - return layout; -} - -/** - * Save current output configuration if and only if it has been locked. - */ -static void push_output_configuration(AACContext *ac) { - if (ac->oc[1].status == OC_LOCKED || ac->oc[0].status == OC_NONE) { - ac->oc[0] = ac->oc[1]; - } - ac->oc[1].status = OC_NONE; -} - -/** - * Restore the previous output configuration if and only if the current - * configuration is unlocked. - */ -static void pop_output_configuration(AACContext *ac) { - if (ac->oc[1].status != OC_LOCKED && ac->oc[0].status != OC_NONE) { - ac->oc[1] = ac->oc[0]; - ac->avctx->channels = ac->oc[1].channels; - ac->avctx->channel_layout = ac->oc[1].channel_layout; - output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, - ac->oc[1].status, 0); - } -} - -/** - * Configure output channel order based on the current program - * configuration element. - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int output_configure(AACContext *ac, - uint8_t layout_map[MAX_ELEM_ID * 4][3], int tags, - enum OCStatus oc_type, int get_new_frame) -{ - AVCodecContext *avctx = ac->avctx; - int i, channels = 0, ret; - uint64_t layout = 0; - uint8_t id_map[TYPE_END][MAX_ELEM_ID] = {{ 0 }}; - uint8_t type_counts[TYPE_END] = { 0 }; - - if (ac->oc[1].layout_map != layout_map) { - memcpy(ac->oc[1].layout_map, layout_map, tags * sizeof(layout_map[0])); - ac->oc[1].layout_map_tags = tags; - } - for (i = 0; i < tags; i++) { - int type = layout_map[i][0]; - int id = layout_map[i][1]; - id_map[type][id] = type_counts[type]++; - } - // Try to sniff a reasonable channel order, otherwise output the - // channels in the order the PCE declared them. - if (avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE) - layout = sniff_channel_order(layout_map, tags); - for (i = 0; i < tags; i++) { - int type = layout_map[i][0]; - int id = layout_map[i][1]; - int iid = id_map[type][id]; - int position = layout_map[i][2]; - // Allocate or free elements depending on if they are in the - // current program configuration. - ret = che_configure(ac, position, type, iid, &channels); - if (ret < 0) - return ret; - ac->tag_che_map[type][id] = ac->che[type][iid]; - } - if (ac->oc[1].m4ac.ps == 1 && channels == 2) { - if (layout == AV_CH_FRONT_CENTER) { - layout = AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT; - } else { - layout = 0; - } - } - - if (layout) avctx->channel_layout = layout; - ac->oc[1].channel_layout = layout; - avctx->channels = ac->oc[1].channels = channels; - ac->oc[1].status = oc_type; - - if (get_new_frame) { - if ((ret = frame_configure_elements(ac->avctx)) < 0) - return ret; - } - - return 0; -} - -static void flush(AVCodecContext *avctx) -{ - AACContext *ac= avctx->priv_data; - int type, i, j; - - for (type = 3; type >= 0; type--) { - for (i = 0; i < MAX_ELEM_ID; i++) { - ChannelElement *che = ac->che[type][i]; - if (che) { - for (j = 0; j <= 1; j++) { - memset(che->ch[j].saved, 0, sizeof(che->ch[j].saved)); - } - } - } - } -} - -/** - * Set up channel positions based on a default channel configuration - * as specified in table 1.17. - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int set_default_channel_config(AVCodecContext *avctx, - uint8_t (*layout_map)[3], - int *tags, - int channel_config) -{ - if (channel_config < 1 || (channel_config > 7 && channel_config < 11) || - channel_config > 12) { - av_log(avctx, AV_LOG_ERROR, - "invalid default channel configuration (%d)\n", - channel_config); - return AVERROR_INVALIDDATA; - } - *tags = tags_per_config[channel_config]; - memcpy(layout_map, aac_channel_layout_map[channel_config - 1], - *tags * sizeof(*layout_map)); - - /* - * AAC specification has 7.1(wide) as a default layout for 8-channel streams. - * However, at least Nero AAC encoder encodes 7.1 streams using the default - * channel config 7, mapping the side channels of the original audio stream - * to the second AAC_CHANNEL_FRONT pair in the AAC stream. Similarly, e.g. FAAD - * decodes the second AAC_CHANNEL_FRONT pair as side channels, therefore decoding - * the incorrect streams as if they were correct (and as the encoder intended). - * - * As actual intended 7.1(wide) streams are very rare, default to assuming a - * 7.1 layout was intended. - */ - if (channel_config == 7 && avctx->strict_std_compliance < FF_COMPLIANCE_STRICT) { - av_log(avctx, AV_LOG_INFO, "Assuming an incorrectly encoded 7.1 channel layout" - " instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode" - " according to the specification instead.\n", FF_COMPLIANCE_STRICT); - layout_map[2][2] = AAC_CHANNEL_SIDE; - } - - return 0; -} - -static ChannelElement *get_che(AACContext *ac, int type, int elem_id) -{ - /* For PCE based channel configurations map the channels solely based - * on tags. */ - if (!ac->oc[1].m4ac.chan_config) { - return ac->tag_che_map[type][elem_id]; - } - // Allow single CPE stereo files to be signalled with mono configuration. - if (!ac->tags_mapped && type == TYPE_CPE && - ac->oc[1].m4ac.chan_config == 1) { - uint8_t layout_map[MAX_ELEM_ID*4][3]; - int layout_map_tags; - push_output_configuration(ac); - - av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n"); - - if (set_default_channel_config(ac->avctx, layout_map, - &layout_map_tags, 2) < 0) - return NULL; - if (output_configure(ac, layout_map, layout_map_tags, - OC_TRIAL_FRAME, 1) < 0) - return NULL; - - ac->oc[1].m4ac.chan_config = 2; - ac->oc[1].m4ac.ps = 0; - } - // And vice-versa - if (!ac->tags_mapped && type == TYPE_SCE && - ac->oc[1].m4ac.chan_config == 2) { - uint8_t layout_map[MAX_ELEM_ID * 4][3]; - int layout_map_tags; - push_output_configuration(ac); - - av_log(ac->avctx, AV_LOG_DEBUG, "stereo with SCE\n"); - - if (set_default_channel_config(ac->avctx, layout_map, - &layout_map_tags, 1) < 0) - return NULL; - if (output_configure(ac, layout_map, layout_map_tags, - OC_TRIAL_FRAME, 1) < 0) - return NULL; - - ac->oc[1].m4ac.chan_config = 1; - if (ac->oc[1].m4ac.sbr) - ac->oc[1].m4ac.ps = -1; - } - /* For indexed channel configurations map the channels solely based - * on position. */ - switch (ac->oc[1].m4ac.chan_config) { - case 12: - case 7: - if (ac->tags_mapped == 3 && type == TYPE_CPE) { - ac->tags_mapped++; - return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2]; - } - case 11: - if (ac->tags_mapped == 2 && - ac->oc[1].m4ac.chan_config == 11 && - type == TYPE_SCE) { - ac->tags_mapped++; - return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1]; - } - case 6: - /* Some streams incorrectly code 5.1 audio as - * SCE[0] CPE[0] CPE[1] SCE[1] - * instead of - * SCE[0] CPE[0] CPE[1] LFE[0]. - * If we seem to have encountered such a stream, transfer - * the LFE[0] element to the SCE[1]'s mapping */ - if (ac->tags_mapped == tags_per_config[ac->oc[1].m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) { - if (!ac->warned_remapping_once && (type != TYPE_LFE || elem_id != 0)) { - av_log(ac->avctx, AV_LOG_WARNING, - "This stream seems to incorrectly report its last channel as %s[%d], mapping to LFE[0]\n", - type == TYPE_SCE ? "SCE" : "LFE", elem_id); - ac->warned_remapping_once++; - } - ac->tags_mapped++; - return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0]; - } - case 5: - if (ac->tags_mapped == 2 && type == TYPE_CPE) { - ac->tags_mapped++; - return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1]; - } - case 4: - /* Some streams incorrectly code 4.0 audio as - * SCE[0] CPE[0] LFE[0] - * instead of - * SCE[0] CPE[0] SCE[1]. - * If we seem to have encountered such a stream, transfer - * the SCE[1] element to the LFE[0]'s mapping */ - if (ac->tags_mapped == tags_per_config[ac->oc[1].m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) { - if (!ac->warned_remapping_once && (type != TYPE_SCE || elem_id != 1)) { - av_log(ac->avctx, AV_LOG_WARNING, - "This stream seems to incorrectly report its last channel as %s[%d], mapping to SCE[1]\n", - type == TYPE_SCE ? "SCE" : "LFE", elem_id); - ac->warned_remapping_once++; - } - ac->tags_mapped++; - return ac->tag_che_map[type][elem_id] = ac->che[TYPE_SCE][1]; - } - if (ac->tags_mapped == 2 && - ac->oc[1].m4ac.chan_config == 4 && - type == TYPE_SCE) { - ac->tags_mapped++; - return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1]; - } - case 3: - case 2: - if (ac->tags_mapped == (ac->oc[1].m4ac.chan_config != 2) && - type == TYPE_CPE) { - ac->tags_mapped++; - return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0]; - } else if (ac->oc[1].m4ac.chan_config == 2) { - return NULL; - } - case 1: - if (!ac->tags_mapped && type == TYPE_SCE) { - ac->tags_mapped++; - return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][0]; - } - default: - return NULL; - } -} - -/** - * Decode an array of 4 bit element IDs, optionally interleaved with a - * stereo/mono switching bit. - * - * @param type speaker type/position for these channels - */ -static void decode_channel_map(uint8_t layout_map[][3], - enum ChannelPosition type, - GetBitContext *gb, int n) -{ - while (n--) { - enum RawDataBlockType syn_ele; - switch (type) { - case AAC_CHANNEL_FRONT: - case AAC_CHANNEL_BACK: - case AAC_CHANNEL_SIDE: - syn_ele = get_bits1(gb); - break; - case AAC_CHANNEL_CC: - skip_bits1(gb); - syn_ele = TYPE_CCE; - break; - case AAC_CHANNEL_LFE: - syn_ele = TYPE_LFE; - break; - default: - // AAC_CHANNEL_OFF has no channel map - av_assert0(0); - } - layout_map[0][0] = syn_ele; - layout_map[0][1] = get_bits(gb, 4); - layout_map[0][2] = type; - layout_map++; - } -} - -/** - * Decode program configuration element; reference: table 4.2. - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac, - uint8_t (*layout_map)[3], - GetBitContext *gb) -{ - int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc; - int sampling_index; - int comment_len; - int tags; - - skip_bits(gb, 2); // object_type - - sampling_index = get_bits(gb, 4); - if (m4ac->sampling_index != sampling_index) - av_log(avctx, AV_LOG_WARNING, - "Sample rate index in program config element does not " - "match the sample rate index configured by the container.\n"); - - num_front = get_bits(gb, 4); - num_side = get_bits(gb, 4); - num_back = get_bits(gb, 4); - num_lfe = get_bits(gb, 2); - num_assoc_data = get_bits(gb, 3); - num_cc = get_bits(gb, 4); - - if (get_bits1(gb)) - skip_bits(gb, 4); // mono_mixdown_tag - if (get_bits1(gb)) - skip_bits(gb, 4); // stereo_mixdown_tag - - if (get_bits1(gb)) - skip_bits(gb, 3); // mixdown_coeff_index and pseudo_surround - - if (get_bits_left(gb) < 4 * (num_front + num_side + num_back + num_lfe + num_assoc_data + num_cc)) { - av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err); - return -1; - } - decode_channel_map(layout_map , AAC_CHANNEL_FRONT, gb, num_front); - tags = num_front; - decode_channel_map(layout_map + tags, AAC_CHANNEL_SIDE, gb, num_side); - tags += num_side; - decode_channel_map(layout_map + tags, AAC_CHANNEL_BACK, gb, num_back); - tags += num_back; - decode_channel_map(layout_map + tags, AAC_CHANNEL_LFE, gb, num_lfe); - tags += num_lfe; - - skip_bits_long(gb, 4 * num_assoc_data); - - decode_channel_map(layout_map + tags, AAC_CHANNEL_CC, gb, num_cc); - tags += num_cc; - - align_get_bits(gb); - - /* comment field, first byte is length */ - comment_len = get_bits(gb, 8) * 8; - if (get_bits_left(gb) < comment_len) { - av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err); - return AVERROR_INVALIDDATA; - } - skip_bits_long(gb, comment_len); - return tags; -} - -/** - * Decode GA "General Audio" specific configuration; reference: table 4.1. - * - * @param ac pointer to AACContext, may be null - * @param avctx pointer to AVCCodecContext, used for logging - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx, - GetBitContext *gb, - MPEG4AudioConfig *m4ac, - int channel_config) -{ - int extension_flag, ret, ep_config, res_flags; - uint8_t layout_map[MAX_ELEM_ID*4][3]; - int tags = 0; - - if (get_bits1(gb)) { // frameLengthFlag - avpriv_request_sample(avctx, "960/120 MDCT window"); - return AVERROR_PATCHWELCOME; - } - m4ac->frame_length_short = 0; - - if (get_bits1(gb)) // dependsOnCoreCoder - skip_bits(gb, 14); // coreCoderDelay - extension_flag = get_bits1(gb); - - if (m4ac->object_type == AOT_AAC_SCALABLE || - m4ac->object_type == AOT_ER_AAC_SCALABLE) - skip_bits(gb, 3); // layerNr - - if (channel_config == 0) { - skip_bits(gb, 4); // element_instance_tag - tags = decode_pce(avctx, m4ac, layout_map, gb); - if (tags < 0) - return tags; - } else { - if ((ret = set_default_channel_config(avctx, layout_map, - &tags, channel_config))) - return ret; - } - - if (count_channels(layout_map, tags) > 1) { - m4ac->ps = 0; - } else if (m4ac->sbr == 1 && m4ac->ps == -1) - m4ac->ps = 1; - - if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) - return ret; - - if (extension_flag) { - switch (m4ac->object_type) { - case AOT_ER_BSAC: - skip_bits(gb, 5); // numOfSubFrame - skip_bits(gb, 11); // layer_length - break; - case AOT_ER_AAC_LC: - case AOT_ER_AAC_LTP: - case AOT_ER_AAC_SCALABLE: - case AOT_ER_AAC_LD: - res_flags = get_bits(gb, 3); - if (res_flags) { - avpriv_report_missing_feature(avctx, - "AAC data resilience (flags %x)", - res_flags); - return AVERROR_PATCHWELCOME; - } - break; - } - skip_bits1(gb); // extensionFlag3 (TBD in version 3) - } - switch (m4ac->object_type) { - case AOT_ER_AAC_LC: - case AOT_ER_AAC_LTP: - case AOT_ER_AAC_SCALABLE: - case AOT_ER_AAC_LD: - ep_config = get_bits(gb, 2); - if (ep_config) { - avpriv_report_missing_feature(avctx, - "epConfig %d", ep_config); - return AVERROR_PATCHWELCOME; - } - } - return 0; -} - -static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx, - GetBitContext *gb, - MPEG4AudioConfig *m4ac, - int channel_config) -{ - int ret, ep_config, res_flags; - uint8_t layout_map[MAX_ELEM_ID*4][3]; - int tags = 0; - const int ELDEXT_TERM = 0; - - m4ac->ps = 0; - m4ac->sbr = 0; - - m4ac->frame_length_short = get_bits1(gb); - res_flags = get_bits(gb, 3); - if (res_flags) { - avpriv_report_missing_feature(avctx, - "AAC data resilience (flags %x)", - res_flags); - return AVERROR_PATCHWELCOME; - } - - if (get_bits1(gb)) { // ldSbrPresentFlag - avpriv_report_missing_feature(avctx, - "Low Delay SBR"); - return AVERROR_PATCHWELCOME; - } - - while (get_bits(gb, 4) != ELDEXT_TERM) { - int len = get_bits(gb, 4); - if (len == 15) - len += get_bits(gb, 8); - if (len == 15 + 255) - len += get_bits(gb, 16); - if (get_bits_left(gb) < len * 8 + 4) { - av_log(avctx, AV_LOG_ERROR, overread_err); - return AVERROR_INVALIDDATA; - } - skip_bits_long(gb, 8 * len); - } - - if ((ret = set_default_channel_config(avctx, layout_map, - &tags, channel_config))) - return ret; - - if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) - return ret; - - ep_config = get_bits(gb, 2); - if (ep_config) { - avpriv_report_missing_feature(avctx, - "epConfig %d", ep_config); - return AVERROR_PATCHWELCOME; - } - return 0; -} - -/** - * Decode audio specific configuration; reference: table 1.13. - * - * @param ac pointer to AACContext, may be null - * @param avctx pointer to AVCCodecContext, used for logging - * @param m4ac pointer to MPEG4AudioConfig, used for parsing - * @param data pointer to buffer holding an audio specific config - * @param bit_size size of audio specific config or data in bits - * @param sync_extension look for an appended sync extension - * - * @return Returns error status or number of consumed bits. <0 - error - */ -static int decode_audio_specific_config(AACContext *ac, - AVCodecContext *avctx, - MPEG4AudioConfig *m4ac, - const uint8_t *data, int bit_size, - int sync_extension) -{ - GetBitContext gb; - int i, ret; - - ff_dlog(avctx, "audio specific config size %d\n", bit_size >> 3); - for (i = 0; i < bit_size >> 3; i++) - ff_dlog(avctx, "%02x ", data[i]); - ff_dlog(avctx, "\n"); - - if ((ret = init_get_bits(&gb, data, bit_size)) < 0) - return ret; - - if ((i = avpriv_mpeg4audio_get_config(m4ac, data, bit_size, - sync_extension)) < 0) - return AVERROR_INVALIDDATA; - if (m4ac->sampling_index > 12) { - av_log(avctx, AV_LOG_ERROR, - "invalid sampling rate index %d\n", - m4ac->sampling_index); - return AVERROR_INVALIDDATA; - } - if (m4ac->object_type == AOT_ER_AAC_LD && - (m4ac->sampling_index < 3 || m4ac->sampling_index > 7)) { - av_log(avctx, AV_LOG_ERROR, - "invalid low delay sampling rate index %d\n", - m4ac->sampling_index); - return AVERROR_INVALIDDATA; - } - - skip_bits_long(&gb, i); - - switch (m4ac->object_type) { - case AOT_AAC_MAIN: - case AOT_AAC_LC: - case AOT_AAC_LTP: - case AOT_ER_AAC_LC: - case AOT_ER_AAC_LD: - if ((ret = decode_ga_specific_config(ac, avctx, &gb, - m4ac, m4ac->chan_config)) < 0) - return ret; - break; - case AOT_ER_AAC_ELD: - if ((ret = decode_eld_specific_config(ac, avctx, &gb, - m4ac, m4ac->chan_config)) < 0) - return ret; - break; - default: - avpriv_report_missing_feature(avctx, - "Audio object type %s%d", - m4ac->sbr == 1 ? "SBR+" : "", - m4ac->object_type); - return AVERROR(ENOSYS); - } - - ff_dlog(avctx, - "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n", - m4ac->object_type, m4ac->chan_config, m4ac->sampling_index, - m4ac->sample_rate, m4ac->sbr, - m4ac->ps); - - return get_bits_count(&gb); -} - -/** - * linear congruential pseudorandom number generator - * - * @param previous_val pointer to the current state of the generator - * - * @return Returns a 32-bit pseudorandom integer - */ -static av_always_inline int lcg_random(unsigned previous_val) -{ - union { unsigned u; int s; } v = { previous_val * 1664525u + 1013904223 }; - return v.s; -} - static av_always_inline void reset_predict_state(PredictorState *ps) { ps->r0 = 0.0f; ps->r1 = 0.0f; ps->cor0 = 0.0f; - ps->cor1 = 0.0f; - ps->var0 = 1.0f; - ps->var1 = 1.0f; -} - -static void reset_all_predictors(PredictorState *ps) -{ - int i; - for (i = 0; i < MAX_PREDICTORS; i++) - reset_predict_state(&ps[i]); -} - -static int sample_rate_idx (int rate) -{ - if (92017 <= rate) return 0; - else if (75132 <= rate) return 1; - else if (55426 <= rate) return 2; - else if (46009 <= rate) return 3; - else if (37566 <= rate) return 4; - else if (27713 <= rate) return 5; - else if (23004 <= rate) return 6; - else if (18783 <= rate) return 7; - else if (13856 <= rate) return 8; - else if (11502 <= rate) return 9; - else if (9391 <= rate) return 10; - else return 11; -} - -static void reset_predictor_group(PredictorState *ps, int group_num) -{ - int i; - for (i = group_num - 1; i < MAX_PREDICTORS; i += 30) - reset_predict_state(&ps[i]); -} - -#define AAC_INIT_VLC_STATIC(num, size) \ - INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \ - ff_aac_spectral_bits[num], sizeof(ff_aac_spectral_bits[num][0]), \ - sizeof(ff_aac_spectral_bits[num][0]), \ - ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), \ - sizeof(ff_aac_spectral_codes[num][0]), \ - size); - -static void aacdec_init(AACContext *ac); - -static av_cold int aac_decode_init(AVCodecContext *avctx) -{ - AACContext *ac = avctx->priv_data; - int ret; - - ac->avctx = avctx; - ac->oc[1].m4ac.sample_rate = avctx->sample_rate; - - aacdec_init(ac); - - avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; - - if (avctx->extradata_size > 0) { - if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, - avctx->extradata, - avctx->extradata_size * 8, - 1)) < 0) - return ret; - } else { - int sr, i; - uint8_t layout_map[MAX_ELEM_ID*4][3]; - int layout_map_tags; - - sr = sample_rate_idx(avctx->sample_rate); - ac->oc[1].m4ac.sampling_index = sr; - ac->oc[1].m4ac.channels = avctx->channels; - ac->oc[1].m4ac.sbr = -1; - ac->oc[1].m4ac.ps = -1; - - for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++) - if (ff_mpeg4audio_channels[i] == avctx->channels) - break; - if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) { - i = 0; - } - ac->oc[1].m4ac.chan_config = i; - - if (ac->oc[1].m4ac.chan_config) { - int ret = set_default_channel_config(avctx, layout_map, - &layout_map_tags, ac->oc[1].m4ac.chan_config); - if (!ret) - output_configure(ac, layout_map, layout_map_tags, - OC_GLOBAL_HDR, 0); - else if (avctx->err_recognition & AV_EF_EXPLODE) - return AVERROR_INVALIDDATA; - } - } - - if (avctx->channels > MAX_CHANNELS) { - av_log(avctx, AV_LOG_ERROR, "Too many channels\n"); - return AVERROR_INVALIDDATA; - } - - AAC_INIT_VLC_STATIC( 0, 304); - AAC_INIT_VLC_STATIC( 1, 270); - AAC_INIT_VLC_STATIC( 2, 550); - AAC_INIT_VLC_STATIC( 3, 300); - AAC_INIT_VLC_STATIC( 4, 328); - AAC_INIT_VLC_STATIC( 5, 294); - AAC_INIT_VLC_STATIC( 6, 306); - AAC_INIT_VLC_STATIC( 7, 268); - AAC_INIT_VLC_STATIC( 8, 510); - AAC_INIT_VLC_STATIC( 9, 366); - AAC_INIT_VLC_STATIC(10, 462); - - ff_aac_sbr_init(); - - ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); - if (!ac->fdsp) { - return AVERROR(ENOMEM); - } - - ac->random_state = 0x1f2e3d4c; - - ff_aac_tableinit(); - - INIT_VLC_STATIC(&vlc_scalefactors, 7, - FF_ARRAY_ELEMS(ff_aac_scalefactor_code), - ff_aac_scalefactor_bits, - sizeof(ff_aac_scalefactor_bits[0]), - sizeof(ff_aac_scalefactor_bits[0]), - ff_aac_scalefactor_code, - sizeof(ff_aac_scalefactor_code[0]), - sizeof(ff_aac_scalefactor_code[0]), - 352); - - ff_mdct_init(&ac->mdct, 11, 1, 1.0 / (32768.0 * 1024.0)); - ff_mdct_init(&ac->mdct_ld, 10, 1, 1.0 / (32768.0 * 512.0)); - ff_mdct_init(&ac->mdct_small, 8, 1, 1.0 / (32768.0 * 128.0)); - ff_mdct_init(&ac->mdct_ltp, 11, 0, -2.0 * 32768.0); - ret = ff_imdct15_init(&ac->mdct480, 5); - if (ret < 0) - return ret; - - // window initialization - ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); - ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128); - ff_init_ff_sine_windows(10); - ff_init_ff_sine_windows( 9); - ff_init_ff_sine_windows( 7); - - cbrt_tableinit(); - - return 0; -} - -/** - * Skip data_stream_element; reference: table 4.10. - */ -static int skip_data_stream_element(AACContext *ac, GetBitContext *gb) -{ - int byte_align = get_bits1(gb); - int count = get_bits(gb, 8); - if (count == 255) - count += get_bits(gb, 8); - if (byte_align) - align_get_bits(gb); - - if (get_bits_left(gb) < 8 * count) { - av_log(ac->avctx, AV_LOG_ERROR, "skip_data_stream_element: "overread_err); - return AVERROR_INVALIDDATA; - } - skip_bits_long(gb, 8 * count); - return 0; -} - -static int decode_prediction(AACContext *ac, IndividualChannelStream *ics, - GetBitContext *gb) -{ - int sfb; - if (get_bits1(gb)) { - ics->predictor_reset_group = get_bits(gb, 5); - if (ics->predictor_reset_group == 0 || - ics->predictor_reset_group > 30) { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid Predictor Reset Group.\n"); - return AVERROR_INVALIDDATA; - } - } - for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]); sfb++) { - ics->prediction_used[sfb] = get_bits1(gb); - } - return 0; -} - -/** - * Decode Long Term Prediction data; reference: table 4.xx. - */ -static void decode_ltp(LongTermPrediction *ltp, - GetBitContext *gb, uint8_t max_sfb) -{ - int sfb; - - ltp->lag = get_bits(gb, 11); - ltp->coef = ltp_coef[get_bits(gb, 3)]; - for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++) - ltp->used[sfb] = get_bits1(gb); -} - -/** - * Decode Individual Channel Stream info; reference: table 4.6. - */ -static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, - GetBitContext *gb) -{ - const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac; - const int aot = m4ac->object_type; - const int sampling_index = m4ac->sampling_index; - if (aot != AOT_ER_AAC_ELD) { - if (get_bits1(gb)) { - av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n"); - if (ac->avctx->err_recognition & AV_EF_BITSTREAM) - return AVERROR_INVALIDDATA; - } - ics->window_sequence[1] = ics->window_sequence[0]; - ics->window_sequence[0] = get_bits(gb, 2); - if (aot == AOT_ER_AAC_LD && - ics->window_sequence[0] != ONLY_LONG_SEQUENCE) { - av_log(ac->avctx, AV_LOG_ERROR, - "AAC LD is only defined for ONLY_LONG_SEQUENCE but " - "window sequence %d found.\n", ics->window_sequence[0]); - ics->window_sequence[0] = ONLY_LONG_SEQUENCE; - return AVERROR_INVALIDDATA; - } - ics->use_kb_window[1] = ics->use_kb_window[0]; - ics->use_kb_window[0] = get_bits1(gb); - } - ics->num_window_groups = 1; - ics->group_len[0] = 1; - if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - int i; - ics->max_sfb = get_bits(gb, 4); - for (i = 0; i < 7; i++) { - if (get_bits1(gb)) { - ics->group_len[ics->num_window_groups - 1]++; - } else { - ics->num_window_groups++; - ics->group_len[ics->num_window_groups - 1] = 1; - } - } - ics->num_windows = 8; - ics->swb_offset = ff_swb_offset_128[sampling_index]; - ics->num_swb = ff_aac_num_swb_128[sampling_index]; - ics->tns_max_bands = ff_tns_max_bands_128[sampling_index]; - ics->predictor_present = 0; - } else { - ics->max_sfb = get_bits(gb, 6); - ics->num_windows = 1; - if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) { - if (m4ac->frame_length_short) { - ics->swb_offset = ff_swb_offset_480[sampling_index]; - ics->num_swb = ff_aac_num_swb_480[sampling_index]; - ics->tns_max_bands = ff_tns_max_bands_480[sampling_index]; - } else { - ics->swb_offset = ff_swb_offset_512[sampling_index]; - ics->num_swb = ff_aac_num_swb_512[sampling_index]; - ics->tns_max_bands = ff_tns_max_bands_512[sampling_index]; - } - if (!ics->num_swb || !ics->swb_offset) - return AVERROR_BUG; - } else { - ics->swb_offset = ff_swb_offset_1024[sampling_index]; - ics->num_swb = ff_aac_num_swb_1024[sampling_index]; - ics->tns_max_bands = ff_tns_max_bands_1024[sampling_index]; - } - if (aot != AOT_ER_AAC_ELD) { - ics->predictor_present = get_bits1(gb); - ics->predictor_reset_group = 0; - } - if (ics->predictor_present) { - if (aot == AOT_AAC_MAIN) { - if (decode_prediction(ac, ics, gb)) { - goto fail; - } - } else if (aot == AOT_AAC_LC || - aot == AOT_ER_AAC_LC) { - av_log(ac->avctx, AV_LOG_ERROR, - "Prediction is not allowed in AAC-LC.\n"); - goto fail; - } else { - if (aot == AOT_ER_AAC_LD) { - av_log(ac->avctx, AV_LOG_ERROR, - "LTP in ER AAC LD not yet implemented.\n"); - return AVERROR_PATCHWELCOME; - } - if ((ics->ltp.present = get_bits(gb, 1))) - decode_ltp(&ics->ltp, gb, ics->max_sfb); - } - } - } - - if (ics->max_sfb > ics->num_swb) { - av_log(ac->avctx, AV_LOG_ERROR, - "Number of scalefactor bands in group (%d) " - "exceeds limit (%d).\n", - ics->max_sfb, ics->num_swb); - goto fail; - } - - return 0; -fail: - ics->max_sfb = 0; - return AVERROR_INVALIDDATA; -} - -/** - * Decode band types (section_data payload); reference: table 4.46. - * - * @param band_type array of the used band type - * @param band_type_run_end array of the last scalefactor band of a band type run - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_band_types(AACContext *ac, enum BandType band_type[120], - int band_type_run_end[120], GetBitContext *gb, - IndividualChannelStream *ics) -{ - int g, idx = 0; - const int bits = (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) ? 3 : 5; - for (g = 0; g < ics->num_window_groups; g++) { - int k = 0; - while (k < ics->max_sfb) { - uint8_t sect_end = k; - int sect_len_incr; - int sect_band_type = get_bits(gb, 4); - if (sect_band_type == 12) { - av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n"); - return AVERROR_INVALIDDATA; - } - do { - sect_len_incr = get_bits(gb, bits); - sect_end += sect_len_incr; - if (get_bits_left(gb) < 0) { - av_log(ac->avctx, AV_LOG_ERROR, "decode_band_types: "overread_err); - return AVERROR_INVALIDDATA; - } - if (sect_end > ics->max_sfb) { - av_log(ac->avctx, AV_LOG_ERROR, - "Number of bands (%d) exceeds limit (%d).\n", - sect_end, ics->max_sfb); - return AVERROR_INVALIDDATA; - } - } while (sect_len_incr == (1 << bits) - 1); - for (; k < sect_end; k++) { - band_type [idx] = sect_band_type; - band_type_run_end[idx++] = sect_end; - } - } - } - return 0; -} - -/** - * Decode scalefactors; reference: table 4.47. - * - * @param global_gain first scalefactor value as scalefactors are differentially coded - * @param band_type array of the used band type - * @param band_type_run_end array of the last scalefactor band of a band type run - * @param sf array of scalefactors or intensity stereo positions - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, - unsigned int global_gain, - IndividualChannelStream *ics, - enum BandType band_type[120], - int band_type_run_end[120]) -{ - int g, i, idx = 0; - int offset[3] = { global_gain, global_gain - NOISE_OFFSET, 0 }; - int clipped_offset; - int noise_flag = 1; - for (g = 0; g < ics->num_window_groups; g++) { - for (i = 0; i < ics->max_sfb;) { - int run_end = band_type_run_end[idx]; - if (band_type[idx] == ZERO_BT) { - for (; i < run_end; i++, idx++) - sf[idx] = 0.0; - } else if ((band_type[idx] == INTENSITY_BT) || - (band_type[idx] == INTENSITY_BT2)) { - for (; i < run_end; i++, idx++) { - offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - SCALE_DIFF_ZERO; - clipped_offset = av_clip(offset[2], -155, 100); - if (offset[2] != clipped_offset) { - avpriv_request_sample(ac->avctx, - "If you heard an audible artifact, there may be a bug in the decoder. " - "Clipped intensity stereo position (%d -> %d)", - offset[2], clipped_offset); - } - sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + POW_SF2_ZERO]; - } - } else if (band_type[idx] == NOISE_BT) { - for (; i < run_end; i++, idx++) { - if (noise_flag-- > 0) - offset[1] += get_bits(gb, NOISE_PRE_BITS) - NOISE_PRE; - else - offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - SCALE_DIFF_ZERO; - clipped_offset = av_clip(offset[1], -100, 155); - if (offset[1] != clipped_offset) { - avpriv_request_sample(ac->avctx, - "If you heard an audible artifact, there may be a bug in the decoder. " - "Clipped noise gain (%d -> %d)", - offset[1], clipped_offset); - } - sf[idx] = -ff_aac_pow2sf_tab[clipped_offset + POW_SF2_ZERO]; - } - } else { - for (; i < run_end; i++, idx++) { - offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - SCALE_DIFF_ZERO; - if (offset[0] > 255U) { - av_log(ac->avctx, AV_LOG_ERROR, - "Scalefactor (%d) out of range.\n", offset[0]); - return AVERROR_INVALIDDATA; - } - sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO]; - } - } - } - } - return 0; -} - -/** - * Decode pulse data; reference: table 4.7. - */ -static int decode_pulses(Pulse *pulse, GetBitContext *gb, - const uint16_t *swb_offset, int num_swb) -{ - int i, pulse_swb; - pulse->num_pulse = get_bits(gb, 2) + 1; - pulse_swb = get_bits(gb, 6); - if (pulse_swb >= num_swb) - return -1; - pulse->pos[0] = swb_offset[pulse_swb]; - pulse->pos[0] += get_bits(gb, 5); - if (pulse->pos[0] >= swb_offset[num_swb]) - return -1; - pulse->amp[0] = get_bits(gb, 4); - for (i = 1; i < pulse->num_pulse; i++) { - pulse->pos[i] = get_bits(gb, 5) + pulse->pos[i - 1]; - if (pulse->pos[i] >= swb_offset[num_swb]) - return -1; - pulse->amp[i] = get_bits(gb, 4); - } - return 0; -} - -/** - * Decode Temporal Noise Shaping data; reference: table 4.48. - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns, - GetBitContext *gb, const IndividualChannelStream *ics) -{ - int w, filt, i, coef_len, coef_res, coef_compress; - const int is8 = ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE; - const int tns_max_order = is8 ? 7 : ac->oc[1].m4ac.object_type == AOT_AAC_MAIN ? 20 : 12; - for (w = 0; w < ics->num_windows; w++) { - if ((tns->n_filt[w] = get_bits(gb, 2 - is8))) { - coef_res = get_bits1(gb); - - for (filt = 0; filt < tns->n_filt[w]; filt++) { - int tmp2_idx; - tns->length[w][filt] = get_bits(gb, 6 - 2 * is8); - - if ((tns->order[w][filt] = get_bits(gb, 5 - 2 * is8)) > tns_max_order) { - av_log(ac->avctx, AV_LOG_ERROR, - "TNS filter order %d is greater than maximum %d.\n", - tns->order[w][filt], tns_max_order); - tns->order[w][filt] = 0; - return AVERROR_INVALIDDATA; - } - if (tns->order[w][filt]) { - tns->direction[w][filt] = get_bits1(gb); - coef_compress = get_bits1(gb); - coef_len = coef_res + 3 - coef_compress; - tmp2_idx = 2 * coef_compress + coef_res; - - for (i = 0; i < tns->order[w][filt]; i++) - tns->coef[w][filt][i] = tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)]; - } - } - } - } - return 0; -} - -/** - * Decode Mid/Side data; reference: table 4.54. - * - * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s; - * [1] mask is decoded from bitstream; [2] mask is all 1s; - * [3] reserved for scalable AAC - */ -static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb, - int ms_present) -{ - int idx; - int max_idx = cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb; - if (ms_present == 1) { - for (idx = 0; idx < max_idx; idx++) - cpe->ms_mask[idx] = get_bits1(gb); - } else if (ms_present == 2) { - memset(cpe->ms_mask, 1, max_idx * sizeof(cpe->ms_mask[0])); - } + ps->cor1 = 0.0f; + ps->var0 = 1.0f; + ps->var1 = 1.0f; } #ifndef VMUL2 @@ -1610,1063 +134,71 @@ t.i = s.i ^ (sign & 1U<<31); *dst++ = v[idx>>2 & 3] * t.f; - sign <<= nz & 1; nz >>= 1; - t.i = s.i ^ (sign & 1U<<31); - *dst++ = v[idx>>4 & 3] * t.f; - - sign <<= nz & 1; - t.i = s.i ^ (sign & 1U<<31); - *dst++ = v[idx>>6 & 3] * t.f; - - return dst; -} -#endif - -/** - * Decode spectral data; reference: table 4.50. - * Dequantize and scale spectral data; reference: 4.6.3.3. - * - * @param coef array of dequantized, scaled spectral data - * @param sf array of scalefactors or intensity stereo positions - * @param pulse_present set if pulses are present - * @param pulse pointer to pulse data struct - * @param band_type array of the used band type - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], - GetBitContext *gb, const float sf[120], - int pulse_present, const Pulse *pulse, - const IndividualChannelStream *ics, - enum BandType band_type[120]) -{ - int i, k, g, idx = 0; - const int c = 1024 / ics->num_windows; - const uint16_t *offsets = ics->swb_offset; - float *coef_base = coef; - - for (g = 0; g < ics->num_windows; g++) - memset(coef + g * 128 + offsets[ics->max_sfb], 0, - sizeof(float) * (c - offsets[ics->max_sfb])); - - for (g = 0; g < ics->num_window_groups; g++) { - unsigned g_len = ics->group_len[g]; - - for (i = 0; i < ics->max_sfb; i++, idx++) { - const unsigned cbt_m1 = band_type[idx] - 1; - float *cfo = coef + offsets[i]; - int off_len = offsets[i + 1] - offsets[i]; - int group; - - if (cbt_m1 >= INTENSITY_BT2 - 1) { - for (group = 0; group < g_len; group++, cfo+=128) { - memset(cfo, 0, off_len * sizeof(float)); - } - } else if (cbt_m1 == NOISE_BT - 1) { - for (group = 0; group < g_len; group++, cfo+=128) { - float scale; - float band_energy; - - for (k = 0; k < off_len; k++) { - ac->random_state = lcg_random(ac->random_state); - cfo[k] = ac->random_state; - } - - band_energy = ac->fdsp->scalarproduct_float(cfo, cfo, off_len); - scale = sf[idx] / sqrtf(band_energy); - ac->fdsp->vector_fmul_scalar(cfo, cfo, scale, off_len); - } - } else { - const float *vq = ff_aac_codebook_vector_vals[cbt_m1]; - const uint16_t *cb_vector_idx = ff_aac_codebook_vector_idx[cbt_m1]; - VLC_TYPE (*vlc_tab)[2] = vlc_spectral[cbt_m1].table; - OPEN_READER(re, gb); - - switch (cbt_m1 >> 1) { - case 0: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; - int len = off_len; - - do { - int code; - unsigned cb_idx; - - UPDATE_CACHE(re, gb); - GET_VLC(code, re, gb, vlc_tab, 8, 2); - cb_idx = cb_vector_idx[code]; - cf = VMUL4(cf, vq, cb_idx, sf + idx); - } while (len -= 4); - } - break; - - case 1: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; - int len = off_len; - - do { - int code; - unsigned nnz; - unsigned cb_idx; - uint32_t bits; - - UPDATE_CACHE(re, gb); - GET_VLC(code, re, gb, vlc_tab, 8, 2); - cb_idx = cb_vector_idx[code]; - nnz = cb_idx >> 8 & 15; - bits = nnz ? GET_CACHE(re, gb) : 0; - LAST_SKIP_BITS(re, gb, nnz); - cf = VMUL4S(cf, vq, cb_idx, bits, sf + idx); - } while (len -= 4); - } - break; - - case 2: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; - int len = off_len; - - do { - int code; - unsigned cb_idx; - - UPDATE_CACHE(re, gb); - GET_VLC(code, re, gb, vlc_tab, 8, 2); - cb_idx = cb_vector_idx[code]; - cf = VMUL2(cf, vq, cb_idx, sf + idx); - } while (len -= 2); - } - break; - - case 3: - case 4: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; - int len = off_len; - - do { - int code; - unsigned nnz; - unsigned cb_idx; - unsigned sign; - - UPDATE_CACHE(re, gb); - GET_VLC(code, re, gb, vlc_tab, 8, 2); - cb_idx = cb_vector_idx[code]; - nnz = cb_idx >> 8 & 15; - sign = nnz ? SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12) : 0; - LAST_SKIP_BITS(re, gb, nnz); - cf = VMUL2S(cf, vq, cb_idx, sign, sf + idx); - } while (len -= 2); - } - break; - - default: - for (group = 0; group < g_len; group++, cfo+=128) { - float *cf = cfo; - uint32_t *icf = (uint32_t *) cf; - int len = off_len; - - do { - int code; - unsigned nzt, nnz; - unsigned cb_idx; - uint32_t bits; - int j; - - UPDATE_CACHE(re, gb); - GET_VLC(code, re, gb, vlc_tab, 8, 2); - - if (!code) { - *icf++ = 0; - *icf++ = 0; - continue; - } - - cb_idx = cb_vector_idx[code]; - nnz = cb_idx >> 12; - nzt = cb_idx >> 8; - bits = SHOW_UBITS(re, gb, nnz) << (32-nnz); - LAST_SKIP_BITS(re, gb, nnz); - - for (j = 0; j < 2; j++) { - if (nzt & 1< 8) { - av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n"); - return AVERROR_INVALIDDATA; - } - - SKIP_BITS(re, gb, b + 1); - b += 4; - n = (1 << b) + SHOW_UBITS(re, gb, b); - LAST_SKIP_BITS(re, gb, b); - *icf++ = cbrt_tab[n] | (bits & 1U<<31); - bits <<= 1; - } else { - unsigned v = ((const uint32_t*)vq)[cb_idx & 15]; - *icf++ = (bits & 1U<<31) | v; - bits <<= !!v; - } - cb_idx >>= 4; - } - } while (len -= 2); - - ac->fdsp->vector_fmul_scalar(cfo, cfo, sf[idx], off_len); - } - } - - CLOSE_READER(re, gb); - } - } - coef += g_len << 7; - } - - if (pulse_present) { - idx = 0; - for (i = 0; i < pulse->num_pulse; i++) { - float co = coef_base[ pulse->pos[i] ]; - while (offsets[idx + 1] <= pulse->pos[i]) - idx++; - if (band_type[idx] != NOISE_BT && sf[idx]) { - float ico = -pulse->amp[i]; - if (co) { - co /= sf[idx]; - ico = co / sqrtf(sqrtf(fabsf(co))) + (co > 0 ? -ico : ico); - } - coef_base[ pulse->pos[i] ] = cbrtf(fabsf(ico)) * ico * sf[idx]; - } - } - } - return 0; -} - -static av_always_inline float flt16_round(float pf) -{ - union av_intfloat32 tmp; - tmp.f = pf; - tmp.i = (tmp.i + 0x00008000U) & 0xFFFF0000U; - return tmp.f; -} - -static av_always_inline float flt16_even(float pf) -{ - union av_intfloat32 tmp; - tmp.f = pf; - tmp.i = (tmp.i + 0x00007FFFU + (tmp.i & 0x00010000U >> 16)) & 0xFFFF0000U; - return tmp.f; -} - -static av_always_inline float flt16_trunc(float pf) -{ - union av_intfloat32 pun; - pun.f = pf; - pun.i &= 0xFFFF0000U; - return pun.f; -} - -static av_always_inline void predict(PredictorState *ps, float *coef, - int output_enable) -{ - const float a = 0.953125; // 61.0 / 64 - const float alpha = 0.90625; // 29.0 / 32 - float e0, e1; - float pv; - float k1, k2; - float r0 = ps->r0, r1 = ps->r1; - float cor0 = ps->cor0, cor1 = ps->cor1; - float var0 = ps->var0, var1 = ps->var1; - - k1 = var0 > 1 ? cor0 * flt16_even(a / var0) : 0; - k2 = var1 > 1 ? cor1 * flt16_even(a / var1) : 0; - - pv = flt16_round(k1 * r0 + k2 * r1); - if (output_enable) - *coef += pv; - - e0 = *coef; - e1 = e0 - k1 * r0; - - ps->cor1 = flt16_trunc(alpha * cor1 + r1 * e1); - ps->var1 = flt16_trunc(alpha * var1 + 0.5f * (r1 * r1 + e1 * e1)); - ps->cor0 = flt16_trunc(alpha * cor0 + r0 * e0); - ps->var0 = flt16_trunc(alpha * var0 + 0.5f * (r0 * r0 + e0 * e0)); - - ps->r1 = flt16_trunc(a * (r0 - k1 * e0)); - ps->r0 = flt16_trunc(a * e0); -} - -/** - * Apply AAC-Main style frequency domain prediction. - */ -static void apply_prediction(AACContext *ac, SingleChannelElement *sce) -{ - int sfb, k; - - if (!sce->ics.predictor_initialized) { - reset_all_predictors(sce->predictor_state); - sce->ics.predictor_initialized = 1; - } - - if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { - for (sfb = 0; - sfb < ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]; - sfb++) { - for (k = sce->ics.swb_offset[sfb]; - k < sce->ics.swb_offset[sfb + 1]; - k++) { - predict(&sce->predictor_state[k], &sce->coeffs[k], - sce->ics.predictor_present && - sce->ics.prediction_used[sfb]); - } - } - if (sce->ics.predictor_reset_group) - reset_predictor_group(sce->predictor_state, - sce->ics.predictor_reset_group); - } else - reset_all_predictors(sce->predictor_state); -} - -/** - * Decode an individual_channel_stream payload; reference: table 4.44. - * - * @param common_window Channels have independent [0], or shared [1], Individual Channel Stream information. - * @param scale_flag scalable [1] or non-scalable [0] AAC (Unused until scalable AAC is implemented.) - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_ics(AACContext *ac, SingleChannelElement *sce, - GetBitContext *gb, int common_window, int scale_flag) -{ - Pulse pulse; - TemporalNoiseShaping *tns = &sce->tns; - IndividualChannelStream *ics = &sce->ics; - float *out = sce->coeffs; - int global_gain, eld_syntax, er_syntax, pulse_present = 0; - int ret; - - eld_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; - er_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_LC || - ac->oc[1].m4ac.object_type == AOT_ER_AAC_LTP || - ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD || - ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; - - /* This assignment is to silence a GCC warning about the variable being used - * uninitialized when in fact it always is. - */ - pulse.num_pulse = 0; - - global_gain = get_bits(gb, 8); - - if (!common_window && !scale_flag) { - if (decode_ics_info(ac, ics, gb) < 0) - return AVERROR_INVALIDDATA; - } - - if ((ret = decode_band_types(ac, sce->band_type, - sce->band_type_run_end, gb, ics)) < 0) - return ret; - if ((ret = decode_scalefactors(ac, sce->sf, gb, global_gain, ics, - sce->band_type, sce->band_type_run_end)) < 0) - return ret; - - pulse_present = 0; - if (!scale_flag) { - if (!eld_syntax && (pulse_present = get_bits1(gb))) { - if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - av_log(ac->avctx, AV_LOG_ERROR, - "Pulse tool not allowed in eight short sequence.\n"); - return AVERROR_INVALIDDATA; - } - if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) { - av_log(ac->avctx, AV_LOG_ERROR, - "Pulse data corrupt or invalid.\n"); - return AVERROR_INVALIDDATA; - } - } - tns->present = get_bits1(gb); - if (tns->present && !er_syntax) - if (decode_tns(ac, tns, gb, ics) < 0) - return AVERROR_INVALIDDATA; - if (!eld_syntax && get_bits1(gb)) { - avpriv_request_sample(ac->avctx, "SSR"); - return AVERROR_PATCHWELCOME; - } - // I see no textual basis in the spec for this occurring after SSR gain - // control, but this is what both reference and real implmentations do - if (tns->present && er_syntax) - if (decode_tns(ac, tns, gb, ics) < 0) - return AVERROR_INVALIDDATA; - } - - if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present, - &pulse, ics, sce->band_type) < 0) - return AVERROR_INVALIDDATA; - - if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN && !common_window) - apply_prediction(ac, sce); - - return 0; -} - -/** - * Mid/Side stereo decoding; reference: 4.6.8.1.3. - */ -static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe) -{ - const IndividualChannelStream *ics = &cpe->ch[0].ics; - float *ch0 = cpe->ch[0].coeffs; - float *ch1 = cpe->ch[1].coeffs; - int g, i, group, idx = 0; - const uint16_t *offsets = ics->swb_offset; - for (g = 0; g < ics->num_window_groups; g++) { - for (i = 0; i < ics->max_sfb; i++, idx++) { - if (cpe->ms_mask[idx] && - cpe->ch[0].band_type[idx] < NOISE_BT && - cpe->ch[1].band_type[idx] < NOISE_BT) { - for (group = 0; group < ics->group_len[g]; group++) { - ac->fdsp->butterflies_float(ch0 + group * 128 + offsets[i], - ch1 + group * 128 + offsets[i], - offsets[i+1] - offsets[i]); - } - } - } - ch0 += ics->group_len[g] * 128; - ch1 += ics->group_len[g] * 128; - } -} - -/** - * intensity stereo decoding; reference: 4.6.8.2.3 - * - * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s; - * [1] mask is decoded from bitstream; [2] mask is all 1s; - * [3] reserved for scalable AAC - */ -static void apply_intensity_stereo(AACContext *ac, - ChannelElement *cpe, int ms_present) -{ - const IndividualChannelStream *ics = &cpe->ch[1].ics; - SingleChannelElement *sce1 = &cpe->ch[1]; - float *coef0 = cpe->ch[0].coeffs, *coef1 = cpe->ch[1].coeffs; - const uint16_t *offsets = ics->swb_offset; - int g, group, i, idx = 0; - int c; - float scale; - for (g = 0; g < ics->num_window_groups; g++) { - for (i = 0; i < ics->max_sfb;) { - if (sce1->band_type[idx] == INTENSITY_BT || - sce1->band_type[idx] == INTENSITY_BT2) { - const int bt_run_end = sce1->band_type_run_end[idx]; - for (; i < bt_run_end; i++, idx++) { - c = -1 + 2 * (sce1->band_type[idx] - 14); - if (ms_present) - c *= 1 - 2 * cpe->ms_mask[idx]; - scale = c * sce1->sf[idx]; - for (group = 0; group < ics->group_len[g]; group++) - ac->fdsp->vector_fmul_scalar(coef1 + group * 128 + offsets[i], - coef0 + group * 128 + offsets[i], - scale, - offsets[i + 1] - offsets[i]); - } - } else { - int bt_run_end = sce1->band_type_run_end[idx]; - idx += bt_run_end - i; - i = bt_run_end; - } - } - coef0 += ics->group_len[g] * 128; - coef1 += ics->group_len[g] * 128; - } -} - -/** - * Decode a channel_pair_element; reference: table 4.4. - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe) -{ - int i, ret, common_window, ms_present = 0; - int eld_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; - - common_window = eld_syntax || get_bits1(gb); - if (common_window) { - if (decode_ics_info(ac, &cpe->ch[0].ics, gb)) - return AVERROR_INVALIDDATA; - i = cpe->ch[1].ics.use_kb_window[0]; - cpe->ch[1].ics = cpe->ch[0].ics; - cpe->ch[1].ics.use_kb_window[1] = i; - if (cpe->ch[1].ics.predictor_present && - (ac->oc[1].m4ac.object_type != AOT_AAC_MAIN)) - if ((cpe->ch[1].ics.ltp.present = get_bits(gb, 1))) - decode_ltp(&cpe->ch[1].ics.ltp, gb, cpe->ch[1].ics.max_sfb); - ms_present = get_bits(gb, 2); - if (ms_present == 3) { - av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n"); - return AVERROR_INVALIDDATA; - } else if (ms_present) - decode_mid_side_stereo(cpe, gb, ms_present); - } - if ((ret = decode_ics(ac, &cpe->ch[0], gb, common_window, 0))) - return ret; - if ((ret = decode_ics(ac, &cpe->ch[1], gb, common_window, 0))) - return ret; - - if (common_window) { - if (ms_present) - apply_mid_side_stereo(ac, cpe); - if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN) { - apply_prediction(ac, &cpe->ch[0]); - apply_prediction(ac, &cpe->ch[1]); - } - } - - apply_intensity_stereo(ac, cpe, ms_present); - return 0; -} - -static const float cce_scale[] = { - 1.09050773266525765921, //2^(1/8) - 1.18920711500272106672, //2^(1/4) - M_SQRT2, - 2, -}; - -/** - * Decode coupling_channel_element; reference: table 4.8. - * - * @return Returns error status. 0 - OK, !0 - error - */ -static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) -{ - int num_gain = 0; - int c, g, sfb, ret; - int sign; - float scale; - SingleChannelElement *sce = &che->ch[0]; - ChannelCoupling *coup = &che->coup; - - coup->coupling_point = 2 * get_bits1(gb); - coup->num_coupled = get_bits(gb, 3); - for (c = 0; c <= coup->num_coupled; c++) { - num_gain++; - coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE; - coup->id_select[c] = get_bits(gb, 4); - if (coup->type[c] == TYPE_CPE) { - coup->ch_select[c] = get_bits(gb, 2); - if (coup->ch_select[c] == 3) - num_gain++; - } else - coup->ch_select[c] = 2; - } - coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1); - - sign = get_bits(gb, 1); - scale = cce_scale[get_bits(gb, 2)]; - - if ((ret = decode_ics(ac, sce, gb, 0, 0))) - return ret; - - for (c = 0; c < num_gain; c++) { - int idx = 0; - int cge = 1; - int gain = 0; - float gain_cache = 1.0; - if (c) { - cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb); - gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0; - gain_cache = powf(scale, -gain); - } - if (coup->coupling_point == AFTER_IMDCT) { - coup->gain[c][0] = gain_cache; - } else { - for (g = 0; g < sce->ics.num_window_groups; g++) { - for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) { - if (sce->band_type[idx] != ZERO_BT) { - if (!cge) { - int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; - if (t) { - int s = 1; - t = gain += t; - if (sign) { - s -= 2 * (t & 0x1); - t >>= 1; - } - gain_cache = powf(scale, -t) * s; - } - } - coup->gain[c][idx] = gain_cache; - } - } - } - } - } - return 0; -} - -/** - * Parse whether channels are to be excluded from Dynamic Range Compression; reference: table 4.53. - * - * @return Returns number of bytes consumed. - */ -static int decode_drc_channel_exclusions(DynamicRangeControl *che_drc, - GetBitContext *gb) -{ - int i; - int num_excl_chan = 0; - - do { - for (i = 0; i < 7; i++) - che_drc->exclude_mask[num_excl_chan++] = get_bits1(gb); - } while (num_excl_chan < MAX_CHANNELS - 7 && get_bits1(gb)); - - return num_excl_chan / 7; -} - -/** - * Decode dynamic range information; reference: table 4.52. - * - * @return Returns number of bytes consumed. - */ -static int decode_dynamic_range(DynamicRangeControl *che_drc, - GetBitContext *gb) -{ - int n = 1; - int drc_num_bands = 1; - int i; - - /* pce_tag_present? */ - if (get_bits1(gb)) { - che_drc->pce_instance_tag = get_bits(gb, 4); - skip_bits(gb, 4); // tag_reserved_bits - n++; - } - - /* excluded_chns_present? */ - if (get_bits1(gb)) { - n += decode_drc_channel_exclusions(che_drc, gb); - } - - /* drc_bands_present? */ - if (get_bits1(gb)) { - che_drc->band_incr = get_bits(gb, 4); - che_drc->interpolation_scheme = get_bits(gb, 4); - n++; - drc_num_bands += che_drc->band_incr; - for (i = 0; i < drc_num_bands; i++) { - che_drc->band_top[i] = get_bits(gb, 8); - n++; - } - } - - /* prog_ref_level_present? */ - if (get_bits1(gb)) { - che_drc->prog_ref_level = get_bits(gb, 7); - skip_bits1(gb); // prog_ref_level_reserved_bits - n++; - } - - for (i = 0; i < drc_num_bands; i++) { - che_drc->dyn_rng_sgn[i] = get_bits1(gb); - che_drc->dyn_rng_ctl[i] = get_bits(gb, 7); - n++; - } - - return n; -} - -static int decode_fill(AACContext *ac, GetBitContext *gb, int len) { - uint8_t buf[256]; - int i, major, minor; - - if (len < 13+7*8) - goto unknown; - - get_bits(gb, 13); len -= 13; - - for(i=0; i+1=8; i++, len-=8) - buf[i] = get_bits(gb, 8); - - buf[i] = 0; - if (ac->avctx->debug & FF_DEBUG_PICT_INFO) - av_log(ac->avctx, AV_LOG_DEBUG, "FILL:%s\n", buf); - - if (sscanf(buf, "libfaac %d.%d", &major, &minor) == 2){ - ac->avctx->internal->skip_samples = 1024; - } - -unknown: - skip_bits_long(gb, len); - - return 0; -} - -/** - * Decode extension data (incomplete); reference: table 4.51. - * - * @param cnt length of TYPE_FIL syntactic element in bytes - * - * @return Returns number of bytes consumed - */ -static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, - ChannelElement *che, enum RawDataBlockType elem_type) -{ - int crc_flag = 0; - int res = cnt; - int type = get_bits(gb, 4); - - if (ac->avctx->debug & FF_DEBUG_STARTCODE) - av_log(ac->avctx, AV_LOG_DEBUG, "extension type: %d len:%d\n", type, cnt); - - switch (type) { // extension type - case EXT_SBR_DATA_CRC: - crc_flag++; - case EXT_SBR_DATA: - if (!che) { - av_log(ac->avctx, AV_LOG_ERROR, "SBR was found before the first channel element.\n"); - return res; - } else if (!ac->oc[1].m4ac.sbr) { - av_log(ac->avctx, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n"); - skip_bits_long(gb, 8 * cnt - 4); - return res; - } else if (ac->oc[1].m4ac.sbr == -1 && ac->oc[1].status == OC_LOCKED) { - av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n"); - skip_bits_long(gb, 8 * cnt - 4); - return res; - } else if (ac->oc[1].m4ac.ps == -1 && ac->oc[1].status < OC_LOCKED && ac->avctx->channels == 1) { - ac->oc[1].m4ac.sbr = 1; - ac->oc[1].m4ac.ps = 1; - ac->avctx->profile = FF_PROFILE_AAC_HE_V2; - output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, - ac->oc[1].status, 1); - } else { - ac->oc[1].m4ac.sbr = 1; - ac->avctx->profile = FF_PROFILE_AAC_HE; - } - res = ff_decode_sbr_extension(ac, &che->sbr, gb, crc_flag, cnt, elem_type); - break; - case EXT_DYNAMIC_RANGE: - res = decode_dynamic_range(&ac->che_drc, gb); - break; - case EXT_FILL: - decode_fill(ac, gb, 8 * cnt - 4); - break; - case EXT_FILL_DATA: - case EXT_DATA_ELEMENT: - default: - skip_bits_long(gb, 8 * cnt - 4); - break; - }; - return res; -} - -/** - * Decode Temporal Noise Shaping filter coefficients and apply all-pole filters; reference: 4.6.9.3. - * - * @param decode 1 if tool is used normally, 0 if tool is used in LTP. - * @param coef spectral coefficients - */ -static void apply_tns(float coef[1024], TemporalNoiseShaping *tns, - IndividualChannelStream *ics, int decode) -{ - const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb); - int w, filt, m, i; - int bottom, top, order, start, end, size, inc; - float lpc[TNS_MAX_ORDER]; - float tmp[TNS_MAX_ORDER+1]; - - for (w = 0; w < ics->num_windows; w++) { - bottom = ics->num_swb; - for (filt = 0; filt < tns->n_filt[w]; filt++) { - top = bottom; - bottom = FFMAX(0, top - tns->length[w][filt]); - order = tns->order[w][filt]; - if (order == 0) - continue; - - // tns_decode_coef - compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0); - - start = ics->swb_offset[FFMIN(bottom, mmm)]; - end = ics->swb_offset[FFMIN( top, mmm)]; - if ((size = end - start) <= 0) - continue; - if (tns->direction[w][filt]) { - inc = -1; - start = end - 1; - } else { - inc = 1; - } - start += w * 128; + sign <<= nz & 1; nz >>= 1; + t.i = s.i ^ (sign & 1U<<31); + *dst++ = v[idx>>4 & 3] * t.f; - if (decode) { - // ar filter - for (m = 0; m < size; m++, start += inc) - for (i = 1; i <= FFMIN(m, order); i++) - coef[start] -= coef[start - i * inc] * lpc[i - 1]; - } else { - // ma filter - for (m = 0; m < size; m++, start += inc) { - tmp[0] = coef[start]; - for (i = 1; i <= FFMIN(m, order); i++) - coef[start] += tmp[i] * lpc[i - 1]; - for (i = order; i > 0; i--) - tmp[i] = tmp[i - 1]; - } - } - } - } + sign <<= nz & 1; + t.i = s.i ^ (sign & 1U<<31); + *dst++ = v[idx>>6 & 3] * t.f; + + return dst; } +#endif -/** - * Apply windowing and MDCT to obtain the spectral - * coefficient from the predicted sample by LTP. - */ -static void windowing_and_mdct_ltp(AACContext *ac, float *out, - float *in, IndividualChannelStream *ics) +static av_always_inline float flt16_round(float pf) { - const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; - const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; - const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; - const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; - - if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) { - ac->fdsp->vector_fmul(in, in, lwindow_prev, 1024); - } else { - memset(in, 0, 448 * sizeof(float)); - ac->fdsp->vector_fmul(in + 448, in + 448, swindow_prev, 128); - } - if (ics->window_sequence[0] != LONG_START_SEQUENCE) { - ac->fdsp->vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024); - } else { - ac->fdsp->vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); - memset(in + 1024 + 576, 0, 448 * sizeof(float)); - } - ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in); + union av_intfloat32 tmp; + tmp.f = pf; + tmp.i = (tmp.i + 0x00008000U) & 0xFFFF0000U; + return tmp.f; } -/** - * Apply the long term prediction - */ -static void apply_ltp(AACContext *ac, SingleChannelElement *sce) +static av_always_inline float flt16_even(float pf) { - const LongTermPrediction *ltp = &sce->ics.ltp; - const uint16_t *offsets = sce->ics.swb_offset; - int i, sfb; - - if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { - float *predTime = sce->ret; - float *predFreq = ac->buf_mdct; - int16_t num_samples = 2048; - - if (ltp->lag < 1024) - num_samples = ltp->lag + 1024; - for (i = 0; i < num_samples; i++) - predTime[i] = sce->ltp_state[i + 2048 - ltp->lag] * ltp->coef; - memset(&predTime[i], 0, (2048 - i) * sizeof(float)); - - ac->windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics); - - if (sce->tns.present) - ac->apply_tns(predFreq, &sce->tns, &sce->ics, 0); - - for (sfb = 0; sfb < FFMIN(sce->ics.max_sfb, MAX_LTP_LONG_SFB); sfb++) - if (ltp->used[sfb]) - for (i = offsets[sfb]; i < offsets[sfb + 1]; i++) - sce->coeffs[i] += predFreq[i]; - } + union av_intfloat32 tmp; + tmp.f = pf; + tmp.i = (tmp.i + 0x00007FFFU + (tmp.i & 0x00010000U >> 16)) & 0xFFFF0000U; + return tmp.f; } -/** - * Update the LTP buffer for next frame - */ -static void update_ltp(AACContext *ac, SingleChannelElement *sce) +static av_always_inline float flt16_trunc(float pf) { - IndividualChannelStream *ics = &sce->ics; - float *saved = sce->saved; - float *saved_ltp = sce->coeffs; - const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; - const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; - int i; - - if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - memcpy(saved_ltp, saved, 512 * sizeof(float)); - memset(saved_ltp + 576, 0, 448 * sizeof(float)); - ac->fdsp->vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); - for (i = 0; i < 64; i++) - saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i]; - } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { - memcpy(saved_ltp, ac->buf_mdct + 512, 448 * sizeof(float)); - memset(saved_ltp + 576, 0, 448 * sizeof(float)); - ac->fdsp->vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); - for (i = 0; i < 64; i++) - saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i]; - } else { // LONG_STOP or ONLY_LONG - ac->fdsp->vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, &lwindow[512], 512); - for (i = 0; i < 512; i++) - saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * lwindow[511 - i]; - } - - memcpy(sce->ltp_state, sce->ltp_state+1024, 1024 * sizeof(*sce->ltp_state)); - memcpy(sce->ltp_state+1024, sce->ret, 1024 * sizeof(*sce->ltp_state)); - memcpy(sce->ltp_state+2048, saved_ltp, 1024 * sizeof(*sce->ltp_state)); + union av_intfloat32 pun; + pun.f = pf; + pun.i &= 0xFFFF0000U; + return pun.f; } -/** - * Conduct IMDCT and windowing. - */ -static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce) +static av_always_inline void predict(PredictorState *ps, float *coef, + int output_enable) { - IndividualChannelStream *ics = &sce->ics; - float *in = sce->coeffs; - float *out = sce->ret; - float *saved = sce->saved; - const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; - const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; - const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; - float *buf = ac->buf_mdct; - float *temp = ac->temp; - int i; - - // imdct - if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - for (i = 0; i < 1024; i += 128) - ac->mdct_small.imdct_half(&ac->mdct_small, buf + i, in + i); - } else - ac->mdct.imdct_half(&ac->mdct, buf, in); - - /* window overlapping - * NOTE: To simplify the overlapping code, all 'meaningless' short to long - * and long to short transitions are considered to be short to short - * transitions. This leaves just two cases (long to long and short to short) - * with a little special sauce for EIGHT_SHORT_SEQUENCE. - */ - if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) && - (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) { - ac->fdsp->vector_fmul_window( out, saved, buf, lwindow_prev, 512); - } else { - memcpy( out, saved, 448 * sizeof(float)); - - if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - ac->fdsp->vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, 64); - ac->fdsp->vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, 64); - ac->fdsp->vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, 64); - ac->fdsp->vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, 64); - ac->fdsp->vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, 64); - memcpy( out + 448 + 4*128, temp, 64 * sizeof(float)); - } else { - ac->fdsp->vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 64); - memcpy( out + 576, buf + 64, 448 * sizeof(float)); - } - } + const float a = 0.953125; // 61.0 / 64 + const float alpha = 0.90625; // 29.0 / 32 + float e0, e1; + float pv; + float k1, k2; + float r0 = ps->r0, r1 = ps->r1; + float cor0 = ps->cor0, cor1 = ps->cor1; + float var0 = ps->var0, var1 = ps->var1; - // buffer update - if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - memcpy( saved, temp + 64, 64 * sizeof(float)); - ac->fdsp->vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 64); - ac->fdsp->vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 64); - ac->fdsp->vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 64); - memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float)); - } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { - memcpy( saved, buf + 512, 448 * sizeof(float)); - memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float)); - } else { // LONG_STOP or ONLY_LONG - memcpy( saved, buf + 512, 512 * sizeof(float)); - } -} + k1 = var0 > 1 ? cor0 * flt16_even(a / var0) : 0; + k2 = var1 > 1 ? cor1 * flt16_even(a / var1) : 0; -static void imdct_and_windowing_ld(AACContext *ac, SingleChannelElement *sce) -{ - IndividualChannelStream *ics = &sce->ics; - float *in = sce->coeffs; - float *out = sce->ret; - float *saved = sce->saved; - float *buf = ac->buf_mdct; - - // imdct - ac->mdct.imdct_half(&ac->mdct_ld, buf, in); - - // window overlapping - if (ics->use_kb_window[1]) { - // AAC LD uses a low overlap sine window instead of a KBD window - memcpy(out, saved, 192 * sizeof(float)); - ac->fdsp->vector_fmul_window(out + 192, saved + 192, buf, ff_sine_128, 64); - memcpy( out + 320, buf + 64, 192 * sizeof(float)); - } else { - ac->fdsp->vector_fmul_window(out, saved, buf, ff_sine_512, 256); - } + pv = flt16_round(k1 * r0 + k2 * r1); + if (output_enable) + *coef += pv; - // buffer update - memcpy(saved, buf + 256, 256 * sizeof(float)); -} + e0 = *coef; + e1 = e0 - k1 * r0; -static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce) -{ - float *in = sce->coeffs; - float *out = sce->ret; - float *saved = sce->saved; - float *buf = ac->buf_mdct; - int i; - const int n = ac->oc[1].m4ac.frame_length_short ? 480 : 512; - const int n2 = n >> 1; - const int n4 = n >> 2; - const float *const window = n == 480 ? ff_aac_eld_window_480 : - ff_aac_eld_window_512; - - // Inverse transform, mapped to the conventional IMDCT by - // Chivukula, R.K.; Reznik, Y.A.; Devarajan, V., - // "Efficient algorithms for MPEG-4 AAC-ELD, AAC-LD and AAC-LC filterbanks," - // International Conference on Audio, Language and Image Processing, ICALIP 2008. - // URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4590245&isnumber=4589950 - for (i = 0; i < n2; i+=2) { - float temp; - temp = in[i ]; in[i ] = -in[n - 1 - i]; in[n - 1 - i] = temp; - temp = -in[i + 1]; in[i + 1] = in[n - 2 - i]; in[n - 2 - i] = temp; - } - if (n == 480) - ac->mdct480->imdct_half(ac->mdct480, buf, in, 1, -1.f/(16*1024*960)); - else - ac->mdct.imdct_half(&ac->mdct_ld, buf, in); - for (i = 0; i < n; i+=2) { - buf[i] = -buf[i]; - } - // Like with the regular IMDCT at this point we still have the middle half - // of a transform but with even symmetry on the left and odd symmetry on - // the right - - // window overlapping - // The spec says to use samples [0..511] but the reference decoder uses - // samples [128..639]. - for (i = n4; i < n2; i ++) { - out[i - n4] = buf[n2 - 1 - i] * window[i - n4] + - saved[ i + n2] * window[i + n - n4] + - -saved[ n + n2 - 1 - i] * window[i + 2*n - n4] + - -saved[2*n + n2 + i] * window[i + 3*n - n4]; - } - for (i = 0; i < n2; i ++) { - out[n4 + i] = buf[i] * window[i + n2 - n4] + - -saved[ n - 1 - i] * window[i + n2 + n - n4] + - -saved[ n + i] * window[i + n2 + 2*n - n4] + - saved[2*n + n - 1 - i] * window[i + n2 + 3*n - n4]; - } - for (i = 0; i < n4; i ++) { - out[n2 + n4 + i] = buf[ i + n2] * window[i + n - n4] + - -saved[ n2 - 1 - i] * window[i + 2*n - n4] + - -saved[ n + n2 + i] * window[i + 3*n - n4]; - } + ps->cor1 = flt16_trunc(alpha * cor1 + r1 * e1); + ps->var1 = flt16_trunc(alpha * var1 + 0.5f * (r1 * r1 + e1 * e1)); + ps->cor0 = flt16_trunc(alpha * cor0 + r0 * e0); + ps->var0 = flt16_trunc(alpha * var0 + 0.5f * (r0 * r0 + e0 * e0)); - // buffer update - memmove(saved + n, saved, 2 * n * sizeof(float)); - memcpy( saved, buf, n * sizeof(float)); + ps->r1 = flt16_trunc(a * (r0 - k1 * e0)); + ps->r0 = flt16_trunc(a * e0); } /** @@ -2724,506 +256,7 @@ dest[i] += gain * src[i]; } -/** - * channel coupling transformation interface - * - * @param apply_coupling_method pointer to (in)dependent coupling function - */ -static void apply_channel_coupling(AACContext *ac, ChannelElement *cc, - enum RawDataBlockType type, int elem_id, - enum CouplingPoint coupling_point, - void (*apply_coupling_method)(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)) -{ - int i, c; - - for (i = 0; i < MAX_ELEM_ID; i++) { - ChannelElement *cce = ac->che[TYPE_CCE][i]; - int index = 0; - - if (cce && cce->coup.coupling_point == coupling_point) { - ChannelCoupling *coup = &cce->coup; - - for (c = 0; c <= coup->num_coupled; c++) { - if (coup->type[c] == type && coup->id_select[c] == elem_id) { - if (coup->ch_select[c] != 1) { - apply_coupling_method(ac, &cc->ch[0], cce, index); - if (coup->ch_select[c] != 0) - index++; - } - if (coup->ch_select[c] != 2) - apply_coupling_method(ac, &cc->ch[1], cce, index++); - } else - index += 1 + (coup->ch_select[c] == 3); - } - } - } -} - -/** - * Convert spectral data to float samples, applying all supported tools as appropriate. - */ -static void spectral_to_sample(AACContext *ac) -{ - int i, type; - void (*imdct_and_window)(AACContext *ac, SingleChannelElement *sce); - switch (ac->oc[1].m4ac.object_type) { - case AOT_ER_AAC_LD: - imdct_and_window = imdct_and_windowing_ld; - break; - case AOT_ER_AAC_ELD: - imdct_and_window = imdct_and_windowing_eld; - break; - default: - imdct_and_window = ac->imdct_and_windowing; - } - for (type = 3; type >= 0; type--) { - for (i = 0; i < MAX_ELEM_ID; i++) { - ChannelElement *che = ac->che[type][i]; - if (che && che->present) { - if (type <= TYPE_CPE) - apply_channel_coupling(ac, che, type, i, BEFORE_TNS, apply_dependent_coupling); - if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) { - if (che->ch[0].ics.predictor_present) { - if (che->ch[0].ics.ltp.present) - ac->apply_ltp(ac, &che->ch[0]); - if (che->ch[1].ics.ltp.present && type == TYPE_CPE) - ac->apply_ltp(ac, &che->ch[1]); - } - } - if (che->ch[0].tns.present) - ac->apply_tns(che->ch[0].coeffs, &che->ch[0].tns, &che->ch[0].ics, 1); - if (che->ch[1].tns.present) - ac->apply_tns(che->ch[1].coeffs, &che->ch[1].tns, &che->ch[1].ics, 1); - if (type <= TYPE_CPE) - apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling); - if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) { - imdct_and_window(ac, &che->ch[0]); - if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) - ac->update_ltp(ac, &che->ch[0]); - if (type == TYPE_CPE) { - imdct_and_window(ac, &che->ch[1]); - if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) - ac->update_ltp(ac, &che->ch[1]); - } - if (ac->oc[1].m4ac.sbr > 0) { - ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret); - } - } - if (type <= TYPE_CCE) - apply_channel_coupling(ac, che, type, i, AFTER_IMDCT, apply_independent_coupling); - che->present = 0; - } else if (che) { - av_log(ac->avctx, AV_LOG_VERBOSE, "ChannelElement %d.%d missing \n", type, i); - } - } - } -} - -static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) -{ - int size; - AACADTSHeaderInfo hdr_info; - uint8_t layout_map[MAX_ELEM_ID*4][3]; - int layout_map_tags, ret; - - size = avpriv_aac_parse_header(gb, &hdr_info); - if (size > 0) { - if (!ac->warned_num_aac_frames && hdr_info.num_aac_frames != 1) { - // This is 2 for "VLB " audio in NSV files. - // See samples/nsv/vlb_audio. - avpriv_report_missing_feature(ac->avctx, - "More than one AAC RDB per ADTS frame"); - ac->warned_num_aac_frames = 1; - } - push_output_configuration(ac); - if (hdr_info.chan_config) { - ac->oc[1].m4ac.chan_config = hdr_info.chan_config; - if ((ret = set_default_channel_config(ac->avctx, - layout_map, - &layout_map_tags, - hdr_info.chan_config)) < 0) - return ret; - if ((ret = output_configure(ac, layout_map, layout_map_tags, - FFMAX(ac->oc[1].status, - OC_TRIAL_FRAME), 0)) < 0) - return ret; - } else { - ac->oc[1].m4ac.chan_config = 0; - /** - * dual mono frames in Japanese DTV can have chan_config 0 - * WITHOUT specifying PCE. - * thus, set dual mono as default. - */ - if (ac->dmono_mode && ac->oc[0].status == OC_NONE) { - layout_map_tags = 2; - layout_map[0][0] = layout_map[1][0] = TYPE_SCE; - layout_map[0][2] = layout_map[1][2] = AAC_CHANNEL_FRONT; - layout_map[0][1] = 0; - layout_map[1][1] = 1; - if (output_configure(ac, layout_map, layout_map_tags, - OC_TRIAL_FRAME, 0)) - return -7; - } - } - ac->oc[1].m4ac.sample_rate = hdr_info.sample_rate; - ac->oc[1].m4ac.sampling_index = hdr_info.sampling_index; - ac->oc[1].m4ac.object_type = hdr_info.object_type; - ac->oc[1].m4ac.frame_length_short = 0; - if (ac->oc[0].status != OC_LOCKED || - ac->oc[0].m4ac.chan_config != hdr_info.chan_config || - ac->oc[0].m4ac.sample_rate != hdr_info.sample_rate) { - ac->oc[1].m4ac.sbr = -1; - ac->oc[1].m4ac.ps = -1; - } - if (!hdr_info.crc_absent) - skip_bits(gb, 16); - } - return size; -} - -static int aac_decode_er_frame(AVCodecContext *avctx, void *data, - int *got_frame_ptr, GetBitContext *gb) -{ - AACContext *ac = avctx->priv_data; - const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac; - ChannelElement *che; - int err, i; - int samples = m4ac->frame_length_short ? 960 : 1024; - int chan_config = m4ac->chan_config; - int aot = m4ac->object_type; - - if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) - samples >>= 1; - - ac->frame = data; - - if ((err = frame_configure_elements(avctx)) < 0) - return err; - - // The FF_PROFILE_AAC_* defines are all object_type - 1 - // This may lead to an undefined profile being signaled - ac->avctx->profile = aot - 1; - - ac->tags_mapped = 0; - - if (chan_config < 0 || (chan_config >= 8 && chan_config < 11) || chan_config >= 13) { - avpriv_request_sample(avctx, "Unknown ER channel configuration %d", - chan_config); - return AVERROR_INVALIDDATA; - } - for (i = 0; i < tags_per_config[chan_config]; i++) { - const int elem_type = aac_channel_layout_map[chan_config-1][i][0]; - const int elem_id = aac_channel_layout_map[chan_config-1][i][1]; - if (!(che=get_che(ac, elem_type, elem_id))) { - av_log(ac->avctx, AV_LOG_ERROR, - "channel element %d.%d is not allocated\n", - elem_type, elem_id); - return AVERROR_INVALIDDATA; - } - che->present = 1; - if (aot != AOT_ER_AAC_ELD) - skip_bits(gb, 4); - switch (elem_type) { - case TYPE_SCE: - err = decode_ics(ac, &che->ch[0], gb, 0, 0); - break; - case TYPE_CPE: - err = decode_cpe(ac, gb, che); - break; - case TYPE_LFE: - err = decode_ics(ac, &che->ch[0], gb, 0, 0); - break; - } - if (err < 0) - return err; - } - - spectral_to_sample(ac); - - ac->frame->nb_samples = samples; - ac->frame->sample_rate = avctx->sample_rate; - *got_frame_ptr = 1; - - skip_bits_long(gb, get_bits_left(gb)); - return 0; -} - -static int aac_decode_frame_int(AVCodecContext *avctx, void *data, - int *got_frame_ptr, GetBitContext *gb, AVPacket *avpkt) -{ - AACContext *ac = avctx->priv_data; - ChannelElement *che = NULL, *che_prev = NULL; - enum RawDataBlockType elem_type, elem_type_prev = TYPE_END; - int err, elem_id; - int samples = 0, multiplier, audio_found = 0, pce_found = 0; - int is_dmono, sce_count = 0; - - ac->frame = data; - - if (show_bits(gb, 12) == 0xfff) { - if ((err = parse_adts_frame_header(ac, gb)) < 0) { - av_log(avctx, AV_LOG_ERROR, "Error decoding AAC frame header.\n"); - goto fail; - } - if (ac->oc[1].m4ac.sampling_index > 12) { - av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->oc[1].m4ac.sampling_index); - err = AVERROR_INVALIDDATA; - goto fail; - } - } - - if ((err = frame_configure_elements(avctx)) < 0) - goto fail; - - // The FF_PROFILE_AAC_* defines are all object_type - 1 - // This may lead to an undefined profile being signaled - ac->avctx->profile = ac->oc[1].m4ac.object_type - 1; - - ac->tags_mapped = 0; - // parse - while ((elem_type = get_bits(gb, 3)) != TYPE_END) { - elem_id = get_bits(gb, 4); - - if (avctx->debug & FF_DEBUG_STARTCODE) - av_log(avctx, AV_LOG_DEBUG, "Elem type:%x id:%x\n", elem_type, elem_id); - - if (!avctx->channels && elem_type != TYPE_PCE) { - err = AVERROR_INVALIDDATA; - goto fail; - } - - if (elem_type < TYPE_DSE) { - if (!(che=get_che(ac, elem_type, elem_id))) { - av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", - elem_type, elem_id); - err = AVERROR_INVALIDDATA; - goto fail; - } - samples = 1024; - che->present = 1; - } - - switch (elem_type) { - - case TYPE_SCE: - err = decode_ics(ac, &che->ch[0], gb, 0, 0); - audio_found = 1; - sce_count++; - break; - - case TYPE_CPE: - err = decode_cpe(ac, gb, che); - audio_found = 1; - break; - - case TYPE_CCE: - err = decode_cce(ac, gb, che); - break; - - case TYPE_LFE: - err = decode_ics(ac, &che->ch[0], gb, 0, 0); - audio_found = 1; - break; - - case TYPE_DSE: - err = skip_data_stream_element(ac, gb); - break; - - case TYPE_PCE: { - uint8_t layout_map[MAX_ELEM_ID*4][3]; - int tags; - push_output_configuration(ac); - tags = decode_pce(avctx, &ac->oc[1].m4ac, layout_map, gb); - if (tags < 0) { - err = tags; - break; - } - if (pce_found) { - av_log(avctx, AV_LOG_ERROR, - "Not evaluating a further program_config_element as this construct is dubious at best.\n"); - } else { - err = output_configure(ac, layout_map, tags, OC_TRIAL_PCE, 1); - if (!err) - ac->oc[1].m4ac.chan_config = 0; - pce_found = 1; - } - break; - } - - case TYPE_FIL: - if (elem_id == 15) - elem_id += get_bits(gb, 8) - 1; - if (get_bits_left(gb) < 8 * elem_id) { - av_log(avctx, AV_LOG_ERROR, "TYPE_FIL: "overread_err); - err = AVERROR_INVALIDDATA; - goto fail; - } - while (elem_id > 0) - elem_id -= decode_extension_payload(ac, gb, elem_id, che_prev, elem_type_prev); - err = 0; /* FIXME */ - break; - - default: - err = AVERROR_BUG; /* should not happen, but keeps compiler happy */ - break; - } - - che_prev = che; - elem_type_prev = elem_type; - - if (err) - goto fail; - - if (get_bits_left(gb) < 3) { - av_log(avctx, AV_LOG_ERROR, overread_err); - err = AVERROR_INVALIDDATA; - goto fail; - } - } - - if (!avctx->channels) { - *got_frame_ptr = 0; - return 0; - } - - spectral_to_sample(ac); - - multiplier = (ac->oc[1].m4ac.sbr == 1) ? ac->oc[1].m4ac.ext_sample_rate > ac->oc[1].m4ac.sample_rate : 0; - samples <<= multiplier; - - if (ac->oc[1].status && audio_found) { - avctx->sample_rate = ac->oc[1].m4ac.sample_rate << multiplier; - avctx->frame_size = samples; - ac->oc[1].status = OC_LOCKED; - } - - if (multiplier) { - int side_size; - const uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size); - if (side && side_size>=4) - AV_WL32(side, 2*AV_RL32(side)); - } - - if (!ac->frame->data[0] && samples) { - av_log(avctx, AV_LOG_ERROR, "no frame data found\n"); - err = AVERROR_INVALIDDATA; - goto fail; - } - - if (samples) { - ac->frame->nb_samples = samples; - ac->frame->sample_rate = avctx->sample_rate; - } else - av_frame_unref(ac->frame); - *got_frame_ptr = !!samples; - - /* for dual-mono audio (SCE + SCE) */ - is_dmono = ac->dmono_mode && sce_count == 2 && - ac->oc[1].channel_layout == (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT); - if (is_dmono) { - if (ac->dmono_mode == 1) - ((AVFrame *)data)->data[1] =((AVFrame *)data)->data[0]; - else if (ac->dmono_mode == 2) - ((AVFrame *)data)->data[0] =((AVFrame *)data)->data[1]; - } - - return 0; -fail: - pop_output_configuration(ac); - return err; -} - -static int aac_decode_frame(AVCodecContext *avctx, void *data, - int *got_frame_ptr, AVPacket *avpkt) -{ - AACContext *ac = avctx->priv_data; - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; - GetBitContext gb; - int buf_consumed; - int buf_offset; - int err; - int new_extradata_size; - const uint8_t *new_extradata = av_packet_get_side_data(avpkt, - AV_PKT_DATA_NEW_EXTRADATA, - &new_extradata_size); - int jp_dualmono_size; - const uint8_t *jp_dualmono = av_packet_get_side_data(avpkt, - AV_PKT_DATA_JP_DUALMONO, - &jp_dualmono_size); - - if (new_extradata && 0) { - av_free(avctx->extradata); - avctx->extradata = av_mallocz(new_extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); - if (!avctx->extradata) - return AVERROR(ENOMEM); - avctx->extradata_size = new_extradata_size; - memcpy(avctx->extradata, new_extradata, new_extradata_size); - push_output_configuration(ac); - if (decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, - avctx->extradata, - avctx->extradata_size*8, 1) < 0) { - pop_output_configuration(ac); - return AVERROR_INVALIDDATA; - } - } - - ac->dmono_mode = 0; - if (jp_dualmono && jp_dualmono_size > 0) - ac->dmono_mode = 1 + *jp_dualmono; - if (ac->force_dmono_mode >= 0) - ac->dmono_mode = ac->force_dmono_mode; - - if (INT_MAX / 8 <= buf_size) - return AVERROR_INVALIDDATA; - - if ((err = init_get_bits(&gb, buf, buf_size * 8)) < 0) - return err; - - switch (ac->oc[1].m4ac.object_type) { - case AOT_ER_AAC_LC: - case AOT_ER_AAC_LTP: - case AOT_ER_AAC_LD: - case AOT_ER_AAC_ELD: - err = aac_decode_er_frame(avctx, data, got_frame_ptr, &gb); - break; - default: - err = aac_decode_frame_int(avctx, data, got_frame_ptr, &gb, avpkt); - } - if (err < 0) - return err; - - buf_consumed = (get_bits_count(&gb) + 7) >> 3; - for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++) - if (buf[buf_offset]) - break; - - return buf_size > buf_offset ? buf_consumed : buf_size; -} - -static av_cold int aac_decode_close(AVCodecContext *avctx) -{ - AACContext *ac = avctx->priv_data; - int i, type; - - for (i = 0; i < MAX_ELEM_ID; i++) { - for (type = 0; type < 4; type++) { - if (ac->che[type][i]) - ff_aac_sbr_ctx_close(&ac->che[type][i]->sbr); - av_freep(&ac->che[type][i]); - } - } - - ff_mdct_end(&ac->mdct); - ff_mdct_end(&ac->mdct_small); - ff_mdct_end(&ac->mdct_ld); - ff_mdct_end(&ac->mdct_ltp); - ff_imdct15_uninit(&ac->mdct480); - av_freep(&ac->fdsp); - return 0; -} - +#include "aacdec_template.c" #define LOAS_SYNC_WORD 0x2b7 ///< 11 bits LOAS sync word @@ -3289,14 +322,14 @@ if (avctx->extradata_size < esize) { av_free(avctx->extradata); - avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_malloc(esize + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) return AVERROR(ENOMEM); } avctx->extradata_size = esize; memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize); - memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(avctx->extradata+esize, 0, AV_INPUT_BUFFER_PADDING_SIZE); } skip_bits_long(gb, bits_consumed); @@ -3463,7 +496,7 @@ push_output_configuration(&latmctx->aac_ctx); if ((err = decode_audio_specific_config( &latmctx->aac_ctx, avctx, &latmctx->aac_ctx.oc[1].m4ac, - avctx->extradata, avctx->extradata_size*8, 1)) < 0) { + avctx->extradata, avctx->extradata_size*8LL, 1)) < 0) { pop_output_configuration(&latmctx->aac_ctx); return err; } @@ -3505,53 +538,6 @@ return ret; } -static void aacdec_init(AACContext *c) -{ - c->imdct_and_windowing = imdct_and_windowing; - c->apply_ltp = apply_ltp; - c->apply_tns = apply_tns; - c->windowing_and_mdct_ltp = windowing_and_mdct_ltp; - c->update_ltp = update_ltp; - - if(ARCH_MIPS) - ff_aacdec_init_mips(c); -} -/** - * AVOptions for Japanese DTV specific extensions (ADTS only) - */ -#define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM -static const AVOption options[] = { - {"dual_mono_mode", "Select the channel to decode for dual mono", - offsetof(AACContext, force_dmono_mode), AV_OPT_TYPE_INT, {.i64=-1}, -1, 2, - AACDEC_FLAGS, "dual_mono_mode"}, - - {"auto", "autoselection", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, - {"main", "Select Main/Left channel", 0, AV_OPT_TYPE_CONST, {.i64= 1}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, - {"sub" , "Select Sub/Right channel", 0, AV_OPT_TYPE_CONST, {.i64= 2}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, - {"both", "Select both channels", 0, AV_OPT_TYPE_CONST, {.i64= 0}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, - - {NULL}, -}; - -static const AVClass aac_decoder_class = { - .class_name = "AAC decoder", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; - -static const AVProfile profiles[] = { - { FF_PROFILE_AAC_MAIN, "Main" }, - { FF_PROFILE_AAC_LOW, "LC" }, - { FF_PROFILE_AAC_SSR, "SSR" }, - { FF_PROFILE_AAC_LTP, "LTP" }, - { FF_PROFILE_AAC_HE, "HE-AAC" }, - { FF_PROFILE_AAC_HE_V2, "HE-AACv2" }, - { FF_PROFILE_AAC_LD, "LD" }, - { FF_PROFILE_AAC_ELD, "ELD" }, - { FF_PROFILE_UNKNOWN }, -}; - AVCodec ff_aac_decoder = { .name = "aac", .long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"), @@ -3564,7 +550,7 @@ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, - .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, .channel_layouts = aac_channel_layout, .flush = flush, .priv_class = &aac_decoder_class, @@ -3588,7 +574,7 @@ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, - .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, .channel_layouts = aac_channel_layout, .flush = flush, .profiles = profiles, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacdec_fixed.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacdec_fixed.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacdec_fixed.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacdec_fixed.c 2015-07-28 17:20:07.000000000 +0000 @@ -0,0 +1,443 @@ +/* + * Copyright (c) 2013 + * MIPS Technologies, Inc., California. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * AAC decoder fixed-point implementation + * + * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org ) + * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com ) + * + * 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 + */ + +/** + * @file + * AAC decoder + * @author Oded Shimon ( ods15 ods15 dyndns org ) + * @author Maxim Gavrilov ( maxim.gavrilov gmail com ) + * + * Fixed point implementation + * @author Stanislav Ocovaj ( stanislav.ocovaj imgtec com ) + */ + +#define FFT_FLOAT 0 +#define FFT_FIXED_32 1 +#define USE_FIXED 1 + +#include "libavutil/fixed_dsp.h" +#include "libavutil/opt.h" +#include "avcodec.h" +#include "internal.h" +#include "get_bits.h" +#include "fft.h" +#include "lpc.h" +#include "kbdwin.h" +#include "sinewin.h" + +#include "aac.h" +#include "aactab.h" +#include "aacdectab.h" +#include "cbrt_tablegen.h" +#include "sbr.h" +#include "aacsbr.h" +#include "mpeg4audio.h" +#include "aacadtsdec.h" +#include "libavutil/intfloat.h" + +#include +#include + +static av_always_inline void reset_predict_state(PredictorState *ps) +{ + ps->r0.mant = 0; + ps->r0.exp = 0; + ps->r1.mant = 0; + ps->r1.exp = 0; + ps->cor0.mant = 0; + ps->cor0.exp = 0; + ps->cor1.mant = 0; + ps->cor1.exp = 0; + ps->var0.mant = 0x20000000; + ps->var0.exp = 1; + ps->var1.mant = 0x20000000; + ps->var1.exp = 1; +} + +int exp2tab[4] = { Q31(1.0000000000/2), Q31(1.1892071150/2), Q31(1.4142135624/2), Q31(1.6817928305/2) }; // 2^0, 2^0.25, 2^0.5, 2^0.75 + +static inline int *DEC_SPAIR(int *dst, unsigned idx) +{ + dst[0] = (idx & 15) - 4; + dst[1] = (idx >> 4 & 15) - 4; + + return dst + 2; +} + +static inline int *DEC_SQUAD(int *dst, unsigned idx) +{ + dst[0] = (idx & 3) - 1; + dst[1] = (idx >> 2 & 3) - 1; + dst[2] = (idx >> 4 & 3) - 1; + dst[3] = (idx >> 6 & 3) - 1; + + return dst + 4; +} + +static inline int *DEC_UPAIR(int *dst, unsigned idx, unsigned sign) +{ + dst[0] = (idx & 15) * (1 - (sign & 0xFFFFFFFE)); + dst[1] = (idx >> 4 & 15) * (1 - ((sign & 1) << 1)); + + return dst + 2; +} + +static inline int *DEC_UQUAD(int *dst, unsigned idx, unsigned sign) +{ + unsigned nz = idx >> 12; + + dst[0] = (idx & 3) * (1 + (((int)sign >> 31) << 1)); + sign <<= nz & 1; + nz >>= 1; + dst[1] = (idx >> 2 & 3) * (1 + (((int)sign >> 31) << 1)); + sign <<= nz & 1; + nz >>= 1; + dst[2] = (idx >> 4 & 3) * (1 + (((int)sign >> 31) << 1)); + sign <<= nz & 1; + nz >>= 1; + dst[3] = (idx >> 6 & 3) * (1 + (((int)sign >> 31) << 1)); + + return dst + 4; +} + +static void vector_pow43(int *coefs, int len) +{ + int i, coef; + + for (i=0; i> 2); + + if (s > 0) { + round = 1 << (s-1); + for (i=0; i> 32); + dst[i] = ((int)(out+round) >> s) * ssign; + } + } + else { + s = s + 32; + round = 1 << (s-1); + for (i=0; i> s); + dst[i] = out * ssign; + } + } +} + +static void noise_scale(int *coefs, int scale, int band_energy, int len) +{ + int ssign = scale < 0 ? -1 : 1; + int s = FFABS(scale); + unsigned int round; + int i, out, c = exp2tab[s & 3]; + int nlz = 0; + + while (band_energy > 0x7fff) { + band_energy >>= 1; + nlz++; + } + c /= band_energy; + s = 21 + nlz - (s >> 2); + + if (s > 0) { + round = 1 << (s-1); + for (i=0; i> 32); + coefs[i] = ((int)(out+round) >> s) * ssign; + } + } + else { + s = s + 32; + round = 1 << (s-1); + for (i=0; i> s); + coefs[i] = out * ssign; + } + } +} + +static av_always_inline SoftFloat flt16_round(SoftFloat pf) +{ + SoftFloat tmp; + int s; + + tmp.exp = pf.exp; + s = pf.mant >> 31; + tmp.mant = (pf.mant ^ s) - s; + tmp.mant = (tmp.mant + 0x00200000U) & 0xFFC00000U; + tmp.mant = (tmp.mant ^ s) - s; + + return tmp; +} + +static av_always_inline SoftFloat flt16_even(SoftFloat pf) +{ + SoftFloat tmp; + int s; + + tmp.exp = pf.exp; + s = pf.mant >> 31; + tmp.mant = (pf.mant ^ s) - s; + tmp.mant = (tmp.mant + 0x001FFFFFU + (tmp.mant & 0x00400000U >> 16)) & 0xFFC00000U; + tmp.mant = (tmp.mant ^ s) - s; + + return tmp; +} + +static av_always_inline SoftFloat flt16_trunc(SoftFloat pf) +{ + SoftFloat pun; + int s; + + pun.exp = pf.exp; + s = pf.mant >> 31; + pun.mant = (pf.mant ^ s) - s; + pun.mant = pun.mant & 0xFFC00000U; + pun.mant = (pun.mant ^ s) - s; + + return pun; +} + +static av_always_inline void predict(PredictorState *ps, int *coef, + int output_enable) +{ + const SoftFloat a = { 1023410176, 0 }; // 61.0 / 64 + const SoftFloat alpha = { 973078528, 0 }; // 29.0 / 32 + SoftFloat e0, e1; + SoftFloat pv; + SoftFloat k1, k2; + SoftFloat r0 = ps->r0, r1 = ps->r1; + SoftFloat cor0 = ps->cor0, cor1 = ps->cor1; + SoftFloat var0 = ps->var0, var1 = ps->var1; + SoftFloat tmp; + + if (var0.exp > 1 || (var0.exp == 1 && var0.mant > 0x20000000)) { + k1 = av_mul_sf(cor0, flt16_even(av_div_sf(a, var0))); + } + else { + k1.mant = 0; + k1.exp = 0; + } + + if (var1.exp > 1 || (var1.exp == 1 && var1.mant > 0x20000000)) { + k2 = av_mul_sf(cor1, flt16_even(av_div_sf(a, var1))); + } + else { + k2.mant = 0; + k2.exp = 0; + } + + tmp = av_mul_sf(k1, r0); + pv = flt16_round(av_add_sf(tmp, av_mul_sf(k2, r1))); + if (output_enable) { + int shift = 28 - pv.exp; + + if (shift < 31) + *coef += (pv.mant + (1 << (shift - 1))) >> shift; + } + + e0 = av_int2sf(*coef, 2); + e1 = av_sub_sf(e0, tmp); + + ps->cor1 = flt16_trunc(av_add_sf(av_mul_sf(alpha, cor1), av_mul_sf(r1, e1))); + tmp = av_add_sf(av_mul_sf(r1, r1), av_mul_sf(e1, e1)); + tmp.exp--; + ps->var1 = flt16_trunc(av_add_sf(av_mul_sf(alpha, var1), tmp)); + ps->cor0 = flt16_trunc(av_add_sf(av_mul_sf(alpha, cor0), av_mul_sf(r0, e0))); + tmp = av_add_sf(av_mul_sf(r0, r0), av_mul_sf(e0, e0)); + tmp.exp--; + ps->var0 = flt16_trunc(av_add_sf(av_mul_sf(alpha, var0), tmp)); + + ps->r1 = flt16_trunc(av_mul_sf(a, av_sub_sf(r0, av_mul_sf(k1, e0)))); + ps->r0 = flt16_trunc(av_mul_sf(a, e0)); +} + + +static const int cce_scale_fixed[8] = { + Q30(1.0), //2^(0/8) + Q30(1.0905077327), //2^(1/8) + Q30(1.1892071150), //2^(2/8) + Q30(1.2968395547), //2^(3/8) + Q30(1.4142135624), //2^(4/8) + Q30(1.5422108254), //2^(5/8) + Q30(1.6817928305), //2^(6/8) + Q30(1.8340080864), //2^(7/8) +}; + +/** + * Apply dependent channel coupling (applied before IMDCT). + * + * @param index index into coupling gain array + */ +static void apply_dependent_coupling_fixed(AACContext *ac, + SingleChannelElement *target, + ChannelElement *cce, int index) +{ + IndividualChannelStream *ics = &cce->ch[0].ics; + const uint16_t *offsets = ics->swb_offset; + int *dest = target->coeffs; + const int *src = cce->ch[0].coeffs; + int g, i, group, k, idx = 0; + if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) { + av_log(ac->avctx, AV_LOG_ERROR, + "Dependent coupling is not supported together with LTP\n"); + return; + } + for (g = 0; g < ics->num_window_groups; g++) { + for (i = 0; i < ics->max_sfb; i++, idx++) { + if (cce->ch[0].band_type[idx] != ZERO_BT) { + const int gain = cce->coup.gain[index][idx]; + int shift, round, c, tmp; + + if (gain < 0) { + c = -cce_scale_fixed[-gain & 7]; + shift = (-gain-1024) >> 3; + } + else { + c = cce_scale_fixed[gain & 7]; + shift = (gain-1024) >> 3; + } + + if (shift < 0) { + shift = -shift; + round = 1 << (shift - 1); + + for (group = 0; group < ics->group_len[g]; group++) { + for (k = offsets[i]; k < offsets[i + 1]; k++) { + tmp = (int)(((int64_t)src[group * 128 + k] * c + \ + (int64_t)0x1000000000) >> 37); + dest[group * 128 + k] += (tmp + round) >> shift; + } + } + } + else { + for (group = 0; group < ics->group_len[g]; group++) { + for (k = offsets[i]; k < offsets[i + 1]; k++) { + tmp = (int)(((int64_t)src[group * 128 + k] * c + \ + (int64_t)0x1000000000) >> 37); + dest[group * 128 + k] += tmp << shift; + } + } + } + } + } + dest += ics->group_len[g] * 128; + src += ics->group_len[g] * 128; + } +} + +/** + * Apply independent channel coupling (applied after IMDCT). + * + * @param index index into coupling gain array + */ +static void apply_independent_coupling_fixed(AACContext *ac, + SingleChannelElement *target, + ChannelElement *cce, int index) +{ + int i, c, shift, round, tmp; + const int gain = cce->coup.gain[index][0]; + const int *src = cce->ch[0].ret; + int *dest = target->ret; + const int len = 1024 << (ac->oc[1].m4ac.sbr == 1); + + c = cce_scale_fixed[gain & 7]; + shift = (gain-1024) >> 3; + if (shift < 0) { + shift = -shift; + round = 1 << (shift - 1); + + for (i = 0; i < len; i++) { + tmp = (int)(((int64_t)src[i] * c + (int64_t)0x1000000000) >> 37); + dest[i] += (tmp + round) >> shift; + } + } + else { + for (i = 0; i < len; i++) { + tmp = (int)(((int64_t)src[i] * c + (int64_t)0x1000000000) >> 37); + dest[i] += tmp << shift; + } + } +} + +#include "aacdec_template.c" + +AVCodec ff_aac_fixed_decoder = { + .name = "aac_fixed", + .long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"), + .type = AVMEDIA_TYPE_AUDIO, + .id = AV_CODEC_ID_AAC, + .priv_data_size = sizeof(AACContext), + .init = aac_decode_init, + .close = aac_decode_close, + .decode = aac_decode_frame, + .sample_fmts = (const enum AVSampleFormat[]) { + AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_NONE + }, + .capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, + .channel_layouts = aac_channel_layout, + .flush = flush, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacdectab.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacdectab.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacdectab.h 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacdectab.h 2015-07-09 17:20:03.000000000 +0000 @@ -38,9 +38,9 @@ /* @name ltp_coef * Table of the LTP coefficients */ -static const float ltp_coef[8] = { - 0.570829, 0.696616, 0.813004, 0.911304, - 0.984900, 1.067894, 1.194601, 1.369533, +static const INTFLOAT ltp_coef[8] = { + Q30(0.570829f), Q30(0.696616f), Q30(0.813004f), Q30(0.911304f), + Q30(0.984900f), Q30(1.067894f), Q30(1.194601f), Q30(1.369533f), }; /* @name tns_tmp2_map @@ -49,28 +49,28 @@ * respectively. * @{ */ -static const float tns_tmp2_map_1_3[4] = { - 0.00000000, -0.43388373, 0.64278758, 0.34202015, +static const INTFLOAT tns_tmp2_map_1_3[4] = { + Q31(0.00000000f), Q31(-0.43388373f), Q31(0.64278758f), Q31(0.34202015f), }; -static const float tns_tmp2_map_0_3[8] = { - 0.00000000, -0.43388373, -0.78183150, -0.97492790, - 0.98480773, 0.86602539, 0.64278758, 0.34202015, +static const INTFLOAT tns_tmp2_map_0_3[8] = { + Q31(0.00000000f), Q31(-0.43388373f), Q31(-0.78183150f), Q31(-0.97492790f), + Q31(0.98480773f), Q31( 0.86602539f), Q31( 0.64278758f), Q31( 0.34202015f), }; -static const float tns_tmp2_map_1_4[8] = { - 0.00000000, -0.20791170, -0.40673664, -0.58778524, - 0.67369562, 0.52643216, 0.36124167, 0.18374951, +static const INTFLOAT tns_tmp2_map_1_4[8] = { + Q31(0.00000000f), Q31(-0.20791170f), Q31(-0.40673664f), Q31(-0.58778524f), + Q31(0.67369562f), Q31( 0.52643216f), Q31( 0.36124167f), Q31( 0.18374951f), }; -static const float tns_tmp2_map_0_4[16] = { - 0.00000000, -0.20791170, -0.40673664, -0.58778524, - -0.74314481, -0.86602539, -0.95105654, -0.99452192, - 0.99573416, 0.96182561, 0.89516330, 0.79801720, - 0.67369562, 0.52643216, 0.36124167, 0.18374951, +static const INTFLOAT tns_tmp2_map_0_4[16] = { + Q31( 0.00000000f), Q31(-0.20791170f), Q31(-0.40673664f), Q31(-0.58778524f), + Q31(-0.74314481f), Q31(-0.86602539f), Q31(-0.95105654f), Q31(-0.99452192f), + Q31( 0.99573416f), Q31( 0.96182561f), Q31( 0.89516330f), Q31( 0.79801720f), + Q31( 0.67369562f), Q31( 0.52643216f), Q31( 0.36124167f), Q31( 0.18374951f), }; -static const float * const tns_tmp2_map[4] = { +static const INTFLOAT * const tns_tmp2_map[4] = { tns_tmp2_map_0_3, tns_tmp2_map_0_4, tns_tmp2_map_1_3, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacdec_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacdec_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacdec_template.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacdec_template.c 2015-08-03 17:20:02.000000000 +0000 @@ -0,0 +1,3229 @@ +/* + * AAC decoder + * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org ) + * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com ) + * Copyright (c) 2008-2013 Alex Converse + * + * AAC LATM decoder + * Copyright (c) 2008-2010 Paul Kendall + * Copyright (c) 2010 Janne Grunau + * + * AAC decoder fixed-point implementation + * Copyright (c) 2013 + * MIPS Technologies, Inc., California. + * + * 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 + */ + +/** + * @file + * AAC decoder + * @author Oded Shimon ( ods15 ods15 dyndns org ) + * @author Maxim Gavrilov ( maxim.gavrilov gmail com ) + * + * AAC decoder fixed-point implementation + * @author Stanislav Ocovaj ( stanislav.ocovaj imgtec com ) + * @author Nedeljko Babic ( nedeljko.babic imgtec com ) + */ + +/* + * supported tools + * + * Support? Name + * N (code in SoC repo) gain control + * Y block switching + * Y window shapes - standard + * N window shapes - Low Delay + * Y filterbank - standard + * N (code in SoC repo) filterbank - Scalable Sample Rate + * Y Temporal Noise Shaping + * Y Long Term Prediction + * Y intensity stereo + * Y channel coupling + * Y frequency domain prediction + * Y Perceptual Noise Substitution + * Y Mid/Side stereo + * N Scalable Inverse AAC Quantization + * N Frequency Selective Switch + * N upsampling filter + * Y quantization & coding - AAC + * N quantization & coding - TwinVQ + * N quantization & coding - BSAC + * N AAC Error Resilience tools + * N Error Resilience payload syntax + * N Error Protection tool + * N CELP + * N Silence Compression + * N HVXC + * N HVXC 4kbits/s VR + * N Structured Audio tools + * N Structured Audio Sample Bank Format + * N MIDI + * N Harmonic and Individual Lines plus Noise + * N Text-To-Speech Interface + * Y Spectral Band Replication + * Y (not in this code) Layer-1 + * Y (not in this code) Layer-2 + * Y (not in this code) Layer-3 + * N SinuSoidal Coding (Transient, Sinusoid, Noise) + * Y Parametric Stereo + * N Direct Stream Transfer + * Y (not in fixed point code) Enhanced AAC Low Delay (ER AAC ELD) + * + * Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication. + * - HE AAC v2 comprises LC AAC with Spectral Band Replication and + Parametric Stereo. + */ + +static VLC vlc_scalefactors; +static VLC vlc_spectral[11]; + +static int output_configure(AACContext *ac, + uint8_t layout_map[MAX_ELEM_ID*4][3], int tags, + enum OCStatus oc_type, int get_new_frame); + +#define overread_err "Input buffer exhausted before END element found\n" + +static int count_channels(uint8_t (*layout)[3], int tags) +{ + int i, sum = 0; + for (i = 0; i < tags; i++) { + int syn_ele = layout[i][0]; + int pos = layout[i][2]; + sum += (1 + (syn_ele == TYPE_CPE)) * + (pos != AAC_CHANNEL_OFF && pos != AAC_CHANNEL_CC); + } + return sum; +} + +/** + * Check for the channel element in the current channel position configuration. + * If it exists, make sure the appropriate element is allocated and map the + * channel order to match the internal FFmpeg channel layout. + * + * @param che_pos current channel position configuration + * @param type channel element type + * @param id channel element id + * @param channels count of the number of channels in the configuration + * + * @return Returns error status. 0 - OK, !0 - error + */ +static av_cold int che_configure(AACContext *ac, + enum ChannelPosition che_pos, + int type, int id, int *channels) +{ + if (*channels >= MAX_CHANNELS) + return AVERROR_INVALIDDATA; + if (che_pos) { + if (!ac->che[type][id]) { + if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement)))) + return AVERROR(ENOMEM); + AAC_RENAME(ff_aac_sbr_ctx_init)(ac, &ac->che[type][id]->sbr); + } + if (type != TYPE_CCE) { + if (*channels >= MAX_CHANNELS - (type == TYPE_CPE || (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1))) { + av_log(ac->avctx, AV_LOG_ERROR, "Too many channels\n"); + return AVERROR_INVALIDDATA; + } + ac->output_element[(*channels)++] = &ac->che[type][id]->ch[0]; + if (type == TYPE_CPE || + (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1)) { + ac->output_element[(*channels)++] = &ac->che[type][id]->ch[1]; + } + } + } else { + if (ac->che[type][id]) + AAC_RENAME(ff_aac_sbr_ctx_close)(&ac->che[type][id]->sbr); + av_freep(&ac->che[type][id]); + } + return 0; +} + +static int frame_configure_elements(AVCodecContext *avctx) +{ + AACContext *ac = avctx->priv_data; + int type, id, ch, ret; + + /* set channel pointers to internal buffers by default */ + for (type = 0; type < 4; type++) { + for (id = 0; id < MAX_ELEM_ID; id++) { + ChannelElement *che = ac->che[type][id]; + if (che) { + che->ch[0].ret = che->ch[0].ret_buf; + che->ch[1].ret = che->ch[1].ret_buf; + } + } + } + + /* get output buffer */ + av_frame_unref(ac->frame); + if (!avctx->channels) + return 1; + + ac->frame->nb_samples = 2048; + if ((ret = ff_get_buffer(avctx, ac->frame, 0)) < 0) + return ret; + + /* map output channel pointers to AVFrame data */ + for (ch = 0; ch < avctx->channels; ch++) { + if (ac->output_element[ch]) + ac->output_element[ch]->ret = (INTFLOAT *)ac->frame->extended_data[ch]; + } + + return 0; +} + +struct elem_to_channel { + uint64_t av_position; + uint8_t syn_ele; + uint8_t elem_id; + uint8_t aac_position; +}; + +static int assign_pair(struct elem_to_channel e2c_vec[MAX_ELEM_ID], + uint8_t (*layout_map)[3], int offset, uint64_t left, + uint64_t right, int pos) +{ + if (layout_map[offset][0] == TYPE_CPE) { + e2c_vec[offset] = (struct elem_to_channel) { + .av_position = left | right, + .syn_ele = TYPE_CPE, + .elem_id = layout_map[offset][1], + .aac_position = pos + }; + return 1; + } else { + e2c_vec[offset] = (struct elem_to_channel) { + .av_position = left, + .syn_ele = TYPE_SCE, + .elem_id = layout_map[offset][1], + .aac_position = pos + }; + e2c_vec[offset + 1] = (struct elem_to_channel) { + .av_position = right, + .syn_ele = TYPE_SCE, + .elem_id = layout_map[offset + 1][1], + .aac_position = pos + }; + return 2; + } +} + +static int count_paired_channels(uint8_t (*layout_map)[3], int tags, int pos, + int *current) +{ + int num_pos_channels = 0; + int first_cpe = 0; + int sce_parity = 0; + int i; + for (i = *current; i < tags; i++) { + if (layout_map[i][2] != pos) + break; + if (layout_map[i][0] == TYPE_CPE) { + if (sce_parity) { + if (pos == AAC_CHANNEL_FRONT && !first_cpe) { + sce_parity = 0; + } else { + return -1; + } + } + num_pos_channels += 2; + first_cpe = 1; + } else { + num_pos_channels++; + sce_parity ^= 1; + } + } + if (sce_parity && + ((pos == AAC_CHANNEL_FRONT && first_cpe) || pos == AAC_CHANNEL_SIDE)) + return -1; + *current = i; + return num_pos_channels; +} + +static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags) +{ + int i, n, total_non_cc_elements; + struct elem_to_channel e2c_vec[4 * MAX_ELEM_ID] = { { 0 } }; + int num_front_channels, num_side_channels, num_back_channels; + uint64_t layout; + + if (FF_ARRAY_ELEMS(e2c_vec) < tags) + return 0; + + i = 0; + num_front_channels = + count_paired_channels(layout_map, tags, AAC_CHANNEL_FRONT, &i); + if (num_front_channels < 0) + return 0; + num_side_channels = + count_paired_channels(layout_map, tags, AAC_CHANNEL_SIDE, &i); + if (num_side_channels < 0) + return 0; + num_back_channels = + count_paired_channels(layout_map, tags, AAC_CHANNEL_BACK, &i); + if (num_back_channels < 0) + return 0; + + if (num_side_channels == 0 && num_back_channels >= 4) { + num_side_channels = 2; + num_back_channels -= 2; + } + + i = 0; + if (num_front_channels & 1) { + e2c_vec[i] = (struct elem_to_channel) { + .av_position = AV_CH_FRONT_CENTER, + .syn_ele = TYPE_SCE, + .elem_id = layout_map[i][1], + .aac_position = AAC_CHANNEL_FRONT + }; + i++; + num_front_channels--; + } + if (num_front_channels >= 4) { + i += assign_pair(e2c_vec, layout_map, i, + AV_CH_FRONT_LEFT_OF_CENTER, + AV_CH_FRONT_RIGHT_OF_CENTER, + AAC_CHANNEL_FRONT); + num_front_channels -= 2; + } + if (num_front_channels >= 2) { + i += assign_pair(e2c_vec, layout_map, i, + AV_CH_FRONT_LEFT, + AV_CH_FRONT_RIGHT, + AAC_CHANNEL_FRONT); + num_front_channels -= 2; + } + while (num_front_channels >= 2) { + i += assign_pair(e2c_vec, layout_map, i, + UINT64_MAX, + UINT64_MAX, + AAC_CHANNEL_FRONT); + num_front_channels -= 2; + } + + if (num_side_channels >= 2) { + i += assign_pair(e2c_vec, layout_map, i, + AV_CH_SIDE_LEFT, + AV_CH_SIDE_RIGHT, + AAC_CHANNEL_FRONT); + num_side_channels -= 2; + } + while (num_side_channels >= 2) { + i += assign_pair(e2c_vec, layout_map, i, + UINT64_MAX, + UINT64_MAX, + AAC_CHANNEL_SIDE); + num_side_channels -= 2; + } + + while (num_back_channels >= 4) { + i += assign_pair(e2c_vec, layout_map, i, + UINT64_MAX, + UINT64_MAX, + AAC_CHANNEL_BACK); + num_back_channels -= 2; + } + if (num_back_channels >= 2) { + i += assign_pair(e2c_vec, layout_map, i, + AV_CH_BACK_LEFT, + AV_CH_BACK_RIGHT, + AAC_CHANNEL_BACK); + num_back_channels -= 2; + } + if (num_back_channels) { + e2c_vec[i] = (struct elem_to_channel) { + .av_position = AV_CH_BACK_CENTER, + .syn_ele = TYPE_SCE, + .elem_id = layout_map[i][1], + .aac_position = AAC_CHANNEL_BACK + }; + i++; + num_back_channels--; + } + + if (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) { + e2c_vec[i] = (struct elem_to_channel) { + .av_position = AV_CH_LOW_FREQUENCY, + .syn_ele = TYPE_LFE, + .elem_id = layout_map[i][1], + .aac_position = AAC_CHANNEL_LFE + }; + i++; + } + while (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) { + e2c_vec[i] = (struct elem_to_channel) { + .av_position = UINT64_MAX, + .syn_ele = TYPE_LFE, + .elem_id = layout_map[i][1], + .aac_position = AAC_CHANNEL_LFE + }; + i++; + } + + // Must choose a stable sort + total_non_cc_elements = n = i; + do { + int next_n = 0; + for (i = 1; i < n; i++) + if (e2c_vec[i - 1].av_position > e2c_vec[i].av_position) { + FFSWAP(struct elem_to_channel, e2c_vec[i - 1], e2c_vec[i]); + next_n = i; + } + n = next_n; + } while (n > 0); + + layout = 0; + for (i = 0; i < total_non_cc_elements; i++) { + layout_map[i][0] = e2c_vec[i].syn_ele; + layout_map[i][1] = e2c_vec[i].elem_id; + layout_map[i][2] = e2c_vec[i].aac_position; + if (e2c_vec[i].av_position != UINT64_MAX) { + layout |= e2c_vec[i].av_position; + } + } + + return layout; +} + +/** + * Save current output configuration if and only if it has been locked. + */ +static void push_output_configuration(AACContext *ac) { + if (ac->oc[1].status == OC_LOCKED || ac->oc[0].status == OC_NONE) { + ac->oc[0] = ac->oc[1]; + } + ac->oc[1].status = OC_NONE; +} + +/** + * Restore the previous output configuration if and only if the current + * configuration is unlocked. + */ +static void pop_output_configuration(AACContext *ac) { + if (ac->oc[1].status != OC_LOCKED && ac->oc[0].status != OC_NONE) { + ac->oc[1] = ac->oc[0]; + ac->avctx->channels = ac->oc[1].channels; + ac->avctx->channel_layout = ac->oc[1].channel_layout; + output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, + ac->oc[1].status, 0); + } +} + +/** + * Configure output channel order based on the current program + * configuration element. + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int output_configure(AACContext *ac, + uint8_t layout_map[MAX_ELEM_ID * 4][3], int tags, + enum OCStatus oc_type, int get_new_frame) +{ + AVCodecContext *avctx = ac->avctx; + int i, channels = 0, ret; + uint64_t layout = 0; + uint8_t id_map[TYPE_END][MAX_ELEM_ID] = {{ 0 }}; + uint8_t type_counts[TYPE_END] = { 0 }; + + if (ac->oc[1].layout_map != layout_map) { + memcpy(ac->oc[1].layout_map, layout_map, tags * sizeof(layout_map[0])); + ac->oc[1].layout_map_tags = tags; + } + for (i = 0; i < tags; i++) { + int type = layout_map[i][0]; + int id = layout_map[i][1]; + id_map[type][id] = type_counts[type]++; + } + // Try to sniff a reasonable channel order, otherwise output the + // channels in the order the PCE declared them. + if (avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE) + layout = sniff_channel_order(layout_map, tags); + for (i = 0; i < tags; i++) { + int type = layout_map[i][0]; + int id = layout_map[i][1]; + int iid = id_map[type][id]; + int position = layout_map[i][2]; + // Allocate or free elements depending on if they are in the + // current program configuration. + ret = che_configure(ac, position, type, iid, &channels); + if (ret < 0) + return ret; + ac->tag_che_map[type][id] = ac->che[type][iid]; + } + if (ac->oc[1].m4ac.ps == 1 && channels == 2) { + if (layout == AV_CH_FRONT_CENTER) { + layout = AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT; + } else { + layout = 0; + } + } + + if (layout) avctx->channel_layout = layout; + ac->oc[1].channel_layout = layout; + avctx->channels = ac->oc[1].channels = channels; + ac->oc[1].status = oc_type; + + if (get_new_frame) { + if ((ret = frame_configure_elements(ac->avctx)) < 0) + return ret; + } + + return 0; +} + +static void flush(AVCodecContext *avctx) +{ + AACContext *ac= avctx->priv_data; + int type, i, j; + + for (type = 3; type >= 0; type--) { + for (i = 0; i < MAX_ELEM_ID; i++) { + ChannelElement *che = ac->che[type][i]; + if (che) { + for (j = 0; j <= 1; j++) { + memset(che->ch[j].saved, 0, sizeof(che->ch[j].saved)); + } + } + } + } +} + +/** + * Set up channel positions based on a default channel configuration + * as specified in table 1.17. + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int set_default_channel_config(AVCodecContext *avctx, + uint8_t (*layout_map)[3], + int *tags, + int channel_config) +{ + if (channel_config < 1 || (channel_config > 7 && channel_config < 11) || + channel_config > 12) { + av_log(avctx, AV_LOG_ERROR, + "invalid default channel configuration (%d)\n", + channel_config); + return AVERROR_INVALIDDATA; + } + *tags = tags_per_config[channel_config]; + memcpy(layout_map, aac_channel_layout_map[channel_config - 1], + *tags * sizeof(*layout_map)); + + /* + * AAC specification has 7.1(wide) as a default layout for 8-channel streams. + * However, at least Nero AAC encoder encodes 7.1 streams using the default + * channel config 7, mapping the side channels of the original audio stream + * to the second AAC_CHANNEL_FRONT pair in the AAC stream. Similarly, e.g. FAAD + * decodes the second AAC_CHANNEL_FRONT pair as side channels, therefore decoding + * the incorrect streams as if they were correct (and as the encoder intended). + * + * As actual intended 7.1(wide) streams are very rare, default to assuming a + * 7.1 layout was intended. + */ + if (channel_config == 7 && avctx->strict_std_compliance < FF_COMPLIANCE_STRICT) { + av_log(avctx, AV_LOG_INFO, "Assuming an incorrectly encoded 7.1 channel layout" + " instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode" + " according to the specification instead.\n", FF_COMPLIANCE_STRICT); + layout_map[2][2] = AAC_CHANNEL_SIDE; + } + + return 0; +} + +static ChannelElement *get_che(AACContext *ac, int type, int elem_id) +{ + /* For PCE based channel configurations map the channels solely based + * on tags. */ + if (!ac->oc[1].m4ac.chan_config) { + return ac->tag_che_map[type][elem_id]; + } + // Allow single CPE stereo files to be signalled with mono configuration. + if (!ac->tags_mapped && type == TYPE_CPE && + ac->oc[1].m4ac.chan_config == 1) { + uint8_t layout_map[MAX_ELEM_ID*4][3]; + int layout_map_tags; + push_output_configuration(ac); + + av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n"); + + if (set_default_channel_config(ac->avctx, layout_map, + &layout_map_tags, 2) < 0) + return NULL; + if (output_configure(ac, layout_map, layout_map_tags, + OC_TRIAL_FRAME, 1) < 0) + return NULL; + + ac->oc[1].m4ac.chan_config = 2; + ac->oc[1].m4ac.ps = 0; + } + // And vice-versa + if (!ac->tags_mapped && type == TYPE_SCE && + ac->oc[1].m4ac.chan_config == 2) { + uint8_t layout_map[MAX_ELEM_ID * 4][3]; + int layout_map_tags; + push_output_configuration(ac); + + av_log(ac->avctx, AV_LOG_DEBUG, "stereo with SCE\n"); + + if (set_default_channel_config(ac->avctx, layout_map, + &layout_map_tags, 1) < 0) + return NULL; + if (output_configure(ac, layout_map, layout_map_tags, + OC_TRIAL_FRAME, 1) < 0) + return NULL; + + ac->oc[1].m4ac.chan_config = 1; + if (ac->oc[1].m4ac.sbr) + ac->oc[1].m4ac.ps = -1; + } + /* For indexed channel configurations map the channels solely based + * on position. */ + switch (ac->oc[1].m4ac.chan_config) { + case 12: + case 7: + if (ac->tags_mapped == 3 && type == TYPE_CPE) { + ac->tags_mapped++; + return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2]; + } + case 11: + if (ac->tags_mapped == 2 && + ac->oc[1].m4ac.chan_config == 11 && + type == TYPE_SCE) { + ac->tags_mapped++; + return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1]; + } + case 6: + /* Some streams incorrectly code 5.1 audio as + * SCE[0] CPE[0] CPE[1] SCE[1] + * instead of + * SCE[0] CPE[0] CPE[1] LFE[0]. + * If we seem to have encountered such a stream, transfer + * the LFE[0] element to the SCE[1]'s mapping */ + if (ac->tags_mapped == tags_per_config[ac->oc[1].m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) { + if (!ac->warned_remapping_once && (type != TYPE_LFE || elem_id != 0)) { + av_log(ac->avctx, AV_LOG_WARNING, + "This stream seems to incorrectly report its last channel as %s[%d], mapping to LFE[0]\n", + type == TYPE_SCE ? "SCE" : "LFE", elem_id); + ac->warned_remapping_once++; + } + ac->tags_mapped++; + return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0]; + } + case 5: + if (ac->tags_mapped == 2 && type == TYPE_CPE) { + ac->tags_mapped++; + return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1]; + } + case 4: + /* Some streams incorrectly code 4.0 audio as + * SCE[0] CPE[0] LFE[0] + * instead of + * SCE[0] CPE[0] SCE[1]. + * If we seem to have encountered such a stream, transfer + * the SCE[1] element to the LFE[0]'s mapping */ + if (ac->tags_mapped == tags_per_config[ac->oc[1].m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) { + if (!ac->warned_remapping_once && (type != TYPE_SCE || elem_id != 1)) { + av_log(ac->avctx, AV_LOG_WARNING, + "This stream seems to incorrectly report its last channel as %s[%d], mapping to SCE[1]\n", + type == TYPE_SCE ? "SCE" : "LFE", elem_id); + ac->warned_remapping_once++; + } + ac->tags_mapped++; + return ac->tag_che_map[type][elem_id] = ac->che[TYPE_SCE][1]; + } + if (ac->tags_mapped == 2 && + ac->oc[1].m4ac.chan_config == 4 && + type == TYPE_SCE) { + ac->tags_mapped++; + return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1]; + } + case 3: + case 2: + if (ac->tags_mapped == (ac->oc[1].m4ac.chan_config != 2) && + type == TYPE_CPE) { + ac->tags_mapped++; + return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0]; + } else if (ac->oc[1].m4ac.chan_config == 2) { + return NULL; + } + case 1: + if (!ac->tags_mapped && type == TYPE_SCE) { + ac->tags_mapped++; + return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][0]; + } + default: + return NULL; + } +} + +/** + * Decode an array of 4 bit element IDs, optionally interleaved with a + * stereo/mono switching bit. + * + * @param type speaker type/position for these channels + */ +static void decode_channel_map(uint8_t layout_map[][3], + enum ChannelPosition type, + GetBitContext *gb, int n) +{ + while (n--) { + enum RawDataBlockType syn_ele; + switch (type) { + case AAC_CHANNEL_FRONT: + case AAC_CHANNEL_BACK: + case AAC_CHANNEL_SIDE: + syn_ele = get_bits1(gb); + break; + case AAC_CHANNEL_CC: + skip_bits1(gb); + syn_ele = TYPE_CCE; + break; + case AAC_CHANNEL_LFE: + syn_ele = TYPE_LFE; + break; + default: + // AAC_CHANNEL_OFF has no channel map + av_assert0(0); + } + layout_map[0][0] = syn_ele; + layout_map[0][1] = get_bits(gb, 4); + layout_map[0][2] = type; + layout_map++; + } +} + +/** + * Decode program configuration element; reference: table 4.2. + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac, + uint8_t (*layout_map)[3], + GetBitContext *gb) +{ + int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc; + int sampling_index; + int comment_len; + int tags; + + skip_bits(gb, 2); // object_type + + sampling_index = get_bits(gb, 4); + if (m4ac->sampling_index != sampling_index) + av_log(avctx, AV_LOG_WARNING, + "Sample rate index in program config element does not " + "match the sample rate index configured by the container.\n"); + + num_front = get_bits(gb, 4); + num_side = get_bits(gb, 4); + num_back = get_bits(gb, 4); + num_lfe = get_bits(gb, 2); + num_assoc_data = get_bits(gb, 3); + num_cc = get_bits(gb, 4); + + if (get_bits1(gb)) + skip_bits(gb, 4); // mono_mixdown_tag + if (get_bits1(gb)) + skip_bits(gb, 4); // stereo_mixdown_tag + + if (get_bits1(gb)) + skip_bits(gb, 3); // mixdown_coeff_index and pseudo_surround + + if (get_bits_left(gb) < 4 * (num_front + num_side + num_back + num_lfe + num_assoc_data + num_cc)) { + av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err); + return -1; + } + decode_channel_map(layout_map , AAC_CHANNEL_FRONT, gb, num_front); + tags = num_front; + decode_channel_map(layout_map + tags, AAC_CHANNEL_SIDE, gb, num_side); + tags += num_side; + decode_channel_map(layout_map + tags, AAC_CHANNEL_BACK, gb, num_back); + tags += num_back; + decode_channel_map(layout_map + tags, AAC_CHANNEL_LFE, gb, num_lfe); + tags += num_lfe; + + skip_bits_long(gb, 4 * num_assoc_data); + + decode_channel_map(layout_map + tags, AAC_CHANNEL_CC, gb, num_cc); + tags += num_cc; + + align_get_bits(gb); + + /* comment field, first byte is length */ + comment_len = get_bits(gb, 8) * 8; + if (get_bits_left(gb) < comment_len) { + av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err); + return AVERROR_INVALIDDATA; + } + skip_bits_long(gb, comment_len); + return tags; +} + +/** + * Decode GA "General Audio" specific configuration; reference: table 4.1. + * + * @param ac pointer to AACContext, may be null + * @param avctx pointer to AVCCodecContext, used for logging + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx, + GetBitContext *gb, + MPEG4AudioConfig *m4ac, + int channel_config) +{ + int extension_flag, ret, ep_config, res_flags; + uint8_t layout_map[MAX_ELEM_ID*4][3]; + int tags = 0; + + if (get_bits1(gb)) { // frameLengthFlag + avpriv_request_sample(avctx, "960/120 MDCT window"); + return AVERROR_PATCHWELCOME; + } + m4ac->frame_length_short = 0; + + if (get_bits1(gb)) // dependsOnCoreCoder + skip_bits(gb, 14); // coreCoderDelay + extension_flag = get_bits1(gb); + + if (m4ac->object_type == AOT_AAC_SCALABLE || + m4ac->object_type == AOT_ER_AAC_SCALABLE) + skip_bits(gb, 3); // layerNr + + if (channel_config == 0) { + skip_bits(gb, 4); // element_instance_tag + tags = decode_pce(avctx, m4ac, layout_map, gb); + if (tags < 0) + return tags; + } else { + if ((ret = set_default_channel_config(avctx, layout_map, + &tags, channel_config))) + return ret; + } + + if (count_channels(layout_map, tags) > 1) { + m4ac->ps = 0; + } else if (m4ac->sbr == 1 && m4ac->ps == -1) + m4ac->ps = 1; + + if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) + return ret; + + if (extension_flag) { + switch (m4ac->object_type) { + case AOT_ER_BSAC: + skip_bits(gb, 5); // numOfSubFrame + skip_bits(gb, 11); // layer_length + break; + case AOT_ER_AAC_LC: + case AOT_ER_AAC_LTP: + case AOT_ER_AAC_SCALABLE: + case AOT_ER_AAC_LD: + res_flags = get_bits(gb, 3); + if (res_flags) { + avpriv_report_missing_feature(avctx, + "AAC data resilience (flags %x)", + res_flags); + return AVERROR_PATCHWELCOME; + } + break; + } + skip_bits1(gb); // extensionFlag3 (TBD in version 3) + } + switch (m4ac->object_type) { + case AOT_ER_AAC_LC: + case AOT_ER_AAC_LTP: + case AOT_ER_AAC_SCALABLE: + case AOT_ER_AAC_LD: + ep_config = get_bits(gb, 2); + if (ep_config) { + avpriv_report_missing_feature(avctx, + "epConfig %d", ep_config); + return AVERROR_PATCHWELCOME; + } + } + return 0; +} + +static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx, + GetBitContext *gb, + MPEG4AudioConfig *m4ac, + int channel_config) +{ + int ret, ep_config, res_flags; + uint8_t layout_map[MAX_ELEM_ID*4][3]; + int tags = 0; + const int ELDEXT_TERM = 0; + + m4ac->ps = 0; + m4ac->sbr = 0; +#if USE_FIXED + if (get_bits1(gb)) { // frameLengthFlag + avpriv_request_sample(avctx, "960/120 MDCT window"); + return AVERROR_PATCHWELCOME; + } +#else + m4ac->frame_length_short = get_bits1(gb); +#endif + res_flags = get_bits(gb, 3); + if (res_flags) { + avpriv_report_missing_feature(avctx, + "AAC data resilience (flags %x)", + res_flags); + return AVERROR_PATCHWELCOME; + } + + if (get_bits1(gb)) { // ldSbrPresentFlag + avpriv_report_missing_feature(avctx, + "Low Delay SBR"); + return AVERROR_PATCHWELCOME; + } + + while (get_bits(gb, 4) != ELDEXT_TERM) { + int len = get_bits(gb, 4); + if (len == 15) + len += get_bits(gb, 8); + if (len == 15 + 255) + len += get_bits(gb, 16); + if (get_bits_left(gb) < len * 8 + 4) { + av_log(avctx, AV_LOG_ERROR, overread_err); + return AVERROR_INVALIDDATA; + } + skip_bits_long(gb, 8 * len); + } + + if ((ret = set_default_channel_config(avctx, layout_map, + &tags, channel_config))) + return ret; + + if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) + return ret; + + ep_config = get_bits(gb, 2); + if (ep_config) { + avpriv_report_missing_feature(avctx, + "epConfig %d", ep_config); + return AVERROR_PATCHWELCOME; + } + return 0; +} + +/** + * Decode audio specific configuration; reference: table 1.13. + * + * @param ac pointer to AACContext, may be null + * @param avctx pointer to AVCCodecContext, used for logging + * @param m4ac pointer to MPEG4AudioConfig, used for parsing + * @param data pointer to buffer holding an audio specific config + * @param bit_size size of audio specific config or data in bits + * @param sync_extension look for an appended sync extension + * + * @return Returns error status or number of consumed bits. <0 - error + */ +static int decode_audio_specific_config(AACContext *ac, + AVCodecContext *avctx, + MPEG4AudioConfig *m4ac, + const uint8_t *data, int64_t bit_size, + int sync_extension) +{ + GetBitContext gb; + int i, ret; + + if (bit_size < 0 || bit_size > INT_MAX) { + av_log(avctx, AV_LOG_ERROR, "Audio specific config size is invalid\n"); + return AVERROR_INVALIDDATA; + } + + ff_dlog(avctx, "audio specific config size %d\n", (int)bit_size >> 3); + for (i = 0; i < bit_size >> 3; i++) + ff_dlog(avctx, "%02x ", data[i]); + ff_dlog(avctx, "\n"); + + if ((ret = init_get_bits(&gb, data, bit_size)) < 0) + return ret; + + if ((i = avpriv_mpeg4audio_get_config(m4ac, data, bit_size, + sync_extension)) < 0) + return AVERROR_INVALIDDATA; + if (m4ac->sampling_index > 12) { + av_log(avctx, AV_LOG_ERROR, + "invalid sampling rate index %d\n", + m4ac->sampling_index); + return AVERROR_INVALIDDATA; + } + if (m4ac->object_type == AOT_ER_AAC_LD && + (m4ac->sampling_index < 3 || m4ac->sampling_index > 7)) { + av_log(avctx, AV_LOG_ERROR, + "invalid low delay sampling rate index %d\n", + m4ac->sampling_index); + return AVERROR_INVALIDDATA; + } + + skip_bits_long(&gb, i); + + switch (m4ac->object_type) { + case AOT_AAC_MAIN: + case AOT_AAC_LC: + case AOT_AAC_LTP: + case AOT_ER_AAC_LC: + case AOT_ER_AAC_LD: + if ((ret = decode_ga_specific_config(ac, avctx, &gb, + m4ac, m4ac->chan_config)) < 0) + return ret; + break; + case AOT_ER_AAC_ELD: + if ((ret = decode_eld_specific_config(ac, avctx, &gb, + m4ac, m4ac->chan_config)) < 0) + return ret; + break; + default: + avpriv_report_missing_feature(avctx, + "Audio object type %s%d", + m4ac->sbr == 1 ? "SBR+" : "", + m4ac->object_type); + return AVERROR(ENOSYS); + } + + ff_dlog(avctx, + "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n", + m4ac->object_type, m4ac->chan_config, m4ac->sampling_index, + m4ac->sample_rate, m4ac->sbr, + m4ac->ps); + + return get_bits_count(&gb); +} + +/** + * linear congruential pseudorandom number generator + * + * @param previous_val pointer to the current state of the generator + * + * @return Returns a 32-bit pseudorandom integer + */ +static av_always_inline int lcg_random(unsigned previous_val) +{ + union { unsigned u; int s; } v = { previous_val * 1664525u + 1013904223 }; + return v.s; +} + +static void reset_all_predictors(PredictorState *ps) +{ + int i; + for (i = 0; i < MAX_PREDICTORS; i++) + reset_predict_state(&ps[i]); +} + +static int sample_rate_idx (int rate) +{ + if (92017 <= rate) return 0; + else if (75132 <= rate) return 1; + else if (55426 <= rate) return 2; + else if (46009 <= rate) return 3; + else if (37566 <= rate) return 4; + else if (27713 <= rate) return 5; + else if (23004 <= rate) return 6; + else if (18783 <= rate) return 7; + else if (13856 <= rate) return 8; + else if (11502 <= rate) return 9; + else if (9391 <= rate) return 10; + else return 11; +} + +static void reset_predictor_group(PredictorState *ps, int group_num) +{ + int i; + for (i = group_num - 1; i < MAX_PREDICTORS; i += 30) + reset_predict_state(&ps[i]); +} + +#define AAC_INIT_VLC_STATIC(num, size) \ + INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \ + ff_aac_spectral_bits[num], sizeof(ff_aac_spectral_bits[num][0]), \ + sizeof(ff_aac_spectral_bits[num][0]), \ + ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), \ + sizeof(ff_aac_spectral_codes[num][0]), \ + size); + +static void aacdec_init(AACContext *ac); + +static av_cold int aac_decode_init(AVCodecContext *avctx) +{ + AACContext *ac = avctx->priv_data; + int ret; + + ac->avctx = avctx; + ac->oc[1].m4ac.sample_rate = avctx->sample_rate; + + aacdec_init(ac); +#if USE_FIXED + avctx->sample_fmt = AV_SAMPLE_FMT_S32P; +#else + avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; +#endif /* USE_FIXED */ + + if (avctx->extradata_size > 0) { + if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, + avctx->extradata, + avctx->extradata_size * 8LL, + 1)) < 0) + return ret; + } else { + int sr, i; + uint8_t layout_map[MAX_ELEM_ID*4][3]; + int layout_map_tags; + + sr = sample_rate_idx(avctx->sample_rate); + ac->oc[1].m4ac.sampling_index = sr; + ac->oc[1].m4ac.channels = avctx->channels; + ac->oc[1].m4ac.sbr = -1; + ac->oc[1].m4ac.ps = -1; + + for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++) + if (ff_mpeg4audio_channels[i] == avctx->channels) + break; + if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) { + i = 0; + } + ac->oc[1].m4ac.chan_config = i; + + if (ac->oc[1].m4ac.chan_config) { + int ret = set_default_channel_config(avctx, layout_map, + &layout_map_tags, ac->oc[1].m4ac.chan_config); + if (!ret) + output_configure(ac, layout_map, layout_map_tags, + OC_GLOBAL_HDR, 0); + else if (avctx->err_recognition & AV_EF_EXPLODE) + return AVERROR_INVALIDDATA; + } + } + + if (avctx->channels > MAX_CHANNELS) { + av_log(avctx, AV_LOG_ERROR, "Too many channels\n"); + return AVERROR_INVALIDDATA; + } + + AAC_INIT_VLC_STATIC( 0, 304); + AAC_INIT_VLC_STATIC( 1, 270); + AAC_INIT_VLC_STATIC( 2, 550); + AAC_INIT_VLC_STATIC( 3, 300); + AAC_INIT_VLC_STATIC( 4, 328); + AAC_INIT_VLC_STATIC( 5, 294); + AAC_INIT_VLC_STATIC( 6, 306); + AAC_INIT_VLC_STATIC( 7, 268); + AAC_INIT_VLC_STATIC( 8, 510); + AAC_INIT_VLC_STATIC( 9, 366); + AAC_INIT_VLC_STATIC(10, 462); + + AAC_RENAME(ff_aac_sbr_init)(); + +#if USE_FIXED + ac->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT); +#else + ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); +#endif /* USE_FIXED */ + if (!ac->fdsp) { + return AVERROR(ENOMEM); + } + + ac->random_state = 0x1f2e3d4c; + + ff_aac_tableinit(); + + INIT_VLC_STATIC(&vlc_scalefactors, 7, + FF_ARRAY_ELEMS(ff_aac_scalefactor_code), + ff_aac_scalefactor_bits, + sizeof(ff_aac_scalefactor_bits[0]), + sizeof(ff_aac_scalefactor_bits[0]), + ff_aac_scalefactor_code, + sizeof(ff_aac_scalefactor_code[0]), + sizeof(ff_aac_scalefactor_code[0]), + 352); + + AAC_RENAME_32(ff_mdct_init)(&ac->mdct, 11, 1, 1.0 / RANGE15(1024.0)); + AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ld, 10, 1, 1.0 / RANGE15(512.0)); + AAC_RENAME_32(ff_mdct_init)(&ac->mdct_small, 8, 1, 1.0 / RANGE15(128.0)); + AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ltp, 11, 0, RANGE15(-2.0)); +#if !USE_FIXED + ret = ff_imdct15_init(&ac->mdct480, 5); + if (ret < 0) + return ret; +#endif + // window initialization + AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_long_1024), 4.0, 1024); + AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_short_128), 6.0, 128); + AAC_RENAME(ff_init_ff_sine_windows)(10); + AAC_RENAME(ff_init_ff_sine_windows)( 9); + AAC_RENAME(ff_init_ff_sine_windows)( 7); + + AAC_RENAME(cbrt_tableinit)(); + + return 0; +} + +/** + * Skip data_stream_element; reference: table 4.10. + */ +static int skip_data_stream_element(AACContext *ac, GetBitContext *gb) +{ + int byte_align = get_bits1(gb); + int count = get_bits(gb, 8); + if (count == 255) + count += get_bits(gb, 8); + if (byte_align) + align_get_bits(gb); + + if (get_bits_left(gb) < 8 * count) { + av_log(ac->avctx, AV_LOG_ERROR, "skip_data_stream_element: "overread_err); + return AVERROR_INVALIDDATA; + } + skip_bits_long(gb, 8 * count); + return 0; +} + +static int decode_prediction(AACContext *ac, IndividualChannelStream *ics, + GetBitContext *gb) +{ + int sfb; + if (get_bits1(gb)) { + ics->predictor_reset_group = get_bits(gb, 5); + if (ics->predictor_reset_group == 0 || + ics->predictor_reset_group > 30) { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid Predictor Reset Group.\n"); + return AVERROR_INVALIDDATA; + } + } + for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]); sfb++) { + ics->prediction_used[sfb] = get_bits1(gb); + } + return 0; +} + +/** + * Decode Long Term Prediction data; reference: table 4.xx. + */ +static void decode_ltp(LongTermPrediction *ltp, + GetBitContext *gb, uint8_t max_sfb) +{ + int sfb; + + ltp->lag = get_bits(gb, 11); + ltp->coef = ltp_coef[get_bits(gb, 3)]; + for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++) + ltp->used[sfb] = get_bits1(gb); +} + +/** + * Decode Individual Channel Stream info; reference: table 4.6. + */ +static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, + GetBitContext *gb) +{ + const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac; + const int aot = m4ac->object_type; + const int sampling_index = m4ac->sampling_index; + if (aot != AOT_ER_AAC_ELD) { + if (get_bits1(gb)) { + av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n"); + if (ac->avctx->err_recognition & AV_EF_BITSTREAM) + return AVERROR_INVALIDDATA; + } + ics->window_sequence[1] = ics->window_sequence[0]; + ics->window_sequence[0] = get_bits(gb, 2); + if (aot == AOT_ER_AAC_LD && + ics->window_sequence[0] != ONLY_LONG_SEQUENCE) { + av_log(ac->avctx, AV_LOG_ERROR, + "AAC LD is only defined for ONLY_LONG_SEQUENCE but " + "window sequence %d found.\n", ics->window_sequence[0]); + ics->window_sequence[0] = ONLY_LONG_SEQUENCE; + return AVERROR_INVALIDDATA; + } + ics->use_kb_window[1] = ics->use_kb_window[0]; + ics->use_kb_window[0] = get_bits1(gb); + } + ics->num_window_groups = 1; + ics->group_len[0] = 1; + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + int i; + ics->max_sfb = get_bits(gb, 4); + for (i = 0; i < 7; i++) { + if (get_bits1(gb)) { + ics->group_len[ics->num_window_groups - 1]++; + } else { + ics->num_window_groups++; + ics->group_len[ics->num_window_groups - 1] = 1; + } + } + ics->num_windows = 8; + ics->swb_offset = ff_swb_offset_128[sampling_index]; + ics->num_swb = ff_aac_num_swb_128[sampling_index]; + ics->tns_max_bands = ff_tns_max_bands_128[sampling_index]; + ics->predictor_present = 0; + } else { + ics->max_sfb = get_bits(gb, 6); + ics->num_windows = 1; + if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) { + if (m4ac->frame_length_short) { + ics->swb_offset = ff_swb_offset_480[sampling_index]; + ics->num_swb = ff_aac_num_swb_480[sampling_index]; + ics->tns_max_bands = ff_tns_max_bands_480[sampling_index]; + } else { + ics->swb_offset = ff_swb_offset_512[sampling_index]; + ics->num_swb = ff_aac_num_swb_512[sampling_index]; + ics->tns_max_bands = ff_tns_max_bands_512[sampling_index]; + } + if (!ics->num_swb || !ics->swb_offset) + return AVERROR_BUG; + } else { + ics->swb_offset = ff_swb_offset_1024[sampling_index]; + ics->num_swb = ff_aac_num_swb_1024[sampling_index]; + ics->tns_max_bands = ff_tns_max_bands_1024[sampling_index]; + } + if (aot != AOT_ER_AAC_ELD) { + ics->predictor_present = get_bits1(gb); + ics->predictor_reset_group = 0; + } + if (ics->predictor_present) { + if (aot == AOT_AAC_MAIN) { + if (decode_prediction(ac, ics, gb)) { + goto fail; + } + } else if (aot == AOT_AAC_LC || + aot == AOT_ER_AAC_LC) { + av_log(ac->avctx, AV_LOG_ERROR, + "Prediction is not allowed in AAC-LC.\n"); + goto fail; + } else { + if (aot == AOT_ER_AAC_LD) { + av_log(ac->avctx, AV_LOG_ERROR, + "LTP in ER AAC LD not yet implemented.\n"); + return AVERROR_PATCHWELCOME; + } + if ((ics->ltp.present = get_bits(gb, 1))) + decode_ltp(&ics->ltp, gb, ics->max_sfb); + } + } + } + + if (ics->max_sfb > ics->num_swb) { + av_log(ac->avctx, AV_LOG_ERROR, + "Number of scalefactor bands in group (%d) " + "exceeds limit (%d).\n", + ics->max_sfb, ics->num_swb); + goto fail; + } + + return 0; +fail: + ics->max_sfb = 0; + return AVERROR_INVALIDDATA; +} + +/** + * Decode band types (section_data payload); reference: table 4.46. + * + * @param band_type array of the used band type + * @param band_type_run_end array of the last scalefactor band of a band type run + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_band_types(AACContext *ac, enum BandType band_type[120], + int band_type_run_end[120], GetBitContext *gb, + IndividualChannelStream *ics) +{ + int g, idx = 0; + const int bits = (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) ? 3 : 5; + for (g = 0; g < ics->num_window_groups; g++) { + int k = 0; + while (k < ics->max_sfb) { + uint8_t sect_end = k; + int sect_len_incr; + int sect_band_type = get_bits(gb, 4); + if (sect_band_type == 12) { + av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n"); + return AVERROR_INVALIDDATA; + } + do { + sect_len_incr = get_bits(gb, bits); + sect_end += sect_len_incr; + if (get_bits_left(gb) < 0) { + av_log(ac->avctx, AV_LOG_ERROR, "decode_band_types: "overread_err); + return AVERROR_INVALIDDATA; + } + if (sect_end > ics->max_sfb) { + av_log(ac->avctx, AV_LOG_ERROR, + "Number of bands (%d) exceeds limit (%d).\n", + sect_end, ics->max_sfb); + return AVERROR_INVALIDDATA; + } + } while (sect_len_incr == (1 << bits) - 1); + for (; k < sect_end; k++) { + band_type [idx] = sect_band_type; + band_type_run_end[idx++] = sect_end; + } + } + } + return 0; +} + +/** + * Decode scalefactors; reference: table 4.47. + * + * @param global_gain first scalefactor value as scalefactors are differentially coded + * @param band_type array of the used band type + * @param band_type_run_end array of the last scalefactor band of a band type run + * @param sf array of scalefactors or intensity stereo positions + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_scalefactors(AACContext *ac, INTFLOAT sf[120], GetBitContext *gb, + unsigned int global_gain, + IndividualChannelStream *ics, + enum BandType band_type[120], + int band_type_run_end[120]) +{ + int g, i, idx = 0; + int offset[3] = { global_gain, global_gain - NOISE_OFFSET, 0 }; + int clipped_offset; + int noise_flag = 1; + for (g = 0; g < ics->num_window_groups; g++) { + for (i = 0; i < ics->max_sfb;) { + int run_end = band_type_run_end[idx]; + if (band_type[idx] == ZERO_BT) { + for (; i < run_end; i++, idx++) + sf[idx] = FIXR(0.); + } else if ((band_type[idx] == INTENSITY_BT) || + (band_type[idx] == INTENSITY_BT2)) { + for (; i < run_end; i++, idx++) { + offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - SCALE_DIFF_ZERO; + clipped_offset = av_clip(offset[2], -155, 100); + if (offset[2] != clipped_offset) { + avpriv_request_sample(ac->avctx, + "If you heard an audible artifact, there may be a bug in the decoder. " + "Clipped intensity stereo position (%d -> %d)", + offset[2], clipped_offset); + } +#if USE_FIXED + sf[idx] = 100 - clipped_offset; +#else + sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + POW_SF2_ZERO]; +#endif /* USE_FIXED */ + } + } else if (band_type[idx] == NOISE_BT) { + for (; i < run_end; i++, idx++) { + if (noise_flag-- > 0) + offset[1] += get_bits(gb, NOISE_PRE_BITS) - NOISE_PRE; + else + offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - SCALE_DIFF_ZERO; + clipped_offset = av_clip(offset[1], -100, 155); + if (offset[1] != clipped_offset) { + avpriv_request_sample(ac->avctx, + "If you heard an audible artifact, there may be a bug in the decoder. " + "Clipped noise gain (%d -> %d)", + offset[1], clipped_offset); + } +#if USE_FIXED + sf[idx] = -(100 + clipped_offset); +#else + sf[idx] = -ff_aac_pow2sf_tab[clipped_offset + POW_SF2_ZERO]; +#endif /* USE_FIXED */ + } + } else { + for (; i < run_end; i++, idx++) { + offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - SCALE_DIFF_ZERO; + if (offset[0] > 255U) { + av_log(ac->avctx, AV_LOG_ERROR, + "Scalefactor (%d) out of range.\n", offset[0]); + return AVERROR_INVALIDDATA; + } +#if USE_FIXED + sf[idx] = -offset[0]; +#else + sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO]; +#endif /* USE_FIXED */ + } + } + } + } + return 0; +} + +/** + * Decode pulse data; reference: table 4.7. + */ +static int decode_pulses(Pulse *pulse, GetBitContext *gb, + const uint16_t *swb_offset, int num_swb) +{ + int i, pulse_swb; + pulse->num_pulse = get_bits(gb, 2) + 1; + pulse_swb = get_bits(gb, 6); + if (pulse_swb >= num_swb) + return -1; + pulse->pos[0] = swb_offset[pulse_swb]; + pulse->pos[0] += get_bits(gb, 5); + if (pulse->pos[0] >= swb_offset[num_swb]) + return -1; + pulse->amp[0] = get_bits(gb, 4); + for (i = 1; i < pulse->num_pulse; i++) { + pulse->pos[i] = get_bits(gb, 5) + pulse->pos[i - 1]; + if (pulse->pos[i] >= swb_offset[num_swb]) + return -1; + pulse->amp[i] = get_bits(gb, 4); + } + return 0; +} + +/** + * Decode Temporal Noise Shaping data; reference: table 4.48. + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns, + GetBitContext *gb, const IndividualChannelStream *ics) +{ + int w, filt, i, coef_len, coef_res, coef_compress; + const int is8 = ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE; + const int tns_max_order = is8 ? 7 : ac->oc[1].m4ac.object_type == AOT_AAC_MAIN ? 20 : 12; + for (w = 0; w < ics->num_windows; w++) { + if ((tns->n_filt[w] = get_bits(gb, 2 - is8))) { + coef_res = get_bits1(gb); + + for (filt = 0; filt < tns->n_filt[w]; filt++) { + int tmp2_idx; + tns->length[w][filt] = get_bits(gb, 6 - 2 * is8); + + if ((tns->order[w][filt] = get_bits(gb, 5 - 2 * is8)) > tns_max_order) { + av_log(ac->avctx, AV_LOG_ERROR, + "TNS filter order %d is greater than maximum %d.\n", + tns->order[w][filt], tns_max_order); + tns->order[w][filt] = 0; + return AVERROR_INVALIDDATA; + } + if (tns->order[w][filt]) { + tns->direction[w][filt] = get_bits1(gb); + coef_compress = get_bits1(gb); + coef_len = coef_res + 3 - coef_compress; + tmp2_idx = 2 * coef_compress + coef_res; + + for (i = 0; i < tns->order[w][filt]; i++) + tns->coef[w][filt][i] = tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)]; + } + } + } + } + return 0; +} + +/** + * Decode Mid/Side data; reference: table 4.54. + * + * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s; + * [1] mask is decoded from bitstream; [2] mask is all 1s; + * [3] reserved for scalable AAC + */ +static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb, + int ms_present) +{ + int idx; + int max_idx = cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb; + if (ms_present == 1) { + for (idx = 0; idx < max_idx; idx++) + cpe->ms_mask[idx] = get_bits1(gb); + } else if (ms_present == 2) { + memset(cpe->ms_mask, 1, max_idx * sizeof(cpe->ms_mask[0])); + } +} + +/** + * Decode spectral data; reference: table 4.50. + * Dequantize and scale spectral data; reference: 4.6.3.3. + * + * @param coef array of dequantized, scaled spectral data + * @param sf array of scalefactors or intensity stereo positions + * @param pulse_present set if pulses are present + * @param pulse pointer to pulse data struct + * @param band_type array of the used band type + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_spectrum_and_dequant(AACContext *ac, INTFLOAT coef[1024], + GetBitContext *gb, const INTFLOAT sf[120], + int pulse_present, const Pulse *pulse, + const IndividualChannelStream *ics, + enum BandType band_type[120]) +{ + int i, k, g, idx = 0; + const int c = 1024 / ics->num_windows; + const uint16_t *offsets = ics->swb_offset; + INTFLOAT *coef_base = coef; + + for (g = 0; g < ics->num_windows; g++) + memset(coef + g * 128 + offsets[ics->max_sfb], 0, + sizeof(INTFLOAT) * (c - offsets[ics->max_sfb])); + + for (g = 0; g < ics->num_window_groups; g++) { + unsigned g_len = ics->group_len[g]; + + for (i = 0; i < ics->max_sfb; i++, idx++) { + const unsigned cbt_m1 = band_type[idx] - 1; + INTFLOAT *cfo = coef + offsets[i]; + int off_len = offsets[i + 1] - offsets[i]; + int group; + + if (cbt_m1 >= INTENSITY_BT2 - 1) { + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { + memset(cfo, 0, off_len * sizeof(*cfo)); + } + } else if (cbt_m1 == NOISE_BT - 1) { + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { +#if !USE_FIXED + float scale; +#endif /* !USE_FIXED */ + INTFLOAT band_energy; + + for (k = 0; k < off_len; k++) { + ac->random_state = lcg_random(ac->random_state); +#if USE_FIXED + cfo[k] = ac->random_state >> 3; +#else + cfo[k] = ac->random_state; +#endif /* USE_FIXED */ + } + +#if USE_FIXED + band_energy = ac->fdsp->scalarproduct_fixed(cfo, cfo, off_len); + band_energy = fixed_sqrt(band_energy, 31); + noise_scale(cfo, sf[idx], band_energy, off_len); +#else + band_energy = ac->fdsp->scalarproduct_float(cfo, cfo, off_len); + scale = sf[idx] / sqrtf(band_energy); + ac->fdsp->vector_fmul_scalar(cfo, cfo, scale, off_len); +#endif /* USE_FIXED */ + } + } else { +#if !USE_FIXED + const float *vq = ff_aac_codebook_vector_vals[cbt_m1]; +#endif /* !USE_FIXED */ + const uint16_t *cb_vector_idx = ff_aac_codebook_vector_idx[cbt_m1]; + VLC_TYPE (*vlc_tab)[2] = vlc_spectral[cbt_m1].table; + OPEN_READER(re, gb); + + switch (cbt_m1 >> 1) { + case 0: + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { + INTFLOAT *cf = cfo; + int len = off_len; + + do { + int code; + unsigned cb_idx; + + UPDATE_CACHE(re, gb); + GET_VLC(code, re, gb, vlc_tab, 8, 2); + cb_idx = cb_vector_idx[code]; +#if USE_FIXED + cf = DEC_SQUAD(cf, cb_idx); +#else + cf = VMUL4(cf, vq, cb_idx, sf + idx); +#endif /* USE_FIXED */ + } while (len -= 4); + } + break; + + case 1: + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { + INTFLOAT *cf = cfo; + int len = off_len; + + do { + int code; + unsigned nnz; + unsigned cb_idx; + uint32_t bits; + + UPDATE_CACHE(re, gb); + GET_VLC(code, re, gb, vlc_tab, 8, 2); + cb_idx = cb_vector_idx[code]; + nnz = cb_idx >> 8 & 15; + bits = nnz ? GET_CACHE(re, gb) : 0; + LAST_SKIP_BITS(re, gb, nnz); +#if USE_FIXED + cf = DEC_UQUAD(cf, cb_idx, bits); +#else + cf = VMUL4S(cf, vq, cb_idx, bits, sf + idx); +#endif /* USE_FIXED */ + } while (len -= 4); + } + break; + + case 2: + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { + INTFLOAT *cf = cfo; + int len = off_len; + + do { + int code; + unsigned cb_idx; + + UPDATE_CACHE(re, gb); + GET_VLC(code, re, gb, vlc_tab, 8, 2); + cb_idx = cb_vector_idx[code]; +#if USE_FIXED + cf = DEC_SPAIR(cf, cb_idx); +#else + cf = VMUL2(cf, vq, cb_idx, sf + idx); +#endif /* USE_FIXED */ + } while (len -= 2); + } + break; + + case 3: + case 4: + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { + INTFLOAT *cf = cfo; + int len = off_len; + + do { + int code; + unsigned nnz; + unsigned cb_idx; + unsigned sign; + + UPDATE_CACHE(re, gb); + GET_VLC(code, re, gb, vlc_tab, 8, 2); + cb_idx = cb_vector_idx[code]; + nnz = cb_idx >> 8 & 15; + sign = nnz ? SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12) : 0; + LAST_SKIP_BITS(re, gb, nnz); +#if USE_FIXED + cf = DEC_UPAIR(cf, cb_idx, sign); +#else + cf = VMUL2S(cf, vq, cb_idx, sign, sf + idx); +#endif /* USE_FIXED */ + } while (len -= 2); + } + break; + + default: + for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { +#if USE_FIXED + int *icf = cfo; + int v; +#else + float *cf = cfo; + uint32_t *icf = (uint32_t *) cf; +#endif /* USE_FIXED */ + int len = off_len; + + do { + int code; + unsigned nzt, nnz; + unsigned cb_idx; + uint32_t bits; + int j; + + UPDATE_CACHE(re, gb); + GET_VLC(code, re, gb, vlc_tab, 8, 2); + + if (!code) { + *icf++ = 0; + *icf++ = 0; + continue; + } + + cb_idx = cb_vector_idx[code]; + nnz = cb_idx >> 12; + nzt = cb_idx >> 8; + bits = SHOW_UBITS(re, gb, nnz) << (32-nnz); + LAST_SKIP_BITS(re, gb, nnz); + + for (j = 0; j < 2; j++) { + if (nzt & 1< 8) { + av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n"); + return AVERROR_INVALIDDATA; + } + + SKIP_BITS(re, gb, b + 1); + b += 4; + n = (1 << b) + SHOW_UBITS(re, gb, b); + LAST_SKIP_BITS(re, gb, b); +#if USE_FIXED + v = n; + if (bits & 1U<<31) + v = -v; + *icf++ = v; +#else + *icf++ = cbrt_tab[n] | (bits & 1U<<31); +#endif /* USE_FIXED */ + bits <<= 1; + } else { +#if USE_FIXED + v = cb_idx & 15; + if (bits & 1U<<31) + v = -v; + *icf++ = v; +#else + unsigned v = ((const uint32_t*)vq)[cb_idx & 15]; + *icf++ = (bits & 1U<<31) | v; +#endif /* USE_FIXED */ + bits <<= !!v; + } + cb_idx >>= 4; + } + } while (len -= 2); +#if !USE_FIXED + ac->fdsp->vector_fmul_scalar(cfo, cfo, sf[idx], off_len); +#endif /* !USE_FIXED */ + } + } + + CLOSE_READER(re, gb); + } + } + coef += g_len << 7; + } + + if (pulse_present) { + idx = 0; + for (i = 0; i < pulse->num_pulse; i++) { + INTFLOAT co = coef_base[ pulse->pos[i] ]; + while (offsets[idx + 1] <= pulse->pos[i]) + idx++; + if (band_type[idx] != NOISE_BT && sf[idx]) { + INTFLOAT ico = -pulse->amp[i]; +#if USE_FIXED + if (co) { + ico = co + (co > 0 ? -ico : ico); + } + coef_base[ pulse->pos[i] ] = ico; +#else + if (co) { + co /= sf[idx]; + ico = co / sqrtf(sqrtf(fabsf(co))) + (co > 0 ? -ico : ico); + } + coef_base[ pulse->pos[i] ] = cbrtf(fabsf(ico)) * ico * sf[idx]; +#endif /* USE_FIXED */ + } + } + } +#if USE_FIXED + coef = coef_base; + idx = 0; + for (g = 0; g < ics->num_window_groups; g++) { + unsigned g_len = ics->group_len[g]; + + for (i = 0; i < ics->max_sfb; i++, idx++) { + const unsigned cbt_m1 = band_type[idx] - 1; + int *cfo = coef + offsets[i]; + int off_len = offsets[i + 1] - offsets[i]; + int group; + + if (cbt_m1 < NOISE_BT - 1) { + for (group = 0; group < (int)g_len; group++, cfo+=128) { + ac->vector_pow43(cfo, off_len); + ac->subband_scale(cfo, cfo, sf[idx], 34, off_len); + } + } + } + coef += g_len << 7; + } +#endif /* USE_FIXED */ + return 0; +} + +/** + * Apply AAC-Main style frequency domain prediction. + */ +static void apply_prediction(AACContext *ac, SingleChannelElement *sce) +{ + int sfb, k; + + if (!sce->ics.predictor_initialized) { + reset_all_predictors(sce->predictor_state); + sce->ics.predictor_initialized = 1; + } + + if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { + for (sfb = 0; + sfb < ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]; + sfb++) { + for (k = sce->ics.swb_offset[sfb]; + k < sce->ics.swb_offset[sfb + 1]; + k++) { + predict(&sce->predictor_state[k], &sce->coeffs[k], + sce->ics.predictor_present && + sce->ics.prediction_used[sfb]); + } + } + if (sce->ics.predictor_reset_group) + reset_predictor_group(sce->predictor_state, + sce->ics.predictor_reset_group); + } else + reset_all_predictors(sce->predictor_state); +} + +/** + * Decode an individual_channel_stream payload; reference: table 4.44. + * + * @param common_window Channels have independent [0], or shared [1], Individual Channel Stream information. + * @param scale_flag scalable [1] or non-scalable [0] AAC (Unused until scalable AAC is implemented.) + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_ics(AACContext *ac, SingleChannelElement *sce, + GetBitContext *gb, int common_window, int scale_flag) +{ + Pulse pulse; + TemporalNoiseShaping *tns = &sce->tns; + IndividualChannelStream *ics = &sce->ics; + INTFLOAT *out = sce->coeffs; + int global_gain, eld_syntax, er_syntax, pulse_present = 0; + int ret; + + eld_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; + er_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_LC || + ac->oc[1].m4ac.object_type == AOT_ER_AAC_LTP || + ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD || + ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; + + /* This assignment is to silence a GCC warning about the variable being used + * uninitialized when in fact it always is. + */ + pulse.num_pulse = 0; + + global_gain = get_bits(gb, 8); + + if (!common_window && !scale_flag) { + if (decode_ics_info(ac, ics, gb) < 0) + return AVERROR_INVALIDDATA; + } + + if ((ret = decode_band_types(ac, sce->band_type, + sce->band_type_run_end, gb, ics)) < 0) + return ret; + if ((ret = decode_scalefactors(ac, sce->sf, gb, global_gain, ics, + sce->band_type, sce->band_type_run_end)) < 0) + return ret; + + pulse_present = 0; + if (!scale_flag) { + if (!eld_syntax && (pulse_present = get_bits1(gb))) { + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + av_log(ac->avctx, AV_LOG_ERROR, + "Pulse tool not allowed in eight short sequence.\n"); + return AVERROR_INVALIDDATA; + } + if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) { + av_log(ac->avctx, AV_LOG_ERROR, + "Pulse data corrupt or invalid.\n"); + return AVERROR_INVALIDDATA; + } + } + tns->present = get_bits1(gb); + if (tns->present && !er_syntax) + if (decode_tns(ac, tns, gb, ics) < 0) + return AVERROR_INVALIDDATA; + if (!eld_syntax && get_bits1(gb)) { + avpriv_request_sample(ac->avctx, "SSR"); + return AVERROR_PATCHWELCOME; + } + // I see no textual basis in the spec for this occurring after SSR gain + // control, but this is what both reference and real implmentations do + if (tns->present && er_syntax) + if (decode_tns(ac, tns, gb, ics) < 0) + return AVERROR_INVALIDDATA; + } + + if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present, + &pulse, ics, sce->band_type) < 0) + return AVERROR_INVALIDDATA; + + if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN && !common_window) + apply_prediction(ac, sce); + + return 0; +} + +/** + * Mid/Side stereo decoding; reference: 4.6.8.1.3. + */ +static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe) +{ + const IndividualChannelStream *ics = &cpe->ch[0].ics; + INTFLOAT *ch0 = cpe->ch[0].coeffs; + INTFLOAT *ch1 = cpe->ch[1].coeffs; + int g, i, group, idx = 0; + const uint16_t *offsets = ics->swb_offset; + for (g = 0; g < ics->num_window_groups; g++) { + for (i = 0; i < ics->max_sfb; i++, idx++) { + if (cpe->ms_mask[idx] && + cpe->ch[0].band_type[idx] < NOISE_BT && + cpe->ch[1].band_type[idx] < NOISE_BT) { +#if USE_FIXED + for (group = 0; group < ics->group_len[g]; group++) { + ac->fdsp->butterflies_fixed(ch0 + group * 128 + offsets[i], + ch1 + group * 128 + offsets[i], + offsets[i+1] - offsets[i]); +#else + for (group = 0; group < ics->group_len[g]; group++) { + ac->fdsp->butterflies_float(ch0 + group * 128 + offsets[i], + ch1 + group * 128 + offsets[i], + offsets[i+1] - offsets[i]); +#endif /* USE_FIXED */ + } + } + } + ch0 += ics->group_len[g] * 128; + ch1 += ics->group_len[g] * 128; + } +} + +/** + * intensity stereo decoding; reference: 4.6.8.2.3 + * + * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s; + * [1] mask is decoded from bitstream; [2] mask is all 1s; + * [3] reserved for scalable AAC + */ +static void apply_intensity_stereo(AACContext *ac, + ChannelElement *cpe, int ms_present) +{ + const IndividualChannelStream *ics = &cpe->ch[1].ics; + SingleChannelElement *sce1 = &cpe->ch[1]; + INTFLOAT *coef0 = cpe->ch[0].coeffs, *coef1 = cpe->ch[1].coeffs; + const uint16_t *offsets = ics->swb_offset; + int g, group, i, idx = 0; + int c; + INTFLOAT scale; + for (g = 0; g < ics->num_window_groups; g++) { + for (i = 0; i < ics->max_sfb;) { + if (sce1->band_type[idx] == INTENSITY_BT || + sce1->band_type[idx] == INTENSITY_BT2) { + const int bt_run_end = sce1->band_type_run_end[idx]; + for (; i < bt_run_end; i++, idx++) { + c = -1 + 2 * (sce1->band_type[idx] - 14); + if (ms_present) + c *= 1 - 2 * cpe->ms_mask[idx]; + scale = c * sce1->sf[idx]; + for (group = 0; group < ics->group_len[g]; group++) +#if USE_FIXED + ac->subband_scale(coef1 + group * 128 + offsets[i], + coef0 + group * 128 + offsets[i], + scale, + 23, + offsets[i + 1] - offsets[i]); +#else + ac->fdsp->vector_fmul_scalar(coef1 + group * 128 + offsets[i], + coef0 + group * 128 + offsets[i], + scale, + offsets[i + 1] - offsets[i]); +#endif /* USE_FIXED */ + } + } else { + int bt_run_end = sce1->band_type_run_end[idx]; + idx += bt_run_end - i; + i = bt_run_end; + } + } + coef0 += ics->group_len[g] * 128; + coef1 += ics->group_len[g] * 128; + } +} + +/** + * Decode a channel_pair_element; reference: table 4.4. + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe) +{ + int i, ret, common_window, ms_present = 0; + int eld_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; + + common_window = eld_syntax || get_bits1(gb); + if (common_window) { + if (decode_ics_info(ac, &cpe->ch[0].ics, gb)) + return AVERROR_INVALIDDATA; + i = cpe->ch[1].ics.use_kb_window[0]; + cpe->ch[1].ics = cpe->ch[0].ics; + cpe->ch[1].ics.use_kb_window[1] = i; + if (cpe->ch[1].ics.predictor_present && + (ac->oc[1].m4ac.object_type != AOT_AAC_MAIN)) + if ((cpe->ch[1].ics.ltp.present = get_bits(gb, 1))) + decode_ltp(&cpe->ch[1].ics.ltp, gb, cpe->ch[1].ics.max_sfb); + ms_present = get_bits(gb, 2); + if (ms_present == 3) { + av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n"); + return AVERROR_INVALIDDATA; + } else if (ms_present) + decode_mid_side_stereo(cpe, gb, ms_present); + } + if ((ret = decode_ics(ac, &cpe->ch[0], gb, common_window, 0))) + return ret; + if ((ret = decode_ics(ac, &cpe->ch[1], gb, common_window, 0))) + return ret; + + if (common_window) { + if (ms_present) + apply_mid_side_stereo(ac, cpe); + if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN) { + apply_prediction(ac, &cpe->ch[0]); + apply_prediction(ac, &cpe->ch[1]); + } + } + + apply_intensity_stereo(ac, cpe, ms_present); + return 0; +} + +static const float cce_scale[] = { + 1.09050773266525765921, //2^(1/8) + 1.18920711500272106672, //2^(1/4) + M_SQRT2, + 2, +}; + +/** + * Decode coupling_channel_element; reference: table 4.8. + * + * @return Returns error status. 0 - OK, !0 - error + */ +static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) +{ + int num_gain = 0; + int c, g, sfb, ret; + int sign; + INTFLOAT scale; + SingleChannelElement *sce = &che->ch[0]; + ChannelCoupling *coup = &che->coup; + + coup->coupling_point = 2 * get_bits1(gb); + coup->num_coupled = get_bits(gb, 3); + for (c = 0; c <= coup->num_coupled; c++) { + num_gain++; + coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE; + coup->id_select[c] = get_bits(gb, 4); + if (coup->type[c] == TYPE_CPE) { + coup->ch_select[c] = get_bits(gb, 2); + if (coup->ch_select[c] == 3) + num_gain++; + } else + coup->ch_select[c] = 2; + } + coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1); + + sign = get_bits(gb, 1); + scale = AAC_RENAME(cce_scale)[get_bits(gb, 2)]; + + if ((ret = decode_ics(ac, sce, gb, 0, 0))) + return ret; + + for (c = 0; c < num_gain; c++) { + int idx = 0; + int cge = 1; + int gain = 0; + INTFLOAT gain_cache = FIXR10(1.); + if (c) { + cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb); + gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0; + gain_cache = GET_GAIN(scale, gain); + } + if (coup->coupling_point == AFTER_IMDCT) { + coup->gain[c][0] = gain_cache; + } else { + for (g = 0; g < sce->ics.num_window_groups; g++) { + for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) { + if (sce->band_type[idx] != ZERO_BT) { + if (!cge) { + int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; + if (t) { + int s = 1; + t = gain += t; + if (sign) { + s -= 2 * (t & 0x1); + t >>= 1; + } + gain_cache = GET_GAIN(scale, t) * s; + } + } + coup->gain[c][idx] = gain_cache; + } + } + } + } + } + return 0; +} + +/** + * Parse whether channels are to be excluded from Dynamic Range Compression; reference: table 4.53. + * + * @return Returns number of bytes consumed. + */ +static int decode_drc_channel_exclusions(DynamicRangeControl *che_drc, + GetBitContext *gb) +{ + int i; + int num_excl_chan = 0; + + do { + for (i = 0; i < 7; i++) + che_drc->exclude_mask[num_excl_chan++] = get_bits1(gb); + } while (num_excl_chan < MAX_CHANNELS - 7 && get_bits1(gb)); + + return num_excl_chan / 7; +} + +/** + * Decode dynamic range information; reference: table 4.52. + * + * @return Returns number of bytes consumed. + */ +static int decode_dynamic_range(DynamicRangeControl *che_drc, + GetBitContext *gb) +{ + int n = 1; + int drc_num_bands = 1; + int i; + + /* pce_tag_present? */ + if (get_bits1(gb)) { + che_drc->pce_instance_tag = get_bits(gb, 4); + skip_bits(gb, 4); // tag_reserved_bits + n++; + } + + /* excluded_chns_present? */ + if (get_bits1(gb)) { + n += decode_drc_channel_exclusions(che_drc, gb); + } + + /* drc_bands_present? */ + if (get_bits1(gb)) { + che_drc->band_incr = get_bits(gb, 4); + che_drc->interpolation_scheme = get_bits(gb, 4); + n++; + drc_num_bands += che_drc->band_incr; + for (i = 0; i < drc_num_bands; i++) { + che_drc->band_top[i] = get_bits(gb, 8); + n++; + } + } + + /* prog_ref_level_present? */ + if (get_bits1(gb)) { + che_drc->prog_ref_level = get_bits(gb, 7); + skip_bits1(gb); // prog_ref_level_reserved_bits + n++; + } + + for (i = 0; i < drc_num_bands; i++) { + che_drc->dyn_rng_sgn[i] = get_bits1(gb); + che_drc->dyn_rng_ctl[i] = get_bits(gb, 7); + n++; + } + + return n; +} + +static int decode_fill(AACContext *ac, GetBitContext *gb, int len) { + uint8_t buf[256]; + int i, major, minor; + + if (len < 13+7*8) + goto unknown; + + get_bits(gb, 13); len -= 13; + + for(i=0; i+1=8; i++, len-=8) + buf[i] = get_bits(gb, 8); + + buf[i] = 0; + if (ac->avctx->debug & FF_DEBUG_PICT_INFO) + av_log(ac->avctx, AV_LOG_DEBUG, "FILL:%s\n", buf); + + if (sscanf(buf, "libfaac %d.%d", &major, &minor) == 2){ + ac->avctx->internal->skip_samples = 1024; + } + +unknown: + skip_bits_long(gb, len); + + return 0; +} + +/** + * Decode extension data (incomplete); reference: table 4.51. + * + * @param cnt length of TYPE_FIL syntactic element in bytes + * + * @return Returns number of bytes consumed + */ +static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, + ChannelElement *che, enum RawDataBlockType elem_type) +{ + int crc_flag = 0; + int res = cnt; + int type = get_bits(gb, 4); + + if (ac->avctx->debug & FF_DEBUG_STARTCODE) + av_log(ac->avctx, AV_LOG_DEBUG, "extension type: %d len:%d\n", type, cnt); + + switch (type) { // extension type + case EXT_SBR_DATA_CRC: + crc_flag++; + case EXT_SBR_DATA: + if (!che) { + av_log(ac->avctx, AV_LOG_ERROR, "SBR was found before the first channel element.\n"); + return res; + } else if (!ac->oc[1].m4ac.sbr) { + av_log(ac->avctx, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n"); + skip_bits_long(gb, 8 * cnt - 4); + return res; + } else if (ac->oc[1].m4ac.sbr == -1 && ac->oc[1].status == OC_LOCKED) { + av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n"); + skip_bits_long(gb, 8 * cnt - 4); + return res; + } else if (ac->oc[1].m4ac.ps == -1 && ac->oc[1].status < OC_LOCKED && ac->avctx->channels == 1) { + ac->oc[1].m4ac.sbr = 1; + ac->oc[1].m4ac.ps = 1; + ac->avctx->profile = FF_PROFILE_AAC_HE_V2; + output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, + ac->oc[1].status, 1); + } else { + ac->oc[1].m4ac.sbr = 1; + ac->avctx->profile = FF_PROFILE_AAC_HE; + } + res = AAC_RENAME(ff_decode_sbr_extension)(ac, &che->sbr, gb, crc_flag, cnt, elem_type); + break; + case EXT_DYNAMIC_RANGE: + res = decode_dynamic_range(&ac->che_drc, gb); + break; + case EXT_FILL: + decode_fill(ac, gb, 8 * cnt - 4); + break; + case EXT_FILL_DATA: + case EXT_DATA_ELEMENT: + default: + skip_bits_long(gb, 8 * cnt - 4); + break; + }; + return res; +} + +/** + * Decode Temporal Noise Shaping filter coefficients and apply all-pole filters; reference: 4.6.9.3. + * + * @param decode 1 if tool is used normally, 0 if tool is used in LTP. + * @param coef spectral coefficients + */ +static void apply_tns(INTFLOAT coef[1024], TemporalNoiseShaping *tns, + IndividualChannelStream *ics, int decode) +{ + const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb); + int w, filt, m, i; + int bottom, top, order, start, end, size, inc; + INTFLOAT lpc[TNS_MAX_ORDER]; + INTFLOAT tmp[TNS_MAX_ORDER+1]; + + for (w = 0; w < ics->num_windows; w++) { + bottom = ics->num_swb; + for (filt = 0; filt < tns->n_filt[w]; filt++) { + top = bottom; + bottom = FFMAX(0, top - tns->length[w][filt]); + order = tns->order[w][filt]; + if (order == 0) + continue; + + // tns_decode_coef + AAC_RENAME(compute_lpc_coefs)(tns->coef[w][filt], order, lpc, 0, 0, 0); + + start = ics->swb_offset[FFMIN(bottom, mmm)]; + end = ics->swb_offset[FFMIN( top, mmm)]; + if ((size = end - start) <= 0) + continue; + if (tns->direction[w][filt]) { + inc = -1; + start = end - 1; + } else { + inc = 1; + } + start += w * 128; + + if (decode) { + // ar filter + for (m = 0; m < size; m++, start += inc) + for (i = 1; i <= FFMIN(m, order); i++) + coef[start] -= AAC_MUL26(coef[start - i * inc], lpc[i - 1]); + } else { + // ma filter + for (m = 0; m < size; m++, start += inc) { + tmp[0] = coef[start]; + for (i = 1; i <= FFMIN(m, order); i++) + coef[start] += AAC_MUL26(tmp[i], lpc[i - 1]); + for (i = order; i > 0; i--) + tmp[i] = tmp[i - 1]; + } + } + } + } +} + +/** + * Apply windowing and MDCT to obtain the spectral + * coefficient from the predicted sample by LTP. + */ +static void windowing_and_mdct_ltp(AACContext *ac, INTFLOAT *out, + INTFLOAT *in, IndividualChannelStream *ics) +{ + const INTFLOAT *lwindow = ics->use_kb_window[0] ? AAC_RENAME(ff_aac_kbd_long_1024) : AAC_RENAME(ff_sine_1024); + const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME(ff_aac_kbd_short_128) : AAC_RENAME(ff_sine_128); + const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME(ff_aac_kbd_long_1024) : AAC_RENAME(ff_sine_1024); + const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME(ff_aac_kbd_short_128) : AAC_RENAME(ff_sine_128); + + if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) { + ac->fdsp->vector_fmul(in, in, lwindow_prev, 1024); + } else { + memset(in, 0, 448 * sizeof(*in)); + ac->fdsp->vector_fmul(in + 448, in + 448, swindow_prev, 128); + } + if (ics->window_sequence[0] != LONG_START_SEQUENCE) { + ac->fdsp->vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024); + } else { + ac->fdsp->vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); + memset(in + 1024 + 576, 0, 448 * sizeof(*in)); + } + ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in); +} + +/** + * Apply the long term prediction + */ +static void apply_ltp(AACContext *ac, SingleChannelElement *sce) +{ + const LongTermPrediction *ltp = &sce->ics.ltp; + const uint16_t *offsets = sce->ics.swb_offset; + int i, sfb; + + if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { + INTFLOAT *predTime = sce->ret; + INTFLOAT *predFreq = ac->buf_mdct; + int16_t num_samples = 2048; + + if (ltp->lag < 1024) + num_samples = ltp->lag + 1024; + for (i = 0; i < num_samples; i++) + predTime[i] = AAC_MUL30(sce->ltp_state[i + 2048 - ltp->lag], ltp->coef); + memset(&predTime[i], 0, (2048 - i) * sizeof(*predTime)); + + ac->windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics); + + if (sce->tns.present) + ac->apply_tns(predFreq, &sce->tns, &sce->ics, 0); + + for (sfb = 0; sfb < FFMIN(sce->ics.max_sfb, MAX_LTP_LONG_SFB); sfb++) + if (ltp->used[sfb]) + for (i = offsets[sfb]; i < offsets[sfb + 1]; i++) + sce->coeffs[i] += predFreq[i]; + } +} + +/** + * Update the LTP buffer for next frame + */ +static void update_ltp(AACContext *ac, SingleChannelElement *sce) +{ + IndividualChannelStream *ics = &sce->ics; + INTFLOAT *saved = sce->saved; + INTFLOAT *saved_ltp = sce->coeffs; + const INTFLOAT *lwindow = ics->use_kb_window[0] ? AAC_RENAME(ff_aac_kbd_long_1024) : AAC_RENAME(ff_sine_1024); + const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME(ff_aac_kbd_short_128) : AAC_RENAME(ff_sine_128); + int i; + + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + memcpy(saved_ltp, saved, 512 * sizeof(*saved_ltp)); + memset(saved_ltp + 576, 0, 448 * sizeof(*saved_ltp)); + ac->fdsp->vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); + + for (i = 0; i < 64; i++) + saved_ltp[i + 512] = AAC_MUL31(ac->buf_mdct[1023 - i], swindow[63 - i]); + } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { + memcpy(saved_ltp, ac->buf_mdct + 512, 448 * sizeof(*saved_ltp)); + memset(saved_ltp + 576, 0, 448 * sizeof(*saved_ltp)); + ac->fdsp->vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); + + for (i = 0; i < 64; i++) + saved_ltp[i + 512] = AAC_MUL31(ac->buf_mdct[1023 - i], swindow[63 - i]); + } else { // LONG_STOP or ONLY_LONG + ac->fdsp->vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, &lwindow[512], 512); + + for (i = 0; i < 512; i++) + saved_ltp[i + 512] = AAC_MUL31(ac->buf_mdct[1023 - i], lwindow[511 - i]); + } + + memcpy(sce->ltp_state, sce->ltp_state+1024, 1024 * sizeof(*sce->ltp_state)); + memcpy(sce->ltp_state+1024, sce->ret, 1024 * sizeof(*sce->ltp_state)); + memcpy(sce->ltp_state+2048, saved_ltp, 1024 * sizeof(*sce->ltp_state)); +} + +/** + * Conduct IMDCT and windowing. + */ +static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce) +{ + IndividualChannelStream *ics = &sce->ics; + INTFLOAT *in = sce->coeffs; + INTFLOAT *out = sce->ret; + INTFLOAT *saved = sce->saved; + const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME(ff_aac_kbd_short_128) : AAC_RENAME(ff_sine_128); + const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME(ff_aac_kbd_long_1024) : AAC_RENAME(ff_sine_1024); + const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME(ff_aac_kbd_short_128) : AAC_RENAME(ff_sine_128); + INTFLOAT *buf = ac->buf_mdct; + INTFLOAT *temp = ac->temp; + int i; + + // imdct + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + for (i = 0; i < 1024; i += 128) + ac->mdct_small.imdct_half(&ac->mdct_small, buf + i, in + i); + } else { + ac->mdct.imdct_half(&ac->mdct, buf, in); +#if USE_FIXED + for (i=0; i<1024; i++) + buf[i] = (buf[i] + 4) >> 3; +#endif /* USE_FIXED */ + } + + /* window overlapping + * NOTE: To simplify the overlapping code, all 'meaningless' short to long + * and long to short transitions are considered to be short to short + * transitions. This leaves just two cases (long to long and short to short) + * with a little special sauce for EIGHT_SHORT_SEQUENCE. + */ + if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) && + (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) { + ac->fdsp->vector_fmul_window( out, saved, buf, lwindow_prev, 512); + } else { + memcpy( out, saved, 448 * sizeof(*out)); + + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + ac->fdsp->vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, 64); + ac->fdsp->vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, 64); + ac->fdsp->vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, 64); + ac->fdsp->vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, 64); + ac->fdsp->vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, 64); + memcpy( out + 448 + 4*128, temp, 64 * sizeof(*out)); + } else { + ac->fdsp->vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 64); + memcpy( out + 576, buf + 64, 448 * sizeof(*out)); + } + } + + // buffer update + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + memcpy( saved, temp + 64, 64 * sizeof(*saved)); + ac->fdsp->vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 64); + ac->fdsp->vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 64); + ac->fdsp->vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 64); + memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(*saved)); + } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { + memcpy( saved, buf + 512, 448 * sizeof(*saved)); + memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(*saved)); + } else { // LONG_STOP or ONLY_LONG + memcpy( saved, buf + 512, 512 * sizeof(*saved)); + } +} + +static void imdct_and_windowing_ld(AACContext *ac, SingleChannelElement *sce) +{ + IndividualChannelStream *ics = &sce->ics; + INTFLOAT *in = sce->coeffs; + INTFLOAT *out = sce->ret; + INTFLOAT *saved = sce->saved; + INTFLOAT *buf = ac->buf_mdct; +#if USE_FIXED + int i; +#endif /* USE_FIXED */ + + // imdct + ac->mdct.imdct_half(&ac->mdct_ld, buf, in); + +#if USE_FIXED + for (i = 0; i < 1024; i++) + buf[i] = (buf[i] + 2) >> 2; +#endif /* USE_FIXED */ + + // window overlapping + if (ics->use_kb_window[1]) { + // AAC LD uses a low overlap sine window instead of a KBD window + memcpy(out, saved, 192 * sizeof(*out)); + ac->fdsp->vector_fmul_window(out + 192, saved + 192, buf, AAC_RENAME(ff_sine_128), 64); + memcpy( out + 320, buf + 64, 192 * sizeof(*out)); + } else { + ac->fdsp->vector_fmul_window(out, saved, buf, AAC_RENAME(ff_sine_512), 256); + } + + // buffer update + memcpy(saved, buf + 256, 256 * sizeof(*saved)); +} + +static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce) +{ + INTFLOAT *in = sce->coeffs; + INTFLOAT *out = sce->ret; + INTFLOAT *saved = sce->saved; + INTFLOAT *buf = ac->buf_mdct; + int i; + const int n = ac->oc[1].m4ac.frame_length_short ? 480 : 512; + const int n2 = n >> 1; + const int n4 = n >> 2; + const INTFLOAT *const window = n == 480 ? AAC_RENAME(ff_aac_eld_window_480) : + AAC_RENAME(ff_aac_eld_window_512); + + // Inverse transform, mapped to the conventional IMDCT by + // Chivukula, R.K.; Reznik, Y.A.; Devarajan, V., + // "Efficient algorithms for MPEG-4 AAC-ELD, AAC-LD and AAC-LC filterbanks," + // International Conference on Audio, Language and Image Processing, ICALIP 2008. + // URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4590245&isnumber=4589950 + for (i = 0; i < n2; i+=2) { + INTFLOAT temp; + temp = in[i ]; in[i ] = -in[n - 1 - i]; in[n - 1 - i] = temp; + temp = -in[i + 1]; in[i + 1] = in[n - 2 - i]; in[n - 2 - i] = temp; + } +#if !USE_FIXED + if (n == 480) + ac->mdct480->imdct_half(ac->mdct480, buf, in, 1, -1.f/(16*1024*960)); + else +#endif + ac->mdct.imdct_half(&ac->mdct_ld, buf, in); + +#if USE_FIXED + for (i = 0; i < 1024; i++) + buf[i] = (buf[i] + 1) >> 1; +#endif /* USE_FIXED */ + + for (i = 0; i < n; i+=2) { + buf[i] = -buf[i]; + } + // Like with the regular IMDCT at this point we still have the middle half + // of a transform but with even symmetry on the left and odd symmetry on + // the right + + // window overlapping + // The spec says to use samples [0..511] but the reference decoder uses + // samples [128..639]. + for (i = n4; i < n2; i ++) { + out[i - n4] = AAC_MUL31( buf[ n2 - 1 - i] , window[i - n4]) + + AAC_MUL31( saved[ i + n2] , window[i + n - n4]) + + AAC_MUL31(-saved[n + n2 - 1 - i] , window[i + 2*n - n4]) + + AAC_MUL31(-saved[ 2*n + n2 + i] , window[i + 3*n - n4]); + } + for (i = 0; i < n2; i ++) { + out[n4 + i] = AAC_MUL31( buf[ i] , window[i + n2 - n4]) + + AAC_MUL31(-saved[ n - 1 - i] , window[i + n2 + n - n4]) + + AAC_MUL31(-saved[ n + i] , window[i + n2 + 2*n - n4]) + + AAC_MUL31( saved[2*n + n - 1 - i] , window[i + n2 + 3*n - n4]); + } + for (i = 0; i < n4; i ++) { + out[n2 + n4 + i] = AAC_MUL31( buf[ i + n2] , window[i + n - n4]) + + AAC_MUL31(-saved[n2 - 1 - i] , window[i + 2*n - n4]) + + AAC_MUL31(-saved[n + n2 + i] , window[i + 3*n - n4]); + } + + // buffer update + memmove(saved + n, saved, 2 * n * sizeof(*saved)); + memcpy( saved, buf, n * sizeof(*saved)); +} + +/** + * channel coupling transformation interface + * + * @param apply_coupling_method pointer to (in)dependent coupling function + */ +static void apply_channel_coupling(AACContext *ac, ChannelElement *cc, + enum RawDataBlockType type, int elem_id, + enum CouplingPoint coupling_point, + void (*apply_coupling_method)(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)) +{ + int i, c; + + for (i = 0; i < MAX_ELEM_ID; i++) { + ChannelElement *cce = ac->che[TYPE_CCE][i]; + int index = 0; + + if (cce && cce->coup.coupling_point == coupling_point) { + ChannelCoupling *coup = &cce->coup; + + for (c = 0; c <= coup->num_coupled; c++) { + if (coup->type[c] == type && coup->id_select[c] == elem_id) { + if (coup->ch_select[c] != 1) { + apply_coupling_method(ac, &cc->ch[0], cce, index); + if (coup->ch_select[c] != 0) + index++; + } + if (coup->ch_select[c] != 2) + apply_coupling_method(ac, &cc->ch[1], cce, index++); + } else + index += 1 + (coup->ch_select[c] == 3); + } + } + } +} + +/** + * Convert spectral data to samples, applying all supported tools as appropriate. + */ +static void spectral_to_sample(AACContext *ac, int samples) +{ + int i, type; + void (*imdct_and_window)(AACContext *ac, SingleChannelElement *sce); + switch (ac->oc[1].m4ac.object_type) { + case AOT_ER_AAC_LD: + imdct_and_window = imdct_and_windowing_ld; + break; + case AOT_ER_AAC_ELD: + imdct_and_window = imdct_and_windowing_eld; + break; + default: + imdct_and_window = ac->imdct_and_windowing; + } + for (type = 3; type >= 0; type--) { + for (i = 0; i < MAX_ELEM_ID; i++) { + ChannelElement *che = ac->che[type][i]; + if (che && che->present) { + if (type <= TYPE_CPE) + apply_channel_coupling(ac, che, type, i, BEFORE_TNS, AAC_RENAME(apply_dependent_coupling)); + if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) { + if (che->ch[0].ics.predictor_present) { + if (che->ch[0].ics.ltp.present) + ac->apply_ltp(ac, &che->ch[0]); + if (che->ch[1].ics.ltp.present && type == TYPE_CPE) + ac->apply_ltp(ac, &che->ch[1]); + } + } + if (che->ch[0].tns.present) + ac->apply_tns(che->ch[0].coeffs, &che->ch[0].tns, &che->ch[0].ics, 1); + if (che->ch[1].tns.present) + ac->apply_tns(che->ch[1].coeffs, &che->ch[1].tns, &che->ch[1].ics, 1); + if (type <= TYPE_CPE) + apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, AAC_RENAME(apply_dependent_coupling)); + if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) { + imdct_and_window(ac, &che->ch[0]); + if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) + ac->update_ltp(ac, &che->ch[0]); + if (type == TYPE_CPE) { + imdct_and_window(ac, &che->ch[1]); + if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) + ac->update_ltp(ac, &che->ch[1]); + } + if (ac->oc[1].m4ac.sbr > 0) { + AAC_RENAME(ff_sbr_apply)(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret); + } + } + if (type <= TYPE_CCE) + apply_channel_coupling(ac, che, type, i, AFTER_IMDCT, AAC_RENAME(apply_independent_coupling)); + +#if USE_FIXED + { + int j; + /* preparation for resampler */ + for(j = 0; jch[0].ret[j] = (int32_t)av_clipl_int32((int64_t)che->ch[0].ret[j]<<7)+0x8000; + if(type == TYPE_CPE) + che->ch[1].ret[j] = (int32_t)av_clipl_int32((int64_t)che->ch[1].ret[j]<<7)+0x8000; + } + } +#endif /* USE_FIXED */ + che->present = 0; + } else if (che) { + av_log(ac->avctx, AV_LOG_VERBOSE, "ChannelElement %d.%d missing \n", type, i); + } + } + } +} + +static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) +{ + int size; + AACADTSHeaderInfo hdr_info; + uint8_t layout_map[MAX_ELEM_ID*4][3]; + int layout_map_tags, ret; + + size = avpriv_aac_parse_header(gb, &hdr_info); + if (size > 0) { + if (!ac->warned_num_aac_frames && hdr_info.num_aac_frames != 1) { + // This is 2 for "VLB " audio in NSV files. + // See samples/nsv/vlb_audio. + avpriv_report_missing_feature(ac->avctx, + "More than one AAC RDB per ADTS frame"); + ac->warned_num_aac_frames = 1; + } + push_output_configuration(ac); + if (hdr_info.chan_config) { + ac->oc[1].m4ac.chan_config = hdr_info.chan_config; + if ((ret = set_default_channel_config(ac->avctx, + layout_map, + &layout_map_tags, + hdr_info.chan_config)) < 0) + return ret; + if ((ret = output_configure(ac, layout_map, layout_map_tags, + FFMAX(ac->oc[1].status, + OC_TRIAL_FRAME), 0)) < 0) + return ret; + } else { + ac->oc[1].m4ac.chan_config = 0; + /** + * dual mono frames in Japanese DTV can have chan_config 0 + * WITHOUT specifying PCE. + * thus, set dual mono as default. + */ + if (ac->dmono_mode && ac->oc[0].status == OC_NONE) { + layout_map_tags = 2; + layout_map[0][0] = layout_map[1][0] = TYPE_SCE; + layout_map[0][2] = layout_map[1][2] = AAC_CHANNEL_FRONT; + layout_map[0][1] = 0; + layout_map[1][1] = 1; + if (output_configure(ac, layout_map, layout_map_tags, + OC_TRIAL_FRAME, 0)) + return -7; + } + } + ac->oc[1].m4ac.sample_rate = hdr_info.sample_rate; + ac->oc[1].m4ac.sampling_index = hdr_info.sampling_index; + ac->oc[1].m4ac.object_type = hdr_info.object_type; + ac->oc[1].m4ac.frame_length_short = 0; + if (ac->oc[0].status != OC_LOCKED || + ac->oc[0].m4ac.chan_config != hdr_info.chan_config || + ac->oc[0].m4ac.sample_rate != hdr_info.sample_rate) { + ac->oc[1].m4ac.sbr = -1; + ac->oc[1].m4ac.ps = -1; + } + if (!hdr_info.crc_absent) + skip_bits(gb, 16); + } + return size; +} + +static int aac_decode_er_frame(AVCodecContext *avctx, void *data, + int *got_frame_ptr, GetBitContext *gb) +{ + AACContext *ac = avctx->priv_data; + const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac; + ChannelElement *che; + int err, i; + int samples = m4ac->frame_length_short ? 960 : 1024; + int chan_config = m4ac->chan_config; + int aot = m4ac->object_type; + + if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) + samples >>= 1; + + ac->frame = data; + + if ((err = frame_configure_elements(avctx)) < 0) + return err; + + // The FF_PROFILE_AAC_* defines are all object_type - 1 + // This may lead to an undefined profile being signaled + ac->avctx->profile = aot - 1; + + ac->tags_mapped = 0; + + if (chan_config < 0 || (chan_config >= 8 && chan_config < 11) || chan_config >= 13) { + avpriv_request_sample(avctx, "Unknown ER channel configuration %d", + chan_config); + return AVERROR_INVALIDDATA; + } + for (i = 0; i < tags_per_config[chan_config]; i++) { + const int elem_type = aac_channel_layout_map[chan_config-1][i][0]; + const int elem_id = aac_channel_layout_map[chan_config-1][i][1]; + if (!(che=get_che(ac, elem_type, elem_id))) { + av_log(ac->avctx, AV_LOG_ERROR, + "channel element %d.%d is not allocated\n", + elem_type, elem_id); + return AVERROR_INVALIDDATA; + } + che->present = 1; + if (aot != AOT_ER_AAC_ELD) + skip_bits(gb, 4); + switch (elem_type) { + case TYPE_SCE: + err = decode_ics(ac, &che->ch[0], gb, 0, 0); + break; + case TYPE_CPE: + err = decode_cpe(ac, gb, che); + break; + case TYPE_LFE: + err = decode_ics(ac, &che->ch[0], gb, 0, 0); + break; + } + if (err < 0) + return err; + } + + spectral_to_sample(ac, samples); + + ac->frame->nb_samples = samples; + ac->frame->sample_rate = avctx->sample_rate; + *got_frame_ptr = 1; + + skip_bits_long(gb, get_bits_left(gb)); + return 0; +} + +static int aac_decode_frame_int(AVCodecContext *avctx, void *data, + int *got_frame_ptr, GetBitContext *gb, AVPacket *avpkt) +{ + AACContext *ac = avctx->priv_data; + ChannelElement *che = NULL, *che_prev = NULL; + enum RawDataBlockType elem_type, elem_type_prev = TYPE_END; + int err, elem_id; + int samples = 0, multiplier, audio_found = 0, pce_found = 0; + int is_dmono, sce_count = 0; + + ac->frame = data; + + if (show_bits(gb, 12) == 0xfff) { + if ((err = parse_adts_frame_header(ac, gb)) < 0) { + av_log(avctx, AV_LOG_ERROR, "Error decoding AAC frame header.\n"); + goto fail; + } + if (ac->oc[1].m4ac.sampling_index > 12) { + av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->oc[1].m4ac.sampling_index); + err = AVERROR_INVALIDDATA; + goto fail; + } + } + + if ((err = frame_configure_elements(avctx)) < 0) + goto fail; + + // The FF_PROFILE_AAC_* defines are all object_type - 1 + // This may lead to an undefined profile being signaled + ac->avctx->profile = ac->oc[1].m4ac.object_type - 1; + + ac->tags_mapped = 0; + // parse + while ((elem_type = get_bits(gb, 3)) != TYPE_END) { + elem_id = get_bits(gb, 4); + + if (avctx->debug & FF_DEBUG_STARTCODE) + av_log(avctx, AV_LOG_DEBUG, "Elem type:%x id:%x\n", elem_type, elem_id); + + if (!avctx->channels && elem_type != TYPE_PCE) { + err = AVERROR_INVALIDDATA; + goto fail; + } + + if (elem_type < TYPE_DSE) { + if (!(che=get_che(ac, elem_type, elem_id))) { + av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", + elem_type, elem_id); + err = AVERROR_INVALIDDATA; + goto fail; + } + samples = 1024; + che->present = 1; + } + + switch (elem_type) { + + case TYPE_SCE: + err = decode_ics(ac, &che->ch[0], gb, 0, 0); + audio_found = 1; + sce_count++; + break; + + case TYPE_CPE: + err = decode_cpe(ac, gb, che); + audio_found = 1; + break; + + case TYPE_CCE: + err = decode_cce(ac, gb, che); + break; + + case TYPE_LFE: + err = decode_ics(ac, &che->ch[0], gb, 0, 0); + audio_found = 1; + break; + + case TYPE_DSE: + err = skip_data_stream_element(ac, gb); + break; + + case TYPE_PCE: { + uint8_t layout_map[MAX_ELEM_ID*4][3]; + int tags; + push_output_configuration(ac); + tags = decode_pce(avctx, &ac->oc[1].m4ac, layout_map, gb); + if (tags < 0) { + err = tags; + break; + } + if (pce_found) { + av_log(avctx, AV_LOG_ERROR, + "Not evaluating a further program_config_element as this construct is dubious at best.\n"); + } else { + err = output_configure(ac, layout_map, tags, OC_TRIAL_PCE, 1); + if (!err) + ac->oc[1].m4ac.chan_config = 0; + pce_found = 1; + } + break; + } + + case TYPE_FIL: + if (elem_id == 15) + elem_id += get_bits(gb, 8) - 1; + if (get_bits_left(gb) < 8 * elem_id) { + av_log(avctx, AV_LOG_ERROR, "TYPE_FIL: "overread_err); + err = AVERROR_INVALIDDATA; + goto fail; + } + while (elem_id > 0) + elem_id -= decode_extension_payload(ac, gb, elem_id, che_prev, elem_type_prev); + err = 0; /* FIXME */ + break; + + default: + err = AVERROR_BUG; /* should not happen, but keeps compiler happy */ + break; + } + + che_prev = che; + elem_type_prev = elem_type; + + if (err) + goto fail; + + if (get_bits_left(gb) < 3) { + av_log(avctx, AV_LOG_ERROR, overread_err); + err = AVERROR_INVALIDDATA; + goto fail; + } + } + + if (!avctx->channels) { + *got_frame_ptr = 0; + return 0; + } + + multiplier = (ac->oc[1].m4ac.sbr == 1) ? ac->oc[1].m4ac.ext_sample_rate > ac->oc[1].m4ac.sample_rate : 0; + samples <<= multiplier; + + spectral_to_sample(ac, samples); + + if (ac->oc[1].status && audio_found) { + avctx->sample_rate = ac->oc[1].m4ac.sample_rate << multiplier; + avctx->frame_size = samples; + ac->oc[1].status = OC_LOCKED; + } + + if (multiplier) { + int side_size; + const uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size); + if (side && side_size>=4) + AV_WL32(side, 2*AV_RL32(side)); + } + + if (!ac->frame->data[0] && samples) { + av_log(avctx, AV_LOG_ERROR, "no frame data found\n"); + err = AVERROR_INVALIDDATA; + goto fail; + } + + if (samples) { + ac->frame->nb_samples = samples; + ac->frame->sample_rate = avctx->sample_rate; + } else + av_frame_unref(ac->frame); + *got_frame_ptr = !!samples; + + /* for dual-mono audio (SCE + SCE) */ + is_dmono = ac->dmono_mode && sce_count == 2 && + ac->oc[1].channel_layout == (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT); + if (is_dmono) { + if (ac->dmono_mode == 1) + ((AVFrame *)data)->data[1] =((AVFrame *)data)->data[0]; + else if (ac->dmono_mode == 2) + ((AVFrame *)data)->data[0] =((AVFrame *)data)->data[1]; + } + + return 0; +fail: + pop_output_configuration(ac); + return err; +} + +static int aac_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame_ptr, AVPacket *avpkt) +{ + AACContext *ac = avctx->priv_data; + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; + GetBitContext gb; + int buf_consumed; + int buf_offset; + int err; + int new_extradata_size; + const uint8_t *new_extradata = av_packet_get_side_data(avpkt, + AV_PKT_DATA_NEW_EXTRADATA, + &new_extradata_size); + int jp_dualmono_size; + const uint8_t *jp_dualmono = av_packet_get_side_data(avpkt, + AV_PKT_DATA_JP_DUALMONO, + &jp_dualmono_size); + + if (new_extradata && 0) { + av_free(avctx->extradata); + avctx->extradata = av_mallocz(new_extradata_size + + AV_INPUT_BUFFER_PADDING_SIZE); + if (!avctx->extradata) + return AVERROR(ENOMEM); + avctx->extradata_size = new_extradata_size; + memcpy(avctx->extradata, new_extradata, new_extradata_size); + push_output_configuration(ac); + if (decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, + avctx->extradata, + avctx->extradata_size*8LL, 1) < 0) { + pop_output_configuration(ac); + return AVERROR_INVALIDDATA; + } + } + + ac->dmono_mode = 0; + if (jp_dualmono && jp_dualmono_size > 0) + ac->dmono_mode = 1 + *jp_dualmono; + if (ac->force_dmono_mode >= 0) + ac->dmono_mode = ac->force_dmono_mode; + + if (INT_MAX / 8 <= buf_size) + return AVERROR_INVALIDDATA; + + if ((err = init_get_bits8(&gb, buf, buf_size)) < 0) + return err; + + switch (ac->oc[1].m4ac.object_type) { + case AOT_ER_AAC_LC: + case AOT_ER_AAC_LTP: + case AOT_ER_AAC_LD: + case AOT_ER_AAC_ELD: + err = aac_decode_er_frame(avctx, data, got_frame_ptr, &gb); + break; + default: + err = aac_decode_frame_int(avctx, data, got_frame_ptr, &gb, avpkt); + } + if (err < 0) + return err; + + buf_consumed = (get_bits_count(&gb) + 7) >> 3; + for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++) + if (buf[buf_offset]) + break; + + return buf_size > buf_offset ? buf_consumed : buf_size; +} + +static av_cold int aac_decode_close(AVCodecContext *avctx) +{ + AACContext *ac = avctx->priv_data; + int i, type; + + for (i = 0; i < MAX_ELEM_ID; i++) { + for (type = 0; type < 4; type++) { + if (ac->che[type][i]) + AAC_RENAME(ff_aac_sbr_ctx_close)(&ac->che[type][i]->sbr); + av_freep(&ac->che[type][i]); + } + } + + ff_mdct_end(&ac->mdct); + ff_mdct_end(&ac->mdct_small); + ff_mdct_end(&ac->mdct_ld); + ff_mdct_end(&ac->mdct_ltp); +#if !USE_FIXED + ff_imdct15_uninit(&ac->mdct480); +#endif + av_freep(&ac->fdsp); + return 0; +} + +static void aacdec_init(AACContext *c) +{ + c->imdct_and_windowing = imdct_and_windowing; + c->apply_ltp = apply_ltp; + c->apply_tns = apply_tns; + c->windowing_and_mdct_ltp = windowing_and_mdct_ltp; + c->update_ltp = update_ltp; +#if USE_FIXED + c->vector_pow43 = vector_pow43; + c->subband_scale = subband_scale; +#endif + +#if !USE_FIXED + if(ARCH_MIPS) + ff_aacdec_init_mips(c); +#endif /* !USE_FIXED */ +} +/** + * AVOptions for Japanese DTV specific extensions (ADTS only) + */ +#define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM +static const AVOption options[] = { + {"dual_mono_mode", "Select the channel to decode for dual mono", + offsetof(AACContext, force_dmono_mode), AV_OPT_TYPE_INT, {.i64=-1}, -1, 2, + AACDEC_FLAGS, "dual_mono_mode"}, + + {"auto", "autoselection", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, + {"main", "Select Main/Left channel", 0, AV_OPT_TYPE_CONST, {.i64= 1}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, + {"sub" , "Select Sub/Right channel", 0, AV_OPT_TYPE_CONST, {.i64= 2}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, + {"both", "Select both channels", 0, AV_OPT_TYPE_CONST, {.i64= 0}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"}, + + {NULL}, +}; + +static const AVClass aac_decoder_class = { + .class_name = "AAC decoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const AVProfile profiles[] = { + { FF_PROFILE_AAC_MAIN, "Main" }, + { FF_PROFILE_AAC_LOW, "LC" }, + { FF_PROFILE_AAC_SSR, "SSR" }, + { FF_PROFILE_AAC_LTP, "LTP" }, + { FF_PROFILE_AAC_HE, "HE-AAC" }, + { FF_PROFILE_AAC_HE_V2, "HE-AACv2" }, + { FF_PROFILE_AAC_LD, "LD" }, + { FF_PROFILE_AAC_ELD, "ELD" }, + { FF_PROFILE_UNKNOWN }, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac_defines.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac_defines.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac_defines.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac_defines.h 2015-07-23 17:20:03.000000000 +0000 @@ -0,0 +1,114 @@ +/* + * AAC defines + * + * 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 + */ + +#ifndef AVCODEC_AAC_DEFINES_H +#define AVCODEC_AAC_DEFINES_H + +#ifndef USE_FIXED +#define USE_FIXED 0 +#endif + +#if USE_FIXED + +#include "libavutil/softfloat.h" + +#define FFT_FLOAT 0 +#define FFT_FIXED_32 1 + +#define AAC_RENAME(x) x ## _fixed +#define AAC_RENAME_32(x) x ## _fixed_32 +#define INTFLOAT int +#define INT64FLOAT int64_t +#define SHORTFLOAT int16_t +#define AAC_FLOAT SoftFloat +#define AAC_SIGNE int +#define FIXR(a) ((int)((a) * 1 + 0.5)) +#define FIXR10(a) ((int)((a) * 1024.0 + 0.5)) +#define Q23(a) (int)((a) * 8388608.0 + 0.5) +#define Q30(x) (int)((x)*1073741824.0 + 0.5) +#define Q31(x) (int)((x)*2147483648.0 + 0.5) +#define RANGE15(x) x +#define GET_GAIN(x, y) (-(y) << (x)) + 1024 +#define AAC_MUL16(x, y) (int)(((int64_t)(x) * (y) + 0x8000) >> 16) +#define AAC_MUL26(x, y) (int)(((int64_t)(x) * (y) + 0x2000000) >> 26) +#define AAC_MUL30(x, y) (int)(((int64_t)(x) * (y) + 0x20000000) >> 30) +#define AAC_MUL31(x, y) (int)(((int64_t)(x) * (y) + 0x40000000) >> 31) +#define AAC_MADD28(x, y, a, b) (int)((((int64_t)(x) * (y)) + \ + ((int64_t)(a) * (b)) + \ + 0x8000000) >> 28) +#define AAC_MADD30(x, y, a, b) (int)((((int64_t)(x) * (y)) + \ + ((int64_t)(a) * (b)) + \ + 0x20000000) >> 30) +#define AAC_MADD30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \ + ((int64_t)(a) * (b)) + \ + ((int64_t)(c) * (d)) + \ + ((int64_t)(e) * (f)) + \ + 0x20000000) >> 30) +#define AAC_MSUB30(x, y, a, b) (int)((((int64_t)(x) * (y)) - \ + ((int64_t)(a) * (b)) + \ + 0x20000000) >> 30) +#define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \ + ((int64_t)(a) * (b)) - \ + ((int64_t)(c) * (d)) - \ + ((int64_t)(e) * (f)) + \ + 0x20000000) >> 30) +#define AAC_MSUB31_V3(x, y, z) (int)((((int64_t)(x) * (z)) - \ + ((int64_t)(y) * (z)) + \ + 0x40000000) >> 31) +#define AAC_HALF_SUM(x, y) (x) >> 1 + (y) >> 1 +#define AAC_SRA_R(x, y) (int)(((x) + (1 << ((y) - 1))) >> (y)) + +#else + +#define FFT_FLOAT 1 +#define FFT_FIXED_32 0 + +#define AAC_RENAME(x) x +#define AAC_RENAME_32(x) x +#define INTFLOAT float +#define INT64FLOAT float +#define SHORTFLOAT float +#define AAC_FLOAT float +#define AAC_SIGNE unsigned +#define FIXR(x) ((float)(x)) +#define FIXR10(x) ((float)(x)) +#define Q23(x) x +#define Q30(x) x +#define Q31(x) x +#define RANGE15(x) (32768.0 * (x)) +#define GET_GAIN(x, y) powf((x), -(y)) +#define AAC_MUL16(x, y) ((x) * (y)) +#define AAC_MUL26(x, y) ((x) * (y)) +#define AAC_MUL30(x, y) ((x) * (y)) +#define AAC_MUL31(x, y) ((x) * (y)) +#define AAC_MADD28(x, y, a, b) ((x) * (y) + (a) * (b)) +#define AAC_MADD30(x, y, a, b) ((x) * (y) + (a) * (b)) +#define AAC_MADD30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) + \ + (c) * (d) + (e) * (f)) +#define AAC_MSUB30(x, y, a, b) ((x) * (y) - (a) * (b)) +#define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) - \ + (c) * (d) - (e) * (f)) +#define AAC_MSUB31_V3(x, y, z) ((x) - (y)) * (z) +#define AAC_HALF_SUM(x, y) ((x) + (y)) * 0.5f +#define AAC_SRA_R(x, y) (x) + +#endif /* USE_FIXED */ + +#endif /* AVCODEC_AAC_DEFINES_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacenc.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacenc.c 2015-08-01 17:20:02.000000000 +0000 @@ -58,7 +58,6 @@ av_log(avctx, AV_LOG_WARNING, __VA_ARGS__); \ } -float ff_aac_pow34sf_tab[428]; static const uint8_t swb_size_1024_96[] = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, @@ -312,19 +311,26 @@ static void adjust_frame_information(ChannelElement *cpe, int chans) { int i, w, w2, g, ch; - int start, maxsfb, cmaxsfb; + int maxsfb, cmaxsfb; + IndividualChannelStream *ics; - for (ch = 0; ch < chans; ch++) { - IndividualChannelStream *ics = &cpe->ch[ch].ics; - start = 0; - maxsfb = 0; - cpe->ch[ch].pulse.num_pulse = 0; + if (cpe->common_window) { + ics = &cpe->ch[0].ics; for (w = 0; w < ics->num_windows; w += ics->group_len[w]) { - for (w2 = 0; w2 < ics->group_len[w]; w2++) { - start = (w+w2) * 128; + for (w2 = 0; w2 < ics->group_len[w]; w2++) { + int start = (w+w2) * 128; for (g = 0; g < ics->num_swb; g++) { - //apply M/S - if (cpe->common_window && !ch && cpe->ms_mask[w*16 + g]) { + //apply Intensity stereo coeffs transformation + if (cpe->is_mask[w*16 + g]) { + int p = -1 + 2 * (cpe->ch[1].band_type[w*16+g] - 14); + float scale = cpe->ch[0].is_ener[w*16+g]; + for (i = 0; i < ics->swb_sizes[g]; i++) { + cpe->ch[0].coeffs[start+i] = (cpe->ch[0].pcoeffs[start+i] + p*cpe->ch[1].pcoeffs[start+i]) * scale; + cpe->ch[1].coeffs[start+i] = 0.0f; + } + } else if (cpe->ms_mask[w*16 + g] && + cpe->ch[0].band_type[w*16 + g] < NOISE_BT && + cpe->ch[1].band_type[w*16 + g] < NOISE_BT) { for (i = 0; i < ics->swb_sizes[g]; i++) { cpe->ch[0].coeffs[start+i] = (cpe->ch[0].pcoeffs[start+i] + cpe->ch[1].pcoeffs[start+i]) * 0.5f; cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].pcoeffs[start+i]; @@ -332,6 +338,16 @@ } start += ics->swb_sizes[g]; } + } + } + } + + for (ch = 0; ch < chans; ch++) { + IndividualChannelStream *ics = &cpe->ch[ch].ics; + maxsfb = 0; + cpe->ch[ch].pulse.num_pulse = 0; + for (w = 0; w < ics->num_windows; w += ics->group_len[w]) { + for (w2 = 0; w2 < ics->group_len[w]; w2++) { for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w*16+cmaxsfb-1]; cmaxsfb--) ; maxsfb = FFMAX(maxsfb, cmaxsfb); @@ -389,7 +405,7 @@ SingleChannelElement *sce) { int diff, off_sf = sce->sf_idx[0], off_pns = sce->sf_idx[0] - NOISE_OFFSET; - int noise_flag = 1; + int off_is = 0, noise_flag = 1; int i, w; for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { @@ -402,6 +418,10 @@ put_bits(&s->pb, NOISE_PRE_BITS, diff + NOISE_PRE); continue; } + } else if (sce->band_type[w*16 + i] == INTENSITY_BT || + sce->band_type[w*16 + i] == INTENSITY_BT2) { + diff = sce->sf_idx[w*16 + i] - off_is; + off_is = sce->sf_idx[w*16 + i]; } else { diff = sce->sf_idx[w*16 + i] - off_sf; off_sf = sce->sf_idx[w*16 + i]; @@ -452,13 +472,33 @@ sce->ics.swb_sizes[i], sce->sf_idx[w*16 + i], sce->band_type[w*16 + i], - s->lambda); + s->lambda, sce->ics.window_clipping[w]); start += sce->ics.swb_sizes[i]; } } } /** + * Downscale spectral coefficients for near-clipping windows to avoid artifacts + */ +static void avoid_clipping(AACEncContext *s, SingleChannelElement *sce) +{ + int start, i, j, w; + + if (sce->ics.clip_avoidance_factor < 1.0f) { + for (w = 0; w < sce->ics.num_windows; w++) { + start = 0; + for (i = 0; i < sce->ics.max_sfb; i++) { + float *swb_coeffs = sce->coeffs + start + w*128; + for (j = 0; j < sce->ics.swb_sizes[i]; j++) + swb_coeffs[j] *= sce->ics.clip_avoidance_factor; + start += sce->ics.swb_sizes[i]; + } + } + } +} + +/** * Encode one channel of audio data. */ static int encode_individual_channel(AVCodecContext *avctx, AACEncContext *s, @@ -529,7 +569,7 @@ AACEncContext *s = avctx->priv_data; float **samples = s->planar_samples, *samples2, *la, *overlap; ChannelElement *cpe; - int i, ch, w, g, chans, tag, start_ch, ret, ms_mode = 0; + int i, ch, w, g, chans, tag, start_ch, ret, ms_mode = 0, is_mode = 0; int chan_el_counter[4]; FFPsyWindowInfo windows[AAC_MAX_CHANNELS]; @@ -558,6 +598,7 @@ for (ch = 0; ch < chans; ch++) { IndividualChannelStream *ics = &cpe->ch[ch].ics; int cur_channel = start_ch + ch; + float clip_avoidance_factor; overlap = &samples[cur_channel][0]; samples2 = overlap + 1024; la = samples2 + (448+64); @@ -585,25 +626,40 @@ ics->num_windows = wi[ch].num_windows; ics->swb_sizes = s->psy.bands [ics->num_windows == 8]; ics->num_swb = tag == TYPE_LFE ? ics->num_swb : s->psy.num_bands[ics->num_windows == 8]; + clip_avoidance_factor = 0.0f; for (w = 0; w < ics->num_windows; w++) ics->group_len[w] = wi[ch].grouping[w]; + for (w = 0; w < ics->num_windows; w++) { + if (wi[ch].clipping[w] > CLIP_AVOIDANCE_FACTOR) { + ics->window_clipping[w] = 1; + clip_avoidance_factor = FFMAX(clip_avoidance_factor, wi[ch].clipping[w]); + } else { + ics->window_clipping[w] = 0; + } + } + if (clip_avoidance_factor > CLIP_AVOIDANCE_FACTOR) { + ics->clip_avoidance_factor = CLIP_AVOIDANCE_FACTOR / clip_avoidance_factor; + } else { + ics->clip_avoidance_factor = 1.0f; + } apply_window_and_mdct(s, &cpe->ch[ch], overlap); if (isnan(cpe->ch->coeffs[0])) { av_log(avctx, AV_LOG_ERROR, "Input contains NaN\n"); return AVERROR(EINVAL); } + avoid_clipping(s, &cpe->ch[ch]); } start_ch += chans; } - if ((ret = ff_alloc_packet2(avctx, avpkt, 8192 * s->channels)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, 8192 * s->channels, 0)) < 0) return ret; do { int frame_bits; init_put_bits(&s->pb, avpkt->data, avpkt->size); - if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT)) + if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & AV_CODEC_FLAG_BITEXACT)) put_bitstream_info(s, LIBAVCODEC_IDENT); start_ch = 0; memset(chan_el_counter, 0, sizeof(chan_el_counter)); @@ -613,6 +669,8 @@ tag = s->chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; + memset(cpe->is_mask, 0, sizeof(cpe->is_mask)); + memset(cpe->ms_mask, 0, sizeof(cpe->ms_mask)); put_bits(&s->pb, 3, tag); put_bits(&s->pb, 4, chan_el_counter[tag]++); for (ch = 0; ch < chans; ch++) @@ -635,6 +693,12 @@ } } } + if (s->options.pns && s->coder->search_for_pns) { + for (ch = 0; ch < chans; ch++) { + s->cur_channel = start_ch + ch; + s->coder->search_for_pns(s, avctx, &cpe->ch[ch]); + } + } s->cur_channel = start_ch; if (s->options.stereo_mode && cpe->common_window) { if (s->options.stereo_mode > 0) { @@ -643,9 +707,16 @@ for (g = 0; g < ics->num_swb; g++) cpe->ms_mask[w*16+g] = 1; } else if (s->coder->search_for_ms) { - s->coder->search_for_ms(s, cpe, s->lambda); + s->coder->search_for_ms(s, cpe); } } + if (chans > 1 && s->options.intensity_stereo && s->coder->search_for_is) { + s->coder->search_for_is(s, avctx, cpe); + if (cpe->is_mode) is_mode = 1; + } + if (s->coder->set_special_band_scalefactors) + for (ch = 0; ch < chans; ch++) + s->coder->set_special_band_scalefactors(s, &cpe->ch[ch]); adjust_frame_information(cpe, chans); if (chans == 2) { put_bits(&s->pb, 1, cpe->common_window); @@ -667,7 +738,7 @@ s->psy.bitres.bits = frame_bits / s->channels; break; } - if (ms_mode) { + if (is_mode || ms_mode) { for (i = 0; i < s->chan_map[0]; i++) { // Must restore coeffs chans = tag == TYPE_CPE ? 2 : 1; @@ -686,7 +757,7 @@ avctx->frame_bits = put_bits_count(&s->pb); // rate control stuff - if (!(avctx->flags & CODEC_FLAG_QSCALE)) { + if (!(avctx->flags & AV_CODEC_FLAG_QSCALE)) { float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits; s->lambda *= ratio; s->lambda = FFMIN(s->lambda, 65536.f); @@ -723,7 +794,7 @@ { int ret = 0; - s->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!s->fdsp) return AVERROR(ENOMEM); @@ -746,7 +817,7 @@ int ch; FF_ALLOCZ_ARRAY_OR_GOTO(avctx, s->buffer.samples, s->channels, 3 * 1024 * sizeof(s->buffer.samples[0]), alloc_fail); FF_ALLOCZ_ARRAY_OR_GOTO(avctx, s->cpe, s->chan_map[0], sizeof(ChannelElement), alloc_fail); - FF_ALLOCZ_OR_GOTO(avctx, avctx->extradata, 5 + FF_INPUT_BUFFER_PADDING_SIZE, alloc_fail); + FF_ALLOCZ_OR_GOTO(avctx, avctx->extradata, 5 + AV_INPUT_BUFFER_PADDING_SIZE, alloc_fail); for(ch = 0; ch < s->channels; ch++) s->planar_samples[ch] = s->buffer.samples + 3 * 1024 * ch; @@ -819,9 +890,6 @@ ff_aac_tableinit(); - for (i = 0; i < 428; i++) - ff_aac_pow34sf_tab[i] = sqrt(ff_aac_pow2sf_tab[i] * sqrt(ff_aac_pow2sf_tab[i])); - avctx->initial_padding = 1024; ff_af_queue_init(avctx, &s->afq); @@ -837,14 +905,17 @@ {"auto", "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.i64 = -1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"}, {"ms_off", "Disable Mid/Side coding", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"}, {"ms_force", "Force Mid/Side for the whole frame if possible", 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"}, - {"aac_coder", "", offsetof(AACEncContext, options.aac_coder), AV_OPT_TYPE_INT, {.i64 = AAC_CODER_TWOLOOP}, 0, AAC_CODER_NB-1, AACENC_FLAGS, "aac_coder"}, + {"aac_coder", "Coding algorithm", offsetof(AACEncContext, options.aac_coder), AV_OPT_TYPE_INT, {.i64 = AAC_CODER_TWOLOOP}, 0, AAC_CODER_NB-1, AACENC_FLAGS, "aac_coder"}, {"faac", "FAAC-inspired method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_FAAC}, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_coder"}, {"anmr", "ANMR method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_ANMR}, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_coder"}, {"twoloop", "Two loop searching method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_TWOLOOP}, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_coder"}, {"fast", "Constant quantizer", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_FAST}, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_coder"}, {"aac_pns", "Perceptual Noise Substitution", offsetof(AACEncContext, options.pns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, AACENC_FLAGS, "aac_pns"}, - {"disable", "Disable PNS", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_pns"}, - {"enable", "Enable PNS (Proof of concept)", 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_pns"}, + {"disable", "Disable perceptual noise substitution", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_pns"}, + {"enable", "Enable perceptual noise substitution", 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "aac_pns"}, + {"aac_is", "Intensity stereo coding", offsetof(AACEncContext, options.intensity_stereo), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, AACENC_FLAGS, "intensity_stereo"}, + {"disable", "Disable intensity stereo coding", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, INT_MIN, INT_MAX, AACENC_FLAGS, "intensity_stereo"}, + {"enable", "Enable intensity stereo coding", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, INT_MIN, INT_MAX, AACENC_FLAGS, "intensity_stereo"}, {NULL} }; @@ -872,8 +943,8 @@ .encode2 = aac_encode_frame, .close = aac_encode_end, .supported_samplerates = mpeg4audio_sample_rates, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY | - CODEC_CAP_EXPERIMENTAL, + .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_EXPERIMENTAL, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, .priv_class = &aacenc_class, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacenc.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacenc.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacenc.h 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacenc.h 2015-08-01 17:20:02.000000000 +0000 @@ -43,6 +43,7 @@ int stereo_mode; int aac_coder; int pns; + int intensity_stereo; } AACEncOptions; struct AACEncContext; @@ -53,8 +54,11 @@ void (*encode_window_bands_info)(struct AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda); void (*quantize_and_encode_band)(struct AACEncContext *s, PutBitContext *pb, const float *in, int size, - int scale_idx, int cb, const float lambda); - void (*search_for_ms)(struct AACEncContext *s, ChannelElement *cpe, const float lambda); + int scale_idx, int cb, const float lambda, int rtz); + void (*set_special_band_scalefactors)(struct AACEncContext *s, SingleChannelElement *sce); + void (*search_for_pns)(struct AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce); + void (*search_for_ms)(struct AACEncContext *s, ChannelElement *cpe); + void (*search_for_is)(struct AACEncContext *s, AVCodecContext *avctx, ChannelElement *cpe); } AACCoefficientsEncoder; extern AACCoefficientsEncoder ff_aac_coders[]; @@ -91,8 +95,6 @@ } buffer; } AACEncContext; -extern float ff_aac_pow34sf_tab[428]; - void ff_aac_coder_init_mips(AACEncContext *c); #endif /* AVCODEC_AACENC_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac.h 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac.h 2015-07-28 17:20:07.000000000 +0000 @@ -30,9 +30,14 @@ #ifndef AVCODEC_AAC_H #define AVCODEC_AAC_H + +#include "aac_defines.h" #include "libavutil/float_dsp.h" +#include "libavutil/fixed_dsp.h" #include "avcodec.h" +#if !USE_FIXED #include "imdct15.h" +#endif #include "fft.h" #include "mpeg4audio.h" #include "sbr.h" @@ -45,6 +50,8 @@ #define TNS_MAX_ORDER 20 #define MAX_LTP_LONG_SFB 40 +#define CLIP_AVOIDANCE_FACTOR 0.95f + enum RawDataBlockType { TYPE_SCE, TYPE_CPE, @@ -76,9 +83,10 @@ ZERO_BT = 0, ///< Scalefactors and spectral data are all zero. FIRST_PAIR_BT = 5, ///< This and later band types encode two values (rather than four) with one code word. ESC_BT = 11, ///< Spectral data are coded with an escape sequence. + RESERVED_BT = 12, ///< Band types following are encoded differently from others. NOISE_BT = 13, ///< Spectral data are scaled white noise not coded in the bitstream. - INTENSITY_BT2 = 14, ///< Scalefactor data are intensity stereo positions. - INTENSITY_BT = 15, ///< Scalefactor data are intensity stereo positions. + INTENSITY_BT2 = 14, ///< Scalefactor data are intensity stereo positions (out of phase). + INTENSITY_BT = 15, ///< Scalefactor data are intensity stereo positions (in phase). }; #define IS_CODEBOOK_UNSIGNED(x) (((x) - 1) & 10) @@ -125,12 +133,12 @@ * Predictor State */ typedef struct PredictorState { - float cor0; - float cor1; - float var0; - float var1; - float r0; - float r1; + AAC_FLOAT cor0; + AAC_FLOAT cor1; + AAC_FLOAT var0; + AAC_FLOAT var1; + AAC_FLOAT r0; + AAC_FLOAT r1; } PredictorState; #define MAX_PREDICTORS 672 @@ -151,7 +159,7 @@ typedef struct LongTermPrediction { int8_t present; int16_t lag; - float coef; + INTFLOAT coef; int8_t used[MAX_LTP_LONG_SFB]; } LongTermPrediction; @@ -174,6 +182,8 @@ int predictor_initialized; int predictor_reset_group; uint8_t prediction_used[41]; + uint8_t window_clipping[8]; ///< set if a certain window is near clipping + float clip_avoidance_factor; ///< set if any window is near clipping to the necessary atennuation factor to avoid it } IndividualChannelStream; /** @@ -185,7 +195,7 @@ int length[8][4]; int direction[8][4]; int order[8][4]; - float coef[8][4][TNS_MAX_ORDER]; + INTFLOAT coef[8][4][TNS_MAX_ORDER]; } TemporalNoiseShaping; /** @@ -222,7 +232,7 @@ int ch_select[8]; /**< [0] shared list of gains; [1] list of gains for right channel; * [2] list of gains for left channel; [3] lists of gains for both channels */ - float gain[16][120]; + INTFLOAT gain[16][120]; } ChannelCoupling; /** @@ -234,16 +244,18 @@ Pulse pulse; enum BandType band_type[128]; ///< band types int band_type_run_end[120]; ///< band type run end points - float sf[120]; ///< scalefactors + INTFLOAT sf[120]; ///< scalefactors int sf_idx[128]; ///< scalefactor indices (used by encoder) uint8_t zeroes[128]; ///< band is not coded (used by encoder) - DECLARE_ALIGNED(32, float, pcoeffs)[1024]; ///< coefficients for IMDCT, pristine - DECLARE_ALIGNED(32, float, coeffs)[1024]; ///< coefficients for IMDCT, maybe processed - DECLARE_ALIGNED(32, float, saved)[1536]; ///< overlap - DECLARE_ALIGNED(32, float, ret_buf)[2048]; ///< PCM output buffer - DECLARE_ALIGNED(16, float, ltp_state)[3072]; ///< time signal for LTP + float is_ener[128]; ///< Intensity stereo pos (used by encoder) + float pns_ener[128]; ///< Noise energy values (used by encoder) + DECLARE_ALIGNED(32, INTFLOAT, pcoeffs)[1024]; ///< coefficients for IMDCT, pristine + DECLARE_ALIGNED(32, INTFLOAT, coeffs)[1024]; ///< coefficients for IMDCT, maybe processed + DECLARE_ALIGNED(32, INTFLOAT, saved)[1536]; ///< overlap + DECLARE_ALIGNED(32, INTFLOAT, ret_buf)[2048]; ///< PCM output buffer + DECLARE_ALIGNED(16, INTFLOAT, ltp_state)[3072]; ///< time signal for LTP PredictorState predictor_state[MAX_PREDICTORS]; - float *ret; ///< PCM output + INTFLOAT *ret; ///< PCM output } SingleChannelElement; /** @@ -254,7 +266,9 @@ // CPE specific int common_window; ///< Set if channels share a common 'IndividualChannelStream' in bitstream. int ms_mode; ///< Signals mid/side stereo flags coding mode (used by encoder) + uint8_t is_mode; ///< Set if any bands have been encoded using intensity stereo (used by encoder) uint8_t ms_mask[128]; ///< Set if mid/side stereo is used for each scalefactor window band + uint8_t is_mask[128]; ///< Set if intensity stereo is used (used by encoder) // shared SingleChannelElement ch[2]; // CCE specific @@ -288,7 +302,7 @@ * (We do not want to have these on the stack.) * @{ */ - DECLARE_ALIGNED(32, float, buf_mdct)[1024]; + DECLARE_ALIGNED(32, INTFLOAT, buf_mdct)[1024]; /** @} */ /** @@ -299,8 +313,12 @@ FFTContext mdct_small; FFTContext mdct_ld; FFTContext mdct_ltp; +#if USE_FIXED + AVFixedDSPContext *fdsp; +#else IMDCT15Context *mdct480; AVFloatDSPContext *fdsp; +#endif /* USE_FIXED */ int random_state; /** @} */ @@ -320,7 +338,7 @@ int dmono_mode; ///< 0->not dmono, 1->use first channel, 2->use second channel /** @} */ - DECLARE_ALIGNED(32, float, temp)[128]; + DECLARE_ALIGNED(32, INTFLOAT, temp)[128]; OutputConfiguration oc[2]; int warned_num_aac_frames; @@ -328,11 +346,13 @@ /* aacdec functions pointers */ void (*imdct_and_windowing)(AACContext *ac, SingleChannelElement *sce); void (*apply_ltp)(AACContext *ac, SingleChannelElement *sce); - void (*apply_tns)(float coef[1024], TemporalNoiseShaping *tns, + void (*apply_tns)(INTFLOAT coef[1024], TemporalNoiseShaping *tns, IndividualChannelStream *ics, int decode); - void (*windowing_and_mdct_ltp)(AACContext *ac, float *out, - float *in, IndividualChannelStream *ics); + void (*windowing_and_mdct_ltp)(AACContext *ac, INTFLOAT *out, + INTFLOAT *in, IndividualChannelStream *ics); void (*update_ltp)(AACContext *ac, SingleChannelElement *sce); + void (*vector_pow43)(int *coefs, int len); + void (*subband_scale)(int *dst, int *src, int scale, int offset, int len); }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac_parser.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac_parser.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac_parser.c 2015-03-13 17:34:43.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac_parser.c 2015-07-28 17:20:07.000000000 +0000 @@ -34,7 +34,7 @@ int size; union { uint64_t u64; - uint8_t u8[8 + FF_INPUT_BUFFER_PADDING_SIZE]; + uint8_t u8[8 + AV_INPUT_BUFFER_PADDING_SIZE]; } tmp; tmp.u64 = av_be2ne64(state); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps.c 2015-07-31 17:20:05.000000000 +0000 @@ -17,16 +17,23 @@ * 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 + * + * Note: Rounding-to-nearest used unless otherwise stated + * */ #include #include "libavutil/common.h" -#include "libavutil/internal.h" #include "libavutil/mathematics.h" #include "avcodec.h" #include "get_bits.h" #include "aacps.h" +#if USE_FIXED +#include "aacps_fixed_tablegen.h" +#else +#include "libavutil/internal.h" #include "aacps_tablegen.h" +#endif /* USE_FIXED */ #include "aacpsdata.c" #define PS_BASELINE 0 ///< Operate in Baseline PS mode @@ -148,7 +155,7 @@ } } -int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left) +int AAC_RENAME(ff_ps_read_data)(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left) { int e; int bit_count_start = get_bits_count(gb_host); @@ -302,35 +309,41 @@ /** Split one subband into 2 subsubbands with a symmetric real filter. * The filter must have its non-center even coefficients equal to zero. */ -static void hybrid2_re(float (*in)[2], float (*out)[32][2], const float filter[8], int len, int reverse) +static void hybrid2_re(INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], const INTFLOAT filter[8], int len, int reverse) { int i, j; for (i = 0; i < len; i++, in++) { - float re_in = filter[6] * in[6][0]; //real inphase - float re_op = 0.0f; //real out of phase - float im_in = filter[6] * in[6][1]; //imag inphase - float im_op = 0.0f; //imag out of phase + INT64FLOAT re_in = AAC_MUL31(filter[6], in[6][0]); //real inphase + INT64FLOAT re_op = 0.0f; //real out of phase + INT64FLOAT im_in = AAC_MUL31(filter[6], in[6][1]); //imag inphase + INT64FLOAT im_op = 0.0f; //imag out of phase for (j = 0; j < 6; j += 2) { - re_op += filter[j+1] * (in[j+1][0] + in[12-j-1][0]); - im_op += filter[j+1] * (in[j+1][1] + in[12-j-1][1]); + re_op += (INT64FLOAT)filter[j+1] * (in[j+1][0] + in[12-j-1][0]); + im_op += (INT64FLOAT)filter[j+1] * (in[j+1][1] + in[12-j-1][1]); } - out[ reverse][i][0] = re_in + re_op; - out[ reverse][i][1] = im_in + im_op; - out[!reverse][i][0] = re_in - re_op; - out[!reverse][i][1] = im_in - im_op; + +#if USE_FIXED + re_op = (re_op + 0x40000000) >> 31; + im_op = (im_op + 0x40000000) >> 31; +#endif /* USE_FIXED */ + + out[ reverse][i][0] = (INTFLOAT)(re_in + re_op); + out[ reverse][i][1] = (INTFLOAT)(im_in + im_op); + out[!reverse][i][0] = (INTFLOAT)(re_in - re_op); + out[!reverse][i][1] = (INTFLOAT)(im_in - im_op); } } /** Split one subband into 6 subsubbands with a complex filter */ -static void hybrid6_cx(PSDSPContext *dsp, float (*in)[2], float (*out)[32][2], - TABLE_CONST float (*filter)[8][2], int len) +static void hybrid6_cx(PSDSPContext *dsp, INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], + TABLE_CONST INTFLOAT (*filter)[8][2], int len) { int i; int N = 8; - LOCAL_ALIGNED_16(float, temp, [8], [2]); + LOCAL_ALIGNED_16(INTFLOAT, temp, [8], [2]); for (i = 0; i < len; i++, in++) { - dsp->hybrid_analysis(temp, in, (const float (*)[8][2]) filter, 1, N); + dsp->hybrid_analysis(temp, in, (const INTFLOAT (*)[8][2]) filter, 1, N); out[0][i][0] = temp[6][0]; out[0][i][1] = temp[6][1]; out[1][i][0] = temp[7][0]; @@ -347,18 +360,18 @@ } static void hybrid4_8_12_cx(PSDSPContext *dsp, - float (*in)[2], float (*out)[32][2], - TABLE_CONST float (*filter)[8][2], int N, int len) + INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], + TABLE_CONST INTFLOAT (*filter)[8][2], int N, int len) { int i; for (i = 0; i < len; i++, in++) { - dsp->hybrid_analysis(out[0] + i, in, (const float (*)[8][2]) filter, 32, N); + dsp->hybrid_analysis(out[0] + i, in, (const INTFLOAT (*)[8][2]) filter, 32, N); } } -static void hybrid_analysis(PSDSPContext *dsp, float out[91][32][2], - float in[5][44][2], float L[2][38][64], +static void hybrid_analysis(PSDSPContext *dsp, INTFLOAT out[91][32][2], + INTFLOAT in[5][44][2], INTFLOAT L[2][38][64], int is34, int len) { int i, j; @@ -387,8 +400,8 @@ } } -static void hybrid_synthesis(PSDSPContext *dsp, float out[2][38][64], - float in[91][32][2], int is34, int len) +static void hybrid_synthesis(PSDSPContext *dsp, INTFLOAT out[2][38][64], + INTFLOAT in[91][32][2], int is34, int len) { int i, n; if (is34) { @@ -429,7 +442,7 @@ } /// All-pass filter decay slope -#define DECAY_SLOPE 0.05f +#define DECAY_SLOPE Q30(0.05f) /// Number of frequency bands that can be addressed by the parameter index, b(k) static const int NR_PAR_BANDS[] = { 20, 34 }; static const int NR_IPDOPD_BANDS[] = { 11, 17 }; @@ -483,28 +496,43 @@ } } -static void map_val_34_to_20(float par[PS_MAX_NR_IIDICC]) +static void map_val_34_to_20(INTFLOAT par[PS_MAX_NR_IIDICC]) { +#if USE_FIXED + par[ 0] = (int)(((int64_t)(par[ 0] + (par[ 1]>>1)) * 1431655765 + \ + 0x40000000) >> 31); + par[ 1] = (int)(((int64_t)((par[ 1]>>1) + par[ 2]) * 1431655765 + \ + 0x40000000) >> 31); + par[ 2] = (int)(((int64_t)(par[ 3] + (par[ 4]>>1)) * 1431655765 + \ + 0x40000000) >> 31); + par[ 3] = (int)(((int64_t)((par[ 4]>>1) + par[ 5]) * 1431655765 + \ + 0x40000000) >> 31); +#else par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f; par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f; par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f; par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333f; - par[ 4] = ( par[ 6] + par[ 7]) * 0.5f; - par[ 5] = ( par[ 8] + par[ 9]) * 0.5f; +#endif /* USE_FIXED */ + par[ 4] = AAC_HALF_SUM(par[ 6], par[ 7]); + par[ 5] = AAC_HALF_SUM(par[ 8], par[ 9]); par[ 6] = par[10]; par[ 7] = par[11]; - par[ 8] = ( par[12] + par[13]) * 0.5f; - par[ 9] = ( par[14] + par[15]) * 0.5f; + par[ 8] = AAC_HALF_SUM(par[12], par[13]); + par[ 9] = AAC_HALF_SUM(par[14], par[15]); par[10] = par[16]; par[11] = par[17]; par[12] = par[18]; par[13] = par[19]; - par[14] = ( par[20] + par[21]) * 0.5f; - par[15] = ( par[22] + par[23]) * 0.5f; - par[16] = ( par[24] + par[25]) * 0.5f; - par[17] = ( par[26] + par[27]) * 0.5f; + par[14] = AAC_HALF_SUM(par[20], par[21]); + par[15] = AAC_HALF_SUM(par[22], par[23]); + par[16] = AAC_HALF_SUM(par[24], par[25]); + par[17] = AAC_HALF_SUM(par[26], par[27]); +#if USE_FIXED + par[18] = (((par[28]+2)>>2) + ((par[29]+2)>>2) + ((par[30]+2)>>2) + ((par[31]+2)>>2)); +#else par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f; - par[19] = ( par[32] + par[33]) * 0.5f; +#endif /* USE_FIXED */ + par[19] = AAC_HALF_SUM(par[32], par[33]); } static void map_idx_10_to_34(int8_t *par_mapped, const int8_t *par, int full) @@ -589,7 +617,7 @@ par_mapped[ 0] = par[ 0]; } -static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC]) +static void map_val_20_to_34(INTFLOAT par[PS_MAX_NR_IIDICC]) { par[33] = par[19]; par[32] = par[19]; @@ -620,27 +648,29 @@ par[ 7] = par[ 4]; par[ 6] = par[ 4]; par[ 5] = par[ 3]; - par[ 4] = (par[ 2] + par[ 3]) * 0.5f; + par[ 4] = AAC_HALF_SUM(par[ 2], par[ 3]); par[ 3] = par[ 2]; par[ 2] = par[ 1]; - par[ 1] = (par[ 0] + par[ 1]) * 0.5f; + par[ 1] = AAC_HALF_SUM(par[ 0], par[ 1]); } -static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[32][2], int is34) +static void decorrelation(PSContext *ps, INTFLOAT (*out)[32][2], const INTFLOAT (*s)[32][2], int is34) { - LOCAL_ALIGNED_16(float, power, [34], [PS_QMF_TIME_SLOTS]); - LOCAL_ALIGNED_16(float, transient_gain, [34], [PS_QMF_TIME_SLOTS]); - float *peak_decay_nrg = ps->peak_decay_nrg; - float *power_smooth = ps->power_smooth; - float *peak_decay_diff_smooth = ps->peak_decay_diff_smooth; - float (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay; - float (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay; - const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; - const float peak_decay_factor = 0.76592833836465f; + LOCAL_ALIGNED_16(INTFLOAT, power, [34], [PS_QMF_TIME_SLOTS]); + LOCAL_ALIGNED_16(INTFLOAT, transient_gain, [34], [PS_QMF_TIME_SLOTS]); + INTFLOAT *peak_decay_nrg = ps->peak_decay_nrg; + INTFLOAT *power_smooth = ps->power_smooth; + INTFLOAT *peak_decay_diff_smooth = ps->peak_decay_diff_smooth; + INTFLOAT (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay; + INTFLOAT (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay; +#if !USE_FIXED const float transient_impact = 1.5f; const float a_smooth = 0.25f; ///< Smoothing coefficient +#endif /* USE_FIXED */ + const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; int i, k, m, n; int n0 = 0, nL = 32; + const INTFLOAT peak_decay_factor = Q31(0.76592833836465f); memset(power, 0, 34 * sizeof(*power)); @@ -658,6 +688,33 @@ } //Transient detection +#if USE_FIXED + for (i = 0; i < NR_PAR_BANDS[is34]; i++) { + for (n = n0; n < nL; n++) { + int decayed_peak; + int denom; + + decayed_peak = (int)(((int64_t)peak_decay_factor * \ + peak_decay_nrg[i] + 0x40000000) >> 31); + peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]); + power_smooth[i] += (power[i][n] - power_smooth[i] + 2) >> 2; + peak_decay_diff_smooth[i] += (peak_decay_nrg[i] - power[i][n] - \ + peak_decay_diff_smooth[i] + 2) >> 2; + denom = peak_decay_diff_smooth[i] + (peak_decay_diff_smooth[i] >> 1); + if (denom > power_smooth[i]) { + int p = power_smooth[i]; + while (denom < 0x40000000) { + denom <<= 1; + p <<= 1; + } + transient_gain[i][n] = p / (denom >> 16); + } + else { + transient_gain[i][n] = 1 << 16; + } + } + } +#else for (i = 0; i < NR_PAR_BANDS[is34]; i++) { for (n = n0; n < nL; n++) { float decayed_peak = peak_decay_factor * peak_decay_nrg[i]; @@ -671,6 +728,7 @@ } } +#endif /* USE_FIXED */ //Decorrelation and transient reduction // PS_AP_LINKS - 1 // ----- @@ -681,8 +739,22 @@ //d[k][z] (out) = transient_gain_mapped[k][z] * H[k][z] * s[k][z] for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) { int b = k_to_i[k]; +#if USE_FIXED + int g_decay_slope; + + if (k - DECAY_CUTOFF[is34] <= 0) { + g_decay_slope = 1 << 30; + } + else if (k - DECAY_CUTOFF[is34] >= 20) { + g_decay_slope = 0; + } + else { + g_decay_slope = (1 << 30) - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]); + } +#else float g_decay_slope = 1.f - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]); g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f); +#endif /* USE_FIXED */ memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0])); memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0])); for (m = 0; m < PS_AP_LINKS; m++) { @@ -690,7 +762,7 @@ } ps->dsp.decorrelate(out[k], delay[k] + PS_MAX_DELAY - 2, ap_delay[k], phi_fract[is34][k], - (const float (*)[2]) Q_fract_allpass[is34][k], + (const INTFLOAT (*)[2]) Q_fract_allpass[is34][k], transient_gain[b], g_decay_slope, nL - n0); } for (; k < SHORT_DELAY_BAND[is34]; k++) { @@ -749,14 +821,14 @@ } } -static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34) +static void stereo_processing(PSContext *ps, INTFLOAT (*l)[32][2], INTFLOAT (*r)[32][2], int is34) { int e, b, k; - float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11; - float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12; - float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21; - float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22; + INTFLOAT (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11; + INTFLOAT (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12; + INTFLOAT (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21; + INTFLOAT (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22; int8_t *opd_hist = ps->opd_hist; int8_t *ipd_hist = ps->ipd_hist; int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; @@ -768,7 +840,7 @@ int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf; int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf; const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; - TABLE_CONST float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; + TABLE_CONST INTFLOAT (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; //Remapping if (ps->num_env_old) { @@ -823,7 +895,7 @@ //Mixing for (e = 0; e < ps->num_env; e++) { for (b = 0; b < NR_PAR_BANDS[is34]; b++) { - float h11, h12, h21, h22; + INTFLOAT h11, h12, h21, h22; h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0]; h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1]; h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2]; @@ -832,27 +904,27 @@ if (!PS_BASELINE && ps->enable_ipdopd && b < NR_IPDOPD_BANDS[is34]) { //The spec say says to only run this smoother when enable_ipdopd //is set but the reference decoder appears to run it constantly - float h11i, h12i, h21i, h22i; - float ipd_adj_re, ipd_adj_im; + INTFLOAT h11i, h12i, h21i, h22i; + INTFLOAT ipd_adj_re, ipd_adj_im; int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b]; int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b]; - float opd_re = pd_re_smooth[opd_idx]; - float opd_im = pd_im_smooth[opd_idx]; - float ipd_re = pd_re_smooth[ipd_idx]; - float ipd_im = pd_im_smooth[ipd_idx]; + INTFLOAT opd_re = pd_re_smooth[opd_idx]; + INTFLOAT opd_im = pd_im_smooth[opd_idx]; + INTFLOAT ipd_re = pd_re_smooth[ipd_idx]; + INTFLOAT ipd_im = pd_im_smooth[ipd_idx]; opd_hist[b] = opd_idx & 0x3F; ipd_hist[b] = ipd_idx & 0x3F; - ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im; - ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im; - h11i = h11 * opd_im; - h11 = h11 * opd_re; - h12i = h12 * ipd_adj_im; - h12 = h12 * ipd_adj_re; - h21i = h21 * opd_im; - h21 = h21 * opd_re; - h22i = h22 * ipd_adj_im; - h22 = h22 * ipd_adj_re; + ipd_adj_re = AAC_MADD30(opd_re, ipd_re, opd_im, ipd_im); + ipd_adj_im = AAC_MSUB30(opd_im, ipd_re, opd_re, ipd_im); + h11i = AAC_MUL30(h11, opd_im); + h11 = AAC_MUL30(h11, opd_re); + h12i = AAC_MUL30(h12, ipd_adj_im); + h12 = AAC_MUL30(h12, ipd_adj_re); + h21i = AAC_MUL30(h21, opd_im); + h21 = AAC_MUL30(h21, opd_re); + h22i = AAC_MUL30(h22, ipd_adj_im); + h22 = AAC_MUL30(h22, ipd_adj_re); H11[1][e+1][b] = h11i; H12[1][e+1][b] = h12i; H21[1][e+1][b] = h21i; @@ -864,11 +936,14 @@ H22[0][e+1][b] = h22; } for (k = 0; k < NR_BANDS[is34]; k++) { - float h[2][4]; - float h_step[2][4]; + LOCAL_ALIGNED_16(INTFLOAT, h, [2], [4]); + LOCAL_ALIGNED_16(INTFLOAT, h_step, [2], [4]); int start = ps->border_position[e]; int stop = ps->border_position[e+1]; - float width = 1.f / (stop - start); + INTFLOAT width = Q30(1.f) / (stop - start); +#if USE_FIXED + width <<= 1; +#endif b = k_to_i[k]; h[0][0] = H11[0][e][b]; h[0][1] = H12[0][e][b]; @@ -889,15 +964,15 @@ } } //Interpolation - h_step[0][0] = (H11[0][e+1][b] - h[0][0]) * width; - h_step[0][1] = (H12[0][e+1][b] - h[0][1]) * width; - h_step[0][2] = (H21[0][e+1][b] - h[0][2]) * width; - h_step[0][3] = (H22[0][e+1][b] - h[0][3]) * width; + h_step[0][0] = AAC_MSUB31_V3(H11[0][e+1][b], h[0][0], width); + h_step[0][1] = AAC_MSUB31_V3(H12[0][e+1][b], h[0][1], width); + h_step[0][2] = AAC_MSUB31_V3(H21[0][e+1][b], h[0][2], width); + h_step[0][3] = AAC_MSUB31_V3(H22[0][e+1][b], h[0][3], width); if (!PS_BASELINE && ps->enable_ipdopd) { - h_step[1][0] = (H11[1][e+1][b] - h[1][0]) * width; - h_step[1][1] = (H12[1][e+1][b] - h[1][1]) * width; - h_step[1][2] = (H21[1][e+1][b] - h[1][2]) * width; - h_step[1][3] = (H22[1][e+1][b] - h[1][3]) * width; + h_step[1][0] = AAC_MSUB31_V3(H11[1][e+1][b], h[1][0], width); + h_step[1][1] = AAC_MSUB31_V3(H12[1][e+1][b], h[1][1], width); + h_step[1][2] = AAC_MSUB31_V3(H21[1][e+1][b], h[1][2], width); + h_step[1][3] = AAC_MSUB31_V3(H22[1][e+1][b], h[1][3], width); } ps->dsp.stereo_interpolate[!PS_BASELINE && ps->enable_ipdopd]( l[k] + start + 1, r[k] + start + 1, @@ -906,10 +981,10 @@ } } -int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top) +int AAC_RENAME(ff_ps_apply)(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top) { - float (*Lbuf)[32][2] = ps->Lbuf; - float (*Rbuf)[32][2] = ps->Rbuf; + INTFLOAT (*Lbuf)[32][2] = ps->Lbuf; + INTFLOAT (*Rbuf)[32][2] = ps->Rbuf; const int len = 32; int is34 = ps->is34bands; @@ -919,7 +994,7 @@ memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*sizeof(ps->ap_delay[0])); hybrid_analysis(&ps->dsp, Lbuf, ps->in_buf, L, is34, len); - decorrelation(ps, Rbuf, (const float (*)[32][2]) Lbuf, is34); + decorrelation(ps, Rbuf, (const INTFLOAT (*)[32][2]) Lbuf, is34); stereo_processing(ps, Lbuf, Rbuf, is34); hybrid_synthesis(&ps->dsp, L, Lbuf, is34, len); hybrid_synthesis(&ps->dsp, R, Rbuf, is34, len); @@ -936,7 +1011,7 @@ #define PS_VLC_ROW(name) \ { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) } -av_cold void ff_ps_init(void) { +av_cold void AAC_RENAME(ff_ps_init)(void) { // Syntax initialization static const struct { const void *ps_codes, *ps_bits; @@ -968,7 +1043,7 @@ ps_tableinit(); } -av_cold void ff_ps_ctx_init(PSContext *ps) +av_cold void AAC_RENAME(ff_ps_ctx_init)(PSContext *ps) { - ff_psdsp_init(&ps->dsp); + AAC_RENAME(ff_psdsp_init)(&ps->dsp); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsdata.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsdata.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsdata.c 2014-12-01 00:21:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsdata.c 2015-07-23 17:20:03.000000000 +0000 @@ -157,7 +157,7 @@ 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }; -static const float g1_Q2[] = { - 0.0f, 0.01899487526049f, 0.0f, -0.07293139167538f, - 0.0f, 0.30596630545168f, 0.5f +static const INTFLOAT g1_Q2[] = { + Q31(0.0f), Q31(0.01899487526049f), Q31(0.0f), Q31(-0.07293139167538f), + Q31(0.0f), Q31(0.30596630545168f), Q31(0.5f) }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsdsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsdsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsdsp.c 2015-06-18 18:54:56.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsdsp.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2010 Alex Converse - * - * 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 "config.h" -#include "libavutil/attributes.h" -#include "aacpsdsp.h" - -static void ps_add_squares_c(float *dst, const float (*src)[2], int n) -{ - int i; - for (i = 0; i < n; i++) - dst[i] += src[i][0] * src[i][0] + src[i][1] * src[i][1]; -} - -static void ps_mul_pair_single_c(float (*dst)[2], float (*src0)[2], float *src1, - int n) -{ - int i; - for (i = 0; i < n; i++) { - dst[i][0] = src0[i][0] * src1[i]; - dst[i][1] = src0[i][1] * src1[i]; - } -} - -static void ps_hybrid_analysis_c(float (*out)[2], float (*in)[2], - const float (*filter)[8][2], - int stride, int n) -{ - int i, j; - - for (i = 0; i < n; i++) { - float sum_re = filter[i][6][0] * in[6][0]; - float sum_im = filter[i][6][0] * in[6][1]; - - for (j = 0; j < 6; j++) { - float in0_re = in[j][0]; - float in0_im = in[j][1]; - float in1_re = in[12-j][0]; - float in1_im = in[12-j][1]; - sum_re += filter[i][j][0] * (in0_re + in1_re) - - filter[i][j][1] * (in0_im - in1_im); - sum_im += filter[i][j][0] * (in0_im + in1_im) + - filter[i][j][1] * (in0_re - in1_re); - } - out[i * stride][0] = sum_re; - out[i * stride][1] = sum_im; - } -} - -static void ps_hybrid_analysis_ileave_c(float (*out)[32][2], float L[2][38][64], - int i, int len) -{ - int j; - - for (; i < 64; i++) { - for (j = 0; j < len; j++) { - out[i][j][0] = L[0][j][i]; - out[i][j][1] = L[1][j][i]; - } - } -} - -static void ps_hybrid_synthesis_deint_c(float out[2][38][64], - float (*in)[32][2], - int i, int len) -{ - int n; - - for (; i < 64; i++) { - for (n = 0; n < len; n++) { - out[0][n][i] = in[i][n][0]; - out[1][n][i] = in[i][n][1]; - } - } -} - -static void ps_decorrelate_c(float (*out)[2], float (*delay)[2], - float (*ap_delay)[PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2], - const float phi_fract[2], const float (*Q_fract)[2], - const float *transient_gain, - float g_decay_slope, - int len) -{ - static const float a[] = { 0.65143905753106f, - 0.56471812200776f, - 0.48954165955695f }; - float ag[PS_AP_LINKS]; - int m, n; - - for (m = 0; m < PS_AP_LINKS; m++) - ag[m] = a[m] * g_decay_slope; - - for (n = 0; n < len; n++) { - float in_re = delay[n][0] * phi_fract[0] - delay[n][1] * phi_fract[1]; - float in_im = delay[n][0] * phi_fract[1] + delay[n][1] * phi_fract[0]; - for (m = 0; m < PS_AP_LINKS; m++) { - float a_re = ag[m] * in_re; - float a_im = ag[m] * in_im; - float link_delay_re = ap_delay[m][n+2-m][0]; - float link_delay_im = ap_delay[m][n+2-m][1]; - float fractional_delay_re = Q_fract[m][0]; - float fractional_delay_im = Q_fract[m][1]; - float apd_re = in_re; - float apd_im = in_im; - in_re = link_delay_re * fractional_delay_re - - link_delay_im * fractional_delay_im - a_re; - in_im = link_delay_re * fractional_delay_im + - link_delay_im * fractional_delay_re - a_im; - ap_delay[m][n+5][0] = apd_re + ag[m] * in_re; - ap_delay[m][n+5][1] = apd_im + ag[m] * in_im; - } - out[n][0] = transient_gain[n] * in_re; - out[n][1] = transient_gain[n] * in_im; - } -} - -static void ps_stereo_interpolate_c(float (*l)[2], float (*r)[2], - float h[2][4], float h_step[2][4], - int len) -{ - float h0 = h[0][0]; - float h1 = h[0][1]; - float h2 = h[0][2]; - float h3 = h[0][3]; - float hs0 = h_step[0][0]; - float hs1 = h_step[0][1]; - float hs2 = h_step[0][2]; - float hs3 = h_step[0][3]; - int n; - - for (n = 0; n < len; n++) { - //l is s, r is d - float l_re = l[n][0]; - float l_im = l[n][1]; - float r_re = r[n][0]; - float r_im = r[n][1]; - h0 += hs0; - h1 += hs1; - h2 += hs2; - h3 += hs3; - l[n][0] = h0 * l_re + h2 * r_re; - l[n][1] = h0 * l_im + h2 * r_im; - r[n][0] = h1 * l_re + h3 * r_re; - r[n][1] = h1 * l_im + h3 * r_im; - } -} - -static void ps_stereo_interpolate_ipdopd_c(float (*l)[2], float (*r)[2], - float h[2][4], float h_step[2][4], - int len) -{ - float h00 = h[0][0], h10 = h[1][0]; - float h01 = h[0][1], h11 = h[1][1]; - float h02 = h[0][2], h12 = h[1][2]; - float h03 = h[0][3], h13 = h[1][3]; - float hs00 = h_step[0][0], hs10 = h_step[1][0]; - float hs01 = h_step[0][1], hs11 = h_step[1][1]; - float hs02 = h_step[0][2], hs12 = h_step[1][2]; - float hs03 = h_step[0][3], hs13 = h_step[1][3]; - int n; - - for (n = 0; n < len; n++) { - //l is s, r is d - float l_re = l[n][0]; - float l_im = l[n][1]; - float r_re = r[n][0]; - float r_im = r[n][1]; - h00 += hs00; - h01 += hs01; - h02 += hs02; - h03 += hs03; - h10 += hs10; - h11 += hs11; - h12 += hs12; - h13 += hs13; - - l[n][0] = h00 * l_re + h02 * r_re - h10 * l_im - h12 * r_im; - l[n][1] = h00 * l_im + h02 * r_im + h10 * l_re + h12 * r_re; - r[n][0] = h01 * l_re + h03 * r_re - h11 * l_im - h13 * r_im; - r[n][1] = h01 * l_im + h03 * r_im + h11 * l_re + h13 * r_re; - } -} - -av_cold void ff_psdsp_init(PSDSPContext *s) -{ - s->add_squares = ps_add_squares_c; - s->mul_pair_single = ps_mul_pair_single_c; - s->hybrid_analysis = ps_hybrid_analysis_c; - s->hybrid_analysis_ileave = ps_hybrid_analysis_ileave_c; - s->hybrid_synthesis_deint = ps_hybrid_synthesis_deint_c; - s->decorrelate = ps_decorrelate_c; - s->stereo_interpolate[0] = ps_stereo_interpolate_c; - s->stereo_interpolate[1] = ps_stereo_interpolate_ipdopd_c; - - if (ARCH_ARM) - ff_psdsp_init_arm(s); - if (ARCH_MIPS) - ff_psdsp_init_mips(s); -} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsdsp_fixed.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsdsp_fixed.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsdsp_fixed.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsdsp_fixed.c 2015-07-23 17:20:03.000000000 +0000 @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2010 Alex Converse + * + * 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 + */ + +#define USE_FIXED 1 + +#include "aacpsdsp_template.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsdsp_float.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsdsp_float.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsdsp_float.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsdsp_float.c 2015-07-23 17:20:03.000000000 +0000 @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2010 Alex Converse + * + * 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 + */ + +#define USE_FIXED 0 + +#include "aacpsdsp_template.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsdsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsdsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsdsp.h 2015-06-18 18:54:56.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsdsp.h 2015-07-31 17:20:05.000000000 +0000 @@ -21,34 +21,37 @@ #ifndef LIBAVCODEC_AACPSDSP_H #define LIBAVCODEC_AACPSDSP_H +#include "aac_defines.h" + #define PS_QMF_TIME_SLOTS 32 #define PS_AP_LINKS 3 #define PS_MAX_AP_DELAY 5 typedef struct PSDSPContext { - void (*add_squares)(float *dst, const float (*src)[2], int n); - void (*mul_pair_single)(float (*dst)[2], float (*src0)[2], float *src1, + void (*add_squares)(INTFLOAT *dst, const INTFLOAT (*src)[2], int n); + void (*mul_pair_single)(INTFLOAT (*dst)[2], INTFLOAT (*src0)[2], INTFLOAT *src1, int n); - void (*hybrid_analysis)(float (*out)[2], float (*in)[2], - const float (*filter)[8][2], + void (*hybrid_analysis)(INTFLOAT (*out)[2], INTFLOAT (*in)[2], + const INTFLOAT (*filter)[8][2], int stride, int n); - void (*hybrid_analysis_ileave)(float (*out)[32][2], float L[2][38][64], + void (*hybrid_analysis_ileave)(INTFLOAT (*out)[32][2], INTFLOAT L[2][38][64], int i, int len); - void (*hybrid_synthesis_deint)(float out[2][38][64], float (*in)[32][2], + void (*hybrid_synthesis_deint)(INTFLOAT out[2][38][64], INTFLOAT (*in)[32][2], int i, int len); - void (*decorrelate)(float (*out)[2], float (*delay)[2], - float (*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2], - const float phi_fract[2], const float (*Q_fract)[2], - const float *transient_gain, - float g_decay_slope, + void (*decorrelate)(INTFLOAT (*out)[2], INTFLOAT (*delay)[2], + INTFLOAT (*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2], + const INTFLOAT phi_fract[2], const INTFLOAT (*Q_fract)[2], + const INTFLOAT *transient_gain, + INTFLOAT g_decay_slope, int len); - void (*stereo_interpolate[2])(float (*l)[2], float (*r)[2], - float h[2][4], float h_step[2][4], + void (*stereo_interpolate[2])(INTFLOAT (*l)[2], INTFLOAT (*r)[2], + INTFLOAT h[2][4], INTFLOAT h_step[2][4], int len); } PSDSPContext; -void ff_psdsp_init(PSDSPContext *s); +void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s); void ff_psdsp_init_arm(PSDSPContext *s); void ff_psdsp_init_mips(PSDSPContext *s); +void ff_psdsp_init_x86(PSDSPContext *s); #endif /* LIBAVCODEC_AACPSDSP_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsdsp_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsdsp_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsdsp_template.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsdsp_template.c 2015-07-31 17:20:05.000000000 +0000 @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2010 Alex Converse + * + * 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 + * + * Note: Rounding-to-nearest used unless otherwise stated + * + */ +#include + +#include "config.h" +#include "libavutil/attributes.h" +#include "aacpsdsp.h" + +static void ps_add_squares_c(INTFLOAT *dst, const INTFLOAT (*src)[2], int n) +{ + int i; + for (i = 0; i < n; i++) + dst[i] += AAC_MADD28(src[i][0], src[i][0], src[i][1], src[i][1]); +} + +static void ps_mul_pair_single_c(INTFLOAT (*dst)[2], INTFLOAT (*src0)[2], INTFLOAT *src1, + int n) +{ + int i; + for (i = 0; i < n; i++) { + dst[i][0] = AAC_MUL16(src0[i][0], src1[i]); + dst[i][1] = AAC_MUL16(src0[i][1], src1[i]); + } +} + +static void ps_hybrid_analysis_c(INTFLOAT (*out)[2], INTFLOAT (*in)[2], + const INTFLOAT (*filter)[8][2], + int stride, int n) +{ + int i, j; + + for (i = 0; i < n; i++) { + INT64FLOAT sum_re = (INT64FLOAT)filter[i][6][0] * in[6][0]; + INT64FLOAT sum_im = (INT64FLOAT)filter[i][6][0] * in[6][1]; + + for (j = 0; j < 6; j++) { + INTFLOAT in0_re = in[j][0]; + INTFLOAT in0_im = in[j][1]; + INTFLOAT in1_re = in[12-j][0]; + INTFLOAT in1_im = in[12-j][1]; + sum_re += (INT64FLOAT)filter[i][j][0] * (in0_re + in1_re) - + (INT64FLOAT)filter[i][j][1] * (in0_im - in1_im); + sum_im += (INT64FLOAT)filter[i][j][0] * (in0_im + in1_im) + + (INT64FLOAT)filter[i][j][1] * (in0_re - in1_re); + } +#if USE_FIXED + out[i * stride][0] = (int)((sum_re + 0x40000000) >> 31); + out[i * stride][1] = (int)((sum_im + 0x40000000) >> 31); +#else + out[i * stride][0] = sum_re; + out[i * stride][1] = sum_im; +#endif /* USE_FIXED */ + } +} +static void ps_hybrid_analysis_ileave_c(INTFLOAT (*out)[32][2], INTFLOAT L[2][38][64], + int i, int len) +{ + int j; + + for (; i < 64; i++) { + for (j = 0; j < len; j++) { + out[i][j][0] = L[0][j][i]; + out[i][j][1] = L[1][j][i]; + } + } +} + +static void ps_hybrid_synthesis_deint_c(INTFLOAT out[2][38][64], + INTFLOAT (*in)[32][2], + int i, int len) +{ + int n; + + for (; i < 64; i++) { + for (n = 0; n < len; n++) { + out[0][n][i] = in[i][n][0]; + out[1][n][i] = in[i][n][1]; + } + } +} + +static void ps_decorrelate_c(INTFLOAT (*out)[2], INTFLOAT (*delay)[2], + INTFLOAT (*ap_delay)[PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2], + const INTFLOAT phi_fract[2], const INTFLOAT (*Q_fract)[2], + const INTFLOAT *transient_gain, + INTFLOAT g_decay_slope, + int len) +{ + static const INTFLOAT a[] = { Q31(0.65143905753106f), + Q31(0.56471812200776f), + Q31(0.48954165955695f) }; + INTFLOAT ag[PS_AP_LINKS]; + int m, n; + + for (m = 0; m < PS_AP_LINKS; m++) + ag[m] = AAC_MUL30(a[m], g_decay_slope); + + for (n = 0; n < len; n++) { + INTFLOAT in_re = AAC_MSUB30(delay[n][0], phi_fract[0], delay[n][1], phi_fract[1]); + INTFLOAT in_im = AAC_MADD30(delay[n][0], phi_fract[1], delay[n][1], phi_fract[0]); + for (m = 0; m < PS_AP_LINKS; m++) { + INTFLOAT a_re = AAC_MUL31(ag[m], in_re); + INTFLOAT a_im = AAC_MUL31(ag[m], in_im); + INTFLOAT link_delay_re = ap_delay[m][n+2-m][0]; + INTFLOAT link_delay_im = ap_delay[m][n+2-m][1]; + INTFLOAT fractional_delay_re = Q_fract[m][0]; + INTFLOAT fractional_delay_im = Q_fract[m][1]; + INTFLOAT apd_re = in_re; + INTFLOAT apd_im = in_im; + in_re = AAC_MSUB30(link_delay_re, fractional_delay_re, + link_delay_im, fractional_delay_im); + in_re -= a_re; + in_im = AAC_MADD30(link_delay_re, fractional_delay_im, + link_delay_im, fractional_delay_re); + in_im -= a_im; + ap_delay[m][n+5][0] = apd_re + AAC_MUL31(ag[m], in_re); + ap_delay[m][n+5][1] = apd_im + AAC_MUL31(ag[m], in_im); + } + out[n][0] = AAC_MUL16(transient_gain[n], in_re); + out[n][1] = AAC_MUL16(transient_gain[n], in_im); + } +} + +static void ps_stereo_interpolate_c(INTFLOAT (*l)[2], INTFLOAT (*r)[2], + INTFLOAT h[2][4], INTFLOAT h_step[2][4], + int len) +{ + INTFLOAT h0 = h[0][0]; + INTFLOAT h1 = h[0][1]; + INTFLOAT h2 = h[0][2]; + INTFLOAT h3 = h[0][3]; + INTFLOAT hs0 = h_step[0][0]; + INTFLOAT hs1 = h_step[0][1]; + INTFLOAT hs2 = h_step[0][2]; + INTFLOAT hs3 = h_step[0][3]; + int n; + + for (n = 0; n < len; n++) { + //l is s, r is d + INTFLOAT l_re = l[n][0]; + INTFLOAT l_im = l[n][1]; + INTFLOAT r_re = r[n][0]; + INTFLOAT r_im = r[n][1]; + h0 += hs0; + h1 += hs1; + h2 += hs2; + h3 += hs3; + l[n][0] = AAC_MADD30(h0, l_re, h2, r_re); + l[n][1] = AAC_MADD30(h0, l_im, h2, r_im); + r[n][0] = AAC_MADD30(h1, l_re, h3, r_re); + r[n][1] = AAC_MADD30(h1, l_im, h3, r_im); + } +} + +static void ps_stereo_interpolate_ipdopd_c(INTFLOAT (*l)[2], INTFLOAT (*r)[2], + INTFLOAT h[2][4], INTFLOAT h_step[2][4], + int len) +{ + INTFLOAT h00 = h[0][0], h10 = h[1][0]; + INTFLOAT h01 = h[0][1], h11 = h[1][1]; + INTFLOAT h02 = h[0][2], h12 = h[1][2]; + INTFLOAT h03 = h[0][3], h13 = h[1][3]; + INTFLOAT hs00 = h_step[0][0], hs10 = h_step[1][0]; + INTFLOAT hs01 = h_step[0][1], hs11 = h_step[1][1]; + INTFLOAT hs02 = h_step[0][2], hs12 = h_step[1][2]; + INTFLOAT hs03 = h_step[0][3], hs13 = h_step[1][3]; + int n; + + for (n = 0; n < len; n++) { + //l is s, r is d + INTFLOAT l_re = l[n][0]; + INTFLOAT l_im = l[n][1]; + INTFLOAT r_re = r[n][0]; + INTFLOAT r_im = r[n][1]; + h00 += hs00; + h01 += hs01; + h02 += hs02; + h03 += hs03; + h10 += hs10; + h11 += hs11; + h12 += hs12; + h13 += hs13; + + l[n][0] = AAC_MSUB30_V8(h00, l_re, h02, r_re, h10, l_im, h12, r_im); + l[n][1] = AAC_MADD30_V8(h00, l_im, h02, r_im, h10, l_re, h12, r_re); + r[n][0] = AAC_MSUB30_V8(h01, l_re, h03, r_re, h11, l_im, h13, r_im); + r[n][1] = AAC_MADD30_V8(h01, l_im, h03, r_im, h11, l_re, h13, r_re); + } +} + +av_cold void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s) +{ + s->add_squares = ps_add_squares_c; + s->mul_pair_single = ps_mul_pair_single_c; + s->hybrid_analysis = ps_hybrid_analysis_c; + s->hybrid_analysis_ileave = ps_hybrid_analysis_ileave_c; + s->hybrid_synthesis_deint = ps_hybrid_synthesis_deint_c; + s->decorrelate = ps_decorrelate_c; + s->stereo_interpolate[0] = ps_stereo_interpolate_c; + s->stereo_interpolate[1] = ps_stereo_interpolate_ipdopd_c; + +#if !USE_FIXED + if (ARCH_ARM) + ff_psdsp_init_arm(s); + if (ARCH_MIPS) + ff_psdsp_init_mips(s); + if (ARCH_X86) + ff_psdsp_init_x86(s); +#endif /* !USE_FIXED */ +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps_fixed.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps_fixed.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps_fixed.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps_fixed.c 2015-07-23 17:20:03.000000000 +0000 @@ -0,0 +1,24 @@ +/* + * MPEG-4 Parametric Stereo decoding functions + * Copyright (c) 2010 Alex Converse + * + * 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 + */ + +#define USE_FIXED 1 + +#include "aacps.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps_fixed_tablegen.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps_fixed_tablegen.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps_fixed_tablegen.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps_fixed_tablegen.c 2015-07-23 17:20:03.000000000 +0000 @@ -0,0 +1,24 @@ +/* + * Generate a header file for hardcoded Parametric Stereo tables + * + * Copyright (c) 2010 Alex Converse + * + * 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 + */ + +#define USE_FIXED 1 +#include "aacps_tablegen_template.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps_fixed_tablegen.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps_fixed_tablegen.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps_fixed_tablegen.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps_fixed_tablegen.h 2015-07-26 17:20:03.000000000 +0000 @@ -0,0 +1,403 @@ +/* + * Header file for hardcoded Parametric Stereo tables + * + * Copyright (c) 2010 Alex Converse + * + * 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 + * + * Note: Rounding-to-nearest used unless otherwise stated + * + */ + +#ifndef AACPS_FIXED_TABLEGEN_H +#define AACPS_FIXED_TABLEGEN_H + +#include +#include + +#if CONFIG_HARDCODED_TABLES +#define ps_tableinit() +#define TABLE_CONST const +#include "libavcodec/aacps_fixed_tables.h" +#else +#include "libavutil/common.h" +#include "libavutil/mathematics.h" +#include "libavutil/mem.h" + +#include "aac_defines.h" +#include "libavutil/softfloat.h" +#define NR_ALLPASS_BANDS20 30 +#define NR_ALLPASS_BANDS34 50 +#define PS_AP_LINKS 3 +#define TABLE_CONST +static int pd_re_smooth[8*8*8]; +static int pd_im_smooth[8*8*8]; +static int HA[46][8][4]; +static int HB[46][8][4]; +static DECLARE_ALIGNED(16, int, f20_0_8) [ 8][8][2]; +static DECLARE_ALIGNED(16, int, f34_0_12)[12][8][2]; +static DECLARE_ALIGNED(16, int, f34_1_8) [ 8][8][2]; +static DECLARE_ALIGNED(16, int, f34_2_4) [ 4][8][2]; +static TABLE_CONST DECLARE_ALIGNED(16, int, Q_fract_allpass)[2][50][3][2]; +static DECLARE_ALIGNED(16, int, phi_fract)[2][50][2]; + +static const int g0_Q8[] = { + Q31(0.00746082949812f), Q31(0.02270420949825f), Q31(0.04546865930473f), Q31(0.07266113929591f), + Q31(0.09885108575264f), Q31(0.11793710567217f), Q31(0.125f) +}; + +static const int g0_Q12[] = { + Q31(0.04081179924692f), Q31(0.03812810994926f), Q31(0.05144908135699f), Q31(0.06399831151592f), + Q31(0.07428313801106f), Q31(0.08100347892914f), Q31(0.08333333333333f) +}; + +static const int g1_Q8[] = { + Q31(0.01565675600122f), Q31(0.03752716391991f), Q31(0.05417891378782f), Q31(0.08417044116767f), + Q31(0.10307344158036f), Q31(0.12222452249753f), Q31(0.125f) +}; + +static const int g2_Q4[] = { + Q31(-0.05908211155639f), Q31(-0.04871498374946f), Q31(0.0f), Q31(0.07778723915851f), + Q31( 0.16486303567403f), Q31( 0.23279856662996f), Q31(0.25f) +}; + +static const int sintbl_4[4] = { 0, 1073741824, 0, -1073741824 }; +static const int costbl_4[4] = { 1073741824, 0, -1073741824, 0 }; +static const int sintbl_8[8] = { 0, 759250125, 1073741824, 759250125, + 0, -759250125, -1073741824, -759250125 }; +static const int costbl_8[8] = { 1073741824, 759250125, 0, -759250125, + -1073741824, -759250125, 0, 759250125 }; +static const int sintbl_12[12] = { 0, 536870912, 929887697, 1073741824, + 929887697, 536870912, 0, -536870912, + -929887697, -1073741824, -929887697, -536870912 }; +static const int costbl_12[12] = { 1073741824, 929887697, 536870912, 0, + -536870912, -929887697, -1073741824, -929887697, + -536870912, 0, 536870912, 929887697 }; + +static void make_filters_from_proto(int (*filter)[8][2], const int *proto, int bands) +{ + + const int *sinptr, *cosptr; + int s, c, sinhalf, coshalf; + int q, n; + + if (bands == 4) { + sinptr = sintbl_4; + cosptr = costbl_4; + sinhalf = 759250125; + coshalf = 759250125; + } else if (bands == 8) { + sinptr = sintbl_8; + cosptr = costbl_8; + sinhalf = 410903207; + coshalf = 992008094; + } else { + sinptr = sintbl_12; + cosptr = costbl_12; + sinhalf = 277904834; + coshalf = 1037154959; + } + + for (q = 0; q < bands; q++) { + for (n = 0; n < 7; n++) { + int theta = (q*(n-6) + (n>>1) - 3) % bands; + + if (theta < 0) + theta += bands; + s = sinptr[theta]; + c = cosptr[theta]; + + if (n & 1) { + theta = (int)(((int64_t)c * coshalf - (int64_t)s * sinhalf + 0x20000000) >> 30); + s = (int)(((int64_t)s * coshalf + (int64_t)c * sinhalf + 0x20000000) >> 30); + c = theta; + } + filter[q][n][0] = (int)(((int64_t)proto[n] * c + 0x20000000) >> 30); + filter[q][n][1] = -(int)(((int64_t)proto[n] * s + 0x20000000) >> 30); + } + } +} + +static void ps_tableinit(void) +{ + static const int ipdopd_sin[] = { Q30(0), Q30(M_SQRT1_2), Q30(1), Q30( M_SQRT1_2), Q30( 0), Q30(-M_SQRT1_2), Q30(-1), Q30(-M_SQRT1_2) }; + static const int ipdopd_cos[] = { Q30(1), Q30(M_SQRT1_2), Q30(0), Q30(-M_SQRT1_2), Q30(-1), Q30(-M_SQRT1_2), Q30( 0), Q30( M_SQRT1_2) }; + int pd0, pd1, pd2; + int idx; + + static const int alpha_tab[] = + { + Q30(1.5146213770f/M_PI), Q30(1.5181334019f/M_PI), Q30(1.5234849453f/M_PI), Q30(1.5369486809f/M_PI), Q30(1.5500687361f/M_PI), Q30(1.5679757595f/M_PI), + Q30(1.4455626011f/M_PI), Q30(1.4531552792f/M_PI), Q30(1.4648091793f/M_PI), Q30(1.4945238829f/M_PI), Q30(1.5239057541f/M_PI), Q30(1.5644006729f/M_PI), + Q30(1.3738563061f/M_PI), Q30(1.3851221800f/M_PI), Q30(1.4026404619f/M_PI), Q30(1.4484288692f/M_PI), Q30(1.4949874878f/M_PI), Q30(1.5604078770f/M_PI), + Q30(1.2645189762f/M_PI), Q30(1.2796478271f/M_PI), Q30(1.3038636446f/M_PI), Q30(1.3710125685f/M_PI), Q30(1.4443849325f/M_PI), Q30(1.5532352924f/M_PI), + Q30(1.1507037878f/M_PI), Q30(1.1669205427f/M_PI), Q30(1.1938756704f/M_PI), Q30(1.2754167318f/M_PI), Q30(1.3761177063f/M_PI), Q30(1.5429240465f/M_PI), + Q30(1.0079245567f/M_PI), Q30(1.0208238363f/M_PI), Q30(1.0433073044f/M_PI), Q30(1.1208510399f/M_PI), Q30(1.2424604893f/M_PI), Q30(1.5185726881f/M_PI), + Q30(0.8995233774f/M_PI), Q30(0.9069069624f/M_PI), Q30(0.9201194048f/M_PI), Q30(0.9698365927f/M_PI), Q30(1.0671583414f/M_PI), Q30(1.4647934437f/M_PI), + Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), + Q30(0.6712729335f/M_PI), Q30(0.6638893485f/M_PI), Q30(0.6506769061f/M_PI), Q30(0.6009597182f/M_PI), Q30(0.5036380291f/M_PI), Q30(0.1060028747f/M_PI), + Q30(0.5628717542f/M_PI), Q30(0.5499725342f/M_PI), Q30(0.5274890065f/M_PI), Q30(0.4499453008f/M_PI), Q30(0.3283358216f/M_PI), Q30(0.0522236861f/M_PI), + Q30(0.4200925827f/M_PI), Q30(0.4038758278f/M_PI), Q30(0.3769206405f/M_PI), Q30(0.2953795493f/M_PI), Q30(0.1946786791f/M_PI), Q30(0.0278722942f/M_PI), + Q30(0.3062773645f/M_PI), Q30(0.2911485136f/M_PI), Q30(0.2669326365f/M_PI), Q30(0.1997837722f/M_PI), Q30(0.1264114529f/M_PI), Q30(0.0175609849f/M_PI), + Q30(0.1969399750f/M_PI), Q30(0.1856741160f/M_PI), Q30(0.1681558639f/M_PI), Q30(0.1223674342f/M_PI), Q30(0.0758088827f/M_PI), Q30(0.0103884479f/M_PI), + Q30(0.1252337098f/M_PI), Q30(0.1176410317f/M_PI), Q30(0.1059871912f/M_PI), Q30(0.0762724727f/M_PI), Q30(0.0468905345f/M_PI), Q30(0.0063956482f/M_PI), + Q30(0.0561749674f/M_PI), Q30(0.0526629239f/M_PI), Q30(0.0473113805f/M_PI), Q30(0.0338476151f/M_PI), Q30(0.0207276177f/M_PI), Q30(0.0028205961f/M_PI), + Q30(1.5676341057f/M_PI), Q30(1.5678333044f/M_PI), Q30(1.5681363344f/M_PI), Q30(1.5688960552f/M_PI), Q30(1.5696337223f/M_PI), Q30(1.5706381798f/M_PI), + Q30(1.5651730299f/M_PI), Q30(1.5655272007f/M_PI), Q30(1.5660660267f/M_PI), Q30(1.5674170256f/M_PI), Q30(1.5687289238f/M_PI), Q30(1.5705151558f/M_PI), + Q30(1.5607966185f/M_PI), Q30(1.5614265203f/M_PI), Q30(1.5623844862f/M_PI), Q30(1.5647867918f/M_PI), Q30(1.5671195984f/M_PI), Q30(1.5702962875f/M_PI), + Q30(1.5530153513f/M_PI), Q30(1.5541347265f/M_PI), Q30(1.5558375120f/M_PI), Q30(1.5601085424f/M_PI), Q30(1.5642569065f/M_PI), Q30(1.5699069500f/M_PI), + Q30(1.5391840935f/M_PI), Q30(1.5411708355f/M_PI), Q30(1.5441943407f/M_PI), Q30(1.5517836809f/M_PI), Q30(1.5591609478f/M_PI), Q30(1.5692136288f/M_PI), + Q30(1.5146213770f/M_PI), Q30(1.5181334019f/M_PI), Q30(1.5234849453f/M_PI), Q30(1.5369486809f/M_PI), Q30(1.5500687361f/M_PI), Q30(1.5679757595f/M_PI), + Q30(1.4915299416f/M_PI), Q30(1.4964480400f/M_PI), Q30(1.5039558411f/M_PI), Q30(1.5229074955f/M_PI), Q30(1.5414420366f/M_PI), Q30(1.5667995214f/M_PI), + Q30(1.4590617418f/M_PI), Q30(1.4658898115f/M_PI), Q30(1.4763505459f/M_PI), Q30(1.5029321909f/M_PI), Q30(1.5291173458f/M_PI), Q30(1.5651149750f/M_PI), + Q30(1.4136143923f/M_PI), Q30(1.4229322672f/M_PI), Q30(1.4373078346f/M_PI), Q30(1.4743183851f/M_PI), Q30(1.5113102198f/M_PI), Q30(1.5626684427f/M_PI), + Q30(1.3505556583f/M_PI), Q30(1.3628427982f/M_PI), Q30(1.3820509911f/M_PI), Q30(1.4327841997f/M_PI), Q30(1.4850014448f/M_PI), Q30(1.5590143204f/M_PI), + Q30(1.2645189762f/M_PI), Q30(1.2796478271f/M_PI), Q30(1.3038636446f/M_PI), Q30(1.3710125685f/M_PI), Q30(1.4443849325f/M_PI), Q30(1.5532352924f/M_PI), + Q30(1.1919227839f/M_PI), Q30(1.2081253529f/M_PI), Q30(1.2346779108f/M_PI), Q30(1.3123005629f/M_PI), Q30(1.4034168720f/M_PI), Q30(1.5471596718f/M_PI), + Q30(1.1061993837f/M_PI), Q30(1.1219338179f/M_PI), Q30(1.1484941244f/M_PI), Q30(1.2320860624f/M_PI), Q30(1.3421301842f/M_PI), Q30(1.5373806953f/M_PI), + Q30(1.0079245567f/M_PI), Q30(1.0208238363f/M_PI), Q30(1.0433073044f/M_PI), Q30(1.1208510399f/M_PI), Q30(1.2424604893f/M_PI), Q30(1.5185726881f/M_PI), + Q30(0.8995233774f/M_PI), Q30(0.9069069624f/M_PI), Q30(0.9201194048f/M_PI), Q30(0.9698365927f/M_PI), Q30(1.0671583414f/M_PI), Q30(1.4647934437f/M_PI), + Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), + Q30(0.6712729335f/M_PI), Q30(0.6638893485f/M_PI), Q30(0.6506769061f/M_PI), Q30(0.6009597182f/M_PI), Q30(0.5036380291f/M_PI), Q30(0.1060028747f/M_PI), + Q30(0.5628717542f/M_PI), Q30(0.5499725342f/M_PI), Q30(0.5274890065f/M_PI), Q30(0.4499453008f/M_PI), Q30(0.3283358216f/M_PI), Q30(0.0522236861f/M_PI), + Q30(0.4645969570f/M_PI), Q30(0.4488625824f/M_PI), Q30(0.4223022461f/M_PI), Q30(0.3387103081f/M_PI), Q30(0.2286661267f/M_PI), Q30(0.0334156826f/M_PI), + Q30(0.3788735867f/M_PI), Q30(0.3626709878f/M_PI), Q30(0.3361184299f/M_PI), Q30(0.2584958076f/M_PI), Q30(0.1673794836f/M_PI), Q30(0.0236366931f/M_PI), + Q30(0.3062773645f/M_PI), Q30(0.2911485136f/M_PI), Q30(0.2669326365f/M_PI), Q30(0.1997837722f/M_PI), Q30(0.1264114529f/M_PI), Q30(0.0175609849f/M_PI), + Q30(0.2202406377f/M_PI), Q30(0.2079535723f/M_PI), Q30(0.1887452900f/M_PI), Q30(0.1380121708f/M_PI), Q30(0.0857949182f/M_PI), Q30(0.0117820343f/M_PI), + Q30(0.1571819335f/M_PI), Q30(0.1478640437f/M_PI), Q30(0.1334884763f/M_PI), Q30(0.0964778885f/M_PI), Q30(0.0594860613f/M_PI), Q30(0.0081279324f/M_PI), + Q30(0.1117345318f/M_PI), Q30(0.1049065739f/M_PI), Q30(0.0944457650f/M_PI), Q30(0.0678641573f/M_PI), Q30(0.0416790098f/M_PI), Q30(0.0056813755f/M_PI), + Q30(0.0792663917f/M_PI), Q30(0.0743482932f/M_PI), Q30(0.0668405443f/M_PI), Q30(0.0478888862f/M_PI), Q30(0.0293543357f/M_PI), Q30(0.0039967746f/M_PI), + Q30(0.0561749674f/M_PI), Q30(0.0526629239f/M_PI), Q30(0.0473113805f/M_PI), Q30(0.0338476151f/M_PI), Q30(0.0207276177f/M_PI), Q30(0.0028205961f/M_PI), + Q30(0.0316122435f/M_PI), Q30(0.0296254847f/M_PI), Q30(0.0266019460f/M_PI), Q30(0.0190126132f/M_PI), Q30(0.0116353342f/M_PI), Q30(0.0015827164f/M_PI), + Q30(0.0177809205f/M_PI), Q30(0.0166615788f/M_PI), Q30(0.0149587989f/M_PI), Q30(0.0106877899f/M_PI), Q30(0.0065393616f/M_PI), Q30(0.0008894200f/M_PI), + Q30(0.0099996664f/M_PI), Q30(0.0093698399f/M_PI), Q30(0.0084118480f/M_PI), Q30(0.0060095116f/M_PI), Q30(0.0036767013f/M_PI), Q30(0.0005000498f/M_PI), + Q30(0.0056233541f/M_PI), Q30(0.0052691097f/M_PI), Q30(0.0047303112f/M_PI), Q30(0.0033792770f/M_PI), Q30(0.0020674451f/M_PI), Q30(0.0002811795f/M_PI), + Q30(0.0031622672f/M_PI), Q30(0.0029630491f/M_PI), Q30(0.0026600463f/M_PI), Q30(0.0019002859f/M_PI), Q30(0.0011625893f/M_PI), Q30(0.0001581155f/M_PI) + }; + + static const int gamma_tab[] = + { + Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0433459543f/M_PI), Q30(0.0672172382f/M_PI), Q30(0.0997167900f/M_PI), Q30(0.1162951663f/M_PI), Q30(0.1250736862f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0672341362f/M_PI), Q30(0.1045235619f/M_PI), Q30(0.1558904350f/M_PI), Q30(0.1824723780f/M_PI), Q30(0.1966800541f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1315985769f/M_PI), Q30(0.2072522491f/M_PI), Q30(0.3188187480f/M_PI), Q30(0.3825501204f/M_PI), Q30(0.4193951190f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1784276664f/M_PI), Q30(0.2856673002f/M_PI), Q30(0.4630723596f/M_PI), Q30(0.5971632004f/M_PI), Q30(0.7603877187f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1315985769f/M_PI), Q30(0.2072522491f/M_PI), Q30(0.3188187480f/M_PI), Q30(0.3825501204f/M_PI), Q30(0.4193951190f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0672341362f/M_PI), Q30(0.1045235619f/M_PI), Q30(0.1558904350f/M_PI), Q30(0.1824723780f/M_PI), Q30(0.1966800541f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0433459543f/M_PI), Q30(0.0672172382f/M_PI), Q30(0.0997167900f/M_PI), Q30(0.1162951663f/M_PI), Q30(0.1250736862f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0011053939f/M_PI), Q30(0.0017089852f/M_PI), Q30(0.0025254129f/M_PI), Q30(0.0029398468f/M_PI), Q30(0.0031597170f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0019607407f/M_PI), Q30(0.0030395309f/M_PI), Q30(0.0044951206f/M_PI), Q30(0.0052305623f/M_PI), Q30(0.0056152637f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0034913034f/M_PI), Q30(0.0054070661f/M_PI), Q30(0.0079917293f/M_PI), Q30(0.0092999367f/M_PI), Q30(0.0099875759f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0062100487f/M_PI), Q30(0.0096135242f/M_PI), Q30(0.0142110568f/M_PI), Q30(0.0165348612f/M_PI), Q30(0.0177587029f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0110366223f/M_PI), Q30(0.0170863140f/M_PI), Q30(0.0252620988f/M_PI), Q30(0.0293955617f/M_PI), Q30(0.0315726399f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0275881495f/M_PI), Q30(0.0427365713f/M_PI), Q30(0.0632618815f/M_PI), Q30(0.0736731067f/M_PI), Q30(0.0791663304f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0387469754f/M_PI), Q30(0.0600636788f/M_PI), Q30(0.0890387669f/M_PI), Q30(0.1037906483f/M_PI), Q30(0.1115923747f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0541138873f/M_PI), Q30(0.0839984417f/M_PI), Q30(0.1248718798f/M_PI), Q30(0.1458375156f/M_PI), Q30(0.1569785923f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0747506917f/M_PI), Q30(0.1163287833f/M_PI), Q30(0.1738867164f/M_PI), Q30(0.2038587779f/M_PI), Q30(0.2199459076f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1212290376f/M_PI), Q30(0.1903949380f/M_PI), Q30(0.2907958031f/M_PI), Q30(0.3466993868f/M_PI), Q30(0.3782821596f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1418247074f/M_PI), Q30(0.2240308374f/M_PI), Q30(0.3474813402f/M_PI), Q30(0.4202919006f/M_PI), Q30(0.4637607038f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1784276664f/M_PI), Q30(0.2856673002f/M_PI), Q30(0.4630723596f/M_PI), Q30(0.5971632004f/M_PI), Q30(0.7603877187f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1418247074f/M_PI), Q30(0.2240308374f/M_PI), Q30(0.3474813402f/M_PI), Q30(0.4202919006f/M_PI), Q30(0.4637607038f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1212290376f/M_PI), Q30(0.1903949380f/M_PI), Q30(0.2907958031f/M_PI), Q30(0.3466993868f/M_PI), Q30(0.3782821596f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0747506917f/M_PI), Q30(0.1163287833f/M_PI), Q30(0.1738867164f/M_PI), Q30(0.2038587779f/M_PI), Q30(0.2199459076f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0541138873f/M_PI), Q30(0.0839984417f/M_PI), Q30(0.1248718798f/M_PI), Q30(0.1458375156f/M_PI), Q30(0.1569785923f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0387469754f/M_PI), Q30(0.0600636788f/M_PI), Q30(0.0890387669f/M_PI), Q30(0.1037906483f/M_PI), Q30(0.1115923747f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0275881495f/M_PI), Q30(0.0427365713f/M_PI), Q30(0.0632618815f/M_PI), Q30(0.0736731067f/M_PI), Q30(0.0791663304f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0110366223f/M_PI), Q30(0.0170863140f/M_PI), Q30(0.0252620988f/M_PI), Q30(0.0293955617f/M_PI), Q30(0.0315726399f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0062100487f/M_PI), Q30(0.0096135242f/M_PI), Q30(0.0142110568f/M_PI), Q30(0.0165348612f/M_PI), Q30(0.0177587029f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0034913034f/M_PI), Q30(0.0054070661f/M_PI), Q30(0.0079917293f/M_PI), Q30(0.0092999367f/M_PI), Q30(0.0099875759f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0019607407f/M_PI), Q30(0.0030395309f/M_PI), Q30(0.0044951206f/M_PI), Q30(0.0052305623f/M_PI), Q30(0.0056152637f/M_PI), + Q30(0.0000000000f/M_PI), Q30(0.0011053939f/M_PI), Q30(0.0017089852f/M_PI), Q30(0.0025254129f/M_PI), Q30(0.0029398468f/M_PI), Q30(0.0031597170f/M_PI) + }; + + static const int iid_par_dequant_c1[] = { + //iid_par_dequant_default + Q30(1.41198278375959f), Q30(1.40313815268360f), Q30(1.38687670404960f), Q30(1.34839972492648f), + Q30(1.29124937110028f), Q30(1.19603741667993f), Q30(1.10737240362323f), Q30(1), + Q30(0.87961716655242f), Q30(0.75464859232732f), Q30(0.57677990744575f), Q30(0.42640143271122f), + Q30(0.27671828230984f), Q30(0.17664462766713f), Q30(0.07940162697653f), + //iid_par_dequant_fine + Q30(1.41420649135832f), Q30(1.41419120222364f), Q30(1.41414285699784f), Q30(1.41399000859438f), + Q30(1.41350698548044f), Q30(1.41198278375959f), Q30(1.40977302262355f), Q30(1.40539479488545f), + Q30(1.39677960498402f), Q30(1.38005309967827f), Q30(1.34839972492648f), Q30(1.31392017367631f), + Q30(1.26431008149654f), Q30(1.19603741667993f), Q30(1.10737240362323f), Q30(1), + Q30(0.87961716655242f), Q30(0.75464859232732f), Q30(0.63365607219232f), Q30(0.52308104267543f), + Q30(0.42640143271122f), Q30(0.30895540465965f), Q30(0.22137464873077f), Q30(0.15768788954414f), + Q30(0.11198225164225f), Q30(0.07940162697653f), Q30(0.04469901562677f), Q30(0.02514469318284f), + Q30(0.01414142856998f), Q30(0.00795258154731f), Q30(0.00447211359449f), + }; + + static const int acos_icc_invq[] = { + Q31(0), Q31(0.178427635f/M_PI), Q31(0.28566733f/M_PI), Q31(0.46307236f/M_PI), Q31(0.59716315f/M_PI), Q31(0.78539816f/M_PI), Q31(1.10030855f/M_PI), Q31(1.57079633f/M_PI) + }; + int iid, icc; + + int k, m; + static const int8_t f_center_20[] = { + -3, -1, 1, 3, 5, 7, 10, 14, 18, 22, + }; + static const int32_t f_center_34[] = { + Q31( 2/768.0),Q31( 6/768.0),Q31(10/768.0),Q31(14/768.0),Q31( 18/768.0),Q31( 22/768.0),Q31( 26/768.0),Q31(30/768.0), + Q31( 34/768.0),Q31(-10/768.0),Q31(-6/768.0),Q31(-2/768.0),Q31( 51/768.0),Q31( 57/768.0),Q31( 15/768.0),Q31(21/768.0), + Q31( 27/768.0),Q31( 33/768.0),Q31(39/768.0),Q31(45/768.0),Q31( 54/768.0),Q31( 66/768.0),Q31( 78/768.0),Q31(42/768.0), + Q31(102/768.0),Q31( 66/768.0),Q31(78/768.0),Q31(90/768.0),Q31(102/768.0),Q31(114/768.0),Q31(126/768.0),Q31(90/768.0) + }; + static const int fractional_delay_links[] = { Q31(0.43f), Q31(0.75f), Q31(0.347f) }; + const int fractional_delay_gain = Q31(0.39f); + + for (pd0 = 0; pd0 < 8; pd0++) { + int pd0_re = (ipdopd_cos[pd0]+2)>>2; + int pd0_im = (ipdopd_sin[pd0]+2)>>2; + for (pd1 = 0; pd1 < 8; pd1++) { + int pd1_re = ipdopd_cos[pd1] >> 1; + int pd1_im = ipdopd_sin[pd1] >> 1; + for (pd2 = 0; pd2 < 8; pd2++) { + int shift, round; + int pd2_re = ipdopd_cos[pd2]; + int pd2_im = ipdopd_sin[pd2]; + int re_smooth = pd0_re + pd1_re + pd2_re; + int im_smooth = pd0_im + pd1_im + pd2_im; + + SoftFloat pd_mag = av_int2sf(((ipdopd_cos[(pd0-pd1)&7]+8)>>4) + ((ipdopd_cos[(pd0-pd2)&7]+4)>>3) + + ((ipdopd_cos[(pd1-pd2)&7]+2)>>2) + 0x15000000, 28); + pd_mag = av_div_sf(FLOAT_1, av_sqrt_sf(pd_mag)); + shift = 30 - pd_mag.exp; + round = 1 << (shift-1); + pd_re_smooth[pd0*64+pd1*8+pd2] = (int)(((int64_t)re_smooth * pd_mag.mant + round) >> shift); + pd_im_smooth[pd0*64+pd1*8+pd2] = (int)(((int64_t)im_smooth * pd_mag.mant + round) >> shift); + } + } + } + + idx = 0; + for (iid = 0; iid < 46; iid++) { + int c1, c2; + + c1 = iid_par_dequant_c1[iid]; + if (iid < 15) + c2 = iid_par_dequant_c1[14-iid]; + else + c2 = iid_par_dequant_c1[60-iid]; + + for (icc = 0; icc < 8; icc++) { + /*if (PS_BASELINE || ps->icc_mode < 3)*/{ + int alpha, beta; + int ca, sa, cb, sb; + + alpha = acos_icc_invq[icc]; + beta = (int)(((int64_t)alpha * 1518500250 + 0x40000000) >> 31); + alpha >>= 1; + beta = (int)(((int64_t)beta * (c1 - c2) + 0x40000000) >> 31); + av_sincos_sf(beta + alpha, &sa, &ca); + av_sincos_sf(beta - alpha, &sb, &cb); + + HA[iid][icc][0] = (int)(((int64_t)c2 * ca + 0x20000000) >> 30); + HA[iid][icc][1] = (int)(((int64_t)c1 * cb + 0x20000000) >> 30); + HA[iid][icc][2] = (int)(((int64_t)c2 * sa + 0x20000000) >> 30); + HA[iid][icc][3] = (int)(((int64_t)c1 * sb + 0x20000000) >> 30); + } /* else */ { + int alpha_int, gamma_int; + int alpha_c_int, alpha_s_int, gamma_c_int, gamma_s_int; + + alpha_int = alpha_tab[idx]; + gamma_int = gamma_tab[idx]; + + av_sincos_sf(alpha_int, &alpha_s_int, &alpha_c_int); + av_sincos_sf(gamma_int, &gamma_s_int, &gamma_c_int); + + alpha_c_int = (int)(((int64_t)alpha_c_int * 1518500250 + 0x20000000) >> 30); + alpha_s_int = (int)(((int64_t)alpha_s_int * 1518500250 + 0x20000000) >> 30); + + HB[iid][icc][0] = (int)(((int64_t)alpha_c_int * gamma_c_int + 0x20000000) >> 30); + HB[iid][icc][1] = (int)(((int64_t)alpha_s_int * gamma_c_int + 0x20000000) >> 30); + HB[iid][icc][2] = -(int)(((int64_t)alpha_s_int * gamma_s_int + 0x20000000) >> 30); + HB[iid][icc][3] = (int)(((int64_t)alpha_c_int * gamma_s_int + 0x20000000) >> 30); + } + + if (icc < 5 || icc > 6) + idx++; + } + } + + for (k = 0; k < NR_ALLPASS_BANDS20; k++) { + int theta; + int64_t f_center; + int c, s; + + if (k < FF_ARRAY_ELEMS(f_center_20)) + f_center = f_center_20[k]; + else + f_center = (k << 3) - 52; + + for (m = 0; m < PS_AP_LINKS; m++) { + theta = (int)(((int64_t)fractional_delay_links[m] * f_center + 8) >> 4); + av_sincos_sf(-theta, &s, &c); + Q_fract_allpass[0][k][m][0] = c; + Q_fract_allpass[0][k][m][1] = s; + } + + theta = (int)(((int64_t)fractional_delay_gain * f_center + 8) >> 4); + av_sincos_sf(-theta, &s, &c); + phi_fract[0][k][0] = c; + phi_fract[0][k][1] = s; + } + + for (k = 0; k < NR_ALLPASS_BANDS34; k++) { + int theta, f_center; + int c, s; + + if (k < FF_ARRAY_ELEMS(f_center_34)) + f_center = f_center_34[k]; + else + f_center = ((int64_t)k << 26) - (53 << 25); + + for (m = 0; m < PS_AP_LINKS; m++) { + theta = (int)(((int64_t)fractional_delay_links[m] * f_center + 0x10000000) >> 27); + av_sincos_sf(-theta, &s, &c); + Q_fract_allpass[1][k][m][0] = c; + Q_fract_allpass[1][k][m][1] = s; + } + + theta = (int)(((int64_t)fractional_delay_gain * f_center + 0x10000000) >> 27); + av_sincos_sf(-theta, &s, &c); + phi_fract[1][k][0] = c; + phi_fract[1][k][1] = s; + } + + make_filters_from_proto(f20_0_8, g0_Q8, 8); + make_filters_from_proto(f34_0_12, g0_Q12, 12); + make_filters_from_proto(f34_1_8, g1_Q8, 8); + make_filters_from_proto(f34_2_4, g2_Q4, 4); +} +#endif /* CONFIG_HARDCODED_TABLES */ + +#endif /* AACPS_FIXED_TABLEGEN_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps_float.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps_float.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps_float.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps_float.c 2015-07-23 17:20:03.000000000 +0000 @@ -0,0 +1,24 @@ +/* + * MPEG-4 Parametric Stereo decoding functions + * Copyright (c) 2010 Alex Converse + * + * 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 + */ + +#define USE_FIXED 0 + +#include "aacps.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps.h 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps.h 2015-07-23 17:20:03.000000000 +0000 @@ -61,26 +61,26 @@ int is34bands; int is34bands_old; - DECLARE_ALIGNED(16, float, in_buf)[5][44][2]; - DECLARE_ALIGNED(16, float, delay)[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2]; - DECLARE_ALIGNED(16, float, ap_delay)[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2]; - DECLARE_ALIGNED(16, float, peak_decay_nrg)[34]; - DECLARE_ALIGNED(16, float, power_smooth)[34]; - DECLARE_ALIGNED(16, float, peak_decay_diff_smooth)[34]; - DECLARE_ALIGNED(16, float, H11)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; - DECLARE_ALIGNED(16, float, H12)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; - DECLARE_ALIGNED(16, float, H21)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; - DECLARE_ALIGNED(16, float, H22)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; - DECLARE_ALIGNED(16, float, Lbuf)[91][32][2]; - DECLARE_ALIGNED(16, float, Rbuf)[91][32][2]; + DECLARE_ALIGNED(16, INTFLOAT, in_buf)[5][44][2]; + DECLARE_ALIGNED(16, INTFLOAT, delay)[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2]; + DECLARE_ALIGNED(16, INTFLOAT, ap_delay)[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2]; + DECLARE_ALIGNED(16, INTFLOAT, peak_decay_nrg)[34]; + DECLARE_ALIGNED(16, INTFLOAT, power_smooth)[34]; + DECLARE_ALIGNED(16, INTFLOAT, peak_decay_diff_smooth)[34]; + DECLARE_ALIGNED(16, INTFLOAT, H11)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; + DECLARE_ALIGNED(16, INTFLOAT, H12)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; + DECLARE_ALIGNED(16, INTFLOAT, H21)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; + DECLARE_ALIGNED(16, INTFLOAT, H22)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; + DECLARE_ALIGNED(16, INTFLOAT, Lbuf)[91][32][2]; + DECLARE_ALIGNED(16, INTFLOAT, Rbuf)[91][32][2]; int8_t opd_hist[PS_MAX_NR_IIDICC]; int8_t ipd_hist[PS_MAX_NR_IIDICC]; PSDSPContext dsp; } PSContext; -void ff_ps_init(void); -void ff_ps_ctx_init(PSContext *ps); -int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int bits_left); -int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top); +void AAC_RENAME(ff_ps_init)(void); +void AAC_RENAME(ff_ps_ctx_init)(PSContext *ps); +int AAC_RENAME(ff_ps_read_data)(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int bits_left); +int AAC_RENAME(ff_ps_apply)(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top); #endif /* AVCODEC_PS_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps_tablegen.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps_tablegen.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps_tablegen.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps_tablegen.c 2015-07-23 17:20:03.000000000 +0000 @@ -20,74 +20,5 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#define CONFIG_HARDCODED_TABLES 0 -#include "aacps_tablegen.h" -#include "tableprint.h" - -void write_float_3d_array (const void *p, int b, int c, int d) -{ - int i; - const float *f = p; - for (i = 0; i < b; i++) { - printf("{\n"); - write_float_2d_array(f, c, d); - printf("},\n"); - f += c * d; - } -} - -void write_float_4d_array (const void *p, int a, int b, int c, int d) -{ - int i; - const float *f = p; - for (i = 0; i < a; i++) { - printf("{\n"); - write_float_3d_array(f, b, c, d); - printf("},\n"); - f += b * c * d; - } -} - -int main(void) -{ - ps_tableinit(); - - write_fileheader(); - - printf("static const float pd_re_smooth[8*8*8] = {\n"); - write_float_array(pd_re_smooth, 8*8*8); - printf("};\n"); - printf("static const float pd_im_smooth[8*8*8] = {\n"); - write_float_array(pd_im_smooth, 8*8*8); - printf("};\n"); - - printf("static const float HA[46][8][4] = {\n"); - write_float_3d_array(HA, 46, 8, 4); - printf("};\n"); - printf("static const float HB[46][8][4] = {\n"); - write_float_3d_array(HB, 46, 8, 4); - printf("};\n"); - - printf("static const DECLARE_ALIGNED(16, float, f20_0_8)[8][8][2] = {\n"); - write_float_3d_array(f20_0_8, 8, 8, 2); - printf("};\n"); - printf("static const DECLARE_ALIGNED(16, float, f34_0_12)[12][8][2] = {\n"); - write_float_3d_array(f34_0_12, 12, 8, 2); - printf("};\n"); - printf("static const DECLARE_ALIGNED(16, float, f34_1_8)[8][8][2] = {\n"); - write_float_3d_array(f34_1_8, 8, 8, 2); - printf("};\n"); - printf("static const DECLARE_ALIGNED(16, float, f34_2_4)[4][8][2] = {\n"); - write_float_3d_array(f34_2_4, 4, 8, 2); - printf("};\n"); - - printf("static const DECLARE_ALIGNED(16, float, Q_fract_allpass)[2][50][3][2] = {\n"); - write_float_4d_array(Q_fract_allpass, 2, 50, 3, 2); - printf("};\n"); - printf("static const DECLARE_ALIGNED(16, float, phi_fract)[2][50][2] = {\n"); - write_float_3d_array(phi_fract, 2, 50, 2); - printf("};\n"); - - return 0; -} +#define USE_FIXED 0 +#include "aacps_tablegen_template.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps_tablegen_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps_tablegen_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacps_tablegen_template.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacps_tablegen_template.c 2015-07-23 17:20:03.000000000 +0000 @@ -0,0 +1,107 @@ +/* + * Generate a header file for hardcoded Parametric Stereo tables + * + * Copyright (c) 2010 Alex Converse + * + * 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 +#define CONFIG_HARDCODED_TABLES 0 +#include "aac_defines.h" + +#if USE_FIXED +#define TYPE_NAME "int32_t" +#define INT32FLOAT int32_t +#define ARRAY_RENAME(x) write_int32_t_ ## x +#define ARRAY_URENAME(x) write_uint32_t_ ## x +#include "aacps_fixed_tablegen.h" +#else +#define TYPE_NAME "float" +#define INT32FLOAT float +#define ARRAY_RENAME(x) write_float_ ## x +#define ARRAY_URENAME(x) write_float_ ## x +#include "aacps_tablegen.h" +#endif /* USE_FIXED */ +#include "tableprint.h" + +void ARRAY_RENAME(3d_array) (const void *p, int b, int c, int d) +{ + int i; + const INT32FLOAT *f = p; + for (i = 0; i < b; i++) { + printf("{\n"); + ARRAY_URENAME(2d_array)(f, c, d); + printf("},\n"); + f += c * d; + } +} + +void ARRAY_RENAME(4d_array) (const void *p, int a, int b, int c, int d) +{ + int i; + const INT32FLOAT *f = p; + for (i = 0; i < a; i++) { + printf("{\n"); + ARRAY_RENAME(3d_array)(f, b, c, d); + printf("},\n"); + f += b * c * d; + } +} + +int main(void) +{ + ps_tableinit(); + + write_fileheader(); + + printf("static const %s pd_re_smooth[8*8*8] = {\n", TYPE_NAME); + ARRAY_RENAME(array)(pd_re_smooth, 8*8*8); + printf("};\n"); + printf("static const %s pd_im_smooth[8*8*8] = {\n", TYPE_NAME); + ARRAY_RENAME(array)(pd_im_smooth, 8*8*8); + printf("};\n"); + + printf("static const %s HA[46][8][4] = {\n", TYPE_NAME); + ARRAY_RENAME(3d_array)(HA, 46, 8, 4); + printf("};\n"); + printf("static const %s HB[46][8][4] = {\n", TYPE_NAME); + ARRAY_RENAME(3d_array)(HB, 46, 8, 4); + printf("};\n"); + + printf("static const DECLARE_ALIGNED(16, %s, f20_0_8)[8][8][2] = {\n", TYPE_NAME); + ARRAY_RENAME(3d_array)(f20_0_8, 8, 8, 2); + printf("};\n"); + printf("static const DECLARE_ALIGNED(16, %s, f34_0_12)[12][8][2] = {\n", TYPE_NAME); + ARRAY_RENAME(3d_array)(f34_0_12, 12, 8, 2); + printf("};\n"); + printf("static const DECLARE_ALIGNED(16, %s, f34_1_8)[8][8][2] = {\n", TYPE_NAME); + ARRAY_RENAME(3d_array)(f34_1_8, 8, 8, 2); + printf("};\n"); + printf("static const DECLARE_ALIGNED(16, %s, f34_2_4)[4][8][2] = {\n", TYPE_NAME); + ARRAY_RENAME(3d_array)(f34_2_4, 4, 8, 2); + printf("};\n"); + + printf("static const DECLARE_ALIGNED(16, %s, Q_fract_allpass)[2][50][3][2] = {\n", TYPE_NAME); + ARRAY_RENAME(4d_array)(Q_fract_allpass, 2, 50, 3, 2); + printf("};\n"); + printf("static const DECLARE_ALIGNED(16, %s, phi_fract)[2][50][2] = {\n", TYPE_NAME); + ARRAY_RENAME(3d_array)(phi_fract, 2, 50, 2); + printf("};\n"); + + return 0; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsy.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsy.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacpsy.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacpsy.c 2015-07-28 17:20:07.000000000 +0000 @@ -262,7 +262,7 @@ for (i = 0; i < avctx->channels; i++) { AacPsyChannel *pch = &ctx->ch[i]; - if (avctx->flags & CODEC_FLAG_QSCALE) + if (avctx->flags & AV_CODEC_FLAG_QSCALE) pch->attack_threshold = psy_vbr_map[avctx->global_quality / FF_QP2LAMBDA].st_lrm; else pch->attack_threshold = lame_calc_attack_threshold(avctx->bit_rate / avctx->channels / 1000); @@ -787,6 +787,7 @@ psy_band->threshold = band->thr; psy_band->energy = band->energy; + psy_band->spread = band->active_lines * 2.0f / band_sizes[g]; } } @@ -836,6 +837,7 @@ int grouping = 0; int uselongblock = 1; int attacks[AAC_NUM_BLOCKS_SHORT + 1] = { 0 }; + float clippings[AAC_NUM_BLOCKS_SHORT]; int i; FFPsyWindowInfo wi = { { 0 } }; @@ -925,14 +927,35 @@ lame_apply_block_type(pch, &wi, uselongblock); + /* Calculate input sample maximums and evaluate clipping risk */ + if (audio) { + for (i = 0; i < AAC_NUM_BLOCKS_SHORT; i++) { + const float *wbuf = audio + i * AAC_BLOCK_SIZE_SHORT; + float max = 0; + int j; + for (j = 0; j < AAC_BLOCK_SIZE_SHORT; j++) + max = FFMAX(max, fabsf(wbuf[j])); + clippings[i] = max; + } + } else { + for (i = 0; i < 8; i++) + clippings[i] = 0; + } + wi.window_type[1] = prev_type; if (wi.window_type[0] != EIGHT_SHORT_SEQUENCE) { + float clipping = 0.0f; + wi.num_windows = 1; wi.grouping[0] = 1; if (wi.window_type[0] == LONG_START_SEQUENCE) wi.window_shape = 0; else wi.window_shape = 1; + + for (i = 0; i < 8; i++) + clipping = FFMAX(clipping, clippings[i]); + wi.clipping[0] = clipping; } else { int lastgrp = 0; @@ -943,6 +966,14 @@ lastgrp = i; wi.grouping[lastgrp]++; } + + for (i = 0; i < 8; i += wi.grouping[i]) { + int w; + float clipping = 0.0f; + for (w = 0; w < wi.grouping[i] && !clipping; w++) + clipping = FFMAX(clipping, clippings[i+w]); + wi.clipping[i] = clipping; + } } /* Determine grouping, based on the location of the first attack, and save for diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr.c 2015-07-20 17:20:03.000000000 +0000 @@ -25,6 +25,7 @@ * AAC Spectral Band Replication decoding functions * @author Robert Swain ( rob opendot cl ) */ +#define USE_FIXED 0 #include "aac.h" #include "sbr.h" @@ -42,252 +43,13 @@ #include #include -#define ENVELOPE_ADJUSTMENT_OFFSET 2 -#define NOISE_FLOOR_OFFSET 6.0f - #if ARCH_MIPS #include "mips/aacsbr_mips.h" #endif /* ARCH_MIPS */ -/** - * SBR VLC tables - */ -enum { - T_HUFFMAN_ENV_1_5DB, - F_HUFFMAN_ENV_1_5DB, - T_HUFFMAN_ENV_BAL_1_5DB, - F_HUFFMAN_ENV_BAL_1_5DB, - T_HUFFMAN_ENV_3_0DB, - F_HUFFMAN_ENV_3_0DB, - T_HUFFMAN_ENV_BAL_3_0DB, - F_HUFFMAN_ENV_BAL_3_0DB, - T_HUFFMAN_NOISE_3_0DB, - T_HUFFMAN_NOISE_BAL_3_0DB, -}; - -/** - * bs_frame_class - frame class of current SBR frame (14496-3 sp04 p98) - */ -enum { - FIXFIX, - FIXVAR, - VARFIX, - VARVAR, -}; - -enum { - EXTENSION_ID_PS = 2, -}; - static VLC vlc_sbr[10]; -static const int8_t vlc_sbr_lav[10] = - { 60, 60, 24, 24, 31, 31, 12, 12, 31, 12 }; - -#define SBR_INIT_VLC_STATIC(num, size) \ - INIT_VLC_STATIC(&vlc_sbr[num], 9, sbr_tmp[num].table_size / sbr_tmp[num].elem_size, \ - sbr_tmp[num].sbr_bits , 1, 1, \ - sbr_tmp[num].sbr_codes, sbr_tmp[num].elem_size, sbr_tmp[num].elem_size, \ - size) - -#define SBR_VLC_ROW(name) \ - { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) } - static void aacsbr_func_ptr_init(AACSBRContext *c); -av_cold void ff_aac_sbr_init(void) -{ - static const struct { - const void *sbr_codes, *sbr_bits; - const unsigned int table_size, elem_size; - } sbr_tmp[] = { - SBR_VLC_ROW(t_huffman_env_1_5dB), - SBR_VLC_ROW(f_huffman_env_1_5dB), - SBR_VLC_ROW(t_huffman_env_bal_1_5dB), - SBR_VLC_ROW(f_huffman_env_bal_1_5dB), - SBR_VLC_ROW(t_huffman_env_3_0dB), - SBR_VLC_ROW(f_huffman_env_3_0dB), - SBR_VLC_ROW(t_huffman_env_bal_3_0dB), - SBR_VLC_ROW(f_huffman_env_bal_3_0dB), - SBR_VLC_ROW(t_huffman_noise_3_0dB), - SBR_VLC_ROW(t_huffman_noise_bal_3_0dB), - }; - - // SBR VLC table initialization - SBR_INIT_VLC_STATIC(0, 1098); - SBR_INIT_VLC_STATIC(1, 1092); - SBR_INIT_VLC_STATIC(2, 768); - SBR_INIT_VLC_STATIC(3, 1026); - SBR_INIT_VLC_STATIC(4, 1058); - SBR_INIT_VLC_STATIC(5, 1052); - SBR_INIT_VLC_STATIC(6, 544); - SBR_INIT_VLC_STATIC(7, 544); - SBR_INIT_VLC_STATIC(8, 592); - SBR_INIT_VLC_STATIC(9, 512); - - aacsbr_tableinit(); - - ff_ps_init(); -} - -/** Places SBR in pure upsampling mode. */ -static void sbr_turnoff(SpectralBandReplication *sbr) { - sbr->start = 0; - // Init defults used in pure upsampling mode - sbr->kx[1] = 32; //Typo in spec, kx' inits to 32 - sbr->m[1] = 0; - // Reset values for first SBR header - sbr->data[0].e_a[1] = sbr->data[1].e_a[1] = -1; - memset(&sbr->spectrum_params, -1, sizeof(SpectrumParameters)); -} - -av_cold void ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr) -{ - if(sbr->mdct.mdct_bits) - return; - sbr->kx[0] = sbr->kx[1]; - sbr_turnoff(sbr); - sbr->data[0].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); - sbr->data[1].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); - /* SBR requires samples to be scaled to +/-32768.0 to work correctly. - * mdct scale factors are adjusted to scale up from +/-1.0 at analysis - * and scale back down at synthesis. */ - ff_mdct_init(&sbr->mdct, 7, 1, 1.0 / (64 * 32768.0)); - ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0 * 32768.0); - ff_ps_ctx_init(&sbr->ps); - ff_sbrdsp_init(&sbr->dsp); - aacsbr_func_ptr_init(&sbr->c); -} - -av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr) -{ - ff_mdct_end(&sbr->mdct); - ff_mdct_end(&sbr->mdct_ana); -} - -static int qsort_comparison_function_int16(const void *a, const void *b) -{ - return *(const int16_t *)a - *(const int16_t *)b; -} - -static inline int in_table_int16(const int16_t *table, int last_el, int16_t needle) -{ - int i; - for (i = 0; i <= last_el; i++) - if (table[i] == needle) - return 1; - return 0; -} - -/// Limiter Frequency Band Table (14496-3 sp04 p198) -static void sbr_make_f_tablelim(SpectralBandReplication *sbr) -{ - int k; - if (sbr->bs_limiter_bands > 0) { - static const float bands_warped[3] = { 1.32715174233856803909f, //2^(0.49/1.2) - 1.18509277094158210129f, //2^(0.49/2) - 1.11987160404675912501f }; //2^(0.49/3) - const float lim_bands_per_octave_warped = bands_warped[sbr->bs_limiter_bands - 1]; - int16_t patch_borders[7]; - uint16_t *in = sbr->f_tablelim + 1, *out = sbr->f_tablelim; - - patch_borders[0] = sbr->kx[1]; - for (k = 1; k <= sbr->num_patches; k++) - patch_borders[k] = patch_borders[k-1] + sbr->patch_num_subbands[k-1]; - - memcpy(sbr->f_tablelim, sbr->f_tablelow, - (sbr->n[0] + 1) * sizeof(sbr->f_tablelow[0])); - if (sbr->num_patches > 1) - memcpy(sbr->f_tablelim + sbr->n[0] + 1, patch_borders + 1, - (sbr->num_patches - 1) * sizeof(patch_borders[0])); - - qsort(sbr->f_tablelim, sbr->num_patches + sbr->n[0], - sizeof(sbr->f_tablelim[0]), - qsort_comparison_function_int16); - - sbr->n_lim = sbr->n[0] + sbr->num_patches - 1; - while (out < sbr->f_tablelim + sbr->n_lim) { - if (*in >= *out * lim_bands_per_octave_warped) { - *++out = *in++; - } else if (*in == *out || - !in_table_int16(patch_borders, sbr->num_patches, *in)) { - in++; - sbr->n_lim--; - } else if (!in_table_int16(patch_borders, sbr->num_patches, *out)) { - *out = *in++; - sbr->n_lim--; - } else { - *++out = *in++; - } - } - } else { - sbr->f_tablelim[0] = sbr->f_tablelow[0]; - sbr->f_tablelim[1] = sbr->f_tablelow[sbr->n[0]]; - sbr->n_lim = 1; - } -} - -static unsigned int read_sbr_header(SpectralBandReplication *sbr, GetBitContext *gb) -{ - unsigned int cnt = get_bits_count(gb); - uint8_t bs_header_extra_1; - uint8_t bs_header_extra_2; - int old_bs_limiter_bands = sbr->bs_limiter_bands; - SpectrumParameters old_spectrum_params; - - sbr->start = 1; - - // Save last spectrum parameters variables to compare to new ones - memcpy(&old_spectrum_params, &sbr->spectrum_params, sizeof(SpectrumParameters)); - - sbr->bs_amp_res_header = get_bits1(gb); - sbr->spectrum_params.bs_start_freq = get_bits(gb, 4); - sbr->spectrum_params.bs_stop_freq = get_bits(gb, 4); - sbr->spectrum_params.bs_xover_band = get_bits(gb, 3); - skip_bits(gb, 2); // bs_reserved - - bs_header_extra_1 = get_bits1(gb); - bs_header_extra_2 = get_bits1(gb); - - if (bs_header_extra_1) { - sbr->spectrum_params.bs_freq_scale = get_bits(gb, 2); - sbr->spectrum_params.bs_alter_scale = get_bits1(gb); - sbr->spectrum_params.bs_noise_bands = get_bits(gb, 2); - } else { - sbr->spectrum_params.bs_freq_scale = 2; - sbr->spectrum_params.bs_alter_scale = 1; - sbr->spectrum_params.bs_noise_bands = 2; - } - - // Check if spectrum parameters changed - if (memcmp(&old_spectrum_params, &sbr->spectrum_params, sizeof(SpectrumParameters))) - sbr->reset = 1; - - if (bs_header_extra_2) { - sbr->bs_limiter_bands = get_bits(gb, 2); - sbr->bs_limiter_gains = get_bits(gb, 2); - sbr->bs_interpol_freq = get_bits1(gb); - sbr->bs_smoothing_mode = get_bits1(gb); - } else { - sbr->bs_limiter_bands = 2; - sbr->bs_limiter_gains = 2; - sbr->bs_interpol_freq = 1; - sbr->bs_smoothing_mode = 1; - } - - if (sbr->bs_limiter_bands != old_bs_limiter_bands && !sbr->reset) - sbr_make_f_tablelim(sbr); - - return get_bits_count(gb) - cnt; -} - -static int array_min_int16(const int16_t *array, int nel) -{ - int i, min = array[0]; - for (i = 1; i < nel; i++) - min = FFMIN(array[i], min); - return min; -} - static void make_bands(int16_t* bands, int start, int stop, int num_bands) { int k, previous, present; @@ -306,821 +68,6 @@ bands[num_bands-1] = stop - previous; } -static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band) -{ - // Requirements (14496-3 sp04 p205) - if (n_master <= 0) { - av_log(avctx, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master); - return -1; - } - if (bs_xover_band >= n_master) { - av_log(avctx, AV_LOG_ERROR, - "Invalid bitstream, crossover band index beyond array bounds: %d\n", - bs_xover_band); - return -1; - } - return 0; -} - -/// Master Frequency Band Table (14496-3 sp04 p194) -static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, - SpectrumParameters *spectrum) -{ - unsigned int temp, max_qmf_subbands = 0; - unsigned int start_min, stop_min; - int k; - const int8_t *sbr_offset_ptr; - int16_t stop_dk[13]; - - if (sbr->sample_rate < 32000) { - temp = 3000; - } else if (sbr->sample_rate < 64000) { - temp = 4000; - } else - temp = 5000; - - switch (sbr->sample_rate) { - case 16000: - sbr_offset_ptr = sbr_offset[0]; - break; - case 22050: - sbr_offset_ptr = sbr_offset[1]; - break; - case 24000: - sbr_offset_ptr = sbr_offset[2]; - break; - case 32000: - sbr_offset_ptr = sbr_offset[3]; - break; - case 44100: case 48000: case 64000: - sbr_offset_ptr = sbr_offset[4]; - break; - case 88200: case 96000: case 128000: case 176400: case 192000: - sbr_offset_ptr = sbr_offset[5]; - break; - default: - av_log(ac->avctx, AV_LOG_ERROR, - "Unsupported sample rate for SBR: %d\n", sbr->sample_rate); - return -1; - } - - start_min = ((temp << 7) + (sbr->sample_rate >> 1)) / sbr->sample_rate; - stop_min = ((temp << 8) + (sbr->sample_rate >> 1)) / sbr->sample_rate; - - sbr->k[0] = start_min + sbr_offset_ptr[spectrum->bs_start_freq]; - - if (spectrum->bs_stop_freq < 14) { - sbr->k[2] = stop_min; - make_bands(stop_dk, stop_min, 64, 13); - qsort(stop_dk, 13, sizeof(stop_dk[0]), qsort_comparison_function_int16); - for (k = 0; k < spectrum->bs_stop_freq; k++) - sbr->k[2] += stop_dk[k]; - } else if (spectrum->bs_stop_freq == 14) { - sbr->k[2] = 2*sbr->k[0]; - } else if (spectrum->bs_stop_freq == 15) { - sbr->k[2] = 3*sbr->k[0]; - } else { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid bs_stop_freq: %d\n", spectrum->bs_stop_freq); - return -1; - } - sbr->k[2] = FFMIN(64, sbr->k[2]); - - // Requirements (14496-3 sp04 p205) - if (sbr->sample_rate <= 32000) { - max_qmf_subbands = 48; - } else if (sbr->sample_rate == 44100) { - max_qmf_subbands = 35; - } else if (sbr->sample_rate >= 48000) - max_qmf_subbands = 32; - else - av_assert0(0); - - if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid bitstream, too many QMF subbands: %d\n", sbr->k[2] - sbr->k[0]); - return -1; - } - - if (!spectrum->bs_freq_scale) { - int dk, k2diff; - - dk = spectrum->bs_alter_scale + 1; - sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1; - if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) - return -1; - - for (k = 1; k <= sbr->n_master; k++) - sbr->f_master[k] = dk; - - k2diff = sbr->k[2] - sbr->k[0] - sbr->n_master * dk; - if (k2diff < 0) { - sbr->f_master[1]--; - sbr->f_master[2]-= (k2diff < -1); - } else if (k2diff) { - sbr->f_master[sbr->n_master]++; - } - - sbr->f_master[0] = sbr->k[0]; - for (k = 1; k <= sbr->n_master; k++) - sbr->f_master[k] += sbr->f_master[k - 1]; - - } else { - int half_bands = 7 - spectrum->bs_freq_scale; // bs_freq_scale = {1,2,3} - int two_regions, num_bands_0; - int vdk0_max, vdk1_min; - int16_t vk0[49]; - - if (49 * sbr->k[2] > 110 * sbr->k[0]) { - two_regions = 1; - sbr->k[1] = 2 * sbr->k[0]; - } else { - two_regions = 0; - sbr->k[1] = sbr->k[2]; - } - - num_bands_0 = lrintf(half_bands * log2f(sbr->k[1] / (float)sbr->k[0])) * 2; - - if (num_bands_0 <= 0) { // Requirements (14496-3 sp04 p205) - av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0); - return -1; - } - - vk0[0] = 0; - - make_bands(vk0+1, sbr->k[0], sbr->k[1], num_bands_0); - - qsort(vk0 + 1, num_bands_0, sizeof(vk0[1]), qsort_comparison_function_int16); - vdk0_max = vk0[num_bands_0]; - - vk0[0] = sbr->k[0]; - for (k = 1; k <= num_bands_0; k++) { - if (vk0[k] <= 0) { // Requirements (14496-3 sp04 p205) - av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]); - return -1; - } - vk0[k] += vk0[k-1]; - } - - if (two_regions) { - int16_t vk1[49]; - float invwarp = spectrum->bs_alter_scale ? 0.76923076923076923077f - : 1.0f; // bs_alter_scale = {0,1} - int num_bands_1 = lrintf(half_bands * invwarp * - log2f(sbr->k[2] / (float)sbr->k[1])) * 2; - - make_bands(vk1+1, sbr->k[1], sbr->k[2], num_bands_1); - - vdk1_min = array_min_int16(vk1 + 1, num_bands_1); - - if (vdk1_min < vdk0_max) { - int change; - qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16); - change = FFMIN(vdk0_max - vk1[1], (vk1[num_bands_1] - vk1[1]) >> 1); - vk1[1] += change; - vk1[num_bands_1] -= change; - } - - qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16); - - vk1[0] = sbr->k[1]; - for (k = 1; k <= num_bands_1; k++) { - if (vk1[k] <= 0) { // Requirements (14496-3 sp04 p205) - av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]); - return -1; - } - vk1[k] += vk1[k-1]; - } - - sbr->n_master = num_bands_0 + num_bands_1; - if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) - return -1; - memcpy(&sbr->f_master[0], vk0, - (num_bands_0 + 1) * sizeof(sbr->f_master[0])); - memcpy(&sbr->f_master[num_bands_0 + 1], vk1 + 1, - num_bands_1 * sizeof(sbr->f_master[0])); - - } else { - sbr->n_master = num_bands_0; - if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) - return -1; - memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0])); - } - } - - return 0; -} - -/// High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46) -static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr) -{ - int i, k, last_k = -1, last_msb = -1, sb = 0; - int msb = sbr->k[0]; - int usb = sbr->kx[1]; - int goal_sb = ((1000 << 11) + (sbr->sample_rate >> 1)) / sbr->sample_rate; - - sbr->num_patches = 0; - - if (goal_sb < sbr->kx[1] + sbr->m[1]) { - for (k = 0; sbr->f_master[k] < goal_sb; k++) ; - } else - k = sbr->n_master; - - do { - int odd = 0; - if (k == last_k && msb == last_msb) { - av_log(ac->avctx, AV_LOG_ERROR, "patch construction failed\n"); - return AVERROR_INVALIDDATA; - } - last_k = k; - last_msb = msb; - for (i = k; i == k || sb > (sbr->k[0] - 1 + msb - odd); i--) { - sb = sbr->f_master[i]; - odd = (sb + sbr->k[0]) & 1; - } - - // Requirements (14496-3 sp04 p205) sets the maximum number of patches to 5. - // After this check the final number of patches can still be six which is - // illegal however the Coding Technologies decoder check stream has a final - // count of 6 patches - if (sbr->num_patches > 5) { - av_log(ac->avctx, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches); - return -1; - } - - sbr->patch_num_subbands[sbr->num_patches] = FFMAX(sb - usb, 0); - sbr->patch_start_subband[sbr->num_patches] = sbr->k[0] - odd - sbr->patch_num_subbands[sbr->num_patches]; - - if (sbr->patch_num_subbands[sbr->num_patches] > 0) { - usb = sb; - msb = sb; - sbr->num_patches++; - } else - msb = sbr->kx[1]; - - if (sbr->f_master[k] - sb < 3) - k = sbr->n_master; - } while (sb != sbr->kx[1] + sbr->m[1]); - - if (sbr->num_patches > 1 && - sbr->patch_num_subbands[sbr->num_patches - 1] < 3) - sbr->num_patches--; - - return 0; -} - -/// Derived Frequency Band Tables (14496-3 sp04 p197) -static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr) -{ - int k, temp; - - sbr->n[1] = sbr->n_master - sbr->spectrum_params.bs_xover_band; - sbr->n[0] = (sbr->n[1] + 1) >> 1; - - memcpy(sbr->f_tablehigh, &sbr->f_master[sbr->spectrum_params.bs_xover_band], - (sbr->n[1] + 1) * sizeof(sbr->f_master[0])); - sbr->m[1] = sbr->f_tablehigh[sbr->n[1]] - sbr->f_tablehigh[0]; - sbr->kx[1] = sbr->f_tablehigh[0]; - - // Requirements (14496-3 sp04 p205) - if (sbr->kx[1] + sbr->m[1] > 64) { - av_log(ac->avctx, AV_LOG_ERROR, - "Stop frequency border too high: %d\n", sbr->kx[1] + sbr->m[1]); - return -1; - } - if (sbr->kx[1] > 32) { - av_log(ac->avctx, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]); - return -1; - } - - sbr->f_tablelow[0] = sbr->f_tablehigh[0]; - temp = sbr->n[1] & 1; - for (k = 1; k <= sbr->n[0]; k++) - sbr->f_tablelow[k] = sbr->f_tablehigh[2 * k - temp]; - - sbr->n_q = FFMAX(1, lrintf(sbr->spectrum_params.bs_noise_bands * - log2f(sbr->k[2] / (float)sbr->kx[1]))); // 0 <= bs_noise_bands <= 3 - if (sbr->n_q > 5) { - av_log(ac->avctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q); - return -1; - } - - sbr->f_tablenoise[0] = sbr->f_tablelow[0]; - temp = 0; - for (k = 1; k <= sbr->n_q; k++) { - temp += (sbr->n[0] - temp) / (sbr->n_q + 1 - k); - sbr->f_tablenoise[k] = sbr->f_tablelow[temp]; - } - - if (sbr_hf_calc_npatches(ac, sbr) < 0) - return -1; - - sbr_make_f_tablelim(sbr); - - sbr->data[0].f_indexnoise = 0; - sbr->data[1].f_indexnoise = 0; - - return 0; -} - -static av_always_inline void get_bits1_vector(GetBitContext *gb, uint8_t *vec, - int elements) -{ - int i; - for (i = 0; i < elements; i++) { - vec[i] = get_bits1(gb); - } -} - -/** ceil(log2(index+1)) */ -static const int8_t ceil_log2[] = { - 0, 1, 2, 2, 3, 3, -}; - -static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, - GetBitContext *gb, SBRData *ch_data) -{ - int i; - int bs_pointer = 0; - // frameLengthFlag ? 15 : 16; 960 sample length frames unsupported; this value is numTimeSlots - int abs_bord_trail = 16; - int num_rel_lead, num_rel_trail; - unsigned bs_num_env_old = ch_data->bs_num_env; - - ch_data->bs_freq_res[0] = ch_data->bs_freq_res[ch_data->bs_num_env]; - ch_data->bs_amp_res = sbr->bs_amp_res_header; - ch_data->t_env_num_env_old = ch_data->t_env[bs_num_env_old]; - - switch (ch_data->bs_frame_class = get_bits(gb, 2)) { - case FIXFIX: - ch_data->bs_num_env = 1 << get_bits(gb, 2); - num_rel_lead = ch_data->bs_num_env - 1; - if (ch_data->bs_num_env == 1) - ch_data->bs_amp_res = 0; - - if (ch_data->bs_num_env > 4) { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n", - ch_data->bs_num_env); - return -1; - } - - ch_data->t_env[0] = 0; - ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; - - abs_bord_trail = (abs_bord_trail + (ch_data->bs_num_env >> 1)) / - ch_data->bs_num_env; - for (i = 0; i < num_rel_lead; i++) - ch_data->t_env[i + 1] = ch_data->t_env[i] + abs_bord_trail; - - ch_data->bs_freq_res[1] = get_bits1(gb); - for (i = 1; i < ch_data->bs_num_env; i++) - ch_data->bs_freq_res[i + 1] = ch_data->bs_freq_res[1]; - break; - case FIXVAR: - abs_bord_trail += get_bits(gb, 2); - num_rel_trail = get_bits(gb, 2); - ch_data->bs_num_env = num_rel_trail + 1; - ch_data->t_env[0] = 0; - ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; - - for (i = 0; i < num_rel_trail; i++) - ch_data->t_env[ch_data->bs_num_env - 1 - i] = - ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2; - - bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); - - for (i = 0; i < ch_data->bs_num_env; i++) - ch_data->bs_freq_res[ch_data->bs_num_env - i] = get_bits1(gb); - break; - case VARFIX: - ch_data->t_env[0] = get_bits(gb, 2); - num_rel_lead = get_bits(gb, 2); - ch_data->bs_num_env = num_rel_lead + 1; - ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; - - for (i = 0; i < num_rel_lead; i++) - ch_data->t_env[i + 1] = ch_data->t_env[i] + 2 * get_bits(gb, 2) + 2; - - bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); - - get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env); - break; - case VARVAR: - ch_data->t_env[0] = get_bits(gb, 2); - abs_bord_trail += get_bits(gb, 2); - num_rel_lead = get_bits(gb, 2); - num_rel_trail = get_bits(gb, 2); - ch_data->bs_num_env = num_rel_lead + num_rel_trail + 1; - - if (ch_data->bs_num_env > 5) { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n", - ch_data->bs_num_env); - return -1; - } - - ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; - - for (i = 0; i < num_rel_lead; i++) - ch_data->t_env[i + 1] = ch_data->t_env[i] + 2 * get_bits(gb, 2) + 2; - for (i = 0; i < num_rel_trail; i++) - ch_data->t_env[ch_data->bs_num_env - 1 - i] = - ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2; - - bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); - - get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env); - break; - } - - av_assert0(bs_pointer >= 0); - if (bs_pointer > ch_data->bs_num_env + 1) { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n", - bs_pointer); - return -1; - } - - for (i = 1; i <= ch_data->bs_num_env; i++) { - if (ch_data->t_env[i-1] > ch_data->t_env[i]) { - av_log(ac->avctx, AV_LOG_ERROR, "Non monotone time borders\n"); - return -1; - } - } - - ch_data->bs_num_noise = (ch_data->bs_num_env > 1) + 1; - - ch_data->t_q[0] = ch_data->t_env[0]; - ch_data->t_q[ch_data->bs_num_noise] = ch_data->t_env[ch_data->bs_num_env]; - if (ch_data->bs_num_noise > 1) { - int idx; - if (ch_data->bs_frame_class == FIXFIX) { - idx = ch_data->bs_num_env >> 1; - } else if (ch_data->bs_frame_class & 1) { // FIXVAR or VARVAR - idx = ch_data->bs_num_env - FFMAX(bs_pointer - 1, 1); - } else { // VARFIX - if (!bs_pointer) - idx = 1; - else if (bs_pointer == 1) - idx = ch_data->bs_num_env - 1; - else // bs_pointer > 1 - idx = bs_pointer - 1; - } - ch_data->t_q[1] = ch_data->t_env[idx]; - } - - ch_data->e_a[0] = -(ch_data->e_a[1] != bs_num_env_old); // l_APrev - ch_data->e_a[1] = -1; - if ((ch_data->bs_frame_class & 1) && bs_pointer) { // FIXVAR or VARVAR and bs_pointer != 0 - ch_data->e_a[1] = ch_data->bs_num_env + 1 - bs_pointer; - } else if ((ch_data->bs_frame_class == 2) && (bs_pointer > 1)) // VARFIX and bs_pointer > 1 - ch_data->e_a[1] = bs_pointer - 1; - - return 0; -} - -static void copy_sbr_grid(SBRData *dst, const SBRData *src) { - //These variables are saved from the previous frame rather than copied - dst->bs_freq_res[0] = dst->bs_freq_res[dst->bs_num_env]; - dst->t_env_num_env_old = dst->t_env[dst->bs_num_env]; - dst->e_a[0] = -(dst->e_a[1] != dst->bs_num_env); - - //These variables are read from the bitstream and therefore copied - memcpy(dst->bs_freq_res+1, src->bs_freq_res+1, sizeof(dst->bs_freq_res)-sizeof(*dst->bs_freq_res)); - memcpy(dst->t_env, src->t_env, sizeof(dst->t_env)); - memcpy(dst->t_q, src->t_q, sizeof(dst->t_q)); - dst->bs_num_env = src->bs_num_env; - dst->bs_amp_res = src->bs_amp_res; - dst->bs_num_noise = src->bs_num_noise; - dst->bs_frame_class = src->bs_frame_class; - dst->e_a[1] = src->e_a[1]; -} - -/// Read how the envelope and noise floor data is delta coded -static void read_sbr_dtdf(SpectralBandReplication *sbr, GetBitContext *gb, - SBRData *ch_data) -{ - get_bits1_vector(gb, ch_data->bs_df_env, ch_data->bs_num_env); - get_bits1_vector(gb, ch_data->bs_df_noise, ch_data->bs_num_noise); -} - -/// Read inverse filtering data -static void read_sbr_invf(SpectralBandReplication *sbr, GetBitContext *gb, - SBRData *ch_data) -{ - int i; - - memcpy(ch_data->bs_invf_mode[1], ch_data->bs_invf_mode[0], 5 * sizeof(uint8_t)); - for (i = 0; i < sbr->n_q; i++) - ch_data->bs_invf_mode[0][i] = get_bits(gb, 2); -} - -static void read_sbr_envelope(SpectralBandReplication *sbr, GetBitContext *gb, - SBRData *ch_data, int ch) -{ - int bits; - int i, j, k; - VLC_TYPE (*t_huff)[2], (*f_huff)[2]; - int t_lav, f_lav; - const int delta = (ch == 1 && sbr->bs_coupling == 1) + 1; - const int odd = sbr->n[1] & 1; - - if (sbr->bs_coupling && ch) { - if (ch_data->bs_amp_res) { - bits = 5; - t_huff = vlc_sbr[T_HUFFMAN_ENV_BAL_3_0DB].table; - t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_BAL_3_0DB]; - f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_3_0DB].table; - f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_3_0DB]; - } else { - bits = 6; - t_huff = vlc_sbr[T_HUFFMAN_ENV_BAL_1_5DB].table; - t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_BAL_1_5DB]; - f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_1_5DB].table; - f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_1_5DB]; - } - } else { - if (ch_data->bs_amp_res) { - bits = 6; - t_huff = vlc_sbr[T_HUFFMAN_ENV_3_0DB].table; - t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_3_0DB]; - f_huff = vlc_sbr[F_HUFFMAN_ENV_3_0DB].table; - f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB]; - } else { - bits = 7; - t_huff = vlc_sbr[T_HUFFMAN_ENV_1_5DB].table; - t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_1_5DB]; - f_huff = vlc_sbr[F_HUFFMAN_ENV_1_5DB].table; - f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_1_5DB]; - } - } - - for (i = 0; i < ch_data->bs_num_env; i++) { - if (ch_data->bs_df_env[i]) { - // bs_freq_res[0] == bs_freq_res[bs_num_env] from prev frame - if (ch_data->bs_freq_res[i + 1] == ch_data->bs_freq_res[i]) { - for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) - ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); - } else if (ch_data->bs_freq_res[i + 1]) { - for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { - k = (j + odd) >> 1; // find k such that f_tablelow[k] <= f_tablehigh[j] < f_tablelow[k + 1] - ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); - } - } else { - for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { - k = j ? 2*j - odd : 0; // find k such that f_tablehigh[k] == f_tablelow[j] - ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); - } - } - } else { - ch_data->env_facs[i + 1][0] = delta * get_bits(gb, bits); // bs_env_start_value_balance - for (j = 1; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) - ch_data->env_facs[i + 1][j] = ch_data->env_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); - } - } - - //assign 0th elements of env_facs from last elements - memcpy(ch_data->env_facs[0], ch_data->env_facs[ch_data->bs_num_env], - sizeof(ch_data->env_facs[0])); -} - -static void read_sbr_noise(SpectralBandReplication *sbr, GetBitContext *gb, - SBRData *ch_data, int ch) -{ - int i, j; - VLC_TYPE (*t_huff)[2], (*f_huff)[2]; - int t_lav, f_lav; - int delta = (ch == 1 && sbr->bs_coupling == 1) + 1; - - if (sbr->bs_coupling && ch) { - t_huff = vlc_sbr[T_HUFFMAN_NOISE_BAL_3_0DB].table; - t_lav = vlc_sbr_lav[T_HUFFMAN_NOISE_BAL_3_0DB]; - f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_3_0DB].table; - f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_3_0DB]; - } else { - t_huff = vlc_sbr[T_HUFFMAN_NOISE_3_0DB].table; - t_lav = vlc_sbr_lav[T_HUFFMAN_NOISE_3_0DB]; - f_huff = vlc_sbr[F_HUFFMAN_ENV_3_0DB].table; - f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB]; - } - - for (i = 0; i < ch_data->bs_num_noise; i++) { - if (ch_data->bs_df_noise[i]) { - for (j = 0; j < sbr->n_q; j++) - ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav); - } else { - ch_data->noise_facs[i + 1][0] = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level - for (j = 1; j < sbr->n_q; j++) - ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); - } - } - - //assign 0th elements of noise_facs from last elements - memcpy(ch_data->noise_facs[0], ch_data->noise_facs[ch_data->bs_num_noise], - sizeof(ch_data->noise_facs[0])); -} - -static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, - GetBitContext *gb, - int bs_extension_id, int *num_bits_left) -{ - switch (bs_extension_id) { - case EXTENSION_ID_PS: - if (!ac->oc[1].m4ac.ps) { - av_log(ac->avctx, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n"); - skip_bits_long(gb, *num_bits_left); // bs_fill_bits - *num_bits_left = 0; - } else { -#if 1 - *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps, *num_bits_left); - ac->avctx->profile = FF_PROFILE_AAC_HE_V2; -#else - avpriv_report_missing_feature(ac->avctx, "Parametric Stereo"); - skip_bits_long(gb, *num_bits_left); // bs_fill_bits - *num_bits_left = 0; -#endif - } - break; - default: - // some files contain 0-padding - if (bs_extension_id || *num_bits_left > 16 || show_bits(gb, *num_bits_left)) - avpriv_request_sample(ac->avctx, "Reserved SBR extensions"); - skip_bits_long(gb, *num_bits_left); // bs_fill_bits - *num_bits_left = 0; - break; - } -} - -static int read_sbr_single_channel_element(AACContext *ac, - SpectralBandReplication *sbr, - GetBitContext *gb) -{ - if (get_bits1(gb)) // bs_data_extra - skip_bits(gb, 4); // bs_reserved - - if (read_sbr_grid(ac, sbr, gb, &sbr->data[0])) - return -1; - read_sbr_dtdf(sbr, gb, &sbr->data[0]); - read_sbr_invf(sbr, gb, &sbr->data[0]); - read_sbr_envelope(sbr, gb, &sbr->data[0], 0); - read_sbr_noise(sbr, gb, &sbr->data[0], 0); - - if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb))) - get_bits1_vector(gb, sbr->data[0].bs_add_harmonic, sbr->n[1]); - - return 0; -} - -static int read_sbr_channel_pair_element(AACContext *ac, - SpectralBandReplication *sbr, - GetBitContext *gb) -{ - if (get_bits1(gb)) // bs_data_extra - skip_bits(gb, 8); // bs_reserved - - if ((sbr->bs_coupling = get_bits1(gb))) { - if (read_sbr_grid(ac, sbr, gb, &sbr->data[0])) - return -1; - copy_sbr_grid(&sbr->data[1], &sbr->data[0]); - read_sbr_dtdf(sbr, gb, &sbr->data[0]); - read_sbr_dtdf(sbr, gb, &sbr->data[1]); - read_sbr_invf(sbr, gb, &sbr->data[0]); - memcpy(sbr->data[1].bs_invf_mode[1], sbr->data[1].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0])); - memcpy(sbr->data[1].bs_invf_mode[0], sbr->data[0].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0])); - read_sbr_envelope(sbr, gb, &sbr->data[0], 0); - read_sbr_noise(sbr, gb, &sbr->data[0], 0); - read_sbr_envelope(sbr, gb, &sbr->data[1], 1); - read_sbr_noise(sbr, gb, &sbr->data[1], 1); - } else { - if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]) || - read_sbr_grid(ac, sbr, gb, &sbr->data[1])) - return -1; - read_sbr_dtdf(sbr, gb, &sbr->data[0]); - read_sbr_dtdf(sbr, gb, &sbr->data[1]); - read_sbr_invf(sbr, gb, &sbr->data[0]); - read_sbr_invf(sbr, gb, &sbr->data[1]); - read_sbr_envelope(sbr, gb, &sbr->data[0], 0); - read_sbr_envelope(sbr, gb, &sbr->data[1], 1); - read_sbr_noise(sbr, gb, &sbr->data[0], 0); - read_sbr_noise(sbr, gb, &sbr->data[1], 1); - } - - if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb))) - get_bits1_vector(gb, sbr->data[0].bs_add_harmonic, sbr->n[1]); - if ((sbr->data[1].bs_add_harmonic_flag = get_bits1(gb))) - get_bits1_vector(gb, sbr->data[1].bs_add_harmonic, sbr->n[1]); - - return 0; -} - -static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, - GetBitContext *gb, int id_aac) -{ - unsigned int cnt = get_bits_count(gb); - - if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) { - if (read_sbr_single_channel_element(ac, sbr, gb)) { - sbr_turnoff(sbr); - return get_bits_count(gb) - cnt; - } - } else if (id_aac == TYPE_CPE) { - if (read_sbr_channel_pair_element(ac, sbr, gb)) { - sbr_turnoff(sbr); - return get_bits_count(gb) - cnt; - } - } else { - av_log(ac->avctx, AV_LOG_ERROR, - "Invalid bitstream - cannot apply SBR to element type %d\n", id_aac); - sbr_turnoff(sbr); - return get_bits_count(gb) - cnt; - } - if (get_bits1(gb)) { // bs_extended_data - int num_bits_left = get_bits(gb, 4); // bs_extension_size - if (num_bits_left == 15) - num_bits_left += get_bits(gb, 8); // bs_esc_count - - num_bits_left <<= 3; - while (num_bits_left > 7) { - num_bits_left -= 2; - read_sbr_extension(ac, sbr, gb, get_bits(gb, 2), &num_bits_left); // bs_extension_id - } - if (num_bits_left < 0) { - av_log(ac->avctx, AV_LOG_ERROR, "SBR Extension over read.\n"); - } - if (num_bits_left > 0) - skip_bits(gb, num_bits_left); - } - - return get_bits_count(gb) - cnt; -} - -static void sbr_reset(AACContext *ac, SpectralBandReplication *sbr) -{ - int err; - err = sbr_make_f_master(ac, sbr, &sbr->spectrum_params); - if (err >= 0) - err = sbr_make_f_derived(ac, sbr); - if (err < 0) { - av_log(ac->avctx, AV_LOG_ERROR, - "SBR reset failed. Switching SBR to pure upsampling mode.\n"); - sbr_turnoff(sbr); - } -} - -/** - * Decode Spectral Band Replication extension data; reference: table 4.55. - * - * @param crc flag indicating the presence of CRC checksum - * @param cnt length of TYPE_FIL syntactic element in bytes - * - * @return Returns number of bytes consumed from the TYPE_FIL element. - */ -int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, - GetBitContext *gb_host, int crc, int cnt, int id_aac) -{ - unsigned int num_sbr_bits = 0, num_align_bits; - unsigned bytes_read; - GetBitContext gbc = *gb_host, *gb = &gbc; - skip_bits_long(gb_host, cnt*8 - 4); - - sbr->reset = 0; - - if (!sbr->sample_rate) - sbr->sample_rate = 2 * ac->oc[1].m4ac.sample_rate; //TODO use the nominal sample rate for arbitrary sample rate support - if (!ac->oc[1].m4ac.ext_sample_rate) - ac->oc[1].m4ac.ext_sample_rate = 2 * ac->oc[1].m4ac.sample_rate; - - if (crc) { - skip_bits(gb, 10); // bs_sbr_crc_bits; TODO - implement CRC check - num_sbr_bits += 10; - } - - //Save some state from the previous frame. - sbr->kx[0] = sbr->kx[1]; - sbr->m[0] = sbr->m[1]; - sbr->kx_and_m_pushed = 1; - - num_sbr_bits++; - if (get_bits1(gb)) // bs_header_flag - num_sbr_bits += read_sbr_header(sbr, gb); - - if (sbr->reset) - sbr_reset(ac, sbr); - - if (sbr->start) - num_sbr_bits += read_sbr_data(ac, sbr, gb, id_aac); - - num_align_bits = ((cnt << 3) - 4 - num_sbr_bits) & 7; - bytes_read = ((num_sbr_bits + num_align_bits + 4) >> 3); - - if (bytes_read > cnt) { - av_log(ac->avctx, AV_LOG_ERROR, - "Expected to read %d SBR bytes actually read %d.\n", cnt, bytes_read); - } - return cnt; -} - /// Dequantization and stereo decoding (14496-3 sp04 p203) static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) { @@ -1179,84 +126,6 @@ } } -/** - * Analysis QMF Bank (14496-3 sp04 p206) - * - * @param x pointer to the beginning of the first sample window - * @param W array of complex-valued samples split into subbands - */ -#ifndef sbr_qmf_analysis -static void sbr_qmf_analysis(AVFloatDSPContext *dsp, FFTContext *mdct, - SBRDSPContext *sbrdsp, const float *in, float *x, - float z[320], float W[2][32][32][2], int buf_idx) -{ - int i; - memcpy(x , x+1024, (320-32)*sizeof(x[0])); - memcpy(x+288, in, 1024*sizeof(x[0])); - for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames - // are not supported - dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320); - sbrdsp->sum64x5(z); - sbrdsp->qmf_pre_shuffle(z); - mdct->imdct_half(mdct, z, z+64); - sbrdsp->qmf_post_shuffle(W[buf_idx][i], z); - x += 32; - } -} -#endif - -/** - * Synthesis QMF Bank (14496-3 sp04 p206) and Downsampled Synthesis QMF Bank - * (14496-3 sp04 p206) - */ -#ifndef sbr_qmf_synthesis -static void sbr_qmf_synthesis(FFTContext *mdct, - SBRDSPContext *sbrdsp, AVFloatDSPContext *dsp, - float *out, float X[2][38][64], - float mdct_buf[2][64], - float *v0, int *v_off, const unsigned int div) -{ - int i, n; - const float *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us; - const int step = 128 >> div; - float *v; - for (i = 0; i < 32; i++) { - if (*v_off < step) { - int saved_samples = (1280 - 128) >> div; - memcpy(&v0[SBR_SYNTHESIS_BUF_SIZE - saved_samples], v0, saved_samples * sizeof(float)); - *v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - step; - } else { - *v_off -= step; - } - v = v0 + *v_off; - if (div) { - for (n = 0; n < 32; n++) { - X[0][i][ n] = -X[0][i][n]; - X[0][i][32+n] = X[1][i][31-n]; - } - mdct->imdct_half(mdct, mdct_buf[0], X[0][i]); - sbrdsp->qmf_deint_neg(v, mdct_buf[0]); - } else { - sbrdsp->neg_odd_64(X[1][i]); - mdct->imdct_half(mdct, mdct_buf[0], X[0][i]); - mdct->imdct_half(mdct, mdct_buf[1], X[1][i]); - sbrdsp->qmf_deint_bfly(v, mdct_buf[1], mdct_buf[0]); - } - dsp->vector_fmul (out, v , sbr_qmf_window , 64 >> div); - dsp->vector_fmul_add(out, v + ( 192 >> div), sbr_qmf_window + ( 64 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + ( 256 >> div), sbr_qmf_window + (128 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + ( 448 >> div), sbr_qmf_window + (192 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + ( 512 >> div), sbr_qmf_window + (256 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + ( 704 >> div), sbr_qmf_window + (320 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + ( 768 >> div), sbr_qmf_window + (384 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + ( 960 >> div), sbr_qmf_window + (448 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + (1024 >> div), sbr_qmf_window + (512 >> div), out , 64 >> div); - dsp->vector_fmul_add(out, v + (1216 >> div), sbr_qmf_window + (576 >> div), out , 64 >> div); - out += 64 >> div; - } -} -#endif - /** High Frequency Generation (14496-3 sp04 p214+) and Inverse Filtering * (14496-3 sp04 p214) * Warning: This routine does not seem numerically stable. @@ -1336,203 +205,6 @@ } } -/// Generate the subband filtered lowband -static int sbr_lf_gen(AACContext *ac, SpectralBandReplication *sbr, - float X_low[32][40][2], const float W[2][32][32][2], - int buf_idx) -{ - int i, k; - const int t_HFGen = 8; - const int i_f = 32; - memset(X_low, 0, 32*sizeof(*X_low)); - for (k = 0; k < sbr->kx[1]; k++) { - for (i = t_HFGen; i < i_f + t_HFGen; i++) { - X_low[k][i][0] = W[buf_idx][i - t_HFGen][k][0]; - X_low[k][i][1] = W[buf_idx][i - t_HFGen][k][1]; - } - } - buf_idx = 1-buf_idx; - for (k = 0; k < sbr->kx[0]; k++) { - for (i = 0; i < t_HFGen; i++) { - X_low[k][i][0] = W[buf_idx][i + i_f - t_HFGen][k][0]; - X_low[k][i][1] = W[buf_idx][i + i_f - t_HFGen][k][1]; - } - } - return 0; -} - -/// High Frequency Generator (14496-3 sp04 p215) -static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, - float X_high[64][40][2], const float X_low[32][40][2], - const float (*alpha0)[2], const float (*alpha1)[2], - const float bw_array[5], const uint8_t *t_env, - int bs_num_env) -{ - int j, x; - int g = 0; - int k = sbr->kx[1]; - for (j = 0; j < sbr->num_patches; j++) { - for (x = 0; x < sbr->patch_num_subbands[j]; x++, k++) { - const int p = sbr->patch_start_subband[j] + x; - while (g <= sbr->n_q && k >= sbr->f_tablenoise[g]) - g++; - g--; - - if (g < 0) { - av_log(ac->avctx, AV_LOG_ERROR, - "ERROR : no subband found for frequency %d\n", k); - return -1; - } - - sbr->dsp.hf_gen(X_high[k] + ENVELOPE_ADJUSTMENT_OFFSET, - X_low[p] + ENVELOPE_ADJUSTMENT_OFFSET, - alpha0[p], alpha1[p], bw_array[g], - 2 * t_env[0], 2 * t_env[bs_num_env]); - } - } - if (k < sbr->m[1] + sbr->kx[1]) - memset(X_high + k, 0, (sbr->m[1] + sbr->kx[1] - k) * sizeof(*X_high)); - - return 0; -} - -/// Generate the subband filtered lowband -static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][38][64], - const float Y0[38][64][2], const float Y1[38][64][2], - const float X_low[32][40][2], int ch) -{ - int k, i; - const int i_f = 32; - const int i_Temp = FFMAX(2*sbr->data[ch].t_env_num_env_old - i_f, 0); - memset(X, 0, 2*sizeof(*X)); - for (k = 0; k < sbr->kx[0]; k++) { - for (i = 0; i < i_Temp; i++) { - X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; - X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; - } - } - for (; k < sbr->kx[0] + sbr->m[0]; k++) { - for (i = 0; i < i_Temp; i++) { - X[0][i][k] = Y0[i + i_f][k][0]; - X[1][i][k] = Y0[i + i_f][k][1]; - } - } - - for (k = 0; k < sbr->kx[1]; k++) { - for (i = i_Temp; i < 38; i++) { - X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; - X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; - } - } - for (; k < sbr->kx[1] + sbr->m[1]; k++) { - for (i = i_Temp; i < i_f; i++) { - X[0][i][k] = Y1[i][k][0]; - X[1][i][k] = Y1[i][k][1]; - } - } - return 0; -} - -/** High Frequency Adjustment (14496-3 sp04 p217) and Mapping - * (14496-3 sp04 p217) - */ -static int sbr_mapping(AACContext *ac, SpectralBandReplication *sbr, - SBRData *ch_data, int e_a[2]) -{ - int e, i, m; - - memset(ch_data->s_indexmapped[1], 0, 7*sizeof(ch_data->s_indexmapped[1])); - for (e = 0; e < ch_data->bs_num_env; e++) { - const unsigned int ilim = sbr->n[ch_data->bs_freq_res[e + 1]]; - uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow; - int k; - - if (sbr->kx[1] != table[0]) { - av_log(ac->avctx, AV_LOG_ERROR, "kx != f_table{high,low}[0]. " - "Derived frequency tables were not regenerated.\n"); - sbr_turnoff(sbr); - return AVERROR_BUG; - } - for (i = 0; i < ilim; i++) - for (m = table[i]; m < table[i + 1]; m++) - sbr->e_origmapped[e][m - sbr->kx[1]] = ch_data->env_facs[e+1][i]; - - // ch_data->bs_num_noise > 1 => 2 noise floors - k = (ch_data->bs_num_noise > 1) && (ch_data->t_env[e] >= ch_data->t_q[1]); - for (i = 0; i < sbr->n_q; i++) - for (m = sbr->f_tablenoise[i]; m < sbr->f_tablenoise[i + 1]; m++) - sbr->q_mapped[e][m - sbr->kx[1]] = ch_data->noise_facs[k+1][i]; - - for (i = 0; i < sbr->n[1]; i++) { - if (ch_data->bs_add_harmonic_flag) { - const unsigned int m_midpoint = - (sbr->f_tablehigh[i] + sbr->f_tablehigh[i + 1]) >> 1; - - ch_data->s_indexmapped[e + 1][m_midpoint - sbr->kx[1]] = ch_data->bs_add_harmonic[i] * - (e >= e_a[1] || (ch_data->s_indexmapped[0][m_midpoint - sbr->kx[1]] == 1)); - } - } - - for (i = 0; i < ilim; i++) { - int additional_sinusoid_present = 0; - for (m = table[i]; m < table[i + 1]; m++) { - if (ch_data->s_indexmapped[e + 1][m - sbr->kx[1]]) { - additional_sinusoid_present = 1; - break; - } - } - memset(&sbr->s_mapped[e][table[i] - sbr->kx[1]], additional_sinusoid_present, - (table[i + 1] - table[i]) * sizeof(sbr->s_mapped[e][0])); - } - } - - memcpy(ch_data->s_indexmapped[0], ch_data->s_indexmapped[ch_data->bs_num_env], sizeof(ch_data->s_indexmapped[0])); - return 0; -} - -/// Estimation of current envelope (14496-3 sp04 p218) -static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2], - SpectralBandReplication *sbr, SBRData *ch_data) -{ - int e, m; - int kx1 = sbr->kx[1]; - - if (sbr->bs_interpol_freq) { - for (e = 0; e < ch_data->bs_num_env; e++) { - const float recip_env_size = 0.5f / (ch_data->t_env[e + 1] - ch_data->t_env[e]); - int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; - int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; - - for (m = 0; m < sbr->m[1]; m++) { - float sum = sbr->dsp.sum_square(X_high[m+kx1] + ilb, iub - ilb); - e_curr[e][m] = sum * recip_env_size; - } - } - } else { - int k, p; - - for (e = 0; e < ch_data->bs_num_env; e++) { - const int env_size = 2 * (ch_data->t_env[e + 1] - ch_data->t_env[e]); - int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; - int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; - const uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow; - - for (p = 0; p < sbr->n[ch_data->bs_freq_res[e + 1]]; p++) { - float sum = 0.0f; - const int den = env_size * (table[p + 1] - table[p]); - - for (k = table[p]; k < table[p + 1]; k++) { - sum += sbr->dsp.sum_square(X_high[k] + ilb, iub - ilb); - } - sum /= den; - for (k = table[p]; k < table[p + 1]; k++) { - e_curr[e][k - kx1] = sum; - } - } - } - } -} - /** * Calculation of levels of additional HF signal components (14496-3 sp04 p219) * and Calculation of gain (14496-3 sp04 p219) @@ -1687,92 +359,4 @@ ch_data->f_indexsine = indexsine; } -void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, - float* L, float* R) -{ - int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate; - int ch; - int nch = (id_aac == TYPE_CPE) ? 2 : 1; - int err; - - if (!sbr->kx_and_m_pushed) { - sbr->kx[0] = sbr->kx[1]; - sbr->m[0] = sbr->m[1]; - } else { - sbr->kx_and_m_pushed = 0; - } - - if (sbr->start) { - sbr_dequant(sbr, id_aac); - } - for (ch = 0; ch < nch; ch++) { - /* decode channel */ - sbr_qmf_analysis(ac->fdsp, &sbr->mdct_ana, &sbr->dsp, ch ? R : L, sbr->data[ch].analysis_filterbank_samples, - (float*)sbr->qmf_filter_scratch, - sbr->data[ch].W, sbr->data[ch].Ypos); - sbr->c.sbr_lf_gen(ac, sbr, sbr->X_low, - (const float (*)[32][32][2]) sbr->data[ch].W, - sbr->data[ch].Ypos); - sbr->data[ch].Ypos ^= 1; - if (sbr->start) { - sbr->c.sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1, - (const float (*)[40][2]) sbr->X_low, sbr->k[0]); - sbr_chirp(sbr, &sbr->data[ch]); - sbr_hf_gen(ac, sbr, sbr->X_high, - (const float (*)[40][2]) sbr->X_low, - (const float (*)[2]) sbr->alpha0, - (const float (*)[2]) sbr->alpha1, - sbr->data[ch].bw_array, sbr->data[ch].t_env, - sbr->data[ch].bs_num_env); - - // hf_adj - err = sbr_mapping(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a); - if (!err) { - sbr_env_estimate(sbr->e_curr, sbr->X_high, sbr, &sbr->data[ch]); - sbr_gain_calc(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a); - sbr->c.sbr_hf_assemble(sbr->data[ch].Y[sbr->data[ch].Ypos], - (const float (*)[40][2]) sbr->X_high, - sbr, &sbr->data[ch], - sbr->data[ch].e_a); - } - } - - /* synthesis */ - sbr->c.sbr_x_gen(sbr, sbr->X[ch], - (const float (*)[64][2]) sbr->data[ch].Y[1-sbr->data[ch].Ypos], - (const float (*)[64][2]) sbr->data[ch].Y[ sbr->data[ch].Ypos], - (const float (*)[40][2]) sbr->X_low, ch); - } - - if (ac->oc[1].m4ac.ps == 1) { - if (sbr->ps.start) { - ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); - } else { - memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0])); - } - nch = 2; - } - - sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, ac->fdsp, - L, sbr->X[0], sbr->qmf_filter_scratch, - sbr->data[0].synthesis_filterbank_samples, - &sbr->data[0].synthesis_filterbank_samples_offset, - downsampled); - if (nch == 2) - sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, ac->fdsp, - R, sbr->X[1], sbr->qmf_filter_scratch, - sbr->data[1].synthesis_filterbank_samples, - &sbr->data[1].synthesis_filterbank_samples_offset, - downsampled); -} - -static void aacsbr_func_ptr_init(AACSBRContext *c) -{ - c->sbr_lf_gen = sbr_lf_gen; - c->sbr_hf_assemble = sbr_hf_assemble; - c->sbr_x_gen = sbr_x_gen; - c->sbr_hf_inverse_filter = sbr_hf_inverse_filter; - - if(ARCH_MIPS) - ff_aacsbr_func_ptr_init_mips(c); -} +#include "aacsbr_template.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbrdata.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbrdata.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbrdata.h 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbrdata.h 2015-07-25 17:20:02.000000000 +0000 @@ -30,6 +30,7 @@ #include #include "libavutil/mem.h" +#include "aac_defines.h" ///< Huffman tables for SBR @@ -267,268 +268,268 @@ }; /* First eight entries repeated at end to simplify SIMD implementations. */ -const DECLARE_ALIGNED(16, float, ff_sbr_noise_table)[][2] = { -{-0.99948153278296, -0.59483417516607}, { 0.97113454393991, -0.67528515225647}, -{ 0.14130051758487, -0.95090983575689}, {-0.47005496701697, -0.37340549728647}, -{ 0.80705063769351, 0.29653668284408}, {-0.38981478896926, 0.89572605717087}, -{-0.01053049862020, -0.66959058036166}, {-0.91266367957293, -0.11522938140034}, -{ 0.54840422910309, 0.75221367176302}, { 0.40009252867955, -0.98929400334421}, -{-0.99867974711855, -0.88147068645358}, {-0.95531076805040, 0.90908757154593}, -{-0.45725933317144, -0.56716323646760}, {-0.72929675029275, -0.98008272727324}, -{ 0.75622801399036, 0.20950329995549}, { 0.07069442601050, -0.78247898470706}, -{ 0.74496252926055, -0.91169004445807}, {-0.96440182703856, -0.94739918296622}, -{ 0.30424629369539, -0.49438267012479}, { 0.66565033746925, 0.64652935542491}, -{ 0.91697008020594, 0.17514097332009}, {-0.70774918760427, 0.52548653416543}, -{-0.70051415345560, -0.45340028808763}, {-0.99496513054797, -0.90071908066973}, -{ 0.98164490790123, -0.77463155528697}, {-0.54671580548181, -0.02570928536004}, -{-0.01689629065389, 0.00287506445732}, {-0.86110349531986, 0.42548583726477}, -{-0.98892980586032, -0.87881132267556}, { 0.51756627678691, 0.66926784710139}, -{-0.99635026409640, -0.58107730574765}, {-0.99969370862163, 0.98369989360250}, -{ 0.55266258627194, 0.59449057465591}, { 0.34581177741673, 0.94879421061866}, -{ 0.62664209577999, -0.74402970906471}, {-0.77149701404973, -0.33883658042801}, -{-0.91592244254432, 0.03687901376713}, {-0.76285492357887, -0.91371867919124}, -{ 0.79788337195331, -0.93180971199849}, { 0.54473080610200, -0.11919206037186}, -{-0.85639281671058, 0.42429854760451}, {-0.92882402971423, 0.27871809078609}, -{-0.11708371046774, -0.99800843444966}, { 0.21356749817493, -0.90716295627033}, -{-0.76191692573909, 0.99768118356265}, { 0.98111043100884, -0.95854459734407}, -{-0.85913269895572, 0.95766566168880}, {-0.93307242253692, 0.49431757696466}, -{ 0.30485754879632, -0.70540034357529}, { 0.85289650925190, 0.46766131791044}, -{ 0.91328082618125, -0.99839597361769}, {-0.05890199924154, 0.70741827819497}, -{ 0.28398686150148, 0.34633555702188}, { 0.95258164539612, -0.54893416026939}, -{-0.78566324168507, -0.75568541079691}, {-0.95789495447877, -0.20423194696966}, -{ 0.82411158711197, 0.96654618432562}, {-0.65185446735885, -0.88734990773289}, -{-0.93643603134666, 0.99870790442385}, { 0.91427159529618, -0.98290505544444}, -{-0.70395684036886, 0.58796798221039}, { 0.00563771969365, 0.61768196727244}, -{ 0.89065051931895, 0.52783352697585}, {-0.68683707712762, 0.80806944710339}, -{ 0.72165342518718, -0.69259857349564}, {-0.62928247730667, 0.13627037407335}, -{ 0.29938434065514, -0.46051329682246}, {-0.91781958879280, -0.74012716684186}, -{ 0.99298717043688, 0.40816610075661}, { 0.82368298622748, -0.74036047190173}, -{-0.98512833386833, -0.99972330709594}, {-0.95915368242257, -0.99237800466040}, -{-0.21411126572790, -0.93424819052545}, {-0.68821476106884, -0.26892306315457}, -{ 0.91851997982317, 0.09358228901785}, {-0.96062769559127, 0.36099095133739}, -{ 0.51646184922287, -0.71373332873917}, { 0.61130721139669, 0.46950141175917}, -{ 0.47336129371299, -0.27333178296162}, { 0.90998308703519, 0.96715662938132}, -{ 0.44844799194357, 0.99211574628306}, { 0.66614891079092, 0.96590176169121}, -{ 0.74922239129237, -0.89879858826087}, {-0.99571588506485, 0.52785521494349}, -{ 0.97401082477563, -0.16855870075190}, { 0.72683747733879, -0.48060774432251}, -{ 0.95432193457128, 0.68849603408441}, {-0.72962208425191, -0.76608443420917}, -{-0.85359479233537, 0.88738125901579}, {-0.81412430338535, -0.97480768049637}, -{-0.87930772356786, 0.74748307690436}, {-0.71573331064977, -0.98570608178923}, -{ 0.83524300028228, 0.83702537075163}, {-0.48086065601423, -0.98848504923531}, -{ 0.97139128574778, 0.80093621198236}, { 0.51992825347895, 0.80247631400510}, -{-0.00848591195325, -0.76670128000486}, {-0.70294374303036, 0.55359910445577}, -{-0.95894428168140, -0.43265504344783}, { 0.97079252950321, 0.09325857238682}, -{-0.92404293670797, 0.85507704027855}, {-0.69506469500450, 0.98633412625459}, -{ 0.26559203620024, 0.73314307966524}, { 0.28038443336943, 0.14537913654427}, -{-0.74138124825523, 0.99310339807762}, {-0.01752795995444, -0.82616635284178}, -{-0.55126773094930, -0.98898543862153}, { 0.97960898850996, -0.94021446752851}, -{-0.99196309146936, 0.67019017358456}, {-0.67684928085260, 0.12631491649378}, -{ 0.09140039465500, -0.20537731453108}, {-0.71658965751996, -0.97788200391224}, -{ 0.81014640078925, 0.53722648362443}, { 0.40616991671205, -0.26469008598449}, -{-0.67680188682972, 0.94502052337695}, { 0.86849774348749, -0.18333598647899}, -{-0.99500381284851, -0.02634122068550}, { 0.84329189340667, 0.10406957462213}, -{-0.09215968531446, 0.69540012101253}, { 0.99956173327206, -0.12358542001404}, -{-0.79732779473535, -0.91582524736159}, { 0.96349973642406, 0.96640458041000}, -{-0.79942778496547, 0.64323902822857}, {-0.11566039853896, 0.28587846253726}, -{-0.39922954514662, 0.94129601616966}, { 0.99089197565987, -0.92062625581587}, -{ 0.28631285179909, -0.91035047143603}, {-0.83302725605608, -0.67330410892084}, -{ 0.95404443402072, 0.49162765398743}, {-0.06449863579434, 0.03250560813135}, -{-0.99575054486311, 0.42389784469507}, {-0.65501142790847, 0.82546114655624}, -{-0.81254441908887, -0.51627234660629}, {-0.99646369485481, 0.84490533520752}, -{ 0.00287840603348, 0.64768261158166}, { 0.70176989408455, -0.20453028573322}, -{ 0.96361882270190, 0.40706967140989}, {-0.68883758192426, 0.91338958840772}, -{-0.34875585502238, 0.71472290693300}, { 0.91980081243087, 0.66507455644919}, -{-0.99009048343881, 0.85868021604848}, { 0.68865791458395, 0.55660316809678}, -{-0.99484402129368, -0.20052559254934}, { 0.94214511408023, -0.99696425367461}, -{-0.67414626793544, 0.49548221180078}, {-0.47339353684664, -0.85904328834047}, -{ 0.14323651387360, -0.94145598222488}, {-0.29268293575672, 0.05759224927952}, -{ 0.43793861458754, -0.78904969892724}, {-0.36345126374441, 0.64874435357162}, -{-0.08750604656825, 0.97686944362527}, {-0.96495267812511, -0.53960305946511}, -{ 0.55526940659947, 0.78891523734774}, { 0.73538215752630, 0.96452072373404}, -{-0.30889773919437, -0.80664389776860}, { 0.03574995626194, -0.97325616900959}, -{ 0.98720684660488, 0.48409133691962}, {-0.81689296271203, -0.90827703628298}, -{ 0.67866860118215, 0.81284503870856}, {-0.15808569732583, 0.85279555024382}, -{ 0.80723395114371, -0.24717418514605}, { 0.47788757329038, -0.46333147839295}, -{ 0.96367554763201, 0.38486749303242}, {-0.99143875716818, -0.24945277239809}, -{ 0.83081876925833, -0.94780851414763}, {-0.58753191905341, 0.01290772389163}, -{ 0.95538108220960, -0.85557052096538}, {-0.96490920476211, -0.64020970923102}, -{-0.97327101028521, 0.12378128133110}, { 0.91400366022124, 0.57972471346930}, -{-0.99925837363824, 0.71084847864067}, {-0.86875903507313, -0.20291699203564}, -{-0.26240034795124, -0.68264554369108}, {-0.24664412953388, -0.87642273115183}, -{ 0.02416275806869, 0.27192914288905}, { 0.82068619590515, -0.85087787994476}, -{ 0.88547373760759, -0.89636802901469}, {-0.18173078152226, -0.26152145156800}, -{ 0.09355476558534, 0.54845123045604}, {-0.54668414224090, 0.95980774020221}, -{ 0.37050990604091, -0.59910140383171}, {-0.70373594262891, 0.91227665827081}, -{-0.34600785879594, -0.99441426144200}, {-0.68774481731008, -0.30238837956299}, -{-0.26843291251234, 0.83115668004362}, { 0.49072334613242, -0.45359708737775}, -{ 0.38975993093975, 0.95515358099121}, {-0.97757125224150, 0.05305894580606}, -{-0.17325552859616, -0.92770672250494}, { 0.99948035025744, 0.58285545563426}, -{-0.64946246527458, 0.68645507104960}, {-0.12016920576437, -0.57147322153312}, -{-0.58947456517751, -0.34847132454388}, {-0.41815140454465, 0.16276422358861}, -{ 0.99885650204884, 0.11136095490444}, {-0.56649614128386, -0.90494866361587}, -{ 0.94138021032330, 0.35281916733018}, {-0.75725076534641, 0.53650549640587}, -{ 0.20541973692630, -0.94435144369918}, { 0.99980371023351, 0.79835913565599}, -{ 0.29078277605775, 0.35393777921520}, {-0.62858772103030, 0.38765693387102}, -{ 0.43440904467688, -0.98546330463232}, {-0.98298583762390, 0.21021524625209}, -{ 0.19513029146934, -0.94239832251867}, {-0.95476662400101, 0.98364554179143}, -{ 0.93379635304810, -0.70881994583682}, {-0.85235410573336, -0.08342347966410}, -{-0.86425093011245, -0.45795025029466}, { 0.38879779059045, 0.97274429344593}, -{ 0.92045124735495, -0.62433652524220}, { 0.89162532251878, 0.54950955570563}, -{-0.36834336949252, 0.96458298020975}, { 0.93891760988045, -0.89968353740388}, -{ 0.99267657565094, -0.03757034316958}, {-0.94063471614176, 0.41332338538963}, -{ 0.99740224117019, -0.16830494996370}, {-0.35899413170555, -0.46633226649613}, -{ 0.05237237274947, -0.25640361602661}, { 0.36703583957424, -0.38653265641875}, -{ 0.91653180367913, -0.30587628726597}, { 0.69000803499316, 0.90952171386132}, -{-0.38658751133527, 0.99501571208985}, {-0.29250814029851, 0.37444994344615}, -{-0.60182204677608, 0.86779651036123}, {-0.97418588163217, 0.96468523666475}, -{ 0.88461574003963, 0.57508405276414}, { 0.05198933055162, 0.21269661669964}, -{-0.53499621979720, 0.97241553731237}, {-0.49429560226497, 0.98183865291903}, -{-0.98935142339139, -0.40249159006933}, {-0.98081380091130, -0.72856895534041}, -{-0.27338148835532, 0.99950922447209}, { 0.06310802338302, -0.54539587529618}, -{-0.20461677199539, -0.14209977628489}, { 0.66223843141647, 0.72528579940326}, -{-0.84764345483665, 0.02372316801261}, {-0.89039863483811, 0.88866581484602}, -{ 0.95903308477986, 0.76744927173873}, { 0.73504123909879, -0.03747203173192}, -{-0.31744434966056, -0.36834111883652}, {-0.34110827591623, 0.40211222807691}, -{ 0.47803883714199, -0.39423219786288}, { 0.98299195879514, 0.01989791390047}, -{-0.30963073129751, -0.18076720599336}, { 0.99992588229018, -0.26281872094289}, -{-0.93149731080767, -0.98313162570490}, { 0.99923472302773, -0.80142993767554}, -{-0.26024169633417, -0.75999759855752}, {-0.35712514743563, 0.19298963768574}, -{-0.99899084509530, 0.74645156992493}, { 0.86557171579452, 0.55593866696299}, -{ 0.33408042438752, 0.86185953874709}, { 0.99010736374716, 0.04602397576623}, -{-0.66694269691195, -0.91643611810148}, { 0.64016792079480, 0.15649530836856}, -{ 0.99570534804836, 0.45844586038111}, {-0.63431466947340, 0.21079116459234}, -{-0.07706847005931, -0.89581437101329}, { 0.98590090577724, 0.88241721133981}, -{ 0.80099335254678, -0.36851896710853}, { 0.78368131392666, 0.45506999802597}, -{ 0.08707806671691, 0.80938994918745}, {-0.86811883080712, 0.39347308654705}, -{-0.39466529740375, -0.66809432114456}, { 0.97875325649683, -0.72467840967746}, -{-0.95038560288864, 0.89563219587625}, { 0.17005239424212, 0.54683053962658}, -{-0.76910792026848, -0.96226617549298}, { 0.99743281016846, 0.42697157037567}, -{ 0.95437383549973, 0.97002324109952}, { 0.99578905365569, -0.54106826257356}, -{ 0.28058259829990, -0.85361420634036}, { 0.85256524470573, -0.64567607735589}, -{-0.50608540105128, -0.65846015480300}, {-0.97210735183243, -0.23095213067791}, -{ 0.95424048234441, -0.99240147091219}, {-0.96926570524023, 0.73775654896574}, -{ 0.30872163214726, 0.41514960556126}, {-0.24523839572639, 0.63206633394807}, -{-0.33813265086024, -0.38661779441897}, {-0.05826828420146, -0.06940774188029}, -{-0.22898461455054, 0.97054853316316}, {-0.18509915019881, 0.47565762892084}, -{-0.10488238045009, -0.87769947402394}, {-0.71886586182037, 0.78030982480538}, -{ 0.99793873738654, 0.90041310491497}, { 0.57563307626120, -0.91034337352097}, -{ 0.28909646383717, 0.96307783970534}, { 0.42188998312520, 0.48148651230437}, -{ 0.93335049681047, -0.43537023883588}, {-0.97087374418267, 0.86636445711364}, -{ 0.36722871286923, 0.65291654172961}, {-0.81093025665696, 0.08778370229363}, -{-0.26240603062237, -0.92774095379098}, { 0.83996497984604, 0.55839849139647}, -{-0.99909615720225, -0.96024605713970}, { 0.74649464155061, 0.12144893606462}, -{-0.74774595569805, -0.26898062008959}, { 0.95781667469567, -0.79047927052628}, -{ 0.95472308713099, -0.08588776019550}, { 0.48708332746299, 0.99999041579432}, -{ 0.46332038247497, 0.10964126185063}, {-0.76497004940162, 0.89210929242238}, -{ 0.57397389364339, 0.35289703373760}, { 0.75374316974495, 0.96705214651335}, -{-0.59174397685714, -0.89405370422752}, { 0.75087906691890, -0.29612672982396}, -{-0.98607857336230, 0.25034911730023}, {-0.40761056640505, -0.90045573444695}, -{ 0.66929266740477, 0.98629493401748}, {-0.97463695257310, -0.00190223301301}, -{ 0.90145509409859, 0.99781390365446}, {-0.87259289048043, 0.99233587353666}, -{-0.91529461447692, -0.15698707534206}, {-0.03305738840705, -0.37205262859764}, -{ 0.07223051368337, -0.88805001733626}, { 0.99498012188353, 0.97094358113387}, -{-0.74904939500519, 0.99985483641521}, { 0.04585228574211, 0.99812337444082}, -{-0.89054954257993, -0.31791913188064}, {-0.83782144651251, 0.97637632547466}, -{ 0.33454804933804, -0.86231516800408}, {-0.99707579362824, 0.93237990079441}, -{-0.22827527843994, 0.18874759397997}, { 0.67248046289143, -0.03646211390569}, -{-0.05146538187944, -0.92599700120679}, { 0.99947295749905, 0.93625229707912}, -{ 0.66951124390363, 0.98905825623893}, {-0.99602956559179, -0.44654715757688}, -{ 0.82104905483590, 0.99540741724928}, { 0.99186510988782, 0.72023001312947}, -{-0.65284592392918, 0.52186723253637}, { 0.93885443798188, -0.74895312615259}, -{ 0.96735248738388, 0.90891816978629}, {-0.22225968841114, 0.57124029781228}, -{-0.44132783753414, -0.92688840659280}, {-0.85694974219574, 0.88844532719844}, -{ 0.91783042091762, -0.46356892383970}, { 0.72556974415690, -0.99899555770747}, -{-0.99711581834508, 0.58211560180426}, { 0.77638976371966, 0.94321834873819}, -{ 0.07717324253925, 0.58638399856595}, {-0.56049829194163, 0.82522301569036}, -{ 0.98398893639988, 0.39467440420569}, { 0.47546946844938, 0.68613044836811}, -{ 0.65675089314631, 0.18331637134880}, { 0.03273375457980, -0.74933109564108}, -{-0.38684144784738, 0.51337349030406}, {-0.97346267944545, -0.96549364384098}, -{-0.53282156061942, -0.91423265091354}, { 0.99817310731176, 0.61133572482148}, -{-0.50254500772635, -0.88829338134294}, { 0.01995873238855, 0.85223515096765}, -{ 0.99930381973804, 0.94578896296649}, { 0.82907767600783, -0.06323442598128}, -{-0.58660709669728, 0.96840773806582}, {-0.17573736667267, -0.48166920859485}, -{ 0.83434292401346, -0.13023450646997}, { 0.05946491307025, 0.20511047074866}, -{ 0.81505484574602, -0.94685947861369}, {-0.44976380954860, 0.40894572671545}, -{-0.89746474625671, 0.99846578838537}, { 0.39677256130792, -0.74854668609359}, -{-0.07588948563079, 0.74096214084170}, { 0.76343198951445, 0.41746629422634}, -{-0.74490104699626, 0.94725911744610}, { 0.64880119792759, 0.41336660830571}, -{ 0.62319537462542, -0.93098313552599}, { 0.42215817594807, -0.07712787385208}, -{ 0.02704554141885, -0.05417518053666}, { 0.80001773566818, 0.91542195141039}, -{-0.79351832348816, -0.36208897989136}, { 0.63872359151636, 0.08128252493444}, -{ 0.52890520960295, 0.60048872455592}, { 0.74238552914587, 0.04491915291044}, -{ 0.99096131449250, -0.19451182854402}, {-0.80412329643109, -0.88513818199457}, -{-0.64612616129736, 0.72198674804544}, { 0.11657770663191, -0.83662833815041}, -{-0.95053182488101, -0.96939905138082}, {-0.62228872928622, 0.82767262846661}, -{ 0.03004475787316, -0.99738896333384}, {-0.97987214341034, 0.36526129686425}, -{-0.99986980746200, -0.36021610299715}, { 0.89110648599879, -0.97894250343044}, -{ 0.10407960510582, 0.77357793811619}, { 0.95964737821728, -0.35435818285502}, -{ 0.50843233159162, 0.96107691266205}, { 0.17006334670615, -0.76854025314829}, -{ 0.25872675063360, 0.99893303933816}, {-0.01115998681937, 0.98496019742444}, -{-0.79598702973261, 0.97138411318894}, {-0.99264708948101, -0.99542822402536}, -{-0.99829663752818, 0.01877138824311}, {-0.70801016548184, 0.33680685948117}, -{-0.70467057786826, 0.93272777501857}, { 0.99846021905254, -0.98725746254433}, -{-0.63364968534650, -0.16473594423746}, {-0.16258217500792, -0.95939125400802}, -{-0.43645594360633, -0.94805030113284}, {-0.99848471702976, 0.96245166923809}, -{-0.16796458968998, -0.98987511890470}, {-0.87979225745213, -0.71725725041680}, -{ 0.44183099021786, -0.93568974498761}, { 0.93310180125532, -0.99913308068246}, -{-0.93941931782002, -0.56409379640356}, {-0.88590003188677, 0.47624600491382}, -{ 0.99971463703691, -0.83889954253462}, {-0.75376385639978, 0.00814643438625}, -{ 0.93887685615875, -0.11284528204636}, { 0.85126435782309, 0.52349251543547}, -{ 0.39701421446381, 0.81779634174316}, {-0.37024464187437, -0.87071656222959}, -{-0.36024828242896, 0.34655735648287}, {-0.93388812549209, -0.84476541096429}, -{-0.65298804552119, -0.18439575450921}, { 0.11960319006843, 0.99899346780168}, -{ 0.94292565553160, 0.83163906518293}, { 0.75081145286948, -0.35533223142265}, -{ 0.56721979748394, -0.24076836414499}, { 0.46857766746029, -0.30140233457198}, -{ 0.97312313923635, -0.99548191630031}, {-0.38299976567017, 0.98516909715427}, -{ 0.41025800019463, 0.02116736935734}, { 0.09638062008048, 0.04411984381457}, -{-0.85283249275397, 0.91475563922421}, { 0.88866808958124, -0.99735267083226}, -{-0.48202429536989, -0.96805608884164}, { 0.27572582416567, 0.58634753335832}, -{-0.65889129659168, 0.58835634138583}, { 0.98838086953732, 0.99994349600236}, -{-0.20651349620689, 0.54593044066355}, {-0.62126416356920, -0.59893681700392}, -{ 0.20320105410437, -0.86879180355289}, {-0.97790548600584, 0.96290806999242}, -{ 0.11112534735126, 0.21484763313301}, {-0.41368337314182, 0.28216837680365}, -{ 0.24133038992960, 0.51294362630238}, {-0.66393410674885, -0.08249679629081}, -{-0.53697829178752, -0.97649903936228}, {-0.97224737889348, 0.22081333579837}, -{ 0.87392477144549, -0.12796173740361}, { 0.19050361015753, 0.01602615387195}, -{-0.46353441212724, -0.95249041539006}, {-0.07064096339021, -0.94479803205886}, -{-0.92444085484466, -0.10457590187436}, {-0.83822593578728, -0.01695043208885}, -{ 0.75214681811150, -0.99955681042665}, {-0.42102998829339, 0.99720941999394}, -{-0.72094786237696, -0.35008961934255}, { 0.78843311019251, 0.52851398958271}, -{ 0.97394027897442, -0.26695944086561}, { 0.99206463477946, -0.57010120849429}, -{ 0.76789609461795, -0.76519356730966}, {-0.82002421836409, -0.73530179553767}, -{ 0.81924990025724, 0.99698425250579}, {-0.26719850873357, 0.68903369776193}, -{-0.43311260380975, 0.85321815947490}, { 0.99194979673836, 0.91876249766422}, -{-0.80692001248487, -0.32627540663214}, { 0.43080003649976, -0.21919095636638}, -{ 0.67709491937357, -0.95478075822906}, { 0.56151770568316, -0.70693811747778}, -{ 0.10831862810749, -0.08628837174592}, { 0.91229417540436, -0.65987351408410}, -{-0.48972893932274, 0.56289246362686}, {-0.89033658689697, -0.71656563987082}, -{ 0.65269447475094, 0.65916004833932}, { 0.67439478141121, -0.81684380846796}, -{-0.47770832416973, -0.16789556203025}, {-0.99715979260878, -0.93565784007648}, -{-0.90889593602546, 0.62034397054380}, {-0.06618622548177, -0.23812217221359}, -{ 0.99430266919728, 0.18812555317553}, { 0.97686402381843, -0.28664534366620}, -{ 0.94813650221268, -0.97506640027128}, {-0.95434497492853, -0.79607978501983}, -{-0.49104783137150, 0.32895214359663}, { 0.99881175120751, 0.88993983831354}, -{ 0.50449166760303, -0.85995072408434}, { 0.47162891065108, -0.18680204049569}, -{-0.62081581361840, 0.75000676218956}, {-0.43867015250812, 0.99998069244322}, -{ 0.98630563232075, -0.53578899600662}, {-0.61510362277374, -0.89515019899997}, -{-0.03841517601843, -0.69888815681179}, {-0.30102157304644, -0.07667808922205}, -{ 0.41881284182683, 0.02188098922282}, {-0.86135454941237, 0.98947480909359}, -{ 0.67226861393788, -0.13494389011014}, {-0.70737398842068, -0.76547349325992}, -{ 0.94044946687963, 0.09026201157416}, {-0.82386352534327, 0.08924768823676}, -{-0.32070666698656, 0.50143421908753}, { 0.57593163224487, -0.98966422921509}, -{-0.36326018419965, 0.07440243123228}, { 0.99979044674350, -0.14130287347405}, -{-0.92366023326932, -0.97979298068180}, {-0.44607178518598, -0.54233252016394}, -{ 0.44226800932956, 0.71326756742752}, { 0.03671907158312, 0.63606389366675}, -{ 0.52175424682195, -0.85396826735705}, {-0.94701139690956, -0.01826348194255}, -{-0.98759606946049, 0.82288714303073}, { 0.87434794743625, 0.89399495655433}, -{-0.93412041758744, 0.41374052024363}, { 0.96063943315511, 0.93116709541280}, -{ 0.97534253457837, 0.86150930812689}, { 0.99642466504163, 0.70190043427512}, -{-0.94705089665984, -0.29580042814306}, { 0.91599807087376, -0.98147830385781}, +const DECLARE_ALIGNED(16, INTFLOAT, AAC_RENAME(ff_sbr_noise_table))[][2] = { +{Q31(-0.99948153278296f), Q31(-0.59483417516607f)}, {Q31( 0.97113454393991f), Q31(-0.67528515225647f)}, +{Q31( 0.14130051758487f), Q31(-0.95090983575689f)}, {Q31(-0.47005496701697f), Q31(-0.37340549728647f)}, +{Q31( 0.80705063769351f), Q31( 0.29653668284408f)}, {Q31(-0.38981478896926f), Q31( 0.89572605717087f)}, +{Q31(-0.01053049862020f), Q31(-0.66959058036166f)}, {Q31(-0.91266367957293f), Q31(-0.11522938140034f)}, +{Q31( 0.54840422910309f), Q31( 0.75221367176302f)}, {Q31( 0.40009252867955f), Q31(-0.98929400334421f)}, +{Q31(-0.99867974711855f), Q31(-0.88147068645358f)}, {Q31(-0.95531076805040f), Q31( 0.90908757154593f)}, +{Q31(-0.45725933317144f), Q31(-0.56716323646760f)}, {Q31(-0.72929675029275f), Q31(-0.98008272727324f)}, +{Q31( 0.75622801399036f), Q31( 0.20950329995549f)}, {Q31( 0.07069442601050f), Q31(-0.78247898470706f)}, +{Q31( 0.74496252926055f), Q31(-0.91169004445807f)}, {Q31(-0.96440182703856f), Q31(-0.94739918296622f)}, +{Q31( 0.30424629369539f), Q31(-0.49438267012479f)}, {Q31( 0.66565033746925f), Q31( 0.64652935542491f)}, +{Q31( 0.91697008020594f), Q31( 0.17514097332009f)}, {Q31(-0.70774918760427f), Q31( 0.52548653416543f)}, +{Q31(-0.70051415345560f), Q31(-0.45340028808763f)}, {Q31(-0.99496513054797f), Q31(-0.90071908066973f)}, +{Q31( 0.98164490790123f), Q31(-0.77463155528697f)}, {Q31(-0.54671580548181f), Q31(-0.02570928536004f)}, +{Q31(-0.01689629065389f), Q31( 0.00287506445732f)}, {Q31(-0.86110349531986f), Q31( 0.42548583726477f)}, +{Q31(-0.98892980586032f), Q31(-0.87881132267556f)}, {Q31( 0.51756627678691f), Q31( 0.66926784710139f)}, +{Q31(-0.99635026409640f), Q31(-0.58107730574765f)}, {Q31(-0.99969370862163f), Q31( 0.98369989360250f)}, +{Q31( 0.55266258627194f), Q31( 0.59449057465591f)}, {Q31( 0.34581177741673f), Q31( 0.94879421061866f)}, +{Q31( 0.62664209577999f), Q31(-0.74402970906471f)}, {Q31(-0.77149701404973f), Q31(-0.33883658042801f)}, +{Q31(-0.91592244254432f), Q31( 0.03687901376713f)}, {Q31(-0.76285492357887f), Q31(-0.91371867919124f)}, +{Q31( 0.79788337195331f), Q31(-0.93180971199849f)}, {Q31( 0.54473080610200f), Q31(-0.11919206037186f)}, +{Q31(-0.85639281671058f), Q31( 0.42429854760451f)}, {Q31(-0.92882402971423f), Q31( 0.27871809078609f)}, +{Q31(-0.11708371046774f), Q31(-0.99800843444966f)}, {Q31( 0.21356749817493f), Q31(-0.90716295627033f)}, +{Q31(-0.76191692573909f), Q31( 0.99768118356265f)}, {Q31( 0.98111043100884f), Q31(-0.95854459734407f)}, +{Q31(-0.85913269895572f), Q31( 0.95766566168880f)}, {Q31(-0.93307242253692f), Q31( 0.49431757696466f)}, +{Q31( 0.30485754879632f), Q31(-0.70540034357529f)}, {Q31( 0.85289650925190f), Q31( 0.46766131791044f)}, +{Q31( 0.91328082618125f), Q31(-0.99839597361769f)}, {Q31(-0.05890199924154f), Q31( 0.70741827819497f)}, +{Q31( 0.28398686150148f), Q31( 0.34633555702188f)}, {Q31( 0.95258164539612f), Q31(-0.54893416026939f)}, +{Q31(-0.78566324168507f), Q31(-0.75568541079691f)}, {Q31(-0.95789495447877f), Q31(-0.20423194696966f)}, +{Q31( 0.82411158711197f), Q31( 0.96654618432562f)}, {Q31(-0.65185446735885f), Q31(-0.88734990773289f)}, +{Q31(-0.93643603134666f), Q31( 0.99870790442385f)}, {Q31( 0.91427159529618f), Q31(-0.98290505544444f)}, +{Q31(-0.70395684036886f), Q31( 0.58796798221039f)}, {Q31( 0.00563771969365f), Q31( 0.61768196727244f)}, +{Q31( 0.89065051931895f), Q31( 0.52783352697585f)}, {Q31(-0.68683707712762f), Q31( 0.80806944710339f)}, +{Q31( 0.72165342518718f), Q31(-0.69259857349564f)}, {Q31(-0.62928247730667f), Q31( 0.13627037407335f)}, +{Q31( 0.29938434065514f), Q31(-0.46051329682246f)}, {Q31(-0.91781958879280f), Q31(-0.74012716684186f)}, +{Q31( 0.99298717043688f), Q31( 0.40816610075661f)}, {Q31( 0.82368298622748f), Q31(-0.74036047190173f)}, +{Q31(-0.98512833386833f), Q31(-0.99972330709594f)}, {Q31(-0.95915368242257f), Q31(-0.99237800466040f)}, +{Q31(-0.21411126572790f), Q31(-0.93424819052545f)}, {Q31(-0.68821476106884f), Q31(-0.26892306315457f)}, +{Q31( 0.91851997982317f), Q31( 0.09358228901785f)}, {Q31(-0.96062769559127f), Q31( 0.36099095133739f)}, +{Q31( 0.51646184922287f), Q31(-0.71373332873917f)}, {Q31( 0.61130721139669f), Q31( 0.46950141175917f)}, +{Q31( 0.47336129371299f), Q31(-0.27333178296162f)}, {Q31( 0.90998308703519f), Q31( 0.96715662938132f)}, +{Q31( 0.44844799194357f), Q31( 0.99211574628306f)}, {Q31( 0.66614891079092f), Q31( 0.96590176169121f)}, +{Q31( 0.74922239129237f), Q31(-0.89879858826087f)}, {Q31(-0.99571588506485f), Q31( 0.52785521494349f)}, +{Q31( 0.97401082477563f), Q31(-0.16855870075190f)}, {Q31( 0.72683747733879f), Q31(-0.48060774432251f)}, +{Q31( 0.95432193457128f), Q31( 0.68849603408441f)}, {Q31(-0.72962208425191f), Q31(-0.76608443420917f)}, +{Q31(-0.85359479233537f), Q31( 0.88738125901579f)}, {Q31(-0.81412430338535f), Q31(-0.97480768049637f)}, +{Q31(-0.87930772356786f), Q31( 0.74748307690436f)}, {Q31(-0.71573331064977f), Q31(-0.98570608178923f)}, +{Q31( 0.83524300028228f), Q31( 0.83702537075163f)}, {Q31(-0.48086065601423f), Q31(-0.98848504923531f)}, +{Q31( 0.97139128574778f), Q31( 0.80093621198236f)}, {Q31( 0.51992825347895f), Q31( 0.80247631400510f)}, +{Q31(-0.00848591195325f), Q31(-0.76670128000486f)}, {Q31(-0.70294374303036f), Q31( 0.55359910445577f)}, +{Q31(-0.95894428168140f), Q31(-0.43265504344783f)}, {Q31( 0.97079252950321f), Q31( 0.09325857238682f)}, +{Q31(-0.92404293670797f), Q31( 0.85507704027855f)}, {Q31(-0.69506469500450f), Q31( 0.98633412625459f)}, +{Q31( 0.26559203620024f), Q31( 0.73314307966524f)}, {Q31( 0.28038443336943f), Q31( 0.14537913654427f)}, +{Q31(-0.74138124825523f), Q31( 0.99310339807762f)}, {Q31(-0.01752795995444f), Q31(-0.82616635284178f)}, +{Q31(-0.55126773094930f), Q31(-0.98898543862153f)}, {Q31( 0.97960898850996f), Q31(-0.94021446752851f)}, +{Q31(-0.99196309146936f), Q31( 0.67019017358456f)}, {Q31(-0.67684928085260f), Q31( 0.12631491649378f)}, +{Q31( 0.09140039465500f), Q31(-0.20537731453108f)}, {Q31(-0.71658965751996f), Q31(-0.97788200391224f)}, +{Q31( 0.81014640078925f), Q31( 0.53722648362443f)}, {Q31( 0.40616991671205f), Q31(-0.26469008598449f)}, +{Q31(-0.67680188682972f), Q31( 0.94502052337695f)}, {Q31( 0.86849774348749f), Q31(-0.18333598647899f)}, +{Q31(-0.99500381284851f), Q31(-0.02634122068550f)}, {Q31( 0.84329189340667f), Q31( 0.10406957462213f)}, +{Q31(-0.09215968531446f), Q31( 0.69540012101253f)}, {Q31( 0.99956173327206f), Q31(-0.12358542001404f)}, +{Q31(-0.79732779473535f), Q31(-0.91582524736159f)}, {Q31( 0.96349973642406f), Q31( 0.96640458041000f)}, +{Q31(-0.79942778496547f), Q31( 0.64323902822857f)}, {Q31(-0.11566039853896f), Q31( 0.28587846253726f)}, +{Q31(-0.39922954514662f), Q31( 0.94129601616966f)}, {Q31( 0.99089197565987f), Q31(-0.92062625581587f)}, +{Q31( 0.28631285179909f), Q31(-0.91035047143603f)}, {Q31(-0.83302725605608f), Q31(-0.67330410892084f)}, +{Q31( 0.95404443402072f), Q31( 0.49162765398743f)}, {Q31(-0.06449863579434f), Q31( 0.03250560813135f)}, +{Q31(-0.99575054486311f), Q31( 0.42389784469507f)}, {Q31(-0.65501142790847f), Q31( 0.82546114655624f)}, +{Q31(-0.81254441908887f), Q31(-0.51627234660629f)}, {Q31(-0.99646369485481f), Q31( 0.84490533520752f)}, +{Q31( 0.00287840603348f), Q31( 0.64768261158166f)}, {Q31( 0.70176989408455f), Q31(-0.20453028573322f)}, +{Q31( 0.96361882270190f), Q31( 0.40706967140989f)}, {Q31(-0.68883758192426f), Q31( 0.91338958840772f)}, +{Q31(-0.34875585502238f), Q31( 0.71472290693300f)}, {Q31( 0.91980081243087f), Q31( 0.66507455644919f)}, +{Q31(-0.99009048343881f), Q31( 0.85868021604848f)}, {Q31( 0.68865791458395f), Q31( 0.55660316809678f)}, +{Q31(-0.99484402129368f), Q31(-0.20052559254934f)}, {Q31( 0.94214511408023f), Q31(-0.99696425367461f)}, +{Q31(-0.67414626793544f), Q31( 0.49548221180078f)}, {Q31(-0.47339353684664f), Q31(-0.85904328834047f)}, +{Q31( 0.14323651387360f), Q31(-0.94145598222488f)}, {Q31(-0.29268293575672f), Q31( 0.05759224927952f)}, +{Q31( 0.43793861458754f), Q31(-0.78904969892724f)}, {Q31(-0.36345126374441f), Q31( 0.64874435357162f)}, +{Q31(-0.08750604656825f), Q31( 0.97686944362527f)}, {Q31(-0.96495267812511f), Q31(-0.53960305946511f)}, +{Q31( 0.55526940659947f), Q31( 0.78891523734774f)}, {Q31( 0.73538215752630f), Q31( 0.96452072373404f)}, +{Q31(-0.30889773919437f), Q31(-0.80664389776860f)}, {Q31( 0.03574995626194f), Q31(-0.97325616900959f)}, +{Q31( 0.98720684660488f), Q31( 0.48409133691962f)}, {Q31(-0.81689296271203f), Q31(-0.90827703628298f)}, +{Q31( 0.67866860118215f), Q31( 0.81284503870856f)}, {Q31(-0.15808569732583f), Q31( 0.85279555024382f)}, +{Q31( 0.80723395114371f), Q31(-0.24717418514605f)}, {Q31( 0.47788757329038f), Q31(-0.46333147839295f)}, +{Q31( 0.96367554763201f), Q31( 0.38486749303242f)}, {Q31(-0.99143875716818f), Q31(-0.24945277239809f)}, +{Q31( 0.83081876925833f), Q31(-0.94780851414763f)}, {Q31(-0.58753191905341f), Q31( 0.01290772389163f)}, +{Q31( 0.95538108220960f), Q31(-0.85557052096538f)}, {Q31(-0.96490920476211f), Q31(-0.64020970923102f)}, +{Q31(-0.97327101028521f), Q31( 0.12378128133110f)}, {Q31( 0.91400366022124f), Q31( 0.57972471346930f)}, +{Q31(-0.99925837363824f), Q31( 0.71084847864067f)}, {Q31(-0.86875903507313f), Q31(-0.20291699203564f)}, +{Q31(-0.26240034795124f), Q31(-0.68264554369108f)}, {Q31(-0.24664412953388f), Q31(-0.87642273115183f)}, +{Q31( 0.02416275806869f), Q31( 0.27192914288905f)}, {Q31( 0.82068619590515f), Q31(-0.85087787994476f)}, +{Q31( 0.88547373760759f), Q31(-0.89636802901469f)}, {Q31(-0.18173078152226f), Q31(-0.26152145156800f)}, +{Q31( 0.09355476558534f), Q31( 0.54845123045604f)}, {Q31(-0.54668414224090f), Q31( 0.95980774020221f)}, +{Q31( 0.37050990604091f), Q31(-0.59910140383171f)}, {Q31(-0.70373594262891f), Q31( 0.91227665827081f)}, +{Q31(-0.34600785879594f), Q31(-0.99441426144200f)}, {Q31(-0.68774481731008f), Q31(-0.30238837956299f)}, +{Q31(-0.26843291251234f), Q31( 0.83115668004362f)}, {Q31( 0.49072334613242f), Q31(-0.45359708737775f)}, +{Q31( 0.38975993093975f), Q31( 0.95515358099121f)}, {Q31(-0.97757125224150f), Q31( 0.05305894580606f)}, +{Q31(-0.17325552859616f), Q31(-0.92770672250494f)}, {Q31( 0.99948035025744f), Q31( 0.58285545563426f)}, +{Q31(-0.64946246527458f), Q31( 0.68645507104960f)}, {Q31(-0.12016920576437f), Q31(-0.57147322153312f)}, +{Q31(-0.58947456517751f), Q31(-0.34847132454388f)}, {Q31(-0.41815140454465f), Q31( 0.16276422358861f)}, +{Q31( 0.99885650204884f), Q31( 0.11136095490444f)}, {Q31(-0.56649614128386f), Q31(-0.90494866361587f)}, +{Q31( 0.94138021032330f), Q31( 0.35281916733018f)}, {Q31(-0.75725076534641f), Q31( 0.53650549640587f)}, +{Q31( 0.20541973692630f), Q31(-0.94435144369918f)}, {Q31( 0.99980371023351f), Q31( 0.79835913565599f)}, +{Q31( 0.29078277605775f), Q31( 0.35393777921520f)}, {Q31(-0.62858772103030f), Q31( 0.38765693387102f)}, +{Q31( 0.43440904467688f), Q31(-0.98546330463232f)}, {Q31(-0.98298583762390f), Q31( 0.21021524625209f)}, +{Q31( 0.19513029146934f), Q31(-0.94239832251867f)}, {Q31(-0.95476662400101f), Q31( 0.98364554179143f)}, +{Q31( 0.93379635304810f), Q31(-0.70881994583682f)}, {Q31(-0.85235410573336f), Q31(-0.08342347966410f)}, +{Q31(-0.86425093011245f), Q31(-0.45795025029466f)}, {Q31( 0.38879779059045f), Q31( 0.97274429344593f)}, +{Q31( 0.92045124735495f), Q31(-0.62433652524220f)}, {Q31( 0.89162532251878f), Q31( 0.54950955570563f)}, +{Q31(-0.36834336949252f), Q31( 0.96458298020975f)}, {Q31( 0.93891760988045f), Q31(-0.89968353740388f)}, +{Q31( 0.99267657565094f), Q31(-0.03757034316958f)}, {Q31(-0.94063471614176f), Q31( 0.41332338538963f)}, +{Q31( 0.99740224117019f), Q31(-0.16830494996370f)}, {Q31(-0.35899413170555f), Q31(-0.46633226649613f)}, +{Q31( 0.05237237274947f), Q31(-0.25640361602661f)}, {Q31( 0.36703583957424f), Q31(-0.38653265641875f)}, +{Q31( 0.91653180367913f), Q31(-0.30587628726597f)}, {Q31( 0.69000803499316f), Q31( 0.90952171386132f)}, +{Q31(-0.38658751133527f), Q31( 0.99501571208985f)}, {Q31(-0.29250814029851f), Q31( 0.37444994344615f)}, +{Q31(-0.60182204677608f), Q31( 0.86779651036123f)}, {Q31(-0.97418588163217f), Q31( 0.96468523666475f)}, +{Q31( 0.88461574003963f), Q31( 0.57508405276414f)}, {Q31( 0.05198933055162f), Q31( 0.21269661669964f)}, +{Q31(-0.53499621979720f), Q31( 0.97241553731237f)}, {Q31(-0.49429560226497f), Q31( 0.98183865291903f)}, +{Q31(-0.98935142339139f), Q31(-0.40249159006933f)}, {Q31(-0.98081380091130f), Q31(-0.72856895534041f)}, +{Q31(-0.27338148835532f), Q31( 0.99950922447209f)}, {Q31( 0.06310802338302f), Q31(-0.54539587529618f)}, +{Q31(-0.20461677199539f), Q31(-0.14209977628489f)}, {Q31( 0.66223843141647f), Q31( 0.72528579940326f)}, +{Q31(-0.84764345483665f), Q31( 0.02372316801261f)}, {Q31(-0.89039863483811f), Q31( 0.88866581484602f)}, +{Q31( 0.95903308477986f), Q31( 0.76744927173873f)}, {Q31( 0.73504123909879f), Q31(-0.03747203173192f)}, +{Q31(-0.31744434966056f), Q31(-0.36834111883652f)}, {Q31(-0.34110827591623f), Q31( 0.40211222807691f)}, +{Q31( 0.47803883714199f), Q31(-0.39423219786288f)}, {Q31( 0.98299195879514f), Q31( 0.01989791390047f)}, +{Q31(-0.30963073129751f), Q31(-0.18076720599336f)}, {Q31( 0.99992588229018f), Q31(-0.26281872094289f)}, +{Q31(-0.93149731080767f), Q31(-0.98313162570490f)}, {Q31( 0.99923472302773f), Q31(-0.80142993767554f)}, +{Q31(-0.26024169633417f), Q31(-0.75999759855752f)}, {Q31(-0.35712514743563f), Q31( 0.19298963768574f)}, +{Q31(-0.99899084509530f), Q31( 0.74645156992493f)}, {Q31( 0.86557171579452f), Q31( 0.55593866696299f)}, +{Q31( 0.33408042438752f), Q31( 0.86185953874709f)}, {Q31( 0.99010736374716f), Q31( 0.04602397576623f)}, +{Q31(-0.66694269691195f), Q31(-0.91643611810148f)}, {Q31( 0.64016792079480f), Q31( 0.15649530836856f)}, +{Q31( 0.99570534804836f), Q31( 0.45844586038111f)}, {Q31(-0.63431466947340f), Q31( 0.21079116459234f)}, +{Q31(-0.07706847005931f), Q31(-0.89581437101329f)}, {Q31( 0.98590090577724f), Q31( 0.88241721133981f)}, +{Q31( 0.80099335254678f), Q31(-0.36851896710853f)}, {Q31( 0.78368131392666f), Q31( 0.45506999802597f)}, +{Q31( 0.08707806671691f), Q31( 0.80938994918745f)}, {Q31(-0.86811883080712f), Q31( 0.39347308654705f)}, +{Q31(-0.39466529740375f), Q31(-0.66809432114456f)}, {Q31( 0.97875325649683f), Q31(-0.72467840967746f)}, +{Q31(-0.95038560288864f), Q31( 0.89563219587625f)}, {Q31( 0.17005239424212f), Q31( 0.54683053962658f)}, +{Q31(-0.76910792026848f), Q31(-0.96226617549298f)}, {Q31( 0.99743281016846f), Q31( 0.42697157037567f)}, +{Q31( 0.95437383549973f), Q31( 0.97002324109952f)}, {Q31( 0.99578905365569f), Q31(-0.54106826257356f)}, +{Q31( 0.28058259829990f), Q31(-0.85361420634036f)}, {Q31( 0.85256524470573f), Q31(-0.64567607735589f)}, +{Q31(-0.50608540105128f), Q31(-0.65846015480300f)}, {Q31(-0.97210735183243f), Q31(-0.23095213067791f)}, +{Q31( 0.95424048234441f), Q31(-0.99240147091219f)}, {Q31(-0.96926570524023f), Q31( 0.73775654896574f)}, +{Q31( 0.30872163214726f), Q31( 0.41514960556126f)}, {Q31(-0.24523839572639f), Q31( 0.63206633394807f)}, +{Q31(-0.33813265086024f), Q31(-0.38661779441897f)}, {Q31(-0.05826828420146f), Q31(-0.06940774188029f)}, +{Q31(-0.22898461455054f), Q31( 0.97054853316316f)}, {Q31(-0.18509915019881f), Q31( 0.47565762892084f)}, +{Q31(-0.10488238045009f), Q31(-0.87769947402394f)}, {Q31(-0.71886586182037f), Q31( 0.78030982480538f)}, +{Q31( 0.99793873738654f), Q31( 0.90041310491497f)}, {Q31( 0.57563307626120f), Q31(-0.91034337352097f)}, +{Q31( 0.28909646383717f), Q31( 0.96307783970534f)}, {Q31( 0.42188998312520f), Q31( 0.48148651230437f)}, +{Q31( 0.93335049681047f), Q31(-0.43537023883588f)}, {Q31(-0.97087374418267f), Q31( 0.86636445711364f)}, +{Q31( 0.36722871286923f), Q31( 0.65291654172961f)}, {Q31(-0.81093025665696f), Q31( 0.08778370229363f)}, +{Q31(-0.26240603062237f), Q31(-0.92774095379098f)}, {Q31( 0.83996497984604f), Q31( 0.55839849139647f)}, +{Q31(-0.99909615720225f), Q31(-0.96024605713970f)}, {Q31( 0.74649464155061f), Q31( 0.12144893606462f)}, +{Q31(-0.74774595569805f), Q31(-0.26898062008959f)}, {Q31( 0.95781667469567f), Q31(-0.79047927052628f)}, +{Q31( 0.95472308713099f), Q31(-0.08588776019550f)}, {Q31( 0.48708332746299f), Q31( 0.99999041579432f)}, +{Q31( 0.46332038247497f), Q31( 0.10964126185063f)}, {Q31(-0.76497004940162f), Q31( 0.89210929242238f)}, +{Q31( 0.57397389364339f), Q31( 0.35289703373760f)}, {Q31( 0.75374316974495f), Q31( 0.96705214651335f)}, +{Q31(-0.59174397685714f), Q31(-0.89405370422752f)}, {Q31( 0.75087906691890f), Q31(-0.29612672982396f)}, +{Q31(-0.98607857336230f), Q31( 0.25034911730023f)}, {Q31(-0.40761056640505f), Q31(-0.90045573444695f)}, +{Q31( 0.66929266740477f), Q31( 0.98629493401748f)}, {Q31(-0.97463695257310f), Q31(-0.00190223301301f)}, +{Q31( 0.90145509409859f), Q31( 0.99781390365446f)}, {Q31(-0.87259289048043f), Q31( 0.99233587353666f)}, +{Q31(-0.91529461447692f), Q31(-0.15698707534206f)}, {Q31(-0.03305738840705f), Q31(-0.37205262859764f)}, +{Q31( 0.07223051368337f), Q31(-0.88805001733626f)}, {Q31( 0.99498012188353f), Q31( 0.97094358113387f)}, +{Q31(-0.74904939500519f), Q31( 0.99985483641521f)}, {Q31( 0.04585228574211f), Q31( 0.99812337444082f)}, +{Q31(-0.89054954257993f), Q31(-0.31791913188064f)}, {Q31(-0.83782144651251f), Q31( 0.97637632547466f)}, +{Q31( 0.33454804933804f), Q31(-0.86231516800408f)}, {Q31(-0.99707579362824f), Q31( 0.93237990079441f)}, +{Q31(-0.22827527843994f), Q31( 0.18874759397997f)}, {Q31( 0.67248046289143f), Q31(-0.03646211390569f)}, +{Q31(-0.05146538187944f), Q31(-0.92599700120679f)}, {Q31( 0.99947295749905f), Q31( 0.93625229707912f)}, +{Q31( 0.66951124390363f), Q31( 0.98905825623893f)}, {Q31(-0.99602956559179f), Q31(-0.44654715757688f)}, +{Q31( 0.82104905483590f), Q31( 0.99540741724928f)}, {Q31( 0.99186510988782f), Q31( 0.72023001312947f)}, +{Q31(-0.65284592392918f), Q31( 0.52186723253637f)}, {Q31( 0.93885443798188f), Q31(-0.74895312615259f)}, +{Q31( 0.96735248738388f), Q31( 0.90891816978629f)}, {Q31(-0.22225968841114f), Q31( 0.57124029781228f)}, +{Q31(-0.44132783753414f), Q31(-0.92688840659280f)}, {Q31(-0.85694974219574f), Q31( 0.88844532719844f)}, +{Q31( 0.91783042091762f), Q31(-0.46356892383970f)}, {Q31( 0.72556974415690f), Q31(-0.99899555770747f)}, +{Q31(-0.99711581834508f), Q31( 0.58211560180426f)}, {Q31( 0.77638976371966f), Q31( 0.94321834873819f)}, +{Q31( 0.07717324253925f), Q31( 0.58638399856595f)}, {Q31(-0.56049829194163f), Q31( 0.82522301569036f)}, +{Q31( 0.98398893639988f), Q31( 0.39467440420569f)}, {Q31( 0.47546946844938f), Q31( 0.68613044836811f)}, +{Q31( 0.65675089314631f), Q31( 0.18331637134880f)}, {Q31( 0.03273375457980f), Q31(-0.74933109564108f)}, +{Q31(-0.38684144784738f), Q31( 0.51337349030406f)}, {Q31(-0.97346267944545f), Q31(-0.96549364384098f)}, +{Q31(-0.53282156061942f), Q31(-0.91423265091354f)}, {Q31( 0.99817310731176f), Q31( 0.61133572482148f)}, +{Q31(-0.50254500772635f), Q31(-0.88829338134294f)}, {Q31( 0.01995873238855f), Q31( 0.85223515096765f)}, +{Q31( 0.99930381973804f), Q31( 0.94578896296649f)}, {Q31( 0.82907767600783f), Q31(-0.06323442598128f)}, +{Q31(-0.58660709669728f), Q31( 0.96840773806582f)}, {Q31(-0.17573736667267f), Q31(-0.48166920859485f)}, +{Q31( 0.83434292401346f), Q31(-0.13023450646997f)}, {Q31( 0.05946491307025f), Q31( 0.20511047074866f)}, +{Q31( 0.81505484574602f), Q31(-0.94685947861369f)}, {Q31(-0.44976380954860f), Q31( 0.40894572671545f)}, +{Q31(-0.89746474625671f), Q31( 0.99846578838537f)}, {Q31( 0.39677256130792f), Q31(-0.74854668609359f)}, +{Q31(-0.07588948563079f), Q31( 0.74096214084170f)}, {Q31( 0.76343198951445f), Q31( 0.41746629422634f)}, +{Q31(-0.74490104699626f), Q31( 0.94725911744610f)}, {Q31( 0.64880119792759f), Q31( 0.41336660830571f)}, +{Q31( 0.62319537462542f), Q31(-0.93098313552599f)}, {Q31( 0.42215817594807f), Q31(-0.07712787385208f)}, +{Q31( 0.02704554141885f), Q31(-0.05417518053666f)}, {Q31( 0.80001773566818f), Q31( 0.91542195141039f)}, +{Q31(-0.79351832348816f), Q31(-0.36208897989136f)}, {Q31( 0.63872359151636f), Q31( 0.08128252493444f)}, +{Q31( 0.52890520960295f), Q31( 0.60048872455592f)}, {Q31( 0.74238552914587f), Q31( 0.04491915291044f)}, +{Q31( 0.99096131449250f), Q31(-0.19451182854402f)}, {Q31(-0.80412329643109f), Q31(-0.88513818199457f)}, +{Q31(-0.64612616129736f), Q31( 0.72198674804544f)}, {Q31( 0.11657770663191f), Q31(-0.83662833815041f)}, +{Q31(-0.95053182488101f), Q31(-0.96939905138082f)}, {Q31(-0.62228872928622f), Q31( 0.82767262846661f)}, +{Q31( 0.03004475787316f), Q31(-0.99738896333384f)}, {Q31(-0.97987214341034f), Q31( 0.36526129686425f)}, +{Q31(-0.99986980746200f), Q31(-0.36021610299715f)}, {Q31( 0.89110648599879f), Q31(-0.97894250343044f)}, +{Q31( 0.10407960510582f), Q31( 0.77357793811619f)}, {Q31( 0.95964737821728f), Q31(-0.35435818285502f)}, +{Q31( 0.50843233159162f), Q31( 0.96107691266205f)}, {Q31( 0.17006334670615f), Q31(-0.76854025314829f)}, +{Q31( 0.25872675063360f), Q31( 0.99893303933816f)}, {Q31(-0.01115998681937f), Q31( 0.98496019742444f)}, +{Q31(-0.79598702973261f), Q31( 0.97138411318894f)}, {Q31(-0.99264708948101f), Q31(-0.99542822402536f)}, +{Q31(-0.99829663752818f), Q31( 0.01877138824311f)}, {Q31(-0.70801016548184f), Q31( 0.33680685948117f)}, +{Q31(-0.70467057786826f), Q31( 0.93272777501857f)}, {Q31( 0.99846021905254f), Q31(-0.98725746254433f)}, +{Q31(-0.63364968534650f), Q31(-0.16473594423746f)}, {Q31(-0.16258217500792f), Q31(-0.95939125400802f)}, +{Q31(-0.43645594360633f), Q31(-0.94805030113284f)}, {Q31(-0.99848471702976f), Q31( 0.96245166923809f)}, +{Q31(-0.16796458968998f), Q31(-0.98987511890470f)}, {Q31(-0.87979225745213f), Q31(-0.71725725041680f)}, +{Q31( 0.44183099021786f), Q31(-0.93568974498761f)}, {Q31( 0.93310180125532f), Q31(-0.99913308068246f)}, +{Q31(-0.93941931782002f), Q31(-0.56409379640356f)}, {Q31(-0.88590003188677f), Q31( 0.47624600491382f)}, +{Q31( 0.99971463703691f), Q31(-0.83889954253462f)}, {Q31(-0.75376385639978f), Q31( 0.00814643438625f)}, +{Q31( 0.93887685615875f), Q31(-0.11284528204636f)}, {Q31( 0.85126435782309f), Q31( 0.52349251543547f)}, +{Q31( 0.39701421446381f), Q31( 0.81779634174316f)}, {Q31(-0.37024464187437f), Q31(-0.87071656222959f)}, +{Q31(-0.36024828242896f), Q31( 0.34655735648287f)}, {Q31(-0.93388812549209f), Q31(-0.84476541096429f)}, +{Q31(-0.65298804552119f), Q31(-0.18439575450921f)}, {Q31( 0.11960319006843f), Q31( 0.99899346780168f)}, +{Q31( 0.94292565553160f), Q31( 0.83163906518293f)}, {Q31( 0.75081145286948f), Q31(-0.35533223142265f)}, +{Q31( 0.56721979748394f), Q31(-0.24076836414499f)}, {Q31( 0.46857766746029f), Q31(-0.30140233457198f)}, +{Q31( 0.97312313923635f), Q31(-0.99548191630031f)}, {Q31(-0.38299976567017f), Q31( 0.98516909715427f)}, +{Q31( 0.41025800019463f), Q31( 0.02116736935734f)}, {Q31( 0.09638062008048f), Q31( 0.04411984381457f)}, +{Q31(-0.85283249275397f), Q31( 0.91475563922421f)}, {Q31( 0.88866808958124f), Q31(-0.99735267083226f)}, +{Q31(-0.48202429536989f), Q31(-0.96805608884164f)}, {Q31( 0.27572582416567f), Q31( 0.58634753335832f)}, +{Q31(-0.65889129659168f), Q31( 0.58835634138583f)}, {Q31( 0.98838086953732f), Q31( 0.99994349600236f)}, +{Q31(-0.20651349620689f), Q31( 0.54593044066355f)}, {Q31(-0.62126416356920f), Q31(-0.59893681700392f)}, +{Q31( 0.20320105410437f), Q31(-0.86879180355289f)}, {Q31(-0.97790548600584f), Q31( 0.96290806999242f)}, +{Q31( 0.11112534735126f), Q31( 0.21484763313301f)}, {Q31(-0.41368337314182f), Q31( 0.28216837680365f)}, +{Q31( 0.24133038992960f), Q31( 0.51294362630238f)}, {Q31(-0.66393410674885f), Q31(-0.08249679629081f)}, +{Q31(-0.53697829178752f), Q31(-0.97649903936228f)}, {Q31(-0.97224737889348f), Q31( 0.22081333579837f)}, +{Q31( 0.87392477144549f), Q31(-0.12796173740361f)}, {Q31( 0.19050361015753f), Q31( 0.01602615387195f)}, +{Q31(-0.46353441212724f), Q31(-0.95249041539006f)}, {Q31(-0.07064096339021f), Q31(-0.94479803205886f)}, +{Q31(-0.92444085484466f), Q31(-0.10457590187436f)}, {Q31(-0.83822593578728f), Q31(-0.01695043208885f)}, +{Q31( 0.75214681811150f), Q31(-0.99955681042665f)}, {Q31(-0.42102998829339f), Q31( 0.99720941999394f)}, +{Q31(-0.72094786237696f), Q31(-0.35008961934255f)}, {Q31( 0.78843311019251f), Q31( 0.52851398958271f)}, +{Q31( 0.97394027897442f), Q31(-0.26695944086561f)}, {Q31( 0.99206463477946f), Q31(-0.57010120849429f)}, +{Q31( 0.76789609461795f), Q31(-0.76519356730966f)}, {Q31(-0.82002421836409f), Q31(-0.73530179553767f)}, +{Q31( 0.81924990025724f), Q31( 0.99698425250579f)}, {Q31(-0.26719850873357f), Q31( 0.68903369776193f)}, +{Q31(-0.43311260380975f), Q31( 0.85321815947490f)}, {Q31( 0.99194979673836f), Q31( 0.91876249766422f)}, +{Q31(-0.80692001248487f), Q31(-0.32627540663214f)}, {Q31( 0.43080003649976f), Q31(-0.21919095636638f)}, +{Q31( 0.67709491937357f), Q31(-0.95478075822906f)}, {Q31( 0.56151770568316f), Q31(-0.70693811747778f)}, +{Q31( 0.10831862810749f), Q31(-0.08628837174592f)}, {Q31( 0.91229417540436f), Q31(-0.65987351408410f)}, +{Q31(-0.48972893932274f), Q31( 0.56289246362686f)}, {Q31(-0.89033658689697f), Q31(-0.71656563987082f)}, +{Q31( 0.65269447475094f), Q31( 0.65916004833932f)}, {Q31( 0.67439478141121f), Q31(-0.81684380846796f)}, +{Q31(-0.47770832416973f), Q31(-0.16789556203025f)}, {Q31(-0.99715979260878f), Q31(-0.93565784007648f)}, +{Q31(-0.90889593602546f), Q31( 0.62034397054380f)}, {Q31(-0.06618622548177f), Q31(-0.23812217221359f)}, +{Q31( 0.99430266919728f), Q31( 0.18812555317553f)}, {Q31( 0.97686402381843f), Q31(-0.28664534366620f)}, +{Q31( 0.94813650221268f), Q31(-0.97506640027128f)}, {Q31(-0.95434497492853f), Q31(-0.79607978501983f)}, +{Q31(-0.49104783137150f), Q31( 0.32895214359663f)}, {Q31( 0.99881175120751f), Q31( 0.88993983831354f)}, +{Q31( 0.50449166760303f), Q31(-0.85995072408434f)}, {Q31( 0.47162891065108f), Q31(-0.18680204049569f)}, +{Q31(-0.62081581361840f), Q31( 0.75000676218956f)}, {Q31(-0.43867015250812f), Q31( 0.99998069244322f)}, +{Q31( 0.98630563232075f), Q31(-0.53578899600662f)}, {Q31(-0.61510362277374f), Q31(-0.89515019899997f)}, +{Q31(-0.03841517601843f), Q31(-0.69888815681179f)}, {Q31(-0.30102157304644f), Q31(-0.07667808922205f)}, +{Q31( 0.41881284182683f), Q31( 0.02188098922282f)}, {Q31(-0.86135454941237f), Q31( 0.98947480909359f)}, +{Q31( 0.67226861393788f), Q31(-0.13494389011014f)}, {Q31(-0.70737398842068f), Q31(-0.76547349325992f)}, +{Q31( 0.94044946687963f), Q31( 0.09026201157416f)}, {Q31(-0.82386352534327f), Q31( 0.08924768823676f)}, +{Q31(-0.32070666698656f), Q31( 0.50143421908753f)}, {Q31( 0.57593163224487f), Q31(-0.98966422921509f)}, +{Q31(-0.36326018419965f), Q31( 0.07440243123228f)}, {Q31( 0.99979044674350f), Q31(-0.14130287347405f)}, +{Q31(-0.92366023326932f), Q31(-0.97979298068180f)}, {Q31(-0.44607178518598f), Q31(-0.54233252016394f)}, +{Q31( 0.44226800932956f), Q31( 0.71326756742752f)}, {Q31( 0.03671907158312f), Q31( 0.63606389366675f)}, +{Q31( 0.52175424682195f), Q31(-0.85396826735705f)}, {Q31(-0.94701139690956f), Q31(-0.01826348194255f)}, +{Q31(-0.98759606946049f), Q31( 0.82288714303073f)}, {Q31( 0.87434794743625f), Q31( 0.89399495655433f)}, +{Q31(-0.93412041758744f), Q31( 0.41374052024363f)}, {Q31( 0.96063943315511f), Q31( 0.93116709541280f)}, +{Q31( 0.97534253457837f), Q31( 0.86150930812689f)}, {Q31( 0.99642466504163f), Q31( 0.70190043427512f)}, +{Q31(-0.94705089665984f), Q31(-0.29580042814306f)}, {Q31( 0.91599807087376f), Q31(-0.98147830385781f)}, // Start of duplicated table -{-0.99948153278296, -0.59483417516607}, { 0.97113454393991, -0.67528515225647}, -{ 0.14130051758487, -0.95090983575689}, {-0.47005496701697, -0.37340549728647}, -{ 0.80705063769351, 0.29653668284408}, {-0.38981478896926, 0.89572605717087}, -{-0.01053049862020, -0.66959058036166}, {-0.91266367957293, -0.11522938140034}, +{Q31(-0.99948153278296f), Q31(-0.59483417516607f)}, {Q31( 0.97113454393991f), Q31(-0.67528515225647f)}, +{Q31( 0.14130051758487f), Q31(-0.95090983575689f)}, {Q31(-0.47005496701697f), Q31(-0.37340549728647f)}, +{Q31( 0.80705063769351f), Q31( 0.29653668284408f)}, {Q31(-0.38981478896926f), Q31( 0.89572605717087f)}, +{Q31(-0.01053049862020f), Q31(-0.66959058036166f)}, {Q31(-0.91266367957293f), Q31(-0.11522938140034f)}, }; #endif /* AVCODEC_AACSBRDATA_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_fixed.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_fixed.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_fixed.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_fixed.c 2015-07-20 17:20:03.000000000 +0000 @@ -0,0 +1,586 @@ +/* + * Copyright (c) 2013 + * MIPS Technologies, Inc., California. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * AAC Spectral Band Replication decoding functions (fixed-point) + * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) + * Copyright (c) 2009-2010 Alex Converse + * + * 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 + */ + +/** + * @file + * AAC Spectral Band Replication decoding functions (fixed-point) + * Note: Rounding-to-nearest used unless otherwise stated + * @author Robert Swain ( rob opendot cl ) + * @author Stanislav Ocovaj ( stanislav.ocovaj imgtec com ) + */ +#define USE_FIXED 1 + +#include "aac.h" +#include "sbr.h" +#include "aacsbr.h" +#include "aacsbrdata.h" +#include "aacsbr_fixed_tablegen.h" +#include "fft.h" +#include "aacps.h" +#include "sbrdsp.h" +#include "libavutil/internal.h" +#include "libavutil/libm.h" +#include "libavutil/avassert.h" + +#include +#include +#include + +static VLC vlc_sbr[10]; +static void aacsbr_func_ptr_init(AACSBRContext *c); +static const int CONST_LN2 = Q31(0.6931471806/256); // ln(2)/256 +static const int CONST_RECIP_LN2 = Q31(0.7213475204); // 0.5/ln(2) +static const int CONST_SQRT2 = Q30(0.7071067812); // sqrt(2)/2 +static const int CONST_076923 = Q31(0.76923076923076923077f); + +int fixed_log_table[10] = +{ + Q31(1.0/2), Q31(1.0/3), Q31(1.0/4), Q31(1.0/5), Q31(1.0/6), + Q31(1.0/7), Q31(1.0/8), Q31(1.0/9), Q31(1.0/10), Q31(1.0/11) +}; + +static int fixed_log(int x) +{ + int i, ret, xpow, tmp; + + ret = x; + xpow = x; + for (i=0; i<10; i+=2){ + xpow = (int)(((int64_t)xpow * x + 0x40000000) >> 31); + tmp = (int)(((int64_t)xpow * fixed_log_table[i] + 0x40000000) >> 31); + ret -= tmp; + + xpow = (int)(((int64_t)xpow * x + 0x40000000) >> 31); + tmp = (int)(((int64_t)xpow * fixed_log_table[i+1] + 0x40000000) >> 31); + ret += tmp; + } + + return ret; +} + +int fixed_exp_table[7] = +{ + Q31(1.0/2), Q31(1.0/6), Q31(1.0/24), Q31(1.0/120), + Q31(1.0/720), Q31(1.0/5040), Q31(1.0/40320) +}; + +static int fixed_exp(int x) +{ + int i, ret, xpow, tmp; + + ret = 0x800000 + x; + xpow = x; + for (i=0; i<7; i++){ + xpow = (int)(((int64_t)xpow * x + 0x400000) >> 23); + tmp = (int)(((int64_t)xpow * fixed_exp_table[i] + 0x40000000) >> 31); + ret += tmp; + } + + return ret; +} + +static void make_bands(int16_t* bands, int start, int stop, int num_bands) +{ + int k, previous, present; + int base, prod, nz = 0; + + base = (stop << 23) / start; + while (base < 0x40000000){ + base <<= 1; + nz++; + } + base = fixed_log(base - 0x80000000); + base = (((base + 0x80) >> 8) + (8-nz)*CONST_LN2) / num_bands; + base = fixed_exp(base); + + previous = start; + prod = start << 23; + + for (k = 0; k < num_bands-1; k++) { + prod = (int)(((int64_t)prod * base + 0x400000) >> 23); + present = (prod + 0x400000) >> 23; + bands[k] = present - previous; + previous = present; + } + bands[num_bands-1] = stop - previous; +} + +/// Dequantization and stereo decoding (14496-3 sp04 p203) +static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) +{ + int k, e; + int ch; + + if (id_aac == TYPE_CPE && sbr->bs_coupling) { + int alpha = sbr->data[0].bs_amp_res ? 2 : 1; + int pan_offset = sbr->data[0].bs_amp_res ? 12 : 24; + for (e = 1; e <= sbr->data[0].bs_num_env; e++) { + for (k = 0; k < sbr->n[sbr->data[0].bs_freq_res[e]]; k++) { + SoftFloat temp1, temp2, fac; + + temp1.exp = sbr->data[0].env_facs[e][k].mant * alpha + 14; + if (temp1.exp & 1) + temp1.mant = 759250125; + else + temp1.mant = 0x20000000; + temp1.exp = (temp1.exp >> 1) + 1; + + temp2.exp = (pan_offset - sbr->data[1].env_facs[e][k].mant) * alpha; + if (temp2.exp & 1) + temp2.mant = 759250125; + else + temp2.mant = 0x20000000; + temp2.exp = (temp2.exp >> 1) + 1; + fac = av_div_sf(temp1, av_add_sf(FLOAT_1, temp2)); + sbr->data[0].env_facs[e][k] = fac; + sbr->data[1].env_facs[e][k] = av_mul_sf(fac, temp2); + } + } + for (e = 1; e <= sbr->data[0].bs_num_noise; e++) { + for (k = 0; k < sbr->n_q; k++) { + SoftFloat temp1, temp2, fac; + + temp1.exp = NOISE_FLOOR_OFFSET - \ + sbr->data[0].noise_facs[e][k].mant + 2; + temp1.mant = 0x20000000; + temp2.exp = 12 - sbr->data[1].noise_facs[e][k].mant + 1; + temp2.mant = 0x20000000; + fac = av_div_sf(temp1, av_add_sf(FLOAT_1, temp2)); + sbr->data[0].noise_facs[e][k] = fac; + sbr->data[1].noise_facs[e][k] = av_mul_sf(fac, temp2); + } + } + } else { // SCE or one non-coupled CPE + for (ch = 0; ch < (id_aac == TYPE_CPE) + 1; ch++) { + int alpha = sbr->data[ch].bs_amp_res ? 2 : 1; + for (e = 1; e <= sbr->data[ch].bs_num_env; e++) + for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++){ + SoftFloat temp1; + + temp1.exp = alpha * sbr->data[ch].env_facs[e][k].mant + 12; + if (temp1.exp & 1) + temp1.mant = 759250125; + else + temp1.mant = 0x20000000; + temp1.exp = (temp1.exp >> 1) + 1; + + sbr->data[ch].env_facs[e][k] = temp1; + } + for (e = 1; e <= sbr->data[ch].bs_num_noise; e++) + for (k = 0; k < sbr->n_q; k++){ + sbr->data[ch].noise_facs[e][k].exp = NOISE_FLOOR_OFFSET - \ + sbr->data[ch].noise_facs[e][k].mant + 1; + sbr->data[ch].noise_facs[e][k].mant = 0x20000000; + } + } + } +} + +/** High Frequency Generation (14496-3 sp04 p214+) and Inverse Filtering + * (14496-3 sp04 p214) + * Warning: This routine does not seem numerically stable. + */ +static void sbr_hf_inverse_filter(SBRDSPContext *dsp, + int (*alpha0)[2], int (*alpha1)[2], + const int X_low[32][40][2], int k0) +{ + int k; + int shift, round; + + for (k = 0; k < k0; k++) { + SoftFloat phi[3][2][2]; + SoftFloat a00, a01, a10, a11; + SoftFloat dk; + + dsp->autocorrelate(X_low[k], phi); + + dk = av_sub_sf(av_mul_sf(phi[2][1][0], phi[1][0][0]), + av_mul_sf(av_add_sf(av_mul_sf(phi[1][1][0], phi[1][1][0]), + av_mul_sf(phi[1][1][1], phi[1][1][1])), FLOAT_0999999)); + + if (!dk.mant) { + a10 = FLOAT_0; + a11 = FLOAT_0; + } else { + SoftFloat temp_real, temp_im; + temp_real = av_sub_sf(av_sub_sf(av_mul_sf(phi[0][0][0], phi[1][1][0]), + av_mul_sf(phi[0][0][1], phi[1][1][1])), + av_mul_sf(phi[0][1][0], phi[1][0][0])); + temp_im = av_sub_sf(av_add_sf(av_mul_sf(phi[0][0][0], phi[1][1][1]), + av_mul_sf(phi[0][0][1], phi[1][1][0])), + av_mul_sf(phi[0][1][1], phi[1][0][0])); + + a10 = av_div_sf(temp_real, dk); + a11 = av_div_sf(temp_im, dk); + } + + if (!phi[1][0][0].mant) { + a00 = FLOAT_0; + a01 = FLOAT_0; + } else { + SoftFloat temp_real, temp_im; + temp_real = av_add_sf(phi[0][0][0], + av_add_sf(av_mul_sf(a10, phi[1][1][0]), + av_mul_sf(a11, phi[1][1][1]))); + temp_im = av_add_sf(phi[0][0][1], + av_sub_sf(av_mul_sf(a11, phi[1][1][0]), + av_mul_sf(a10, phi[1][1][1]))); + + temp_real.mant = -temp_real.mant; + temp_im.mant = -temp_im.mant; + a00 = av_div_sf(temp_real, phi[1][0][0]); + a01 = av_div_sf(temp_im, phi[1][0][0]); + } + + shift = a00.exp; + if (shift >= 3) + alpha0[k][0] = 0x7fffffff; + else { + a00.mant <<= 1; + shift = 2-shift; + if (shift == 0) + alpha0[k][0] = a00.mant; + else { + round = 1 << (shift-1); + alpha0[k][0] = (a00.mant + round) >> shift; + } + } + + shift = a01.exp; + if (shift >= 3) + alpha0[k][1] = 0x7fffffff; + else { + a01.mant <<= 1; + shift = 2-shift; + if (shift == 0) + alpha0[k][1] = a01.mant; + else { + round = 1 << (shift-1); + alpha0[k][1] = (a01.mant + round) >> shift; + } + } + shift = a10.exp; + if (shift >= 3) + alpha1[k][0] = 0x7fffffff; + else { + a10.mant <<= 1; + shift = 2-shift; + if (shift == 0) + alpha1[k][0] = a10.mant; + else { + round = 1 << (shift-1); + alpha1[k][0] = (a10.mant + round) >> shift; + } + } + + shift = a11.exp; + if (shift >= 3) + alpha1[k][1] = 0x7fffffff; + else { + a11.mant <<= 1; + shift = 2-shift; + if (shift == 0) + alpha1[k][1] = a11.mant; + else { + round = 1 << (shift-1); + alpha1[k][1] = (a11.mant + round) >> shift; + } + } + + shift = (int)(((int64_t)(alpha1[k][0]>>1) * (alpha1[k][0]>>1) + \ + (int64_t)(alpha1[k][1]>>1) * (alpha1[k][1]>>1) + \ + 0x40000000) >> 31); + if (shift >= 0x20000000){ + alpha1[k][0] = 0; + alpha1[k][1] = 0; + alpha0[k][0] = 0; + alpha0[k][1] = 0; + } + + shift = (int)(((int64_t)(alpha0[k][0]>>1) * (alpha0[k][0]>>1) + \ + (int64_t)(alpha0[k][1]>>1) * (alpha0[k][1]>>1) + \ + 0x40000000) >> 31); + if (shift >= 0x20000000){ + alpha1[k][0] = 0; + alpha1[k][1] = 0; + alpha0[k][0] = 0; + alpha0[k][1] = 0; + } + } +} + +/// Chirp Factors (14496-3 sp04 p214) +static void sbr_chirp(SpectralBandReplication *sbr, SBRData *ch_data) +{ + int i; + int new_bw; + static const int bw_tab[] = { 0, 1610612736, 1932735283, 2104533975 }; + int64_t accu; + + for (i = 0; i < sbr->n_q; i++) { + if (ch_data->bs_invf_mode[0][i] + ch_data->bs_invf_mode[1][i] == 1) + new_bw = 1288490189; + else + new_bw = bw_tab[ch_data->bs_invf_mode[0][i]]; + + if (new_bw < ch_data->bw_array[i]){ + accu = (int64_t)new_bw * 1610612736; + accu += (int64_t)ch_data->bw_array[i] * 0x20000000; + new_bw = (int)((accu + 0x40000000) >> 31); + } else { + accu = (int64_t)new_bw * 1946157056; + accu += (int64_t)ch_data->bw_array[i] * 201326592; + new_bw = (int)((accu + 0x40000000) >> 31); + } + ch_data->bw_array[i] = new_bw < 0x2000000 ? 0 : new_bw; + } +} + +/** + * Calculation of levels of additional HF signal components (14496-3 sp04 p219) + * and Calculation of gain (14496-3 sp04 p219) + */ +static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr, + SBRData *ch_data, const int e_a[2]) +{ + int e, k, m; + // max gain limits : -3dB, 0dB, 3dB, inf dB (limiter off) + static const SoftFloat limgain[4] = { { 760155524, 0 }, { 0x20000000, 1 }, + { 758351638, 1 }, { 625000000, 34 } }; + + for (e = 0; e < ch_data->bs_num_env; e++) { + int delta = !((e == e_a[1]) || (e == e_a[0])); + for (k = 0; k < sbr->n_lim; k++) { + SoftFloat gain_boost, gain_max; + SoftFloat sum[2] = { { 0, 0}, { 0, 0 } }; + for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { + const SoftFloat temp = av_div_sf(sbr->e_origmapped[e][m], + av_add_sf(FLOAT_1, sbr->q_mapped[e][m])); + sbr->q_m[e][m] = av_sqrt_sf(av_mul_sf(temp, sbr->q_mapped[e][m])); + sbr->s_m[e][m] = av_sqrt_sf(av_mul_sf(temp, av_int2sf(ch_data->s_indexmapped[e + 1][m], 0))); + if (!sbr->s_mapped[e][m]) { + if (delta) { + sbr->gain[e][m] = av_sqrt_sf(av_div_sf(sbr->e_origmapped[e][m], + av_mul_sf(av_add_sf(FLOAT_1, sbr->e_curr[e][m]), + av_add_sf(FLOAT_1, sbr->q_mapped[e][m])))); + } else { + sbr->gain[e][m] = av_sqrt_sf(av_div_sf(sbr->e_origmapped[e][m], + av_add_sf(FLOAT_1, sbr->e_curr[e][m]))); + } + } else { + sbr->gain[e][m] = av_sqrt_sf( + av_div_sf( + av_mul_sf(sbr->e_origmapped[e][m], sbr->q_mapped[e][m]), + av_mul_sf( + av_add_sf(FLOAT_1, sbr->e_curr[e][m]), + av_add_sf(FLOAT_1, sbr->q_mapped[e][m])))); + } + } + for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { + sum[0] = av_add_sf(sum[0], sbr->e_origmapped[e][m]); + sum[1] = av_add_sf(sum[1], sbr->e_curr[e][m]); + } + gain_max = av_mul_sf(limgain[sbr->bs_limiter_gains], + av_sqrt_sf( + av_div_sf( + av_add_sf(FLOAT_EPSILON, sum[0]), + av_add_sf(FLOAT_EPSILON, sum[1])))); + if (av_gt_sf(gain_max, FLOAT_100000)) + gain_max = FLOAT_100000; + for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { + SoftFloat q_m_max = av_div_sf( + av_mul_sf(sbr->q_m[e][m], gain_max), + sbr->gain[e][m]); + if (av_gt_sf(sbr->q_m[e][m], q_m_max)) + sbr->q_m[e][m] = q_m_max; + if (av_gt_sf(sbr->gain[e][m], gain_max)) + sbr->gain[e][m] = gain_max; + } + sum[0] = sum[1] = FLOAT_0; + for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { + sum[0] = av_add_sf(sum[0], sbr->e_origmapped[e][m]); + sum[1] = av_add_sf(sum[1], + av_mul_sf( + av_mul_sf(sbr->e_curr[e][m], + sbr->gain[e][m]), + sbr->gain[e][m])); + sum[1] = av_add_sf(sum[1], + av_mul_sf(sbr->s_m[e][m], sbr->s_m[e][m])); + if (delta && !sbr->s_m[e][m].mant) + sum[1] = av_add_sf(sum[1], + av_mul_sf(sbr->q_m[e][m], sbr->q_m[e][m])); + } + gain_boost = av_sqrt_sf( + av_div_sf( + av_add_sf(FLOAT_EPSILON, sum[0]), + av_add_sf(FLOAT_EPSILON, sum[1]))); + if (av_gt_sf(gain_boost, FLOAT_1584893192)) + gain_boost = FLOAT_1584893192; + + for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { + sbr->gain[e][m] = av_mul_sf(sbr->gain[e][m], gain_boost); + sbr->q_m[e][m] = av_mul_sf(sbr->q_m[e][m], gain_boost); + sbr->s_m[e][m] = av_mul_sf(sbr->s_m[e][m], gain_boost); + } + } + } +} + +/// Assembling HF Signals (14496-3 sp04 p220) +static void sbr_hf_assemble(int Y1[38][64][2], + const int X_high[64][40][2], + SpectralBandReplication *sbr, SBRData *ch_data, + const int e_a[2]) +{ + int e, i, j, m; + const int h_SL = 4 * !sbr->bs_smoothing_mode; + const int kx = sbr->kx[1]; + const int m_max = sbr->m[1]; + static const SoftFloat h_smooth[5] = { + { 715827883, -1 }, + { 647472402, -1 }, + { 937030863, -2 }, + { 989249804, -3 }, + { 546843842, -4 }, + }; + SoftFloat (*g_temp)[48] = ch_data->g_temp, (*q_temp)[48] = ch_data->q_temp; + int indexnoise = ch_data->f_indexnoise; + int indexsine = ch_data->f_indexsine; + + if (sbr->reset) { + for (i = 0; i < h_SL; i++) { + memcpy(g_temp[i + 2*ch_data->t_env[0]], sbr->gain[0], m_max * sizeof(sbr->gain[0][0])); + memcpy(q_temp[i + 2*ch_data->t_env[0]], sbr->q_m[0], m_max * sizeof(sbr->q_m[0][0])); + } + } else if (h_SL) { + for (i = 0; i < 4; i++) { + memcpy(g_temp[i + 2 * ch_data->t_env[0]], + g_temp[i + 2 * ch_data->t_env_num_env_old], + sizeof(g_temp[0])); + memcpy(q_temp[i + 2 * ch_data->t_env[0]], + q_temp[i + 2 * ch_data->t_env_num_env_old], + sizeof(q_temp[0])); + } + } + + for (e = 0; e < ch_data->bs_num_env; e++) { + for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) { + memcpy(g_temp[h_SL + i], sbr->gain[e], m_max * sizeof(sbr->gain[0][0])); + memcpy(q_temp[h_SL + i], sbr->q_m[e], m_max * sizeof(sbr->q_m[0][0])); + } + } + + for (e = 0; e < ch_data->bs_num_env; e++) { + for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) { + SoftFloat g_filt_tab[48]; + SoftFloat q_filt_tab[48]; + SoftFloat *g_filt, *q_filt; + + if (h_SL && e != e_a[0] && e != e_a[1]) { + g_filt = g_filt_tab; + q_filt = q_filt_tab; + for (m = 0; m < m_max; m++) { + const int idx1 = i + h_SL; + g_filt[m].mant = g_filt[m].exp = 0; + q_filt[m].mant = q_filt[m].exp = 0; + for (j = 0; j <= h_SL; j++) { + g_filt[m] = av_add_sf(g_filt[m], + av_mul_sf(g_temp[idx1 - j][m], + h_smooth[j])); + q_filt[m] = av_add_sf(q_filt[m], + av_mul_sf(q_temp[idx1 - j][m], + h_smooth[j])); + } + } + } else { + g_filt = g_temp[i + h_SL]; + q_filt = q_temp[i]; + } + + sbr->dsp.hf_g_filt(Y1[i] + kx, X_high + kx, g_filt, m_max, + i + ENVELOPE_ADJUSTMENT_OFFSET); + + if (e != e_a[0] && e != e_a[1]) { + sbr->dsp.hf_apply_noise[indexsine](Y1[i] + kx, sbr->s_m[e], + q_filt, indexnoise, + kx, m_max); + } else { + int idx = indexsine&1; + int A = (1-((indexsine+(kx & 1))&2)); + int B = (A^(-idx)) + idx; + int *out = &Y1[i][kx][idx]; + int shift, round; + + SoftFloat *in = sbr->s_m[e]; + for (m = 0; m+1 < m_max; m+=2) { + shift = 22 - in[m ].exp; + round = 1 << (shift-1); + out[2*m ] += (in[m ].mant * A + round) >> shift; + + shift = 22 - in[m+1].exp; + round = 1 << (shift-1); + out[2*m+2] += (in[m+1].mant * B + round) >> shift; + } + if(m_max&1) + { + shift = 22 - in[m ].exp; + round = 1 << (shift-1); + + out[2*m ] += (in[m ].mant * A + round) >> shift; + } + } + indexnoise = (indexnoise + m_max) & 0x1ff; + indexsine = (indexsine + 1) & 3; + } + } + ch_data->f_indexnoise = indexnoise; + ch_data->f_indexsine = indexsine; +} + +#include "aacsbr_template.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_fixed_tablegen.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_fixed_tablegen.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_fixed_tablegen.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_fixed_tablegen.c 2015-07-21 17:20:03.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Header file for hardcoded AAC SBR windows + * + * Copyright (c) 2014 Reimar Döffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "libavutil/internal.h" +#include "libavutil/common.h" +#undef CONFIG_HARDCODED_TABLES +#define CONFIG_HARDCODED_TABLES 0 +#define USE_FIXED 1 +#include "aacsbr_fixed_tablegen.h" +#include "tableprint.h" + +int main(void) +{ + aacsbr_tableinit(); + + write_fileheader(); + + WRITE_ARRAY_ALIGNED("static const", 32, int32_t, sbr_qmf_window_ds); + WRITE_ARRAY_ALIGNED("static const", 32, int32_t, sbr_qmf_window_us); + + return 0; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_fixed_tablegen.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_fixed_tablegen.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_fixed_tablegen.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_fixed_tablegen.h 2015-07-20 17:20:03.000000000 +0000 @@ -0,0 +1,32 @@ +/* + * Header file for hardcoded AAC SBR windows + * + * Copyright (c) 2014 Reimar Döffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_AACSBR_FIXED_TABLEGEN_H +#define AVCODEC_AACSBR_FIXED_TABLEGEN_H + +#include "aacsbr_tablegen_common.h" + +#if CONFIG_HARDCODED_TABLES +#include "libavcodec/aacsbr_fixed_tables.h" +#endif /* CONFIG_HARDCODED_TABLES */ + +#endif /* AVCODEC_AACSBR_FIXED_TABLEGEN_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr.h 2015-03-15 02:45:56.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr.h 2015-07-20 17:20:03.000000000 +0000 @@ -33,18 +33,63 @@ #include "aac.h" #include "sbr.h" +#define ENVELOPE_ADJUSTMENT_OFFSET 2 +#define NOISE_FLOOR_OFFSET FIXR(6.0f) + +/** + * SBR VLC tables + */ +enum { + T_HUFFMAN_ENV_1_5DB, + F_HUFFMAN_ENV_1_5DB, + T_HUFFMAN_ENV_BAL_1_5DB, + F_HUFFMAN_ENV_BAL_1_5DB, + T_HUFFMAN_ENV_3_0DB, + F_HUFFMAN_ENV_3_0DB, + T_HUFFMAN_ENV_BAL_3_0DB, + F_HUFFMAN_ENV_BAL_3_0DB, + T_HUFFMAN_NOISE_3_0DB, + T_HUFFMAN_NOISE_BAL_3_0DB, +}; + +/** + * bs_frame_class - frame class of current SBR frame (14496-3 sp04 p98) + */ +enum { + FIXFIX, + FIXVAR, + VARFIX, + VARVAR, +}; + +enum { + EXTENSION_ID_PS = 2, +}; + +static const int8_t vlc_sbr_lav[10] = + { 60, 60, 24, 24, 31, 31, 12, 12, 31, 12 }; + +#define SBR_INIT_VLC_STATIC(num, size) \ + INIT_VLC_STATIC(&vlc_sbr[num], 9, sbr_tmp[num].table_size / sbr_tmp[num].elem_size, \ + sbr_tmp[num].sbr_bits , 1, 1, \ + sbr_tmp[num].sbr_codes, sbr_tmp[num].elem_size, sbr_tmp[num].elem_size, \ + size) + +#define SBR_VLC_ROW(name) \ + { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) } + /** Initialize SBR. */ -void ff_aac_sbr_init(void); +void AAC_RENAME(ff_aac_sbr_init)(void); /** Initialize one SBR context. */ -void ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr); +void AAC_RENAME(ff_aac_sbr_ctx_init)(AACContext *ac, SpectralBandReplication *sbr); /** Close one SBR context. */ -void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr); +void AAC_RENAME(ff_aac_sbr_ctx_close)(SpectralBandReplication *sbr); /** Decode one SBR element. */ -int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, +int AAC_RENAME(ff_decode_sbr_extension)(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int crc, int cnt, int id_aac); /** Apply one SBR element to one AAC element. */ -void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, - float* L, float *R); +void AAC_RENAME(ff_sbr_apply)(AACContext *ac, SpectralBandReplication *sbr, int id_aac, + INTFLOAT* L, INTFLOAT *R); void ff_aacsbr_func_ptr_init_mips(AACSBRContext *c); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_tablegen.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_tablegen.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_tablegen.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_tablegen.c 2015-07-21 17:20:03.000000000 +0000 @@ -21,8 +21,11 @@ */ #include -#define CONFIG_HARDCODED_TABLES 0 +#include "libavutil/internal.h" #include "libavutil/common.h" +#undef CONFIG_HARDCODED_TABLES +#define CONFIG_HARDCODED_TABLES 0 +#define USE_FIXED 0 #include "aacsbr_tablegen.h" #include "tableprint.h" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_tablegen_common.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_tablegen_common.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_tablegen_common.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_tablegen_common.h 2015-07-20 17:20:03.000000000 +0000 @@ -0,0 +1,129 @@ +/* + * Header file for hardcoded AAC SBR windows + * + * Copyright (c) 2014 Reimar Döffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_AACSBR_TABLEGEN_COMMON_H +#define AVCODEC_AACSBR_TABLEGEN_COMMON_H +#include "aac.h" + +#if CONFIG_HARDCODED_TABLES +#define aacsbr_tableinit() +#else +///< window coefficients for analysis/synthesis QMF banks +static DECLARE_ALIGNED(32, INTFLOAT, sbr_qmf_window_ds)[320]; +static DECLARE_ALIGNED(32, INTFLOAT, sbr_qmf_window_us)[640] = { + Q31( 0.0000000000f), Q31(-0.0005525286f), Q31(-0.0005617692f), Q31(-0.0004947518f), + Q31(-0.0004875227f), Q31(-0.0004893791f), Q31(-0.0005040714f), Q31(-0.0005226564f), + Q31(-0.0005466565f), Q31(-0.0005677802f), Q31(-0.0005870930f), Q31(-0.0006132747f), + Q31(-0.0006312493f), Q31(-0.0006540333f), Q31(-0.0006777690f), Q31(-0.0006941614f), + Q31(-0.0007157736f), Q31(-0.0007255043f), Q31(-0.0007440941f), Q31(-0.0007490598f), + Q31(-0.0007681371f), Q31(-0.0007724848f), Q31(-0.0007834332f), Q31(-0.0007779869f), + Q31(-0.0007803664f), Q31(-0.0007801449f), Q31(-0.0007757977f), Q31(-0.0007630793f), + Q31(-0.0007530001f), Q31(-0.0007319357f), Q31(-0.0007215391f), Q31(-0.0006917937f), + Q31(-0.0006650415f), Q31(-0.0006341594f), Q31(-0.0005946118f), Q31(-0.0005564576f), + Q31(-0.0005145572f), Q31(-0.0004606325f), Q31(-0.0004095121f), Q31(-0.0003501175f), + Q31(-0.0002896981f), Q31(-0.0002098337f), Q31(-0.0001446380f), Q31(-0.0000617334f), + Q31( 0.0000134949f), Q31( 0.0001094383f), Q31( 0.0002043017f), Q31( 0.0002949531f), + Q31( 0.0004026540f), Q31( 0.0005107388f), Q31( 0.0006239376f), Q31( 0.0007458025f), + Q31( 0.0008608443f), Q31( 0.0009885988f), Q31( 0.0011250155f), Q31( 0.0012577884f), + Q31( 0.0013902494f), Q31( 0.0015443219f), Q31( 0.0016868083f), Q31( 0.0018348265f), + Q31( 0.0019841140f), Q31( 0.0021461583f), Q31( 0.0023017254f), Q31( 0.0024625616f), + Q31( 0.0026201758f), Q31( 0.0027870464f), Q31( 0.0029469447f), Q31( 0.0031125420f), + Q31( 0.0032739613f), Q31( 0.0034418874f), Q31( 0.0036008268f), Q31( 0.0037603922f), + Q31( 0.0039207432f), Q31( 0.0040819753f), Q31( 0.0042264269f), Q31( 0.0043730719f), + Q31( 0.0045209852f), Q31( 0.0046606460f), Q31( 0.0047932560f), Q31( 0.0049137603f), + Q31( 0.0050393022f), Q31( 0.0051407353f), Q31( 0.0052461166f), Q31( 0.0053471681f), + Q31( 0.0054196775f), Q31( 0.0054876040f), Q31( 0.0055475714f), Q31( 0.0055938023f), + Q31( 0.0056220643f), Q31( 0.0056455196f), Q31( 0.0056389199f), Q31( 0.0056266114f), + Q31( 0.0055917128f), Q31( 0.0055404363f), Q31( 0.0054753783f), Q31( 0.0053838975f), + Q31( 0.0052715758f), Q31( 0.0051382275f), Q31( 0.0049839687f), Q31( 0.0048109469f), + Q31( 0.0046039530f), Q31( 0.0043801861f), Q31( 0.0041251642f), Q31( 0.0038456408f), + Q31( 0.0035401246f), Q31( 0.0032091885f), Q31( 0.0028446757f), Q31( 0.0024508540f), + Q31( 0.0020274176f), Q31( 0.0015784682f), Q31( 0.0010902329f), Q31( 0.0005832264f), + Q31( 0.0000276045f), Q31(-0.0005464280f), Q31(-0.0011568135f), Q31(-0.0018039472f), + Q31(-0.0024826723f), Q31(-0.0031933778f), Q31(-0.0039401124f), Q31(-0.0047222596f), + Q31(-0.0055337211f), Q31(-0.0063792293f), Q31(-0.0072615816f), Q31(-0.0081798233f), + Q31(-0.0091325329f), Q31(-0.0101150215f), Q31(-0.0111315548f), Q31(-0.0121849995f), + Q31( 0.0132718220f), Q31( 0.0143904666f), Q31( 0.0155405553f), Q31( 0.0167324712f), + Q31( 0.0179433381f), Q31( 0.0191872431f), Q31( 0.0204531793f), Q31( 0.0217467550f), + Q31( 0.0230680169f), Q31( 0.0244160992f), Q31( 0.0257875847f), Q31( 0.0271859429f), + Q31( 0.0286072173f), Q31( 0.0300502657f), Q31( 0.0315017608f), Q31( 0.0329754081f), + Q31( 0.0344620948f), Q31( 0.0359697560f), Q31( 0.0374812850f), Q31( 0.0390053679f), + Q31( 0.0405349170f), Q31( 0.0420649094f), Q31( 0.0436097542f), Q31( 0.0451488405f), + Q31( 0.0466843027f), Q31( 0.0482165720f), Q31( 0.0497385755f), Q31( 0.0512556155f), + Q31( 0.0527630746f), Q31( 0.0542452768f), Q31( 0.0557173648f), Q31( 0.0571616450f), + Q31( 0.0585915683f), Q31( 0.0599837480f), Q31( 0.0613455171f), Q31( 0.0626857808f), + Q31( 0.0639715898f), Q31( 0.0652247106f), Q31( 0.0664367512f), Q31( 0.0676075985f), + Q31( 0.0687043828f), Q31( 0.0697630244f), Q31( 0.0707628710f), Q31( 0.0717002673f), + Q31( 0.0725682583f), Q31( 0.0733620255f), Q31( 0.0741003642f), Q31( 0.0747452558f), + Q31( 0.0753137336f), Q31( 0.0758008358f), Q31( 0.0761992479f), Q31( 0.0764992170f), + Q31( 0.0767093490f), Q31( 0.0768173975f), Q31( 0.0768230011f), Q31( 0.0767204924f), + Q31( 0.0765050718f), Q31( 0.0761748321f), Q31( 0.0757305756f), Q31( 0.0751576255f), + Q31( 0.0744664394f), Q31( 0.0736406005f), Q31( 0.0726774642f), Q31( 0.0715826364f), + Q31( 0.0703533073f), Q31( 0.0689664013f), Q31( 0.0674525021f), Q31( 0.0657690668f), + Q31( 0.0639444805f), Q31( 0.0619602779f), Q31( 0.0598166570f), Q31( 0.0575152691f), + Q31( 0.0550460034f), Q31( 0.0524093821f), Q31( 0.0495978676f), Q31( 0.0466303305f), + Q31( 0.0434768782f), Q31( 0.0401458278f), Q31( 0.0366418116f), Q31( 0.0329583930f), + Q31( 0.0290824006f), Q31( 0.0250307561f), Q31( 0.0207997072f), Q31( 0.0163701258f), + Q31( 0.0117623832f), Q31( 0.0069636862f), Q31( 0.0019765601f), Q31(-0.0032086896f), + Q31(-0.0085711749f), Q31(-0.0141288827f), Q31(-0.0198834129f), Q31(-0.0258227288f), + Q31(-0.0319531274f), Q31(-0.0382776572f), Q31(-0.0447806821f), Q31(-0.0514804176f), + Q31(-0.0583705326f), Q31(-0.0654409853f), Q31(-0.0726943300f), Q31(-0.0801372934f), + Q31(-0.0877547536f), Q31(-0.0955533352f), Q31(-0.1035329531f), Q31(-0.1116826931f), + Q31(-0.1200077984f), Q31(-0.1285002850f), Q31(-0.1371551761f), Q31(-0.1459766491f), + Q31(-0.1549607071f), Q31(-0.1640958855f), Q31(-0.1733808172f), Q31(-0.1828172548f), + Q31(-0.1923966745f), Q31(-0.2021250176f), Q31(-0.2119735853f), Q31(-0.2219652696f), + Q31(-0.2320690870f), Q31(-0.2423016884f), Q31(-0.2526480309f), Q31(-0.2631053299f), + Q31(-0.2736634040f), Q31(-0.2843214189f), Q31(-0.2950716717f), Q31(-0.3059098575f), + Q31(-0.3168278913f), Q31(-0.3278113727f), Q31(-0.3388722693f), Q31(-0.3499914122f), + Q31( 0.3611589903f), Q31( 0.3723795546f), Q31( 0.3836350013f), Q31( 0.3949211761f), + Q31( 0.4062317676f), Q31( 0.4175696896f), Q31( 0.4289119920f), Q31( 0.4402553754f), + Q31( 0.4515996535f), Q31( 0.4629308085f), Q31( 0.4742453214f), Q31( 0.4855253091f), + Q31( 0.4967708254f), Q31( 0.5079817500f), Q31( 0.5191234970f), Q31( 0.5302240895f), + Q31( 0.5412553448f), Q31( 0.5522051258f), Q31( 0.5630789140f), Q31( 0.5738524131f), + Q31( 0.5845403235f), Q31( 0.5951123086f), Q31( 0.6055783538f), Q31( 0.6159109932f), + Q31( 0.6261242695f), Q31( 0.6361980107f), Q31( 0.6461269695f), Q31( 0.6559016302f), + Q31( 0.6655139880f), Q31( 0.6749663190f), Q31( 0.6842353293f), Q31( 0.6933282376f), + Q31( 0.7022388719f), Q31( 0.7109410426f), Q31( 0.7194462634f), Q31( 0.7277448900f), + Q31( 0.7358211758f), Q31( 0.7436827863f), Q31( 0.7513137456f), Q31( 0.7587080760f), + Q31( 0.7658674865f), Q31( 0.7727780881f), Q31( 0.7794287519f), Q31( 0.7858353120f), + Q31( 0.7919735841f), Q31( 0.7978466413f), Q31( 0.8034485751f), Q31( 0.8087695004f), + Q31( 0.8138191270f), Q31( 0.8185776004f), Q31( 0.8230419890f), Q31( 0.8272275347f), + Q31( 0.8311038457f), Q31( 0.8346937361f), Q31( 0.8379717337f), Q31( 0.8409541392f), + Q31( 0.8436238281f), Q31( 0.8459818469f), Q31( 0.8480315777f), Q31( 0.8497805198f), + Q31( 0.8511971524f), Q31( 0.8523047035f), Q31( 0.8531020949f), Q31( 0.8535720573f), + Q31( 0.8537385600f), +}; + +static av_cold void aacsbr_tableinit(void) +{ + int n; + for (n = 1; n < 320; n++) + sbr_qmf_window_us[320 + n] = sbr_qmf_window_us[320 - n]; + sbr_qmf_window_us[384] = -sbr_qmf_window_us[384]; + sbr_qmf_window_us[512] = -sbr_qmf_window_us[512]; + + for (n = 0; n < 320; n++) + sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n]; +} +#endif /* CONFIG_HARDCODED_TABLES */ + +#endif /* AVCODEC_AACSBR_TABLEGEN_COMMON_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_tablegen.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_tablegen.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_tablegen.h 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_tablegen.h 2015-07-20 17:20:03.000000000 +0000 @@ -23,107 +23,10 @@ #ifndef AVCODEC_AACSBR_TABLEGEN_H #define AVCODEC_AACSBR_TABLEGEN_H +#include "aacsbr_tablegen_common.h" + #if CONFIG_HARDCODED_TABLES -#define aacsbr_tableinit() #include "libavcodec/aacsbr_tables.h" -#else -///< window coefficients for analysis/synthesis QMF banks -static DECLARE_ALIGNED(32, float, sbr_qmf_window_ds)[320]; -static DECLARE_ALIGNED(32, float, sbr_qmf_window_us)[640] = { - 0.0000000000, -0.0005525286, -0.0005617692, -0.0004947518, - -0.0004875227, -0.0004893791, -0.0005040714, -0.0005226564, - -0.0005466565, -0.0005677802, -0.0005870930, -0.0006132747, - -0.0006312493, -0.0006540333, -0.0006777690, -0.0006941614, - -0.0007157736, -0.0007255043, -0.0007440941, -0.0007490598, - -0.0007681371, -0.0007724848, -0.0007834332, -0.0007779869, - -0.0007803664, -0.0007801449, -0.0007757977, -0.0007630793, - -0.0007530001, -0.0007319357, -0.0007215391, -0.0006917937, - -0.0006650415, -0.0006341594, -0.0005946118, -0.0005564576, - -0.0005145572, -0.0004606325, -0.0004095121, -0.0003501175, - -0.0002896981, -0.0002098337, -0.0001446380, -0.0000617334, - 0.0000134949, 0.0001094383, 0.0002043017, 0.0002949531, - 0.0004026540, 0.0005107388, 0.0006239376, 0.0007458025, - 0.0008608443, 0.0009885988, 0.0011250155, 0.0012577884, - 0.0013902494, 0.0015443219, 0.0016868083, 0.0018348265, - 0.0019841140, 0.0021461583, 0.0023017254, 0.0024625616, - 0.0026201758, 0.0027870464, 0.0029469447, 0.0031125420, - 0.0032739613, 0.0034418874, 0.0036008268, 0.0037603922, - 0.0039207432, 0.0040819753, 0.0042264269, 0.0043730719, - 0.0045209852, 0.0046606460, 0.0047932560, 0.0049137603, - 0.0050393022, 0.0051407353, 0.0052461166, 0.0053471681, - 0.0054196775, 0.0054876040, 0.0055475714, 0.0055938023, - 0.0056220643, 0.0056455196, 0.0056389199, 0.0056266114, - 0.0055917128, 0.0055404363, 0.0054753783, 0.0053838975, - 0.0052715758, 0.0051382275, 0.0049839687, 0.0048109469, - 0.0046039530, 0.0043801861, 0.0041251642, 0.0038456408, - 0.0035401246, 0.0032091885, 0.0028446757, 0.0024508540, - 0.0020274176, 0.0015784682, 0.0010902329, 0.0005832264, - 0.0000276045, -0.0005464280, -0.0011568135, -0.0018039472, - -0.0024826723, -0.0031933778, -0.0039401124, -0.0047222596, - -0.0055337211, -0.0063792293, -0.0072615816, -0.0081798233, - -0.0091325329, -0.0101150215, -0.0111315548, -0.0121849995, - 0.0132718220, 0.0143904666, 0.0155405553, 0.0167324712, - 0.0179433381, 0.0191872431, 0.0204531793, 0.0217467550, - 0.0230680169, 0.0244160992, 0.0257875847, 0.0271859429, - 0.0286072173, 0.0300502657, 0.0315017608, 0.0329754081, - 0.0344620948, 0.0359697560, 0.0374812850, 0.0390053679, - 0.0405349170, 0.0420649094, 0.0436097542, 0.0451488405, - 0.0466843027, 0.0482165720, 0.0497385755, 0.0512556155, - 0.0527630746, 0.0542452768, 0.0557173648, 0.0571616450, - 0.0585915683, 0.0599837480, 0.0613455171, 0.0626857808, - 0.0639715898, 0.0652247106, 0.0664367512, 0.0676075985, - 0.0687043828, 0.0697630244, 0.0707628710, 0.0717002673, - 0.0725682583, 0.0733620255, 0.0741003642, 0.0747452558, - 0.0753137336, 0.0758008358, 0.0761992479, 0.0764992170, - 0.0767093490, 0.0768173975, 0.0768230011, 0.0767204924, - 0.0765050718, 0.0761748321, 0.0757305756, 0.0751576255, - 0.0744664394, 0.0736406005, 0.0726774642, 0.0715826364, - 0.0703533073, 0.0689664013, 0.0674525021, 0.0657690668, - 0.0639444805, 0.0619602779, 0.0598166570, 0.0575152691, - 0.0550460034, 0.0524093821, 0.0495978676, 0.0466303305, - 0.0434768782, 0.0401458278, 0.0366418116, 0.0329583930, - 0.0290824006, 0.0250307561, 0.0207997072, 0.0163701258, - 0.0117623832, 0.0069636862, 0.0019765601, -0.0032086896, - -0.0085711749, -0.0141288827, -0.0198834129, -0.0258227288, - -0.0319531274, -0.0382776572, -0.0447806821, -0.0514804176, - -0.0583705326, -0.0654409853, -0.0726943300, -0.0801372934, - -0.0877547536, -0.0955533352, -0.1035329531, -0.1116826931, - -0.1200077984, -0.1285002850, -0.1371551761, -0.1459766491, - -0.1549607071, -0.1640958855, -0.1733808172, -0.1828172548, - -0.1923966745, -0.2021250176, -0.2119735853, -0.2219652696, - -0.2320690870, -0.2423016884, -0.2526480309, -0.2631053299, - -0.2736634040, -0.2843214189, -0.2950716717, -0.3059098575, - -0.3168278913, -0.3278113727, -0.3388722693, -0.3499914122, - 0.3611589903, 0.3723795546, 0.3836350013, 0.3949211761, - 0.4062317676, 0.4175696896, 0.4289119920, 0.4402553754, - 0.4515996535, 0.4629308085, 0.4742453214, 0.4855253091, - 0.4967708254, 0.5079817500, 0.5191234970, 0.5302240895, - 0.5412553448, 0.5522051258, 0.5630789140, 0.5738524131, - 0.5845403235, 0.5951123086, 0.6055783538, 0.6159109932, - 0.6261242695, 0.6361980107, 0.6461269695, 0.6559016302, - 0.6655139880, 0.6749663190, 0.6842353293, 0.6933282376, - 0.7022388719, 0.7109410426, 0.7194462634, 0.7277448900, - 0.7358211758, 0.7436827863, 0.7513137456, 0.7587080760, - 0.7658674865, 0.7727780881, 0.7794287519, 0.7858353120, - 0.7919735841, 0.7978466413, 0.8034485751, 0.8087695004, - 0.8138191270, 0.8185776004, 0.8230419890, 0.8272275347, - 0.8311038457, 0.8346937361, 0.8379717337, 0.8409541392, - 0.8436238281, 0.8459818469, 0.8480315777, 0.8497805198, - 0.8511971524, 0.8523047035, 0.8531020949, 0.8535720573, - 0.8537385600, -}; - -static av_cold void aacsbr_tableinit(void) -{ - int n; - for (n = 1; n < 320; n++) - sbr_qmf_window_us[320 + n] = sbr_qmf_window_us[320 - n]; - sbr_qmf_window_us[384] = -sbr_qmf_window_us[384]; - sbr_qmf_window_us[512] = -sbr_qmf_window_us[512]; - - for (n = 0; n < 320; n++) - sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n]; -} #endif /* CONFIG_HARDCODED_TABLES */ #endif /* AVCODEC_AACSBR_TABLEGEN_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aacsbr_template.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aacsbr_template.c 2015-07-23 17:20:03.000000000 +0000 @@ -0,0 +1,1535 @@ +/* + * AAC Spectral Band Replication decoding functions + * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) + * Copyright (c) 2009-2010 Alex Converse + * + * Fixed point code + * Copyright (c) 2013 + * MIPS Technologies, Inc., California. + * + * 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 + */ + +/** + * @file + * AAC Spectral Band Replication decoding functions + * @author Robert Swain ( rob opendot cl ) + * @author Stanislav Ocovaj ( stanislav.ocovaj@imgtec.com ) + * @author Zoran Basaric ( zoran.basaric@imgtec.com ) + */ + +av_cold void AAC_RENAME(ff_aac_sbr_init)(void) +{ + static const struct { + const void *sbr_codes, *sbr_bits; + const unsigned int table_size, elem_size; + } sbr_tmp[] = { + SBR_VLC_ROW(t_huffman_env_1_5dB), + SBR_VLC_ROW(f_huffman_env_1_5dB), + SBR_VLC_ROW(t_huffman_env_bal_1_5dB), + SBR_VLC_ROW(f_huffman_env_bal_1_5dB), + SBR_VLC_ROW(t_huffman_env_3_0dB), + SBR_VLC_ROW(f_huffman_env_3_0dB), + SBR_VLC_ROW(t_huffman_env_bal_3_0dB), + SBR_VLC_ROW(f_huffman_env_bal_3_0dB), + SBR_VLC_ROW(t_huffman_noise_3_0dB), + SBR_VLC_ROW(t_huffman_noise_bal_3_0dB), + }; + + // SBR VLC table initialization + SBR_INIT_VLC_STATIC(0, 1098); + SBR_INIT_VLC_STATIC(1, 1092); + SBR_INIT_VLC_STATIC(2, 768); + SBR_INIT_VLC_STATIC(3, 1026); + SBR_INIT_VLC_STATIC(4, 1058); + SBR_INIT_VLC_STATIC(5, 1052); + SBR_INIT_VLC_STATIC(6, 544); + SBR_INIT_VLC_STATIC(7, 544); + SBR_INIT_VLC_STATIC(8, 592); + SBR_INIT_VLC_STATIC(9, 512); + + aacsbr_tableinit(); + + AAC_RENAME(ff_ps_init)(); +} + +/** Places SBR in pure upsampling mode. */ +static void sbr_turnoff(SpectralBandReplication *sbr) { + sbr->start = 0; + // Init defults used in pure upsampling mode + sbr->kx[1] = 32; //Typo in spec, kx' inits to 32 + sbr->m[1] = 0; + // Reset values for first SBR header + sbr->data[0].e_a[1] = sbr->data[1].e_a[1] = -1; + memset(&sbr->spectrum_params, -1, sizeof(SpectrumParameters)); +} + +av_cold void AAC_RENAME(ff_aac_sbr_ctx_init)(AACContext *ac, SpectralBandReplication *sbr) +{ + if(sbr->mdct.mdct_bits) + return; + sbr->kx[0] = sbr->kx[1]; + sbr_turnoff(sbr); + sbr->data[0].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); + sbr->data[1].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); + /* SBR requires samples to be scaled to +/-32768.0 to work correctly. + * mdct scale factors are adjusted to scale up from +/-1.0 at analysis + * and scale back down at synthesis. */ + AAC_RENAME_32(ff_mdct_init)(&sbr->mdct, 7, 1, 1.0 / (64 * 32768.0)); + AAC_RENAME_32(ff_mdct_init)(&sbr->mdct_ana, 7, 1, -2.0 * 32768.0); + AAC_RENAME(ff_ps_ctx_init)(&sbr->ps); + AAC_RENAME(ff_sbrdsp_init)(&sbr->dsp); + aacsbr_func_ptr_init(&sbr->c); +} + +av_cold void AAC_RENAME(ff_aac_sbr_ctx_close)(SpectralBandReplication *sbr) +{ + AAC_RENAME_32(ff_mdct_end)(&sbr->mdct); + AAC_RENAME_32(ff_mdct_end)(&sbr->mdct_ana); +} + +static int qsort_comparison_function_int16(const void *a, const void *b) +{ + return *(const int16_t *)a - *(const int16_t *)b; +} + +static inline int in_table_int16(const int16_t *table, int last_el, int16_t needle) +{ + int i; + for (i = 0; i <= last_el; i++) + if (table[i] == needle) + return 1; + return 0; +} + +/// Limiter Frequency Band Table (14496-3 sp04 p198) +static void sbr_make_f_tablelim(SpectralBandReplication *sbr) +{ + int k; + if (sbr->bs_limiter_bands > 0) { + static const INTFLOAT bands_warped[3] = { Q23(1.32715174233856803909f), //2^(0.49/1.2) + Q23(1.18509277094158210129f), //2^(0.49/2) + Q23(1.11987160404675912501f) }; //2^(0.49/3) + const INTFLOAT lim_bands_per_octave_warped = bands_warped[sbr->bs_limiter_bands - 1]; + int16_t patch_borders[7]; + uint16_t *in = sbr->f_tablelim + 1, *out = sbr->f_tablelim; + + patch_borders[0] = sbr->kx[1]; + for (k = 1; k <= sbr->num_patches; k++) + patch_borders[k] = patch_borders[k-1] + sbr->patch_num_subbands[k-1]; + + memcpy(sbr->f_tablelim, sbr->f_tablelow, + (sbr->n[0] + 1) * sizeof(sbr->f_tablelow[0])); + if (sbr->num_patches > 1) + memcpy(sbr->f_tablelim + sbr->n[0] + 1, patch_borders + 1, + (sbr->num_patches - 1) * sizeof(patch_borders[0])); + + qsort(sbr->f_tablelim, sbr->num_patches + sbr->n[0], + sizeof(sbr->f_tablelim[0]), + qsort_comparison_function_int16); + + sbr->n_lim = sbr->n[0] + sbr->num_patches - 1; + while (out < sbr->f_tablelim + sbr->n_lim) { +#if USE_FIXED + if ((*in << 23) >= *out * lim_bands_per_octave_warped) { +#else + if (*in >= *out * lim_bands_per_octave_warped) { +#endif /* USE_FIXED */ + *++out = *in++; + } else if (*in == *out || + !in_table_int16(patch_borders, sbr->num_patches, *in)) { + in++; + sbr->n_lim--; + } else if (!in_table_int16(patch_borders, sbr->num_patches, *out)) { + *out = *in++; + sbr->n_lim--; + } else { + *++out = *in++; + } + } + } else { + sbr->f_tablelim[0] = sbr->f_tablelow[0]; + sbr->f_tablelim[1] = sbr->f_tablelow[sbr->n[0]]; + sbr->n_lim = 1; + } +} + +static unsigned int read_sbr_header(SpectralBandReplication *sbr, GetBitContext *gb) +{ + unsigned int cnt = get_bits_count(gb); + uint8_t bs_header_extra_1; + uint8_t bs_header_extra_2; + int old_bs_limiter_bands = sbr->bs_limiter_bands; + SpectrumParameters old_spectrum_params; + + sbr->start = 1; + + // Save last spectrum parameters variables to compare to new ones + memcpy(&old_spectrum_params, &sbr->spectrum_params, sizeof(SpectrumParameters)); + + sbr->bs_amp_res_header = get_bits1(gb); + sbr->spectrum_params.bs_start_freq = get_bits(gb, 4); + sbr->spectrum_params.bs_stop_freq = get_bits(gb, 4); + sbr->spectrum_params.bs_xover_band = get_bits(gb, 3); + skip_bits(gb, 2); // bs_reserved + + bs_header_extra_1 = get_bits1(gb); + bs_header_extra_2 = get_bits1(gb); + + if (bs_header_extra_1) { + sbr->spectrum_params.bs_freq_scale = get_bits(gb, 2); + sbr->spectrum_params.bs_alter_scale = get_bits1(gb); + sbr->spectrum_params.bs_noise_bands = get_bits(gb, 2); + } else { + sbr->spectrum_params.bs_freq_scale = 2; + sbr->spectrum_params.bs_alter_scale = 1; + sbr->spectrum_params.bs_noise_bands = 2; + } + + // Check if spectrum parameters changed + if (memcmp(&old_spectrum_params, &sbr->spectrum_params, sizeof(SpectrumParameters))) + sbr->reset = 1; + + if (bs_header_extra_2) { + sbr->bs_limiter_bands = get_bits(gb, 2); + sbr->bs_limiter_gains = get_bits(gb, 2); + sbr->bs_interpol_freq = get_bits1(gb); + sbr->bs_smoothing_mode = get_bits1(gb); + } else { + sbr->bs_limiter_bands = 2; + sbr->bs_limiter_gains = 2; + sbr->bs_interpol_freq = 1; + sbr->bs_smoothing_mode = 1; + } + + if (sbr->bs_limiter_bands != old_bs_limiter_bands && !sbr->reset) + sbr_make_f_tablelim(sbr); + + return get_bits_count(gb) - cnt; +} + +static int array_min_int16(const int16_t *array, int nel) +{ + int i, min = array[0]; + for (i = 1; i < nel; i++) + min = FFMIN(array[i], min); + return min; +} + +static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band) +{ + // Requirements (14496-3 sp04 p205) + if (n_master <= 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master); + return -1; + } + if (bs_xover_band >= n_master) { + av_log(avctx, AV_LOG_ERROR, + "Invalid bitstream, crossover band index beyond array bounds: %d\n", + bs_xover_band); + return -1; + } + return 0; +} + +/// Master Frequency Band Table (14496-3 sp04 p194) +static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, + SpectrumParameters *spectrum) +{ + unsigned int temp, max_qmf_subbands = 0; + unsigned int start_min, stop_min; + int k; + const int8_t *sbr_offset_ptr; + int16_t stop_dk[13]; + + if (sbr->sample_rate < 32000) { + temp = 3000; + } else if (sbr->sample_rate < 64000) { + temp = 4000; + } else + temp = 5000; + + switch (sbr->sample_rate) { + case 16000: + sbr_offset_ptr = sbr_offset[0]; + break; + case 22050: + sbr_offset_ptr = sbr_offset[1]; + break; + case 24000: + sbr_offset_ptr = sbr_offset[2]; + break; + case 32000: + sbr_offset_ptr = sbr_offset[3]; + break; + case 44100: case 48000: case 64000: + sbr_offset_ptr = sbr_offset[4]; + break; + case 88200: case 96000: case 128000: case 176400: case 192000: + sbr_offset_ptr = sbr_offset[5]; + break; + default: + av_log(ac->avctx, AV_LOG_ERROR, + "Unsupported sample rate for SBR: %d\n", sbr->sample_rate); + return -1; + } + + start_min = ((temp << 7) + (sbr->sample_rate >> 1)) / sbr->sample_rate; + stop_min = ((temp << 8) + (sbr->sample_rate >> 1)) / sbr->sample_rate; + + sbr->k[0] = start_min + sbr_offset_ptr[spectrum->bs_start_freq]; + + if (spectrum->bs_stop_freq < 14) { + sbr->k[2] = stop_min; + make_bands(stop_dk, stop_min, 64, 13); + qsort(stop_dk, 13, sizeof(stop_dk[0]), qsort_comparison_function_int16); + for (k = 0; k < spectrum->bs_stop_freq; k++) + sbr->k[2] += stop_dk[k]; + } else if (spectrum->bs_stop_freq == 14) { + sbr->k[2] = 2*sbr->k[0]; + } else if (spectrum->bs_stop_freq == 15) { + sbr->k[2] = 3*sbr->k[0]; + } else { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid bs_stop_freq: %d\n", spectrum->bs_stop_freq); + return -1; + } + sbr->k[2] = FFMIN(64, sbr->k[2]); + + // Requirements (14496-3 sp04 p205) + if (sbr->sample_rate <= 32000) { + max_qmf_subbands = 48; + } else if (sbr->sample_rate == 44100) { + max_qmf_subbands = 35; + } else if (sbr->sample_rate >= 48000) + max_qmf_subbands = 32; + else + av_assert0(0); + + if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid bitstream, too many QMF subbands: %d\n", sbr->k[2] - sbr->k[0]); + return -1; + } + + if (!spectrum->bs_freq_scale) { + int dk, k2diff; + + dk = spectrum->bs_alter_scale + 1; + sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1; + if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) + return -1; + + for (k = 1; k <= sbr->n_master; k++) + sbr->f_master[k] = dk; + + k2diff = sbr->k[2] - sbr->k[0] - sbr->n_master * dk; + if (k2diff < 0) { + sbr->f_master[1]--; + sbr->f_master[2]-= (k2diff < -1); + } else if (k2diff) { + sbr->f_master[sbr->n_master]++; + } + + sbr->f_master[0] = sbr->k[0]; + for (k = 1; k <= sbr->n_master; k++) + sbr->f_master[k] += sbr->f_master[k - 1]; + + } else { + int half_bands = 7 - spectrum->bs_freq_scale; // bs_freq_scale = {1,2,3} + int two_regions, num_bands_0; + int vdk0_max, vdk1_min; + int16_t vk0[49]; +#if USE_FIXED + int tmp, nz = 0; +#endif /* USE_FIXED */ + + if (49 * sbr->k[2] > 110 * sbr->k[0]) { + two_regions = 1; + sbr->k[1] = 2 * sbr->k[0]; + } else { + two_regions = 0; + sbr->k[1] = sbr->k[2]; + } + +#if USE_FIXED + tmp = (sbr->k[1] << 23) / sbr->k[0]; + while (tmp < 0x40000000) { + tmp <<= 1; + nz++; + } + tmp = fixed_log(tmp - 0x80000000); + tmp = (int)(((int64_t)tmp * CONST_RECIP_LN2 + 0x20000000) >> 30); + tmp = (((tmp + 0x80) >> 8) + ((8 - nz) << 23)) * half_bands; + num_bands_0 = ((tmp + 0x400000) >> 23) * 2; +#else + num_bands_0 = lrintf(half_bands * log2f(sbr->k[1] / (float)sbr->k[0])) * 2; +#endif /* USE_FIXED */ + + if (num_bands_0 <= 0) { // Requirements (14496-3 sp04 p205) + av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0); + return -1; + } + + vk0[0] = 0; + + make_bands(vk0+1, sbr->k[0], sbr->k[1], num_bands_0); + + qsort(vk0 + 1, num_bands_0, sizeof(vk0[1]), qsort_comparison_function_int16); + vdk0_max = vk0[num_bands_0]; + + vk0[0] = sbr->k[0]; + for (k = 1; k <= num_bands_0; k++) { + if (vk0[k] <= 0) { // Requirements (14496-3 sp04 p205) + av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]); + return -1; + } + vk0[k] += vk0[k-1]; + } + + if (two_regions) { + int16_t vk1[49]; +#if USE_FIXED + int num_bands_1; + + tmp = (sbr->k[2] << 23) / sbr->k[1]; + nz = 0; + while (tmp < 0x40000000) { + tmp <<= 1; + nz++; + } + tmp = fixed_log(tmp - 0x80000000); + tmp = (int)(((int64_t)tmp * CONST_RECIP_LN2 + 0x20000000) >> 30); + tmp = (((tmp + 0x80) >> 8) + ((8 - nz) << 23)) * half_bands; + if (spectrum->bs_alter_scale) + tmp = (int)(((int64_t)tmp * CONST_076923 + 0x40000000) >> 31); + num_bands_1 = ((tmp + 0x400000) >> 23) * 2; +#else + float invwarp = spectrum->bs_alter_scale ? 0.76923076923076923077f + : 1.0f; // bs_alter_scale = {0,1} + int num_bands_1 = lrintf(half_bands * invwarp * + log2f(sbr->k[2] / (float)sbr->k[1])) * 2; +#endif /* USE_FIXED */ + make_bands(vk1+1, sbr->k[1], sbr->k[2], num_bands_1); + + vdk1_min = array_min_int16(vk1 + 1, num_bands_1); + + if (vdk1_min < vdk0_max) { + int change; + qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16); + change = FFMIN(vdk0_max - vk1[1], (vk1[num_bands_1] - vk1[1]) >> 1); + vk1[1] += change; + vk1[num_bands_1] -= change; + } + + qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16); + + vk1[0] = sbr->k[1]; + for (k = 1; k <= num_bands_1; k++) { + if (vk1[k] <= 0) { // Requirements (14496-3 sp04 p205) + av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]); + return -1; + } + vk1[k] += vk1[k-1]; + } + + sbr->n_master = num_bands_0 + num_bands_1; + if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) + return -1; + memcpy(&sbr->f_master[0], vk0, + (num_bands_0 + 1) * sizeof(sbr->f_master[0])); + memcpy(&sbr->f_master[num_bands_0 + 1], vk1 + 1, + num_bands_1 * sizeof(sbr->f_master[0])); + + } else { + sbr->n_master = num_bands_0; + if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) + return -1; + memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0])); + } + } + + return 0; +} + +/// High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46) +static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr) +{ + int i, k, last_k = -1, last_msb = -1, sb = 0; + int msb = sbr->k[0]; + int usb = sbr->kx[1]; + int goal_sb = ((1000 << 11) + (sbr->sample_rate >> 1)) / sbr->sample_rate; + + sbr->num_patches = 0; + + if (goal_sb < sbr->kx[1] + sbr->m[1]) { + for (k = 0; sbr->f_master[k] < goal_sb; k++) ; + } else + k = sbr->n_master; + + do { + int odd = 0; + if (k == last_k && msb == last_msb) { + av_log(ac->avctx, AV_LOG_ERROR, "patch construction failed\n"); + return AVERROR_INVALIDDATA; + } + last_k = k; + last_msb = msb; + for (i = k; i == k || sb > (sbr->k[0] - 1 + msb - odd); i--) { + sb = sbr->f_master[i]; + odd = (sb + sbr->k[0]) & 1; + } + + // Requirements (14496-3 sp04 p205) sets the maximum number of patches to 5. + // After this check the final number of patches can still be six which is + // illegal however the Coding Technologies decoder check stream has a final + // count of 6 patches + if (sbr->num_patches > 5) { + av_log(ac->avctx, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches); + return -1; + } + + sbr->patch_num_subbands[sbr->num_patches] = FFMAX(sb - usb, 0); + sbr->patch_start_subband[sbr->num_patches] = sbr->k[0] - odd - sbr->patch_num_subbands[sbr->num_patches]; + + if (sbr->patch_num_subbands[sbr->num_patches] > 0) { + usb = sb; + msb = sb; + sbr->num_patches++; + } else + msb = sbr->kx[1]; + + if (sbr->f_master[k] - sb < 3) + k = sbr->n_master; + } while (sb != sbr->kx[1] + sbr->m[1]); + + if (sbr->num_patches > 1 && + sbr->patch_num_subbands[sbr->num_patches - 1] < 3) + sbr->num_patches--; + + return 0; +} + +/// Derived Frequency Band Tables (14496-3 sp04 p197) +static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr) +{ + int k, temp; +#if USE_FIXED + int nz = 0; +#endif /* USE_FIXED */ + + sbr->n[1] = sbr->n_master - sbr->spectrum_params.bs_xover_band; + sbr->n[0] = (sbr->n[1] + 1) >> 1; + + memcpy(sbr->f_tablehigh, &sbr->f_master[sbr->spectrum_params.bs_xover_band], + (sbr->n[1] + 1) * sizeof(sbr->f_master[0])); + sbr->m[1] = sbr->f_tablehigh[sbr->n[1]] - sbr->f_tablehigh[0]; + sbr->kx[1] = sbr->f_tablehigh[0]; + + // Requirements (14496-3 sp04 p205) + if (sbr->kx[1] + sbr->m[1] > 64) { + av_log(ac->avctx, AV_LOG_ERROR, + "Stop frequency border too high: %d\n", sbr->kx[1] + sbr->m[1]); + return -1; + } + if (sbr->kx[1] > 32) { + av_log(ac->avctx, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]); + return -1; + } + + sbr->f_tablelow[0] = sbr->f_tablehigh[0]; + temp = sbr->n[1] & 1; + for (k = 1; k <= sbr->n[0]; k++) + sbr->f_tablelow[k] = sbr->f_tablehigh[2 * k - temp]; +#if USE_FIXED + temp = (sbr->k[2] << 23) / sbr->kx[1]; + while (temp < 0x40000000) { + temp <<= 1; + nz++; + } + temp = fixed_log(temp - 0x80000000); + temp = (int)(((int64_t)temp * CONST_RECIP_LN2 + 0x20000000) >> 30); + temp = (((temp + 0x80) >> 8) + ((8 - nz) << 23)) * sbr->spectrum_params.bs_noise_bands; + + sbr->n_q = (temp + 0x400000) >> 23; + if (sbr->n_q < 1) + sbr->n_q = 1; +#else + sbr->n_q = FFMAX(1, lrintf(sbr->spectrum_params.bs_noise_bands * + log2f(sbr->k[2] / (float)sbr->kx[1]))); // 0 <= bs_noise_bands <= 3 +#endif /* USE_FIXED */ + + if (sbr->n_q > 5) { + av_log(ac->avctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q); + return -1; + } + + sbr->f_tablenoise[0] = sbr->f_tablelow[0]; + temp = 0; + for (k = 1; k <= sbr->n_q; k++) { + temp += (sbr->n[0] - temp) / (sbr->n_q + 1 - k); + sbr->f_tablenoise[k] = sbr->f_tablelow[temp]; + } + + if (sbr_hf_calc_npatches(ac, sbr) < 0) + return -1; + + sbr_make_f_tablelim(sbr); + + sbr->data[0].f_indexnoise = 0; + sbr->data[1].f_indexnoise = 0; + + return 0; +} + +static av_always_inline void get_bits1_vector(GetBitContext *gb, uint8_t *vec, + int elements) +{ + int i; + for (i = 0; i < elements; i++) { + vec[i] = get_bits1(gb); + } +} + +/** ceil(log2(index+1)) */ +static const int8_t ceil_log2[] = { + 0, 1, 2, 2, 3, 3, +}; + +static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, + GetBitContext *gb, SBRData *ch_data) +{ + int i; + int bs_pointer = 0; + // frameLengthFlag ? 15 : 16; 960 sample length frames unsupported; this value is numTimeSlots + int abs_bord_trail = 16; + int num_rel_lead, num_rel_trail; + unsigned bs_num_env_old = ch_data->bs_num_env; + + ch_data->bs_freq_res[0] = ch_data->bs_freq_res[ch_data->bs_num_env]; + ch_data->bs_amp_res = sbr->bs_amp_res_header; + ch_data->t_env_num_env_old = ch_data->t_env[bs_num_env_old]; + + switch (ch_data->bs_frame_class = get_bits(gb, 2)) { + case FIXFIX: + ch_data->bs_num_env = 1 << get_bits(gb, 2); + num_rel_lead = ch_data->bs_num_env - 1; + if (ch_data->bs_num_env == 1) + ch_data->bs_amp_res = 0; + + if (ch_data->bs_num_env > 4) { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n", + ch_data->bs_num_env); + return -1; + } + + ch_data->t_env[0] = 0; + ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; + + abs_bord_trail = (abs_bord_trail + (ch_data->bs_num_env >> 1)) / + ch_data->bs_num_env; + for (i = 0; i < num_rel_lead; i++) + ch_data->t_env[i + 1] = ch_data->t_env[i] + abs_bord_trail; + + ch_data->bs_freq_res[1] = get_bits1(gb); + for (i = 1; i < ch_data->bs_num_env; i++) + ch_data->bs_freq_res[i + 1] = ch_data->bs_freq_res[1]; + break; + case FIXVAR: + abs_bord_trail += get_bits(gb, 2); + num_rel_trail = get_bits(gb, 2); + ch_data->bs_num_env = num_rel_trail + 1; + ch_data->t_env[0] = 0; + ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; + + for (i = 0; i < num_rel_trail; i++) + ch_data->t_env[ch_data->bs_num_env - 1 - i] = + ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2; + + bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); + + for (i = 0; i < ch_data->bs_num_env; i++) + ch_data->bs_freq_res[ch_data->bs_num_env - i] = get_bits1(gb); + break; + case VARFIX: + ch_data->t_env[0] = get_bits(gb, 2); + num_rel_lead = get_bits(gb, 2); + ch_data->bs_num_env = num_rel_lead + 1; + ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; + + for (i = 0; i < num_rel_lead; i++) + ch_data->t_env[i + 1] = ch_data->t_env[i] + 2 * get_bits(gb, 2) + 2; + + bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); + + get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env); + break; + case VARVAR: + ch_data->t_env[0] = get_bits(gb, 2); + abs_bord_trail += get_bits(gb, 2); + num_rel_lead = get_bits(gb, 2); + num_rel_trail = get_bits(gb, 2); + ch_data->bs_num_env = num_rel_lead + num_rel_trail + 1; + + if (ch_data->bs_num_env > 5) { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n", + ch_data->bs_num_env); + return -1; + } + + ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail; + + for (i = 0; i < num_rel_lead; i++) + ch_data->t_env[i + 1] = ch_data->t_env[i] + 2 * get_bits(gb, 2) + 2; + for (i = 0; i < num_rel_trail; i++) + ch_data->t_env[ch_data->bs_num_env - 1 - i] = + ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2; + + bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]); + + get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env); + break; + } + + av_assert0(bs_pointer >= 0); + if (bs_pointer > ch_data->bs_num_env + 1) { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n", + bs_pointer); + return -1; + } + + for (i = 1; i <= ch_data->bs_num_env; i++) { + if (ch_data->t_env[i-1] > ch_data->t_env[i]) { + av_log(ac->avctx, AV_LOG_ERROR, "Non monotone time borders\n"); + return -1; + } + } + + ch_data->bs_num_noise = (ch_data->bs_num_env > 1) + 1; + + ch_data->t_q[0] = ch_data->t_env[0]; + ch_data->t_q[ch_data->bs_num_noise] = ch_data->t_env[ch_data->bs_num_env]; + if (ch_data->bs_num_noise > 1) { + int idx; + if (ch_data->bs_frame_class == FIXFIX) { + idx = ch_data->bs_num_env >> 1; + } else if (ch_data->bs_frame_class & 1) { // FIXVAR or VARVAR + idx = ch_data->bs_num_env - FFMAX(bs_pointer - 1, 1); + } else { // VARFIX + if (!bs_pointer) + idx = 1; + else if (bs_pointer == 1) + idx = ch_data->bs_num_env - 1; + else // bs_pointer > 1 + idx = bs_pointer - 1; + } + ch_data->t_q[1] = ch_data->t_env[idx]; + } + + ch_data->e_a[0] = -(ch_data->e_a[1] != bs_num_env_old); // l_APrev + ch_data->e_a[1] = -1; + if ((ch_data->bs_frame_class & 1) && bs_pointer) { // FIXVAR or VARVAR and bs_pointer != 0 + ch_data->e_a[1] = ch_data->bs_num_env + 1 - bs_pointer; + } else if ((ch_data->bs_frame_class == 2) && (bs_pointer > 1)) // VARFIX and bs_pointer > 1 + ch_data->e_a[1] = bs_pointer - 1; + + return 0; +} + +static void copy_sbr_grid(SBRData *dst, const SBRData *src) { + //These variables are saved from the previous frame rather than copied + dst->bs_freq_res[0] = dst->bs_freq_res[dst->bs_num_env]; + dst->t_env_num_env_old = dst->t_env[dst->bs_num_env]; + dst->e_a[0] = -(dst->e_a[1] != dst->bs_num_env); + + //These variables are read from the bitstream and therefore copied + memcpy(dst->bs_freq_res+1, src->bs_freq_res+1, sizeof(dst->bs_freq_res)-sizeof(*dst->bs_freq_res)); + memcpy(dst->t_env, src->t_env, sizeof(dst->t_env)); + memcpy(dst->t_q, src->t_q, sizeof(dst->t_q)); + dst->bs_num_env = src->bs_num_env; + dst->bs_amp_res = src->bs_amp_res; + dst->bs_num_noise = src->bs_num_noise; + dst->bs_frame_class = src->bs_frame_class; + dst->e_a[1] = src->e_a[1]; +} + +/// Read how the envelope and noise floor data is delta coded +static void read_sbr_dtdf(SpectralBandReplication *sbr, GetBitContext *gb, + SBRData *ch_data) +{ + get_bits1_vector(gb, ch_data->bs_df_env, ch_data->bs_num_env); + get_bits1_vector(gb, ch_data->bs_df_noise, ch_data->bs_num_noise); +} + +/// Read inverse filtering data +static void read_sbr_invf(SpectralBandReplication *sbr, GetBitContext *gb, + SBRData *ch_data) +{ + int i; + + memcpy(ch_data->bs_invf_mode[1], ch_data->bs_invf_mode[0], 5 * sizeof(uint8_t)); + for (i = 0; i < sbr->n_q; i++) + ch_data->bs_invf_mode[0][i] = get_bits(gb, 2); +} + +static void read_sbr_envelope(SpectralBandReplication *sbr, GetBitContext *gb, + SBRData *ch_data, int ch) +{ + int bits; + int i, j, k; + VLC_TYPE (*t_huff)[2], (*f_huff)[2]; + int t_lav, f_lav; + const int delta = (ch == 1 && sbr->bs_coupling == 1) + 1; + const int odd = sbr->n[1] & 1; + + if (sbr->bs_coupling && ch) { + if (ch_data->bs_amp_res) { + bits = 5; + t_huff = vlc_sbr[T_HUFFMAN_ENV_BAL_3_0DB].table; + t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_BAL_3_0DB]; + f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_3_0DB].table; + f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_3_0DB]; + } else { + bits = 6; + t_huff = vlc_sbr[T_HUFFMAN_ENV_BAL_1_5DB].table; + t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_BAL_1_5DB]; + f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_1_5DB].table; + f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_1_5DB]; + } + } else { + if (ch_data->bs_amp_res) { + bits = 6; + t_huff = vlc_sbr[T_HUFFMAN_ENV_3_0DB].table; + t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_3_0DB]; + f_huff = vlc_sbr[F_HUFFMAN_ENV_3_0DB].table; + f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB]; + } else { + bits = 7; + t_huff = vlc_sbr[T_HUFFMAN_ENV_1_5DB].table; + t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_1_5DB]; + f_huff = vlc_sbr[F_HUFFMAN_ENV_1_5DB].table; + f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_1_5DB]; + } + } + +#if USE_FIXED + for (i = 0; i < ch_data->bs_num_env; i++) { + if (ch_data->bs_df_env[i]) { + // bs_freq_res[0] == bs_freq_res[bs_num_env] from prev frame + if (ch_data->bs_freq_res[i + 1] == ch_data->bs_freq_res[i]) { + for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) + ch_data->env_facs[i + 1][j].mant = ch_data->env_facs[i][j].mant + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); + } else if (ch_data->bs_freq_res[i + 1]) { + for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { + k = (j + odd) >> 1; // find k such that f_tablelow[k] <= f_tablehigh[j] < f_tablelow[k + 1] + ch_data->env_facs[i + 1][j].mant = ch_data->env_facs[i][k].mant + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); + } + } else { + for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { + k = j ? 2*j - odd : 0; // find k such that f_tablehigh[k] == f_tablelow[j] + ch_data->env_facs[i + 1][j].mant = ch_data->env_facs[i][k].mant + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); + } + } + } else { + ch_data->env_facs[i + 1][0].mant = delta * get_bits(gb, bits); // bs_env_start_value_balance + for (j = 1; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) + ch_data->env_facs[i + 1][j].mant = ch_data->env_facs[i + 1][j - 1].mant + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); + } + } +#else + for (i = 0; i < ch_data->bs_num_env; i++) { + if (ch_data->bs_df_env[i]) { + // bs_freq_res[0] == bs_freq_res[bs_num_env] from prev frame + if (ch_data->bs_freq_res[i + 1] == ch_data->bs_freq_res[i]) { + for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) + ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); + } else if (ch_data->bs_freq_res[i + 1]) { + for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { + k = (j + odd) >> 1; // find k such that f_tablelow[k] <= f_tablehigh[j] < f_tablelow[k + 1] + ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); + } + } else { + for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) { + k = j ? 2*j - odd : 0; // find k such that f_tablehigh[k] == f_tablelow[j] + ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav); + } + } + } else { + ch_data->env_facs[i + 1][0] = delta * get_bits(gb, bits); // bs_env_start_value_balance + for (j = 1; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) + ch_data->env_facs[i + 1][j] = ch_data->env_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); + } + } +#endif /* USE_FIXED */ + + //assign 0th elements of env_facs from last elements + memcpy(ch_data->env_facs[0], ch_data->env_facs[ch_data->bs_num_env], + sizeof(ch_data->env_facs[0])); +} + +static void read_sbr_noise(SpectralBandReplication *sbr, GetBitContext *gb, + SBRData *ch_data, int ch) +{ + int i, j; + VLC_TYPE (*t_huff)[2], (*f_huff)[2]; + int t_lav, f_lav; + int delta = (ch == 1 && sbr->bs_coupling == 1) + 1; + + if (sbr->bs_coupling && ch) { + t_huff = vlc_sbr[T_HUFFMAN_NOISE_BAL_3_0DB].table; + t_lav = vlc_sbr_lav[T_HUFFMAN_NOISE_BAL_3_0DB]; + f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_3_0DB].table; + f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_3_0DB]; + } else { + t_huff = vlc_sbr[T_HUFFMAN_NOISE_3_0DB].table; + t_lav = vlc_sbr_lav[T_HUFFMAN_NOISE_3_0DB]; + f_huff = vlc_sbr[F_HUFFMAN_ENV_3_0DB].table; + f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB]; + } + +#if USE_FIXED + for (i = 0; i < ch_data->bs_num_noise; i++) { + if (ch_data->bs_df_noise[i]) { + for (j = 0; j < sbr->n_q; j++) + ch_data->noise_facs[i + 1][j].mant = ch_data->noise_facs[i][j].mant + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav); + } else { + ch_data->noise_facs[i + 1][0].mant = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level + for (j = 1; j < sbr->n_q; j++) + ch_data->noise_facs[i + 1][j].mant = ch_data->noise_facs[i + 1][j - 1].mant + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); + } + } +#else + for (i = 0; i < ch_data->bs_num_noise; i++) { + if (ch_data->bs_df_noise[i]) { + for (j = 0; j < sbr->n_q; j++) + ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav); + } else { + ch_data->noise_facs[i + 1][0] = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level + for (j = 1; j < sbr->n_q; j++) + ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav); + } + } +#endif /* USE_FIXED */ + + //assign 0th elements of noise_facs from last elements + memcpy(ch_data->noise_facs[0], ch_data->noise_facs[ch_data->bs_num_noise], + sizeof(ch_data->noise_facs[0])); +} + +static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, + GetBitContext *gb, + int bs_extension_id, int *num_bits_left) +{ + switch (bs_extension_id) { + case EXTENSION_ID_PS: + if (!ac->oc[1].m4ac.ps) { + av_log(ac->avctx, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n"); + skip_bits_long(gb, *num_bits_left); // bs_fill_bits + *num_bits_left = 0; + } else { +#if 1 + *num_bits_left -= AAC_RENAME(ff_ps_read_data)(ac->avctx, gb, &sbr->ps, *num_bits_left); + ac->avctx->profile = FF_PROFILE_AAC_HE_V2; +#else + avpriv_report_missing_feature(ac->avctx, "Parametric Stereo"); + skip_bits_long(gb, *num_bits_left); // bs_fill_bits + *num_bits_left = 0; +#endif + } + break; + default: + // some files contain 0-padding + if (bs_extension_id || *num_bits_left > 16 || show_bits(gb, *num_bits_left)) + avpriv_request_sample(ac->avctx, "Reserved SBR extensions"); + skip_bits_long(gb, *num_bits_left); // bs_fill_bits + *num_bits_left = 0; + break; + } +} + +static int read_sbr_single_channel_element(AACContext *ac, + SpectralBandReplication *sbr, + GetBitContext *gb) +{ + if (get_bits1(gb)) // bs_data_extra + skip_bits(gb, 4); // bs_reserved + + if (read_sbr_grid(ac, sbr, gb, &sbr->data[0])) + return -1; + read_sbr_dtdf(sbr, gb, &sbr->data[0]); + read_sbr_invf(sbr, gb, &sbr->data[0]); + read_sbr_envelope(sbr, gb, &sbr->data[0], 0); + read_sbr_noise(sbr, gb, &sbr->data[0], 0); + + if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb))) + get_bits1_vector(gb, sbr->data[0].bs_add_harmonic, sbr->n[1]); + + return 0; +} + +static int read_sbr_channel_pair_element(AACContext *ac, + SpectralBandReplication *sbr, + GetBitContext *gb) +{ + if (get_bits1(gb)) // bs_data_extra + skip_bits(gb, 8); // bs_reserved + + if ((sbr->bs_coupling = get_bits1(gb))) { + if (read_sbr_grid(ac, sbr, gb, &sbr->data[0])) + return -1; + copy_sbr_grid(&sbr->data[1], &sbr->data[0]); + read_sbr_dtdf(sbr, gb, &sbr->data[0]); + read_sbr_dtdf(sbr, gb, &sbr->data[1]); + read_sbr_invf(sbr, gb, &sbr->data[0]); + memcpy(sbr->data[1].bs_invf_mode[1], sbr->data[1].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0])); + memcpy(sbr->data[1].bs_invf_mode[0], sbr->data[0].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0])); + read_sbr_envelope(sbr, gb, &sbr->data[0], 0); + read_sbr_noise(sbr, gb, &sbr->data[0], 0); + read_sbr_envelope(sbr, gb, &sbr->data[1], 1); + read_sbr_noise(sbr, gb, &sbr->data[1], 1); + } else { + if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]) || + read_sbr_grid(ac, sbr, gb, &sbr->data[1])) + return -1; + read_sbr_dtdf(sbr, gb, &sbr->data[0]); + read_sbr_dtdf(sbr, gb, &sbr->data[1]); + read_sbr_invf(sbr, gb, &sbr->data[0]); + read_sbr_invf(sbr, gb, &sbr->data[1]); + read_sbr_envelope(sbr, gb, &sbr->data[0], 0); + read_sbr_envelope(sbr, gb, &sbr->data[1], 1); + read_sbr_noise(sbr, gb, &sbr->data[0], 0); + read_sbr_noise(sbr, gb, &sbr->data[1], 1); + } + + if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb))) + get_bits1_vector(gb, sbr->data[0].bs_add_harmonic, sbr->n[1]); + if ((sbr->data[1].bs_add_harmonic_flag = get_bits1(gb))) + get_bits1_vector(gb, sbr->data[1].bs_add_harmonic, sbr->n[1]); + + return 0; +} + +static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, + GetBitContext *gb, int id_aac) +{ + unsigned int cnt = get_bits_count(gb); + + sbr->id_aac = id_aac; + + if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) { + if (read_sbr_single_channel_element(ac, sbr, gb)) { + sbr_turnoff(sbr); + return get_bits_count(gb) - cnt; + } + } else if (id_aac == TYPE_CPE) { + if (read_sbr_channel_pair_element(ac, sbr, gb)) { + sbr_turnoff(sbr); + return get_bits_count(gb) - cnt; + } + } else { + av_log(ac->avctx, AV_LOG_ERROR, + "Invalid bitstream - cannot apply SBR to element type %d\n", id_aac); + sbr_turnoff(sbr); + return get_bits_count(gb) - cnt; + } + if (get_bits1(gb)) { // bs_extended_data + int num_bits_left = get_bits(gb, 4); // bs_extension_size + if (num_bits_left == 15) + num_bits_left += get_bits(gb, 8); // bs_esc_count + + num_bits_left <<= 3; + while (num_bits_left > 7) { + num_bits_left -= 2; + read_sbr_extension(ac, sbr, gb, get_bits(gb, 2), &num_bits_left); // bs_extension_id + } + if (num_bits_left < 0) { + av_log(ac->avctx, AV_LOG_ERROR, "SBR Extension over read.\n"); + } + if (num_bits_left > 0) + skip_bits(gb, num_bits_left); + } + + return get_bits_count(gb) - cnt; +} + +static void sbr_reset(AACContext *ac, SpectralBandReplication *sbr) +{ + int err; + err = sbr_make_f_master(ac, sbr, &sbr->spectrum_params); + if (err >= 0) + err = sbr_make_f_derived(ac, sbr); + if (err < 0) { + av_log(ac->avctx, AV_LOG_ERROR, + "SBR reset failed. Switching SBR to pure upsampling mode.\n"); + sbr_turnoff(sbr); + } +} + +/** + * Decode Spectral Band Replication extension data; reference: table 4.55. + * + * @param crc flag indicating the presence of CRC checksum + * @param cnt length of TYPE_FIL syntactic element in bytes + * + * @return Returns number of bytes consumed from the TYPE_FIL element. + */ +int AAC_RENAME(ff_decode_sbr_extension)(AACContext *ac, SpectralBandReplication *sbr, + GetBitContext *gb_host, int crc, int cnt, int id_aac) +{ + unsigned int num_sbr_bits = 0, num_align_bits; + unsigned bytes_read; + GetBitContext gbc = *gb_host, *gb = &gbc; + skip_bits_long(gb_host, cnt*8 - 4); + + sbr->reset = 0; + + if (!sbr->sample_rate) + sbr->sample_rate = 2 * ac->oc[1].m4ac.sample_rate; //TODO use the nominal sample rate for arbitrary sample rate support + if (!ac->oc[1].m4ac.ext_sample_rate) + ac->oc[1].m4ac.ext_sample_rate = 2 * ac->oc[1].m4ac.sample_rate; + + if (crc) { + skip_bits(gb, 10); // bs_sbr_crc_bits; TODO - implement CRC check + num_sbr_bits += 10; + } + + //Save some state from the previous frame. + sbr->kx[0] = sbr->kx[1]; + sbr->m[0] = sbr->m[1]; + sbr->kx_and_m_pushed = 1; + + num_sbr_bits++; + if (get_bits1(gb)) // bs_header_flag + num_sbr_bits += read_sbr_header(sbr, gb); + + if (sbr->reset) + sbr_reset(ac, sbr); + + if (sbr->start) + num_sbr_bits += read_sbr_data(ac, sbr, gb, id_aac); + + num_align_bits = ((cnt << 3) - 4 - num_sbr_bits) & 7; + bytes_read = ((num_sbr_bits + num_align_bits + 4) >> 3); + + if (bytes_read > cnt) { + av_log(ac->avctx, AV_LOG_ERROR, + "Expected to read %d SBR bytes actually read %d.\n", cnt, bytes_read); + } + return cnt; +} + +/** + * Analysis QMF Bank (14496-3 sp04 p206) + * + * @param x pointer to the beginning of the first sample window + * @param W array of complex-valued samples split into subbands + */ +#ifndef sbr_qmf_analysis +#if USE_FIXED +static void sbr_qmf_analysis(AVFixedDSPContext *dsp, FFTContext *mdct, +#else +static void sbr_qmf_analysis(AVFloatDSPContext *dsp, FFTContext *mdct, +#endif /* USE_FIXED */ + SBRDSPContext *sbrdsp, const INTFLOAT *in, INTFLOAT *x, + INTFLOAT z[320], INTFLOAT W[2][32][32][2], int buf_idx) +{ + int i; + memcpy(x , x+1024, (320-32)*sizeof(x[0])); + memcpy(x+288, in, 1024*sizeof(x[0])); + for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames + // are not supported + dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320); + sbrdsp->sum64x5(z); + sbrdsp->qmf_pre_shuffle(z); + mdct->imdct_half(mdct, z, z+64); + sbrdsp->qmf_post_shuffle(W[buf_idx][i], z); + x += 32; + } +} +#endif + +/** + * Synthesis QMF Bank (14496-3 sp04 p206) and Downsampled Synthesis QMF Bank + * (14496-3 sp04 p206) + */ +#ifndef sbr_qmf_synthesis +static void sbr_qmf_synthesis(FFTContext *mdct, +#if USE_FIXED + SBRDSPContext *sbrdsp, AVFixedDSPContext *dsp, +#else + SBRDSPContext *sbrdsp, AVFloatDSPContext *dsp, +#endif /* USE_FIXED */ + INTFLOAT *out, INTFLOAT X[2][38][64], + INTFLOAT mdct_buf[2][64], + INTFLOAT *v0, int *v_off, const unsigned int div) +{ + int i, n; + const INTFLOAT *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us; + const int step = 128 >> div; + INTFLOAT *v; + for (i = 0; i < 32; i++) { + if (*v_off < step) { + int saved_samples = (1280 - 128) >> div; + memcpy(&v0[SBR_SYNTHESIS_BUF_SIZE - saved_samples], v0, saved_samples * sizeof(INTFLOAT)); + *v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - step; + } else { + *v_off -= step; + } + v = v0 + *v_off; + if (div) { + for (n = 0; n < 32; n++) { + X[0][i][ n] = -X[0][i][n]; + X[0][i][32+n] = X[1][i][31-n]; + } + mdct->imdct_half(mdct, mdct_buf[0], X[0][i]); + sbrdsp->qmf_deint_neg(v, mdct_buf[0]); + } else { + sbrdsp->neg_odd_64(X[1][i]); + mdct->imdct_half(mdct, mdct_buf[0], X[0][i]); + mdct->imdct_half(mdct, mdct_buf[1], X[1][i]); + sbrdsp->qmf_deint_bfly(v, mdct_buf[1], mdct_buf[0]); + } + dsp->vector_fmul (out, v , sbr_qmf_window , 64 >> div); + dsp->vector_fmul_add(out, v + ( 192 >> div), sbr_qmf_window + ( 64 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + ( 256 >> div), sbr_qmf_window + (128 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + ( 448 >> div), sbr_qmf_window + (192 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + ( 512 >> div), sbr_qmf_window + (256 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + ( 704 >> div), sbr_qmf_window + (320 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + ( 768 >> div), sbr_qmf_window + (384 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + ( 960 >> div), sbr_qmf_window + (448 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + (1024 >> div), sbr_qmf_window + (512 >> div), out , 64 >> div); + dsp->vector_fmul_add(out, v + (1216 >> div), sbr_qmf_window + (576 >> div), out , 64 >> div); + out += 64 >> div; + } +} +#endif + +/// Generate the subband filtered lowband +static int sbr_lf_gen(AACContext *ac, SpectralBandReplication *sbr, + INTFLOAT X_low[32][40][2], const INTFLOAT W[2][32][32][2], + int buf_idx) +{ + int i, k; + const int t_HFGen = 8; + const int i_f = 32; + memset(X_low, 0, 32*sizeof(*X_low)); + for (k = 0; k < sbr->kx[1]; k++) { + for (i = t_HFGen; i < i_f + t_HFGen; i++) { + X_low[k][i][0] = W[buf_idx][i - t_HFGen][k][0]; + X_low[k][i][1] = W[buf_idx][i - t_HFGen][k][1]; + } + } + buf_idx = 1-buf_idx; + for (k = 0; k < sbr->kx[0]; k++) { + for (i = 0; i < t_HFGen; i++) { + X_low[k][i][0] = W[buf_idx][i + i_f - t_HFGen][k][0]; + X_low[k][i][1] = W[buf_idx][i + i_f - t_HFGen][k][1]; + } + } + return 0; +} + +/// High Frequency Generator (14496-3 sp04 p215) +static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, + INTFLOAT X_high[64][40][2], const INTFLOAT X_low[32][40][2], + const INTFLOAT (*alpha0)[2], const INTFLOAT (*alpha1)[2], + const INTFLOAT bw_array[5], const uint8_t *t_env, + int bs_num_env) +{ + int j, x; + int g = 0; + int k = sbr->kx[1]; + for (j = 0; j < sbr->num_patches; j++) { + for (x = 0; x < sbr->patch_num_subbands[j]; x++, k++) { + const int p = sbr->patch_start_subband[j] + x; + while (g <= sbr->n_q && k >= sbr->f_tablenoise[g]) + g++; + g--; + + if (g < 0) { + av_log(ac->avctx, AV_LOG_ERROR, + "ERROR : no subband found for frequency %d\n", k); + return -1; + } + + sbr->dsp.hf_gen(X_high[k] + ENVELOPE_ADJUSTMENT_OFFSET, + X_low[p] + ENVELOPE_ADJUSTMENT_OFFSET, + alpha0[p], alpha1[p], bw_array[g], + 2 * t_env[0], 2 * t_env[bs_num_env]); + } + } + if (k < sbr->m[1] + sbr->kx[1]) + memset(X_high + k, 0, (sbr->m[1] + sbr->kx[1] - k) * sizeof(*X_high)); + + return 0; +} + +/// Generate the subband filtered lowband +static int sbr_x_gen(SpectralBandReplication *sbr, INTFLOAT X[2][38][64], + const INTFLOAT Y0[38][64][2], const INTFLOAT Y1[38][64][2], + const INTFLOAT X_low[32][40][2], int ch) +{ + int k, i; + const int i_f = 32; + const int i_Temp = FFMAX(2*sbr->data[ch].t_env_num_env_old - i_f, 0); + memset(X, 0, 2*sizeof(*X)); + for (k = 0; k < sbr->kx[0]; k++) { + for (i = 0; i < i_Temp; i++) { + X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; + X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; + } + } + for (; k < sbr->kx[0] + sbr->m[0]; k++) { + for (i = 0; i < i_Temp; i++) { + X[0][i][k] = Y0[i + i_f][k][0]; + X[1][i][k] = Y0[i + i_f][k][1]; + } + } + + for (k = 0; k < sbr->kx[1]; k++) { + for (i = i_Temp; i < 38; i++) { + X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; + X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; + } + } + for (; k < sbr->kx[1] + sbr->m[1]; k++) { + for (i = i_Temp; i < i_f; i++) { + X[0][i][k] = Y1[i][k][0]; + X[1][i][k] = Y1[i][k][1]; + } + } + return 0; +} + +/** High Frequency Adjustment (14496-3 sp04 p217) and Mapping + * (14496-3 sp04 p217) + */ +static int sbr_mapping(AACContext *ac, SpectralBandReplication *sbr, + SBRData *ch_data, int e_a[2]) +{ + int e, i, m; + + memset(ch_data->s_indexmapped[1], 0, 7*sizeof(ch_data->s_indexmapped[1])); + for (e = 0; e < ch_data->bs_num_env; e++) { + const unsigned int ilim = sbr->n[ch_data->bs_freq_res[e + 1]]; + uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow; + int k; + + if (sbr->kx[1] != table[0]) { + av_log(ac->avctx, AV_LOG_ERROR, "kx != f_table{high,low}[0]. " + "Derived frequency tables were not regenerated.\n"); + sbr_turnoff(sbr); + return AVERROR_BUG; + } + for (i = 0; i < ilim; i++) + for (m = table[i]; m < table[i + 1]; m++) + sbr->e_origmapped[e][m - sbr->kx[1]] = ch_data->env_facs[e+1][i]; + + // ch_data->bs_num_noise > 1 => 2 noise floors + k = (ch_data->bs_num_noise > 1) && (ch_data->t_env[e] >= ch_data->t_q[1]); + for (i = 0; i < sbr->n_q; i++) + for (m = sbr->f_tablenoise[i]; m < sbr->f_tablenoise[i + 1]; m++) + sbr->q_mapped[e][m - sbr->kx[1]] = ch_data->noise_facs[k+1][i]; + + for (i = 0; i < sbr->n[1]; i++) { + if (ch_data->bs_add_harmonic_flag) { + const unsigned int m_midpoint = + (sbr->f_tablehigh[i] + sbr->f_tablehigh[i + 1]) >> 1; + + ch_data->s_indexmapped[e + 1][m_midpoint - sbr->kx[1]] = ch_data->bs_add_harmonic[i] * + (e >= e_a[1] || (ch_data->s_indexmapped[0][m_midpoint - sbr->kx[1]] == 1)); + } + } + + for (i = 0; i < ilim; i++) { + int additional_sinusoid_present = 0; + for (m = table[i]; m < table[i + 1]; m++) { + if (ch_data->s_indexmapped[e + 1][m - sbr->kx[1]]) { + additional_sinusoid_present = 1; + break; + } + } + memset(&sbr->s_mapped[e][table[i] - sbr->kx[1]], additional_sinusoid_present, + (table[i + 1] - table[i]) * sizeof(sbr->s_mapped[e][0])); + } + } + + memcpy(ch_data->s_indexmapped[0], ch_data->s_indexmapped[ch_data->bs_num_env], sizeof(ch_data->s_indexmapped[0])); + return 0; +} + +/// Estimation of current envelope (14496-3 sp04 p218) +static void sbr_env_estimate(AAC_FLOAT (*e_curr)[48], INTFLOAT X_high[64][40][2], + SpectralBandReplication *sbr, SBRData *ch_data) +{ + int e, m; + int kx1 = sbr->kx[1]; + + if (sbr->bs_interpol_freq) { + for (e = 0; e < ch_data->bs_num_env; e++) { +#if USE_FIXED + const SoftFloat recip_env_size = av_int2sf(0x20000000 / (ch_data->t_env[e + 1] - ch_data->t_env[e]), 30); +#else + const float recip_env_size = 0.5f / (ch_data->t_env[e + 1] - ch_data->t_env[e]); +#endif /* USE_FIXED */ + int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; + int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; + + for (m = 0; m < sbr->m[1]; m++) { + AAC_FLOAT sum = sbr->dsp.sum_square(X_high[m+kx1] + ilb, iub - ilb); +#if USE_FIXED + e_curr[e][m] = av_mul_sf(sum, recip_env_size); +#else + e_curr[e][m] = sum * recip_env_size; +#endif /* USE_FIXED */ + } + } + } else { + int k, p; + + for (e = 0; e < ch_data->bs_num_env; e++) { + const int env_size = 2 * (ch_data->t_env[e + 1] - ch_data->t_env[e]); + int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; + int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; + const uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow; + + for (p = 0; p < sbr->n[ch_data->bs_freq_res[e + 1]]; p++) { +#if USE_FIXED + SoftFloat sum = { 0, 0 }; + const SoftFloat den = av_int2sf(0x20000000 / (env_size * (table[p + 1] - table[p])), 29); + for (k = table[p]; k < table[p + 1]; k++) { + sum = av_add_sf(sum, sbr->dsp.sum_square(X_high[k] + ilb, iub - ilb)); + } + sum = av_mul_sf(sum, den); +#else + float sum = 0.0f; + const int den = env_size * (table[p + 1] - table[p]); + + for (k = table[p]; k < table[p + 1]; k++) { + sum += sbr->dsp.sum_square(X_high[k] + ilb, iub - ilb); + } + sum /= den; +#endif /* USE_FIXED */ + for (k = table[p]; k < table[p + 1]; k++) { + e_curr[e][k - kx1] = sum; + } + } + } + } +} + +void AAC_RENAME(ff_sbr_apply)(AACContext *ac, SpectralBandReplication *sbr, int id_aac, + INTFLOAT* L, INTFLOAT* R) +{ + int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate; + int ch; + int nch = (id_aac == TYPE_CPE) ? 2 : 1; + int err; + + if (id_aac != sbr->id_aac) { + av_log(ac->avctx, AV_LOG_ERROR, + "element type mismatch %d != %d\n", id_aac, sbr->id_aac); + sbr_turnoff(sbr); + } + + if (!sbr->kx_and_m_pushed) { + sbr->kx[0] = sbr->kx[1]; + sbr->m[0] = sbr->m[1]; + } else { + sbr->kx_and_m_pushed = 0; + } + + if (sbr->start) { + sbr_dequant(sbr, id_aac); + } + for (ch = 0; ch < nch; ch++) { + /* decode channel */ + sbr_qmf_analysis(ac->fdsp, &sbr->mdct_ana, &sbr->dsp, ch ? R : L, sbr->data[ch].analysis_filterbank_samples, + (INTFLOAT*)sbr->qmf_filter_scratch, + sbr->data[ch].W, sbr->data[ch].Ypos); + sbr->c.sbr_lf_gen(ac, sbr, sbr->X_low, + (const INTFLOAT (*)[32][32][2]) sbr->data[ch].W, + sbr->data[ch].Ypos); + sbr->data[ch].Ypos ^= 1; + if (sbr->start) { + sbr->c.sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1, + (const INTFLOAT (*)[40][2]) sbr->X_low, sbr->k[0]); + sbr_chirp(sbr, &sbr->data[ch]); + av_assert0(sbr->data[ch].bs_num_env > 0); + sbr_hf_gen(ac, sbr, sbr->X_high, + (const INTFLOAT (*)[40][2]) sbr->X_low, + (const INTFLOAT (*)[2]) sbr->alpha0, + (const INTFLOAT (*)[2]) sbr->alpha1, + sbr->data[ch].bw_array, sbr->data[ch].t_env, + sbr->data[ch].bs_num_env); + + // hf_adj + err = sbr_mapping(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a); + if (!err) { + sbr_env_estimate(sbr->e_curr, sbr->X_high, sbr, &sbr->data[ch]); + sbr_gain_calc(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a); + sbr->c.sbr_hf_assemble(sbr->data[ch].Y[sbr->data[ch].Ypos], + (const INTFLOAT (*)[40][2]) sbr->X_high, + sbr, &sbr->data[ch], + sbr->data[ch].e_a); + } + } + + /* synthesis */ + sbr->c.sbr_x_gen(sbr, sbr->X[ch], + (const INTFLOAT (*)[64][2]) sbr->data[ch].Y[1-sbr->data[ch].Ypos], + (const INTFLOAT (*)[64][2]) sbr->data[ch].Y[ sbr->data[ch].Ypos], + (const INTFLOAT (*)[40][2]) sbr->X_low, ch); + } + + if (ac->oc[1].m4ac.ps == 1) { + if (sbr->ps.start) { + AAC_RENAME(ff_ps_apply)(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); + } else { + memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0])); + } + nch = 2; + } + + sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, ac->fdsp, + L, sbr->X[0], sbr->qmf_filter_scratch, + sbr->data[0].synthesis_filterbank_samples, + &sbr->data[0].synthesis_filterbank_samples_offset, + downsampled); + if (nch == 2) + sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, ac->fdsp, + R, sbr->X[1], sbr->qmf_filter_scratch, + sbr->data[1].synthesis_filterbank_samples, + &sbr->data[1].synthesis_filterbank_samples_offset, + downsampled); +} + +static void aacsbr_func_ptr_init(AACSBRContext *c) +{ + c->sbr_lf_gen = sbr_lf_gen; + c->sbr_hf_assemble = sbr_hf_assemble; + c->sbr_x_gen = sbr_x_gen; + c->sbr_hf_inverse_filter = sbr_hf_inverse_filter; + +#if !USE_FIXED + if(ARCH_MIPS) + ff_aacsbr_func_ptr_init_mips(c); +#endif +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aactab.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aactab.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aactab.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aactab.c 2015-07-25 17:20:02.000000000 +0000 @@ -35,6 +35,8 @@ DECLARE_ALIGNED(32, float, ff_aac_kbd_long_1024)[1024]; DECLARE_ALIGNED(32, float, ff_aac_kbd_short_128)[128]; +DECLARE_ALIGNED(32, int, ff_aac_kbd_long_1024_fixed)[1024]; +DECLARE_ALIGNED(32, int, ff_aac_kbd_short_128_fixed)[128]; const uint8_t ff_aac_num_swb_1024[] = { 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40, 40 @@ -1767,6 +1769,490 @@ -0.00111144, -0.00109764, -0.00108377, -0.00106989, }; +/* Q30 representation of ff_aac_eld_window_512 table */ +const DECLARE_ALIGNED(32, int, ff_aac_eld_window_512_fixed)[1920] = { + 0x003783ba, 0x005d04f4, 0x008ae226, 0x00c02021, + 0x00fb1804, 0x013a30a8, 0x017be9e6, 0x01bf296c, + 0x02033204, 0x0247502c, 0x028adab0, 0x02cd9568, + 0x030fa980, 0x03513dc0, 0x03927274, 0x03d363e0, + 0x04142e40, 0x0454edc0, 0x0495bd48, 0x04d6a060, + 0x051786d8, 0x05586548, 0x059935e8, 0x05d9feb0, + 0x061acea0, 0x065bb680, 0x069cc800, 0x06de13f0, + 0x071fa748, 0x07618b80, 0x07a3c7a8, 0x07e66da0, + 0x082999d0, 0x086d6590, 0x08b1e640, 0x08f72850, + 0x093d3120, 0x09840550, 0x09cba880, 0x0a1415f0, + 0x0a5d41b0, 0x0aa720d0, 0x0af1a9a0, 0x0b3cce70, + 0x0b887ec0, 0x0bd4ac10, 0x0c214a70, 0x0c6e5130, + 0x0cbbba50, 0x0d098130, 0x0d57a240, 0x0da61a60, + 0x0df4e620, 0x0e4401d0, 0x0e9369f0, 0x0ee31de0, + 0x0f332000, 0x0f837180, 0x0fd412a0, 0x10250260, + 0x10763f20, 0x10c7c660, 0x11199560, 0x116baa00, + 0x11be0400, 0x1210a1c0, 0x12638180, 0x12b69ee0, + 0x1309f3e0, 0x135d7ac0, 0x13b12dc0, 0x1404ffa0, + 0x1458dd40, 0x14acb720, 0x15008120, 0x15543260, + 0x15a7c460, 0x15fb3160, 0x164e7520, 0x16a193c0, + 0x16f49740, 0x17478720, 0x179a6720, 0x17ed3720, + 0x183ff460, 0x18929c20, 0x18e52b00, 0x19379c00, + 0x1989e900, 0x19dc0ca0, 0x1a2e0280, 0x1a7fc400, + 0x1ad14a00, 0x1b228ec0, 0x1b738ea0, 0x1bc44540, + 0x1c14ada0, 0x1c64c380, 0x1cb48440, 0x1d03f420, + 0x1d531c00, 0x1da20160, 0x1df0a660, 0x1e3f0860, + 0x1e8d2340, 0x1edaf340, 0x1f2875e0, 0x1f75a700, + 0x1fc281e0, 0x200f0380, 0x205b2ac0, 0x20a6f980, + 0x20f27200, 0x213d9600, 0x21886580, 0x21d2e040, + 0x221d0640, 0x2266d6c0, 0x22b05180, 0x22f97580, + 0x23424280, 0x238ab880, 0x23d2d780, 0x241aa040, + 0x246213c0, 0x24a93300, 0x24efff80, 0x25367b40, + 0x256f68c0, 0x25b53580, 0x25faa580, 0x263fb940, + 0x26847080, 0x26c8cbc0, 0x270ccb00, 0x27506e40, + 0x2793b600, 0x27d6a200, 0x281932c0, 0x285b6880, + 0x289d4400, 0x28dec5c0, 0x291feec0, 0x2960bf80, + 0x29a137c0, 0x29e15800, 0x2a212000, 0x2a609080, + 0x2a9fa980, 0x2ade6b40, 0x2b1cd600, 0x2b5aea00, + 0x2b98a740, 0x2bd60d80, 0x2c131cc0, 0x2c4fd500, + 0x2c8c3600, 0x2cc83f00, 0x2d03f040, 0x2d3f48c0, + 0x2d7a48c0, 0x2db4ef40, 0x2def3c40, 0x2e292ec0, + 0x2e62c700, 0x2e9c0400, 0x2ed4e580, 0x2f0d6ac0, + 0x2f4592c0, 0x2f7d5c80, 0x2fb4c6c0, 0x2febd140, + 0x30227b40, 0x3058c400, 0x308eab40, 0x30c43040, + 0x30f95100, 0x312e0d00, 0x31626240, 0x31965040, + 0x31c9d5c0, 0x31fcf240, 0x322fa480, 0x3261ec00, + 0x3293c7c0, 0x32c53680, 0x32f63780, 0x3326c9c0, + 0x3356ec00, 0x33869d00, 0x33b5db80, 0x33e4a700, + 0x3412fdc0, 0x3440df40, 0x346e4a80, 0x349b3e40, + 0x34c7ba00, 0x34f3bd80, 0x351f47c0, 0x354a5840, + 0x3574ee40, 0x359f0900, 0x35c8a840, 0x35f1cb80, + 0x361a71c0, 0x36429a80, 0x366a4580, 0x36917280, + 0x36b82100, 0x36de5180, 0x37040340, 0x372936c0, + 0x374dec40, 0x37722340, 0x3795dc40, 0x37b91780, + 0x37dbd600, 0x37fe18c0, 0x381fe080, 0x38412e00, + 0x38620280, 0x38825f40, 0x38a24540, 0x38c1b680, + 0x38e0b5c0, 0x38ff4540, 0x391d6800, 0x393b20c0, + 0x39587280, 0x39755fc0, 0x3991eb80, 0x39ae1a80, + 0x39c9f280, 0x39e57980, 0x3a00b600, 0x3a1bae00, + 0x3a366800, 0x3a50e9c0, 0x3a6b3a40, 0x3a8560c0, + 0x3a9f6640, 0x3ab95400, 0x3ad332c0, 0x3aed0680, + 0x3b06cf80, 0x3b208d40, 0x3b3a3e80, 0x3b53cb80, + 0x3b6d0780, 0x3b85c380, 0x3b9dd0c0, 0x3bb4eb40, + 0x3bcabac0, 0x3bdee680, 0x3bf11680, 0x3c011440, + 0x3c179ac0, 0x3c1c4f00, 0x3c21aa40, 0x3c278880, + 0x3c2dba80, 0x3c341140, 0x3c3a5e80, 0x3c409100, + 0x3c46b480, 0x3c4cd5c0, 0x3c530180, 0x3c593cc0, + 0x3c5f84c0, 0x3c65d640, 0x3c6c2e40, 0x3c728b40, + 0x3c78ee80, 0x3c7f5840, 0x3c85c940, 0x3c8c4240, + 0x3c92c380, 0x3c994cc0, 0x3c9fde40, 0x3ca67880, + 0x3cad1ac0, 0x3cb3c540, 0x3cba7800, 0x3cc132c0, + 0x3cc7f640, 0x3ccec280, 0x3cd59800, 0x3cdc76c0, + 0x3ce35e80, 0x3cea4f00, 0x3cf147c0, 0x3cf84900, + 0x3cff5340, 0x3d0666c0, 0x3d0d8400, 0x3d14ab40, + 0x3d1bdc00, 0x3d2315c0, 0x3d2a5880, 0x3d31a440, + 0x3d38f900, 0x3d405780, 0x3d47c040, 0x3d4f3300, + 0x3d56af40, 0x3d5e3500, 0x3d65c380, 0x3d6d5ac0, + 0x3d74fb40, 0x3d7ca540, 0x3d845900, 0x3d8c1680, + 0x3d93dd00, 0x3d9bac80, 0x3da38400, 0x3dab6400, + 0x3db34c80, 0x3dbb3dc0, 0x3dc33840, 0x3dcb3bc0, + 0x3dd347c0, 0x3ddb5bc0, 0x3de37780, 0x3deb9b00, + 0x3df3c600, 0x3dfbf940, 0x3e0434c0, 0x3e0c7840, + 0x3e14c3c0, 0x3e1d1640, 0x3e256f80, 0x3e2dcf40, + 0x3e363580, 0x3e3ea300, 0x3e4717c0, 0x3e4f9380, + 0x3e581600, 0x3e609e40, 0x3e692c40, 0x3e71bf80, + 0x3e7a5840, 0x3e82f740, 0x3e8b9c40, 0x3e944700, + 0x3e9cf780, 0x3ea5ad00, 0x3eae66c0, 0x3eb72500, + 0x3ebfe780, 0x3ec8af00, 0x3ed17b80, 0x3eda4d00, + 0x3ee32340, 0x3eebfd40, 0x3ef4dac0, 0x3efdbbc0, + 0x3f06a040, 0x3f0f88c0, 0x3f187540, 0x3f216600, + 0x3f2a5a80, 0x3f335200, 0x3f3c4c40, 0x3f454940, + 0x3f4e4940, 0x3f574c80, 0x3f605340, 0x3f695dc0, + 0x3f726b40, 0x3f7b7b40, 0x3f848dc0, 0x3f8da240, + 0x3f96b940, 0x3f9fd300, 0x3fa8f040, 0x3fb21080, + 0x3fbb33c0, 0x3fc459c0, 0x3fcd81c0, 0x3fd6abc0, + 0x3fdfd780, 0x3fe90480, 0x3ff23280, 0x3ffb6100, + 0x40049f80, 0x400dd080, 0x40170400, 0x40203880, + 0x40296f00, 0x4032a600, 0x403bde00, 0x40451680, + 0x404e4f00, 0x40578700, 0x4060be80, 0x4069f500, + 0x40732b80, 0x407c6280, 0x40859980, 0x408ed100, + 0x40980800, 0x40a13f00, 0x40aa7500, 0x40b3a980, + 0x40bcdd80, 0x40c61180, 0x40cf4500, 0x40d87800, + 0x40e1ab00, 0x40eadc80, 0x40f40c80, 0x40fd3a80, + 0x41066700, 0x410f9300, 0x4118bd80, 0x4121e700, + 0x412b0f80, 0x41343580, 0x413d5880, 0x41467980, + 0x414f9780, 0x4158b380, 0x4161cd80, 0x416ae580, + 0x4173fb00, 0x417d0d00, 0x41861b80, 0x418f2600, + 0x41982c80, 0x41a12f80, 0x41aa3000, 0x41b32c80, + 0x41bc2580, 0x41c51a00, 0x41ce0900, 0x41d6f300, + 0x41dfd800, 0x41e8b880, 0x41f19400, 0x41fa6b80, + 0x42033d00, 0x420c0900, 0x4214cf00, 0x421d8e00, + 0x42264680, 0x422ef980, 0x4237a680, 0x42404d80, + 0x4248ee00, 0x42518780, 0x425a1a00, 0x4262a480, + 0x426b2800, 0x4273a400, 0x427c1980, 0x42848880, + 0x428cef80, 0x42954f00, 0x429da680, 0x42a5f500, + 0x42ae3b80, 0x42b67a00, 0x42beb100, 0x42c6e080, + 0x42cf0780, 0x42d72680, 0x42df3c00, 0x42e74880, + 0x42ef4c80, 0x42f74880, 0x42ff3c80, 0x43072880, + 0x430f0c80, 0x4316e800, 0x431eba00, 0x43268380, + 0x432e4480, 0x4335fd00, 0x433dae80, 0x43455800, + 0x434cfa00, 0x43549400, 0x435c2500, 0x4363ad80, + 0x436b2e00, 0x4372a700, 0x437a1800, 0x43818200, + 0x4388e400, 0x43903f00, 0x43979200, 0x439edd00, + 0x43a62080, 0x43ad5c80, 0x43b49180, 0x43bbbf80, + 0x43c2e800, 0x43ca0b00, 0x43d12980, 0x43d84280, + 0x43df5200, 0x43e65500, 0x43ed4800, 0x43f43080, + 0x43fb1c80, 0x44021b80, 0x44093a00, 0x44106480, + 0x44176700, 0x441e0c00, 0x44241e00, 0x44297380, + 0x4425dc00, 0x44240180, 0x441ff300, 0x4419e300, + 0x44123f80, 0x44097500, 0x43ffe900, 0x43f5e700, + 0x43eb9f00, 0x43e13f00, 0x43d6f200, 0x43ccbd80, + 0x43c28400, 0x43b82780, 0x43ad8b00, 0x43a29c80, + 0x43975180, 0x438ba080, 0x437f8180, 0x4372fd00, + 0x43662b00, 0x43592480, 0x434c0000, 0x433ecd00, + 0x43319180, 0x43245300, 0x43171700, 0x4309da80, + 0x42fc9300, 0x42ef3500, 0x42e1b600, 0x42d40280, + 0x42c60000, 0x42b79300, 0x42a8a180, 0x42991a00, + 0x4288f200, 0x42782100, 0x42669e00, 0x42546880, + 0x42418800, 0x422e0480, 0x4219e500, 0x42053680, + 0x41f00980, 0x41da7080, 0x41c47b00, 0x41ae3600, + 0x4197ab80, 0x4180e400, 0x4169e780, 0x4152bb00, + 0x413b5e80, 0x4123d180, 0x410c1480, 0x40f42100, + 0x40dbed00, 0x40c36c80, 0x40aa9600, 0x40915f80, + 0x4077c100, 0x405db280, 0x40432c80, 0x40282580, + 0x400c9280, 0x3ff068c0, 0x3fd39dc0, 0x3fb62bc0, + 0x3f981200, 0x3f795080, 0x3f59e780, 0x3f39ebc0, + 0x3f198680, 0x3ef8e100, 0x3ed82440, 0x3eb76c80, + 0x3e96c940, 0x3e764900, 0x3e55f980, 0x3e35cb00, + 0x3e1590c0, 0x3df51cc0, 0x3dd44200, 0x3db2e640, + 0x3d910200, 0x3d6e8e40, 0x3d4b8480, 0x3d27e600, + 0x3d03bc00, 0x3cdf0fc0, 0x3cb9eb80, 0x3c946240, + 0x3c6e9180, 0x3c489700, 0x3c229000, 0x3bfc95c0, + 0x3bd6bd00, 0x3bb11a80, 0x3b8bc180, 0x3b669bc0, + 0x3b416a00, 0x3b1beb80, 0x3af5e140, 0x3acf3300, + 0x3aa7ef80, 0x3a802780, 0x3a57eb80, 0x3a2f5880, + 0x3a069640, 0x39ddcd40, 0x39b524c0, 0x398ca540, + 0x39643800, 0x393bc540, 0x39133580, 0x38ea7ac0, + 0x38c19040, 0x389871c0, 0x386f1b40, 0x38458e00, + 0x381bd000, 0x37f1e780, 0x37c7db00, 0x379db080, + 0x37736e80, 0x37491b00, 0x371ebcc0, 0x36f45980, + 0x36c96600, 0x369ed300, 0x36740380, 0x3648ffc0, + 0x361dcf40, 0x35f27a00, 0x35c70780, 0x359b7f80, + 0x356fe9c0, 0x35444dc0, 0x3518b280, 0x34ed1940, + 0x34c17c00, 0x3495d4c0, 0x346a1d40, 0x343e4300, + 0x34122840, 0x33e5ae00, 0x33b8b780, 0x338b4dc0, + 0x335d9f00, 0x332fdc00, 0x33023440, 0x32d4cc40, + 0x32a7bc80, 0x327b1d40, 0x324f04c0, 0x32235280, + 0x31f7b100, 0x31cbc7c0, 0x319f4140, 0x3171fb40, + 0x31440840, 0x31157d00, 0x30e66e80, 0x30b6fc40, + 0x30875080, 0x30579600, 0x3027f700, 0x2ff89140, + 0x2fc976c0, 0x2f9ab880, 0x2f6c6780, 0x2f3e8780, + 0x2f111000, 0x2ee3f800, 0x2eb73480, 0x2e8a9840, + 0x2e5dd340, 0x2e3093c0, 0x2e028ac0, 0x2dd39680, + 0x2da3c480, 0x2d732380, 0x2d41c400, 0x2d0fd300, + 0x2cdd9ac0, 0x2cab6640, 0x2c797f00, 0x2c480d40, + 0x2c171700, 0x2be6a0c0, 0x2bb6ae80, 0x2b8739c0, + 0x2b583200, 0x2b298600, 0x2afb2400, 0x2accfa40, + 0x2a9ef500, 0x2a710100, 0x2a430ac0, 0x2a14f9c0, + 0x29e6b0c0, 0x29b81240, 0x29890140, 0x29596900, + 0x29293e00, 0x28f87500, 0x28c70340, 0x2894efc0, + 0x28625140, 0x282f4040, 0x27fbd5c0, 0x27c83540, + 0x27948ec0, 0x27611240, 0x272def80, 0x26fb4cc0, + 0x26c94780, 0x2697fcc0, 0x26678880, 0x2637f740, + 0x26094540, 0x25db6dc0, 0x25ae6b40, 0x25821680, + 0x255627c0, 0x252a55c0, 0x24fe5680, 0x24d1db40, + 0x24a48fc0, 0x24761f40, 0x244637c0, 0x2414c900, + 0x23e20240, 0x23ae1740, 0x23793bc0, 0x2343cc00, + 0x230e4ac0, 0x22d93c80, 0x22a52400, 0x22725180, + 0x2240e480, 0x2210f9c0, 0x21e2ab40, 0x21b5c7c0, + 0x2189d2c0, 0x215e4d40, 0x2132b900, 0x2106ba80, + 0x20da1940, 0x20ac9d80, 0x207e11c0, 0x204e77c0, + 0x201e0880, 0x1fecfea0, 0x1fbb94e0, 0x1f8a0500, + 0x1f59d340, 0x1f27ac20, 0x1ef67c60, 0x1ec64e40, + 0x1e96fdc0, 0x1e686400, 0x1e3a5a00, 0x1e0cae80, + 0x1ddf25e0, 0x1db18460, 0x1d839020, 0x1d5536e0, + 0x1d268e80, 0x1cf7ae60, 0x1cc8aea0, 0x1c99af00, + 0x1c6ad820, 0x1c3c5280, 0x1c0e4500, 0x1be0ab60, + 0x1bb35620, 0x1b861400, 0x1b58b480, 0x1b2b1a00, + 0x1afd39c0, 0x1acf09a0, 0x1aa080c0, 0x1a71b020, + 0x1a42c2a0, 0x1a13e420, 0x19e53fc0, 0x19b6eb00, + 0x1988e620, 0x195b3060, 0x192dc8a0, 0x1900a8a0, + 0x18d3c4e0, 0x18a711e0, 0x187a83e0, 0x184e10e0, + 0x1821b060, 0x17f55a00, 0x17c90580, 0x179cb100, + 0x177060a0, 0x17441880, 0x1717dd20, 0x16ebb080, + 0x16bf9260, 0x169382e0, 0x166781c0, 0x163b8f80, + 0x160fade0, 0x15e3de40, 0x15b82220, 0x158c7ae0, + 0x1560ea80, 0x15357240, 0x150a1400, 0x14ded020, + 0x14b3a640, 0x148895a0, 0x145d9dc0, 0x1432bde0, + 0x1407f540, 0x13dd4380, 0x13b2a860, 0x13882460, + 0x135db880, 0x133365a0, 0x13092cc0, 0x12df0e60, + 0x12b50aa0, 0x128b2120, 0x12615200, 0x12379da0, + 0x120e04c0, 0x11e48820, 0x11bb2860, 0x1191e600, + 0x1168c080, 0x113fb7a0, 0x1116cb40, 0x10edfba0, + 0x10c54a00, 0x109cb7a0, 0x10744560, 0x104bf420, + 0x1023c3e0, 0x0ffbb500, 0x0fd3c790, 0x0fabfbe0, + 0x0f845290, 0x0f5ccc40, 0x0f356970, 0x0f0e2a60, + 0x0ee70eb0, 0x0ec01610, 0x0e994040, 0x0e728d50, + 0x0e4bfdf0, 0x0e2592c0, 0x0dff4c70, 0x0dd92af0, + 0x0db32da0, 0x0d8d53e0, 0x0d679cf0, 0x0d420880, + 0x0d1c9680, 0x0cf74700, 0x0cd219f0, 0x0cad0eb0, + 0x0c882450, 0x0c6359a0, 0x0c3ead90, 0x0c1a1f80, + 0x0bf5af40, 0x0bd15cf0, 0x0bad2870, 0x0b891440, + 0x0b652530, 0x0b416020, 0x0b1dca30, 0x0afa6810, + 0x0ad73ee0, 0x0ab45370, 0x0a91aac0, 0x0a6f49b0, + 0x0a4da7f0, 0x0a2c7e20, 0x0a0ba310, 0x09eb1220, + 0x09cac6e0, 0x09aabc70, 0x098aee40, 0x096b57a0, + 0x094bf400, 0x092cbea0, 0x090db2e0, 0x08eecef0, + 0x08d01360, 0x08b18110, 0x089318b0, 0x0874db00, + 0x0856c880, 0x0838e1b0, 0x081b2730, 0x07fd99a8, + 0x07e03a28, 0x07c309a8, 0x07a60910, 0x07893918, + 0x076c99d0, 0x07502b90, 0x0733ee70, 0x0717e2f8, + 0x06fc09b8, 0x06e06378, 0x06c4f0b8, 0x06a9b1c8, + 0x068ea6a0, 0x0673cf18, 0x06592b18, 0x063ebad0, + 0x06247ed0, 0x060a7780, 0x05f0a570, 0x05d708b8, + 0x05bda128, 0x05a46e80, 0x058b7078, 0x0572a740, + 0x055a1330, 0x0541b4d8, 0x05298c98, 0x05119a88, + 0x04f9de50, 0x04e257a0, 0x04cb0630, 0x04b3ea00, + 0x049d0378, 0x04865308, 0x046fd918, 0x045995a8, + 0x04438860, 0x042db0d0, 0x04180ea0, 0x0402a1d0, + 0x03ed6abc, 0x03d869b8, 0x03c39f28, 0x03af0af0, + 0x039aaca0, 0x038683b4, 0x03728fc0, 0x035ed0b0, + 0x034b46c4, 0x0337f254, 0x0324d3a0, 0x0311eab0, + 0x02ff370c, 0x02ecb85c, 0x02da6e34, 0x02c858a8, + 0x02b67820, 0x02a4cd28, 0x02935820, 0x02821920, + 0x02710fac, 0x02603b54, 0x024f9bb4, 0x023f308c, + 0x022ef9e8, 0x021ef7c8, 0x020f2a40, 0x01ff908e, + 0x01f02974, 0x01e0f38a, 0x01d1ed94, 0x01c316d6, + 0x01b46f5e, 0x01a5f720, 0x0197ae28, 0x018994ea, + 0x017bac54, 0x016df546, 0x016070ae, 0x01532078, + 0x01460760, 0x01392834, 0x012c85a4, 0x01201f7a, + 0x0113f27c, 0x0107fb6c, 0x00fc36fd, 0x00f0a2d5, + 0x00e53d51, 0x00da050f, 0x00cef88c, 0x00c41869, + 0x00b9671f, 0x00aee754, 0x00a49b80, 0x009a8384, + 0x00909ca6, 0x0086e400, 0x007d56e3, 0x0073f48e, + 0x006abe70, 0x0061b5de, 0x0058dc65, 0x005033b4, + 0x0047be30, 0x003f7e30, 0x00377619, 0x002fa4d4, + 0x002805ee, 0x002094cb, 0x00194cb8, 0x00122856, + 0x000b215c, 0x00043148, 0xfffd51f0, 0xfff683a0, + 0xffefcd4d, 0xffe9362f, 0xffe2c57d, 0xffdc855c, + 0xffd682c4, 0xffd0cad4, 0xffcb6a2c, 0xffc663bc, + 0xffc1b06f, 0xffbd48e1, 0xffb92570, 0xffb53a54, + 0xffb1779c, 0xffadcd38, 0xffaa2b42, 0xffa68855, + 0xffa2e141, 0xff9f332c, 0xff9b7b9c, 0xff97bf2e, + 0xff9409e2, 0xff9067e2, 0xff8ce556, 0xff898bf0, + 0xff866306, 0xff8371d0, 0xff80bf63, 0xff7e4eba, + 0xff7c1eaa, 0xff7a2e04, 0xff787b47, 0xff770280, + 0xff75bd06, 0xff74a3f7, 0xff73b0b2, 0xff72dd02, + 0xff72237e, 0xff717ebe, 0xff70e94c, 0xff705f59, + 0xff6fde6a, 0xff6f6426, 0xff6eee40, 0xff6e7d0b, + 0xff6e1359, 0xff6db403, 0xff6d61f8, 0xff6d2054, + 0xff6cf267, 0xff6cdb76, 0xff6cdebb, 0xff6cff47, + 0xff6d3fc9, 0xff6da306, 0xff6e2b82, 0xff6eda13, + 0xff6fad6d, 0xff70a463, 0xff71bd9d, 0xff72f662, + 0xff744a80, 0xff75b5c4, 0xff773409, 0xff78c0a6, + 0xff7a5693, 0xff7bf0dc, 0xff7d8abb, 0xff7f2301, + 0xff80bc08, 0xff825854, 0xff83fa56, 0xff85a55c, + 0xff875d22, 0xff892598, 0xff8b025d, 0xff8cf53c, + 0xff8efdf4, 0xff911c48, 0xff934fc9, 0xff959675, + 0xff97ec86, 0xff9a4e35, 0xff9cb7d2, 0xff9f26cc, + 0xffa199ce, 0xffa40f74, 0xffa6867c, 0xffa8feb2, + 0xffab78e0, 0xffadf5c7, 0xffb07640, 0xffb2fba0, + 0xffb587a2, 0xffb81bfb, 0xffbaba46, 0xffbd6236, + 0xffc011a8, 0xffc2c679, 0xffc57e84, 0xffc83894, + 0xffcaf41a, 0xffcdb0b8, 0xffd06e17, 0xffd32bf7, + 0xffd5ea38, 0xffd8a8c3, 0xffdb6764, 0xffde25fb, + 0xffe0e471, 0xffe3a2b2, 0xffe66087, 0xffe91da6, + 0xffebd978, 0xffee9351, 0xfff14ab0, 0xfff3fef6, + 0xfff6af94, 0xfff95c0c, 0xfffc03c7, 0xfffea659, + 0x00015885, 0x0003f2e9, 0x00068a73, 0x00091e8d, + 0x000bae7f, 0x000e39bf, 0x0010bf96, 0x00133f78, + 0x0015b8c4, 0x00182ae4, 0x001a9558, 0x001cf7b2, + 0x001f51e0, 0x0021a3b4, 0x0023ed25, 0x00262df2, + 0x002865c5, 0x002a9469, 0x002cb967, 0x002ed4aa, + 0x0030e607, 0x0032ed88, 0x0034eb2f, 0x0036de23, + 0x0038c503, 0x003a9e4c, 0x003c68a6, 0x003e23dd, + 0x003fd0db, 0x00417083, 0x0043038b, 0x00448adf, + 0x00460740, 0x0047799c, 0x0048e2b2, 0x004a42af, + 0x004b98fb, 0x004ce50b, 0x004e2654, 0x004f5b5d, + 0x005081c3, 0x00519716, 0x00529920, 0x005386d0, + 0x0054603f, 0x00552581, 0x0055d6cc, 0x00567558, + 0x0057033c, 0x005782b4, 0x0057f5b6, 0x00585e46, + 0x0058be68, 0x005917ff, 0x00596ce4, 0x0059bcc0, + 0x005a053a, 0x005a43ee, 0x005a76ae, 0x005a9b37, + 0x005aaf38, 0x005ab07a, 0x005a9cef, 0x005a7349, + 0x005a3328, 0x0059dc0a, 0x00596db0, 0x0058e8e5, + 0x00584f98, 0x0057a3c0, 0x0056e738, 0x00561bec, + 0x005543df, 0x0054610b, 0x0053753e, 0x0052824e, + 0x005189f6, 0x00508dec, 0x004f8fc0, 0x004e8fd0, + 0x004d8d26, 0x004c86d7, 0x004b7c0a, 0x004a6b33, + 0x00495239, 0x00482f0e, 0x0046ffc4, 0x0045c201, + 0x00447337, 0x004310cc, 0x00419871, 0x004008e4, + 0x003e6231, 0x003ca460, 0x003acf8a, 0x0038e57a, + 0x0036e981, 0x0034defa, 0x0032c94b, 0x0030acc6, + 0x002e8eb4, 0x002c7452, 0x002a62aa, 0x00285bbf, + 0x00265eda, 0x00246b24, 0x00227f9c, 0x002098e7, + 0x001eb13b, 0x001cc2ef, 0x001ac899, 0x0018be3d, + 0x0016a198, 0x00147065, 0x00122897, 0x000fcbc5, + 0x000d5f03, 0x000ae77a, 0x00086a52, 0x0005eb92, + 0x00036e4a, 0x0000f57e, 0xfffe8414, 0xfffc1a78, + 0xfff9b6bb, 0xfff756d9, 0xfff4f8d0, 0xfff29add, + 0xfff03b87, 0xffedd94c, 0xffeb7295, 0xffe9072b, + 0xffe6981a, 0xffe4265b, 0xffe1b30e, 0xffdf3f2b, + 0xffdccb9e, 0xffda5993, 0xffd7ea0c, 0xffd57d60, + 0xffd31302, 0xffd0aa27, 0xffce4243, 0xffcbdb40, + 0xffc97595, 0xffc711a2, 0xffc4af9d, 0xffc24fa6, + 0xffbff1de, 0xffbd9699, 0xffbb3e44, 0xffb8e8d5, + 0xffb695f4, 0xffb44522, 0xffb1f627, 0xffafa8f0, + 0xffad5d91, 0xffab140a, 0xffa8cc1c, 0xffa68590, + 0xffa44066, 0xffa1fca0, 0xff9fba30, 0xff9d7902, + 0xff9b3916, 0xff98fa6d, 0xff96bd06, 0xff9480b6, + 0xff924532, 0xff900a24, 0xff8dcf41, 0xff8b9433, + 0xff895884, 0xff871bd3, 0xff84dd8a, 0xff829d34, + 0xff805a43, 0xff7e142d, 0xff7bca71, 0xff797c83, + 0xff7729e3, 0xff74d204, 0xff727451, 0xff70101e, + 0xff6da493, 0xff6b30d1, 0xff68b3f4, 0xff662d31, + 0xff639bd1, 0xff60ff09, 0xff5e562c, 0xff5ba3e0, + 0xff58ee39, 0xff563c22, 0xff5394f3, 0xff50fd1e, + 0xff4e7599, 0xff4bff32, 0xff499ad4, 0xff47490a, + 0xff450a36, 0xff42deb7, 0xff40c6cf, 0xff3ec2be, + 0xff3cd299, 0xff3af681, 0xff392e6a, 0xff377a4a, + 0xff35d9f7, 0xff344d44, 0xff32d3e8, 0xff316d96, + 0xff3019d9, 0xff2ed83a, 0xff2da82f, 0xff2c88bf, + 0xff2b78b4, 0xff2a76cc, 0xff298184, 0xff289890, + 0xff27bc7d, 0xff26ee21, 0xff262e28, 0xff257cdc, + 0xff24d9f4, 0xff244524, 0xff23be15, 0xff234488, + 0xff22d852, 0xff227947, 0xff22273d, 0xff21e1d2, + 0xff21a871, 0xff217a79, 0xff215748, 0xff213eca, + 0xff21319e, 0xff21305c, 0xff213baf, 0xff2153c2, + 0xff21782b, 0xff21a892, 0xff21e477, 0xff222bda, + 0xff227f26, 0xff22debd, 0xff234b09, 0xff23c394, + 0xff24471d, 0xff24d42b, 0xff25695c, 0xff260538, + 0xff26a652, 0xff274b28, 0xff27f22d, 0xff2899d2, + 0xff295975, 0xff29f2ad, 0xff2a96d7, 0xff2b45f4, + 0xff2bffe3, 0xff2cc4ba, 0xff2d9458, 0xff2e6ede, + 0xff2f544c, 0xff3044b7, 0xff314034, 0xff3246fa, + 0xff33591e, 0xff3476e0, 0xff35a060, 0xff36d534, + 0xff38148f, 0xff395daf, 0xff3aafd4, 0xff3c0ac8, + 0xff3d6ed6, 0xff3edc54, 0xff405382, 0xff41d3f5, + 0xff435ccc, 0xff44ed0f, 0xff4683d3, 0xff482080, + 0xff49c297, 0xff4b69ab, 0xff4d1547, 0xff4ec4f5, + 0xff50781d, 0xff522e20, 0xff53e692, 0xff55a15d, + 0xff575f17, 0xff592022, 0xff5ae4de, 0xff5cacb4, + 0xff5e75e2, 0xff603ee5, 0xff62062f, 0xff63caab, + 0xff658b55, 0xff67476d, 0xff68fe11, 0xff6aaea0, + 0xff6c5899, 0xff6dfb86, 0xff6f96e7, 0xff712a65, + 0xff72b59f, 0xff74382b, 0xff75b1d3, 0xff772276, + 0xff788a20, 0xff79e8e5, 0xff7b3ef0, 0xff7c8c98, + 0xff7dd249, 0xff7f108c, 0xff804804, 0xff817d0e, + 0xff82b74a, 0xff83fde6, 0xff855762, 0xff86c622, + 0xff884904, 0xff89ded1, 0xff8b8646, 0xff8d3e4c, + 0xff8f05cc, 0xff90dbc6, 0xff92bf2a, 0xff94af04, + 0xff96aa26, 0xff98af9a, 0xff9abe48, 0xff9cd543, + 0xff9ef3c1, 0xffa118ea, 0xffa343fd, 0xffa57423, + 0xffa7a890, 0xffa9e084, 0xffac1b31, 0xffae5802, + 0xffb09680, 0xffb2d621, 0xffb51678, 0xffb75704, + 0xffb99726, 0xffbbd645, 0xffbe13d7, 0xffc04f26, + 0xffc2879a, 0xffc4bc72, 0xffc6ed24, 0xffc918e3, + 0xffcb3eb8, 0xffcd5dcc, 0xffcf7549, 0xffd184d8, + 0xffd38c8f, 0xffd58ca4, 0xffd7854d, 0xffd97694, + 0xffdb606e, 0xffdd42d1, 0xffdf1da8, 0xffe0f09b, + 0xffe2bb00, 0xffe47c41, 0xffe633c6, 0xffe7e150, + 0xffe98534, 0xffeb1fb4, 0xffecb10e, 0xffee3944, + 0xffefb7e9, 0xfff12cbe, 0xfff29762, 0xfff3f789, + 0xfff54cbe, 0xfff69695, 0xfff7d4b8, 0xfff90748, + 0xfffa2ee5, 0xfffb4c3c, 0xfffc6003, 0xfffd6af0, + 0xfffe6dda, 0xffff69b8, 0x00005f4b, 0x00014e7f, + 0x00023646, 0x000315b4, 0x0003ebd3, 0x0004b74a, + 0x00057677, 0x000627e2, 0x0006ca09, 0x00075ce1, + 0x0007e196, 0x00085955, 0x0008c556, 0x00092751, + 0x00098153, 0x0009d581, 0x000a25be, 0x000a732b, + 0x000abe1f, 0x000b06e4, 0x000b4db1, 0x000b91fa, + 0x000bd266, 0x000c0da0, 0x000c426e, 0x000c6ffb, + 0x000c95b0, 0x000cb2f7, 0x000cc76e, 0x000cd317, + 0x000cd647, 0x000cd17f, 0x000cc52b, 0x000cb1ea, + 0x000c98c0, 0x000c7a62, 0x000c57c7, 0x000c3187, + 0x000c0862, 0x000bdcd8, 0x000baf81, 0x000b80c7, + 0x000b50ec, 0x000b202f, 0x000aeec6, 0x000abcb2, + 0x000a89d2, 0x000a5605, 0x000a2116, 0x0009eafb, + 0x0009b37d, 0x00097a9d, 0x00094030, 0x00090440, + 0x0008c6b9, 0x000887ae, 0x0008470c, 0x00080512, + 0x0007c1f6, 0x00077df9, 0x0007395a, 0x0006f45b, + 0x0006af67, 0x00066abe, 0x000626b6, 0x0005e38f, + 0x0005a1a0, 0x0005611e, 0x00052234, 0x0004e502, + 0x0004a95d, 0x00046f46, 0x00043691, 0x0003ff33, + 0x0003c90d, 0x0003941f, 0x00036047, 0x00032d9c, + 0x0002fc1e, 0x0002cbed, 0x00029d1e, 0x00026fbc, + 0x000243f2, 0x000219d6, 0x0001f17d, 0x0001caf1, + 0x0001a63e, 0x00018363, 0x00016256, 0x00014316, + 0x0001258f, 0x000109cb, 0x0000efaa, 0x0000d720, + 0x0000c03a, 0x0000aacb, 0x000096de, 0x0000846a, + 0x0000736d, 0x000063d3, 0x000055a6, 0x000048d0, + 0x00003d47, 0x000032f6, 0x000029dc, 0x000021d9, + 0x00001ae3, 0x000014ee, 0x00000fdb, 0x00000ba9, + 0x00000839, 0x00000589, 0x00000370, 0x000001ee, + 0x000000d7, 0x00000036, 0xffffffe0, 0xffffffc0, + 0xffffffd5, 0xfffffff5, 0x0000000b, 0x0000000b, + 0x0000000b, 0x0000000b, 0xfffffff5, 0xffffffd5, + 0xffffffca, 0xffffffe0, 0x00000036, 0x000000d7, + 0x000001ce, 0x0000033b, 0x00000529, 0x000007ad, + 0x00000ac8, 0x00000e99, 0x00001316, 0x0000185e, + 0x00001e7e, 0x00002575, 0x00002d4c, 0x0000361b, + 0x00003fd6, 0x00004a93, 0x00005647, 0x00006312, + 0x000070de, 0x00007fad, 0x00008f87, 0x0000a064, + 0x0000b242, 0x0000c52d, 0x0000d919, 0x0000ee12, + 0x0001040c, 0x00011b13, 0x0001331b, 0x00014c30, + 0x0001663c, 0x0001814a, 0x00019d4f, 0x0001ba35, + 0x0001d7e7, 0x0001f645, 0x00021544, 0x000234c3, + 0x000254b9, 0x00027505, 0x000295a7, 0x0002b67e, + 0x0002d7a1, 0x0002f904, 0x00031ab2, 0x00033ca0, + 0x00035ee5, 0x0003818a, 0x0003a485, 0x0003c7e1, + 0x0003eb72, 0x00040f0e, 0x0004329f, 0x000455e6, + 0x000478c0, 0x00049aef, 0x0004bc52, 0x0004dca9, + 0x0004fbde, 0x000519c5, 0x00053635, 0x0005512d, + 0x00056aae, 0x000582a1, 0x00059927, 0x0005ae40, + 0x0005c1f6, 0x0005d455, 0x0005e572, 0x0005f56d, + 0x00060446, 0x0006121e, 0x00061f09, 0x00062b08, + 0x00063605, 0x00063feb, 0x00064899, 0x00064ff0, + 0x000655a5, 0x00065996, 0x00065b6f, 0x00065af8, + 0x000657e9, 0x000651d4, 0x00064884, 0x00063bae, + 0x00062b33, 0x00061706, 0x0005fefd, 0x0005e344, + 0x0005c404, 0x0005a195, 0x00057c41, 0x00055473, + 0x00052ac2, 0x0004ffc4, 0x0004d410, 0x0004a7e5, + 0x00047b4f, 0x00044e39, 0x00042096, 0x0003f208, + 0x0003c1e1, 0x00038f77, 0x00035a12, 0x00032127, + 0x0002e476, 0x0002a389, 0x00025e29, 0x0002146d, + 0x0001c700, 0x00017682, 0x000123a1, 0x0000cefd, + 0x000078f7, 0x0000221a, 0xffffcad1, 0xffff7332, + 0xffff1b1e, 0xfffec253, 0xfffe6891, 0xfffe0da2, + 0xfffdb15c, 0xfffd5393, 0xfffcf412, 0xfffc92e3, + 0xfffc3032, 0xfffbcc29, 0xfffb6714, 0xfffb0113, + 0xfffa9a5b, 0xfffa3337, 0xfff9cbd4, 0xfff96450, + 0xfff8fcac, 0xfff894dc, 0xfff82cd8, 0xfff7c4a8, + 0xfff75c6d, 0xfff6f45e, 0xfff68c84, 0xfff62500, + 0xfff5bde8, 0xfff5575a, 0xfff4f179, 0xfff48c64, + 0xfff42810, 0xfff3c488, 0xfff361d7, 0xfff30008, + 0xfff29f3a, 0xfff23f78, 0xfff1e0d8, 0xfff1835b, + 0xfff1272a, 0xfff0cc46, 0xfff072cf, 0xfff01ad0, + 0xffefc469, 0xffef6fa4, 0xffef1ca3, 0xffeecb7a, + 0xffee7c1f, 0xffee2eb2, 0xffede33d, 0xffed99c1, + 0xffed5249, 0xffed0cde, 0xffecc98d, 0xffec8849, + 0xffec4934, 0xffec0c38, 0xffebd175, 0xffeb98eb, + 0xffeb62a4, 0xffeb2ead, 0xffeafd19, 0xffeacdea, + 0xffeaa129, 0xffea76cc, 0xffea4ef4, 0xffea299f, + 0xffea06e5, 0xffe9e6ce, 0xffe9c97d, 0xffe9aebb, + 0xffe99651, 0xffe97fd6, 0xffe96ad3, 0xffe95711, + 0xffe9447d, 0xffe93315, 0xffe922ce, 0xffe913a0, + 0xffe90588, 0xffe8f887, 0xffe8ec93, 0xffe8e1c1, + 0xffe8d806, 0xffe8cf77, 0xffe8c816, 0xffe8c1eb, + 0xffe8bd03, 0xffe8b967, 0xffe8b72e, 0xffe8b64d, + 0xffe8b6d8, 0xffe8b8dc, 0xffe8bc6c, 0xffe8c18a, + 0xffe8c840, 0xffe8d0a4, 0xffe8daca, 0xffe8e69e, + 0xffe8f42a, 0xffe9035a, 0xffe9142b, 0xffe926a0, + 0xffe93ab7, 0xffe95066, 0xffe967b8, 0xffe980ad, + 0xffe99b3a, 0xffe9b754, 0xffe9d511, 0xffe9f45b, + 0xffea1532, 0xffea3797, 0xffea5b89, 0xffea8108, + 0xffeaa7ff, 0xffead079, 0xffeafa55, 0xffeb259e, + 0xffeb5254, 0xffeb8061, 0xffebafdc, 0xffebe0ae, + 0xffec12ce, 0xffec462f, 0xffec7add, 0xffecb0a3, + 0xffece774, 0xffed1f32, 0xffed57a7, 0xffed90b2, + 0xffedca48, 0xffee042a, 0xffee3e57, 0xffee788e, +}; + const DECLARE_ALIGNED(32, float, ff_aac_eld_window_480)[1800] = { 0.00101191, 0.00440397, 0.00718669, 0.01072130, 0.01459757, 0.01875954, 0.02308987, 0.02751541, @@ -2219,3 +2705,456 @@ -0.00115988, -0.00114605, -0.00113200, -0.00111778, -0.00110343, -0.00108898, -0.00107448, -0.00105995, }; + +const DECLARE_ALIGNED(32, int, ff_aac_eld_window_480_fixed)[1800] = { + 0x00109442, 0x00482797, 0x0075bf2a, 0x00afa864, + 0x00ef2aa5, 0x01335b36, 0x017a4df0, 0x01c2cffe, + 0x020bfb4c, 0x0254fd74, 0x029d557c, 0x02e50574, + 0x032c41a8, 0x03732c08, 0x03b9cb88, 0x040032e8, + 0x044686f0, 0x048cd578, 0x04d30738, 0x05190500, + 0x055ec210, 0x05a44750, 0x05e9aeb8, 0x062f0c80, + 0x067477a0, 0x06ba1ac0, 0x07001998, 0x074680e0, + 0x078d5ec0, 0x07d4d038, 0x081cf8f0, 0x0865f8b0, + 0x08afe0e0, 0x08fab150, 0x09466cd0, 0x09931910, + 0x09e0adb0, 0x0a2f1640, 0x0a7e43f0, 0x0ace2960, + 0x0b1eb180, 0x0b6fc4b0, 0x0bc15050, 0x0c134710, + 0x0c65a420, 0x0cb86340, 0x0d0b7df0, 0x0d5ef450, + 0x0db2cb60, 0x0e070180, 0x0e5b91f0, 0x0eb07f20, + 0x0f05d0a0, 0x0f5b8920, 0x0fb1a950, 0x10082e40, + 0x105f1400, 0x10b65820, 0x110df780, 0x1165f120, + 0x11be43e0, 0x1216eea0, 0x126feac0, 0x12c92b00, + 0x1322a620, 0x137c55c0, 0x13d61ae0, 0x142fc940, + 0x148949e0, 0x14e28da0, 0x153b9a80, 0x15947640, + 0x15ed1840, 0x16458660, 0x169deb20, 0x16f663c0, + 0x174ef8c0, 0x17a7a120, 0x180041c0, 0x1858d000, + 0x18b14940, 0x1909a140, 0x1961c820, 0x19b9b620, + 0x1a116480, 0x1a68c1a0, 0x1abfbd00, 0x1b164f60, + 0x1b6c7580, 0x1bc23120, 0x1c1780e0, 0x1c6c5d00, + 0x1cc0dbe0, 0x1d1532a0, 0x1d697660, 0x1dbdac20, + 0x1e11b280, 0x1e655b80, 0x1eb89e80, 0x1f0b7720, + 0x1f5dd680, 0x1fafaec0, 0x2000fb00, 0x2051c340, + 0x20a22ac0, 0x20f24580, 0x214213c0, 0x21919140, + 0x21e0b300, 0x222f7580, 0x227dd900, 0x22cbd880, + 0x23196ec0, 0x23669b00, 0x23b35d80, 0x23ffb6c0, + 0x244ba7c0, 0x249731c0, 0x24e25700, 0x252d1940, + 0x2594ae40, 0x25deea40, 0x2628bd00, 0x26722680, + 0x26bb2740, 0x2703bf40, 0x274beec0, 0x2793b600, + 0x27db1500, 0x28220c00, 0x28689b80, 0x28aec4c0, + 0x28f48800, 0x2939e680, 0x297ee080, 0x29c37600, + 0x2a07a740, 0x2a4b74c0, 0x2a8ede80, 0x2ad1e500, + 0x2b148880, 0x2b56c940, 0x2b98a740, 0x2bda2240, + 0x2c1b3a80, 0x2c5bef80, 0x2c9c4100, 0x2cdc2e80, + 0x2d1bb800, 0x2d5adc80, 0x2d999b80, 0x2dd7f500, + 0x2e15e800, 0x2e537400, 0x2e9098c0, 0x2ecd5540, + 0x2f09a900, 0x2f4592c0, 0x2f811140, 0x2fbc2340, + 0x2ff6c7c0, 0x3030fe80, 0x306ac6c0, 0x30a41f80, + 0x30dd07c0, 0x31157dc0, 0x314d7fc0, 0x31850c80, + 0x31bc22c0, 0x31f2c1c0, 0x3228e840, 0x325e9540, + 0x3293c7c0, 0x32c87e40, 0x32fcb800, 0x33307340, + 0x3363aec0, 0x33966940, 0x33c8a140, 0x33fa5580, + 0x342b84c0, 0x345c2dc0, 0x348c4f80, 0x34bbe900, + 0x34eaf9c0, 0x35198080, 0x35477d00, 0x3574ee40, + 0x35a1d340, 0x35ce2bc0, 0x35f9f6c0, 0x36253380, + 0x364fe180, 0x367a0040, 0x36a38f80, 0x36cc8ec0, + 0x36f4fe80, 0x371cde80, 0x37442e80, 0x376aef00, + 0x37912000, 0x37b6c200, 0x37dbd600, 0x38005d00, + 0x38245840, 0x3847c880, 0x386aaf80, 0x388d0e80, + 0x38aee700, 0x38d03bc0, 0x38f11000, 0x39116700, + 0x39314440, 0x3950ab00, 0x396f9e80, 0x398e22c0, + 0x39ac3c40, 0x39c9f280, 0x39e74cc0, 0x3a045280, + 0x3a210b40, 0x3a3d7ec0, 0x3a59b480, 0x3a75b480, + 0x3a918900, 0x3aad3cc0, 0x3ac8db00, 0x3ae46bc0, + 0x3afff080, 0x3b1b6840, 0x3b36d2c0, 0x3b521980, + 0x3b6d0780, 0x3b876400, 0x3ba0f4c0, 0x3bb96740, + 0x3bd03dc0, 0x3be56580, 0x3bf6dec0, 0x3c0c6140, + 0x3c15a9c0, 0x3c1a5780, 0x3c1fd0c0, 0x3c25edc0, + 0x3c2c78c0, 0x3c333880, 0x3c39f3c0, 0x3c409100, + 0x3c471d00, 0x3c4da780, 0x3c543f40, 0x3c5ae880, + 0x3c619f00, 0x3c685f00, 0x3c6f25c0, 0x3c75f280, + 0x3c7cc6c0, 0x3c83a2c0, 0x3c8a87c0, 0x3c9175c0, + 0x3c986d00, 0x3c9f6e00, 0x3ca67880, 0x3cad8c40, + 0x3cb4a980, 0x3cbbd000, 0x3cc2ffc0, 0x3cca3940, + 0x3cd17d40, 0x3cd8cb80, 0x3ce02480, 0x3ce78740, + 0x3ceef3c0, 0x3cf66a00, 0x3cfdea00, 0x3d0574c0, + 0x3d0d0a40, 0x3d14ab40, 0x3d1c5700, 0x3d240d00, + 0x3d2bcd40, 0x3d3397c0, 0x3d3b6cc0, 0x3d434d00, + 0x3d4b38c0, 0x3d532fc0, 0x3d5b3180, 0x3d633dc0, + 0x3d6b53c0, 0x3d737400, 0x3d7b9f00, 0x3d83d540, + 0x3d8c1680, 0x3d946200, 0x3d9cb780, 0x3da51680, + 0x3dad7f00, 0x3db5f140, 0x3dbe6dc0, 0x3dc6f480, + 0x3dcf8540, 0x3dd81fc0, 0x3de0c300, 0x3de96ec0, + 0x3df22340, 0x3dfae0c0, 0x3e03a800, 0x3e0c7840, + 0x3e155180, 0x3e1e32c0, 0x3e271bc0, 0x3e300c00, + 0x3e390400, 0x3e420400, 0x3e4b0c40, 0x3e541c80, + 0x3e5d33c0, 0x3e6651c0, 0x3e6f7580, 0x3e789fc0, + 0x3e81d080, 0x3e8b0880, 0x3e944700, 0x3e9d8c00, + 0x3ea6d680, 0x3eb02600, 0x3eb97a80, 0x3ec2d400, + 0x3ecc3340, 0x3ed59880, 0x3edf0300, 0x3ee87280, + 0x3ef1e600, 0x3efb5d40, 0x3f04d880, 0x3f0e5840, + 0x3f17dcc0, 0x3f216600, 0x3f2af340, 0x3f348440, + 0x3f3e1840, 0x3f47af40, 0x3f514a00, 0x3f5ae840, + 0x3f648b00, 0x3f6e3140, 0x3f77db00, 0x3f818740, + 0x3f8b3600, 0x3f94e780, 0x3f9e9c40, 0x3fa85480, + 0x3fb21080, 0x3fbbcfc0, 0x3fc59200, 0x3fcf56c0, + 0x3fd91dc0, 0x3fe2e640, 0x3fecb040, 0x3ff67b40, + 0x40098600, 0x40135580, 0x401d2700, 0x4026fa00, + 0x4030ce80, 0x403aa380, 0x40447900, 0x404e4f00, + 0x40582400, 0x4061f900, 0x406bcd00, 0x4075a080, + 0x407f7480, 0x40894900, 0x40931e00, 0x409cf280, + 0x40a6c600, 0x40b09800, 0x40ba6980, 0x40c43a80, + 0x40ce0b00, 0x40d7db00, 0x40e1ab00, 0x40eb7980, + 0x40f54600, 0x40ff1080, 0x4108d980, 0x4112a100, + 0x411c6800, 0x41262d80, 0x412ff080, 0x4139b180, + 0x41436e80, 0x414d2980, 0x4156e100, 0x41609700, + 0x416a4a80, 0x4173fb00, 0x417da800, 0x41875000, + 0x4190f400, 0x419a9400, 0x41a43000, 0x41adc880, + 0x41b75d00, 0x41c0ec80, 0x41ca7700, 0x41d3fb00, + 0x41dd7980, 0x41e6f280, 0x41f06600, 0x41f9d480, + 0x42033d00, 0x420c9f00, 0x4215f980, 0x421f4d00, + 0x42289900, 0x4231de80, 0x423b1d00, 0x42445500, + 0x424d8500, 0x4256ad00, 0x425fcc80, 0x4268e380, + 0x4271f200, 0x427af900, 0x4283f880, 0x428cef80, + 0x4295de00, 0x429ec280, 0x42a79d80, 0x42b06f00, + 0x42b93800, 0x42c1f800, 0x42caaf80, 0x42d35d80, + 0x42dc0100, 0x42e49b00, 0x42ed2a80, 0x42f5b080, + 0x42fe2d80, 0x4306a180, 0x430f0c80, 0x43176d80, + 0x431fc480, 0x43281100, 0x43305400, 0x43388e80, + 0x4340c000, 0x4348e900, 0x43510900, 0x43591f00, + 0x43612b80, 0x43692f00, 0x43712900, 0x43791a80, + 0x43810380, 0x4388e400, 0x4390bc00, 0x43988b00, + 0x43a05180, 0x43a80f00, 0x43afc480, 0x43b77180, + 0x43bf1780, 0x43c6b700, 0x43ce5100, 0x43d5e580, + 0x43dd7100, 0x43e4ef80, 0x43ec5b80, 0x43f3ba80, + 0x43fb1c80, 0x44029400, 0x440a2e80, 0x4411d080, + 0x44193800, 0x44202480, 0x44265880, 0x442ba780, + 0x442d8680, 0x4428a500, 0x44241380, 0x441ccb00, + 0x44140100, 0x440a1200, 0x43ff7280, 0x43f46980, + 0x43e93200, 0x43ddff00, 0x43d2dc80, 0x43c7ac00, + 0x43bc4900, 0x43b09400, 0x43a47d80, 0x4397fd80, + 0x438b0780, 0x437d9b80, 0x436fd380, 0x4361cd80, + 0x4353a800, 0x43457500, 0x43373c80, 0x43290500, + 0x431ad400, 0x430ca280, 0x42fe6000, 0x42f00080, + 0x42e17380, 0x42d29e00, 0x42c35d80, 0x42b39200, + 0x42a32080, 0x4291fc00, 0x42801900, 0x426d6d80, + 0x4259f680, 0x4245bd00, 0x4230ca80, 0x421b2900, + 0x4204e800, 0x41ee1d00, 0x41d6dd80, 0x41bf3c80, + 0x41a74680, 0x418f0680, 0x41768800, 0x415dd100, + 0x4144e400, 0x412bbf80, 0x41126400, 0x40f8cc00, + 0x40deea00, 0x40c4b100, 0x40aa1400, 0x408f0800, + 0x40738380, 0x40577d80, 0x403aeb80, 0x401dc180, + 0x3ffff240, 0x3fe170c0, 0x3fc232c0, 0x3fa23680, + 0x3f817c40, 0x3f6002c0, 0x3f3ddec0, 0x3f1b4180, + 0x3ef85d40, 0x3ed56340, 0x3eb27240, 0x3e8f9c40, + 0x3e6cf400, 0x3e4a81c0, 0x3e282140, 0x3e059980, + 0x3de2b280, 0x3dbf4100, 0x3d9b3640, 0x3d768b00, + 0x3d513640, 0x3d2b3840, 0x3d049b80, 0x3cdd6b40, + 0x3cb5b400, 0x3c8d8f40, 0x3c652080, 0x3c3c8c40, + 0x3c13f480, 0x3beb7580, 0x3bc327c0, 0x3b9b2680, + 0x3b737000, 0x3b4bc580, 0x3b23d740, 0x3afb5640, + 0x3ad21c40, 0x3aa83780, 0x3a7dbc40, 0x3a52bf80, + 0x3a276600, 0x39fbe0c0, 0x39d06140, 0x39a50ec0, + 0x3979e300, 0x394ebf40, 0x392386c0, 0x38f82280, + 0x38cc89c0, 0x38a0b7c0, 0x3874a740, 0x38485840, + 0x381bd1c0, 0x37ef1b40, 0x37c23cc0, 0x37953dc0, + 0x376825c0, 0x373afc80, 0x370dc980, 0x36e09440, + 0x36b41dc0, 0x36862100, 0x3657e480, 0x36297240, + 0x35fad380, 0x35cc1200, 0x359d36c0, 0x356e4b40, + 0x353f5880, 0x35106780, 0x34e17780, 0x34b28240, + 0x34838040, 0x345466c0, 0x34251940, 0x33f57280, + 0x33c54bc0, 0x33949840, 0x33638380, 0x33324980, + 0x33012500, 0x32d04480, 0x329fc7c0, 0x326fcbc0, + 0x324068c0, 0x32116fc0, 0x31e27600, 0x31b30fc0, + 0x3182e300, 0x3151e240, 0x312029c0, 0x30edd080, + 0x30baf700, 0x3087cd00, 0x30548600, 0x30215680, + 0x2fee65c0, 0x2fbbca40, 0x2f899980, 0x2f57e6c0, + 0x2f26b540, 0x2ef5f980, 0x2ec5aa00, 0x2e95afc0, + 0x2e65c180, 0x2e357b40, 0x2e047840, 0x2dd27380, + 0x2d9f6c40, 0x2d6b7780, 0x2d36a6c0, 0x2d012940, + 0x2ccb5680, 0x2c958a00, 0x2c601b80, 0x2c2b3640, + 0x2bf6dfc0, 0x2bc31ec0, 0x2b8ff500, 0x2b5d5540, + 0x2b2b2a00, 0x2af95e80, 0x2ac7dd80, 0x2a968f80, + 0x2a655d40, 0x2a342f00, 0x2a02e8c0, 0x29d16700, + 0x299f8640, 0x296d2380, 0x293a2740, 0x29068400, + 0x28d22b40, 0x289d1540, 0x28675280, 0x28310180, + 0x27fa3f00, 0x27c32f80, 0x278c08c0, 0x275505c0, + 0x271e60c0, 0x26e84b00, 0x26b2e880, 0x267e5cc0, + 0x264ac940, 0x26183a40, 0x25e6aa80, 0x25b615c0, + 0x25866b80, 0x25576b40, 0x2528ba00, 0x24f9ffc0, + 0x24cadfc0, 0x249af540, 0x2469da80, 0x24372780, + 0x2402b800, 0x23ccbfc0, 0x23957cc0, 0x235d3140, + 0x23245200, 0x22eb8000, 0x22b35cc0, 0x227c7940, + 0x22471d40, 0x22136840, 0x21e18240, 0x21b15d80, + 0x21827dc0, 0x21544600, 0x21261b00, 0x20f78600, + 0x20c83e00, 0x20980000, 0x20668e00, 0x2033f300, + 0x20007400, 0x1fcc64e0, 0x1f97d120, 0x1f642320, + 0x1f2f49e0, 0x1efaa840, 0x1ec73580, 0x1e94d880, + 0x1e636120, 0x1e32a160, 0x1e025ba0, 0x1dd24300, + 0x1da20e60, 0x1d717940, 0x1d407560, 0x1d0f2040, + 0x1cdd95c0, 0x1cabf500, 0x1c7a6940, 0x1c492340, + 0x1c185680, 0x1be818c0, 0x1bb83f60, 0x1b888d20, + 0x1b58c640, 0x1b28c240, 0x1af871e0, 0x1ac7c960, + 0x1a96bf00, 0x1a656b60, 0x1a340360, 0x1a02bd20, + 0x19d1c6c0, 0x19a12f40, 0x1970f480, 0x19411640, + 0x19119000, 0x18e255a0, 0x18b358a0, 0x18848b20, + 0x1855e040, 0x18274e00, 0x17f8c9e0, 0x17ca4a80, + 0x179bce40, 0x176d5a60, 0x173ef400, 0x17109fe0, + 0x16e25f60, 0x16b43240, 0x16861880, 0x16581220, + 0x162a20c0, 0x15fc4620, 0x15ce8420, 0x15a0dca0, + 0x157351c0, 0x1545e580, 0x151899a0, 0x14eb6ec0, + 0x14be63a0, 0x14917a00, 0x14649ae0, 0x14377060, + 0x1409d0c0, 0x13dbbb20, 0x13ad58e0, 0x137f0160, + 0x1350cc80, 0x1322b8c0, 0x12f4ca60, 0x12c704e0, + 0x129968a0, 0x126bf5c0, 0x123eade0, 0x12119300, + 0x11e4a660, 0x11b7e860, 0x118b5940, 0x115ef8a0, + 0x1132c600, 0x1106c1a0, 0x10daecc0, 0x10af4900, + 0x1083d7a0, 0x10589c00, 0x102d9a00, 0x1002d1e0, + 0x0fd842c0, 0x0fadde80, 0x0f839a50, 0x0f597700, + 0x0f2f76e0, 0x0f05a170, 0x0edbf9c0, 0x0eb27f30, + 0x0e8930d0, 0x0e600d70, 0x0e371550, 0x0e0e4950, + 0x0de5ab50, 0x0dbd3d20, 0x0d94fe10, 0x0d6cecb0, + 0x0d450220, 0x0d1d38f0, 0x0cf59130, 0x0cce0c30, + 0x0ca6af10, 0x0c7f7b80, 0x0c587010, 0x0c318960, + 0x0c0ac200, 0x0be418d0, 0x0bbd8da0, 0x0b9724e0, + 0x0b70e6c0, 0x0b4ad970, 0x0b2502f0, 0x0aff6930, + 0x0ada1250, 0x0ab50430, 0x0a9044d0, 0x0a6bda30, + 0x0a3bedf0, 0x0a18be40, 0x09f5e530, 0x09d35cf0, + 0x09b11ff0, 0x098f2890, 0x096d7120, 0x094bf400, + 0x092aab80, 0x09099240, 0x08e8a620, 0x08c7e850, + 0x08a75990, 0x0886fae0, 0x0866ccf0, 0x0846d070, + 0x08270610, 0x08076e70, 0x07e80ac8, 0x07c8dc60, + 0x07a9e440, 0x078b2348, 0x076c99d0, 0x074e4818, + 0x07302e50, 0x07124d18, 0x06f4a530, 0x06d73778, + 0x06ba0488, 0x069d0c88, 0x06804f68, 0x0663cce0, + 0x06478528, 0x062b78a0, 0x060fa7e8, 0x05f413b8, + 0x05d8bc38, 0x05bda128, 0x05a2c258, 0x05881f60, + 0x056db888, 0x05538e60, 0x0539a170, 0x051ff218, + 0x05068040, 0x04ed4b90, 0x04d45398, 0x04bb9820, + 0x04a31988, 0x048ad860, 0x0472d528, 0x045b0ff0, + 0x04438860, 0x042c3de8, 0x04153040, 0x03fe5f4c, + 0x03e7cb98, 0x03d17580, 0x03bb5d64, 0x03a582e8, + 0x038fe588, 0x037a8494, 0x03655fcc, 0x03507768, + 0x033bcbb4, 0x03275d28, 0x03132bc0, 0x02ff370c, + 0x02eb7e94, 0x02d801e8, 0x02c4c11c, 0x02b1bcbc, + 0x029ef578, 0x028c6ba8, 0x027a1f20, 0x02680f54, + 0x02563bac, 0x0244a3c8, 0x023347a0, 0x02222730, + 0x0211429c, 0x02009938, 0x01f02974, 0x01dff1ae, + 0x01cff058, 0x01c024c8, 0x01b08ef4, 0x01a12eda, + 0x019204b0, 0x01831138, 0x01745588, 0x0165d2c2, + 0x01578a96, 0x01497ffc, 0x013bb670, 0x012e3160, + 0x0120f146, 0x0113f27c, 0x0107310c, 0x00faa909, + 0x00ee57a1, 0x00e23b09, 0x00d6515b, 0x00ca9977, + 0x00bf1509, 0x00b3c74d, 0x00a8b388, 0x009ddb3d, + 0x00933bf2, 0x0088d22c, 0x007e9a70, 0x0074935a, + 0x006abe70, 0x00611d5c, 0x0057b1f8, 0x004e7e73, + 0x0045859b, 0x003cca96, 0x00344f32, 0x002c1074, + 0x00240873, 0x001c31ba, 0x0014863f, 0x000cfe8b, + 0x00059307, 0xfffe3b9a, 0xfff6f718, 0xffefcd4d, + 0xffe8c6f4, 0xffe1ed10, 0xffdb4c57, 0xffd4f484, + 0xffcef5dc, 0xffc95d0c, 0xffc4284e, 0xffbf4e14, + 0xffbac5ae, 0xffb68360, 0xffb27548, 0xffae87be, + 0xffaaa733, 0xffa6c67e, 0xffa2e141, 0xff9ef40c, + 0xff9afc25, 0xff970058, 0xff930f7c, 0xff8f3857, + 0xff8b8900, 0xff880bfe, 0xff84c9ea, 0xff81cbbd, + 0xff7f17ad, 0xff7cadc6, 0xff7a8c4e, 0xff78b1cd, + 0xff7719f3, 0xff75bd06, 0xff7492a4, 0xff7392bf, + 0xff72b600, 0xff71f5c6, 0xff714b72, 0xff70b0ed, + 0xff702232, 0xff6f9c90, 0xff6f1cee, 0xff6ea21f, + 0xff6e2e9c, 0xff6dc617, 0xff6d6c09, 0xff6d2425, + 0xff6cf267, 0xff6cdaca, 0xff6ce155, 0xff6d0983, + 0xff6d56bb, 0xff6dcc4c, 0xff6e6cd0, 0xff6f3832, + 0xff702cc4, 0xff71492e, 0xff728ae2, 0xff73ed63, + 0xff756b7c, 0xff77001c, 0xff78a5d9, 0xff7a5693, + 0xff7c0c40, 0xff7dc141, 0xff7f74aa, 0xff81298b, + 0xff82e2de, 0xff84a3de, 0xff8670bd, 0xff884e42, + 0xff8a410c, 0xff8c4c7f, 0xff8e70fc, 0xff90ae18, + 0xff93037e, 0xff956f12, 0xff97ec86, 0xff9a7724, + 0xff9d0a9d, 0xff9fa3ea, 0xffa2417e, 0xffa4e1ac, + 0xffa78332, 0xffaa265a, 0xffaccc26, 0xffaf758e, + 0xffb223d4, 0xffb4d906, 0xffb79726, 0xffba604e, + 0xffbd349e, 0xffc011a8, 0xffc2f4d2, 0xffc5db82, + 0xffc8c45f, 0xffcbaed5, 0xffce9a6d, 0xffd186c6, + 0xffd473aa, 0xffd760e5, 0xffda4e55, 0xffdd3bd0, + 0xffe0292b, 0xffe31645, 0xffe602ff, 0xffe8eef7, + 0xffebd978, 0xffeec1bf, 0xfff1a72c, 0xfff488fe, + 0xfff76689, 0xfffa3f2c, 0xfffd1245, 0xffffdf33, + 0x000020ac, 0x0002e66f, 0x0005a937, 0x00086839, + 0x000b22b3, 0x000dd7da, 0x001086ec, 0x00132f3c, + 0x0015d001, 0x00186897, 0x001af849, 0x001d7eb6, + 0x001ffbbe, 0x00226f41, 0x0024d8e8, 0x00273874, + 0x00298d82, 0x002bd7aa, 0x002e16d4, 0x00304af6, + 0x00327406, 0x00349203, 0x0036a416, 0x0038a893, + 0x003a9da0, 0x003c8170, 0x003e53b8, 0x0040159a, + 0x0041c816, 0x00436c92, 0x0045042c, 0x00468ff2, + 0x00481106, 0x004987fe, 0x004af466, 0x004c5599, + 0x004daae4, 0x004ef28c, 0x005029c4, 0x00514d9a, + 0x00525b57, 0x005351f7, 0x00543190, 0x0054fa43, + 0x0055ac2f, 0x00564938, 0x0056d3f7, 0x00574f3c, + 0x0057bdd7, 0x00582260, 0x00587f28, 0x0058d6b1, + 0x0059293c, 0x0059741a, 0x0059b472, 0x0059e73c, + 0x005a0976, 0x005a1870, 0x005a116e, 0x0059f224, + 0x0059b964, 0x005966ce, 0x0058f9e2, 0x005872e8, + 0x0057d407, 0x00571f82, 0x005657b0, 0x00557ecd, + 0x00549731, 0x0053a34b, 0x0052a56a, 0x00519fc6, + 0x00509482, 0x004f85a4, 0x004e74ee, 0x004d6214, + 0x004c4bd3, 0x004b314c, 0x004a1110, 0x0048e8c8, + 0x0047b5f7, 0x00467626, 0x00452690, 0x0043c405, + 0x00424b7f, 0x0040ba04, 0x003f0e53, 0x003d488b, + 0x003b688c, 0x00396eb6, 0x00375dfb, 0x00353aaa, + 0x003308ac, 0x0030ccb1, 0x002e8cf1, 0x002c4fd5, + 0x002a1be8, 0x0027f486, 0x0025d90d, 0x0023c852, + 0x0021c13b, 0x001fbf23, 0x001dbafc, 0x001badc6, + 0x00199136, 0x00176150, 0x00151b86, 0x0012bcd1, + 0x001044d1, 0x000db8d0, 0x000b1f43, 0x00087e89, + 0x0005dbe2, 0x00033b1e, 0x00009fee, 0xfffe0d82, + 0xfffb83cf, 0xfff90047, 0xfff6805a, 0xfff4019a, + 0xfff18203, 0xffeeffb2, 0xffec78ba, 0xffe9ec4d, + 0xffe75b4e, 0xffe4c71f, 0xffe23138, 0xffdf9ae6, + 0xffdd0574, 0xffda723c, 0xffd7e24a, 0xffd55567, + 0xffd2cabe, 0xffd04161, 0xffcdb890, 0xffcb306a, + 0xffc8a95c, 0xffc62406, 0xffc3a140, 0xffc12188, + 0xffbea542, 0xffbc2cc2, 0xffb9b7d2, 0xffb745f2, + 0xffb4d6ac, 0xffb268fe, 0xffaffc72, 0xffad90e8, + 0xffab263e, 0xffa8bcb8, 0xffa6547e, 0xffa3ed7b, + 0xffa187ba, 0xff9f2351, 0xff9cc055, 0xff9a5ebc, + 0xff97fe84, 0xff959f84, 0xff934146, 0xff90e37d, + 0xff8e858a, 0xff8c26c0, 0xff89c69e, 0xff876483, + 0xff84ffe4, 0xff82982b, 0xff802cb6, 0xff7dbccf, + 0xff7b47b4, 0xff78ccd0, 0xff764b6c, 0xff73c2db, + 0xff713227, 0xff6e9864, 0xff6bf470, 0xff694553, + 0xff668a0d, 0xff63c1a6, 0xff60ec34, 0xff5e0e9e, + 0xff5b30d3, 0xff585b8c, 0xff5595c9, 0xff52e1da, + 0xff5040a0, 0xff4db31c, 0xff4b3a3b, 0xff48d67e, + 0xff468850, 0xff445011, 0xff422ded, 0xff4021f9, + 0xff3e2c56, 0xff3c4cf8, 0xff3a83df, 0xff38d0ec, + 0xff3733c9, 0xff35ac14, 0xff343963, 0xff32db09, + 0xff319066, 0xff305898, 0xff2f323d, 0xff2e1bb2, + 0xff2d1369, 0xff2c18f8, 0xff2b2d2a, 0xff2a50e1, + 0xff2984f4, 0xff28c978, 0xff281e01, 0xff278245, + 0xff26f5c3, 0xff26785a, 0xff2609bf, 0xff25a9c8, + 0xff255814, 0xff2513f6, 0xff24dcc4, 0xff24b1a6, + 0xff2492b1, 0xff248093, 0xff247c0b, 0xff2485c6, + 0xff249daf, 0xff24c359, 0xff24f639, 0xff253605, + 0xff258312, 0xff25ddd5, 0xff2646e7, 0xff26be25, + 0xff274264, 0xff27d1f6, 0xff286b19, 0xff290c13, + 0xff29b30d, 0xff2a5e38, 0xff2b0bbd, 0xff2bb9a2, + 0xff29a9d2, 0xff2a53dc, 0xff2b0a5a, 0xff2bcd43, + 0xff2c9c76, 0xff2d7808, 0xff2e5ffa, 0xff2f544c, + 0xff305528, 0xff316299, 0xff327ce0, 0xff33a432, + 0xff34d8ba, 0xff361a8e, 0xff3768f8, 0xff38c2f5, + 0xff3a2784, 0xff3b9623, 0xff3d0ef4, 0xff3e9277, + 0xff4020ed, 0xff41ba14, 0xff435ccc, 0xff4507fd, + 0xff46ba84, 0xff4873ac, 0xff4a32ea, 0xff4bf7bb, + 0xff4dc17f, 0xff4f8fa0, 0xff516167, 0xff53361d, + 0xff550d79, 0xff56e7ee, 0xff58c5ff, 0xff5aa84d, + 0xff5c8e41, 0xff5e75e2, 0xff605d4d, 0xff6242b6, + 0xff6424b8, 0xff66023d, 0xff67da44, 0xff69abd6, + 0xff6b7646, 0xff6d38e8, 0xff6ef348, 0xff70a4ce, + 0xff724d0f, 0xff73eb95, 0xff757fff, 0xff770a2d, + 0xff788a20, 0xff79fff6, 0xff7b6be7, 0xff7cce52, + 0xff7e27e4, 0xff7f78fc, 0xff80c38a, 0xff820e98, + 0xff836378, 0xff84caaa, 0xff864990, 0xff87dff4, + 0xff898c30, 0xff8b4cda, 0xff8d207a, 0xff8f05cc, + 0xff90fb9b, 0xff930098, 0xff95138e, 0xff97332d, + 0xff995e2a, 0xff9b934e, 0xff9dd18c, 0xffa017e3, + 0xffa26550, 0xffa4b8e7, 0xffa711a8, 0xffa96eae, + 0xffabcefc, 0xffae31cc, 0xffb09680, 0xffb2fc82, + 0xffb5635a, 0xffb7ca52, 0xffba30a8, 0xffbc95a8, + 0xffbef8a4, 0xffc158d0, 0xffc3b557, 0xffc60d6b, + 0xffc86041, 0xffcaacb7, 0xffccf1cb, 0xffcf2e5c, + 0xffd161e8, 0xffd38c8f, 0xffd5ae88, 0xffd7c808, + 0xffd9d925, 0xffdbe1c8, 0xffdde1f3, 0xffdfd964, + 0xffe1c79b, 0xffe3abcc, 0xffe5852a, 0xffe75341, + 0xffe9162f, 0xffeace55, 0xffec7c15, 0xffee1f63, + 0xffefb7e9, 0xfff1453d, 0xfff2c6fd, 0xfff43ca8, + 0xfff5a5d4, 0xfff701ea, 0xfff850b4, 0xfff99288, + 0xfffac853, 0xfffbf2d5, 0xfffd12e6, 0xfffe2991, + 0xffff37e4, 0x00003eea, 0x00013ec4, 0x00023646, + 0x0003244d, 0x00040797, 0x0004de8c, 0x0005a734, + 0x00065fab, 0x0007068f, 0x00079c82, 0x000822fa, + 0x00089b70, 0x000907a6, 0x00096a01, 0x0009c506, + 0x000a1b37, 0x000a6e18, 0x000abe1f, 0x000b0bac, + 0x000b5701, 0x000b9f3b, 0x000be2c2, 0x000c1fff, + 0x000c5599, 0x000c829a, 0x000ca661, 0x000cc058, + 0x000cd028, 0x000cd63d, 0x000cd317, 0x000cc739, + 0x000cb36d, 0x000c98c0, 0x000c7833, 0x000c52df, + 0x000c2984, 0x000bfcf9, 0x000bcdea, 0x000b9cf7, + 0x000b6a97, 0x000b3700, 0x000b029d, 0x000acd79, + 0x000a977e, 0x000a6076, 0x000a2838, 0x0009eea1, + 0x0009b37d, 0x000976c2, 0x0009384e, 0x0008f816, + 0x0008b612, 0x0008724a, 0x00082cd5, 0x0007e5e8, + 0x00079dce, 0x000754de, 0x00070b62, 0x0006c1c6, + 0x0006786a, 0x00062fba, 0x0005e801, 0x0005a1a0, + 0x00055ce1, 0x000519fb, 0x0004d8f8, 0x000499b8, + 0x00045c30, 0x00042040, 0x0003e5c8, 0x0003acb3, + 0x000374df, 0x00033e59, 0x00030934, 0x0002d57d, + 0x0002a348, 0x000272b6, 0x000243f2, 0x00021711, + 0x0001ec3e, 0x0001c37a, 0x00019cc3, 0x00017830, + 0x000155a0, 0x00013514, 0x0001168b, 0x0000f9e6, + 0x0000df23, 0x0000c62e, 0x0000aef2, 0x00009978, + 0x000085a1, 0x0000736d, 0x000062dc, 0x000053d8, + 0x0000466c, 0x00003a62, 0x00002fd1, 0x00002681, + 0x00001e73, 0x00001792, 0x000011c9, 0x00000cf6, + 0x0000091a, 0x000005ff, 0x000003b1, 0x00000203, + 0x000000d7, 0x0000002b, 0xffffffd5, 0xffffffc0, + 0xffffffd5, 0x00000000, 0x00000015, 0x00000000, + 0x00000000, 0x00000015, 0x00000000, 0xffffffd5, + 0xffffffca, 0xffffffd5, 0x0000002b, 0x000000cc, + 0x000001e3, 0x0000037b, 0x0000059f, 0x0000086e, + 0x00000bf4, 0x0000103b, 0x00001564, 0x00001b6e, + 0x0000226f, 0x00002a68, 0x00003377, 0x00003d93, + 0x000048c5, 0x00005525, 0x000062a6, 0x00007155, + 0x0000812f, 0x00009237, 0x0000a455, 0x0000b7ab, + 0x0000cc18, 0x0000e1bd, 0x0000f878, 0x0001106c, + 0x00012981, 0x000143c2, 0x00015f30, 0x00017bb6, + 0x00019948, 0x0001b7e6, 0x0001d771, 0x0001f7bc, + 0x000218b4, 0x00023a42, 0x00025c3b, 0x00027ea0, + 0x0002a150, 0x0002c440, 0x0002e771, 0x00030aed, + 0x00032eb4, 0x000352db, 0x00037759, 0x00039c4c, + 0x0003c1ac, 0x0003e74b, 0x00040d00, 0x0004329f, + 0x000457de, 0x00047c9c, 0x0004a083, 0x0004c35e, + 0x0004e502, 0x00050543, 0x000523ec, 0x000540e7, + 0x00055c2b, 0x000575c0, 0x00058da9, 0x0005a3e4, + 0x0005b886, 0x0005cbb1, 0x0005dd65, 0x0005edcb, + 0x0005fcfa, 0x00060afc, 0x00061808, 0x000623fc, + 0x00062ec3, 0x00063849, 0x0006404b, 0x000646ac, + 0x00064b13, 0x00064d37, 0x00064cd6, 0x0006497b, + 0x000642c5, 0x0006385e, 0x000629f0, 0x00061766, + 0x000600a0, 0x0005e57d, 0x0005c63e, 0x0005a322, + 0x00057c97, 0x00055306, 0x00052711, 0x0004f96f, + 0x0004caeb, 0x00049bfc, 0x00046c96, 0x00043cbb, + 0x00040c3f, 0x0003daab, 0x0003a734, 0x000370f9, + 0x0003372d, 0x0002f944, 0x0002b6d4, 0x00026f71, + 0x000222fb, 0x0001d212, 0x00017d84, 0x00012630, + 0x0000ccda, 0x00007200, 0x0000163b, 0xffffba15, + 0xffff5da3, 0xffff0091, 0xfffea293, 0xfffe4367, + 0xfffde2da, 0xfffd809f, 0xfffd1c81, 0xfffcb66a, + 0xfffc4e90, 0xfffbe53e, 0xfffb7aa0, 0xfffb0f0a, + 0xfffaa2c9, 0xfffa3612, 0xfff9c92f, 0xfff95c2d, + 0xfff8eef4, 0xfff8817c, 0xfff813c3, 0xfff7a5d4, + 0xfff737e5, 0xfff6ca17, 0xfff65c9e, 0xfff5efbc, + 0xfff58390, 0xfff51830, 0xfff4adbc, 0xfff44435, + 0xfff3db9a, 0xfff373d6, 0xfff30cfd, 0xfff2a71c, + 0xfff24248, 0xfff1de9f, 0xfff17c44, 0xfff11b56, + 0xfff0bbea, 0xfff05e17, 0xfff00206, 0xffefa7d9, + 0xffef4f99, 0xffeef95d, 0xffeea53a, 0xffee533a, + 0xffee035e, 0xffedb5b0, 0xffed6a3c, 0xffed20f5, + 0xffecd9fe, 0xffec9555, 0xffec5305, 0xffec1319, + 0xffebd591, 0xffeb9a83, 0xffeb61f9, 0xffeb2bfe, + 0xffeaf89c, 0xffeac7ea, 0xffea99d2, 0xffea6e7e, + 0xffea45ef, 0xffea203a, 0xffe9fda0, 0xffe9decc, + 0xffe9c3de, 0xffe9ac56, 0xffe99789, 0xffe9845e, + 0xffe97295, 0xffe96219, 0xffe952ea, 0xffe944f3, + 0xffe93833, 0xffe92c9f, 0xffe92238, 0xffe918fe, + 0xffe910fb, 0xffe90a3a, 0xffe904c6, 0xffe900a0, + 0xffe8fddb, 0xffe8fc83, 0xffe8fca4, 0xffe8fe3c, + 0xffe9016c, 0xffe9061e, 0xffe90c74, 0xffe9146c, + 0xffe91e11, 0xffe929a5, 0xffe93731, 0xffe946c0, + 0xffe95833, 0xffe96b7e, 0xffe98082, 0xffe9975e, + 0xffe9affd, 0xffe9ca5e, 0xffe9e68e, 0xffea0481, + 0xffea242b, 0xffea458e, 0xffea6894, 0xffea8d52, + 0xffeab3c8, 0xffeadc0c, 0xffeb05fe, 0xffeb31a7, + 0xffeb5ede, 0xffeb8da2, 0xffebbdf4, 0xffebefbd, + 0xffec231f, 0xffec5802, 0xffec8e5e, 0xffecc61c, + 0xffecff1c, 0xffed391e, 0xffed740c, 0xffedafb1, + 0xffedebe1, 0xffee287d, 0xffee654e, 0xffeea23f, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aactab.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aactab.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aactab.h 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aactab.h 2015-07-25 17:20:02.000000000 +0000 @@ -46,8 +46,13 @@ */ DECLARE_ALIGNED(32, extern float, ff_aac_kbd_long_1024)[1024]; DECLARE_ALIGNED(32, extern float, ff_aac_kbd_short_128)[128]; +DECLARE_ALIGNED(32, extern int, ff_aac_kbd_long_1024_fixed)[1024]; +DECLARE_ALIGNED(32, extern int, ff_aac_kbd_long_512_fixed)[512]; +DECLARE_ALIGNED(32, extern int, ff_aac_kbd_short_128_fixed)[128]; const DECLARE_ALIGNED(32, extern float, ff_aac_eld_window_512)[1920]; +const DECLARE_ALIGNED(32, extern int, ff_aac_eld_window_512_fixed)[1920]; const DECLARE_ALIGNED(32, extern float, ff_aac_eld_window_480)[1800]; +const DECLARE_ALIGNED(32, extern int, ff_aac_eld_window_480_fixed)[1800]; // @} /* @name number of scalefactor window bands for long and short transform windows respectively diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac_tablegen.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac_tablegen.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac_tablegen.c 2014-12-01 00:21:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac_tablegen.c 2015-07-21 17:20:03.000000000 +0000 @@ -33,5 +33,7 @@ WRITE_ARRAY("const", float, ff_aac_pow2sf_tab); + WRITE_ARRAY("const", float, ff_aac_pow34sf_tab); + return 0; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac_tablegen_decl.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac_tablegen_decl.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac_tablegen_decl.h 2015-03-13 17:34:43.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac_tablegen_decl.h 2015-07-21 17:20:03.000000000 +0000 @@ -28,9 +28,11 @@ #if CONFIG_HARDCODED_TABLES #define ff_aac_tableinit() extern const float ff_aac_pow2sf_tab[428]; +extern const float ff_aac_pow34sf_tab[428]; #else void ff_aac_tableinit(void); extern float ff_aac_pow2sf_tab[428]; +extern float ff_aac_pow34sf_tab[428]; #endif /* CONFIG_HARDCODED_TABLES */ #endif /* AVCODEC_AAC_TABLEGEN_DECL_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac_tablegen.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac_tablegen.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aac_tablegen.h 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aac_tablegen.h 2015-07-21 17:20:03.000000000 +0000 @@ -30,12 +30,15 @@ #else #include "libavutil/mathematics.h" float ff_aac_pow2sf_tab[428]; +float ff_aac_pow34sf_tab[428]; av_cold void ff_aac_tableinit(void) { int i; - for (i = 0; i < 428; i++) + for (i = 0; i < 428; i++) { ff_aac_pow2sf_tab[i] = pow(2, (i - POW_SF2_ZERO) / 4.0); + ff_aac_pow34sf_tab[i] = pow(ff_aac_pow2sf_tab[i], 3.0/4.0); + } } #endif /* CONFIG_HARDCODED_TABLES */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aarch64/h264pred_init.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aarch64/h264pred_init.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aarch64/h264pred_init.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aarch64/h264pred_init.c 2015-07-21 17:20:03.000000000 +0000 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2009 Mans Rullgard + * + * 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 + +#include "libavutil/attributes.h" +#include "libavutil/aarch64/cpu.h" +#include "libavcodec/avcodec.h" +#include "libavcodec/h264pred.h" + +void ff_pred16x16_vert_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_hor_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_plane_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_dc_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_128_dc_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_left_dc_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_top_dc_neon(uint8_t *src, ptrdiff_t stride); + +void ff_pred8x8_vert_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_hor_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_plane_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_dc_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_128_dc_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_left_dc_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_top_dc_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_l0t_dc_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_0lt_dc_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_l00_dc_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_0l0_dc_neon(uint8_t *src, ptrdiff_t stride); + +static av_cold void h264_pred_init_neon(H264PredContext *h, int codec_id, + const int bit_depth, + const int chroma_format_idc) +{ + const int high_depth = bit_depth > 8; + + if (high_depth) + return; + + if (chroma_format_idc <= 1) { + h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vert_neon; + h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_hor_neon; + if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) + h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon; + h->pred8x8[DC_128_PRED8x8 ] = ff_pred8x8_128_dc_neon; + if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 && + codec_id != AV_CODEC_ID_VP8) { + h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_neon; + h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon; + h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon; + h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = ff_pred8x8_l0t_dc_neon; + h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = ff_pred8x8_0lt_dc_neon; + h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = ff_pred8x8_l00_dc_neon; + h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = ff_pred8x8_0l0_dc_neon; + } + } + + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_neon; + h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vert_neon; + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_hor_neon; + h->pred16x16[LEFT_DC_PRED8x8] = ff_pred16x16_left_dc_neon; + h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon; + h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_neon; + if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 && + codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) + h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon; +} + +av_cold void ff_h264_pred_init_aarch64(H264PredContext *h, int codec_id, + int bit_depth, const int chroma_format_idc) +{ + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) + h264_pred_init_neon(h, codec_id, bit_depth, chroma_format_idc); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aarch64/h264pred_neon.S ffmpeg-2.7.2~trusty~ppa1/libavcodec/aarch64/h264pred_neon.S --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aarch64/h264pred_neon.S 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aarch64/h264pred_neon.S 2015-07-21 17:20:03.000000000 +0000 @@ -0,0 +1,361 @@ +/* + * Copyright (c) 2009 Mans Rullgard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/aarch64/asm.S" + +.macro ldcol.8 rd, rs, rt, n=8, hi=0 +.if \n >= 8 || \hi == 0 + ld1 {\rd\().b}[0], [\rs], \rt + ld1 {\rd\().b}[1], [\rs], \rt + ld1 {\rd\().b}[2], [\rs], \rt + ld1 {\rd\().b}[3], [\rs], \rt +.endif +.if \n >= 8 || \hi == 1 + ld1 {\rd\().b}[4], [\rs], \rt + ld1 {\rd\().b}[5], [\rs], \rt + ld1 {\rd\().b}[6], [\rs], \rt + ld1 {\rd\().b}[7], [\rs], \rt +.endif +.if \n == 16 + ld1 {\rd\().b}[8], [\rs], \rt + ld1 {\rd\().b}[9], [\rs], \rt + ld1 {\rd\().b}[10], [\rs], \rt + ld1 {\rd\().b}[11], [\rs], \rt + ld1 {\rd\().b}[12], [\rs], \rt + ld1 {\rd\().b}[13], [\rs], \rt + ld1 {\rd\().b}[14], [\rs], \rt + ld1 {\rd\().b}[15], [\rs], \rt +.endif +.endm + +function ff_pred16x16_128_dc_neon, export=1 + movi v0.16b, #128 + b .L_pred16x16_dc_end +endfunc + +function ff_pred16x16_top_dc_neon, export=1 + sub x2, x0, x1 + ld1 {v0.16b}, [x2] + uaddlv h0, v0.16b + rshrn v0.8b, v0.8h, #4 + dup v0.16b, v0.b[0] + b .L_pred16x16_dc_end +endfunc + +function ff_pred16x16_left_dc_neon, export=1 + sub x2, x0, #1 + ldcol.8 v0, x2, x1, 16 + uaddlv h0, v0.16b + rshrn v0.8b, v0.8h, #4 + dup v0.16b, v0.b[0] + b .L_pred16x16_dc_end +endfunc + +function ff_pred16x16_dc_neon, export=1 + sub x2, x0, x1 + sub x3, x0, #1 + ld1 {v0.16b}, [x2] + ldcol.8 v1, x3, x1, 16 + uaddlv h0, v0.16b + uaddlv h1, v1.16b + add v0.4h, v0.4h, v1.4h + rshrn v0.8b, v0.8h, #5 + dup v0.16b, v0.b[0] +.L_pred16x16_dc_end: + mov w3, #8 +6: st1 {v0.16b}, [x0], x1 + st1 {v0.16b}, [x0], x1 + subs w3, w3, #1 + b.ne 6b + ret +endfunc + +function ff_pred16x16_hor_neon, export=1 + sub x2, x0, #1 + mov w3, #16 +1: ld1r {v0.16b}, [x2], x1 + st1 {v0.16b}, [x0], x1 + subs w3, w3, #1 + b.ne 1b + ret +endfunc + +function ff_pred16x16_vert_neon, export=1 + sub x2, x0, x1 + add x1, x1, x1 + ld1 {v0.16b}, [x2], x1 + mov w3, #8 +1: st1 {v0.16b}, [x0], x1 + st1 {v0.16b}, [x2], x1 + subs w3, w3, #1 + b.ne 1b + ret +endfunc + +function ff_pred16x16_plane_neon, export=1 + sub x3, x0, x1 + movrel x4, p16weight + add x2, x3, #8 + sub x3, x3, #1 + ld1 {v0.8b}, [x3] + ld1 {v2.8b}, [x2], x1 + ldcol.8 v1, x3, x1 + add x3, x3, x1 + ldcol.8 v3, x3, x1 + rev64 v0.8b, v0.8b + rev64 v1.8b, v1.8b + uaddl v7.8h, v2.8b, v3.8b + usubl v2.8h, v2.8b, v0.8b + usubl v3.8h, v3.8b, v1.8b + ld1 {v0.8h}, [x4] + mul v2.8h, v2.8h, v0.8h + mul v3.8h, v3.8h, v0.8h + addp v2.8h, v2.8h, v3.8h + addp v2.8h, v2.8h, v2.8h + addp v2.4h, v2.4h, v2.4h + sshll v3.4s, v2.4h, #2 + saddw v2.4s, v3.4s, v2.4h + rshrn v4.4h, v2.4s, #6 + trn2 v5.4h, v4.4h, v4.4h + add v2.4h, v4.4h, v5.4h + shl v3.4h, v2.4h, #3 + ext v7.16b, v7.16b, v7.16b, #14 + sub v3.4h, v3.4h, v2.4h // 7 * (b + c) + add v7.4h, v7.4h, v0.4h + shl v2.4h, v7.4h, #4 + sub v2.4h, v2.4h, v3.4h + shl v3.4h, v4.4h, #4 + ext v0.16b, v0.16b, v0.16b, #14 + sub v6.4h, v5.4h, v3.4h + mov v0.h[0], wzr + mul v0.8h, v0.8h, v4.h[0] + dup v1.8h, v2.h[0] + dup v2.8h, v4.h[0] + dup v3.8h, v6.h[0] + shl v2.8h, v2.8h, #3 + add v1.8h, v1.8h, v0.8h + add v3.8h, v3.8h, v2.8h + mov w3, #16 +1: + sqshrun v0.8b, v1.8h, #5 + add v1.8h, v1.8h, v2.8h + sqshrun2 v0.16b, v1.8h, #5 + add v1.8h, v1.8h, v3.8h + st1 {v0.16b}, [x0], x1 + subs w3, w3, #1 + b.ne 1b + ret +endfunc + +const p16weight, align=4 + .short 1,2,3,4,5,6,7,8 +endconst +const p8weight, align=4 + .short 1,2,3,4,1,2,3,4 +endconst + +function ff_pred8x8_hor_neon, export=1 + sub x2, x0, #1 + mov w3, #8 +1: ld1r {v0.8b}, [x2], x1 + st1 {v0.8b}, [x0], x1 + subs w3, w3, #1 + b.ne 1b + ret +endfunc + +function ff_pred8x8_vert_neon, export=1 + sub x2, x0, x1 + lsl x1, x1, #1 + ld1 {v0.8b}, [x2], x1 + mov w3, #4 +1: st1 {v0.8b}, [x0], x1 + st1 {v0.8b}, [x2], x1 + subs w3, w3, #1 + b.ne 1b + ret +endfunc + +function ff_pred8x8_plane_neon, export=1 + sub x3, x0, x1 + movrel x4, p8weight + movrel x5, p16weight + add x2, x3, #4 + sub x3, x3, #1 + ld1 {v0.s}[0], [x3] + ld1 {v2.s}[0], [x2], x1 + ldcol.8 v0, x3, x1, 4, hi=1 + add x3, x3, x1 + ldcol.8 v3, x3, x1, 4 + uaddl v7.8h, v2.8b, v3.8b + rev32 v0.8b, v0.8b + trn1 v2.2s, v2.2s, v3.2s + usubl v2.8h, v2.8b, v0.8b + ld1 {v6.8h}, [x4] + mul v2.8h, v2.8h, v6.8h + ld1 {v0.8h}, [x5] + saddlp v2.4s, v2.8h + addp v2.4s, v2.4s, v2.4s + shl v3.4s, v2.4s, #4 + add v2.4s, v3.4s, v2.4s + rshrn v5.4h, v2.4s, #5 + addp v2.4h, v5.4h, v5.4h + shl v3.4h, v2.4h, #1 + add v3.4h, v3.4h, v2.4h + rev64 v7.4h, v7.4h + add v7.4h, v7.4h, v0.4h + shl v2.4h, v7.4h, #4 + sub v2.4h, v2.4h, v3.4h + ext v0.16b, v0.16b, v0.16b, #14 + mov v0.h[0], wzr + mul v0.8h, v0.8h, v5.h[0] + dup v1.8h, v2.h[0] + dup v2.8h, v5.h[1] + add v1.8h, v1.8h, v0.8h + mov w3, #8 +1: + sqshrun v0.8b, v1.8h, #5 + add v1.8h, v1.8h, v2.8h + st1 {v0.8b}, [x0], x1 + subs w3, w3, #1 + b.ne 1b + ret +endfunc + +function ff_pred8x8_128_dc_neon, export=1 + movi v0.8b, #128 + movi v1.8b, #128 + b .L_pred8x8_dc_end +endfunc + +function ff_pred8x8_top_dc_neon, export=1 + sub x2, x0, x1 + ld1 {v0.8b}, [x2] + uaddlp v0.4h, v0.8b + addp v0.4h, v0.4h, v0.4h + zip1 v0.8h, v0.8h, v0.8h + rshrn v2.8b, v0.8h, #2 + zip1 v0.8b, v2.8b, v2.8b + zip1 v1.8b, v2.8b, v2.8b + b .L_pred8x8_dc_end +endfunc + +function ff_pred8x8_left_dc_neon, export=1 + sub x2, x0, #1 + ldcol.8 v0, x2, x1 + uaddlp v0.4h, v0.8b + addp v0.4h, v0.4h, v0.4h + rshrn v2.8b, v0.8h, #2 + dup v1.8b, v2.b[1] + dup v0.8b, v2.b[0] + b .L_pred8x8_dc_end +endfunc + +function ff_pred8x8_dc_neon, export=1 + sub x2, x0, x1 + sub x3, x0, #1 + ld1 {v0.8b}, [x2] + ldcol.8 v1, x3, x1 + uaddlp v0.4h, v0.8b + uaddlp v1.4h, v1.8b + trn1 v2.2s, v0.2s, v1.2s + trn2 v3.2s, v0.2s, v1.2s + addp v4.4h, v2.4h, v3.4h + addp v5.4h, v4.4h, v4.4h + rshrn v6.8b, v5.8h, #3 + rshrn v7.8b, v4.8h, #2 + dup v0.8b, v6.b[0] + dup v2.8b, v7.b[2] + dup v1.8b, v7.b[3] + dup v3.8b, v6.b[1] + zip1 v0.2s, v0.2s, v2.2s + zip1 v1.2s, v1.2s, v3.2s +.L_pred8x8_dc_end: + mov w3, #4 + add x2, x0, x1, lsl #2 +6: st1 {v0.8b}, [x0], x1 + st1 {v1.8b}, [x2], x1 + subs w3, w3, #1 + b.ne 6b + ret +endfunc + +function ff_pred8x8_l0t_dc_neon, export=1 + sub x2, x0, x1 + sub x3, x0, #1 + ld1 {v0.8b}, [x2] + ldcol.8 v1, x3, x1, 4 + zip1 v0.4s, v0.4s, v1.4s + uaddlp v0.8h, v0.16b + addp v0.8h, v0.8h, v0.8h + addp v1.4h, v0.4h, v0.4h + rshrn v2.8b, v0.8h, #2 + rshrn v3.8b, v1.8h, #3 + dup v4.8b, v3.b[0] + dup v6.8b, v2.b[2] + dup v5.8b, v2.b[0] + zip1 v0.2s, v4.2s, v6.2s + zip1 v1.2s, v5.2s, v6.2s + b .L_pred8x8_dc_end +endfunc + +function ff_pred8x8_l00_dc_neon, export=1 + sub x2, x0, #1 + ldcol.8 v0, x2, x1, 4 + uaddlp v0.4h, v0.8b + addp v0.4h, v0.4h, v0.4h + rshrn v0.8b, v0.8h, #2 + movi v1.8b, #128 + dup v0.8b, v0.b[0] + b .L_pred8x8_dc_end +endfunc + +function ff_pred8x8_0lt_dc_neon, export=1 + add x3, x0, x1, lsl #2 + sub x2, x0, x1 + sub x3, x3, #1 + ld1 {v0.8b}, [x2] + ldcol.8 v1, x3, x1, 4, hi=1 + zip1 v0.4s, v0.4s, v1.4s + uaddlp v0.8h, v0.16b + addp v0.8h, v0.8h, v0.8h + addp v1.4h, v0.4h, v0.4h + rshrn v2.8b, v0.8h, #2 + rshrn v3.8b, v1.8h, #3 + dup v4.8b, v2.b[0] + dup v5.8b, v2.b[3] + dup v6.8b, v2.b[2] + dup v7.8b, v3.b[1] + zip1 v0.2s, v4.2s, v6.2s + zip1 v1.2s, v5.2s, v7.2s + b .L_pred8x8_dc_end +endfunc + +function ff_pred8x8_0l0_dc_neon, export=1 + add x2, x0, x1, lsl #2 + sub x2, x2, #1 + ldcol.8 v1, x2, x1, 4 + uaddlp v2.4h, v1.8b + addp v2.4h, v2.4h, v2.4h + rshrn v1.8b, v2.8h, #2 + movi v0.8b, #128 + dup v1.8b, v1.b[0] + b .L_pred8x8_dc_end +endfunc diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aarch64/Makefile ffmpeg-2.7.2~trusty~ppa1/libavcodec/aarch64/Makefile --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aarch64/Makefile 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aarch64/Makefile 2015-07-21 17:20:03.000000000 +0000 @@ -1,6 +1,7 @@ OBJS-$(CONFIG_FFT) += aarch64/fft_init_aarch64.o OBJS-$(CONFIG_H264CHROMA) += aarch64/h264chroma_init_aarch64.o OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_init_aarch64.o +OBJS-$(CONFIG_H264PRED) += aarch64/h264pred_init.o OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_init_aarch64.o OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_init_aarch64.o OBJS-$(CONFIG_IMDCT15) += aarch64/imdct15_init.o @@ -18,6 +19,7 @@ NEON-OBJS-$(CONFIG_H264CHROMA) += aarch64/h264cmc_neon.o NEON-OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_neon.o \ aarch64/h264idct_neon.o +NEON-OBJS-$(CONFIG_H264PRED) += aarch64/h264pred_neon.o NEON-OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_neon.o \ aarch64/hpeldsp_neon.o NEON-OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_neon.o diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aasc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aasc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aasc.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aasc.c 2015-07-28 17:20:07.000000000 +0000 @@ -158,5 +158,5 @@ .init = aasc_decode_init, .close = aasc_decode_end, .decode = aasc_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3dec.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -193,13 +193,13 @@ ff_bswapdsp_init(&s->bdsp); #if (USE_FIXED) - s->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & CODEC_FLAG_BITEXACT); + s->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT); #else - s->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); ff_fmt_convert_init(&s->fmt_conv, avctx); #endif - ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT); + ff_ac3dsp_init(&s->ac3dsp, avctx->flags & AV_CODEC_FLAG_BITEXACT); av_lfg_init(&s->dith_state, 0); if (USE_FIXED) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3dec_fixed.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3dec_fixed.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3dec_fixed.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3dec_fixed.c 2015-07-28 17:20:07.000000000 +0000 @@ -188,7 +188,7 @@ .init = ac3_decode_init, .close = ac3_decode_end, .decode = ac3_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3dec_float.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3dec_float.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3dec_float.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3dec_float.c 2015-07-28 17:20:07.000000000 +0000 @@ -60,7 +60,7 @@ .init = ac3_decode_init, .close = ac3_decode_end, .decode = ac3_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, @@ -83,7 +83,7 @@ .init = ac3_decode_init, .close = ac3_decode_end, .decode = ac3_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"), .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3dec.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3dec.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3dec.h 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3dec.h 2015-07-28 17:20:07.000000000 +0000 @@ -235,7 +235,7 @@ DECLARE_ALIGNED(32, INTFLOAT, window)[AC3_BLOCK_SIZE]; ///< window coefficients DECLARE_ALIGNED(32, INTFLOAT, tmp_output)[AC3_BLOCK_SIZE]; ///< temporary storage for output before windowing DECLARE_ALIGNED(32, SHORTFLOAT, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< output after imdct transform and windowing - DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread + DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread ///@} } AC3DecodeContext; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3enc.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3enc.c 2015-07-28 17:20:07.000000000 +0000 @@ -2484,7 +2484,7 @@ ff_audiodsp_init(&s->adsp); ff_me_cmp_init(&s->mecc, avctx); - ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT); + ff_ac3dsp_init(&s->ac3dsp, avctx->flags & AV_CODEC_FLAG_BITEXACT); dprint_options(s); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3enc_float.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3enc_float.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3enc_float.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3enc_float.c 2015-07-28 17:20:07.000000000 +0000 @@ -139,7 +139,7 @@ av_cold int ff_ac3_float_encode_init(AVCodecContext *avctx) { AC3EncodeContext *s = avctx->priv_data; - s->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!s->fdsp) return AVERROR(ENOMEM); return ff_ac3_encode_init(avctx); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3enc_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3enc_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3enc_template.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3enc_template.c 2015-07-28 17:20:07.000000000 +0000 @@ -438,7 +438,7 @@ ff_ac3_quantize_mantissas(s); - if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size, 0)) < 0) return ret; ff_ac3_output_frame(s, avpkt->data); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3_parser.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3_parser.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ac3_parser.c 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ac3_parser.c 2015-07-28 17:20:07.000000000 +0000 @@ -166,7 +166,7 @@ int err; union { uint64_t u64; - uint8_t u8[8 + FF_INPUT_BUFFER_PADDING_SIZE]; + uint8_t u8[8 + AV_INPUT_BUFFER_PADDING_SIZE]; } tmp = { av_be2ne64(state) }; AC3HeaderInfo hdr, *phdr = &hdr; GetBitContext gbc; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/adpcm.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/adpcm.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/adpcm.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/adpcm.c 2015-07-28 17:20:07.000000000 +0000 @@ -84,8 +84,9 @@ /* end of tables */ typedef struct ADPCMDecodeContext { - ADPCMChannelStatus status[6]; + ADPCMChannelStatus status[10]; int vqa_version; /**< VQA version. Used for ADPCM_IMA_WS */ + int has_status; } ADPCMDecodeContext; static av_cold int adpcm_decode_init(AVCodecContext * avctx) @@ -104,9 +105,12 @@ case AV_CODEC_ID_ADPCM_EA_R2: case AV_CODEC_ID_ADPCM_EA_R3: case AV_CODEC_ID_ADPCM_EA_XAS: - case AV_CODEC_ID_ADPCM_THP: max_channels = 6; break; + case AV_CODEC_ID_ADPCM_THP: + case AV_CODEC_ID_ADPCM_THP_LE: + max_channels = 10; + break; } if (avctx->channels < min_channels || avctx->channels > max_channels) { av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n"); @@ -145,6 +149,7 @@ case AV_CODEC_ID_ADPCM_EA_R3: case AV_CODEC_ID_ADPCM_EA_XAS: case AV_CODEC_ID_ADPCM_THP: + case AV_CODEC_ID_ADPCM_THP_LE: case AV_CODEC_ID_ADPCM_AFC: case AV_CODEC_ID_ADPCM_DTK: avctx->sample_fmt = AV_SAMPLE_FMT_S16P; @@ -636,15 +641,22 @@ break; } case AV_CODEC_ID_ADPCM_THP: + case AV_CODEC_ID_ADPCM_THP_LE: if (avctx->extradata) { - nb_samples = buf_size / (8 * ch) * 14; + nb_samples = buf_size * 14 / (8 * ch); break; } has_coded_samples = 1; bytestream2_skip(gb, 4); // channel size - *coded_samples = bytestream2_get_be32(gb); - *coded_samples -= *coded_samples % 14; - nb_samples = (buf_size - (8 + 36 * ch)) / (8 * ch) * 14; + *coded_samples = (avctx->codec->id == AV_CODEC_ID_ADPCM_THP_LE) ? + bytestream2_get_le32(gb) : + bytestream2_get_be32(gb); + buf_size -= 8 + 36 * ch; + buf_size /= ch; + nb_samples = buf_size / 8 * 14; + if (buf_size % 8 > 1) + nb_samples += (buf_size % 8 - 1) * 2; + *approx_nb_samples = 1; break; case AV_CODEC_ID_ADPCM_AFC: nb_samples = buf_size / (9 * ch) * 16; @@ -1415,10 +1427,17 @@ break; } case AV_CODEC_ID_ADPCM_THP: + case AV_CODEC_ID_ADPCM_THP_LE: { - int table[6][16]; + int table[10][16]; int ch; +#define THP_GET16(g) \ + sign_extend( \ + avctx->codec->id == AV_CODEC_ID_ADPCM_THP_LE ? \ + bytestream2_get_le16u(&(g)) : \ + bytestream2_get_be16u(&(g)), 16) + if (avctx->extradata) { GetByteContext tb; if (avctx->extradata_size < 32 * avctx->channels) { @@ -1429,24 +1448,29 @@ bytestream2_init(&tb, avctx->extradata, avctx->extradata_size); for (i = 0; i < avctx->channels; i++) for (n = 0; n < 16; n++) - table[i][n] = sign_extend(bytestream2_get_be16u(&tb), 16); + table[i][n] = THP_GET16(tb); } else { - for (i = 0; i < avctx->channels; i++) - for (n = 0; n < 16; n++) - table[i][n] = sign_extend(bytestream2_get_be16u(&gb), 16); + for (i = 0; i < avctx->channels; i++) + for (n = 0; n < 16; n++) + table[i][n] = THP_GET16(gb); - /* Initialize the previous sample. */ - for (i = 0; i < avctx->channels; i++) { - c->status[i].sample1 = sign_extend(bytestream2_get_be16u(&gb), 16); - c->status[i].sample2 = sign_extend(bytestream2_get_be16u(&gb), 16); - } + if (!c->has_status) { + /* Initialize the previous sample. */ + for (i = 0; i < avctx->channels; i++) { + c->status[i].sample1 = THP_GET16(gb); + c->status[i].sample2 = THP_GET16(gb); + } + c->has_status = 1; + } else { + bytestream2_skip(&gb, avctx->channels * 4); + } } for (ch = 0; ch < avctx->channels; ch++) { samples = samples_p[ch]; /* Read in every sample for this channel. */ - for (i = 0; i < nb_samples / 14; i++) { + for (i = 0; i < (nb_samples + 13) / 14; i++) { int byte = bytestream2_get_byteu(&gb); int index = (byte >> 4) & 7; unsigned int exp = byte & 0x0F; @@ -1454,7 +1478,7 @@ int factor2 = table[ch][index * 2 + 1]; /* Decode 14 samples. */ - for (n = 0; n < 14; n++) { + for (n = 0; n < 14 && (i * 14 + n < nb_samples); n++) { int32_t sampledat; if (n & 1) { @@ -1542,6 +1566,12 @@ return bytestream2_tell(&gb); } +static void adpcm_flush(AVCodecContext *avctx) +{ + ADPCMDecodeContext *c = avctx->priv_data; + c->has_status = 0; +} + static const enum AVSampleFormat sample_fmts_s16[] = { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }; @@ -1560,7 +1590,8 @@ .priv_data_size = sizeof(ADPCMDecodeContext), \ .init = adpcm_decode_init, \ .decode = adpcm_decode_frame, \ - .capabilities = CODEC_CAP_DR1, \ + .flush = adpcm_flush, \ + .capabilities = AV_CODEC_CAP_DR1, \ .sample_fmts = sample_fmts_, \ } @@ -1593,6 +1624,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_3, sample_fmts_s16, adpcm_sbpro_3, "ADPCM Sound Blaster Pro 2.6-bit"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_4, sample_fmts_s16, adpcm_sbpro_4, "ADPCM Sound Blaster Pro 4-bit"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_SWF, sample_fmts_s16, adpcm_swf, "ADPCM Shockwave Flash"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_THP, sample_fmts_s16p, adpcm_thp, "ADPCM Nintendo Gamecube THP"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_THP_LE, sample_fmts_s16p, adpcm_thp_le, "ADPCM Nintendo THP (little-endian)"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_THP, sample_fmts_s16p, adpcm_thp, "ADPCM Nintendo THP"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_XA, sample_fmts_s16p, adpcm_xa, "ADPCM CDROM XA"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_YAMAHA, sample_fmts_s16, adpcm_yamaha, "ADPCM Yamaha"); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/adpcmenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/adpcmenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/adpcmenc.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/adpcmenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -113,7 +113,7 @@ avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 / avctx->channels + 2; avctx->bits_per_coded_sample = 4; avctx->block_align = BLKSIZE; - if (!(avctx->extradata = av_malloc(32 + FF_INPUT_BUFFER_PADDING_SIZE))) + if (!(avctx->extradata = av_malloc(32 + AV_INPUT_BUFFER_PADDING_SIZE))) goto error; avctx->extradata_size = 32; extradata = avctx->extradata; @@ -486,7 +486,7 @@ pkt_size = (2 + avctx->channels * (22 + 4 * (frame->nb_samples - 1)) + 7) / 8; else pkt_size = avctx->block_align; - if ((ret = ff_alloc_packet2(avctx, avpkt, pkt_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, pkt_size, 0)) < 0) return ret; dst = avpkt->data; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/adxdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/adxdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/adxdec.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/adxdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -183,7 +183,7 @@ .init = adx_decode_init, .decode = adx_decode_frame, .flush = adx_decode_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/adxenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/adxenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/adxenc.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/adxenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -146,7 +146,7 @@ int ch, out_size, ret; out_size = BLOCK_SIZE * avctx->channels + !c->header_parsed * HEADER_SIZE; - if ((ret = ff_alloc_packet2(avctx, avpkt, out_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, out_size, 0)) < 0) return ret; dst = avpkt->data; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aic.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aic.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aic.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aic.c 2015-07-28 17:20:07.000000000 +0000 @@ -387,8 +387,11 @@ return AVERROR_INVALIDDATA; } - if ((ret = aic_decode_header(ctx, buf, buf_size)) < 0) + ret = aic_decode_header(ctx, buf, buf_size); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid header\n"); return ret; + } if ((ret = ff_get_buffer(avctx, ctx->frame, 0)) < 0) return ret; @@ -400,13 +403,17 @@ for (x = 0; x < ctx->mb_width; x += ctx->slice_width) { slice_size = bytestream2_get_le16(&gb) * 4; if (slice_size + off > buf_size || !slice_size) { - av_log(avctx, AV_LOG_ERROR, "Incorrect slice size\n"); + av_log(avctx, AV_LOG_ERROR, + "Incorrect slice size %d at %d.%d\n", slice_size, x, y); return AVERROR_INVALIDDATA; } - if ((ret = aic_decode_slice(ctx, x, y, - buf + off, slice_size)) < 0) + ret = aic_decode_slice(ctx, x, y, buf + off, slice_size); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, + "Error decoding slice at %d.%d\n", x, y); return ret; + } off += slice_size; } @@ -441,7 +448,7 @@ ctx->num_x_slices = (ctx->mb_width + 15) >> 4; ctx->slice_width = 16; for (i = 1; i < 32; i++) { - if (!(ctx->mb_width % i) && (ctx->mb_width / i < 32)) { + if (!(ctx->mb_width % i) && (ctx->mb_width / i <= 32)) { ctx->slice_width = ctx->mb_width / i; ctx->num_x_slices = i; break; @@ -481,5 +488,5 @@ .init = aic_decode_init, .close = aic_decode_close, .decode = aic_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/alac.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/alac.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/alac.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/alac.c 2015-07-28 17:20:07.000000000 +0000 @@ -534,6 +534,12 @@ int ch; int buf_size = alac->max_samples_per_frame * sizeof(int32_t); + for (ch = 0; ch < 2; ch++) { + alac->predict_error_buffer[ch] = NULL; + alac->output_samples_buffer[ch] = NULL; + alac->extra_bits_buffer[ch] = NULL; + } + for (ch = 0; ch < FFMIN(alac->channels, 2); ch++) { FF_ALLOC_OR_GOTO(alac->avctx, alac->predict_error_buffer[ch], buf_size, buf_alloc_fail); @@ -668,6 +674,6 @@ .close = alac_decode_close, .decode = alac_decode_frame, .init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy), - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .priv_class = &alac_class }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/alacenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/alacenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/alacenc.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/alacenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -531,7 +531,7 @@ avctx->channels, avctx->bits_per_raw_sample); - avctx->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { ret = AVERROR(ENOMEM); goto error; @@ -618,7 +618,7 @@ else max_frame_size = s->max_coded_frame_size; - if ((ret = ff_alloc_packet2(avctx, avpkt, 2 * max_frame_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, 2 * max_frame_size, 0)) < 0) return ret; /* use verbatim mode for compression_level 0 */ @@ -653,7 +653,7 @@ .init = alac_encode_init, .encode2 = alac_encode_frame, .close = alac_encode_close, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME, + .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .channel_layouts = ff_alac_channel_layouts, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_S16P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aliaspixdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aliaspixdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aliaspixdec.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aliaspixdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -124,5 +124,5 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_ALIAS_PIX, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aliaspixenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aliaspixenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aliaspixenc.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aliaspixenc.c 2015-08-03 17:20:02.000000000 +0000 @@ -27,22 +27,18 @@ #define ALIAS_HEADER_SIZE 10 -static av_cold int encode_init(AVCodecContext *avctx) -{ - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - return 0; -} - static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { int width, height, bits_pixel, i, j, length, ret; uint8_t *in_buf, *buf; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif width = avctx->width; height = avctx->height; @@ -65,7 +61,7 @@ } length = ALIAS_HEADER_SIZE + 4 * width * height; // max possible - if ((ret = ff_alloc_packet(pkt, length)) < 0) { + if ((ret = ff_alloc_packet2(avctx, pkt, length, ALIAS_HEADER_SIZE + height*2)) < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n", length); return ret; } @@ -114,20 +110,12 @@ return 0; } -static av_cold int encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - return 0; -} - AVCodec ff_alias_pix_encoder = { .name = "alias_pix", .long_name = NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_ALIAS_PIX, - .init = encode_init, .encode2 = encode_frame, - .close = encode_close, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/allcodecs.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/allcodecs.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/allcodecs.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/allcodecs.c 2015-08-03 17:20:02.000000000 +0000 @@ -76,6 +76,7 @@ /* hardware accelerators */ REGISTER_HWACCEL(H263_VAAPI, h263_vaapi); REGISTER_HWACCEL(H263_VDPAU, h263_vdpau); + REGISTER_HWACCEL(H263_VIDEOTOOLBOX, h263_videotoolbox); REGISTER_HWACCEL(H264_D3D11VA, h264_d3d11va); REGISTER_HWACCEL(H264_DXVA2, h264_dxva2); REGISTER_HWACCEL(H264_MMAL, h264_mmal); @@ -84,21 +85,29 @@ REGISTER_HWACCEL(H264_VDA, h264_vda); REGISTER_HWACCEL(H264_VDA_OLD, h264_vda_old); REGISTER_HWACCEL(H264_VDPAU, h264_vdpau); + REGISTER_HWACCEL(H264_VIDEOTOOLBOX, h264_videotoolbox); REGISTER_HWACCEL(HEVC_D3D11VA, hevc_d3d11va); REGISTER_HWACCEL(HEVC_DXVA2, hevc_dxva2); + REGISTER_HWACCEL(HEVC_QSV, hevc_qsv); + REGISTER_HWACCEL(HEVC_VDPAU, hevc_vdpau); REGISTER_HWACCEL(MPEG1_XVMC, mpeg1_xvmc); REGISTER_HWACCEL(MPEG1_VDPAU, mpeg1_vdpau); + REGISTER_HWACCEL(MPEG1_VIDEOTOOLBOX, mpeg1_videotoolbox); REGISTER_HWACCEL(MPEG2_XVMC, mpeg2_xvmc); REGISTER_HWACCEL(MPEG2_D3D11VA, mpeg2_d3d11va); REGISTER_HWACCEL(MPEG2_DXVA2, mpeg2_dxva2); + REGISTER_HWACCEL(MPEG2_QSV, mpeg2_qsv); REGISTER_HWACCEL(MPEG2_VAAPI, mpeg2_vaapi); REGISTER_HWACCEL(MPEG2_VDPAU, mpeg2_vdpau); + REGISTER_HWACCEL(MPEG2_VIDEOTOOLBOX, mpeg2_videotoolbox); REGISTER_HWACCEL(MPEG4_VAAPI, mpeg4_vaapi); REGISTER_HWACCEL(MPEG4_VDPAU, mpeg4_vdpau); + REGISTER_HWACCEL(MPEG4_VIDEOTOOLBOX, mpeg4_videotoolbox); REGISTER_HWACCEL(VC1_D3D11VA, vc1_d3d11va); REGISTER_HWACCEL(VC1_DXVA2, vc1_dxva2); REGISTER_HWACCEL(VC1_VAAPI, vc1_vaapi); REGISTER_HWACCEL(VC1_VDPAU, vc1_vdpau); + REGISTER_HWACCEL(VC1_QSV, vc1_qsv); REGISTER_HWACCEL(WMV3_D3D11VA, wmv3_d3d11va); REGISTER_HWACCEL(WMV3_DXVA2, wmv3_dxva2); REGISTER_HWACCEL(WMV3_VAAPI, wmv3_vaapi); @@ -140,6 +149,7 @@ REGISTER_DECODER(CPIA, cpia); REGISTER_DECODER(CSCD, cscd); REGISTER_DECODER(CYUV, cyuv); + REGISTER_DECODER(DDS, dds); REGISTER_DECODER(DFA, dfa); REGISTER_DECODER(DIRAC, dirac); REGISTER_ENCDEC (DNXHD, dnxhd); @@ -181,7 +191,9 @@ REGISTER_DECODER(H264_QSV, h264_qsv); REGISTER_DECODER(H264_VDA, h264_vda); REGISTER_DECODER(H264_VDPAU, h264_vdpau); + REGISTER_ENCDEC (HAP, hap); REGISTER_DECODER(HEVC, hevc); + REGISTER_DECODER(HEVC_QSV, hevc_qsv); REGISTER_DECODER(HNM4_VIDEO, hnm4_video); REGISTER_DECODER(HQ_HQA, hq_hqa); REGISTER_DECODER(HQX, hqx); @@ -220,6 +232,7 @@ REGISTER_DECODER(MPEG_VDPAU, mpeg_vdpau); REGISTER_DECODER(MPEG1_VDPAU, mpeg1_vdpau); REGISTER_DECODER(MPEG2_CRYSTALHD, mpeg2_crystalhd); + REGISTER_DECODER(MPEG2_QSV, mpeg2_qsv); REGISTER_DECODER(MSA1, msa1); REGISTER_DECODER(MSMPEG4_CRYSTALHD, msmpeg4_crystalhd); REGISTER_DECODER(MSMPEG4V1, msmpeg4v1); @@ -300,6 +313,7 @@ REGISTER_DECODER(VC1_CRYSTALHD, vc1_crystalhd); REGISTER_DECODER(VC1_VDPAU, vc1_vdpau); REGISTER_DECODER(VC1IMAGE, vc1image); + REGISTER_DECODER(VC1_QSV, vc1_qsv); REGISTER_DECODER(VCR1, vcr1); REGISTER_DECODER(VMDVIDEO, vmdvideo); REGISTER_DECODER(VMNC, vmnc); @@ -336,6 +350,7 @@ /* audio codecs */ REGISTER_ENCDEC (AAC, aac); + REGISTER_DECODER(AAC_FIXED, aac_fixed); REGISTER_DECODER(AAC_LATM, aac_latm); REGISTER_ENCDEC (AC3, ac3); REGISTER_ENCDEC (AC3_FIXED, ac3_fixed); @@ -486,6 +501,7 @@ REGISTER_DECODER(ADPCM_SBPRO_4, adpcm_sbpro_4); REGISTER_ENCDEC (ADPCM_SWF, adpcm_swf); REGISTER_DECODER(ADPCM_THP, adpcm_thp); + REGISTER_DECODER(ADPCM_THP_LE, adpcm_thp_le); REGISTER_DECODER(ADPCM_VIMA, adpcm_vima); REGISTER_DECODER(ADPCM_XA, adpcm_xa); REGISTER_ENCDEC (ADPCM_YAMAHA, adpcm_yamaha); @@ -545,6 +561,7 @@ REGISTER_ENCODER(LIBWAVPACK, libwavpack); REGISTER_ENCODER(LIBWEBP_ANIM, libwebp_anim); /* preferred over libwebp */ REGISTER_ENCODER(LIBWEBP, libwebp); + REGISTER_ENCODER(LIBX262, libx262); REGISTER_ENCODER(LIBX264, libx264); REGISTER_ENCODER(LIBX264RGB, libx264rgb); REGISTER_ENCODER(LIBX265, libx265); @@ -565,6 +582,9 @@ REGISTER_ENCODER(NVENC, nvenc); REGISTER_ENCODER(NVENC_H264, nvenc_h264); REGISTER_ENCODER(NVENC_HEVC, nvenc_hevc); + REGISTER_ENCODER(HEVC_QSV, hevc_qsv); + REGISTER_ENCODER(LIBKVAZAAR, libkvazaar); + REGISTER_ENCODER(MPEG2_QSV, mpeg2_qsv); /* parsers */ REGISTER_PARSER(AAC, aac); @@ -609,6 +629,7 @@ REGISTER_BSF(CHOMP, chomp); REGISTER_BSF(DUMP_EXTRADATA, dump_extradata); REGISTER_BSF(H264_MP4TOANNEXB, h264_mp4toannexb); + REGISTER_BSF(HEVC_MP4TOANNEXB, hevc_mp4toannexb); REGISTER_BSF(IMX_DUMP_HEADER, imx_dump_header); REGISTER_BSF(MJPEG2JPEG, mjpeg2jpeg); REGISTER_BSF(MJPEGA_DUMP_HEADER, mjpega_dump_header); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/alsdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/alsdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/alsdec.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/alsdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -1853,5 +1853,5 @@ .close = decode_end, .decode = decode_frame, .flush = flush, - .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/amrnbdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/amrnbdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/amrnbdec.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/amrnbdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -1088,7 +1088,7 @@ .priv_data_size = sizeof(AMRContext), .init = amrnb_decode_init, .decode = amrnb_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/amrwbdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/amrwbdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/amrwbdec.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/amrwbdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -1273,7 +1273,7 @@ .priv_data_size = sizeof(AMRWBContext), .init = amrwb_decode_init, .decode = amrwb_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/anm.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/anm.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/anm.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/anm.c 2015-07-28 17:20:07.000000000 +0000 @@ -198,5 +198,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ansi.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ansi.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ansi.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ansi.c 2015-07-28 17:20:07.000000000 +0000 @@ -478,5 +478,5 @@ .init = decode_init, .close = decode_close, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/apedec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/apedec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/apedec.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/apedec.c 2015-07-28 17:20:07.000000000 +0000 @@ -1570,7 +1570,8 @@ .init = ape_decode_init, .close = ape_decode_close, .decode = ape_decode_frame, - .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_DR1, .flush = ape_flush, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S16P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/api-flac-test.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/api-flac-test.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/api-flac-test.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/api-flac-test.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,266 +0,0 @@ -/* - * Copyright (c) 2015 Ludmila Glinskih - * Copyright (c) 2001 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/* - * FLAC codec test. - * Encodes raw data to FLAC format and decodes it back to raw. Compares raw-data - * after that. - */ - -#include "avcodec.h" -#include "libavutil/common.h" -#include "libavutil/samplefmt.h" - -#define NUMBER_OF_FRAMES 200 -#define NAME_BUFF_SIZE 100 - -/* generate i-th frame of test audio */ -static int generate_raw_frame(uint16_t *frame_data, int i, int sample_rate, - int channels, int frame_size) -{ - int j, k; - - for (j = 0; j < frame_size; j++) { - frame_data[channels * j] = 10000 * ((j / 10 * i) % 2); - for (k = 1; k < channels; k++) - frame_data[channels * j + k] = frame_data[channels * j] * (k + 1); - } - return 0; -} - -static int init_encoder(AVCodec *enc, AVCodecContext **enc_ctx, - int64_t ch_layout, int sample_rate) -{ - AVCodecContext *ctx; - int result; - char name_buff[NAME_BUFF_SIZE]; - - av_get_channel_layout_string(name_buff, NAME_BUFF_SIZE, 0, ch_layout); - av_log(NULL, AV_LOG_INFO, "channel layout: %s, sample rate: %i\n", name_buff, sample_rate); - - ctx = avcodec_alloc_context3(enc); - if (!ctx) { - av_log(NULL, AV_LOG_ERROR, "Can't allocate encoder context\n"); - return AVERROR(ENOMEM); - } - - ctx->sample_fmt = AV_SAMPLE_FMT_S16; - ctx->sample_rate = sample_rate; - ctx->channel_layout = ch_layout; - - result = avcodec_open2(ctx, enc, NULL); - if (result < 0) { - av_log(ctx, AV_LOG_ERROR, "Can't open encoder\n"); - return result; - } - - *enc_ctx = ctx; - return 0; -} - -static int init_decoder(AVCodec *dec, AVCodecContext **dec_ctx, - int64_t ch_layout) -{ - AVCodecContext *ctx; - int result; - - ctx = avcodec_alloc_context3(dec); - if (!ctx) { - av_log(NULL, AV_LOG_ERROR , "Can't allocate decoder context\n"); - return AVERROR(ENOMEM); - } - - ctx->request_sample_fmt = AV_SAMPLE_FMT_S16; - /* XXX: FLAC ignores it for some reason */ - ctx->request_channel_layout = ch_layout; - ctx->channel_layout = ch_layout; - - result = avcodec_open2(ctx, dec, NULL); - if (result < 0) { - av_log(ctx, AV_LOG_ERROR, "Can't open decoder\n"); - return result; - } - - *dec_ctx = ctx; - return 0; -} - -static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, - AVCodecContext *dec_ctx) -{ - AVPacket enc_pkt; - AVFrame *in_frame, *out_frame; - uint8_t *raw_in = NULL, *raw_out = NULL; - int in_offset = 0, out_offset = 0; - int frame_data_size = 0; - int result = 0; - int got_output = 0; - int i = 0; - - in_frame = av_frame_alloc(); - if (!in_frame) { - av_log(NULL, AV_LOG_ERROR, "Can't allocate input frame\n"); - return AVERROR(ENOMEM); - } - - in_frame->nb_samples = enc_ctx->frame_size; - in_frame->format = enc_ctx->sample_fmt; - in_frame->channel_layout = enc_ctx->channel_layout; - if (av_frame_get_buffer(in_frame, 32) != 0) { - av_log(NULL, AV_LOG_ERROR, "Can't allocate a buffer for input frame\n"); - return AVERROR(ENOMEM); - } - - out_frame = av_frame_alloc(); - if (!out_frame) { - av_log(NULL, AV_LOG_ERROR, "Can't allocate output frame\n"); - return AVERROR(ENOMEM); - } - - raw_in = av_malloc(in_frame->linesize[0] * NUMBER_OF_FRAMES); - if (!raw_in) { - av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_in\n"); - return AVERROR(ENOMEM); - } - - raw_out = av_malloc(in_frame->linesize[0] * NUMBER_OF_FRAMES); - if (!raw_out) { - av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_out\n"); - return AVERROR(ENOMEM); - } - - for (i = 0; i < NUMBER_OF_FRAMES; i++) { - av_init_packet(&enc_pkt); - enc_pkt.data = NULL; - enc_pkt.size = 0; - - generate_raw_frame((uint16_t*)(in_frame->data[0]), i, enc_ctx->sample_rate, - enc_ctx->channels, enc_ctx->frame_size); - memcpy(raw_in + in_offset, in_frame->data[0], in_frame->linesize[0]); - in_offset += in_frame->linesize[0]; - result = avcodec_encode_audio2(enc_ctx, &enc_pkt, in_frame, &got_output); - if (result < 0) { - av_log(NULL, AV_LOG_ERROR, "Error encoding audio frame\n"); - return result; - } - - /* if we get an encoded packet, feed it straight to the decoder */ - if (got_output) { - result = avcodec_decode_audio4(dec_ctx, out_frame, &got_output, &enc_pkt); - if (result < 0) { - av_log(NULL, AV_LOG_ERROR, "Error decoding audio packet\n"); - return result; - } - - if (got_output) { - if (result != enc_pkt.size) { - av_log(NULL, AV_LOG_INFO, "Decoder consumed only part of a packet, it is allowed to do so -- need to update this test\n"); - return AVERROR_UNKNOWN; - } - - if (in_frame->nb_samples != out_frame->nb_samples) { - av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different number of samples\n"); - return AVERROR_UNKNOWN; - } - - if (in_frame->channel_layout != out_frame->channel_layout) { - av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different channel layout\n"); - return AVERROR_UNKNOWN; - } - - if (in_frame->format != out_frame->format) { - av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different sample format\n"); - return AVERROR_UNKNOWN; - } - memcpy(raw_out + out_offset, out_frame->data[0], out_frame->linesize[0]); - out_offset += out_frame->linesize[0]; - } - } - av_free_packet(&enc_pkt); - } - - if (memcmp(raw_in, raw_out, frame_data_size * NUMBER_OF_FRAMES) != 0) { - av_log(NULL, AV_LOG_ERROR, "Output differs\n"); - return 1; - } - - av_log(NULL, AV_LOG_INFO, "OK\n"); - - av_freep(&raw_in); - av_freep(&raw_out); - av_frame_free(&in_frame); - av_frame_free(&out_frame); - return 0; -} - -static int close_encoder(AVCodecContext **enc_ctx) -{ - avcodec_close(*enc_ctx); - av_freep(enc_ctx); - return 0; -} - -static int close_decoder(AVCodecContext **dec_ctx) -{ - avcodec_close(*dec_ctx); - av_freep(dec_ctx); - return 0; -} - -int main(void) -{ - AVCodec *enc = NULL, *dec = NULL; - AVCodecContext *enc_ctx = NULL, *dec_ctx = NULL; - uint64_t channel_layouts[] = {AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_5POINT1_BACK, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_STEREO_DOWNMIX}; - int sample_rates[] = {8000, 44100, 48000, 192000}; - int cl, sr; - - avcodec_register_all(); - - enc = avcodec_find_encoder(AV_CODEC_ID_FLAC); - if (!enc) { - av_log(NULL, AV_LOG_ERROR, "Can't find encoder\n"); - return 1; - } - - dec = avcodec_find_decoder(AV_CODEC_ID_FLAC); - if (!dec) { - av_log(NULL, AV_LOG_ERROR, "Can't find decoder\n"); - return 1; - } - - for (cl = 0; cl < FF_ARRAY_ELEMS(channel_layouts); cl++) { - for (sr = 0; sr < FF_ARRAY_ELEMS(sample_rates); sr++) { - if (init_encoder(enc, &enc_ctx, channel_layouts[cl], sample_rates[sr]) != 0) - return 1; - if (init_decoder(dec, &dec_ctx, channel_layouts[cl]) != 0) - return 1; - if (run_test(enc, dec, enc_ctx, dec_ctx) != 0) - return 1; - close_encoder(&enc_ctx); - close_decoder(&dec_ctx); - } - } - - return 0; -} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/arm/h264pred_init_arm.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/arm/h264pred_init_arm.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/arm/h264pred_init_arm.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/arm/h264pred_init_arm.c 2015-07-18 17:20:03.000000000 +0000 @@ -54,22 +54,23 @@ if (high_depth) return; - if(chroma_format_idc == 1){ - h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vert_neon; - h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_hor_neon; - if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) - h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon; - h->pred8x8[DC_128_PRED8x8 ] = ff_pred8x8_128_dc_neon; - if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 && - codec_id != AV_CODEC_ID_VP8) { - h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_neon; - h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon; - h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon; - h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = ff_pred8x8_l0t_dc_neon; - h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = ff_pred8x8_0lt_dc_neon; - h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = ff_pred8x8_l00_dc_neon; - h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = ff_pred8x8_0l0_dc_neon; - } + + if (chroma_format_idc <= 1) { + h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vert_neon; + h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_hor_neon; + if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) + h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon; + h->pred8x8[DC_128_PRED8x8 ] = ff_pred8x8_128_dc_neon; + if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 && + codec_id != AV_CODEC_ID_VP8) { + h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_neon; + h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon; + h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon; + h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = ff_pred8x8_l0t_dc_neon; + h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = ff_pred8x8_0lt_dc_neon; + h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = ff_pred8x8_l00_dc_neon; + h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = ff_pred8x8_0l0_dc_neon; + } } h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_neon; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/arm/idctdsp_init_arm.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/arm/idctdsp_init_arm.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/arm/idctdsp_init_arm.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/arm/idctdsp_init_arm.c 2015-07-28 17:20:07.000000000 +0000 @@ -64,7 +64,7 @@ int cpu_flags = av_get_cpu_flags(); if (!avctx->lowres && !high_bit_depth) { - if ((avctx->idct_algo == FF_IDCT_AUTO && !(avctx->flags & CODEC_FLAG_BITEXACT)) || + if ((avctx->idct_algo == FF_IDCT_AUTO && !(avctx->flags & AV_CODEC_FLAG_BITEXACT)) || avctx->idct_algo == FF_IDCT_ARM) { c->idct_put = j_rev_dct_arm_put; c->idct_add = j_rev_dct_arm_add; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/arm/idctdsp_init_armv6.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/arm/idctdsp_init_armv6.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/arm/idctdsp_init_armv6.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/arm/idctdsp_init_armv6.c 2015-07-28 17:20:07.000000000 +0000 @@ -33,7 +33,7 @@ unsigned high_bit_depth) { if (!avctx->lowres && !high_bit_depth) { - if ((avctx->idct_algo == FF_IDCT_AUTO && !(avctx->flags & CODEC_FLAG_BITEXACT)) || + if ((avctx->idct_algo == FF_IDCT_AUTO && !(avctx->flags & AV_CODEC_FLAG_BITEXACT)) || avctx->idct_algo == FF_IDCT_SIMPLEARMV6) { c->idct_put = ff_simple_idct_put_armv6; c->idct_add = ff_simple_idct_add_armv6; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/arm/Makefile ffmpeg-2.7.2~trusty~ppa1/libavcodec/arm/Makefile --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/arm/Makefile 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/arm/Makefile 2015-07-18 17:20:03.000000000 +0000 @@ -18,6 +18,9 @@ arm/idctdsp_arm.o \ arm/jrevdct_arm.o \ arm/simple_idct_arm.o +OBJS-$(CONFIG_FLACDSP) += arm/flacdsp_init_arm.o \ + arm/flacdsp_arm.o +OBJS-$(CONFIG_G722DSP) += arm/g722dsp_init_arm.o OBJS-$(CONFIG_LLAUDDSP) += arm/lossless_audiodsp_init_arm.o OBJS-$(CONFIG_ME_CMP) += arm/me_cmp_init_arm.o OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_init_arm.o @@ -25,28 +28,21 @@ OBJS-$(CONFIG_MPEGVIDEOENC) += arm/mpegvideoencdsp_init_arm.o OBJS-$(CONFIG_NEON_CLOBBER_TEST) += arm/neontest.o OBJS-$(CONFIG_PIXBLOCKDSP) += arm/pixblockdsp_init_arm.o +OBJS-$(CONFIG_RV34DSP) += arm/rv34dsp_init_arm.o OBJS-$(CONFIG_VIDEODSP) += arm/videodsp_init_arm.o OBJS-$(CONFIG_VP3DSP) += arm/vp3dsp_init_arm.o +OBJS-$(CONFIG_VP8DSP) += arm/vp8dsp_init_arm.o # decoders/encoders OBJS-$(CONFIG_AAC_DECODER) += arm/aacpsdsp_init_arm.o \ arm/sbrdsp_init_arm.o -OBJS-$(CONFIG_ADPCM_G722_DECODER) += arm/g722dsp_init_arm.o -OBJS-$(CONFIG_ADPCM_G722_ENCODER) += arm/g722dsp_init_arm.o OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_init_arm.o -OBJS-$(CONFIG_FLAC_DECODER) += arm/flacdsp_init_arm.o \ - arm/flacdsp_arm.o -OBJS-$(CONFIG_FLAC_ENCODER) += arm/flacdsp_init_arm.o OBJS-$(CONFIG_HEVC_DECODER) += arm/hevcdsp_init_arm.o OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_init_arm.o +OBJS-$(CONFIG_RV40_DECODER) += arm/rv40dsp_init_arm.o OBJS-$(CONFIG_VC1_DECODER) += arm/vc1dsp_init_arm.o OBJS-$(CONFIG_VORBIS_DECODER) += arm/vorbisdsp_init_arm.o OBJS-$(CONFIG_VP6_DECODER) += arm/vp6dsp_init_arm.o -OBJS-$(CONFIG_VP7_DECODER) += arm/vp8dsp_init_arm.o -OBJS-$(CONFIG_VP8_DECODER) += arm/vp8dsp_init_arm.o -OBJS-$(CONFIG_RV30_DECODER) += arm/rv34dsp_init_arm.o -OBJS-$(CONFIG_RV40_DECODER) += arm/rv34dsp_init_arm.o \ - arm/rv40dsp_init_arm.o # ARMv5 optimizations @@ -74,16 +70,13 @@ ARMV6-OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_fixed_armv6.o ARMV6-OBJS-$(CONFIG_MPEGVIDEOENC) += arm/mpegvideoencdsp_armv6.o ARMV6-OBJS-$(CONFIG_PIXBLOCKDSP) += arm/pixblockdsp_armv6.o +ARMV6-OBJS-$(CONFIG_VP8DSP) += arm/vp8_armv6.o \ + arm/vp8dsp_init_armv6.o \ + arm/vp8dsp_armv6.o # decoders/encoders ARMV6-OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_armv6.o ARMV6-OBJS-$(CONFIG_STARTCODE) += arm/startcode_armv6.o -ARMV6-OBJS-$(CONFIG_VP7_DECODER) += arm/vp8_armv6.o \ - arm/vp8dsp_init_armv6.o \ - arm/vp8dsp_armv6.o -ARMV6-OBJS-$(CONFIG_VP8_DECODER) += arm/vp8_armv6.o \ - arm/vp8dsp_init_armv6.o \ - arm/vp8dsp_armv6.o # VFP optimizations @@ -110,6 +103,7 @@ NEON-OBJS-$(CONFIG_FFT) += arm/fft_neon.o \ arm/fft_fixed_neon.o NEON-OBJS-$(CONFIG_FMTCONVERT) += arm/fmtconvert_neon.o +NEON-OBJS-$(CONFIG_G722DSP) += arm/g722dsp_neon.o NEON-OBJS-$(CONFIG_H264CHROMA) += arm/h264cmc_neon.o NEON-OBJS-$(CONFIG_H264DSP) += arm/h264dsp_neon.o \ arm/h264idct_neon.o @@ -126,12 +120,12 @@ NEON-OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_neon.o NEON-OBJS-$(CONFIG_RDFT) += arm/rdft_neon.o NEON-OBJS-$(CONFIG_VP3DSP) += arm/vp3dsp_neon.o +NEON-OBJS-$(CONFIG_VP8DSP) += arm/vp8dsp_init_neon.o \ + arm/vp8dsp_neon.o # decoders/encoders NEON-OBJS-$(CONFIG_AAC_DECODER) += arm/aacpsdsp_neon.o \ arm/sbrdsp_neon.o -NEON-OBJS-$(CONFIG_ADPCM_G722_DECODER) += arm/g722dsp_neon.o -NEON-OBJS-$(CONFIG_ADPCM_G722_ENCODER) += arm/g722dsp_neon.o NEON-OBJS-$(CONFIG_LLAUDDSP) += arm/lossless_audiodsp_neon.o NEON-OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_neon.o \ arm/synth_filter_neon.o @@ -146,7 +140,3 @@ arm/vc1dsp_neon.o NEON-OBJS-$(CONFIG_VORBIS_DECODER) += arm/vorbisdsp_neon.o NEON-OBJS-$(CONFIG_VP6_DECODER) += arm/vp6dsp_neon.o -NEON-OBJS-$(CONFIG_VP7_DECODER) += arm/vp8dsp_init_neon.o \ - arm/vp8dsp_neon.o -NEON-OBJS-$(CONFIG_VP8_DECODER) += arm/vp8dsp_init_neon.o \ - arm/vp8dsp_neon.o diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ass.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ass.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ass.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ass.c 2015-07-28 17:20:07.000000000 +0000 @@ -66,7 +66,7 @@ "\r\n" "[Events]\r\n" "Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\r\n", - !(avctx->flags & CODEC_FLAG_BITEXACT) ? AV_STRINGIFY(LIBAVCODEC_VERSION) : "", + !(avctx->flags & AV_CODEC_FLAG_BITEXACT) ? AV_STRINGIFY(LIBAVCODEC_VERSION) : "", ASS_DEFAULT_PLAYRESX, ASS_DEFAULT_PLAYRESY, font, font_size, color, color, back_color, back_color, -bold, -italic, -underline, alignment); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ass_split.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ass_split.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ass_split.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ass_split.c 2015-06-14 17:20:02.000000000 +0000 @@ -356,6 +356,8 @@ ASSSplitContext *ff_ass_split(const char *buf) { ASSSplitContext *ctx = av_mallocz(sizeof(*ctx)); + if (!ctx) + return NULL; ctx->current_section = -1; if (ass_split(ctx, buf) < 0) { ff_ass_split_free(ctx); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/asvdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/asvdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/asvdec.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/asvdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -195,7 +195,7 @@ a->idsp.idct_put(dest_y + 8 * linesize, linesize, block[2]); a->idsp.idct_put(dest_y + 8 * linesize + 8, linesize, block[3]); - if (!(a->avctx->flags & CODEC_FLAG_GRAY)) { + if (!(a->avctx->flags & AV_CODEC_FLAG_GRAY)) { a->idsp.idct_put(dest_cb, frame->linesize[1], block[4]); a->idsp.idct_put(dest_cr, frame->linesize[2], block[5]); } @@ -322,7 +322,7 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif @@ -336,6 +336,6 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/asvenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/asvenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/asvenc.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/asvenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -207,7 +207,7 @@ for (i = 0; i < 4; i++) a->fdsp.fdct(block[i]); - if (!(a->avctx->flags & CODEC_FLAG_GRAY)) { + if (!(a->avctx->flags & AV_CODEC_FLAG_GRAY)) { a->pdsp.get_pixels(block[4], ptr_cb, frame->linesize[1]); a->pdsp.get_pixels(block[5], ptr_cr, frame->linesize[2]); for (i = 4; i < 6; i++) @@ -265,7 +265,7 @@ } if ((ret = ff_alloc_packet2(avctx, pkt, a->mb_height * a->mb_width * MAX_MB_SIZE + - FF_MIN_BUFFER_SIZE)) < 0) + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return ret; init_put_bits(&a->pb, pkt->data, pkt->size); @@ -363,8 +363,7 @@ .encode2 = encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | - FF_CODEC_CAP_INIT_CLEANUP, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; #endif @@ -379,7 +378,6 @@ .encode2 = encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | - FF_CODEC_CAP_INIT_CLEANUP, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/atrac1.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/atrac1.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/atrac1.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/atrac1.c 2015-07-28 17:20:07.000000000 +0000 @@ -361,7 +361,7 @@ ff_atrac_generate_tables(); - q->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); q->bands[0] = q->low; q->bands[1] = q->mid; @@ -386,7 +386,7 @@ .init = atrac1_decode_init, .close = atrac1_decode_end, .decode = atrac1_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/atrac3.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/atrac3.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/atrac3.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/atrac3.c 2015-07-28 17:20:07.000000000 +0000 @@ -886,7 +886,7 @@ return AVERROR(EINVAL); q->decoded_bytes_buffer = av_mallocz(FFALIGN(avctx->block_align, 4) + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!q->decoded_bytes_buffer) return AVERROR(ENOMEM); @@ -914,7 +914,7 @@ } ff_atrac_init_gain_compensation(&q->gainc_ctx, 4, 3); - q->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); q->units = av_mallocz_array(avctx->channels, sizeof(*q->units)); if (!q->units || !q->fdsp) { @@ -934,7 +934,7 @@ .init = atrac3_decode_init, .close = atrac3_decode_close, .decode = atrac3_decode_frame, - .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/atrac3plusdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/atrac3plusdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/atrac3plusdec.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/atrac3plusdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -171,7 +171,7 @@ ctx->my_channel_layout = avctx->channel_layout; ctx->ch_units = av_mallocz_array(ctx->num_channel_blocks, sizeof(*ctx->ch_units)); - ctx->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + ctx->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!ctx->ch_units || !ctx->fdsp) { atrac3p_decode_close(avctx); @@ -392,6 +392,7 @@ .long_name = NULL_IF_CONFIG_SMALL("ATRAC3+ (Adaptive TRansform Acoustic Coding 3+)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_ATRAC3P, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(ATRAC3PContext), .init = atrac3p_decode_init, .close = atrac3p_decode_close, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/aura.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/aura.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/aura.c 2015-06-18 18:54:56.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/aura.c 2015-07-28 17:20:07.000000000 +0000 @@ -104,5 +104,5 @@ .id = AV_CODEC_ID_AURA2, .init = aura_decode_init, .decode = aura_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/avcodec.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/avcodec.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/avcodec.h 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/avcodec.h 2015-07-29 17:20:04.000000000 +0000 @@ -293,6 +293,8 @@ AV_CODEC_ID_HQX, AV_CODEC_ID_TDSC, AV_CODEC_ID_HQ_HQA, + AV_CODEC_ID_HAP, + AV_CODEC_ID_DDS, AV_CODEC_ID_BRENDER_PIX= MKBETAG('B','P','I','X'), AV_CODEC_ID_Y41P = MKBETAG('Y','4','1','P'), @@ -356,6 +358,7 @@ AV_CODEC_ID_PCM_S8_PLANAR, AV_CODEC_ID_PCM_S24LE_PLANAR_DEPRECATED, AV_CODEC_ID_PCM_S32LE_PLANAR_DEPRECATED, + AV_CODEC_ID_PCM_S16BE_PLANAR_DEPRECATED, AV_CODEC_ID_PCM_S24LE_PLANAR = MKBETAG(24,'P','S','P'), AV_CODEC_ID_PCM_S32LE_PLANAR = MKBETAG(32,'P','S','P'), AV_CODEC_ID_PCM_S16BE_PLANAR = MKBETAG('P','S','P',16), @@ -401,6 +404,7 @@ AV_CODEC_ID_ADPCM_DTK = MKBETAG('D','T','K',' '), AV_CODEC_ID_ADPCM_IMA_RAD = MKBETAG('R','A','D',' '), AV_CODEC_ID_ADPCM_G726LE = MKBETAG('6','2','7','G'), + AV_CODEC_ID_ADPCM_THP_LE = MKBETAG('T','H','P','L'), /* AMR */ AV_CODEC_ID_AMR_NB = 0x12000, @@ -499,6 +503,7 @@ AV_CODEC_ID_DSD_MSBF = MKBETAG('D','S','D','M'), AV_CODEC_ID_DSD_LSBF_PLANAR = MKBETAG('D','S','D','1'), AV_CODEC_ID_DSD_MSBF_PLANAR = MKBETAG('D','S','D','8'), + AV_CODEC_ID_4GV = MKBETAG('s','4','g','v'), /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. @@ -627,20 +632,33 @@ * Note: If the first 23 bits of the additional bytes are not 0, then damaged * MPEG bitstreams could cause overread and segfault. */ -#define FF_INPUT_BUFFER_PADDING_SIZE 32 +#define AV_INPUT_BUFFER_PADDING_SIZE 32 /** * @ingroup lavc_encoding * minimum encoding buffer size * Used to avoid some checks during header writing. */ -#define FF_MIN_BUFFER_SIZE 16384 +#define AV_INPUT_BUFFER_MIN_SIZE 16384 +#if FF_API_WITHOUT_PREFIX +/** + * @deprecated use AV_INPUT_BUFFER_PADDING_SIZE instead + */ +#define FF_INPUT_BUFFER_PADDING_SIZE 32 + +/** + * @deprecated use AV_INPUT_BUFFER_MIN_SIZE instead + */ +#define FF_MIN_BUFFER_SIZE 16384 +#endif /* FF_API_WITHOUT_PREFIX */ /** * @ingroup lavc_encoding * motion estimation type. + * @deprecated use codec private option instead */ +#if FF_API_MOTION_EST enum Motion_Est_ID { ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed ME_FULL, @@ -653,6 +671,7 @@ ME_TESA, ///< transformed exhaustive search algorithm ME_ITER=50, ///< iterative search }; +#endif /** * @ingroup lavc_decoding @@ -708,11 +727,232 @@ * Allow decoders to produce frames with data planes that are not aligned * to CPU requirements (e.g. due to cropping). */ -#define CODEC_FLAG_UNALIGNED 0x0001 -#define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale. -#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263. -#define CODEC_FLAG_OUTPUT_CORRUPT 0x0008 ///< Output even those frames that might be corrupted -#define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC. +#define AV_CODEC_FLAG_UNALIGNED (1 << 0) +/** + * Use fixed qscale. + */ +#define AV_CODEC_FLAG_QSCALE (1 << 1) +/** + * 4 MV per MB allowed / advanced prediction for H.263. + */ +#define AV_CODEC_FLAG_4MV (1 << 2) +/** + * Output even those frames that might be corrupted. + */ +#define AV_CODEC_FLAG_OUTPUT_CORRUPT (1 << 3) +/** + * Use qpel MC. + */ +#define AV_CODEC_FLAG_QPEL (1 << 4) +/** + * Use internal 2pass ratecontrol in first pass mode. + */ +#define AV_CODEC_FLAG_PASS1 (1 << 9) +/** + * Use internal 2pass ratecontrol in second pass mode. + */ +#define AV_CODEC_FLAG_PASS2 (1 << 10) +/** + * loop filter. + */ +#define AV_CODEC_FLAG_LOOP_FILTER (1 << 11) +/** + * Only decode/encode grayscale. + */ +#define AV_CODEC_FLAG_GRAY (1 << 13) +/** + * error[?] variables will be set during encoding. + */ +#define AV_CODEC_FLAG_PSNR (1 << 15) +/** + * Input bitstream might be truncated at a random location + * instead of only at frame boundaries. + */ +#define AV_CODEC_FLAG_TRUNCATED (1 << 16) +/** + * Use interlaced DCT. + */ +#define AV_CODEC_FLAG_INTERLACED_DCT (1 << 18) +/** + * Force low delay. + */ +#define AV_CODEC_FLAG_LOW_DELAY (1 << 19) +/** + * Place global headers in extradata instead of every keyframe. + */ +#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22) +/** + * Use only bitexact stuff (except (I)DCT). + */ +#define AV_CODEC_FLAG_BITEXACT (1 << 23) +/* Fx : Flag for h263+ extra options */ +/** + * H.263 advanced intra coding / MPEG-4 AC prediction + */ +#define AV_CODEC_FLAG_AC_PRED (1 << 24) +/** + * interlaced motion estimation + */ +#define AV_CODEC_FLAG_INTERLACED_ME (1 << 29) +/** + * Allow non spec compliant speedup tricks. + */ +#define AV_CODEC_FLAG_CLOSED_GOP (1U << 31) + +#define AV_CODEC_FLAG2_FAST (1 << 0) +/** + * Skip bitstream encoding. + */ +#define AV_CODEC_FLAG2_NO_OUTPUT (1 << 2) +/** + * Place global headers at every keyframe instead of in extradata. + */ +#define AV_CODEC_FLAG2_LOCAL_HEADER (1 << 3) + +/** + * timecode is in drop frame format. DEPRECATED!!!! + */ +#define AV_CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 + +/** + * Input bitstream might be truncated at a packet boundaries + * instead of only at frame boundaries. + */ +#define AV_CODEC_FLAG2_CHUNKS (1 << 15) +/** + * Discard cropping information from SPS. + */ +#define AV_CODEC_FLAG2_IGNORE_CROP (1 << 16) + +/** + * Show all frames before the first keyframe + */ +#define AV_CODEC_FLAG2_SHOW_ALL 0x00400000 +/** + * Export motion vectors through frame side data + */ +#define AV_CODEC_FLAG2_EXPORT_MVS 0x10000000 +/** + * Do not skip samples and export skip information as frame side data + */ +#define AV_CODEC_FLAG2_SKIP_MANUAL 0x20000000 + +/* Unsupported options : + * Syntax Arithmetic coding (SAC) + * Reference Picture Selection + * Independent Segment Decoding */ +/* /Fx */ +/* codec capabilities */ + +/** + * Decoder can use draw_horiz_band callback. + */ +#define AV_CODEC_CAP_DRAW_HORIZ_BAND (1 << 0) +/** + * Codec uses get_buffer() for allocating buffers and supports custom allocators. + * If not set, it might not use get_buffer() at all or use operations that + * assume the buffer was allocated by avcodec_default_get_buffer. + */ +#define AV_CODEC_CAP_DR1 (1 << 1) +#define AV_CODEC_CAP_TRUNCATED (1 << 3) +/** + * Encoder or decoder requires flushing with NULL input at the end in order to + * give the complete and correct output. + * + * NOTE: If this flag is not set, the codec is guaranteed to never be fed with + * with NULL data. The user can still send NULL data to the public encode + * or decode function, but libavcodec will not pass it along to the codec + * unless this flag is set. + * + * Decoders: + * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL, + * avpkt->size=0 at the end to get the delayed data until the decoder no longer + * returns frames. + * + * Encoders: + * The encoder needs to be fed with NULL data at the end of encoding until the + * encoder no longer returns data. + * + * NOTE: For encoders implementing the AVCodec.encode2() function, setting this + * flag also means that the encoder must set the pts and duration for + * each output packet. If this flag is not set, the pts and duration will + * be determined by libavcodec from the input frame. + */ +#define AV_CODEC_CAP_DELAY (1 << 5) +/** + * Codec can be fed a final frame with a smaller size. + * This can be used to prevent truncation of the last audio samples. + */ +#define AV_CODEC_CAP_SMALL_LAST_FRAME (1 << 6) + +#if FF_API_CAP_VDPAU +/** + * Codec can export data for HW decoding (VDPAU). + */ +#define AV_CODEC_CAP_HWACCEL_VDPAU (1 << 7) +#endif + +/** + * Codec can output multiple frames per AVPacket + * Normally demuxers return one frame at a time, demuxers which do not do + * are connected to a parser to split what they return into proper frames. + * This flag is reserved to the very rare category of codecs which have a + * bitstream that cannot be split into frames without timeconsuming + * operations like full decoding. Demuxers carring such bitstreams thus + * may return multiple frames in a packet. This has many disadvantages like + * prohibiting stream copy in many cases thus it should only be considered + * as a last resort. + */ +#define AV_CODEC_CAP_SUBFRAMES (1 << 8) +/** + * Codec is experimental and is thus avoided in favor of non experimental + * encoders + */ +#define AV_CODEC_CAP_EXPERIMENTAL (1 << 9) +/** + * Codec should fill in channel configuration and samplerate instead of container + */ +#define AV_CODEC_CAP_CHANNEL_CONF (1 << 10) +/** + * Codec supports frame-level multithreading. + */ +#define AV_CODEC_CAP_FRAME_THREADS (1 << 12) +/** + * Codec supports slice-based (or partition-based) multithreading. + */ +#define AV_CODEC_CAP_SLICE_THREADS (1 << 13) +/** + * Codec supports changed parameters at any point. + */ +#define AV_CODEC_CAP_PARAM_CHANGE (1 << 14) +/** + * Codec supports avctx->thread_count == 0 (auto). + */ +#define AV_CODEC_CAP_AUTO_THREADS (1 << 15) +/** + * Audio encoder supports receiving a different number of samples in each call. + */ +#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16) +/** + * Codec is intra only. + */ +#define AV_CODEC_CAP_INTRA_ONLY 0x40000000 +/** + * Codec is lossless. + */ +#define AV_CODEC_CAP_LOSSLESS 0x80000000 + + +#if FF_API_WITHOUT_PREFIX +/** + * Allow decoders to produce frames with data planes that are not aligned + * to CPU requirements (e.g. due to cropping). + */ +#define CODEC_FLAG_UNALIGNED AV_CODEC_FLAG_UNALIGNED +#define CODEC_FLAG_QSCALE AV_CODEC_FLAG_QSCALE +#define CODEC_FLAG_4MV AV_CODEC_FLAG_4MV +#define CODEC_FLAG_OUTPUT_CORRUPT AV_CODEC_FLAG_OUTPUT_CORRUPT +#define CODEC_FLAG_QPEL AV_CODEC_FLAG_QPEL #if FF_API_GMC /** * @deprecated use the "gmc" private option of the libxvid encoder @@ -733,9 +973,9 @@ */ #define CODEC_FLAG_INPUT_PRESERVED 0x0100 #endif -#define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode. -#define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode. -#define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale. +#define CODEC_FLAG_PASS1 AV_CODEC_FLAG_PASS1 +#define CODEC_FLAG_PASS2 AV_CODEC_FLAG_PASS2 +#define CODEC_FLAG_GRAY AV_CODEC_FLAG_GRAY #if FF_API_EMU_EDGE /** * @deprecated edges are not used/required anymore. I.e. this flag is now always @@ -743,9 +983,9 @@ */ #define CODEC_FLAG_EMU_EDGE 0x4000 #endif -#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding. -#define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random - location instead of only at frame boundaries. */ +#define CODEC_FLAG_PSNR AV_CODEC_FLAG_PSNR +#define CODEC_FLAG_TRUNCATED AV_CODEC_FLAG_TRUNCATED + #if FF_API_NORMALIZE_AQP /** * @deprecated use the flag "naq" in the "mpv_flags" private option of the @@ -753,25 +993,24 @@ */ #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 #endif -#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT. -#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay. -#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe. -#define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT). -/* Fx : Flag for h263+ extra options */ -#define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction -#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter -#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation -#define CODEC_FLAG_CLOSED_GOP 0x80000000 -#define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks. -#define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding. -#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata. -#define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. DEPRECATED!!!! -#define CODEC_FLAG2_IGNORE_CROP 0x00010000 ///< Discard cropping information from SPS. - -#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. -#define CODEC_FLAG2_SHOW_ALL 0x00400000 ///< Show all frames before the first keyframe -#define CODEC_FLAG2_EXPORT_MVS 0x10000000 ///< Export motion vectors through frame side data -#define CODEC_FLAG2_SKIP_MANUAL 0x20000000 ///< Do not skip samples and export skip information as frame side data +#define CODEC_FLAG_INTERLACED_DCT AV_CODEC_FLAG_INTERLACED_DCT +#define CODEC_FLAG_LOW_DELAY AV_CODEC_FLAG_LOW_DELAY +#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER +#define CODEC_FLAG_BITEXACT AV_CODEC_FLAG_BITEXACT +#define CODEC_FLAG_AC_PRED AV_CODEC_FLAG_AC_PRED +#define CODEC_FLAG_LOOP_FILTER AV_CODEC_FLAG_LOOP_FILTER +#define CODEC_FLAG_INTERLACED_ME AV_CODEC_FLAG_INTERLACED_ME +#define CODEC_FLAG_CLOSED_GOP AV_CODEC_FLAG_CLOSED_GOP +#define CODEC_FLAG2_FAST AV_CODEC_FLAG2_FAST +#define CODEC_FLAG2_NO_OUTPUT AV_CODEC_FLAG2_NO_OUTPUT +#define CODEC_FLAG2_LOCAL_HEADER AV_CODEC_FLAG2_LOCAL_HEADER +#define CODEC_FLAG2_DROP_FRAME_TIMECODE AV_CODEC_FLAG2_DROP_FRAME_TIMECODE +#define CODEC_FLAG2_IGNORE_CROP AV_CODEC_FLAG2_IGNORE_CROP + +#define CODEC_FLAG2_CHUNKS AV_CODEC_FLAG2_CHUNKS +#define CODEC_FLAG2_SHOW_ALL AV_CODEC_FLAG2_SHOW_ALL +#define CODEC_FLAG2_EXPORT_MVS AV_CODEC_FLAG2_EXPORT_MVS +#define CODEC_FLAG2_SKIP_MANUAL AV_CODEC_FLAG2_SKIP_MANUAL /* Unsupported options : * Syntax Arithmetic coding (SAC) @@ -889,6 +1128,13 @@ */ #define CODEC_CAP_LOSSLESS 0x80000000 +/** + * HWAccel is experimental and is thus avoided in favor of non experimental + * codecs + */ +#define HWACCEL_CODEC_CAP_EXPERIMENTAL 0x0200 +#endif /* FF_API_WITHOUT_PREFIX */ + #if FF_API_MB_TYPE //The following defines may change, don't expect compatibility if you use them. #define MB_TYPE_INTRA4x4 0x0001 @@ -1044,6 +1290,18 @@ AV_PKT_DATA_AUDIO_SERVICE_TYPE, /** + * This side data contains quality related information from the encoder. + * @code + * u32le quality factor of the compressed frame. Allowed range is between 1 (good) and FF_LAMBDA_MAX (bad). + * u8 picture type + * u8 error count + * u16 reserved + * u64le[error count] sum of squared differences between encoder in and output + * @endcode + */ + AV_PKT_DATA_QUALITY_STATS, + + /** * Recommmends skipping the specified number of samples * @code * u32le number of samples to skip from start of this packet @@ -1108,6 +1366,8 @@ AV_PKT_DATA_METADATA_UPDATE, }; +#define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED + typedef struct AVPacketSideData { uint8_t *data; int size; @@ -1300,7 +1560,8 @@ /** * the average bitrate * - encoding: Set by user; unused for constant quantizer encoding. - * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream. + * - decoding: Set by user, may be overwritten by libavcodec + * if this info is available in the stream */ int bit_rate; @@ -1328,14 +1589,14 @@ #define FF_COMPRESSION_DEFAULT -1 /** - * CODEC_FLAG_*. + * AV_CODEC_FLAG_*. * - encoding: Set by user. * - decoding: Set by user. */ int flags; /** - * CODEC_FLAG2_* + * AV_CODEC_FLAG2_* * - encoding: Set by user. * - decoding: Set by user. */ @@ -1346,7 +1607,7 @@ * mjpeg: Huffman tables * rv10: additional flags * mpeg4: global headers (they can be in the bitstream or here) - * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger + * 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. * - encoding: Set/allocated/freed by libavcodec. @@ -1405,21 +1666,31 @@ /* video only */ /** * picture width / height. + * + * @note Those fields may not match the values of the last + * AVFrame outputted by avcodec_decode_video2 due frame + * reordering. + * * - encoding: MUST be set by user. * - decoding: May be set by the user before opening the decoder if known e.g. * from the container. Some decoders will require the dimensions * to be set by the caller. During decoding, the decoder may - * overwrite those values as required. + * overwrite those values as required while parsing the data. */ int width, height; /** * Bitstream width / height, may be different from width/height e.g. when * the decoded frame is cropped before being output or lowres is enabled. + * + * @note Those field may not match the value of the last + * AVFrame outputted by avcodec_decode_video2 due frame + * reordering. + * * - encoding: unused * - decoding: May be set by the user before opening the decoder if known * e.g. from the container. During decoding, the decoder may - * overwrite those values as required. + * overwrite those values as required while parsing the data. */ int coded_width, coded_height; @@ -1438,19 +1709,24 @@ * Pixel format, see AV_PIX_FMT_xxx. * May be set by the demuxer if known from headers. * May be overridden by the decoder if it knows better. + * + * @note This field may not match the value of the last + * AVFrame outputted by avcodec_decode_video2 due frame + * reordering. + * * - encoding: Set by user. - * - decoding: Set by user if known, overridden by libavcodec if known + * - decoding: Set by user if known, overridden by libavcodec while + * parsing the data. */ enum AVPixelFormat pix_fmt; +#if FF_API_MOTION_EST /** - * Motion estimation algorithm used for video coding. - * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex), - * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific] - * - encoding: MUST be set by user. - * - decoding: unused + * This option does nothing + * @deprecated use codec private options instead */ - int me_method; + attribute_deprecated int me_method; +#endif /** * If non NULL, 'draw_horiz_band' is called by the libavcodec @@ -1511,9 +1787,11 @@ */ float b_quant_factor; - /** obsolete FIXME remove */ - int rc_strategy; +#if FF_API_RC_STRATEGY + /** @deprecated use codec private option instead */ + attribute_deprecated int rc_strategy; #define FF_RC_STRATEGY_XVID 1 +#endif int b_frame_strategy; @@ -1734,20 +2012,18 @@ */ int me_range; +#if FF_API_QUANT_BIAS /** - * intra quantizer bias - * - encoding: Set by user. - * - decoding: unused + * @deprecated use encoder private option instead */ - int intra_quant_bias; + attribute_deprecated int intra_quant_bias; #define FF_DEFAULT_QUANT_BIAS 999999 /** - * inter quantizer bias - * - encoding: Set by user. - * - decoding: unused + * @deprecated use encoder private option instead */ - int inter_quant_bias; + attribute_deprecated int inter_quant_bias; +#endif /** * slice flags @@ -1998,7 +2274,7 @@ * * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame * except the last must contain exactly frame_size samples per channel. - * May be 0 when the codec has CODEC_CAP_VARIABLE_FRAME_SIZE set, then the + * May be 0 when the codec has AV_CODEC_CAP_VARIABLE_FRAME_SIZE set, then the * frame size is not restricted. * - decoding: may be set by some decoders to indicate constant frame size */ @@ -2200,7 +2476,7 @@ * buffers than buf[] can hold. extended_buf will be freed in * av_frame_unref(). * - * If CODEC_CAP_DR1 is not set then get_buffer2() must call + * If AV_CODEC_CAP_DR1 is not set then get_buffer2() must call * avcodec_default_get_buffer2() instead of providing buffers allocated by * some other means. * @@ -2322,7 +2598,7 @@ /** * maximum bitrate * - encoding: Set by user. - * - decoding: Set by libavcodec. + * - decoding: Set by user, may be overwritten by libavcodec. */ int rc_max_rate; @@ -2589,6 +2865,7 @@ #endif #define FF_DEBUG_BUFFERS 0x00008000 #define FF_DEBUG_THREADS 0x00010000 +#define FF_DEBUG_GREEN_MD 0x00800000 #define FF_DEBUG_NOMC 0x01000000 #if FF_API_DEBUG_MV @@ -2657,7 +2934,7 @@ /** * error - * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR. + * - encoding: Set by libavcodec if flags & AV_CODEC_FLAG_PSNR. * - decoding: unused */ uint64_t error[AV_NUM_DATA_POINTERS]; @@ -2737,12 +3014,16 @@ int lowres; #endif +#if FF_API_CODED_FRAME /** * the picture in the bitstream * - encoding: Set by libavcodec. * - decoding: unused + * + * @deprecated use the quality factor packet side data instead */ - AVFrame *coded_frame; + attribute_deprecated AVFrame *coded_frame; +#endif /** * thread count @@ -2906,17 +3187,16 @@ #define FF_PROFILE_JPEG2000_DCINEMA_2K 3 #define FF_PROFILE_JPEG2000_DCINEMA_4K 4 +#define FF_PROFILE_VP9_0 0 +#define FF_PROFILE_VP9_1 1 +#define FF_PROFILE_VP9_2 2 +#define FF_PROFILE_VP9_3 3 #define FF_PROFILE_HEVC_MAIN 1 #define FF_PROFILE_HEVC_MAIN_10 2 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3 #define FF_PROFILE_HEVC_REXT 4 -#define FF_PROFILE_VP9_0 0 -#define FF_PROFILE_VP9_1 1 -#define FF_PROFILE_VP9_2 2 -#define FF_PROFILE_VP9_3 3 - /** * level * - encoding: Set by user. @@ -3146,6 +3426,16 @@ * - decoding: set by user through AVOPtions (NO direct access) */ char *codec_whitelist; + + /* + * Properties of the stream that gets decoded + * To be accessed through av_codec_get_properties() (NO direct access) + * - encoding: unused + * - decoding: set by libavcodec + */ + unsigned properties; +#define FF_CODEC_PROPERTY_LOSSLESS 0x00000001 +#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002 } AVCodecContext; AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx); @@ -3154,6 +3444,8 @@ const AVCodecDescriptor *av_codec_get_codec_descriptor(const AVCodecContext *avctx); void av_codec_set_codec_descriptor(AVCodecContext *avctx, const AVCodecDescriptor *desc); +unsigned av_codec_get_codec_properties(const AVCodecContext *avctx); + int av_codec_get_lowres(const AVCodecContext *avctx); void av_codec_set_lowres(AVCodecContext *avctx, int val); @@ -3195,7 +3487,7 @@ enum AVCodecID id; /** * Codec capabilities. - * see CODEC_CAP_* + * see AV_CODEC_CAP_* */ int capabilities; const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} @@ -3316,7 +3608,7 @@ /** * Hardware accelerated codec capabilities. - * see FF_HWACCEL_CODEC_CAP_* + * see HWACCEL_CODEC_CAP_* */ int capabilities; @@ -3782,7 +4074,7 @@ * function returns successfully, the data is owned by the underlying AVBuffer. * The caller may not access the data through other means. * @param size size of data in bytes, without the padding. I.e. the full buffer - * size is assumed to be size + FF_INPUT_BUFFER_PADDING_SIZE. + * size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE. * * @return 0 on success, a negative AVERROR on error */ @@ -3980,7 +4272,7 @@ /** * The default callback for AVCodecContext.get_buffer2(). It is made public so * it can be called by custom get_buffer2() implementations for decoders without - * CODEC_CAP_DR1 set. + * AV_CODEC_CAP_DR1 set. */ int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags); @@ -4004,7 +4296,7 @@ * buffer that is acceptable for the codec if you do not use any horizontal * padding. * - * May only be used if a codec with CODEC_CAP_DR1 has been opened. + * May only be used if a codec with AV_CODEC_CAP_DR1 has been opened. */ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); @@ -4013,7 +4305,7 @@ * buffer that is acceptable for the codec if you also ensure that all * line sizes are a multiple of the respective linesize_align[i]. * - * May only be used if a codec with CODEC_CAP_DR1 has been opened. + * May only be used if a codec with AV_CODEC_CAP_DR1 has been opened. */ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[AV_NUM_DATA_POINTERS]); @@ -4111,15 +4403,15 @@ * needs to be fed to the decoder with remaining data until it is completely * consumed or an error occurs. * - * Some decoders (those marked with CODEC_CAP_DELAY) have a delay between input + * Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input * and output. This means that for some packets they will not immediately * produce decoded output and need to be flushed at the end of decoding to get * all the decoded data. Flushing is done by calling this function with packets * with avpkt->data set to NULL and avpkt->size set to 0 until it stops * returning samples. It is safe to flush even those decoders that are not - * marked with CODEC_CAP_DELAY, then no samples will be returned. + * marked with AV_CODEC_CAP_DELAY, then no samples will be returned. * - * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE + * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE * larger than the actual read bytes because some optimized bitstream * readers read 32 or 64 bits at once and could read over the end. * @@ -4142,7 +4434,7 @@ * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is * non-zero. Note that this field being set to zero * does not mean that an error has occurred. For - * decoders with CODEC_CAP_DELAY set, no given decode + * decoders with AV_CODEC_CAP_DELAY set, no given decode * call is guaranteed to produce a frame. * @param[in] avpkt The input AVPacket containing the input buffer. * At least avpkt->data and avpkt->size should be set. Some @@ -4159,14 +4451,14 @@ * Some decoders may support multiple frames in a single AVPacket, such * decoders would then just decode the first frame. * - * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than + * @warning The input buffer must be AV_INPUT_BUFFER_PADDING_SIZE larger than * the actual read bytes because some optimized bitstream readers read 32 or 64 * bits at once and could read over the end. * * @warning The end of the input buffer buf should be set to 0 to ensure that * no overreading happens for damaged MPEG streams. * - * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay + * @note Codecs which have the AV_CODEC_CAP_DELAY capability set have a delay * between input and output, these need to be fed with avpkt->data=NULL, * avpkt->size=0 at the end to return the remaining frames. * @@ -4206,7 +4498,7 @@ * Return a negative value on error, otherwise return the number of bytes used. * If no subtitle could be decompressed, got_sub_ptr is zero. * Otherwise, the subtitle is stored in *sub. - * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for + * Note that AV_CODEC_CAP_DR1 is not available for subtitle codecs. This is for * simplicity, because the performance difference is expect to be negligible * and reusing a get_buffer written for video codecs would probably perform badly * due to a potentially very different allocation pattern. @@ -4568,8 +4860,8 @@ * called to free the user supplied buffer). * @param[in] frame AVFrame containing the raw audio data to be encoded. * May be NULL when flushing an encoder that has the - * CODEC_CAP_DELAY capability set. - * If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame + * AV_CODEC_CAP_DELAY capability set. + * If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame * can have any number of samples. * If it is not set, frame->nb_samples must be equal to * avctx->frame_size for all frames except the last. @@ -4630,7 +4922,7 @@ * called to free the user supplied buffer). * @param[in] frame AVFrame containing the raw video data to be encoded. * May be NULL when flushing an encoder that has the - * CODEC_CAP_DELAY capability set. + * AV_CODEC_CAP_DELAY capability set. * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the * output packet is non-empty, and to 0 if it is * empty. If the function returns an error, the @@ -5167,7 +5459,7 @@ /** * Same behaviour av_fast_malloc but the buffer has additional - * FF_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0. + * AV_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0. * * In addition the whole buffer will initially and after resizes * be 0-initialized so that no uninitialized data will ever appear. diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/avpacket.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/avpacket.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/avpacket.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/avpacket.c 2015-07-28 17:20:07.000000000 +0000 @@ -68,14 +68,14 @@ static int packet_alloc(AVBufferRef **buf, int size) { int ret; - if ((unsigned)size >= (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE) + if ((unsigned)size >= (unsigned)size + AV_INPUT_BUFFER_PADDING_SIZE) return AVERROR(EINVAL); - ret = av_buffer_realloc(buf, size + FF_INPUT_BUFFER_PADDING_SIZE); + ret = av_buffer_realloc(buf, size + AV_INPUT_BUFFER_PADDING_SIZE); if (ret < 0) return ret; - memset((*buf)->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset((*buf)->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); return 0; } @@ -105,20 +105,20 @@ if (pkt->size <= size) return; pkt->size = size; - memset(pkt->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(pkt->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); } int av_grow_packet(AVPacket *pkt, int grow_by) { int new_size; - av_assert0((unsigned)pkt->size <= INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE); + av_assert0((unsigned)pkt->size <= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE); if (!pkt->size) return av_new_packet(pkt, grow_by); if ((unsigned)grow_by > - INT_MAX - (pkt->size + FF_INPUT_BUFFER_PADDING_SIZE)) + INT_MAX - (pkt->size + AV_INPUT_BUFFER_PADDING_SIZE)) return -1; - new_size = pkt->size + grow_by + FF_INPUT_BUFFER_PADDING_SIZE; + new_size = pkt->size + grow_by + AV_INPUT_BUFFER_PADDING_SIZE; if (pkt->buf) { int ret = av_buffer_realloc(&pkt->buf, new_size); if (ret < 0) @@ -136,17 +136,17 @@ } pkt->data = pkt->buf->data; pkt->size += grow_by; - memset(pkt->data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE); return 0; } int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size) { - if (size >= INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) + if (size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) return AVERROR(EINVAL); - pkt->buf = av_buffer_create(data, size + FF_INPUT_BUFFER_PADDING_SIZE, + pkt->buf = av_buffer_create(data, size + AV_INPUT_BUFFER_PADDING_SIZE, av_buffer_default_free, NULL, 0); if (!pkt->buf) return AVERROR(ENOMEM); @@ -174,9 +174,9 @@ void *data; \ if (padding) { \ if ((unsigned)(size) > \ - (unsigned)(size) + FF_INPUT_BUFFER_PADDING_SIZE) \ + (unsigned)(size) + AV_INPUT_BUFFER_PADDING_SIZE) \ goto failed_alloc; \ - ALLOC(data, size + FF_INPUT_BUFFER_PADDING_SIZE); \ + ALLOC(data, size + AV_INPUT_BUFFER_PADDING_SIZE); \ } else { \ ALLOC(data, size); \ } \ @@ -185,7 +185,7 @@ memcpy(data, src, size); \ if (padding) \ memset((uint8_t *)data + size, 0, \ - FF_INPUT_BUFFER_PADDING_SIZE); \ + AV_INPUT_BUFFER_PADDING_SIZE); \ dst = data; \ } while (0) @@ -303,7 +303,7 @@ if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data)) return NULL; - if ((unsigned)size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) + if ((unsigned)size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) return NULL; pkt->side_data = av_realloc(pkt->side_data, @@ -311,7 +311,7 @@ if (!pkt->side_data) return NULL; - pkt->side_data[elems].data = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE); + pkt->side_data[elems].data = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); if (!pkt->side_data[elems].data) return NULL; pkt->side_data[elems].size = size; @@ -366,7 +366,7 @@ AVBufferRef *buf; int i; uint8_t *p; - uint64_t size= pkt->size + 8LL + FF_INPUT_BUFFER_PADDING_SIZE; + uint64_t size= pkt->size + 8LL + AV_INPUT_BUFFER_PADDING_SIZE; AVPacket old= *pkt; for (i=0; idestruct = dummy_destruct_packet; FF_ENABLE_DEPRECATION_WARNINGS #endif - pkt->size = size - FF_INPUT_BUFFER_PADDING_SIZE; + pkt->size = size - AV_INPUT_BUFFER_PADDING_SIZE; bytestream_put_buffer(&p, old.data, old.size); for (i=old.side_data_elems-1; i>=0; i--) { bytestream_put_buffer(&p, old.side_data[i].data, old.side_data[i].size); @@ -392,7 +392,7 @@ } bytestream_put_be64(&p, FF_MERGE_MARKER); av_assert0(p-pkt->data == pkt->size); - memset(p, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(p, 0, AV_INPUT_BUFFER_PADDING_SIZE); av_free_packet(&old); pkt->side_data_elems = 0; pkt->side_data = NULL; @@ -425,7 +425,7 @@ for (i=0; ; i++){ size= AV_RB32(p); av_assert0(size<=INT_MAX && p - pkt->data >= size); - pkt->side_data[i].data = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE); + pkt->side_data[i].data = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); pkt->side_data[i].size = size; pkt->side_data[i].type = p[4]&127; if (!pkt->side_data[i].data) @@ -602,3 +602,28 @@ if (pkt->convergence_duration > 0) pkt->convergence_duration = av_rescale_q(pkt->convergence_duration, src_tb, dst_tb); } + +int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type) +{ + uint8_t *side_data; + int side_data_size; + int i; + + side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size); + if (!side_data) { + side_data_size = 4+4+8*error_count; + side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, + side_data_size); + } + + if (!side_data || side_data_size < 4+4+8*error_count) + return AVERROR(ENOMEM); + + AV_WL32(side_data , quality ); + side_data[4] = pict_type; + side_data[5] = error_count; + for (i = 0; iis_mjpeg) - return ff_mjpeg_decode_init(avctx); + if(a->is_mjpeg) { + AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG); + AVDictionary *thread_opt = NULL; + if (!codec) { + av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n"); + return AVERROR_DECODER_NOT_FOUND; + } + + a->mjpeg_avctx = avcodec_alloc_context3(codec); + + av_dict_set(&thread_opt, "threads", "1", 0); // Is this needed ? + a->mjpeg_avctx->refcounted_frames = 1; + a->mjpeg_avctx->flags = avctx->flags; + a->mjpeg_avctx->idct_algo = avctx->idct_algo; + a->mjpeg_avctx->lowres = avctx->lowres; + a->mjpeg_avctx->width = avctx->width; + a->mjpeg_avctx->height = avctx->height; + + if ((ret = ff_codec_open2_recursive(a->mjpeg_avctx, codec, &thread_opt)) < 0) { + av_log(avctx, AV_LOG_ERROR, "MJPEG codec failed to open\n"); + } + av_dict_free(&thread_opt); + + return ret; + } if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0) return ret; @@ -68,8 +91,8 @@ { AVRnContext *a = avctx->priv_data; - if(a->is_mjpeg) - ff_mjpeg_decode_end(avctx); + avcodec_close(a->mjpeg_avctx); + av_freep(&a->mjpeg_avctx); return 0; } @@ -83,8 +106,27 @@ int buf_size = avpkt->size; int y, ret, true_height; - if(a->is_mjpeg) - return ff_mjpeg_decode_frame(avctx, data, got_frame, avpkt); + if(a->is_mjpeg) { + ret = avcodec_decode_video2(a->mjpeg_avctx, data, got_frame, avpkt); + + if (ret >= 0 && *got_frame && avctx->width <= p->width && avctx->height <= p->height) { + int shift = p->height - avctx->height; + int subsample_h, subsample_v; + + av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &subsample_h, &subsample_v); + + p->data[0] += p->linesize[0] * shift; + if (p->data[2]) { + p->data[1] += p->linesize[1] * (shift>>subsample_v); + p->data[2] += p->linesize[2] * (shift>>subsample_v); + } + + p->width = avctx->width; + p->height = avctx->height; + } + avctx->pix_fmt = a->mjpeg_avctx->pix_fmt; + return ret; + } true_height = buf_size / (2*avctx->width); @@ -126,6 +168,6 @@ .init = init, .close = end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .max_lowres = 3, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/avs.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/avs.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/avs.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/avs.c 2015-07-28 17:20:07.000000000 +0000 @@ -185,5 +185,5 @@ .init = avs_decode_init, .decode = avs_decode_frame, .close = avs_decode_end, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/avuidec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/avuidec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/avuidec.c 2015-06-18 18:54:56.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/avuidec.c 2015-07-28 17:20:07.000000000 +0000 @@ -126,5 +126,5 @@ .id = AV_CODEC_ID_AVUI, .init = avui_decode_init, .decode = avui_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/avuienc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/avuienc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/avuienc.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/avuienc.c 2015-08-03 17:20:02.000000000 +0000 @@ -30,7 +30,7 @@ av_log(avctx, AV_LOG_ERROR, "Only 720x486 and 720x576 are supported.\n"); return AVERROR(EINVAL); } - if (!(avctx->extradata = av_mallocz(144 + FF_INPUT_BUFFER_PADDING_SIZE))) + if (!(avctx->extradata = av_mallocz(144 + AV_INPUT_BUFFER_PADDING_SIZE))) return AVERROR(ENOMEM); avctx->extradata_size = 144; memcpy(avctx->extradata, "\0\0\0\x18""APRGAPRG0001", 16); @@ -44,11 +44,6 @@ AV_WB32(avctx->extradata + 48, avctx->height); memcpy(avctx->extradata + 52, "\0\0\0\x1\0\0\0\x20\0\0\0\x2", 12); - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) { - av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n"); - return AVERROR(ENOMEM); - } return 0; } @@ -67,16 +62,14 @@ skip = 16; } size = 2 * avctx->width * (avctx->height + skip) + 8 * interlaced; - if ((ret = ff_alloc_packet2(avctx, pkt, size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, size, size)) < 0) return ret; dst = pkt->data; if (!interlaced) { + memset(dst, 0, avctx->width * skip); dst += avctx->width * skip; } - avctx->coded_frame->key_frame = 1; - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; - for (i = 0; i <= interlaced; i++) { uint8_t *src; if (interlaced && avctx->height == 486) { @@ -84,6 +77,7 @@ } else { src = pic->data[0] + i * pic->linesize[0]; } + memset(dst, 0, avctx->width * skip + 4 * i); dst += avctx->width * skip + 4 * i; for (j = 0; j < avctx->height; j += interlaced + 1) { memcpy(dst, src, avctx->width * 2); @@ -97,13 +91,6 @@ return 0; } -static av_cold int avui_encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - - return 0; -} - AVCodec ff_avui_encoder = { .name = "avui", .long_name = NULL_IF_CONFIG_SMALL("Avid Meridien Uncompressed"), @@ -111,7 +98,6 @@ .id = AV_CODEC_ID_AVUI, .init = avui_encode_init, .encode2 = avui_encode_frame, - .close = avui_encode_close, - .capabilities = CODEC_CAP_EXPERIMENTAL, + .capabilities = AV_CODEC_CAP_EXPERIMENTAL | AV_CODEC_CAP_INTRA_ONLY, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_UYVY422, AV_PIX_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/bethsoftvideo.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/bethsoftvideo.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/bethsoftvideo.c 2015-06-18 18:54:56.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/bethsoftvideo.c 2015-07-28 17:20:07.000000000 +0000 @@ -162,5 +162,5 @@ .init = bethsoftvid_decode_init, .close = bethsoftvid_decode_end, .decode = bethsoftvid_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/bfi.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/bfi.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/bfi.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/bfi.c 2015-07-28 17:20:07.000000000 +0000 @@ -184,5 +184,5 @@ .init = bfi_decode_init, .close = bfi_decode_close, .decode = bfi_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/binkaudio.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/binkaudio.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/binkaudio.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/binkaudio.c 2015-07-28 17:20:07.000000000 +0000 @@ -302,10 +302,10 @@ av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); return AVERROR_INVALIDDATA; } - buf = av_realloc(s->packet_buffer, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE); + buf = av_realloc(s->packet_buffer, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE); if (!buf) return AVERROR(ENOMEM); - memset(buf + avpkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(buf + avpkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE); s->packet_buffer = buf; memcpy(s->packet_buffer, avpkt->data, avpkt->size); if ((ret = init_get_bits8(gb, s->packet_buffer, avpkt->size)) < 0) @@ -343,7 +343,7 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1, }; AVCodec ff_binkaudio_dct_decoder = { @@ -355,5 +355,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/bink.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/bink.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/bink.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/bink.c 2015-07-28 17:20:07.000000000 +0000 @@ -1354,5 +1354,5 @@ .close = decode_end, .decode = decode_frame, .flush = flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/bintext.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/bintext.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/bintext.c 2015-06-18 18:54:56.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/bintext.c 2015-07-28 17:20:07.000000000 +0000 @@ -227,7 +227,7 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif #if CONFIG_XBIN_DECODER @@ -240,7 +240,7 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif #if CONFIG_IDF_DECODER @@ -253,6 +253,6 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/blockdsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/blockdsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/blockdsp.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/blockdsp.c 2015-06-23 17:20:03.000000000 +0000 @@ -77,4 +77,6 @@ #else ff_blockdsp_init_x86(c, high_bit_depth); #endif /* FF_API_XVMC */ + if (ARCH_MIPS) + ff_blockdsp_init_mips(c, high_bit_depth); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/blockdsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/blockdsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/blockdsp.h 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/blockdsp.h 2015-06-23 17:20:03.000000000 +0000 @@ -49,5 +49,6 @@ #else void ff_blockdsp_init_x86(BlockDSPContext *c, unsigned high_bit_depth); #endif /* FF_API_XVMC */ +void ff_blockdsp_init_mips(BlockDSPContext *c, unsigned high_bit_depth); #endif /* AVCODEC_BLOCKDSP_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/bmp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/bmp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/bmp.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/bmp.c 2015-07-28 17:20:07.000000000 +0000 @@ -349,5 +349,5 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_BMP, .decode = bmp_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/bmpenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/bmpenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/bmpenc.c 2015-06-18 18:54:56.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/bmpenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -60,10 +60,6 @@ return AVERROR(EINVAL); } - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - return 0; } @@ -78,8 +74,12 @@ int bit_count = avctx->bits_per_coded_sample; uint8_t *ptr, *buf; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif switch (avctx->pix_fmt) { case AV_PIX_FMT_RGB444: compression = BMP_BITFIELDS; @@ -118,7 +118,7 @@ #define SIZE_BITMAPINFOHEADER 40 hsize = SIZE_BITMAPFILEHEADER + SIZE_BITMAPINFOHEADER + (pal_entries << 2); n_bytes = n_bytes_image + hsize; - if ((ret = ff_alloc_packet2(avctx, pkt, n_bytes)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, n_bytes, 0)) < 0) return ret; buf = pkt->data; bytestream_put_byte(&buf, 'B'); // BITMAPFILEHEADER.bfType @@ -163,12 +163,6 @@ return 0; } -static av_cold int bmp_encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - return 0; -} - AVCodec ff_bmp_encoder = { .name = "bmp", .long_name = NULL_IF_CONFIG_SMALL("BMP (Windows and OS/2 bitmap)"), @@ -176,7 +170,6 @@ .id = AV_CODEC_ID_BMP, .init = bmp_encode_init, .encode2 = bmp_encode_frame, - .close = bmp_encode_close, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGRA, AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB565, AV_PIX_FMT_RGB555, AV_PIX_FMT_RGB444, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/bmvaudio.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/bmvaudio.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/bmvaudio.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/bmvaudio.c 2015-07-28 17:20:07.000000000 +0000 @@ -85,5 +85,5 @@ .id = AV_CODEC_ID_BMV_AUDIO, .init = bmv_aud_decode_init, .decode = bmv_aud_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/bmvvideo.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/bmvvideo.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/bmvvideo.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/bmvvideo.c 2015-07-28 17:20:07.000000000 +0000 @@ -294,5 +294,5 @@ .priv_data_size = sizeof(BMVDecContext), .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/brenderpix.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/brenderpix.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/brenderpix.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/brenderpix.c 2015-07-28 17:20:07.000000000 +0000 @@ -288,5 +288,5 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_BRENDER_PIX, .decode = pix_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/bytestream.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/bytestream.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/bytestream.h 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/bytestream.h 2015-07-13 17:20:03.000000000 +0000 @@ -71,8 +71,10 @@ } \ static av_always_inline type bytestream2_get_ ## name(GetByteContext *g) \ { \ - if (g->buffer_end - g->buffer < bytes) \ + if (g->buffer_end - g->buffer < bytes) { \ + g->buffer = g->buffer_end; \ return 0; \ + } \ return bytestream2_get_ ## name ## u(g); \ } \ static av_always_inline type bytestream2_peek_ ## name(GetByteContext *g) \ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/c93.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/c93.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/c93.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/c93.c 2015-07-28 17:20:07.000000000 +0000 @@ -268,5 +268,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cavsdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cavsdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cavsdec.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cavsdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -1262,6 +1262,6 @@ .init = ff_cavs_init, .close = ff_cavs_end, .decode = cavs_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .flush = cavs_flush, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cbrt_fixed_tablegen.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cbrt_fixed_tablegen.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cbrt_fixed_tablegen.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cbrt_fixed_tablegen.c 2015-07-09 17:20:03.000000000 +0000 @@ -0,0 +1,24 @@ +/* + * Generate a header file for hardcoded AAC cube-root table + * + * Copyright (c) 2010 Reimar Döffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#define USE_FIXED 1 +#include "cbrt_tablegen_template.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cbrt_tablegen.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cbrt_tablegen.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cbrt_tablegen.c 2014-12-01 00:21:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cbrt_tablegen.c 2015-07-09 17:20:03.000000000 +0000 @@ -20,18 +20,5 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#define CONFIG_HARDCODED_TABLES 0 -#include "cbrt_tablegen.h" -#include "tableprint.h" - -int main(void) -{ - cbrt_tableinit(); - - write_fileheader(); - - WRITE_ARRAY("static const", uint32_t, cbrt_tab); - - return 0; -} +#define USE_FIXED 0 +#include "cbrt_tablegen_template.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cbrt_tablegen.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/cbrt_tablegen.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cbrt_tablegen.h 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cbrt_tablegen.h 2015-07-23 17:20:03.000000000 +0000 @@ -26,14 +26,26 @@ #include #include #include "libavutil/attributes.h" +#include "libavcodec/aac_defines.h" + +#if USE_FIXED +#define CBRT(x) (int)floor((x).f * 8192 + 0.5) +#else +#define CBRT(x) x.i +#endif #if CONFIG_HARDCODED_TABLES +#if USE_FIXED +#define cbrt_tableinit_fixed() +#include "libavcodec/cbrt_fixed_tables.h" +#else #define cbrt_tableinit() #include "libavcodec/cbrt_tables.h" +#endif #else static uint32_t cbrt_tab[1 << 13]; -static av_cold void cbrt_tableinit(void) +static av_cold void AAC_RENAME(cbrt_tableinit)(void) { if (!cbrt_tab[(1<<13) - 1]) { int i; @@ -44,7 +56,7 @@ uint32_t i; } f; f.f = pow(i, 1.0 / 3.0) * i; - cbrt_tab[i] = f.i; + cbrt_tab[i] = CBRT(f); } } } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cbrt_tablegen_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cbrt_tablegen_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cbrt_tablegen_template.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cbrt_tablegen_template.c 2015-07-23 17:20:03.000000000 +0000 @@ -0,0 +1,37 @@ +/* + * Generate a header file for hardcoded AAC cube-root table + * + * Copyright (c) 2010 Reimar Döffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#define CONFIG_HARDCODED_TABLES 0 +#include "cbrt_tablegen.h" +#include "tableprint.h" + +int main(void) +{ + AAC_RENAME(cbrt_tableinit)(); + + write_fileheader(); + + WRITE_ARRAY("static const", uint32_t, cbrt_tab); + + return 0; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cdgraphics.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cdgraphics.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cdgraphics.c 2015-06-18 18:54:56.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cdgraphics.c 2015-07-28 17:20:07.000000000 +0000 @@ -376,5 +376,5 @@ .init = cdg_decode_init, .close = cdg_decode_end, .decode = cdg_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cdxl.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cdxl.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cdxl.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cdxl.c 2015-07-28 17:20:07.000000000 +0000 @@ -272,7 +272,7 @@ if (encoding) { av_fast_padded_malloc(&c->new_video, &c->new_video_size, - h * w + FF_INPUT_BUFFER_PADDING_SIZE); + h * w + AV_INPUT_BUFFER_PADDING_SIZE); if (!c->new_video) return AVERROR(ENOMEM); if (c->bpp == 8) @@ -305,5 +305,5 @@ .init = cdxl_decode_init, .close = cdxl_decode_end, .decode = cdxl_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cinepak.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cinepak.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cinepak.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cinepak.c 2015-07-28 17:20:07.000000000 +0000 @@ -484,5 +484,5 @@ .init = cinepak_decode_init, .close = cinepak_decode_end, .decode = cinepak_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cinepakenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cinepakenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cinepakenc.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cinepakenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -327,7 +327,7 @@ (info->v4_size ? CHUNK_HEADER_SIZE + info->v4_size * entry_size : 0) + CHUNK_HEADER_SIZE) << 3; - //av_log(s->avctx, AV_LOG_INFO, "sizes %3i %3i -> %9lli score mb_count %i", info->v1_size, info->v4_size, (long long int)ret, mb_count); + //av_log(s->avctx, AV_LOG_INFO, "sizes %3i %3i -> %9"PRId64" score mb_count %i", info->v1_size, info->v4_size, ret, mb_count); #ifdef CINEPAK_REPORT_SERR *serr = 0; @@ -897,7 +897,7 @@ // check that we did it right in the beginning of the function av_assert0(i >= size); // training set is no smaller than the codebook - //av_log(s->avctx, AV_LOG_INFO, "isv1 %i size= %i i= %i error %lli\n", v1mode, size, i, (long long int)total_error); + //av_log(s->avctx, AV_LOG_INFO, "isv1 %i size= %i i= %i error %"PRId64"\n", v1mode, size, i, total_error); return size; } @@ -1050,7 +1050,7 @@ } } - //av_log(s->avctx, AV_LOG_INFO, "%3i %3i score = %lli\n", v1_size, v4_size, (long long int)score); + //av_log(s->avctx, AV_LOG_INFO, "%3i %3i score = %"PRId64"\n", v1_size, v4_size, score); if(best_size == 0 || score < *best_score) { @@ -1060,10 +1060,10 @@ #endif best_size = encode_mode(s, h, scratch_pict, last_pict, &info, s->strip_buf + STRIP_HEADER_SIZE); - //av_log(s->avctx, AV_LOG_INFO, "mode %i, %3i, %3i: %18lli %i B", mode, info.v1_size, info.v4_size, (long long int)score, best_size); + //av_log(s->avctx, AV_LOG_INFO, "mode %i, %3i, %3i: %18"PRId64" %i B", mode, info.v1_size, info.v4_size, score, best_size); //av_log(s->avctx, AV_LOG_INFO, "\n"); #ifdef CINEPAK_REPORT_SERR - av_log(s->avctx, AV_LOG_INFO, "mode %i, %3i, %3i: %18lli %i B\n", mode, v1_size, v4_size, (long long int)serr, best_size); + av_log(s->avctx, AV_LOG_INFO, "mode %i, %3i, %3i: %18"PRId64" %i B\n", mode, v1_size, v4_size, serr, best_size); #endif #ifdef CINEPAKENC_DEBUG @@ -1224,9 +1224,9 @@ best_serr = serr; #endif best_size = size + write_cvid_header(s, s->frame_buf, num_strips, size, isakeyframe); - //av_log(s->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12lli, %i B\n", num_strips, (long long int)score, best_size); + //av_log(s->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12"PRId64", %i B\n", num_strips, score, best_size); #ifdef CINEPAK_REPORT_SERR - av_log(s->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12lli, %i B\n", num_strips, (long long int)serr, best_size); + av_log(s->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12"PRId64", %i B\n", num_strips, serr, best_size); #endif FFSWAP(AVFrame *, s->best_frame, s->scratch_frame); @@ -1275,7 +1275,7 @@ s->lambda = frame->quality ? frame->quality - 1 : 2 * FF_LAMBDA_SCALE; - if ((ret = ff_alloc_packet2(avctx, pkt, s->frame_buf_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, s->frame_buf_size, 0)) < 0) return ret; ret = rd_frame(s, frame, (s->curframe == 0), pkt->data, s->frame_buf_size); pkt->size = ret; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cljrdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cljrdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cljrdec.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cljrdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -89,6 +89,6 @@ .id = AV_CODEC_ID_CLJR, .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cljrenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cljrenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cljrenc.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cljrenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -56,7 +56,7 @@ return AVERROR_EXPERIMENTAL; } - if ((ret = ff_alloc_packet2(avctx, pkt, 32*avctx->height*avctx->width/4)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, 32*avctx->height*avctx->width/4, 0)) < 0) return ret; init_put_bits(&pb, pkt->data, pkt->size); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cllc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cllc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cllc.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cllc.c 2015-07-28 17:20:07.000000000 +0000 @@ -495,5 +495,5 @@ .init = cllc_decode_init, .decode = cllc_decode_frame, .close = cllc_decode_close, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cngdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cngdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cngdec.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cngdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -167,5 +167,5 @@ .close = cng_decode_close, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cngenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cngenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cngenc.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cngenc.c 2015-08-03 17:20:02.000000000 +0000 @@ -75,7 +75,7 @@ int qdbov; int16_t *samples = (int16_t*) frame->data[0]; - if ((ret = ff_alloc_packet(avpkt, 1 + p->order))) { + if ((ret = ff_alloc_packet2(avctx, avpkt, 1 + p->order, 1 + p->order))) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); return ret; } @@ -97,7 +97,7 @@ avpkt->data[1 + i] = p->ref_coef[i] * 127 + 127; *got_packet_ptr = 1; - avpkt->size = 1 + p->order; + av_assert1(avpkt->size == 1 + p->order); return 0; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/codec_desc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/codec_desc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/codec_desc.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/codec_desc.c 2015-06-26 17:20:02.000000000 +0000 @@ -1178,7 +1178,7 @@ { .id = AV_CODEC_ID_SMVJPEG, .type = AVMEDIA_TYPE_VIDEO, - .name = "smv", + .name = "smvjpeg", .long_name = NULL_IF_CONFIG_SMALL("Sigmatel Motion Video"), }, @@ -1252,6 +1252,13 @@ .long_name = NULL_IF_CONFIG_SMALL("Canopus HQ/HQA"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_HAP, + .type = AVMEDIA_TYPE_VIDEO, + .name = "hap", + .long_name = NULL_IF_CONFIG_SMALL("Vidvox Hap decoder"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, + }, /* image codecs */ { @@ -1276,6 +1283,14 @@ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, }, { + .id = AV_CODEC_ID_DDS, + .type = AVMEDIA_TYPE_VIDEO, + .name = "dds", + .long_name = NULL_IF_CONFIG_SMALL("DirectDraw Surface image decoder"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | + AV_CODEC_PROP_LOSSLESS, + }, + { .id = AV_CODEC_ID_DPX, .type = AVMEDIA_TYPE_VIDEO, .name = "dpx", @@ -1820,7 +1835,14 @@ .id = AV_CODEC_ID_ADPCM_THP, .type = AVMEDIA_TYPE_AUDIO, .name = "adpcm_thp", - .long_name = NULL_IF_CONFIG_SMALL("ADPCM Nintendo Gamecube THP"), + .long_name = NULL_IF_CONFIG_SMALL("ADPCM Nintendo THP"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_ADPCM_THP_LE, + .type = AVMEDIA_TYPE_AUDIO, + .name = "adpcm_thp_le", + .long_name = NULL_IF_CONFIG_SMALL("ADPCM Nintendo THP (Little-Endian)"), .props = AV_CODEC_PROP_LOSSY, }, { @@ -2517,6 +2539,13 @@ .props = AV_CODEC_PROP_LOSSY, }, { + .id = AV_CODEC_ID_4GV, + .type = AVMEDIA_TYPE_AUDIO, + .name = "4gv", + .long_name = NULL_IF_CONFIG_SMALL("4GV (Fourth Generation Vocoder)"), + .props = AV_CODEC_PROP_LOSSY, + }, + { .id = AV_CODEC_ID_DSD_LSBF, .type = AVMEDIA_TYPE_AUDIO, .name = "dsd_lsbf", @@ -2880,6 +2909,13 @@ .props = AV_CODEC_PROP_LOSSLESS, }, { + .id = AV_CODEC_ID_PCM_S16BE_PLANAR_DEPRECATED, + .type = AVMEDIA_TYPE_AUDIO, + .name = "pcm_s16be_planar_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("PCM signed 16-bit big-endian planar (deprecated id)"), + .props = AV_CODEC_PROP_LOSSLESS, + }, + { .id = AV_CODEC_ID_TAK_DEPRECATED, .type = AVMEDIA_TYPE_AUDIO, .name = "tak_deprecated", diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cook.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cook.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cook.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cook.c 2015-07-28 17:20:07.000000000 +0000 @@ -1232,11 +1232,11 @@ /* Pad the databuffer with: DECODE_BYTES_PAD1 or DECODE_BYTES_PAD2 for decode_bytes(), - FF_INPUT_BUFFER_PADDING_SIZE, for the bitstreamreader. */ + AV_INPUT_BUFFER_PADDING_SIZE, for the bitstreamreader. */ q->decoded_bytes_buffer = av_mallocz(avctx->block_align + DECODE_BYTES_PAD1(avctx->block_align) - + FF_INPUT_BUFFER_PADDING_SIZE); + + AV_INPUT_BUFFER_PADDING_SIZE); if (!q->decoded_bytes_buffer) return AVERROR(ENOMEM); @@ -1282,7 +1282,7 @@ .init = cook_decode_init, .close = cook_decode_close, .decode = cook_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cpia.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cpia.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cpia.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cpia.c 2015-07-28 17:20:07.000000000 +0000 @@ -229,5 +229,5 @@ .init = cpia_decode_init, .close = cpia_decode_end, .decode = cpia_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/crystalhd.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/crystalhd.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/crystalhd.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/crystalhd.c 2015-07-28 17:20:07.000000000 +0000 @@ -422,7 +422,7 @@ int dummy_int; /* Back up the extradata so it can be restored at close time. */ - priv->orig_extradata = av_malloc(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + priv->orig_extradata = av_malloc(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!priv->orig_extradata) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate copy of extradata\n"); @@ -1098,7 +1098,7 @@ .init = init, .close = uninit, .decode = decode, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .flush = flush, .pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUYV422, AV_PIX_FMT_NONE}, .priv_class = &h264_class, @@ -1122,7 +1122,7 @@ .init = init, .close = uninit, .decode = decode, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .flush = flush, .pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUYV422, AV_PIX_FMT_NONE}, .priv_class = &mpeg2_class, @@ -1146,7 +1146,7 @@ .init = init, .close = uninit, .decode = decode, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .flush = flush, .pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUYV422, AV_PIX_FMT_NONE}, .priv_class = &mpeg4_class, @@ -1170,7 +1170,7 @@ .init = init, .close = uninit, .decode = decode, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_EXPERIMENTAL, .flush = flush, .pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUYV422, AV_PIX_FMT_NONE}, .priv_class = &msmpeg4_class, @@ -1194,7 +1194,7 @@ .init = init, .close = uninit, .decode = decode, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .flush = flush, .pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUYV422, AV_PIX_FMT_NONE}, .priv_class = &vc1_class, @@ -1218,7 +1218,7 @@ .init = init, .close = uninit, .decode = decode, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .flush = flush, .pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUYV422, AV_PIX_FMT_NONE}, .priv_class = &wmv3_class, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cscd.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cscd.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cscd.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cscd.c 2015-07-28 17:20:07.000000000 +0000 @@ -166,5 +166,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/cyuv.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/cyuv.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/cyuv.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/cyuv.c 2015-07-28 17:20:07.000000000 +0000 @@ -184,7 +184,7 @@ .priv_data_size = sizeof(CyuvDecodeContext), .init = cyuv_decode_init, .decode = cyuv_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif @@ -197,6 +197,6 @@ .priv_data_size = sizeof(CyuvDecodeContext), .init = cyuv_decode_init, .decode = cyuv_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/d3d11va.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/d3d11va.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/d3d11va.h 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/d3d11va.h 2015-07-29 17:20:04.000000000 +0000 @@ -30,9 +30,9 @@ * Public libavcodec D3D11VA header. */ -#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0602 #undef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 +#define _WIN32_WINNT 0x0602 #endif #include diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dcadec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dcadec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dcadec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dcadec.c 2015-07-28 17:20:07.000000000 +0000 @@ -1669,11 +1669,18 @@ /* If we have XXCH then the channel layout is managed differently */ /* note that XLL will also have another way to do things */ +#if FF_API_REQUEST_CHANNELS +FF_DISABLE_DEPRECATION_WARNINGS if (!(s->core_ext_mask & DCA_EXT_XXCH) || (s->core_ext_mask & DCA_EXT_XXCH && avctx->request_channels > 0 && avctx->request_channels < num_core_channels + !!s->lfe + s->xxch_chset_nch[0])) - { /* xxx should also do MA extensions */ + { +FF_ENABLE_DEPRECATION_WARNINGS +#else + if (!(s->core_ext_mask & DCA_EXT_XXCH)) { +#endif + /* xxx should also do MA extensions */ if (s->amode < 16) { avctx->channel_layout = ff_dca_core_channel_layout[s->amode]; @@ -1750,6 +1757,8 @@ /* we only get here if an XXCH channel set can be added to the mix */ channel_mask = s->xxch_core_spkmask; +#if FF_API_REQUEST_CHANNELS +FF_DISABLE_DEPRECATION_WARNINGS if (avctx->request_channels > 0 && avctx->request_channels < s->prim_channels) { channels = num_core_channels + !!s->lfe; @@ -1758,7 +1767,10 @@ channels += s->xxch_chset_nch[i]; channel_mask |= s->xxch_spk_masks[i]; } - } else { +FF_ENABLE_DEPRECATION_WARNINGS + } else +#endif + { channels = s->prim_channels + !!s->lfe; for (i = 0; i < s->xxch_chset; i++) { channel_mask |= s->xxch_spk_masks[i]; @@ -1988,7 +2000,7 @@ s->avctx = avctx; dca_init_vlcs(); - s->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!s->fdsp) return AVERROR(ENOMEM); @@ -2056,7 +2068,7 @@ .init = dca_decode_init, .decode = dca_decode_frame, .close = dca_decode_end, - .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, .profiles = NULL_IF_CONFIG_SMALL(profiles), diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dcaenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dcaenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dcaenc.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dcaenc.c 2015-08-04 17:20:03.000000000 +0000 @@ -916,7 +916,7 @@ const int32_t *samples; int ret, i; - if ((ret = ff_alloc_packet2(avctx, avpkt, c->frame_size )) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, c->frame_size , 0)) < 0) return ret; samples = (const int32_t *)frame->data[0]; @@ -938,6 +938,10 @@ for (i = 0; i < SUBFRAMES; i++) put_subframe(c, i); + + for (i = put_bits_count(&c->pb); i < 8*c->frame_size; i++) + put_bits(&c->pb, 1, 0); + flush_put_bits(&c->pb); avpkt->pts = frame->pts; @@ -960,7 +964,7 @@ .priv_data_size = sizeof(DCAEncContext), .init = encode_init, .encode2 = encode_frame, - .capabilities = CODEC_CAP_EXPERIMENTAL, + .capabilities = AV_CODEC_CAP_EXPERIMENTAL, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE }, .supported_samplerates = sample_rates, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dca_parser.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dca_parser.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dca_parser.c 2015-06-19 20:44:37.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dca_parser.c 2015-07-28 17:20:07.000000000 +0000 @@ -113,7 +113,7 @@ int *sample_rate, int *framesize) { GetBitContext gb; - uint8_t hdr[12 + FF_INPUT_BUFFER_PADDING_SIZE] = { 0 }; + uint8_t hdr[12 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 }; int ret, sample_blocks, sr_code; if (buf_size < 12) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dds.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dds.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dds.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dds.c 2015-07-28 17:20:07.000000000 +0000 @@ -0,0 +1,699 @@ +/* + * DirectDraw Surface image decoder + * Copyright (C) 2015 Vittorio Giovara + * + * 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 + */ + +/** + * @file + * DDS decoder + * + * https://msdn.microsoft.com/en-us/library/bb943982%28v=vs.85%29.aspx + */ + +#include + +#include "libavutil/imgutils.h" + +#include "avcodec.h" +#include "bytestream.h" +#include "internal.h" +#include "texturedsp.h" +#include "thread.h" + +#define DDPF_FOURCC (1 << 2) +#define DDPF_PALETTE (1 << 5) +#define DDPF_NORMALMAP (1 << 31) + +enum DDSPostProc { + DDS_NONE = 0, + DDS_ALPHA_EXP, + DDS_NORMAL_MAP, + DDS_RAW_YCOCG, + DDS_SWAP_ALPHA, + DDS_SWIZZLE_A2XY, + DDS_SWIZZLE_RBXG, + DDS_SWIZZLE_RGXB, + DDS_SWIZZLE_RXBG, + DDS_SWIZZLE_RXGB, + DDS_SWIZZLE_XGBR, + DDS_SWIZZLE_XRBG, + DDS_SWIZZLE_XGXR, +}; + +enum DDSDXGIFormat { + DXGI_FORMAT_R16G16B16A16_TYPELESS = 9, + DXGI_FORMAT_R16G16B16A16_FLOAT = 10, + DXGI_FORMAT_R16G16B16A16_UNORM = 11, + DXGI_FORMAT_R16G16B16A16_UINT = 12, + DXGI_FORMAT_R16G16B16A16_SNORM = 13, + DXGI_FORMAT_R16G16B16A16_SINT = 14, + + DXGI_FORMAT_R8G8B8A8_TYPELESS = 27, + DXGI_FORMAT_R8G8B8A8_UNORM = 28, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29, + DXGI_FORMAT_R8G8B8A8_UINT = 30, + DXGI_FORMAT_R8G8B8A8_SNORM = 31, + DXGI_FORMAT_R8G8B8A8_SINT = 32, + + DXGI_FORMAT_BC1_TYPELESS = 70, + DXGI_FORMAT_BC1_UNORM = 71, + DXGI_FORMAT_BC1_UNORM_SRGB = 72, + DXGI_FORMAT_BC2_TYPELESS = 73, + DXGI_FORMAT_BC2_UNORM = 74, + DXGI_FORMAT_BC2_UNORM_SRGB = 75, + DXGI_FORMAT_BC3_TYPELESS = 76, + DXGI_FORMAT_BC3_UNORM = 77, + DXGI_FORMAT_BC3_UNORM_SRGB = 78, + DXGI_FORMAT_BC4_TYPELESS = 79, + DXGI_FORMAT_BC4_UNORM = 80, + DXGI_FORMAT_BC4_SNORM = 81, + DXGI_FORMAT_BC5_TYPELESS = 82, + DXGI_FORMAT_BC5_UNORM = 83, + DXGI_FORMAT_BC5_SNORM = 84, + DXGI_FORMAT_B5G6R5_UNORM = 85, + DXGI_FORMAT_B8G8R8A8_UNORM = 87, + DXGI_FORMAT_B8G8R8X8_UNORM = 88, + DXGI_FORMAT_B8G8R8A8_TYPELESS = 90, + DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91, + DXGI_FORMAT_B8G8R8X8_TYPELESS = 92, + DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93, +}; + +typedef struct DDSContext { + TextureDSPContext texdsp; + GetByteContext gbc; + + int compressed; + int paletted; + enum DDSPostProc postproc; + + const uint8_t *tex_data; // Compressed texture + int tex_ratio; // Compression ratio + int slice_count; // Number of slices for threaded operations + + /* Pointer to the selected compress or decompress function. */ + int (*tex_funct)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block); +} DDSContext; + +static int parse_pixel_format(AVCodecContext *avctx) +{ + DDSContext *ctx = avctx->priv_data; + GetByteContext *gbc = &ctx->gbc; + char buf[32]; + uint32_t flags, fourcc, gimp_tag; + enum DDSDXGIFormat dxgi; + int size, bpp, r, g, b, a; + int alpha_exponent, ycocg_classic, ycocg_scaled, normal_map, array; + + /* Alternative DDS implementations use reserved1 as custom header. */ + bytestream2_skip(gbc, 4 * 3); + gimp_tag = bytestream2_get_le32(gbc); + alpha_exponent = gimp_tag == MKTAG('A', 'E', 'X', 'P'); + ycocg_classic = gimp_tag == MKTAG('Y', 'C', 'G', '1'); + ycocg_scaled = gimp_tag == MKTAG('Y', 'C', 'G', '2'); + bytestream2_skip(gbc, 4 * 7); + + /* Now the real DDPF starts. */ + size = bytestream2_get_le32(gbc); + if (size != 32) { + av_log(avctx, AV_LOG_ERROR, "Invalid pixel format header %d.\n", size); + return AVERROR_INVALIDDATA; + } + flags = bytestream2_get_le32(gbc); + ctx->compressed = flags & DDPF_FOURCC; + ctx->paletted = flags & DDPF_PALETTE; + normal_map = flags & DDPF_NORMALMAP; + fourcc = bytestream2_get_le32(gbc); + + bpp = bytestream2_get_le32(gbc); // rgbbitcount + r = bytestream2_get_le32(gbc); // rbitmask + g = bytestream2_get_le32(gbc); // gbitmask + b = bytestream2_get_le32(gbc); // bbitmask + a = bytestream2_get_le32(gbc); // abitmask + + bytestream2_skip(gbc, 4); // caps + bytestream2_skip(gbc, 4); // caps2 + bytestream2_skip(gbc, 4); // caps3 + bytestream2_skip(gbc, 4); // caps4 + bytestream2_skip(gbc, 4); // reserved2 + + av_get_codec_tag_string(buf, sizeof(buf), fourcc); + av_log(avctx, AV_LOG_VERBOSE, "fourcc %s bpp %d " + "r 0x%x g 0x%x b 0x%x a 0x%x\n", buf, bpp, r, g, b, a); + if (gimp_tag) { + av_get_codec_tag_string(buf, sizeof(buf), gimp_tag); + av_log(avctx, AV_LOG_VERBOSE, "and GIMP-DDS tag %s\n", buf); + } + + if (ctx->compressed) + avctx->pix_fmt = AV_PIX_FMT_RGBA; + + if (ctx->compressed) { + switch (fourcc) { + case MKTAG('D', 'X', 'T', '1'): + ctx->tex_ratio = 8; + ctx->tex_funct = ctx->texdsp.dxt1a_block; + break; + case MKTAG('D', 'X', 'T', '2'): + ctx->tex_ratio = 16; + ctx->tex_funct = ctx->texdsp.dxt2_block; + break; + case MKTAG('D', 'X', 'T', '3'): + ctx->tex_ratio = 16; + ctx->tex_funct = ctx->texdsp.dxt3_block; + break; + case MKTAG('D', 'X', 'T', '4'): + ctx->tex_ratio = 16; + ctx->tex_funct = ctx->texdsp.dxt4_block; + break; + case MKTAG('D', 'X', 'T', '5'): + ctx->tex_ratio = 16; + if (ycocg_scaled) + ctx->tex_funct = ctx->texdsp.dxt5ys_block; + else if (ycocg_classic) + ctx->tex_funct = ctx->texdsp.dxt5y_block; + else + ctx->tex_funct = ctx->texdsp.dxt5_block; + break; + case MKTAG('R', 'X', 'G', 'B'): + ctx->tex_ratio = 16; + ctx->tex_funct = ctx->texdsp.dxt5_block; + /* This format may be considered as a normal map, + * but it is handled differently in a separate postproc. */ + ctx->postproc = DDS_SWIZZLE_RXGB; + normal_map = 0; + break; + case MKTAG('A', 'T', 'I', '1'): + case MKTAG('B', 'C', '4', 'U'): + ctx->tex_ratio = 8; + ctx->tex_funct = ctx->texdsp.rgtc1u_block; + break; + case MKTAG('B', 'C', '4', 'S'): + ctx->tex_ratio = 8; + ctx->tex_funct = ctx->texdsp.rgtc1s_block; + break; + case MKTAG('A', 'T', 'I', '2'): + /* RGT2 variant with swapped R and G (3Dc)*/ + ctx->tex_ratio = 16; + ctx->tex_funct = ctx->texdsp.dxn3dc_block; + break; + case MKTAG('B', 'C', '5', 'U'): + ctx->tex_ratio = 16; + ctx->tex_funct = ctx->texdsp.rgtc2u_block; + break; + case MKTAG('B', 'C', '5', 'S'): + ctx->tex_ratio = 16; + ctx->tex_funct = ctx->texdsp.rgtc2s_block; + break; + case MKTAG('U', 'Y', 'V', 'Y'): + ctx->compressed = 0; + avctx->pix_fmt = AV_PIX_FMT_UYVY422; + break; + case MKTAG('Y', 'U', 'Y', '2'): + ctx->compressed = 0; + avctx->pix_fmt = AV_PIX_FMT_YUYV422; + break; + case MKTAG('P', '8', ' ', ' '): + /* ATI Palette8, same as normal palette */ + ctx->compressed = 0; + ctx->paletted = 1; + avctx->pix_fmt = AV_PIX_FMT_PAL8; + break; + case MKTAG('D', 'X', '1', '0'): + /* DirectX 10 extra header */ + dxgi = bytestream2_get_le32(gbc); + bytestream2_skip(gbc, 4); // resourceDimension + bytestream2_skip(gbc, 4); // miscFlag + array = bytestream2_get_le32(gbc); + bytestream2_skip(gbc, 4); // miscFlag2 + + if (array != 0) + av_log(avctx, AV_LOG_VERBOSE, + "Found array of size %d (ignored).\n", array); + + /* Only BC[1-5] are actually compressed. */ + ctx->compressed = (dxgi >= 70) && (dxgi <= 84); + + av_log(avctx, AV_LOG_VERBOSE, "DXGI format %d.\n", dxgi); + switch (dxgi) { + /* RGB types. */ + case DXGI_FORMAT_R16G16B16A16_TYPELESS: + case DXGI_FORMAT_R16G16B16A16_FLOAT: + case DXGI_FORMAT_R16G16B16A16_UNORM: + case DXGI_FORMAT_R16G16B16A16_UINT: + case DXGI_FORMAT_R16G16B16A16_SNORM: + case DXGI_FORMAT_R16G16B16A16_SINT: + avctx->pix_fmt = AV_PIX_FMT_BGRA64; + break; + case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + avctx->colorspace = AVCOL_SPC_RGB; + case DXGI_FORMAT_R8G8B8A8_TYPELESS: + case DXGI_FORMAT_R8G8B8A8_UNORM: + case DXGI_FORMAT_R8G8B8A8_UINT: + case DXGI_FORMAT_R8G8B8A8_SNORM: + case DXGI_FORMAT_R8G8B8A8_SINT: + avctx->pix_fmt = AV_PIX_FMT_BGRA; + break; + case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + avctx->colorspace = AVCOL_SPC_RGB; + case DXGI_FORMAT_B8G8R8A8_TYPELESS: + case DXGI_FORMAT_B8G8R8A8_UNORM: + avctx->pix_fmt = AV_PIX_FMT_RGBA; + break; + case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: + avctx->colorspace = AVCOL_SPC_RGB; + case DXGI_FORMAT_B8G8R8X8_TYPELESS: + case DXGI_FORMAT_B8G8R8X8_UNORM: + avctx->pix_fmt = AV_PIX_FMT_RGBA; // opaque + break; + case DXGI_FORMAT_B5G6R5_UNORM: + avctx->pix_fmt = AV_PIX_FMT_RGB565LE; + break; + /* Texture types. */ + case DXGI_FORMAT_BC1_UNORM_SRGB: + avctx->colorspace = AVCOL_SPC_RGB; + case DXGI_FORMAT_BC1_TYPELESS: + case DXGI_FORMAT_BC1_UNORM: + ctx->tex_ratio = 8; + ctx->tex_funct = ctx->texdsp.dxt1a_block; + break; + case DXGI_FORMAT_BC2_UNORM_SRGB: + avctx->colorspace = AVCOL_SPC_RGB; + case DXGI_FORMAT_BC2_TYPELESS: + case DXGI_FORMAT_BC2_UNORM: + ctx->tex_ratio = 16; + ctx->tex_funct = ctx->texdsp.dxt3_block; + break; + case DXGI_FORMAT_BC3_UNORM_SRGB: + avctx->colorspace = AVCOL_SPC_RGB; + case DXGI_FORMAT_BC3_TYPELESS: + case DXGI_FORMAT_BC3_UNORM: + ctx->tex_ratio = 16; + ctx->tex_funct = ctx->texdsp.dxt5_block; + break; + case DXGI_FORMAT_BC4_TYPELESS: + case DXGI_FORMAT_BC4_UNORM: + ctx->tex_ratio = 8; + ctx->tex_funct = ctx->texdsp.rgtc1u_block; + break; + case DXGI_FORMAT_BC4_SNORM: + ctx->tex_ratio = 8; + ctx->tex_funct = ctx->texdsp.rgtc1s_block; + break; + case DXGI_FORMAT_BC5_TYPELESS: + case DXGI_FORMAT_BC5_UNORM: + ctx->tex_ratio = 16; + ctx->tex_funct = ctx->texdsp.rgtc2u_block; + break; + case DXGI_FORMAT_BC5_SNORM: + ctx->tex_ratio = 16; + ctx->tex_funct = ctx->texdsp.rgtc2s_block; + break; + default: + av_log(avctx, AV_LOG_ERROR, + "Unsupported DXGI format %d.\n", dxgi); + return AVERROR_INVALIDDATA; + } + break; + default: + av_log(avctx, AV_LOG_ERROR, "Unsupported %s fourcc.\n", buf); + return AVERROR_INVALIDDATA; + } + } else if (ctx->paletted) { + if (bpp == 8) { + avctx->pix_fmt = AV_PIX_FMT_PAL8; + } else { + av_log(avctx, AV_LOG_ERROR, "Unsupported palette bpp %d.\n", bpp); + return AVERROR_INVALIDDATA; + } + } else { + /* 8 bpp */ + if (bpp == 8 && r == 0xff && g == 0 && b == 0 && a == 0) + avctx->pix_fmt = AV_PIX_FMT_GRAY8; + /* 16 bpp */ + else if (bpp == 16 && r == 0xff && g == 0 && b == 0 && a == 0xff00) + avctx->pix_fmt = AV_PIX_FMT_YA8; + else if (bpp == 16 && r == 0xffff && g == 0 && b == 0 && a == 0) + avctx->pix_fmt = AV_PIX_FMT_GRAY16LE; + else if (bpp == 16 && r == 0xf800 && g == 0x7e0 && b == 0x1f && a == 0) + avctx->pix_fmt = AV_PIX_FMT_RGB565LE; + /* 24 bpp */ + else if (bpp == 24 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0) + avctx->pix_fmt = AV_PIX_FMT_BGR24; + /* 32 bpp */ + else if (bpp == 32 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0) + avctx->pix_fmt = AV_PIX_FMT_BGR0; // opaque + else if (bpp == 32 && r == 0xff && g == 0xff00 && b == 0xff0000 && a == 0) + avctx->pix_fmt = AV_PIX_FMT_RGB0; // opaque + else if (bpp == 32 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0xff000000) + avctx->pix_fmt = AV_PIX_FMT_BGRA; + else if (bpp == 32 && r == 0xff && g == 0xff00 && b == 0xff0000 && a == 0xff000000) + avctx->pix_fmt = AV_PIX_FMT_RGBA; + /* give up */ + else { + av_log(avctx, AV_LOG_ERROR, "Unknown pixel format " + "[bpp %d r 0x%x g 0x%x b 0x%x a 0x%x].\n", bpp, r, g, b, a); + return AVERROR_INVALIDDATA; + } + } + + /* Set any remaining post-proc that should happen before frame is ready. */ + if (alpha_exponent) + ctx->postproc = DDS_ALPHA_EXP; + else if (normal_map) + ctx->postproc = DDS_NORMAL_MAP; + else if (ycocg_classic && !ctx->compressed) + ctx->postproc = DDS_RAW_YCOCG; + else if (avctx->pix_fmt == AV_PIX_FMT_YA8) + ctx->postproc = DDS_SWAP_ALPHA; + + /* ATI/NVidia variants sometimes add swizzling in bpp. */ + switch (bpp) { + case MKTAG('A', '2', 'X', 'Y'): + ctx->postproc = DDS_SWIZZLE_A2XY; + break; + case MKTAG('x', 'G', 'B', 'R'): + ctx->postproc = DDS_SWIZZLE_XGBR; + break; + case MKTAG('x', 'R', 'B', 'G'): + ctx->postproc = DDS_SWIZZLE_XRBG; + break; + case MKTAG('R', 'B', 'x', 'G'): + ctx->postproc = DDS_SWIZZLE_RBXG; + break; + case MKTAG('R', 'G', 'x', 'B'): + ctx->postproc = DDS_SWIZZLE_RGXB; + break; + case MKTAG('R', 'x', 'B', 'G'): + ctx->postproc = DDS_SWIZZLE_RXBG; + break; + case MKTAG('x', 'G', 'x', 'R'): + ctx->postproc = DDS_SWIZZLE_XGXR; + break; + case MKTAG('A', '2', 'D', '5'): + ctx->postproc = DDS_NORMAL_MAP; + break; + } + + return 0; +} + +static int decompress_texture_thread(AVCodecContext *avctx, void *arg, + int slice, int thread_nb) +{ + DDSContext *ctx = avctx->priv_data; + AVFrame *frame = arg; + const uint8_t *d = ctx->tex_data; + int w_block = avctx->coded_width / TEXTURE_BLOCK_W; + int h_block = avctx->coded_height / TEXTURE_BLOCK_H; + int x, y; + int start_slice, end_slice; + int base_blocks_per_slice = h_block / ctx->slice_count; + int remainder_blocks = h_block % ctx->slice_count; + + /* When the frame height (in blocks) doesn't divide evenly between the + * number of slices, spread the remaining blocks evenly between the first + * operations */ + start_slice = slice * base_blocks_per_slice; + /* Add any extra blocks (one per slice) that have been added before this slice */ + start_slice += FFMIN(slice, remainder_blocks); + + end_slice = start_slice + base_blocks_per_slice; + /* Add an extra block if there are still remainder blocks to be accounted for */ + if (slice < remainder_blocks) + end_slice++; + + for (y = start_slice; y < end_slice; y++) { + uint8_t *p = frame->data[0] + y * frame->linesize[0] * TEXTURE_BLOCK_H; + int off = y * w_block; + for (x = 0; x < w_block; x++) { + ctx->tex_funct(p + x * 16, frame->linesize[0], + d + (off + x) * ctx->tex_ratio); + } + } + + return 0; +} + +static void do_swizzle(AVFrame *frame, int x, int y) +{ + int i; + for (i = 0; i < frame->linesize[0] * frame->height; i += 4) { + uint8_t *src = frame->data[0] + i; + FFSWAP(uint8_t, src[x], src[y]); + } +} + +static void run_postproc(AVCodecContext *avctx, AVFrame *frame) +{ + DDSContext *ctx = avctx->priv_data; + int i, x_off; + + switch (ctx->postproc) { + case DDS_ALPHA_EXP: + /* Alpha-exponential mode divides each channel by the maximum + * R, G or B value, and stores the multiplying factor in the + * alpha channel. */ + av_log(avctx, AV_LOG_DEBUG, "Post-processing alpha exponent.\n"); + + for (i = 0; i < frame->linesize[0] * frame->height; i += 4) { + uint8_t *src = frame->data[0] + i; + int r = src[0]; + int g = src[1]; + int b = src[2]; + int a = src[3]; + + src[0] = r * a / 255; + src[1] = g * a / 255; + src[2] = b * a / 255; + src[3] = 255; + } + break; + case DDS_NORMAL_MAP: + /* Normal maps work in the XYZ color space and they encode + * X in R or in A, depending on the texture type, Y in G and + * derive Z with a square root of the distance. + * + * http://www.realtimecollisiondetection.net/blog/?p=28 */ + av_log(avctx, AV_LOG_DEBUG, "Post-processing normal map.\n"); + + x_off = ctx->tex_ratio == 8 ? 0 : 3; + for (i = 0; i < frame->linesize[0] * frame->height; i += 4) { + uint8_t *src = frame->data[0] + i; + int x = src[x_off]; + int y = src[1]; + int z = 127; + + int d = (255 * 255 - x * x - y * y) / 2; + if (d > 0) + z = rint(sqrtf(d)); + + src[0] = x; + src[1] = y; + src[2] = z; + src[3] = 255; + } + break; + case DDS_RAW_YCOCG: + /* Data is Y-Co-Cg-A and not RGBA, but they are represented + * with the same masks in the DDPF header. */ + av_log(avctx, AV_LOG_DEBUG, "Post-processing raw YCoCg.\n"); + + for (i = 0; i < frame->linesize[0] * frame->height; i += 4) { + uint8_t *src = frame->data[0] + i; + int a = src[0]; + int cg = src[1] - 128; + int co = src[2] - 128; + int y = src[3]; + + src[0] = av_clip_uint8(y + co - cg); + src[1] = av_clip_uint8(y + cg); + src[2] = av_clip_uint8(y - co - cg); + src[3] = a; + } + break; + case DDS_SWAP_ALPHA: + /* Alpha and Luma are stored swapped. */ + av_log(avctx, AV_LOG_DEBUG, "Post-processing swapped Luma/Alpha.\n"); + + for (i = 0; i < frame->linesize[0] * frame->height; i += 2) { + uint8_t *src = frame->data[0] + i; + FFSWAP(uint8_t, src[0], src[1]); + } + break; + case DDS_SWIZZLE_A2XY: + /* Swap R and G, often used to restore a standard RGTC2. */ + av_log(avctx, AV_LOG_DEBUG, "Post-processing A2XY swizzle.\n"); + do_swizzle(frame, 0, 1); + break; + case DDS_SWIZZLE_RBXG: + /* Swap G and A, then B and new A (G). */ + av_log(avctx, AV_LOG_DEBUG, "Post-processing RBXG swizzle.\n"); + do_swizzle(frame, 1, 3); + do_swizzle(frame, 2, 3); + break; + case DDS_SWIZZLE_RGXB: + /* Swap B and A. */ + av_log(avctx, AV_LOG_DEBUG, "Post-processing RGXB swizzle.\n"); + do_swizzle(frame, 2, 3); + break; + case DDS_SWIZZLE_RXBG: + /* Swap G and A. */ + av_log(avctx, AV_LOG_DEBUG, "Post-processing RXBG swizzle.\n"); + do_swizzle(frame, 1, 3); + break; + case DDS_SWIZZLE_RXGB: + /* Swap R and A (misleading name). */ + av_log(avctx, AV_LOG_DEBUG, "Post-processing RXGB swizzle.\n"); + do_swizzle(frame, 0, 3); + break; + case DDS_SWIZZLE_XGBR: + /* Swap B and A, then R and new A (B). */ + av_log(avctx, AV_LOG_DEBUG, "Post-processing XGBR swizzle.\n"); + do_swizzle(frame, 2, 3); + do_swizzle(frame, 0, 3); + break; + case DDS_SWIZZLE_XGXR: + /* Swap G and A, then R and new A (G), then new R (G) and new G (A). + * This variant does not store any B component. */ + av_log(avctx, AV_LOG_DEBUG, "Post-processing XGXR swizzle.\n"); + do_swizzle(frame, 1, 3); + do_swizzle(frame, 0, 3); + do_swizzle(frame, 0, 1); + break; + case DDS_SWIZZLE_XRBG: + /* Swap G and A, then R and new A (G). */ + av_log(avctx, AV_LOG_DEBUG, "Post-processing XRBG swizzle.\n"); + do_swizzle(frame, 1, 3); + do_swizzle(frame, 0, 3); + break; + } +} + +static int dds_decode(AVCodecContext *avctx, void *data, + int *got_frame, AVPacket *avpkt) +{ + DDSContext *ctx = avctx->priv_data; + GetByteContext *gbc = &ctx->gbc; + AVFrame *frame = data; + int mipmap; + int ret; + + ff_texturedsp_init(&ctx->texdsp); + bytestream2_init(gbc, avpkt->data, avpkt->size); + + if (bytestream2_get_bytes_left(gbc) < 128) { + av_log(avctx, AV_LOG_ERROR, "Frame is too small (%d).", + bytestream2_get_bytes_left(gbc)); + return AVERROR_INVALIDDATA; + } + + if (bytestream2_get_le32(gbc) != MKTAG('D', 'D', 'S', ' ') || + bytestream2_get_le32(gbc) != 124) { // header size + av_log(avctx, AV_LOG_ERROR, "Invalid DDS header."); + return AVERROR_INVALIDDATA; + } + + bytestream2_skip(gbc, 4); // flags + + avctx->height = bytestream2_get_le32(gbc); + avctx->width = bytestream2_get_le32(gbc); + ret = av_image_check_size(avctx->width, avctx->height, 0, avctx); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid image size %dx%d.\n", + avctx->width, avctx->height); + return ret; + } + + /* Since codec is based on 4x4 blocks, size is aligned to 4. */ + avctx->coded_width = FFALIGN(avctx->width, TEXTURE_BLOCK_W); + avctx->coded_height = FFALIGN(avctx->height, TEXTURE_BLOCK_H); + + bytestream2_skip(gbc, 4); // pitch + bytestream2_skip(gbc, 4); // depth + mipmap = bytestream2_get_le32(gbc); + if (mipmap != 0) + av_log(avctx, AV_LOG_VERBOSE, "Found %d mipmaps (ignored).\n", mipmap); + + /* Extract pixel format information, considering additional elements + * in reserved1 and reserved2. */ + ret = parse_pixel_format(avctx); + if (ret < 0) + return ret; + + ret = ff_get_buffer(avctx, frame, 0); + if (ret < 0) + return ret; + + if (ctx->compressed) { + ctx->slice_count = av_clip(avctx->thread_count, 1, + avctx->coded_height / TEXTURE_BLOCK_H); + + /* Use the decompress function on the texture, one block per thread. */ + ctx->tex_data = gbc->buffer; + avctx->execute2(avctx, decompress_texture_thread, frame, NULL, ctx->slice_count); + } else { + int linesize = av_image_get_linesize(avctx->pix_fmt, frame->width, 0); + + if (ctx->paletted) { + int i; + /* Use the first 1024 bytes as palette, then copy the rest. */ + bytestream2_get_buffer(gbc, frame->data[1], 256 * 4); + for (i = 0; i < 256; i++) + AV_WN32(frame->data[1] + i*4, + (frame->data[1][2+i*4]<<0)+ + (frame->data[1][1+i*4]<<8)+ + (frame->data[1][0+i*4]<<16)+ + (frame->data[1][3+i*4]<<24) + ); + + frame->palette_has_changed = 1; + } + + av_image_copy_plane(frame->data[0], frame->linesize[0], + gbc->buffer, linesize, + linesize, frame->height); + } + + /* Run any post processing here if needed. */ + if (avctx->pix_fmt == AV_PIX_FMT_BGRA || + avctx->pix_fmt == AV_PIX_FMT_RGBA || + avctx->pix_fmt == AV_PIX_FMT_RGB0 || + avctx->pix_fmt == AV_PIX_FMT_BGR0 || + avctx->pix_fmt == AV_PIX_FMT_YA8) + run_postproc(avctx, frame); + + /* Frame is ready to be output. */ + frame->pict_type = AV_PICTURE_TYPE_I; + frame->key_frame = 1; + *got_frame = 1; + + return avpkt->size; +} + +AVCodec ff_dds_decoder = { + .name = "dds", + .long_name = NULL_IF_CONFIG_SMALL("DirectDraw Surface image decoder"), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_DDS, + .decode = dds_decode, + .priv_data_size = sizeof(DDSContext), + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dfa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dfa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dfa.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dfa.c 2015-07-28 17:20:07.000000000 +0000 @@ -418,5 +418,5 @@ .init = dfa_decode_init, .close = dfa_decode_end, .decode = dfa_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/diracdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/diracdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/diracdec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/diracdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -1563,7 +1563,7 @@ } } -static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, int width, int height) +static int interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, int width, int height) { /* chroma allocates an edge of 8 when subsampled which for 4:2:2 means an h edge of 16 and v edge of 8 @@ -1575,11 +1575,14 @@ /* no need for hpel if we only have fpel vectors */ if (!s->mv_precision) - return; + return 0; for (i = 1; i < 4; i++) { if (!ref->hpel_base[plane][i]) ref->hpel_base[plane][i] = av_malloc((height+2*edge) * ref->avframe->linesize[plane] + 32); + if (!ref->hpel_base[plane][i]) { + return AVERROR(ENOMEM); + } /* we need to be 16-byte aligned even for chroma */ ref->hpel[plane][i] = ref->hpel_base[plane][i] + edge*ref->avframe->linesize[plane] + 16; } @@ -1593,6 +1596,8 @@ s->mpvencdsp.draw_edges(ref->hpel[plane][3], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM); } ref->interpolated[plane] = 1; + + return 0; } /** @@ -1646,8 +1651,11 @@ select_dsp_funcs(s, p->width, p->height, p->xblen, p->yblen); - for (i = 0; i < s->num_refs; i++) - interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height); + for (i = 0; i < s->num_refs; i++) { + int ret = interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height); + if (ret < 0) + return ret; + } memset(s->mctmp, 0, 4*p->yoffset*p->stride); @@ -2032,6 +2040,6 @@ .init = dirac_decode_init, .close = dirac_decode_end, .decode = dirac_decode_frame, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .flush = dirac_decode_flush, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dnxhddata.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dnxhddata.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dnxhddata.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dnxhddata.c 2015-07-28 17:20:07.000000000 +0000 @@ -1119,7 +1119,7 @@ for (i = 0; i < FF_ARRAY_ELEMS(ff_dnxhd_cid_table); i++) { const CIDEntry *cid = &ff_dnxhd_cid_table[i]; if (cid->width == avctx->width && cid->height == avctx->height && - cid->interlaced == !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT) && + cid->interlaced == !!(avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) && cid->bit_depth == bit_depth) { for (j = 0; j < FF_ARRAY_ELEMS(cid->bit_rates); j++) { if (cid->bit_rates[j] == mbs) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dnxhddec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dnxhddec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dnxhddec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dnxhddec.c 2015-07-28 17:20:07.000000000 +0000 @@ -395,7 +395,7 @@ ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[4]); ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[5]); - if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) { + if (!(ctx->avctx->flags & AV_CODEC_FLAG_GRAY)) { dct_y_offset = dct_linesize_chroma << 3; ctx->idsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]); ctx->idsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[3]); @@ -408,7 +408,7 @@ ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[6]); ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[7]); - if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) { + if (!(ctx->avctx->flags & AV_CODEC_FLAG_GRAY)) { dct_y_offset = dct_linesize_chroma << 3; ctx->idsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]); ctx->idsp.idct_put(dest_u + dct_x_offset, dct_linesize_chroma, ctx->blocks[3]); @@ -515,5 +515,5 @@ .init = dnxhd_decode_init, .close = dnxhd_decode_close, .decode = dnxhd_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dnxhdenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dnxhdenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dnxhdenc.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dnxhdenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -46,6 +46,9 @@ static const AVOption options[] = { { "nitris_compat", "encode with Avid Nitris compatibility", offsetof(DNXHDEncContext, nitris_compat), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, + { "ibias", "intra quant bias", + offsetof(DNXHDEncContext, intra_quant_bias), AV_OPT_TYPE_INT, + { .i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, VE }, { NULL } }; @@ -214,14 +217,14 @@ weight_matrix[j] = ctx->cid_table->luma_weight[i]; } ff_convert_matrix(&ctx->m, ctx->qmatrix_l, ctx->qmatrix_l16, - weight_matrix, ctx->m.intra_quant_bias, 1, + weight_matrix, ctx->intra_quant_bias, 1, ctx->m.avctx->qmax, 1); for (i = 1; i < 64; i++) { int j = ctx->m.idsp.idct_permutation[ff_zigzag_direct[i]]; weight_matrix[j] = ctx->cid_table->chroma_weight[i]; } ff_convert_matrix(&ctx->m, ctx->qmatrix_c, ctx->qmatrix_c16, - weight_matrix, ctx->m.intra_quant_bias, 1, + weight_matrix, ctx->intra_quant_bias, 1, ctx->m.avctx->qmax, 1); for (qscale = 1; qscale <= ctx->m.avctx->qmax; qscale++) { @@ -348,17 +351,22 @@ ctx->m.mb_height = (avctx->height + 15) / 16; ctx->m.mb_width = (avctx->width + 15) / 16; - if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) { + if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { ctx->interlaced = 1; ctx->m.mb_height /= 2; } ctx->m.mb_num = ctx->m.mb_height * ctx->m.mb_width; - if (avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS) - ctx->m.intra_quant_bias = avctx->intra_quant_bias; +#if FF_API_QUANT_BIAS +FF_DISABLE_DEPRECATION_WARNINGS + if (ctx->intra_quant_bias == FF_DEFAULT_QUANT_BIAS && + avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS) + ctx->intra_quant_bias = avctx->intra_quant_bias; +FF_ENABLE_DEPRECATION_WARNINGS +#endif // XXX tune lbias/cbias - if ((ret = dnxhd_init_qmat(ctx, ctx->m.intra_quant_bias, 0)) < 0) + if ((ret = dnxhd_init_qmat(ctx, ctx->intra_quant_bias, 0)) < 0) return ret; /* Avid Nitris hardware decoder requires a minimum amount of padding @@ -380,12 +388,12 @@ FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale, ctx->m.mb_num * sizeof(uint8_t), fail); - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->key_frame = 1; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (avctx->thread_count > MAX_THREADS) { av_log(avctx, AV_LOG_ERROR, "too many threads\n"); @@ -1036,7 +1044,11 @@ ctx->thread[i]->dct_uv_offset = ctx->m.uvlinesize*8; } +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS ctx->m.avctx->coded_frame->interlaced_frame = frame->interlaced_frame; +FF_ENABLE_DEPRECATION_WARNINGS +#endif ctx->cur_field = frame->interlaced_frame && !frame->top_field_first; } @@ -1048,7 +1060,7 @@ int offset, i, ret; uint8_t *buf; - if ((ret = ff_alloc_packet2(avctx, pkt, ctx->cid_table->frame_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, ctx->cid_table->frame_size, 0)) < 0) return ret; buf = pkt->data; @@ -1097,7 +1109,13 @@ goto encode_coding_unit; } +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->quality = ctx->qscale * FF_QP2LAMBDA; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + ff_side_data_set_encoder_stats(pkt, ctx->qscale * FF_QP2LAMBDA, NULL, 0, AV_PICTURE_TYPE_I); pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; @@ -1130,8 +1148,6 @@ for (i = 1; i < avctx->thread_count; i++) av_freep(&ctx->thread[i]); - av_frame_free(&avctx->coded_frame); - return 0; } @@ -1149,7 +1165,7 @@ .init = dnxhd_encode_init, .encode2 = dnxhd_encode_picture, .close = dnxhd_encode_end, - .capabilities = CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_SLICE_THREADS, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV422P10, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dnxhdenc.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/dnxhdenc.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dnxhdenc.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dnxhdenc.h 2015-07-03 17:20:03.000000000 +0000 @@ -63,6 +63,7 @@ int nitris_compat; unsigned min_padding; + int intra_quant_bias; DECLARE_ALIGNED(16, int16_t, blocks)[8][64]; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dpcm.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dpcm.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dpcm.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dpcm.c 2015-07-28 17:20:07.000000000 +0000 @@ -334,7 +334,7 @@ .priv_data_size = sizeof(DPCMContext), \ .init = dpcm_decode_init, \ .decode = dpcm_decode_frame, \ - .capabilities = CODEC_CAP_DR1, \ + .capabilities = AV_CODEC_CAP_DR1, \ } DPCM_DECODER(AV_CODEC_ID_INTERPLAY_DPCM, interplay_dpcm, "DPCM Interplay"); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dpx.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dpx.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dpx.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dpx.c 2015-07-28 17:20:07.000000000 +0000 @@ -392,5 +392,5 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_DPX, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dpxenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dpxenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dpxenc.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dpxenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -195,7 +195,7 @@ need_align = size - len; size *= avctx->height; } - if ((ret = ff_alloc_packet2(avctx, pkt, size + HEADER_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, size + HEADER_SIZE, 0)) < 0) return ret; buf = pkt->data; @@ -207,7 +207,7 @@ memcpy (buf + 8, "V1.0", 4); write32(buf + 20, 1); /* new image */ write32(buf + 24, HEADER_SIZE); - if (!(avctx->flags & CODEC_FLAG_BITEXACT)) + if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) memcpy (buf + 160, LIBAVCODEC_IDENT, FFMIN(sizeof(LIBAVCODEC_IDENT), 100)); write32(buf + 660, 0xFFFFFFFF); /* unencrypted */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dsicinaudio.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dsicinaudio.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dsicinaudio.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dsicinaudio.c 2015-07-28 17:20:07.000000000 +0000 @@ -129,5 +129,5 @@ .priv_data_size = sizeof(CinAudioContext), .init = cinaudio_decode_init, .decode = cinaudio_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dsicinvideo.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dsicinvideo.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dsicinvideo.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dsicinvideo.c 2015-07-28 17:20:07.000000000 +0000 @@ -313,5 +313,5 @@ .init = cinvideo_decode_init, .close = cinvideo_decode_end, .decode = cinvideo_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dss_sp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dss_sp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dss_sp.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dss_sp.c 2015-07-28 17:20:07.000000000 +0000 @@ -66,7 +66,7 @@ int pulse_dec_mode; DECLARE_ALIGNED(16, uint8_t, bits)[DSS_SP_FRAME_SIZE + - FF_INPUT_BUFFER_PADDING_SIZE]; + AV_INPUT_BUFFER_PADDING_SIZE]; } DssSpContext; /* @@ -783,5 +783,5 @@ .priv_data_size = sizeof(DssSpContext), .init = dss_sp_decode_init, .decode = dss_sp_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dump_extradata_bsf.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dump_extradata_bsf.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dump_extradata_bsf.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dump_extradata_bsf.c 2015-07-28 17:20:07.000000000 +0000 @@ -30,18 +30,18 @@ int cmd= args ? *args : 0; /* cast to avoid warning about discarding qualifiers */ if(avctx->extradata){ - if( (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER) && cmd=='a') + if( (keyframe && (avctx->flags2 & AV_CODEC_FLAG2_LOCAL_HEADER) && cmd == 'a') ||(keyframe && (cmd=='k' || !cmd)) ||(cmd=='e') /*||(? && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_BEGIN)*/){ int size= buf_size + avctx->extradata_size; *poutbuf_size= size; - *poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); + *poutbuf= av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE); if (!*poutbuf) return AVERROR(ENOMEM); memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); - memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + AV_INPUT_BUFFER_PADDING_SIZE); return 1; } } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dvbsubdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dvbsubdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dvbsubdec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dvbsubdec.c 2015-08-04 17:20:03.000000000 +0000 @@ -237,6 +237,8 @@ int time_out; int compute_edt; /**< if 1 end display time calculated using pts if 0 (Default) calculated using time out */ + int compute_clut; + int substream; int64_t prev_start; DVBSubRegion *region_list; DVBSubCLUT *clut_list; @@ -367,17 +369,22 @@ int i, r, g, b, a = 0; DVBSubContext *ctx = avctx->priv_data; - if (!avctx->extradata || (avctx->extradata_size < 4) || ((avctx->extradata_size % 5 != 0) && (avctx->extradata_size != 4))) { + if (ctx->substream < 0) { + ctx->composition_id = -1; + ctx->ancillary_id = -1; + } else if (!avctx->extradata || (avctx->extradata_size < 4) || ((avctx->extradata_size % 5 != 0) && (avctx->extradata_size != 4))) { av_log(avctx, AV_LOG_WARNING, "Invalid DVB subtitles stream extradata!\n"); ctx->composition_id = -1; ctx->ancillary_id = -1; } else { - if (avctx->extradata_size > 5) { - av_log(avctx, AV_LOG_WARNING, "Decoding first DVB subtitles sub-stream\n"); + if (avctx->extradata_size > 5*ctx->substream + 2) { + ctx->composition_id = AV_RB16(avctx->extradata + 5*ctx->substream); + ctx->ancillary_id = AV_RB16(avctx->extradata + 5*ctx->substream + 2); + } else { + av_log(avctx, AV_LOG_WARNING, "Selected DVB subtitles sub-stream %d is not available\n", ctx->substream); + ctx->composition_id = AV_RB16(avctx->extradata); + ctx->ancillary_id = AV_RB16(avctx->extradata + 2); } - - ctx->composition_id = AV_RB16(avctx->extradata); - ctx->ancillary_id = AV_RB16(avctx->extradata + 2); } ctx->version = -1; @@ -754,6 +761,63 @@ return pixels_read; } +static void compute_default_clut(AVPicture *frame, int w, int h) +{ + uint8_t list[256] = {0}; + uint8_t list_inv[256]; + int counttab[256] = {0}; + int count, i, x, y; + +#define V(x,y) frame->data[0][(x) + (y)*frame->linesize[0]] + for (y = 0; ydata[0][(x) + (y)*frame->linesize[0]] ] + + for (i = 0; i<256; i++) { + int scoretab[256] = {0}; + int bestscore = 0; + int bestv = 0; + for (y = 0; ydata[0][x + y*frame->linesize[0]]; + int l_m = list[v]; + int l_l = x ? L(x-1, y) : 1; + int l_r = x+1 bestscore) { + bestscore = score; + bestv = v; + } + } + } + if (!bestscore) + break; + list [ bestv ] = 1; + list_inv[ i ] = bestv; + } + + count = i - 1; + for (i--; i>=0; i--) { + int v = i*255/count; + AV_WN32(frame->data[1] + 4*list_inv[i], RGBA(v/2,v,v/2,v)); + } +} + + static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_output) { DVBSubContext *ctx = avctx->priv_data; @@ -855,6 +919,9 @@ memcpy(rect->pict.data[0], region->pbuf, region->buf_size); + if ((clut == &default_clut && ctx->compute_clut == -1) || ctx->compute_clut == 1) + compute_default_clut(&rect->pict, rect->w, rect->h); + i++; } } @@ -1107,7 +1174,7 @@ if (depth == 0) { av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf); - return AVERROR_INVALIDDATA; + return 0; } full_range = (*buf++) & 1; @@ -1545,6 +1612,7 @@ int i; int ret = 0; int got_segment = 0; + int got_dds = 0; ff_dlog(avctx, "DVB sub packet:\n"); @@ -1607,9 +1675,15 @@ case DVBSUB_DISPLAYDEFINITION_SEGMENT: ret = dvbsub_parse_display_definition_segment(avctx, p, segment_length); + got_dds = 1; break; case DVBSUB_DISPLAY_SEGMENT: ret = dvbsub_display_end_segment(avctx, p, segment_length, sub, data_size); + if (got_segment == 15 && !got_dds && !avctx->width && !avctx->height) { + // Default from ETSI EN 300 743 V1.3.1 (7.2.1) + avctx->width = 720; + avctx->height = 576; + } got_segment |= 16; break; default: @@ -1646,6 +1720,8 @@ #define DS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_SUBTITLE_PARAM static const AVOption options[] = { {"compute_edt", "compute end of time using pts or timeout", offsetof(DVBSubContext, compute_edt), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DS}, + {"compute_clut", "compute clut when not available(-1) or always(1) or never(0)", offsetof(DVBSubContext, compute_clut), FF_OPT_TYPE_INT, {.i64 = -1}, -1, 1, DS}, + {"dvb_substream", "", offsetof(DVBSubContext, substream), FF_OPT_TYPE_INT, {.i64 = -1}, -1, 63, DS}, {NULL} }; static const AVClass dvbsubdec_class = { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dvdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dvdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dvdec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dvdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -287,14 +287,20 @@ GetBitContext gb; BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1; LOCAL_ALIGNED_16(int16_t, sblock, [5 * DV_MAX_BPM], [64]); - LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + FF_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ - LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [80 * 5 + FF_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ + LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + AV_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ + LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [80 * 5 + AV_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ const int log2_blocksize = 3-s->avctx->lowres; int is_field_mode[5]; + int vs_bit_buffer_damaged = 0; + int mb_bit_buffer_damaged[5] = {0}; + int retried = 0; + int sta; av_assert1((((int) mb_bit_buffer) & 7) == 0); av_assert1((((int) vs_bit_buffer) & 7) == 0); +retry: + memset(sblock, 0, 5 * DV_MAX_BPM * sizeof(*sblock)); /* pass 1: read DC and AC coefficients in blocks */ @@ -305,6 +311,14 @@ for (mb_index = 0; mb_index < 5; mb_index++, mb1 += s->sys->bpm, block1 += s->sys->bpm * 64) { /* skip header */ quant = buf_ptr[3] & 0x0f; + if (avctx->error_concealment) { + if ((buf_ptr[3] >> 4) == 0x0E) + vs_bit_buffer_damaged = 1; + if (!mb_index) { + sta = buf_ptr[3] >> 4; + } else if (sta != (buf_ptr[3] >> 4)) + vs_bit_buffer_damaged = 1; + } buf_ptr += 4; init_put_bits(&pb, mb_bit_buffer, 80); mb = mb1; @@ -349,11 +363,16 @@ * block is finished */ if (mb->pos >= 64) bit_copy(&pb, &gb); + if (mb->pos >= 64 && mb->pos < 127) + vs_bit_buffer_damaged = mb_bit_buffer_damaged[mb_index] = 1; block += 64; mb++; } + if (mb_bit_buffer_damaged[mb_index] > 0) + continue; + /* pass 2: we can do it just after */ ff_dlog(avctx, "***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index); block = block1; @@ -367,6 +386,8 @@ /* if still not finished, no need to parse other blocks */ if (mb->pos < 64) break; + if (mb->pos < 127) + vs_bit_buffer_damaged = mb_bit_buffer_damaged[mb_index] = 1; } } /* all blocks are finished, so the extra bytes can be used at @@ -384,17 +405,25 @@ flush_put_bits(&vs_pb); for (mb_index = 0; mb_index < 5; mb_index++) { for (j = 0; j < s->sys->bpm; j++) { - if (mb->pos < 64 && get_bits_left(&gb) > 0) { + if (mb->pos < 64 && get_bits_left(&gb) > 0 && !vs_bit_buffer_damaged) { ff_dlog(avctx, "start %d:%d\n", mb_index, j); dv_decode_ac(&gb, mb, block); } - if (mb->pos >= 64 && mb->pos < 127) + + if (mb->pos >= 64 && mb->pos < 127) { av_log(avctx, AV_LOG_ERROR, "AC EOB marker is absent pos=%d\n", mb->pos); + vs_bit_buffer_damaged = 1; + } block += 64; mb++; } } + if (vs_bit_buffer_damaged && !retried) { + av_log(avctx, AV_LOG_ERROR, "Concealing bitstream errors\n"); + retried = 1; + goto retry; + } /* compute idct and place blocks */ block = &sblock[0][0]; @@ -539,6 +568,6 @@ .priv_data_size = sizeof(DVVideoContext), .init = dvvideo_decode_init, .decode = dvvideo_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, .max_lowres = 3, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dvenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dvenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dvenc.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dvenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -65,10 +65,6 @@ return ret; } - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - dv_vlc_map_tableinit(); memset(&fdsp,0, sizeof(fdsp)); @@ -208,7 +204,7 @@ static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, uint8_t *data, int linesize) { - if (s->avctx->flags & CODEC_FLAG_INTERLACED_DCT) { + if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { int ps = s->ildct_cmp(NULL, data, NULL, linesize, 8) - 400; if (ps > 0) { int is = s->ildct_cmp(NULL, data, NULL, linesize << 1, 4) + @@ -721,13 +717,17 @@ DVVideoContext *s = c->priv_data; int ret; - if ((ret = ff_alloc_packet2(c, pkt, s->sys->frame_size)) < 0) + if ((ret = ff_alloc_packet2(c, pkt, s->sys->frame_size, 0)) < 0) return ret; c->pix_fmt = s->sys->pix_fmt; s->frame = frame; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS c->coded_frame->key_frame = 1; c->coded_frame->pict_type = AV_PICTURE_TYPE_I; +FF_ENABLE_DEPRECATION_WARNINGS +#endif s->buf = pkt->data; c->execute(c, dv_encode_video_segment, s->work_chunks, NULL, @@ -743,12 +743,6 @@ return 0; } -static int dvvideo_encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - return 0; -} - AVCodec ff_dvvideo_encoder = { .name = "dvvideo", .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), @@ -757,8 +751,7 @@ .priv_data_size = sizeof(DVVideoContext), .init = dvvideo_encode_init, .encode2 = dvvideo_encode_frame, - .close = dvvideo_encode_close, - .capabilities = CODEC_CAP_SLICE_THREADS | CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY, + .capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dxa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dxa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dxa.c 2015-06-18 18:54:57.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dxa.c 2015-07-28 17:20:07.000000000 +0000 @@ -284,7 +284,7 @@ case 5: if (!tmpptr) { av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n"); - if (!(avctx->flags2 & CODEC_FLAG2_SHOW_ALL)) + if (!(avctx->flags2 & AV_CODEC_FLAG2_SHOW_ALL)) return AVERROR_INVALIDDATA; } frame->key_frame = 0; @@ -370,5 +370,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dxtory.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dxtory.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dxtory.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dxtory.c 2015-07-28 17:20:07.000000000 +0000 @@ -752,5 +752,5 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_DXTORY, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dxva2.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/dxva2.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dxva2.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dxva2.h 2015-07-29 17:20:04.000000000 +0000 @@ -29,9 +29,9 @@ * Public libavcodec DXVA2 header. */ -#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0602 #undef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 +#define _WIN32_WINNT 0x0602 #endif #include diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dxva2_hevc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/dxva2_hevc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dxva2_hevc.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dxva2_hevc.c 2015-08-03 17:20:02.000000000 +0000 @@ -57,102 +57,104 @@ DXVA_PicParams_HEVC *pp) { const HEVCFrame *current_picture = h->ref; + const HEVCSPS *sps = h->ps.sps; + const HEVCPPS *pps = h->ps.pps; int i, j; memset(pp, 0, sizeof(*pp)); - pp->PicWidthInMinCbsY = h->sps->min_cb_width; - pp->PicHeightInMinCbsY = h->sps->min_cb_height; + pp->PicWidthInMinCbsY = sps->min_cb_width; + pp->PicHeightInMinCbsY = sps->min_cb_height; - pp->wFormatAndSequenceInfoFlags = (h->sps->chroma_format_idc << 0) | - (h->sps->separate_colour_plane_flag << 2) | - ((h->sps->bit_depth - 8) << 3) | - ((h->sps->bit_depth - 8) << 6) | - ((h->sps->log2_max_poc_lsb - 4) << 9) | + pp->wFormatAndSequenceInfoFlags = (sps->chroma_format_idc << 0) | + (sps->separate_colour_plane_flag << 2) | + ((sps->bit_depth - 8) << 3) | + ((sps->bit_depth - 8) << 6) | + ((sps->log2_max_poc_lsb - 4) << 9) | (0 << 13) | (0 << 14) | (0 << 15); fill_picture_entry(&pp->CurrPic, ff_dxva2_get_surface_index(avctx, ctx, current_picture->frame), 0); - pp->sps_max_dec_pic_buffering_minus1 = h->sps->temporal_layer[h->sps->max_sub_layers - 1].max_dec_pic_buffering - 1; - pp->log2_min_luma_coding_block_size_minus3 = h->sps->log2_min_cb_size - 3; - pp->log2_diff_max_min_luma_coding_block_size = h->sps->log2_diff_max_min_coding_block_size; - pp->log2_min_transform_block_size_minus2 = h->sps->log2_min_tb_size - 2; - pp->log2_diff_max_min_transform_block_size = h->sps->log2_max_trafo_size - h->sps->log2_min_tb_size; - pp->max_transform_hierarchy_depth_inter = h->sps->max_transform_hierarchy_depth_inter; - pp->max_transform_hierarchy_depth_intra = h->sps->max_transform_hierarchy_depth_intra; - pp->num_short_term_ref_pic_sets = h->sps->nb_st_rps; - pp->num_long_term_ref_pics_sps = h->sps->num_long_term_ref_pics_sps; - - pp->num_ref_idx_l0_default_active_minus1 = h->pps->num_ref_idx_l0_default_active - 1; - pp->num_ref_idx_l1_default_active_minus1 = h->pps->num_ref_idx_l1_default_active - 1; - pp->init_qp_minus26 = h->pps->pic_init_qp_minus26; + pp->sps_max_dec_pic_buffering_minus1 = sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering - 1; + pp->log2_min_luma_coding_block_size_minus3 = sps->log2_min_cb_size - 3; + pp->log2_diff_max_min_luma_coding_block_size = sps->log2_diff_max_min_coding_block_size; + pp->log2_min_transform_block_size_minus2 = sps->log2_min_tb_size - 2; + pp->log2_diff_max_min_transform_block_size = sps->log2_max_trafo_size - sps->log2_min_tb_size; + pp->max_transform_hierarchy_depth_inter = sps->max_transform_hierarchy_depth_inter; + pp->max_transform_hierarchy_depth_intra = sps->max_transform_hierarchy_depth_intra; + pp->num_short_term_ref_pic_sets = sps->nb_st_rps; + pp->num_long_term_ref_pics_sps = sps->num_long_term_ref_pics_sps; + + pp->num_ref_idx_l0_default_active_minus1 = pps->num_ref_idx_l0_default_active - 1; + pp->num_ref_idx_l1_default_active_minus1 = pps->num_ref_idx_l1_default_active - 1; + pp->init_qp_minus26 = pps->pic_init_qp_minus26; if (h->sh.short_term_ref_pic_set_sps_flag == 0 && h->sh.short_term_rps) { - pp->ucNumDeltaPocsOfRefRpsIdx = h->sh.short_term_rps->num_delta_pocs; + pp->ucNumDeltaPocsOfRefRpsIdx = h->sh.short_term_rps->rps_idx_num_delta_pocs; pp->wNumBitsForShortTermRPSInSlice = h->sh.short_term_ref_pic_set_size; } - pp->dwCodingParamToolFlags = (h->sps->scaling_list_enable_flag << 0) | - (h->sps->amp_enabled_flag << 1) | - (h->sps->sao_enabled << 2) | - (h->sps->pcm_enabled_flag << 3) | - ((h->sps->pcm_enabled_flag ? (h->sps->pcm.bit_depth - 1) : 0) << 4) | - ((h->sps->pcm_enabled_flag ? (h->sps->pcm.bit_depth_chroma - 1) : 0) << 8) | - ((h->sps->pcm_enabled_flag ? (h->sps->pcm.log2_min_pcm_cb_size - 3) : 0) << 12) | - ((h->sps->pcm_enabled_flag ? (h->sps->pcm.log2_max_pcm_cb_size - h->sps->pcm.log2_min_pcm_cb_size) : 0) << 14) | - (h->sps->pcm.loop_filter_disable_flag << 16) | - (h->sps->long_term_ref_pics_present_flag << 17) | - (h->sps->sps_temporal_mvp_enabled_flag << 18) | - (h->sps->sps_strong_intra_smoothing_enable_flag << 19) | - (h->pps->dependent_slice_segments_enabled_flag << 20) | - (h->pps->output_flag_present_flag << 21) | - (h->pps->num_extra_slice_header_bits << 22) | - (h->pps->sign_data_hiding_flag << 25) | - (h->pps->cabac_init_present_flag << 26) | + pp->dwCodingParamToolFlags = (sps->scaling_list_enable_flag << 0) | + (sps->amp_enabled_flag << 1) | + (sps->sao_enabled << 2) | + (sps->pcm_enabled_flag << 3) | + ((sps->pcm_enabled_flag ? (sps->pcm.bit_depth - 1) : 0) << 4) | + ((sps->pcm_enabled_flag ? (sps->pcm.bit_depth_chroma - 1) : 0) << 8) | + ((sps->pcm_enabled_flag ? (sps->pcm.log2_min_pcm_cb_size - 3) : 0) << 12) | + ((sps->pcm_enabled_flag ? (sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size) : 0) << 14) | + (sps->pcm.loop_filter_disable_flag << 16) | + (sps->long_term_ref_pics_present_flag << 17) | + (sps->sps_temporal_mvp_enabled_flag << 18) | + (sps->sps_strong_intra_smoothing_enable_flag << 19) | + (pps->dependent_slice_segments_enabled_flag << 20) | + (pps->output_flag_present_flag << 21) | + (pps->num_extra_slice_header_bits << 22) | + (pps->sign_data_hiding_flag << 25) | + (pps->cabac_init_present_flag << 26) | (0 << 27); - pp->dwCodingSettingPicturePropertyFlags = (h->pps->constrained_intra_pred_flag << 0) | - (h->pps->transform_skip_enabled_flag << 1) | - (h->pps->cu_qp_delta_enabled_flag << 2) | - (h->pps->pic_slice_level_chroma_qp_offsets_present_flag << 3) | - (h->pps->weighted_pred_flag << 4) | - (h->pps->weighted_bipred_flag << 5) | - (h->pps->transquant_bypass_enable_flag << 6) | - (h->pps->tiles_enabled_flag << 7) | - (h->pps->entropy_coding_sync_enabled_flag << 8) | - (h->pps->uniform_spacing_flag << 9) | - ((h->pps->tiles_enabled_flag ? h->pps->loop_filter_across_tiles_enabled_flag : 0) << 10) | - (h->pps->seq_loop_filter_across_slices_enabled_flag << 11) | - (h->pps->deblocking_filter_override_enabled_flag << 12) | - (h->pps->disable_dbf << 13) | - (h->pps->lists_modification_present_flag << 14) | - (h->pps->slice_header_extension_present_flag << 15) | + pp->dwCodingSettingPicturePropertyFlags = (pps->constrained_intra_pred_flag << 0) | + (pps->transform_skip_enabled_flag << 1) | + (pps->cu_qp_delta_enabled_flag << 2) | + (pps->pic_slice_level_chroma_qp_offsets_present_flag << 3) | + (pps->weighted_pred_flag << 4) | + (pps->weighted_bipred_flag << 5) | + (pps->transquant_bypass_enable_flag << 6) | + (pps->tiles_enabled_flag << 7) | + (pps->entropy_coding_sync_enabled_flag << 8) | + (pps->uniform_spacing_flag << 9) | + ((pps->tiles_enabled_flag ? pps->loop_filter_across_tiles_enabled_flag : 0) << 10) | + (pps->seq_loop_filter_across_slices_enabled_flag << 11) | + (pps->deblocking_filter_override_enabled_flag << 12) | + (pps->disable_dbf << 13) | + (pps->lists_modification_present_flag << 14) | + (pps->slice_header_extension_present_flag << 15) | (IS_IRAP(h) << 16) | (IS_IDR(h) << 17) | /* IntraPicFlag */ (IS_IRAP(h) << 18) | (0 << 19); - pp->pps_cb_qp_offset = h->pps->cb_qp_offset; - pp->pps_cr_qp_offset = h->pps->cr_qp_offset; - if (h->pps->tiles_enabled_flag) { - pp->num_tile_columns_minus1 = h->pps->num_tile_columns - 1; - pp->num_tile_rows_minus1 = h->pps->num_tile_rows - 1; - - if (!h->pps->uniform_spacing_flag) { - for (i = 0; i < h->pps->num_tile_columns; i++) - pp->column_width_minus1[i] = h->pps->column_width[i] - 1; + pp->pps_cb_qp_offset = pps->cb_qp_offset; + pp->pps_cr_qp_offset = pps->cr_qp_offset; + if (pps->tiles_enabled_flag) { + pp->num_tile_columns_minus1 = pps->num_tile_columns - 1; + pp->num_tile_rows_minus1 = pps->num_tile_rows - 1; + + if (!pps->uniform_spacing_flag) { + for (i = 0; i < pps->num_tile_columns; i++) + pp->column_width_minus1[i] = pps->column_width[i] - 1; - for (i = 0; i < h->pps->num_tile_rows; i++) - pp->row_height_minus1[i] = h->pps->row_height[i] - 1; + for (i = 0; i < pps->num_tile_rows; i++) + pp->row_height_minus1[i] = pps->row_height[i] - 1; } } - pp->diff_cu_qp_delta_depth = h->pps->diff_cu_qp_delta_depth; - pp->pps_beta_offset_div2 = h->pps->beta_offset / 2; - pp->pps_tc_offset_div2 = h->pps->tc_offset / 2; - pp->log2_parallel_merge_level_minus2 = h->pps->log2_parallel_merge_level - 2; + pp->diff_cu_qp_delta_depth = pps->diff_cu_qp_delta_depth; + pp->pps_beta_offset_div2 = pps->beta_offset / 2; + pp->pps_tc_offset_div2 = pps->tc_offset / 2; + pp->log2_parallel_merge_level_minus2 = pps->log2_parallel_merge_level - 2; pp->CurrPicOrderCntVal = h->poc; // fill RefPicList from the DPB @@ -197,8 +199,8 @@ static void fill_scaling_lists(AVDXVAContext *ctx, const HEVCContext *h, DXVA_Qmatrix_HEVC *qm) { unsigned i, j, pos; - const ScalingList *sl = h->pps->scaling_list_data_present_flag ? - &h->pps->scaling_list : &h->sps->scaling_list; + const ScalingList *sl = h->ps.pps->scaling_list_data_present_flag ? + &h->ps.pps->scaling_list : &h->ps.sps->scaling_list; memset(qm, 0, sizeof(*qm)); for (i = 0; i < 6; i++) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/dxva2_internal.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/dxva2_internal.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/dxva2_internal.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/dxva2_internal.h 2015-07-27 17:20:04.000000000 +0000 @@ -27,6 +27,9 @@ #include "config.h" +/* define the proper COM entries before forcing desktop APIs */ +#include + #if CONFIG_DXVA2 #include "dxva2.h" #endif @@ -35,6 +38,12 @@ #endif #if HAVE_DXVA_H +/* When targeting WINAPI_FAMILY_PHONE_APP or WINAPI_FAMILY_APP, dxva.h + * defines nothing. Force the struct definitions to be visible. */ +#undef WINAPI_FAMILY +#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP +#undef _CRT_BUILD_DESKTOP_APP +#define _CRT_BUILD_DESKTOP_APP 0 #include #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/eacmv.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/eacmv.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/eacmv.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/eacmv.c 2015-07-28 17:20:07.000000000 +0000 @@ -242,5 +242,5 @@ .init = cmv_decode_init, .close = cmv_decode_end, .decode = cmv_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/eamad.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/eamad.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/eamad.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/eamad.c 2015-07-28 17:20:07.000000000 +0000 @@ -29,6 +29,7 @@ */ #include "avcodec.h" +#include "blockdsp.h" #include "bytestream.h" #include "bswapdsp.h" #include "get_bits.h" @@ -36,9 +37,8 @@ #include "eaidct.h" #include "idctdsp.h" #include "internal.h" -#include "mpeg12.h" #include "mpeg12data.h" -#include "libavutil/imgutils.h" +#include "mpeg12vlc.h" #define EA_PREAMBLE_SIZE 8 #define MADk_TAG MKTAG('M', 'A', 'D', 'k') /* MAD i-frame */ @@ -101,7 +101,7 @@ frame->linesize[0], t->last_frame->data[0] + offset, t->last_frame->linesize[0], add); - } else if (!(t->avctx->flags & CODEC_FLAG_GRAY)) { + } else if (!(t->avctx->flags & AV_CODEC_FLAG_GRAY)) { int index = j - 3; unsigned offset = (mb_y * 8 + (mv_y/2))*t->last_frame->linesize[index] + mb_x * 8 + (mv_x/2); if (offset >= (t->avctx->height/2 - 7) * t->last_frame->linesize[index] - 7) @@ -120,7 +120,7 @@ ff_ea_idct_put_c( frame->data[0] + (mb_y*16 + ((j&2)<<2))*frame->linesize[0] + mb_x*16 + ((j&1)<<3), frame->linesize[0], block); - } else if (!(t->avctx->flags & CODEC_FLAG_GRAY)) { + } else if (!(t->avctx->flags & AV_CODEC_FLAG_GRAY)) { int index = j - 3; ff_ea_idct_put_c( frame->data[index] + (mb_y*8)*frame->linesize[index] + mb_x*8, @@ -312,7 +312,7 @@ return AVERROR(ENOMEM); s->bbdsp.bswap16_buf(s->bitstream_buf, (const uint16_t *)(buf + bytestream2_tell(&gb)), bytestream2_get_bytes_left(&gb) / 2); - memset((uint8_t*)s->bitstream_buf + bytestream2_get_bytes_left(&gb), 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset((uint8_t*)s->bitstream_buf + bytestream2_get_bytes_left(&gb), 0, AV_INPUT_BUFFER_PADDING_SIZE); init_get_bits(&s->gb, s->bitstream_buf, 8*(bytestream2_get_bytes_left(&gb))); for (s->mb_y=0; s->mb_y < (avctx->height+15)/16; s->mb_y++) @@ -348,5 +348,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/eatgq.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/eatgq.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/eatgq.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/eatgq.c 2015-07-28 17:20:07.000000000 +0000 @@ -116,7 +116,7 @@ ff_ea_idct_put_c(dest_y + 8, linesize, block[1]); ff_ea_idct_put_c(dest_y + 8 * linesize , linesize, block[2]); ff_ea_idct_put_c(dest_y + 8 * linesize + 8, linesize, block[3]); - if (!(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { ff_ea_idct_put_c(dest_cb, frame->linesize[1], block[4]); ff_ea_idct_put_c(dest_cr, frame->linesize[2], block[5]); } @@ -142,7 +142,7 @@ tgq_dconly(s, dest_y + 8, linesize, dc[1]); tgq_dconly(s, dest_y + 8 * linesize, linesize, dc[2]); tgq_dconly(s, dest_y + 8 * linesize + 8, linesize, dc[3]); - if (!(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { tgq_dconly(s, dest_cb, frame->linesize[1], dc[4]); tgq_dconly(s, dest_cr, frame->linesize[2], dc[5]); } @@ -249,5 +249,5 @@ .priv_data_size = sizeof(TgqContext), .init = tgq_decode_init, .decode = tgq_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/eatgv.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/eatgv.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/eatgv.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/eatgv.c 2015-07-28 17:20:07.000000000 +0000 @@ -364,5 +364,5 @@ .init = tgv_decode_init, .close = tgv_decode_end, .decode = tgv_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/eatqi.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/eatqi.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/eatqi.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/eatqi.c 2015-07-28 17:20:07.000000000 +0000 @@ -85,7 +85,7 @@ ff_ea_idct_put_c(dest_y + 8, linesize, block[1]); ff_ea_idct_put_c(dest_y + 8*linesize , linesize, block[2]); ff_ea_idct_put_c(dest_y + 8*linesize + 8, linesize, block[3]); - if(!(s->avctx->flags&CODEC_FLAG_GRAY)) { + if(!(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { ff_ea_idct_put_c(dest_cb, frame->linesize[1], block[4]); ff_ea_idct_put_c(dest_cr, frame->linesize[2], block[5]); } @@ -162,5 +162,5 @@ .init = tqi_decode_init, .close = tqi_decode_end, .decode = tqi_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/elsdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/elsdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/elsdec.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/elsdec.c 2015-07-01 17:20:03.000000000 +0000 @@ -0,0 +1,422 @@ +/* + * ELS (Entropy Logarithmic-Scale) decoder + * + * Copyright (c) 2013 Maxim Poliakovski + * + * 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 + */ + +/** + * @file + * Entropy Logarithmic-Scale binary arithmetic decoder + */ + +#include +#include + +#include "libavutil/common.h" +#include "libavutil/intreadwrite.h" + +#include "avcodec.h" +#include "elsdec.h" + +/* ELS coder constants and structures. */ +#define ELS_JOTS_PER_BYTE 36 +#define ELS_MAX (1 << 24) +#define RUNG_SPACE (64 * sizeof(ElsRungNode)) + +/* ELS coder tables. */ +static const struct Ladder { + int8_t AMps; + int8_t ALps; + uint8_t next0; + uint8_t next1; +} Ladder[174] = { + { -6, -5, 2, 1 }, + { -2, -12, 3, 6 }, + { -2, -12, 4, 6 }, + { -1, -16, 7, 5 }, + { -1, -16, 8, 10 }, + { -5, -6, 11, 9 }, + { -6, -5, 10, 5 }, + { -1, -18, 13, 11 }, + { -1, -18, 12, 14 }, + { -6, -5, 15, 18 }, + { -5, -6, 14, 9 }, + { -3, -8, 17, 15 }, + { -1, -20, 20, 16 }, + { -1, -20, 23, 17 }, + { -3, -8, 16, 18 }, + { -5, -6, 19, 26 }, + { -3, -9, 22, 24 }, + { -3, -9, 21, 19 }, + { -5, -6, 24, 26 }, + { -4, -7, 27, 25 }, + { -1, -22, 34, 28 }, + { -2, -11, 29, 27 }, + { -2, -11, 28, 30 }, + { -1, -22, 39, 29 }, + { -4, -7, 30, 32 }, + { -6, -5, 33, 31 }, + { -6, -5, 32, 25 }, + { -3, -8, 35, 33 }, + { -2, -12, 36, 38 }, + { -2, -12, 37, 35 }, + { -3, -8, 38, 40 }, + { -6, -5, 41, 48 }, + { -6, -5, 40, 31 }, + { -5, -6, 43, 41 }, + { -1, -24, 94, 42 }, + { -3, -8, 45, 43 }, + { -2, -12, 42, 44 }, + { -2, -12, 47, 45 }, + { -3, -8, 44, 46 }, + { -1, -24, 125, 47 }, + { -5, -6, 46, 48 }, + { -6, -5, 49, 49 }, + { -2, -13, 152, 164 }, + { -4, -7, 51, 49 }, + { -3, -9, 164, 168 }, + { -3, -9, 55, 51 }, + { -4, -7, 168, 170 }, + { -2, -13, 67, 55 }, + { -6, -5, 170, 49 }, + { -6, -5, 51, 170 }, + { -1, -72, 50, 74 }, + { -4, -7, 53, 49 }, + { -1, -61, 50, 74 }, + { -3, -8, 55, 49 }, + { -1, -51, 52, 76 }, + { -3, -9, 57, 51 }, + { -1, -46, 54, 76 }, + { -2, -10, 59, 53 }, + { -1, -43, 56, 78 }, + { -2, -11, 61, 53 }, + { -1, -41, 58, 80 }, + { -2, -12, 63, 55 }, + { -1, -39, 60, 82 }, + { -2, -12, 65, 55 }, + { -1, -37, 62, 84 }, + { -2, -13, 67, 57 }, + { -1, -36, 64, 86 }, + { -1, -14, 69, 59 }, + { -1, -35, 66, 88 }, + { -1, -14, 71, 59 }, + { -1, -34, 68, 90 }, + { -1, -15, 73, 61 }, + { -1, -33, 70, 92 }, + { -1, -15, 75, 61 }, + { -1, -32, 72, 94 }, + { -1, -15, 77, 63 }, + { -1, -31, 74, 96 }, + { -1, -16, 79, 65 }, + { -1, -31, 76, 98 }, + { -1, -16, 81, 67 }, + { -1, -30, 78, 100 }, + { -1, -17, 83, 67 }, + { -1, -29, 80, 102 }, + { -1, -17, 85, 69 }, + { -1, -29, 82, 104 }, + { -1, -18, 87, 71 }, + { -1, -28, 84, 104 }, + { -1, -18, 89, 73 }, + { -1, -28, 86, 108 }, + { -1, -18, 91, 73 }, + { -1, -27, 88, 108 }, + { -1, -19, 93, 75 }, + { -1, -27, 90, 112 }, + { -1, -19, 95, 77 }, + { -1, -26, 92, 112 }, + { -1, -20, 97, 79 }, + { -1, -26, 94, 114 }, + { -1, -20, 99, 81 }, + { -1, -25, 96, 116 }, + { -1, -20, 101, 83 }, + { -1, -25, 98, 118 }, + { -1, -21, 103, 83 }, + { -1, -24, 100, 120 }, + { -1, -21, 105, 85 }, + { -1, -24, 102, 122 }, + { -1, -22, 107, 87 }, + { -1, -23, 104, 124 }, + { -1, -22, 109, 89 }, + { -1, -23, 106, 126 }, + { -1, -22, 111, 91 }, + { -1, -22, 108, 128 }, + { -1, -23, 113, 93 }, + { -1, -22, 110, 130 }, + { -1, -23, 115, 95 }, + { -1, -22, 112, 132 }, + { -1, -24, 117, 97 }, + { -1, -21, 114, 134 }, + { -1, -24, 119, 99 }, + { -1, -21, 116, 136 }, + { -1, -25, 121, 101 }, + { -1, -20, 118, 136 }, + { -1, -25, 123, 103 }, + { -1, -20, 120, 138 }, + { -1, -26, 125, 105 }, + { -1, -20, 122, 140 }, + { -1, -26, 127, 107 }, + { -1, -19, 124, 142 }, + { -1, -27, 129, 107 }, + { -1, -19, 126, 144 }, + { -1, -27, 131, 111 }, + { -1, -18, 128, 146 }, + { -1, -28, 133, 111 }, + { -1, -18, 130, 146 }, + { -1, -28, 135, 115 }, + { -1, -18, 132, 148 }, + { -1, -29, 137, 115 }, + { -1, -17, 134, 150 }, + { -1, -29, 139, 117 }, + { -1, -17, 136, 152 }, + { -1, -30, 141, 119 }, + { -1, -16, 138, 152 }, + { -1, -31, 143, 121 }, + { -1, -16, 140, 154 }, + { -1, -31, 145, 123 }, + { -1, -15, 142, 156 }, + { -1, -32, 147, 125 }, + { -1, -15, 144, 158 }, + { -1, -33, 149, 127 }, + { -1, -15, 146, 158 }, + { -1, -34, 151, 129 }, + { -1, -14, 148, 160 }, + { -1, -35, 153, 131 }, + { -1, -14, 150, 160 }, + { -1, -36, 155, 133 }, + { -2, -13, 152, 162 }, + { -1, -37, 157, 135 }, + { -2, -12, 154, 164 }, + { -1, -39, 159, 137 }, + { -2, -12, 156, 164 }, + { -1, -41, 161, 139 }, + { -2, -11, 158, 166 }, + { -1, -43, 163, 141 }, + { -2, -10, 160, 166 }, + { -1, -46, 165, 143 }, + { -3, -9, 162, 168 }, + { -1, -51, 167, 143 }, + { -3, -8, 164, 170 }, + { -1, -61, 169, 145 }, + { -4, -7, 166, 170 }, + { -1, -72, 169, 145 }, + { -6, -5, 168, 49 }, + { 0, -108, 171, 171 }, + { 0, -108, 172, 172 }, + { -6, -5, 173, 173 }, +}; + +static const uint32_t els_exp_tab[ELS_JOTS_PER_BYTE * 4 + 1] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, + 1, 2, 2, 2, 3, 4, 4, 5, + 6, 7, 8, 10, 11, 13, 16, 18, + 21, 25, 29, 34, 40, 47, 54, 64, + 74, 87, 101, 118, 138, 161, 188, 219, + 256, 298, 348, 406, 474, 552, 645, 752, + 877, 1024, 1194, 1393, 1625, 1896, 2211, 2580, + 3010, 3511, 4096, 4778, 5573, 6501, 7584, 8847, + 10321, 12040, 14045, 16384, 19112, 22295, 26007, 30339, + 35391, 41285, 48160, 56180, 65536, 76288, 89088, 103936, + 121344, 141312, 165120, 192512, 224512, 262144, 305664, 356608, + 416000, 485376, 566016, 660480, 770560, 898816, 1048576, 1223168, + 1426688, 1664256, 1941504, 2264832, 2642176, 3082240, 3595520, 4194304, + 4892672, 5707520, 6657792, 7766784, 9060096, 10568960, 12328960, 14382080, + 16777216, +}; + +void ff_els_decoder_init(ElsDecCtx *ctx, const uint8_t *in, size_t data_size) +{ + int nbytes; + + /* consume up to 3 bytes from the input data */ + if (data_size >= 3) { + ctx->x = AV_RB24(in); + nbytes = 3; + } else if (data_size == 2) { + ctx->x = AV_RB16(in); + nbytes = 2; + } else { + ctx->x = *in; + nbytes = 1; + } + + ctx->in_buf = in + nbytes; + ctx->data_size = data_size - nbytes; + ctx->err = 0; + ctx->j = ELS_JOTS_PER_BYTE; + ctx->t = ELS_MAX; + ctx->diff = FFMIN(ELS_MAX - ctx->x, + ELS_MAX - els_exp_tab[ELS_JOTS_PER_BYTE * 4 - 1]); +} + +void ff_els_decoder_uninit(ElsUnsignedRung *rung) +{ + av_free(rung->rem_rung_list); +} + +static int els_import_byte(ElsDecCtx *ctx) +{ + if (!ctx->data_size) { + ctx->err = AVERROR_EOF; + return AVERROR_EOF; + } + ctx->x = (ctx->x << 8) | *ctx->in_buf++; + ctx->data_size--; + ctx->j += ELS_JOTS_PER_BYTE; + ctx->t <<= 8; + + return 0; +} + +int ff_els_decode_bit(ElsDecCtx *ctx, uint8_t *rung) +{ + int z, bit, ret; + const uint32_t *pAllowable = &els_exp_tab[ELS_JOTS_PER_BYTE * 3]; + + if (ctx->err) + return 0; + + z = pAllowable[ctx->j + Ladder[*rung].ALps]; + ctx->t -= z; + ctx->diff -= z; + if (ctx->diff > 0) + return *rung & 1; /* shortcut for x < t > pAllowable[j - 1] */ + + if (ctx->t > ctx->x) { /* decode most probable symbol (MPS) */ + ctx->j += Ladder[*rung].AMps; + while (ctx->t > pAllowable[ctx->j]) + ctx->j++; + + if (ctx->j <= 0) { /* MPS: import one byte from bytestream. */ + ret = els_import_byte(ctx); + if (ret < 0) + return ret; + } + + z = ctx->t; + bit = *rung & 1; + *rung = Ladder[*rung].next0; + } else { /* decode less probable symbol (LPS) */ + ctx->x -= ctx->t; + ctx->t = z; + + ctx->j += Ladder[*rung].ALps; + if (ctx->j <= 0) { + /* LPS: import one byte from bytestream. */ + z <<= 8; + ret = els_import_byte(ctx); + if (ret < 0) + return ret; + if (ctx->j <= 0) { + /* LPS: import second byte from bytestream. */ + z <<= 8; + ret = els_import_byte(ctx); + if (ret < 0) + return ret; + while (pAllowable[ctx->j - 1] >= z) + ctx->j--; + } + } + + bit = !(*rung & 1); + *rung = Ladder[*rung].next1; + } + + ctx->diff = FFMIN(z - ctx->x, z - pAllowable[ctx->j - 1]); + + return bit; +} + +unsigned ff_els_decode_unsigned(ElsDecCtx *ctx, ElsUnsignedRung *ur) +{ + int i, n, r, bit; + ElsRungNode *rung_node; + + if (ctx->err) + return 0; + + /* decode unary prefix */ + for (n = 0; n < ELS_EXPGOLOMB_LEN + 1; n++) + if (ff_els_decode_bit(ctx, &ur->prefix_rung[n])) + break; + + /* handle the error/overflow case */ + if (ctx->err || n >= ELS_EXPGOLOMB_LEN) { + ctx->err = AVERROR_INVALIDDATA; + return 0; + } + + /* handle the zero case */ + if (!n) + return 0; + + /* initialize probability tree */ + if (!ur->rem_rung_list) { + ur->rem_rung_list = av_realloc(NULL, RUNG_SPACE); + if (!ur->rem_rung_list) { + ctx->err = AVERROR(ENOMEM); + return 0; + } + memset(ur->rem_rung_list, 0, RUNG_SPACE); + ur->rung_list_size = RUNG_SPACE; + ur->avail_index = ELS_EXPGOLOMB_LEN; + } + + /* decode the remainder */ + for (i = 0, r = 0, bit = 0; i < n; i++) { + if (!i) + rung_node = &ur->rem_rung_list[n]; + else { + if (!rung_node->next_index) { + if (ur->rung_list_size <= (ur->avail_index + 2) * sizeof(ElsRungNode)) { + // remember rung_node position + ptrdiff_t pos = rung_node - ur->rem_rung_list; + ur->rem_rung_list = av_realloc(ur->rem_rung_list, + ur->rung_list_size + + RUNG_SPACE); + if (!ur->rem_rung_list) { + av_free(ur->rem_rung_list); + ctx->err = AVERROR(ENOMEM); + return 0; + } + memset((uint8_t *) ur->rem_rung_list + ur->rung_list_size, 0, + RUNG_SPACE); + ur->rung_list_size += RUNG_SPACE; + // restore rung_node position in the new list + rung_node = &ur->rem_rung_list[pos]; + } + rung_node->next_index = ur->avail_index; + ur->avail_index += 2; + } + rung_node = &ur->rem_rung_list[rung_node->next_index + bit]; + } + + bit = ff_els_decode_bit(ctx, &rung_node->rung); + if (ctx->err) + return bit; + + r = (r << 1) + bit; + } + + return (1 << n) - 1 + r; /* make value from exp golomb code */ +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/elsdec.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/elsdec.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/elsdec.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/elsdec.h 2015-07-01 17:20:03.000000000 +0000 @@ -0,0 +1,60 @@ +/* + * ELS (Entropy Logarithmic-Scale) decoder + * + * Copyright (c) 2013 Maxim Poliakovski + * + * 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 + */ + +/** + * @file + * Entropy Logarithmic-Scale binary arithmetic coder + */ + +#ifndef AVCODEC_ELSDEC_H +#define AVCODEC_ELSDEC_H + +#include +#include + +#define ELS_EXPGOLOMB_LEN 10 + +typedef struct ElsDecCtx { + const uint8_t *in_buf; + unsigned x; + size_t data_size; + int j, t, diff, err; +} ElsDecCtx; + +typedef struct ElsRungNode { + uint8_t rung; + uint16_t next_index; +} ElsRungNode; + +typedef struct ElsUnsignedRung { + uint8_t prefix_rung[ELS_EXPGOLOMB_LEN + 1]; + ElsRungNode *rem_rung_list; + size_t rung_list_size; + uint16_t avail_index; +} ElsUnsignedRung; + +void ff_els_decoder_init(ElsDecCtx *ctx, const uint8_t *in, size_t data_size); +void ff_els_decoder_uninit(ElsUnsignedRung *rung); +int ff_els_decode_bit(ElsDecCtx *ctx, unsigned char *rung); +unsigned ff_els_decode_unsigned(ElsDecCtx *ctx, ElsUnsignedRung *ur); + +#endif /* AVCODEC_ELSDEC_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/error_resilience.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/error_resilience.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/error_resilience.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/error_resilience.c 2015-07-28 17:20:07.000000000 +0000 @@ -777,7 +777,7 @@ static int er_supported(ERContext *s) { if(s->avctx->hwaccel && s->avctx->hwaccel->decode_slice || - s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU || + s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU || !s->cur_pic.f || s->cur_pic.field_picture ) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/escape124.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/escape124.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/escape124.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/escape124.c 2015-07-28 17:20:07.000000000 +0000 @@ -373,5 +373,5 @@ .init = escape124_decode_init, .close = escape124_decode_close, .decode = escape124_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/escape130.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/escape130.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/escape130.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/escape130.c 2015-07-28 17:20:07.000000000 +0000 @@ -356,5 +356,5 @@ .init = escape130_decode_init, .close = escape130_decode_close, .decode = escape130_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/evrcdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/evrcdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/evrcdec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/evrcdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -26,6 +26,7 @@ */ #include "libavutil/mathematics.h" +#include "libavutil/opt.h" #include "avcodec.h" #include "internal.h" #include "get_bits.h" @@ -66,6 +67,10 @@ } EVRCAFrame; typedef struct EVRCContext { + AVClass *class; + + int postfilter; + GetBitContext gb; evrc_packet_rate bitrate; evrc_packet_rate last_valid_bitrate; @@ -876,9 +881,11 @@ memmove(e->pitch, e->pitch + subframe_size, ACB_SIZE * sizeof(float)); synthesis_filter(e->pitch + ACB_SIZE, ilpc, - e->synthesis, subframe_size, tmp); - postfilter(e, tmp, ilpc, samples, pitch_lag, - &postfilter_coeffs[e->bitrate], subframe_size); + e->synthesis, subframe_size, + e->postfilter ? tmp : samples); + if (e->postfilter) + postfilter(e, tmp, ilpc, samples, pitch_lag, + &postfilter_coeffs[e->bitrate], subframe_size); samples += subframe_size; } @@ -906,6 +913,21 @@ return avpkt->size; } +#define OFFSET(x) offsetof(EVRCContext, x) +#define AD AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM + +static const AVOption options[] = { + { "postfilter", "enable postfilter", OFFSET(postfilter), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, AD }, + { NULL } +}; + +static const AVClass evrcdec_class = { + .class_name = "evrc", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_evrc_decoder = { .name = "evrc", .long_name = NULL_IF_CONFIG_SMALL("EVRC (Enhanced Variable Rate Codec)"), @@ -913,6 +935,7 @@ .id = AV_CODEC_ID_EVRC, .init = evrc_decode_init, .decode = evrc_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(EVRCContext), + .priv_class = &evrcdec_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/exr.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/exr.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/exr.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/exr.c 2015-07-28 17:20:07.000000000 +0000 @@ -1447,7 +1447,7 @@ .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS | - CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_SLICE_THREADS, .priv_class = &exr_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/fft-test.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/fft-test.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/fft-test.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/fft-test.c 2015-06-19 17:20:03.000000000 +0000 @@ -197,7 +197,7 @@ double error = 0, max = 0; for (i = 0; i < n; i++) { - double e = fabsf(tab1[i] - (tab2[i] / scale)) / RANGE; + double e = fabs(tab1[i] - (tab2[i] / scale)) / RANGE; if (e >= 1e-3) { av_log(NULL, AV_LOG_ERROR, "ERROR %5d: "FMT" "FMT"\n", i, tab1[i], tab2[i]); @@ -285,7 +285,7 @@ break; case 'c': { - int cpuflags = av_get_cpu_flags(); + unsigned cpuflags = av_get_cpu_flags(); if (av_parse_cpu_caps(&cpuflags, optarg) < 0) return 1; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ffv1dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ffv1dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ffv1dec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ffv1dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -1110,6 +1110,6 @@ .decode = decode_frame, .init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), - .capabilities = CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/ | - CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/ | + AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ffv1enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ffv1enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ffv1enc.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ffv1enc.c 2015-07-28 17:20:07.000000000 +0000 @@ -312,7 +312,7 @@ diff = fold(diff, bits); if (s->ac) { - if (s->flags & CODEC_FLAG_PASS1) { + if (s->flags & AV_CODEC_FLAG_PASS1) { put_symbol_inline(c, p->state[context], diff, 1, s->rc_stat, s->rc_stat2[p->quant_table_index][context]); } else { @@ -550,7 +550,7 @@ f->avctx->extradata_size = 10000 + 4 + (11 * 11 * 5 * 5 * 5 + 11 * 11 * 11) * 32; - f->avctx->extradata = av_malloc(f->avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + f->avctx->extradata = av_malloc(f->avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!f->avctx->extradata) return AVERROR(ENOMEM); ff_init_range_encoder(c, f->avctx->extradata, f->avctx->extradata_size); @@ -672,7 +672,8 @@ s->version = 0; - if ((avctx->flags & (CODEC_FLAG_PASS1|CODEC_FLAG_PASS2)) || avctx->slices>1) + if ((avctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) || + avctx->slices > 1) s->version = FFMAX(s->version, 2); // Unspecified level & slices, we choose version 1.2+ to ensure multithreaded decodability @@ -755,6 +756,8 @@ s->transparency = desc->nb_components == 4; if (!avctx->bits_per_raw_sample && !s->bits_per_raw_sample) s->bits_per_raw_sample = 8; + else if (!s->bits_per_raw_sample) + s->bits_per_raw_sample = 8; break; case AV_PIX_FMT_RGB32: s->colorspace = 1; @@ -851,11 +854,11 @@ if ((ret = ffv1_allocate_initial_states(s)) < 0) return ret; - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (!s->transparency) s->plane_count = 2; @@ -865,7 +868,7 @@ avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_h_shift, &s->chroma_v_shift); s->picture_number = 0; - if (avctx->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2)) { + if (avctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) { for (i = 0; i < s->quant_table_count; i++) { s->rc_stat2[i] = av_mallocz(s->context_count[i] * sizeof(*s->rc_stat2[i])); @@ -978,7 +981,7 @@ return ret; #define STATS_OUT_SIZE 1024 * 1024 * 6 - if (avctx->flags & CODEC_FLAG_PASS1) { + if (avctx->flags & AV_CODEC_FLAG_PASS1) { avctx->stats_out = av_mallocz(STATS_OUT_SIZE); if (!avctx->stats_out) return AVERROR(ENOMEM); @@ -1136,7 +1139,7 @@ } retry: - if (c->coded_frame->key_frame) + if (f->key_frame) ffv1_clear_slice_state(f, fs); if (f->version > 2) { encode_slice_header(f, fs); @@ -1194,11 +1197,11 @@ uint8_t keystate = 128; uint8_t *buf_p; int i, ret; - int64_t maxsize = FF_MIN_BUFFER_SIZE + int64_t maxsize = AV_INPUT_BUFFER_MIN_SIZE + avctx->width*avctx->height*35LL*4; if(!pict) { - if (avctx->flags & CODEC_FLAG_PASS1) { + if (avctx->flags & AV_CODEC_FLAG_PASS1) { int j, k, m; char *p = avctx->stats_out; char *end = p + STATS_OUT_SIZE; @@ -1243,9 +1246,9 @@ } if (f->version > 3) - maxsize = FF_MIN_BUFFER_SIZE + avctx->width*avctx->height*3LL*4; + maxsize = AV_INPUT_BUFFER_MIN_SIZE + avctx->width*avctx->height*3LL*4; - if ((ret = ff_alloc_packet2(avctx, pkt, maxsize)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, maxsize, 0)) < 0) return ret; ff_init_range_encoder(c, pkt->data, pkt->size); @@ -1258,12 +1261,12 @@ if (avctx->gop_size == 0 || f->picture_number % avctx->gop_size == 0) { put_rac(c, &keystate, 1); - avctx->coded_frame->key_frame = 1; + f->key_frame = 1; f->gob_count++; write_header(f); } else { put_rac(c, &keystate, 0); - avctx->coded_frame->key_frame = 0; + f->key_frame = 0; } if (f->ac > 1) { @@ -1313,14 +1316,20 @@ buf_p += bytes; } - if (avctx->flags & CODEC_FLAG_PASS1) + if (avctx->flags & AV_CODEC_FLAG_PASS1) avctx->stats_out[0] = '\0'; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->key_frame = f->key_frame; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + f->picture_number++; pkt->size = buf_p - pkt->data; pkt->pts = pkt->dts = pict->pts; - pkt->flags |= AV_PKT_FLAG_KEY * avctx->coded_frame->key_frame; + pkt->flags |= AV_PKT_FLAG_KEY * f->key_frame; *got_packet = 1; return 0; @@ -1328,7 +1337,6 @@ static av_cold int encode_close(AVCodecContext *avctx) { - av_frame_free(&avctx->coded_frame); ffv1_close(avctx); return 0; } @@ -1361,7 +1369,7 @@ .init = encode_init, .encode2 = encode_frame, .close = encode_close, - .capabilities = CODEC_CAP_SLICE_THREADS | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_DELAY, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV411P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ffv1.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/ffv1.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ffv1.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ffv1.h 2015-07-21 17:20:03.000000000 +0000 @@ -87,6 +87,7 @@ int transparency; int flags; int picture_number; + int key_frame; ThreadFrame picture, last_picture; struct FFV1Context *fsrc; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ffwavesynth.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ffwavesynth.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ffwavesynth.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ffwavesynth.c 2015-07-28 17:20:07.000000000 +0000 @@ -477,5 +477,5 @@ .init = wavesynth_init, .close = wavesynth_close, .decode = wavesynth_decode, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/fic.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/fic.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/fic.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/fic.c 2015-07-28 17:20:07.000000000 +0000 @@ -22,6 +22,7 @@ */ #include "libavutil/common.h" +#include "libavutil/opt.h" #include "avcodec.h" #include "internal.h" #include "get_bits.h" @@ -36,6 +37,7 @@ } FICThreadContext; typedef struct FICContext { + AVClass *class; AVCodecContext *avctx; AVFrame *frame; AVFrame *final_frame; @@ -51,6 +53,7 @@ int num_slices, slice_h; uint8_t cursor_buf[4096]; + int skip_cursor; } FICContext; static const uint8_t fic_qmat_hq[64] = { @@ -263,7 +266,7 @@ int msize; int tsize; int cur_x, cur_y; - int skip_cursor = 0; + int skip_cursor = ctx->skip_cursor; uint8_t *sdata; if ((ret = ff_reget_buffer(avctx, ctx->frame)) < 0) @@ -452,6 +455,18 @@ return 0; } +static const AVOption options[] = { +{ "skip_cursor", "skip the cursor", offsetof(FICContext, skip_cursor), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM }, +{ NULL }, +}; + +static const AVClass fic_decoder_class = { + .class_name = "FIC encoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_fic_decoder = { .name = "fic", .long_name = NULL_IF_CONFIG_SMALL("Mirillis FIC"), @@ -461,5 +476,6 @@ .init = fic_decode_init, .decode = fic_decode_frame, .close = fic_decode_close, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, + .priv_class = &fic_decoder_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/flacdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/flacdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/flacdec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/flacdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -665,7 +665,7 @@ .close = flac_decode_close, .decode = flac_decode_frame, .init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy), - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S32, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/flacenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/flacenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/flacenc.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/flacenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -1390,7 +1390,7 @@ } } - if ((ret = ff_alloc_packet2(avctx, avpkt, frame_bytes)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, frame_bytes, 0)) < 0) return ret; out_bytes = write_frame(s, avpkt); @@ -1475,7 +1475,7 @@ .init = flac_encode_init, .encode2 = flac_encode_frame, .close = flac_encode_close, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY | CODEC_CAP_LOSSLESS, + .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_LOSSLESS, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/flashsv2enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/flashsv2enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/flashsv2enc.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/flashsv2enc.c 2015-07-28 17:20:07.000000000 +0000 @@ -854,7 +854,7 @@ int res; int keyframe = 0; - if ((res = ff_alloc_packet2(avctx, pkt, s->frame_size + FF_MIN_BUFFER_SIZE)) < 0) + if ((res = ff_alloc_packet2(avctx, pkt, s->frame_size + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return res; /* First frame needs to be a keyframe */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/flashsv.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/flashsv.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/flashsv.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/flashsv.c 2015-07-28 17:20:07.000000000 +0000 @@ -509,7 +509,7 @@ .init = flashsv_decode_init, .close = flashsv_decode_end, .decode = flashsv_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_NONE }, }; #endif /* CONFIG_FLASHSV_DECODER */ @@ -572,7 +572,7 @@ .init = flashsv2_decode_init, .close = flashsv2_decode_end, .decode = flashsv_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_NONE }, }; #endif /* CONFIG_FLASHSV2_DECODER */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/flashsvenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/flashsvenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/flashsvenc.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/flashsvenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -98,8 +98,6 @@ av_freep(&s->previous_frame); av_freep(&s->tmpblock); - av_frame_free(&avctx->coded_frame); - return 0; } @@ -131,12 +129,6 @@ return AVERROR(ENOMEM); } - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) { - flashsv_encode_end(avctx); - return AVERROR(ENOMEM); - } - return 0; } @@ -246,7 +238,7 @@ I_frame = 1; } - if ((res = ff_alloc_packet2(avctx, pkt, s->image_width * s->image_height * 3)) < 0) + if ((res = ff_alloc_packet2(avctx, pkt, s->image_width * s->image_height * 3, 0)) < 0) return res; pkt->size = encode_bitstream(s, p, pkt->data, pkt->size, opt_w * 16, opt_h * 16, @@ -262,16 +254,24 @@ //mark the frame type so the muxer can mux it correctly if (I_frame) { +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif s->last_key_frame = avctx->frame_number; ff_dlog(avctx, "Inserting keyframe at frame %d\n", avctx->frame_number); } else { +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P; avctx->coded_frame->key_frame = 0; +FF_ENABLE_DEPRECATION_WARNINGS +#endif } - if (avctx->coded_frame->key_frame) + if (I_frame) pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/flicvideo.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/flicvideo.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/flicvideo.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/flicvideo.c 2015-07-28 17:20:07.000000000 +0000 @@ -193,7 +193,7 @@ pixels = s->frame->data[0]; pixel_limit = s->avctx->height * s->frame->linesize[0]; - if (buf_size < 16 || buf_size > INT_MAX - (3 * 256 + FF_INPUT_BUFFER_PADDING_SIZE)) + if (buf_size < 16 || buf_size > INT_MAX - (3 * 256 + AV_INPUT_BUFFER_PADDING_SIZE)) return AVERROR_INVALIDDATA; frame_size = bytestream2_get_le32(&g2); if (frame_size > buf_size) @@ -814,5 +814,5 @@ .init = flic_decode_init, .close = flic_decode_end, .decode = flic_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/flvdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/flvdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/flvdec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/flvdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -122,7 +122,7 @@ .init = ff_h263_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, .max_lowres = 3, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/flvenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/flvenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/flvenc.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/flvenc.c 2015-06-13 17:20:02.000000000 +0000 @@ -20,6 +20,7 @@ #include "flv.h" #include "h263.h" +#include "h263data.h" #include "mpegvideo.h" #include "mpegvideodata.h" @@ -90,7 +91,12 @@ } } -FF_MPV_GENERIC_CLASS(flv) +static const AVClass flv_class = { + .class_name = "flv encoder", + .item_name = av_default_item_name, + .option = ff_mpv_generic_options, + .version = LIBAVUTIL_VERSION_INT, +}; AVCodec ff_flv_encoder = { .name = "flv", diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/frame_thread_encoder.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/frame_thread_encoder.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/frame_thread_encoder.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/frame_thread_encoder.c 2015-07-28 17:20:07.000000000 +0000 @@ -122,12 +122,12 @@ if( !(avctx->thread_type & FF_THREAD_FRAME) - || !(avctx->codec->capabilities & CODEC_CAP_INTRA_ONLY)) + || !(avctx->codec->capabilities & AV_CODEC_CAP_INTRA_ONLY)) return 0; if( !avctx->thread_count && avctx->codec_id == AV_CODEC_ID_MJPEG - && !(avctx->flags & CODEC_FLAG_QSCALE)) { + && !(avctx->flags & AV_CODEC_FLAG_QSCALE)) { av_log(avctx, AV_LOG_DEBUG, "Forcing thread count to 1 for MJPEG encoding, use -thread_type slice " "or a constant quantizer if you want to use multiple cpu cores\n"); @@ -135,7 +135,7 @@ } if( avctx->thread_count > 1 && avctx->codec_id == AV_CODEC_ID_MJPEG - && !(avctx->flags & CODEC_FLAG_QSCALE)) + && !(avctx->flags & AV_CODEC_FLAG_QSCALE)) av_log(avctx, AV_LOG_WARNING, "MJPEG CBR encoding works badly with frame multi-threading, consider " "using -threads 1, -thread_type slice or a constant quantizer.\n"); @@ -143,7 +143,7 @@ if (avctx->codec_id == AV_CODEC_ID_HUFFYUV || avctx->codec_id == AV_CODEC_ID_FFVHUFF) { int warn = 0; - if (avctx->flags & CODEC_FLAG_PASS1) + if (avctx->flags & AV_CODEC_FLAG_PASS1) warn = 1; else if(avctx->context_model > 0) { AVDictionaryEntry *t = av_dict_get(options, "non_deterministic", diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/fraps.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/fraps.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/fraps.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/fraps.c 2015-07-28 17:20:07.000000000 +0000 @@ -322,5 +322,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/frwu.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/frwu.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/frwu.c 2015-06-18 18:54:57.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/frwu.c 2015-07-28 17:20:07.000000000 +0000 @@ -123,6 +123,6 @@ .priv_data_size = sizeof(FRWUContext), .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .priv_class = &frwu_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/g2meet.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/g2meet.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/g2meet.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/g2meet.c 2015-07-28 17:20:07.000000000 +0000 @@ -1,6 +1,7 @@ /* - * Go2Webinar decoder + * Go2Webinar / Go2Meeting decoder * Copyright (c) 2012 Konstantin Shishkov + * Copyright (c) 2013 Maxim Poliakovski * * This file is part of FFmpeg. * @@ -21,7 +22,7 @@ /** * @file - * Go2Webinar decoder + * Go2Webinar / Go2Meeting decoder */ #include @@ -32,12 +33,16 @@ #include "avcodec.h" #include "blockdsp.h" #include "bytestream.h" +#include "elsdec.h" #include "get_bits.h" #include "idctdsp.h" #include "internal.h" #include "jpegtables.h" #include "mjpeg.h" +#define EPIC_PIX_STACK_SIZE 1024 +#define EPIC_PIX_STACK_MAX (EPIC_PIX_STACK_SIZE - 1) + enum ChunkType { DISPLAY_INFO = 0xC8, TILE_DATA, @@ -74,6 +79,42 @@ 50, 50, 50, 50, 50, 50, 50, 50, }; +typedef struct ePICPixListElem { + struct ePICPixListElem *next; + uint32_t pixel; + uint8_t rung; +} ePICPixListElem; + +typedef struct ePICPixHashElem { + uint32_t pix_id; + struct ePICPixListElem *list; +} ePICPixHashElem; + +#define EPIC_HASH_SIZE 256 +typedef struct ePICPixHash { + ePICPixHashElem *bucket[EPIC_HASH_SIZE]; + int bucket_size[EPIC_HASH_SIZE]; + int bucket_fill[EPIC_HASH_SIZE]; +} ePICPixHash; + +typedef struct ePICContext { + ElsDecCtx els_ctx; + int next_run_pos; + ElsUnsignedRung unsigned_rung; + uint8_t W_flag_rung; + uint8_t N_flag_rung; + uint8_t W_ctx_rung[256]; + uint8_t N_ctx_rung[512]; + uint8_t nw_pred_rung[256]; + uint8_t ne_pred_rung[256]; + uint8_t prev_row_rung[14]; + uint8_t runlen_zeroes[14]; + uint8_t runlen_one; + int stack_pos; + uint32_t stack[EPIC_PIX_STACK_SIZE]; + ePICPixHash hash; +} ePICContext; + typedef struct JPGContext { BlockDSPContext bdsp; IDCTDSPContext idsp; @@ -87,7 +128,9 @@ } JPGContext; typedef struct G2MContext { + ePICContext ec; JPGContext jc; + int version; int compression; @@ -101,8 +144,9 @@ uint8_t *framebuf; int framebuf_stride, old_width, old_height; - uint8_t *synth_tile, *jpeg_tile; - int tile_stride, old_tile_w, old_tile_h; + uint8_t *synth_tile, *jpeg_tile, *epic_buf, *epic_buf_base; + int tile_stride, epic_buf_stride, old_tile_w, old_tile_h; + int swapuv; uint8_t *kempf_buf, *kempf_flags; @@ -229,11 +273,11 @@ return 0; } -static inline void yuv2rgb(uint8_t *out, int Y, int U, int V) +static inline void yuv2rgb(uint8_t *out, int ridx, int Y, int U, int V) { - out[0] = av_clip_uint8(Y + ( 91881 * V + 32768 >> 16)); - out[1] = av_clip_uint8(Y + (-22554 * U - 46802 * V + 32768 >> 16)); - out[2] = av_clip_uint8(Y + (116130 * U + 32768 >> 16)); + out[ridx] = av_clip_uint8(Y + (91881 * V + 32768 >> 16)); + out[1] = av_clip_uint8(Y + (-22554 * U - 46802 * V + 32768 >> 16)); + out[2 - ridx] = av_clip_uint8(Y + (116130 * U + 32768 >> 16)); } static int jpg_decode_data(JPGContext *c, int width, int height, @@ -247,12 +291,13 @@ int bx, by; int unesc_size; int ret; + const int ridx = swapuv ? 2 : 0; if ((ret = av_reallocp(&c->buf, - src_size + FF_INPUT_BUFFER_PADDING_SIZE)) < 0) + src_size + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) return ret; jpg_unescape(src, src_size, c->buf, &unesc_size); - memset(c->buf + unesc_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(c->buf + unesc_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); if((ret = init_get_bits8(&gb, c->buf, unesc_size)) < 0) return ret; @@ -299,9 +344,9 @@ int Y, U, V; Y = c->block[(j >> 3) * 2 + (i >> 3)][(i & 7) + (j & 7) * 8]; - U = c->block[4 ^ swapuv][(i >> 1) + (j >> 1) * 8] - 128; - V = c->block[5 ^ swapuv][(i >> 1) + (j >> 1) * 8] - 128; - yuv2rgb(out + i * 3, Y, U, V); + U = c->block[4][(i >> 1) + (j >> 1) * 8] - 128; + V = c->block[5][(i >> 1) + (j >> 1) * 8] - 128; + yuv2rgb(out + i * 3, ridx, Y, U, V); } } @@ -318,6 +363,654 @@ return 0; } +#define LOAD_NEIGHBOURS(x) \ + W = curr_row[(x) - 1]; \ + N = above_row[(x)]; \ + WW = curr_row[(x) - 2]; \ + NW = above_row[(x) - 1]; \ + NE = above_row[(x) + 1]; \ + NN = above2_row[(x)]; \ + NNW = above2_row[(x) - 1]; \ + NWW = above_row[(x) - 2]; \ + NNE = above2_row[(x) + 1] + +#define UPDATE_NEIGHBOURS(x) \ + NNW = NN; \ + NN = NNE; \ + NWW = NW; \ + NW = N; \ + N = NE; \ + NE = above_row[(x) + 1]; \ + NNE = above2_row[(x) + 1] + +#define R_shift 16 +#define G_shift 8 +#define B_shift 0 + +/* improved djb2 hash from http://www.cse.yorku.ca/~oz/hash.html */ +static int djb2_hash(uint32_t key) +{ + uint32_t h = 5381; + + h = (h * 33) ^ ((key >> 24) & 0xFF); // xxx: probably not needed at all + h = (h * 33) ^ ((key >> 16) & 0xFF); + h = (h * 33) ^ ((key >> 8) & 0xFF); + h = (h * 33) ^ (key & 0xFF); + + return h & (EPIC_HASH_SIZE - 1); +} + +static void epic_hash_init(ePICPixHash *hash) +{ + memset(hash, 0, sizeof(*hash)); +} + +static ePICPixHashElem *epic_hash_find(const ePICPixHash *hash, uint32_t key) +{ + int i, idx = djb2_hash(key); + ePICPixHashElem *bucket = hash->bucket[idx]; + + for (i = 0; i < hash->bucket_fill[idx]; i++) + if (bucket[i].pix_id == key) + return &bucket[i]; + + return NULL; +} + +static ePICPixHashElem *epic_hash_add(ePICPixHash *hash, uint32_t key) +{ + ePICPixHashElem *bucket, *ret; + int idx = djb2_hash(key); + + if (hash->bucket_size[idx] > INT_MAX / sizeof(**hash->bucket)) + return NULL; + + if (!(hash->bucket_fill[idx] < hash->bucket_size[idx])) { + int new_size = hash->bucket_size[idx] + 16; + bucket = av_realloc(hash->bucket[idx], new_size * sizeof(*bucket)); + if (!bucket) + return NULL; + hash->bucket[idx] = bucket; + hash->bucket_size[idx] = new_size; + } + + ret = &hash->bucket[idx][hash->bucket_fill[idx]++]; + memset(ret, 0, sizeof(*ret)); + ret->pix_id = key; + return ret; +} + +static int epic_add_pixel_to_cache(ePICPixHash *hash, uint32_t key, uint32_t pix) +{ + ePICPixListElem *new_elem; + ePICPixHashElem *hash_elem = epic_hash_find(hash, key); + + if (!hash_elem) { + if (!(hash_elem = epic_hash_add(hash, key))) + return AVERROR(ENOMEM); + } + + new_elem = av_mallocz(sizeof(*new_elem)); + if (!new_elem) + return AVERROR(ENOMEM); + + new_elem->pixel = pix; + new_elem->next = hash_elem->list; + hash_elem->list = new_elem; + + return 0; +} + +static inline int epic_cache_entries_for_pixel(const ePICPixHash *hash, + uint32_t pix) +{ + ePICPixHashElem *hash_elem = epic_hash_find(hash, pix); + + if (hash_elem != NULL && hash_elem->list != NULL) + return 1; + + return 0; +} + +static void epic_free_pixel_cache(ePICPixHash *hash) +{ + int i, j; + + for (i = 0; i < EPIC_HASH_SIZE; i++) { + for (j = 0; j < hash->bucket_fill[i]; j++) { + ePICPixListElem *list_elem = hash->bucket[i][j].list; + while (list_elem) { + ePICPixListElem *tmp = list_elem->next; + av_free(list_elem); + list_elem = tmp; + } + } + av_freep(&hash->bucket[i]); + hash->bucket_size[i] = + hash->bucket_fill[i] = 0; + } +} + +static inline int is_pixel_on_stack(const ePICContext *dc, uint32_t pix) +{ + int i; + + for (i = 0; i < dc->stack_pos; i++) + if (dc->stack[i] == pix) + break; + + return i != dc->stack_pos; +} + +#define TOSIGNED(val) (((val) >> 1) ^ -((val) & 1)) + +static inline int epic_decode_component_pred(ePICContext *dc, + int N, int W, int NW) +{ + unsigned delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung); + return mid_pred(N, N + W - NW, W) - TOSIGNED(delta); +} + +static uint32_t epic_decode_pixel_pred(ePICContext *dc, int x, int y, + const uint32_t *curr_row, + const uint32_t *above_row) +{ + uint32_t N, W, NW, pred; + unsigned delta; + int GN, GW, GNW, R, G, B; + + if (x && y) { + W = curr_row[x - 1]; + N = above_row[x]; + NW = above_row[x - 1]; + + GN = (N >> G_shift) & 0xFF; + GW = (W >> G_shift) & 0xFF; + GNW = (NW >> G_shift) & 0xFF; + + G = epic_decode_component_pred(dc, GN, GW, GNW); + + R = G + epic_decode_component_pred(dc, + ((N >> R_shift) & 0xFF) - GN, + ((W >> R_shift) & 0xFF) - GW, + ((NW >> R_shift) & 0xFF) - GNW); + + B = G + epic_decode_component_pred(dc, + ((N >> B_shift) & 0xFF) - GN, + ((W >> B_shift) & 0xFF) - GW, + ((NW >> B_shift) & 0xFF) - GNW); + } else { + if (x) + pred = curr_row[x - 1]; + else + pred = above_row[x]; + + delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung); + R = ((pred >> R_shift) & 0xFF) - TOSIGNED(delta); + + delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung); + G = ((pred >> G_shift) & 0xFF) - TOSIGNED(delta); + + delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung); + B = ((pred >> B_shift) & 0xFF) - TOSIGNED(delta); + } + + if (R<0 || G<0 || B<0) { + av_log(NULL, AV_LOG_ERROR, "RGB %d %d %d is out of range\n", R, G, B); + return 0; + } + + return (R << R_shift) | (G << G_shift) | (B << B_shift); +} + +static int epic_predict_pixel(ePICContext *dc, uint8_t *rung, + uint32_t *pPix, uint32_t pix) +{ + if (!ff_els_decode_bit(&dc->els_ctx, rung)) { + *pPix = pix; + return 1; + } + dc->stack[dc->stack_pos++ & EPIC_PIX_STACK_MAX] = pix; + return 0; +} + +static int epic_handle_edges(ePICContext *dc, int x, int y, + const uint32_t *curr_row, + const uint32_t *above_row, uint32_t *pPix) +{ + uint32_t pix; + + if (!x && !y) { /* special case: top-left pixel */ + /* the top-left pixel is coded independently with 3 unsigned numbers */ + *pPix = (ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung) << R_shift) | + (ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung) << G_shift) | + (ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung) << B_shift); + return 1; + } + + if (x) { /* predict from W first */ + pix = curr_row[x - 1]; + if (epic_predict_pixel(dc, &dc->W_flag_rung, pPix, pix)) + return 1; + } + + if (y) { /* then try to predict from N */ + pix = above_row[x]; + if (!dc->stack_pos || dc->stack[0] != pix) { + if (epic_predict_pixel(dc, &dc->N_flag_rung, pPix, pix)) + return 1; + } + } + + return 0; +} + +static int epic_decode_run_length(ePICContext *dc, int x, int y, int tile_width, + const uint32_t *curr_row, + const uint32_t *above_row, + const uint32_t *above2_row, + uint32_t *pPix, int *pRun) +{ + int idx, got_pixel = 0, WWneW, old_WWneW = 0; + uint32_t W, WW, N, NN, NW, NE, NWW, NNW, NNE; + + *pRun = 0; + + LOAD_NEIGHBOURS(x); + + if (dc->next_run_pos == x) { + /* can't reuse W for the new pixel in this case */ + WWneW = 1; + } else { + idx = (WW != W) << 7 | + (NW != W) << 6 | + (N != NE) << 5 | + (NW != N) << 4 | + (NWW != NW) << 3 | + (NNE != NE) << 2 | + (NN != N) << 1 | + (NNW != NW); + WWneW = ff_els_decode_bit(&dc->els_ctx, &dc->W_ctx_rung[idx]); + } + + if (WWneW) + dc->stack[dc->stack_pos++ & EPIC_PIX_STACK_MAX] = W; + else { + *pPix = W; + got_pixel = 1; + } + + do { + int NWneW = 1; + if (got_pixel) // pixel value already known (derived from either W or N) + NWneW = *pPix != N; + else { // pixel value is unknown and will be decoded later + NWneW = *pRun ? NWneW : NW != W; + + /* TODO: RFC this mess! */ + switch (((NW != N) << 2) | (NWneW << 1) | WWneW) { + case 0: + break; // do nothing here + case 3: + case 5: + case 6: + case 7: + if (!is_pixel_on_stack(dc, N)) { + idx = WWneW << 8 | + (*pRun ? old_WWneW : WW != W) << 7 | + NWneW << 6 | + (N != NE) << 5 | + (NW != N) << 4 | + (NWW != NW) << 3 | + (NNE != NE) << 2 | + (NN != N) << 1 | + (NNW != NW); + if (!ff_els_decode_bit(&dc->els_ctx, &dc->N_ctx_rung[idx])) { + NWneW = 0; + *pPix = N; + got_pixel = 1; + break; + } + } + /* fall through */ + default: + NWneW = 1; + old_WWneW = WWneW; + if (!is_pixel_on_stack(dc, N)) + dc->stack[dc->stack_pos++ & EPIC_PIX_STACK_MAX] = N; + } + } + + (*pRun)++; + if (x + *pRun >= tile_width - 1) + break; + + UPDATE_NEIGHBOURS(x + *pRun); + + if (!NWneW && NW == N && N == NE) { + int pos, run, rle; + int start_pos = x + *pRun; + + /* scan for a run of pix in the line above */ + uint32_t pix = above_row[start_pos + 1]; + for (pos = start_pos + 2; pos < tile_width; pos++) + if (!(above_row[pos] == pix)) + break; + run = pos - start_pos - 1; + idx = av_ceil_log2(run); + if (ff_els_decode_bit(&dc->els_ctx, &dc->prev_row_rung[idx])) + *pRun += run; + else { + int flag; + /* run-length is coded as plain binary number of idx - 1 bits */ + for (pos = idx - 1, rle = 0, flag = 0; pos >= 0; pos--) { + if ((1 << pos) + rle < run && + ff_els_decode_bit(&dc->els_ctx, + flag ? &dc->runlen_one + : &dc->runlen_zeroes[pos])) { + flag = 1; + rle |= 1 << pos; + } + } + *pRun += rle; + break; // return immediately + } + if (x + *pRun >= tile_width - 1) + break; + + LOAD_NEIGHBOURS(x + *pRun); + WWneW = 0; + NWneW = 0; + } + + idx = WWneW << 7 | + NWneW << 6 | + (N != NE) << 5 | + (NW != N) << 4 | + (NWW != NW) << 3 | + (NNE != NE) << 2 | + (NN != N) << 1 | + (NNW != NW); + WWneW = ff_els_decode_bit(&dc->els_ctx, &dc->W_ctx_rung[idx]); + } while (!WWneW); + + dc->next_run_pos = x + *pRun; + return got_pixel; +} + +static int epic_predict_pixel2(ePICContext *dc, uint8_t *rung, + uint32_t *pPix, uint32_t pix) +{ + if (ff_els_decode_bit(&dc->els_ctx, rung)) { + *pPix = pix; + return 1; + } + dc->stack[dc->stack_pos++ & EPIC_PIX_STACK_MAX] = pix; + return 0; +} + +static int epic_predict_from_NW_NE(ePICContext *dc, int x, int y, int run, + int tile_width, const uint32_t *curr_row, + const uint32_t *above_row, uint32_t *pPix) +{ + int pos; + + /* try to reuse the NW pixel first */ + if (x && y) { + uint32_t NW = above_row[x - 1]; + if (NW != curr_row[x - 1] && NW != above_row[x] && !is_pixel_on_stack(dc, NW)) { + if (epic_predict_pixel2(dc, &dc->nw_pred_rung[NW & 0xFF], pPix, NW)) + return 1; + } + } + + /* try to reuse the NE[x + run, y] pixel */ + pos = x + run - 1; + if (pos < tile_width - 1 && y) { + uint32_t NE = above_row[pos + 1]; + if (NE != above_row[pos] && !is_pixel_on_stack(dc, NE)) { + if (epic_predict_pixel2(dc, &dc->ne_pred_rung[NE & 0xFF], pPix, NE)) + return 1; + } + } + + return 0; +} + +static int epic_decode_from_cache(ePICContext *dc, uint32_t W, uint32_t *pPix) +{ + ePICPixListElem *list, *prev = NULL; + ePICPixHashElem *hash_elem = epic_hash_find(&dc->hash, W); + + if (!hash_elem || !hash_elem->list) + return 0; + + list = hash_elem->list; + while (list) { + if (!is_pixel_on_stack(dc, list->pixel)) { + if (ff_els_decode_bit(&dc->els_ctx, &list->rung)) { + *pPix = list->pixel; + if (list != hash_elem->list) { + prev->next = list->next; + list->next = hash_elem->list; + hash_elem->list = list; + } + return 1; + } + dc->stack[dc->stack_pos++ & EPIC_PIX_STACK_MAX] = list->pixel; + } + prev = list; + list = list->next; + } + + return 0; +} + +static int epic_decode_tile(ePICContext *dc, uint8_t *out, int tile_height, + int tile_width, int stride) +{ + int x, y; + uint32_t pix; + uint32_t *curr_row = NULL, *above_row = NULL, *above2_row; + + for (y = 0; y < tile_height; y++, out += stride) { + above2_row = above_row; + above_row = curr_row; + curr_row = (uint32_t *) out; + + for (x = 0, dc->next_run_pos = 0; x < tile_width;) { + if (dc->els_ctx.err) + return AVERROR_INVALIDDATA; // bail out in the case of ELS overflow + + pix = curr_row[x - 1]; // get W pixel + + if (y >= 1 && x >= 2 && + pix != curr_row[x - 2] && pix != above_row[x - 1] && + pix != above_row[x - 2] && pix != above_row[x] && + !epic_cache_entries_for_pixel(&dc->hash, pix)) { + curr_row[x] = epic_decode_pixel_pred(dc, x, y, curr_row, above_row); + x++; + } else { + int got_pixel, run; + dc->stack_pos = 0; // empty stack + + if (y < 2 || x < 2 || x == tile_width - 1) { + run = 1; + got_pixel = epic_handle_edges(dc, x, y, curr_row, above_row, &pix); + } else + got_pixel = epic_decode_run_length(dc, x, y, tile_width, + curr_row, above_row, + above2_row, &pix, &run); + + if (!got_pixel && !epic_predict_from_NW_NE(dc, x, y, run, + tile_width, curr_row, + above_row, &pix)) { + uint32_t ref_pix = curr_row[x - 1]; + if (!x || !epic_decode_from_cache(dc, ref_pix, &pix)) { + pix = epic_decode_pixel_pred(dc, x, y, curr_row, above_row); + if (x) { + int ret = epic_add_pixel_to_cache(&dc->hash, + ref_pix, + pix); + if (ret) + return ret; + } + } + } + for (; run > 0; x++, run--) + curr_row[x] = pix; + } + } + } + + return 0; +} + +static int epic_jb_decode_tile(G2MContext *c, int tile_x, int tile_y, + const uint8_t *src, size_t src_size, + AVCodecContext *avctx) +{ + uint8_t prefix, mask = 0x80; + int extrabytes, tile_width, tile_height, awidth, aheight; + size_t els_dsize; + uint8_t *dst; + + if (!src_size) + return 0; + + /* get data size of the ELS partition as unsigned variable-length integer */ + prefix = *src++; + src_size--; + for (extrabytes = 0; (prefix & mask) && (extrabytes < 7); extrabytes++) + mask >>= 1; + if (extrabytes > 3 || src_size < extrabytes) { + av_log(avctx, AV_LOG_ERROR, "ePIC: invalid data size VLI\n"); + return AVERROR_INVALIDDATA; + } + + els_dsize = prefix & ((0x80 >> extrabytes) - 1); // mask out the length prefix + while (extrabytes-- > 0) { + els_dsize = (els_dsize << 8) | *src++; + src_size--; + } + + if (src_size < els_dsize) { + av_log(avctx, AV_LOG_ERROR, "ePIC: data too short, needed %zu, got %zu\n", + els_dsize, src_size); + return AVERROR_INVALIDDATA; + } + + tile_width = FFMIN(c->width - tile_x * c->tile_width, c->tile_width); + tile_height = FFMIN(c->height - tile_y * c->tile_height, c->tile_height); + awidth = FFALIGN(tile_width, 16); + aheight = FFALIGN(tile_height, 16); + + if (els_dsize) { + int ret, i, j, k; + uint8_t tr_r, tr_g, tr_b, *buf; + uint32_t *in; + /* ELS decoder initializations */ + memset(&c->ec, 0, sizeof(c->ec)); + ff_els_decoder_init(&c->ec.els_ctx, src, els_dsize); + epic_hash_init(&c->ec.hash); + + /* decode transparent pixel value */ + tr_r = ff_els_decode_unsigned(&c->ec.els_ctx, &c->ec.unsigned_rung); + tr_g = ff_els_decode_unsigned(&c->ec.els_ctx, &c->ec.unsigned_rung); + tr_b = ff_els_decode_unsigned(&c->ec.els_ctx, &c->ec.unsigned_rung); + if (c->ec.els_ctx.err != 0) { + av_log(avctx, AV_LOG_ERROR, + "ePIC: couldn't decode transparency pixel!\n"); + return AVERROR_INVALIDDATA; + } + + ret = epic_decode_tile(&c->ec, c->epic_buf, tile_height, tile_width, + c->epic_buf_stride); + + epic_free_pixel_cache(&c->ec.hash); + ff_els_decoder_uninit(&c->ec.unsigned_rung); + + if (ret) { + av_log(avctx, AV_LOG_ERROR, + "ePIC: tile decoding failed, frame=%d, tile_x=%d, tile_y=%d\n", + avctx->frame_number, tile_x, tile_y); + return AVERROR_INVALIDDATA; + } + + buf = c->epic_buf; + dst = c->framebuf + tile_x * c->tile_width * 3 + + tile_y * c->tile_height * c->framebuf_stride; + + for (j = 0; j < tile_height; j++) { + uint8_t *out = dst; + in = (uint32_t *) buf; + for (i = 0; i < tile_width; i++) { + out[0] = (in[i] >> R_shift) & 0xFF; + out[1] = (in[i] >> G_shift) & 0xFF; + out[2] = (in[i] >> B_shift) & 0xFF; + out += 3; + } + buf += c->epic_buf_stride; + dst += c->framebuf_stride; + } + + if (src_size > els_dsize) { + uint8_t *jpg; + uint32_t tr; + int bstride = FFALIGN(tile_width, 16) >> 3; + int nblocks = 0; + int estride = c->epic_buf_stride >> 2; + + src += els_dsize; + src_size -= els_dsize; + + in = (uint32_t *) c->epic_buf; + tr = (tr_r << R_shift) | (tr_g << G_shift) | (tr_b << B_shift); + + memset(c->kempf_flags, 0, + (aheight >> 3) * bstride * sizeof(*c->kempf_flags)); + for (j = 0; j < tile_height; j += 8) { + for (i = 0; i < tile_width; i += 8) { + c->kempf_flags[(i >> 3) + (j >> 3) * bstride] = 0; + for (k = 0; k < 8 * 8; k++) { + if (in[i + (k & 7) + (k >> 3) * estride] == tr) { + c->kempf_flags[(i >> 3) + (j >> 3) * bstride] = 1; + nblocks++; + break; + } + } + } + in += 8 * estride; + } + + memset(c->jpeg_tile, 0, c->tile_stride * aheight); + jpg_decode_data(&c->jc, awidth, aheight, src, src_size, + c->jpeg_tile, c->tile_stride, + c->kempf_flags, bstride, nblocks, c->swapuv); + + in = (uint32_t *) c->epic_buf; + dst = c->framebuf + tile_x * c->tile_width * 3 + + tile_y * c->tile_height * c->framebuf_stride; + jpg = c->jpeg_tile; + for (j = 0; j < tile_height; j++) { + for (i = 0; i < tile_width; i++) + if (in[i] == tr) + memcpy(dst + i * 3, jpg + i * 3, 3); + in += c->epic_buf_stride >> 2; + dst += c->framebuf_stride; + jpg += c->tile_stride; + } + } + } else { + dst = c->framebuf + tile_x * c->tile_width * 3 + + tile_y * c->tile_height * c->framebuf_stride; + return jpg_decode_data(&c->jc, tile_width, tile_height, src, src_size, + dst, c->framebuf_stride, NULL, 0, 0, c->swapuv); + } + + return 0; +} + static int kempf_restore_buf(const uint8_t *src, int len, uint8_t *dst, int stride, const uint8_t *jpeg_tile, int tile_stride, @@ -327,6 +1020,7 @@ GetBitContext gb; int i, j, nb, col; int ret; + int align_width = FFALIGN(width, 16); if ((ret = init_get_bits8(&gb, src, len)) < 0) return ret; @@ -346,6 +1040,7 @@ else memcpy(dst + i * 3, jpeg_tile + i * 3, 3); } + skip_bits_long(&gb, nb * (align_width - width)); } return 0; @@ -475,22 +1170,32 @@ return AVERROR(ENOMEM); } if (!c->synth_tile || !c->jpeg_tile || + (c->compression == 2 && !c->epic_buf_base) || c->old_tile_w < c->tile_width || c->old_tile_h < c->tile_height) { - c->tile_stride = FFALIGN(c->tile_width, 16) * 3; - aligned_height = FFALIGN(c->tile_height, 16); - av_free(c->synth_tile); - av_free(c->jpeg_tile); - av_free(c->kempf_buf); - av_free(c->kempf_flags); + c->tile_stride = FFALIGN(c->tile_width, 16) * 3; + c->epic_buf_stride = FFALIGN(c->tile_width * 4, 16); + aligned_height = FFALIGN(c->tile_height, 16); + av_freep(&c->synth_tile); + av_freep(&c->jpeg_tile); + av_freep(&c->kempf_buf); + av_freep(&c->kempf_flags); + av_freep(&c->epic_buf_base); + c->epic_buf = NULL; c->synth_tile = av_mallocz(c->tile_stride * aligned_height); c->jpeg_tile = av_mallocz(c->tile_stride * aligned_height); - c->kempf_buf = av_mallocz((c->tile_width + 1) * aligned_height - + FF_INPUT_BUFFER_PADDING_SIZE); - c->kempf_flags = av_mallocz( c->tile_width * aligned_height); + c->kempf_buf = av_mallocz((c->tile_width + 1) * aligned_height + + AV_INPUT_BUFFER_PADDING_SIZE); + c->kempf_flags = av_mallocz(c->tile_width * aligned_height); if (!c->synth_tile || !c->jpeg_tile || !c->kempf_buf || !c->kempf_flags) return AVERROR(ENOMEM); + if (c->compression == 2) { + c->epic_buf_base = av_mallocz(c->epic_buf_stride * aligned_height + 4); + if (!c->epic_buf_base) + return AVERROR(ENOMEM); + c->epic_buf = c->epic_buf_base + 4; + } } return 0; @@ -696,10 +1401,7 @@ return AVERROR_INVALIDDATA; } - if ((magic & 0xF) < 4) { - av_log(avctx, AV_LOG_ERROR, "G2M2 and G2M3 are not yet supported\n"); - return AVERROR(ENOSYS); - } + c->swapuv = magic == MKBETAG('G', '2', 'M', '2'); while (bytestream2_get_bytes_left(&bc) > 5) { chunk_size = bytestream2_get_le32(&bc) - 1; @@ -808,9 +1510,10 @@ ret = 0; switch (c->compression) { case COMPR_EPIC_J_B: - av_log(avctx, AV_LOG_ERROR, - "ePIC j-b compression is not implemented yet\n"); - return AVERROR(ENOSYS); + ret = epic_jb_decode_tile(c, c->tile_x, c->tile_y, + buf + bytestream2_tell(&bc), + chunk_size - 2, avctx); + break; case COMPR_KEMPF_J_B: ret = kempf_decode_tile(c, c->tile_x, c->tile_y, buf + bytestream2_tell(&bc), @@ -906,6 +1609,8 @@ jpg_free_context(&c->jc); + av_freep(&c->epic_buf_base); + c->epic_buf = NULL; av_freep(&c->kempf_buf); av_freep(&c->kempf_flags); av_freep(&c->synth_tile); @@ -925,5 +1630,6 @@ .init = g2m_decode_init, .close = g2m_decode_end, .decode = g2m_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/g722dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/g722dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/g722dec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/g722dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -145,6 +145,6 @@ .priv_data_size = sizeof(G722Context), .init = g722_decode_init, .decode = g722_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .priv_class = &g722_decoder_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/g722enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/g722enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/g722enc.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/g722enc.c 2015-07-28 17:20:07.000000000 +0000 @@ -358,7 +358,7 @@ int nb_samples, out_size, ret; out_size = (frame->nb_samples + 1) / 2; - if ((ret = ff_alloc_packet2(avctx, avpkt, out_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, out_size, 0)) < 0) return ret; nb_samples = frame->nb_samples - (frame->nb_samples & 1); @@ -389,7 +389,7 @@ .init = g722_encode_init, .close = g722_encode_close, .encode2 = g722_encode_frame, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME, + .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/g723_1.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/g723_1.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/g723_1.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/g723_1.c 2015-07-28 17:20:07.000000000 +0000 @@ -1337,7 +1337,7 @@ .priv_data_size = sizeof(G723_1_Context), .init = g723_1_decode_init, .decode = g723_1_decode_frame, - .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1, .priv_class = &g723_1dec_class, }; @@ -2462,7 +2462,7 @@ av_freep(&in_orig); in = NULL; - if ((ret = ff_alloc_packet2(avctx, avpkt, 24)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, 24, 0)) < 0) return ret; *got_packet_ptr = 1; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/g726.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/g726.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/g726.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/g726.c 2015-07-28 17:20:07.000000000 +0000 @@ -23,7 +23,6 @@ */ #include -#include "libavutil/avassert.h" #include "libavutil/channel_layout.h" #include "libavutil/opt.h" #include "avcodec.h" @@ -316,7 +315,11 @@ "Resample or reduce the compliance level.\n"); return AVERROR(EINVAL); } - av_assert0(avctx->sample_rate > 0); + if (avctx->sample_rate <= 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid sample rate %d\n", + avctx->sample_rate); + return AVERROR(EINVAL); + } if(avctx->channels != 1){ av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n"); @@ -348,7 +351,7 @@ int i, ret, out_size; out_size = (frame->nb_samples * c->code_size + 7) / 8; - if ((ret = ff_alloc_packet2(avctx, avpkt, out_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, out_size, 0)) < 0) return ret; init_put_bits(&pb, avpkt->data, avpkt->size); @@ -389,7 +392,7 @@ .priv_data_size = sizeof(G726Context), .init = g726_encode_init, .encode2 = g726_encode_frame, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME, + .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .priv_class = &g726_class, @@ -474,7 +477,7 @@ .init = g726_decode_init, .decode = g726_decode_frame, .flush = g726_decode_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif @@ -487,7 +490,7 @@ .init = g726_decode_init, .decode = g726_decode_frame, .flush = g726_decode_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM little-endian"), }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/g729dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/g729dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/g729dec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/g729dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -722,5 +722,5 @@ .priv_data_size = sizeof(G729Context), .init = decoder_init, .decode = decode_frame, - .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/get_bits.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/get_bits.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/get_bits.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/get_bits.h 2015-07-28 17:20:07.000000000 +0000 @@ -401,7 +401,7 @@ /** * Initialize GetBitContext. - * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes + * @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 @@ -432,7 +432,7 @@ /** * Initialize GetBitContext. - * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes + * @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 diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/gif.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/gif.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/gif.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/gif.c 2015-07-28 17:20:07.000000000 +0000 @@ -221,13 +221,12 @@ av_log(avctx, AV_LOG_ERROR, "GIF does not support resolutions above 65535x65535\n"); return AVERROR(EINVAL); } - - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif s->transparent_index = -1; @@ -270,7 +269,7 @@ const uint32_t *palette = NULL; int ret; - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width*avctx->height*7/5 + FF_MIN_BUFFER_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width*avctx->height*7/5 + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return ret; outbuf_ptr = pkt->data; end = pkt->data + pkt->size; @@ -320,8 +319,6 @@ { GIFContext *s = avctx->priv_data; - av_frame_free(&avctx->coded_frame); - av_freep(&s->lzw); av_freep(&s->buf); av_frame_free(&s->last_frame); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/gifdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/gifdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/gifdec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/gifdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -553,6 +553,6 @@ .init = gif_decode_init, .close = gif_decode_close, .decode = gif_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .priv_class = &decoder_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/gsmdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/gsmdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/gsmdec.c 2015-06-18 18:54:57.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/gsmdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -120,7 +120,7 @@ .init = gsm_init, .decode = gsm_decode_frame, .flush = gsm_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif #if CONFIG_GSM_MS_DECODER @@ -133,6 +133,6 @@ .init = gsm_init, .decode = gsm_decode_frame, .flush = gsm_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h261dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h261dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h261dec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h261dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -685,6 +685,6 @@ .init = h261_decode_init, .close = h261_decode_end, .decode = h261_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .max_lowres = 3, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h261enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h261enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h261enc.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h261enc.c 2015-07-09 17:20:03.000000000 +0000 @@ -68,14 +68,14 @@ put_bits(&s->pb, 1, 0); /* split screen off */ put_bits(&s->pb, 1, 0); /* camera off */ - put_bits(&s->pb, 1, 0); /* freeze picture release off */ + put_bits(&s->pb, 1, s->pict_type == AV_PICTURE_TYPE_I); /* freeze picture release on/off */ format = ff_h261_get_picture_format(s->width, s->height); put_bits(&s->pb, 1, format); /* 0 == QCIF, 1 == CIF */ - put_bits(&s->pb, 1, 0); /* still image mode */ - put_bits(&s->pb, 1, 0); /* reserved */ + put_bits(&s->pb, 1, 1); /* still image mode */ + put_bits(&s->pb, 1, 1); /* reserved */ put_bits(&s->pb, 1, 0); /* no PEI */ if (format == 0) @@ -378,7 +378,12 @@ s->intra_ac_vlc_last_length = s->inter_ac_vlc_last_length = uni_h261_rl_len + 128*64; } -FF_MPV_GENERIC_CLASS(h261) +static const AVClass h261_class = { + .class_name = "h261 encoder", + .item_name = av_default_item_name, + .option = ff_mpv_generic_options, + .version = LIBAVUTIL_VERSION_INT, +}; AVCodec ff_h261_encoder = { .name = "h261", diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263.c 2015-06-13 17:20:02.000000000 +0000 @@ -40,9 +40,6 @@ #include "mpeg4video.h" -uint8_t ff_h263_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3]; - - void ff_h263_update_motion_val(MpegEncContext * s){ const int mb_xy = s->mb_y * s->mb_stride + s->mb_x; //FIXME a lot of that is only needed for !low_delay diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263data.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263data.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263data.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263data.c 2015-06-13 17:20:02.000000000 +0000 @@ -0,0 +1,292 @@ +/* + * H263+ tables + * + * 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 + */ + +/** + * @file + * H.263 tables. + */ + +#include + +#include "h263data.h" +#include "mpegvideo.h" + +uint8_t ff_h263_static_rl_table_store[2][2][2 * MAX_RUN + MAX_LEVEL + 3]; + +/* intra MCBPC, mb_type = (intra), then (intraq) */ +const uint8_t ff_h263_intra_MCBPC_code[9] = { 1, 1, 2, 3, 1, 1, 2, 3, 1 }; +const uint8_t ff_h263_intra_MCBPC_bits[9] = { 1, 3, 3, 3, 4, 6, 6, 6, 9 }; + +/* inter MCBPC, mb_type = (inter), (intra), (interq), (intraq), (inter4v) */ +/* Changed the tables for interq and inter4v+q, following the standard + * ** Juanjo ** */ +const uint8_t ff_h263_inter_MCBPC_code[28] = { + 1, 3, 2, 5, + 3, 4, 3, 3, + 3, 7, 6, 5, + 4, 4, 3, 2, + 2, 5, 4, 5, + 1, 0, 0, 0, /* Stuffing */ + 2, 12, 14, 15, +}; +const uint8_t ff_h263_inter_MCBPC_bits[28] = { + 1, 4, 4, 6, /* inter */ + 5, 8, 8, 7, /* intra */ + 3, 7, 7, 9, /* interQ */ + 6, 9, 9, 9, /* intraQ */ + 3, 7, 7, 8, /* inter4 */ + 9, 0, 0, 0, /* Stuffing */ + 11, 13, 13, 13, /* inter4Q */ +}; + +const uint8_t ff_h263_mbtype_b_tab[15][2] = { + { 1, 1 }, + { 3, 3 }, + { 1, 5 }, + { 4, 4 }, + { 5, 4 }, + { 6, 6 }, + { 2, 4 }, + { 3, 4 }, + { 7, 6 }, + { 4, 6 }, + { 5, 6 }, + { 1, 6 }, + { 1, 10 }, + { 1, 7 }, + { 1, 8 }, +}; + +const uint8_t ff_cbpc_b_tab[4][2] = { + { 0, 1 }, + { 2, 2 }, + { 7, 3 }, + { 6, 3 }, +}; + +const uint8_t ff_h263_cbpy_tab[16][2] = { + { 3, 4 }, { 5, 5 }, { 4, 5 }, { 9, 4 }, { 3, 5 }, { 7, 4 }, { 2, 6 }, + { 11, 4 }, { 2, 5 }, { 3, 6 }, { 5, 4 }, { 10, 4 }, { 4, 4 }, { 8, 4 }, + { 6, 4 }, { 3, 2 } +}; + +const uint8_t ff_mvtab[33][2] = { + { 1, 1 }, { 1, 2 }, { 1, 3 }, { 1, 4 }, { 3, 6 }, { 5, 7 }, + { 4, 7 }, { 3, 7 }, { 11, 9 }, { 10, 9 }, { 9, 9 }, { 17, 10 }, + { 16, 10 }, { 15, 10 }, { 14, 10 }, { 13, 10 }, { 12, 10 }, { 11, 10 }, + { 10, 10 }, { 9, 10 }, { 8, 10 }, { 7, 10 }, { 6, 10 }, { 5, 10 }, + { 4, 10 }, { 7, 11 }, { 6, 11 }, { 5, 11 }, { 4, 11 }, { 3, 11 }, + { 2, 11 }, { 3, 12 }, { 2, 12 } +}; + +/* third non intra table */ +const uint16_t ff_inter_vlc[103][2] = { + { 0x2, 2 }, { 0xf, 4 }, { 0x15, 6 }, { 0x17, 7 }, + { 0x1f, 8 }, { 0x25, 9 }, { 0x24, 9 }, { 0x21, 10 }, + { 0x20, 10 }, { 0x7, 11 }, { 0x6, 11 }, { 0x20, 11 }, + { 0x6, 3 }, { 0x14, 6 }, { 0x1e, 8 }, { 0xf, 10 }, + { 0x21, 11 }, { 0x50, 12 }, { 0xe, 4 }, { 0x1d, 8 }, + { 0xe, 10 }, { 0x51, 12 }, { 0xd, 5 }, { 0x23, 9 }, + { 0xd, 10 }, { 0xc, 5 }, { 0x22, 9 }, { 0x52, 12 }, + { 0xb, 5 }, { 0xc, 10 }, { 0x53, 12 }, { 0x13, 6 }, + { 0xb, 10 }, { 0x54, 12 }, { 0x12, 6 }, { 0xa, 10 }, + { 0x11, 6 }, { 0x9, 10 }, { 0x10, 6 }, { 0x8, 10 }, + { 0x16, 7 }, { 0x55, 12 }, { 0x15, 7 }, { 0x14, 7 }, + { 0x1c, 8 }, { 0x1b, 8 }, { 0x21, 9 }, { 0x20, 9 }, + { 0x1f, 9 }, { 0x1e, 9 }, { 0x1d, 9 }, { 0x1c, 9 }, + { 0x1b, 9 }, { 0x1a, 9 }, { 0x22, 11 }, { 0x23, 11 }, + { 0x56, 12 }, { 0x57, 12 }, { 0x7, 4 }, { 0x19, 9 }, + { 0x5, 11 }, { 0xf, 6 }, { 0x4, 11 }, { 0xe, 6 }, + { 0xd, 6 }, { 0xc, 6 }, { 0x13, 7 }, { 0x12, 7 }, + { 0x11, 7 }, { 0x10, 7 }, { 0x1a, 8 }, { 0x19, 8 }, + { 0x18, 8 }, { 0x17, 8 }, { 0x16, 8 }, { 0x15, 8 }, + { 0x14, 8 }, { 0x13, 8 }, { 0x18, 9 }, { 0x17, 9 }, + { 0x16, 9 }, { 0x15, 9 }, { 0x14, 9 }, { 0x13, 9 }, + { 0x12, 9 }, { 0x11, 9 }, { 0x7, 10 }, { 0x6, 10 }, + { 0x5, 10 }, { 0x4, 10 }, { 0x24, 11 }, { 0x25, 11 }, + { 0x26, 11 }, { 0x27, 11 }, { 0x58, 12 }, { 0x59, 12 }, + { 0x5a, 12 }, { 0x5b, 12 }, { 0x5c, 12 }, { 0x5d, 12 }, + { 0x5e, 12 }, { 0x5f, 12 }, { 0x3, 7 }, +}; + +const int8_t ff_inter_level[102] = { + 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 1, 2, 3, 4, + 5, 6, 1, 2, 3, 4, 1, 2, + 3, 1, 2, 3, 1, 2, 3, 1, + 2, 3, 1, 2, 1, 2, 1, 2, + 1, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 2, 3, 1, 2, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, +}; + +const int8_t ff_inter_run[102] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 2, 2, 2, 2, 3, 3, + 3, 4, 4, 4, 5, 5, 5, 6, + 6, 6, 7, 7, 8, 8, 9, 9, + 10, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 0, 0, 0, 1, 1, 2, + 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, +}; + +RLTable ff_h263_rl_inter = { + 102, + 58, + ff_inter_vlc, + ff_inter_run, + ff_inter_level, +}; + +static const uint16_t intra_vlc_aic[103][2] = { + { 0x2, 2 }, { 0x6, 3 }, { 0xe, 4 }, { 0xc, 5 }, + { 0xd, 5 }, { 0x10, 6 }, { 0x11, 6 }, { 0x12, 6 }, + { 0x16, 7 }, { 0x1b, 8 }, { 0x20, 9 }, { 0x21, 9 }, + { 0x1a, 9 }, { 0x1b, 9 }, { 0x1c, 9 }, { 0x1d, 9 }, + { 0x1e, 9 }, { 0x1f, 9 }, { 0x23, 11 }, { 0x22, 11 }, + { 0x57, 12 }, { 0x56, 12 }, { 0x55, 12 }, { 0x54, 12 }, + { 0x53, 12 }, { 0xf, 4 }, { 0x14, 6 }, { 0x14, 7 }, + { 0x1e, 8 }, { 0xf, 10 }, { 0x21, 11 }, { 0x50, 12 }, + { 0xb, 5 }, { 0x15, 7 }, { 0xe, 10 }, { 0x9, 10 }, + { 0x15, 6 }, { 0x1d, 8 }, { 0xd, 10 }, { 0x51, 12 }, + { 0x13, 6 }, { 0x23, 9 }, { 0x7, 11 }, { 0x17, 7 }, + { 0x22, 9 }, { 0x52, 12 }, { 0x1c, 8 }, { 0xc, 10 }, + { 0x1f, 8 }, { 0xb, 10 }, { 0x25, 9 }, { 0xa, 10 }, + { 0x24, 9 }, { 0x6, 11 }, { 0x21, 10 }, { 0x20, 10 }, + { 0x8, 10 }, { 0x20, 11 }, { 0x7, 4 }, { 0xc, 6 }, + { 0x10, 7 }, { 0x13, 8 }, { 0x11, 9 }, { 0x12, 9 }, + { 0x4, 10 }, { 0x27, 11 }, { 0x26, 11 }, { 0x5f, 12 }, + { 0xf, 6 }, { 0x13, 9 }, { 0x5, 10 }, { 0x25, 11 }, + { 0xe, 6 }, { 0x14, 9 }, { 0x24, 11 }, { 0xd, 6 }, + { 0x6, 10 }, { 0x5e, 12 }, { 0x11, 7 }, { 0x7, 10 }, + { 0x13, 7 }, { 0x5d, 12 }, { 0x12, 7 }, { 0x5c, 12 }, + { 0x14, 8 }, { 0x5b, 12 }, { 0x15, 8 }, { 0x1a, 8 }, + { 0x19, 8 }, { 0x18, 8 }, { 0x17, 8 }, { 0x16, 8 }, + { 0x19, 9 }, { 0x15, 9 }, { 0x16, 9 }, { 0x18, 9 }, + { 0x17, 9 }, { 0x4, 11 }, { 0x5, 11 }, { 0x58, 12 }, + { 0x59, 12 }, { 0x5a, 12 }, { 0x3, 7 }, +}; + +static const int8_t intra_run_aic[102] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 3, 3, 3, 3, + 4, 4, 4, 5, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 11, + 12, 13, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, + 2, 2, 2, 3, 3, 3, 4, 4, + 5, 5, 6, 6, 7, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, +}; + +static const int8_t intra_level_aic[102] = { + 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, + 25, 1, 2, 3, 4, 5, 6, 7, + 1, 2, 3, 4, 1, 2, 3, 4, + 1, 2, 3, 1, 2, 3, 1, 2, + 1, 2, 1, 2, 1, 2, 1, 1, + 1, 1, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 1, 2, 3, 4, + 1, 2, 3, 1, 2, 3, 1, 2, + 1, 2, 1, 2, 1, 2, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, +}; + +RLTable ff_rl_intra_aic = { + 102, + 58, + intra_vlc_aic, + intra_run_aic, + intra_level_aic, +}; + +const uint16_t ff_h263_format[8][2] = { + { 0, 0 }, + { 128, 96 }, + { 176, 144 }, + { 352, 288 }, + { 704, 576 }, + { 1408, 1152 }, +}; + +const uint8_t ff_aic_dc_scale_table[32] = { +// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62 +}; + +const uint8_t ff_modified_quant_tab[2][32] = { +// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 + { + 0, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 + }, + { + 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 31, 31, 26 + } +}; + +const uint8_t ff_h263_chroma_qscale_table[32] = { +// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 + 0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15 +}; + +const uint16_t ff_mba_max[6] = { + 47, 98, 395, 1583, 6335, 9215 +}; + +const uint8_t ff_mba_length[7] = { + 6, 7, 9, 11, 13, 14, 14 +}; + +const AVRational ff_h263_pixel_aspect[16] = { + { 0, 1 }, + { 1, 1 }, + { 12, 11 }, + { 10, 11 }, + { 16, 11 }, + { 40, 33 }, + { 0, 1 }, + { 0, 1 }, + { 0, 1 }, + { 0, 1 }, + { 0, 1 }, + { 0, 1 }, + { 0, 1 }, + { 0, 1 }, + { 0, 1 }, + { 0, 1 }, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263data.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263data.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263data.h 2015-06-18 18:54:57.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263data.h 2015-06-13 17:20:02.000000000 +0000 @@ -30,265 +30,48 @@ #define AVCODEC_H263DATA_H #include -#include "mpegvideo.h" + +#include "libavutil/rational.h" + +#include "rl.h" + +extern const AVRational ff_h263_pixel_aspect[16]; /* intra MCBPC, mb_type = (intra), then (intraq) */ -const uint8_t ff_h263_intra_MCBPC_code[9] = { 1, 1, 2, 3, 1, 1, 2, 3, 1 }; -const uint8_t ff_h263_intra_MCBPC_bits[9] = { 1, 3, 3, 3, 4, 6, 6, 6, 9 }; +extern const uint8_t ff_h263_intra_MCBPC_code[9]; +extern const uint8_t ff_h263_intra_MCBPC_bits[9]; /* inter MCBPC, mb_type = (inter), (intra), (interq), (intraq), (inter4v) */ /* Changed the tables for interq and inter4v+q, following the standard ** Juanjo ** */ -const uint8_t ff_h263_inter_MCBPC_code[28] = { - 1, 3, 2, 5, - 3, 4, 3, 3, - 3, 7, 6, 5, - 4, 4, 3, 2, - 2, 5, 4, 5, - 1, 0, 0, 0, /* Stuffing */ - 2, 12, 14, 15, -}; -const uint8_t ff_h263_inter_MCBPC_bits[28] = { - 1, 4, 4, 6, /* inter */ - 5, 8, 8, 7, /* intra */ - 3, 7, 7, 9, /* interQ */ - 6, 9, 9, 9, /* intraQ */ - 3, 7, 7, 8, /* inter4 */ - 9, 0, 0, 0, /* Stuffing */ - 11, 13, 13, 13,/* inter4Q*/ -}; - -const uint8_t ff_h263_mbtype_b_tab[15][2] = { - {1, 1}, - {3, 3}, - {1, 5}, - {4, 4}, - {5, 4}, - {6, 6}, - {2, 4}, - {3, 4}, - {7, 6}, - {4, 6}, - {5, 6}, - {1, 6}, - {1,10}, - {1, 7}, - {1, 8}, -}; - -const uint8_t ff_cbpc_b_tab[4][2] = { -{0, 1}, -{2, 2}, -{7, 3}, -{6, 3}, -}; - -const uint8_t ff_h263_cbpy_tab[16][2] = -{ - {3,4}, {5,5}, {4,5}, {9,4}, {3,5}, {7,4}, {2,6}, {11,4}, - {2,5}, {3,6}, {5,4}, {10,4}, {4,4}, {8,4}, {6,4}, {3,2} -}; - -const uint8_t ff_mvtab[33][2] = -{ - {1,1}, {1,2}, {1,3}, {1,4}, {3,6}, {5,7}, {4,7}, {3,7}, - {11,9}, {10,9}, {9,9}, {17,10}, {16,10}, {15,10}, {14,10}, {13,10}, - {12,10}, {11,10}, {10,10}, {9,10}, {8,10}, {7,10}, {6,10}, {5,10}, - {4,10}, {7,11}, {6,11}, {5,11}, {4,11}, {3,11}, {2,11}, {3,12}, - {2,12} -}; +extern const uint8_t ff_h263_inter_MCBPC_code[28]; +extern const uint8_t ff_h263_inter_MCBPC_bits[28]; + +extern const uint8_t ff_h263_mbtype_b_tab[15][2]; + +extern const uint8_t ff_cbpc_b_tab[4][2]; +extern const uint8_t ff_h263_cbpy_tab[16][2]; + +extern const uint8_t ff_mvtab[33][2]; /* third non intra table */ -const uint16_t ff_inter_vlc[103][2] = { -{ 0x2, 2 },{ 0xf, 4 },{ 0x15, 6 },{ 0x17, 7 }, -{ 0x1f, 8 },{ 0x25, 9 },{ 0x24, 9 },{ 0x21, 10 }, -{ 0x20, 10 },{ 0x7, 11 },{ 0x6, 11 },{ 0x20, 11 }, -{ 0x6, 3 },{ 0x14, 6 },{ 0x1e, 8 },{ 0xf, 10 }, -{ 0x21, 11 },{ 0x50, 12 },{ 0xe, 4 },{ 0x1d, 8 }, -{ 0xe, 10 },{ 0x51, 12 },{ 0xd, 5 },{ 0x23, 9 }, -{ 0xd, 10 },{ 0xc, 5 },{ 0x22, 9 },{ 0x52, 12 }, -{ 0xb, 5 },{ 0xc, 10 },{ 0x53, 12 },{ 0x13, 6 }, -{ 0xb, 10 },{ 0x54, 12 },{ 0x12, 6 },{ 0xa, 10 }, -{ 0x11, 6 },{ 0x9, 10 },{ 0x10, 6 },{ 0x8, 10 }, -{ 0x16, 7 },{ 0x55, 12 },{ 0x15, 7 },{ 0x14, 7 }, -{ 0x1c, 8 },{ 0x1b, 8 },{ 0x21, 9 },{ 0x20, 9 }, -{ 0x1f, 9 },{ 0x1e, 9 },{ 0x1d, 9 },{ 0x1c, 9 }, -{ 0x1b, 9 },{ 0x1a, 9 },{ 0x22, 11 },{ 0x23, 11 }, -{ 0x56, 12 },{ 0x57, 12 },{ 0x7, 4 },{ 0x19, 9 }, -{ 0x5, 11 },{ 0xf, 6 },{ 0x4, 11 },{ 0xe, 6 }, -{ 0xd, 6 },{ 0xc, 6 },{ 0x13, 7 },{ 0x12, 7 }, -{ 0x11, 7 },{ 0x10, 7 },{ 0x1a, 8 },{ 0x19, 8 }, -{ 0x18, 8 },{ 0x17, 8 },{ 0x16, 8 },{ 0x15, 8 }, -{ 0x14, 8 },{ 0x13, 8 },{ 0x18, 9 },{ 0x17, 9 }, -{ 0x16, 9 },{ 0x15, 9 },{ 0x14, 9 },{ 0x13, 9 }, -{ 0x12, 9 },{ 0x11, 9 },{ 0x7, 10 },{ 0x6, 10 }, -{ 0x5, 10 },{ 0x4, 10 },{ 0x24, 11 },{ 0x25, 11 }, -{ 0x26, 11 },{ 0x27, 11 },{ 0x58, 12 },{ 0x59, 12 }, -{ 0x5a, 12 },{ 0x5b, 12 },{ 0x5c, 12 },{ 0x5d, 12 }, -{ 0x5e, 12 },{ 0x5f, 12 },{ 0x3, 7 }, -}; - -const int8_t ff_inter_level[102] = { - 1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 1, 2, 3, 4, - 5, 6, 1, 2, 3, 4, 1, 2, - 3, 1, 2, 3, 1, 2, 3, 1, - 2, 3, 1, 2, 1, 2, 1, 2, - 1, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 2, 3, 1, 2, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, -}; - -const int8_t ff_inter_run[102] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 2, 2, 2, 2, 3, 3, - 3, 4, 4, 4, 5, 5, 5, 6, - 6, 6, 7, 7, 8, 8, 9, 9, - 10, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 0, 0, 0, 1, 1, 2, - 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, -}; - -RLTable ff_h263_rl_inter = { - 102, - 58, - ff_inter_vlc, - ff_inter_run, - ff_inter_level, -}; - -static const uint16_t intra_vlc_aic[103][2] = { -{ 0x2, 2 }, { 0x6, 3 }, { 0xe, 4 }, { 0xc, 5 }, -{ 0xd, 5 }, { 0x10, 6 }, { 0x11, 6 }, { 0x12, 6 }, -{ 0x16, 7 }, { 0x1b, 8 }, { 0x20, 9 }, { 0x21, 9 }, -{ 0x1a, 9 }, { 0x1b, 9 }, { 0x1c, 9 }, { 0x1d, 9 }, -{ 0x1e, 9 }, { 0x1f, 9 }, { 0x23, 11 }, { 0x22, 11 }, -{ 0x57, 12 }, { 0x56, 12 }, { 0x55, 12 }, { 0x54, 12 }, -{ 0x53, 12 }, { 0xf, 4 }, { 0x14, 6 }, { 0x14, 7 }, -{ 0x1e, 8 }, { 0xf, 10 }, { 0x21, 11 }, { 0x50, 12 }, -{ 0xb, 5 }, { 0x15, 7 }, { 0xe, 10 }, { 0x9, 10 }, -{ 0x15, 6 }, { 0x1d, 8 }, { 0xd, 10 }, { 0x51, 12 }, -{ 0x13, 6 }, { 0x23, 9 }, { 0x7, 11 }, { 0x17, 7 }, -{ 0x22, 9 }, { 0x52, 12 }, { 0x1c, 8 }, { 0xc, 10 }, -{ 0x1f, 8 }, { 0xb, 10 }, { 0x25, 9 }, { 0xa, 10 }, -{ 0x24, 9 }, { 0x6, 11 }, { 0x21, 10 }, { 0x20, 10 }, -{ 0x8, 10 }, { 0x20, 11 }, { 0x7, 4 }, { 0xc, 6 }, -{ 0x10, 7 }, { 0x13, 8 }, { 0x11, 9 }, { 0x12, 9 }, -{ 0x4, 10 }, { 0x27, 11 }, { 0x26, 11 }, { 0x5f, 12 }, -{ 0xf, 6 }, { 0x13, 9 }, { 0x5, 10 }, { 0x25, 11 }, -{ 0xe, 6 }, { 0x14, 9 }, { 0x24, 11 }, { 0xd, 6 }, -{ 0x6, 10 }, { 0x5e, 12 }, { 0x11, 7 }, { 0x7, 10 }, -{ 0x13, 7 }, { 0x5d, 12 }, { 0x12, 7 }, { 0x5c, 12 }, -{ 0x14, 8 }, { 0x5b, 12 }, { 0x15, 8 }, { 0x1a, 8 }, -{ 0x19, 8 }, { 0x18, 8 }, { 0x17, 8 }, { 0x16, 8 }, -{ 0x19, 9 }, { 0x15, 9 }, { 0x16, 9 }, { 0x18, 9 }, -{ 0x17, 9 }, { 0x4, 11 }, { 0x5, 11 }, { 0x58, 12 }, -{ 0x59, 12 }, { 0x5a, 12 }, { 0x3, 7 }, -}; - -static const int8_t intra_run_aic[102] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 3, 3, 3, 3, - 4, 4, 4, 5, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 11, -12, 13, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 1, - 2, 2, 2, 3, 3, 3, 4, 4, - 5, 5, 6, 6, 7, 7, 8, 9, -10, 11, 12, 13, 14, 15, 16, 17, -18, 19, 20, 21, 22, 23, -}; - -static const int8_t intra_level_aic[102] = { - 1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16, -17, 18, 19, 20, 21, 22, 23, 24, -25, 1, 2, 3, 4, 5, 6, 7, - 1, 2, 3, 4, 1, 2, 3, 4, - 1, 2, 3, 1, 2, 3, 1, 2, - 1, 2, 1, 2, 1, 2, 1, 1, - 1, 1, 1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 1, 2, 3, 4, - 1, 2, 3, 1, 2, 3, 1, 2, - 1, 2, 1, 2, 1, 2, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, -}; - -RLTable ff_rl_intra_aic = { - 102, - 58, - intra_vlc_aic, - intra_run_aic, - intra_level_aic, -}; - -const uint16_t ff_h263_format[8][2] = { - { 0, 0 }, - { 128, 96 }, - { 176, 144 }, - { 352, 288 }, - { 704, 576 }, - { 1408, 1152 }, -}; - -const uint8_t ff_aic_dc_scale_table[32]={ -// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 - 0, 2, 4, 6, 8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62 -}; - -const uint8_t ff_modified_quant_tab[2][32]={ -// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 -{ - 0, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9,10,11,12,13,14,15,16,17,18,18,19,20,21,22,23,24,25,26,27,28 -},{ - 0, 2, 3, 4, 5, 6, 7, 8, 9,10,11,13,14,15,16,17,18,19,20,21,22,24,25,26,27,28,29,30,31,31,31,26 -} -}; - -const uint8_t ff_h263_chroma_qscale_table[32]={ -// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 - 0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 9,10,10,11,11,12,12,12,13,13,13,14,14,14,14,14,15,15,15,15,15 -}; - -const uint16_t ff_mba_max[6]={ - 47, 98, 395,1583,6335,9215 -}; - -const uint8_t ff_mba_length[7]={ - 6, 7, 9, 11, 13, 14, 14 -}; - -const AVRational ff_h263_pixel_aspect[16]={ - {0, 1}, - {1, 1}, - {12, 11}, - {10, 11}, - {16, 11}, - {40, 33}, - {0, 1}, - {0, 1}, - {0, 1}, - {0, 1}, - {0, 1}, - {0, 1}, - {0, 1}, - {0, 1}, - {0, 1}, - {0, 1}, -}; +extern const uint16_t ff_inter_vlc[103][2]; + +extern const int8_t ff_inter_level[102]; +extern const int8_t ff_inter_run[102]; + +extern RLTable ff_h263_rl_inter; +extern RLTable ff_rl_intra_aic; +extern uint8_t ff_h263_static_rl_table_store[2][2][2 * MAX_RUN + MAX_LEVEL + 3]; + +extern const uint16_t ff_h263_format[8][2]; + +extern const uint8_t ff_aic_dc_scale_table[32]; + +extern const uint8_t ff_modified_quant_tab[2][32]; + +extern const uint8_t ff_h263_chroma_qscale_table[32]; + +extern const uint16_t ff_mba_max[6]; +extern const uint8_t ff_mba_length[7]; #endif /* AVCODEC_H263DATA_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263dec.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263dec.c 2015-08-03 17:20:02.000000000 +0000 @@ -50,7 +50,7 @@ if (avctx->codec->id == AV_CODEC_ID_MSS2) return AV_PIX_FMT_YUV420P; - if (CONFIG_GRAY && (avctx->flags & CODEC_FLAG_GRAY)) { + if (CONFIG_GRAY && (avctx->flags & AV_CODEC_FLAG_GRAY)) { if (avctx->color_range == AVCOL_RANGE_UNSPECIFIED) avctx->color_range = AVCOL_RANGE_MPEG; return AV_PIX_FMT_GRAY8; @@ -165,7 +165,7 @@ /* We would have to scan through the whole buf to handle the weird * reordering ... */ return buf_size; - } else if (s->avctx->flags & CODEC_FLAG_TRUNCATED) { + } else if (s->avctx->flags & AV_CODEC_FLAG_TRUNCATED) { pos -= s->parse_context.last_index; // padding is not really read so this might be -1 if (pos < 0) @@ -430,7 +430,7 @@ return 0; } - if (s->avctx->flags & CODEC_FLAG_TRUNCATED) { + if (s->avctx->flags & AV_CODEC_FLAG_TRUNCATED) { int next; if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4) { @@ -603,7 +603,7 @@ if (!s->divx_packed && !avctx->hwaccel) ff_thread_finish_setup(avctx); - if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) { + if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)) { ff_vdpau_mpeg4_decode_picture(avctx->priv_data, s->gb.buffer, s->gb.buffer_end - s->gb.buffer); goto frame_end; } @@ -723,6 +723,9 @@ #if CONFIG_H263_VDPAU_HWACCEL || CONFIG_MPEG4_VDPAU_HWACCEL AV_PIX_FMT_VDPAU, #endif +#if CONFIG_H263_VIDEOTOOLBOX_HWACCEL || CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL + AV_PIX_FMT_VIDEOTOOLBOX, +#endif AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }; @@ -736,8 +739,8 @@ .init = ff_h263_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | - CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY, .flush = ff_mpeg_flush, .max_lowres = 3, .pix_fmts = ff_h263_hwaccel_pixfmt_list_420, @@ -752,8 +755,8 @@ .init = ff_h263_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | - CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY, .flush = ff_mpeg_flush, .max_lowres = 3, .pix_fmts = ff_h263_hwaccel_pixfmt_list_420, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263dsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263dsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263dsp.c 2015-06-18 18:54:57.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263dsp.c 2015-06-17 17:20:02.000000000 +0000 @@ -121,4 +121,6 @@ if (ARCH_X86) ff_h263dsp_init_x86(ctx); + if (ARCH_MIPS) + ff_h263dsp_init_mips(ctx); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263dsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263dsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263dsp.h 2015-06-18 18:54:57.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263dsp.h 2015-06-17 17:20:02.000000000 +0000 @@ -30,5 +30,6 @@ void ff_h263dsp_init(H263DSPContext *ctx); void ff_h263dsp_init_x86(H263DSPContext *ctx); +void ff_h263dsp_init_mips(H263DSPContext *ctx); #endif /* AVCODEC_H263DSP_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h263.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h263.h 2015-07-28 17:20:07.000000000 +0000 @@ -24,6 +24,7 @@ #include "libavutil/rational.h" #include "get_bits.h" #include "mpegvideo.h" +#include "h263data.h" #include "rl.h" #if !FF_API_ASPECT_EXTENDED @@ -42,39 +43,10 @@ #define H263_GOB_HEIGHT(h) ((h) <= 400 ? 1 : (h) <= 800 ? 2 : 4) -extern const AVRational ff_h263_pixel_aspect[16]; -extern const uint8_t ff_h263_cbpy_tab[16][2]; - -extern const uint8_t ff_cbpc_b_tab[4][2]; - -extern const uint8_t ff_mvtab[33][2]; - -extern const uint8_t ff_h263_intra_MCBPC_code[9]; -extern const uint8_t ff_h263_intra_MCBPC_bits[9]; - -extern const uint8_t ff_h263_inter_MCBPC_code[28]; -extern const uint8_t ff_h263_inter_MCBPC_bits[28]; -extern const uint8_t ff_h263_mbtype_b_tab[15][2]; - extern VLC ff_h263_intra_MCBPC_vlc; extern VLC ff_h263_inter_MCBPC_vlc; extern VLC ff_h263_cbpy_vlc; -extern const uint16_t ff_inter_vlc[103][2]; -extern const int8_t ff_inter_level[102]; -extern const int8_t ff_inter_run[102]; - -extern RLTable ff_h263_rl_inter; - -extern RLTable ff_rl_intra_aic; - -extern const uint16_t ff_h263_format[8][2]; -extern const uint8_t ff_modified_quant_tab[2][32]; -extern const uint16_t ff_mba_max[6]; -extern const uint8_t ff_mba_length[7]; - -extern uint8_t ff_h263_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3]; - extern const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[]; @@ -144,7 +116,7 @@ } static inline void ff_h263_encode_motion_vector(MpegEncContext * s, int x, int y, int f_code){ - if (s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT) { + if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) { skip_put_bits(&s->pb, h263_get_motion_length(x, f_code) +h263_get_motion_length(y, f_code)); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264.c 2015-07-28 17:20:07.000000000 +0000 @@ -293,7 +293,7 @@ if(i>=length-1){ //no escaped 0 *dst_length= length; *consumed= length+1; //+1 for the header - if(h->avctx->flags2 & CODEC_FLAG2_FAST){ + if(h->avctx->flags2 & AV_CODEC_FLAG2_FAST){ return src; }else{ memcpy(dst, src, length); @@ -324,7 +324,7 @@ dst[di++] = src[si++]; nsc: - memset(dst + di, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(dst + di, 0, AV_INPUT_BUFFER_PADDING_SIZE); *dst_length = di; *consumed = si + 1; // +1 for the header @@ -591,6 +591,9 @@ int i; h->avctx = avctx; + h->backup_width = -1; + h->backup_height = -1; + h->backup_pix_fmt = AV_PIX_FMT_NONE; h->dequant_coeff_pps = -1; h->current_sps_id = -1; h->cur_chroma_format_idc = -1; @@ -866,6 +869,27 @@ } } + if (h->sei_reguserdata_afd_present) { + AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_AFD, + sizeof(uint8_t)); + + if (sd) { + *sd->data = h->active_format_description; + h->sei_reguserdata_afd_present = 0; + } + } + + if (h->a53_caption) { + AVFrameSideData *sd = av_frame_new_side_data(cur->f, + AV_FRAME_DATA_A53_CC, + h->a53_caption_size); + if (sd) + memcpy(sd->data, h->a53_caption, h->a53_caption_size); + av_freep(&h->a53_caption); + h->a53_caption_size = 0; + h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; + } + cur->mmco_reset = h->mmco_reset; h->mmco_reset = 0; @@ -961,8 +985,12 @@ h->next_output_pic->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_SEI); } - if (setup_finished && !h->avctx->hwaccel) + if (setup_finished && !h->avctx->hwaccel) { ff_thread_finish_setup(h->avctx); + + if (h->avctx->active_thread_type & FF_THREAD_FRAME) + h->setup_finished = 1; + } } int ff_pred_weight_table(H264Context *h, H264SliceContext *sl) @@ -1364,7 +1392,7 @@ if(!h->slice_context_count) h->slice_context_count= 1; h->max_contexts = h->slice_context_count; - if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS)) { + if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) { h->current_slice = 0; if (!h->first_field) h->cur_pic_ptr = NULL; @@ -1518,8 +1546,8 @@ // "recovered". if (h->nal_unit_type == NAL_IDR_SLICE) h->frame_recovered |= FRAME_RECOVERED_IDR; - h->frame_recovered |= 3*!!(avctx->flags2 & CODEC_FLAG2_SHOW_ALL); - h->frame_recovered |= 3*!!(avctx->flags & CODEC_FLAG_OUTPUT_CORRUPT); + h->frame_recovered |= 3*!!(avctx->flags2 & AV_CODEC_FLAG2_SHOW_ALL); + h->frame_recovered |= 3*!!(avctx->flags & AV_CODEC_FLAG_OUTPUT_CORRUPT); #if 1 h->cur_pic_ptr->recovered |= h->frame_recovered; #else @@ -1527,14 +1555,14 @@ #endif if (h->current_slice == 1) { - if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS)) + if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) decode_postinit(h, nal_index >= nals_needed); if (h->avctx->hwaccel && (ret = h->avctx->hwaccel->start_frame(h->avctx, buf, buf_size)) < 0) goto end; if (CONFIG_H264_VDPAU_DECODER && - h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) + h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) ff_vdpau_h264_picture_start(h); } @@ -1546,7 +1574,7 @@ if (ret < 0) goto end; } else if (CONFIG_H264_VDPAU_DECODER && - h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) { + h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) { ff_vdpau_add_data_chunk(h->cur_pic_ptr->f->data[0], start_code, sizeof(start_code)); @@ -1675,6 +1703,14 @@ av_dict_set(&dst->metadata, "stereo_mode", ff_h264_sei_stereo_mode(h), 0); + h->backup_width = h->avctx->width; + h->backup_height = h->avctx->height; + h->backup_pix_fmt = h->avctx->pix_fmt; + + h->avctx->width = dst->width; + h->avctx->height = dst->height; + h->avctx->pix_fmt = dst->format; + if (srcp->sei_recovery_frame_cnt == 0) dst->key_frame = 1; if (!srcp->crop) @@ -1725,6 +1761,20 @@ int ret; h->flags = avctx->flags; + h->setup_finished = 0; + + if (h->backup_width != -1) { + avctx->width = h->backup_width; + h->backup_width = -1; + } + if (h->backup_height != -1) { + avctx->height = h->backup_height; + h->backup_height = -1; + } + if (h->backup_pix_fmt != AV_PIX_FMT_NONE) { + avctx->pix_fmt = h->backup_pix_fmt; + h->backup_pix_fmt = AV_PIX_FMT_NONE; + } ff_h264_unref_picture(h, &h->last_pic_for_ec); @@ -1781,7 +1831,7 @@ goto out; } - if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) { + if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) { if (avctx->skip_frame >= AVDISCARD_NONREF || buf_size >= 4 && !memcmp("Q264", buf, 4)) return buf_size; @@ -1789,9 +1839,9 @@ return AVERROR_INVALIDDATA; } - if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS) || + if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) || (h->mb_y >= h->mb_height && h->mb_height)) { - if (avctx->flags2 & CODEC_FLAG2_CHUNKS) + if (avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) decode_postinit(h, 1); ff_h264_field_end(h, &h->slice_ctx[0], 0); @@ -1931,9 +1981,9 @@ .init = ff_h264_decode_init, .close = h264_decode_end, .decode = h264_decode_frame, - .capabilities = /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | - CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS | - CODEC_CAP_FRAME_THREADS, + .capabilities = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_FRAME_THREADS, .flush = flush_dpb, .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context), @@ -1958,7 +2008,7 @@ .init = ff_h264_decode_init, .close = h264_decode_end, .decode = h264_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HWACCEL_VDPAU, .flush = flush_dpb, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_VDPAU_H264, AV_PIX_FMT_NONE}, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264dsp_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264dsp_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264dsp_template.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264dsp_template.c 2015-07-02 17:20:03.000000000 +0000 @@ -110,7 +110,7 @@ alpha <<= BIT_DEPTH - 8; beta <<= BIT_DEPTH - 8; for( i = 0; i < 4; i++ ) { - const int tc_orig = tc0[i] << (BIT_DEPTH - 8); + const int tc_orig = tc0[i] * (1 << (BIT_DEPTH - 8)); if( tc_orig < 0 ) { pix += inner_iters*ystride; continue; @@ -141,7 +141,7 @@ tc++; } - i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); + i_delta = av_clip( (((q0 - p0 ) * 4) + (p1 - q1) + 4) >> 3, -tc, tc ); pix[-xstride] = av_clip_pixel( p0 + i_delta ); /* p0' */ pix[0] = av_clip_pixel( q0 - i_delta ); /* q0' */ } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264.h 2015-07-17 17:20:02.000000000 +0000 @@ -132,11 +132,12 @@ typedef enum { SEI_TYPE_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1) SEI_TYPE_PIC_TIMING = 1, ///< picture timing - SEI_TYPE_USER_DATA_ITU_T_T35 = 4, ///< user data registered by ITU-T Recommendation T.35 + SEI_TYPE_USER_DATA_REGISTERED = 4, ///< registered user data as specified by Rec. ITU-T T.35 SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data SEI_TYPE_RECOVERY_POINT = 6, ///< recovery point (frame # to decoder sync) SEI_TYPE_FRAME_PACKING = 45, ///< frame packing arrangement SEI_TYPE_DISPLAY_ORIENTATION = 47, ///< display orientation + SEI_TYPE_GREEN_METADATA = 56 ///< GreenMPEG information } SEI_Type; /** @@ -268,6 +269,22 @@ } FPA; /** + * Green MetaData Information Type + */ +typedef struct GreenMetaData { + uint8_t green_metadata_type; + uint8_t period_type; + uint16_t num_seconds; + uint16_t num_pictures; + uint8_t percent_non_zero_macroblocks; + uint8_t percent_intra_coded_macroblocks; + uint8_t percent_six_tap_filtering; + uint8_t percent_alpha_point_deblocking_instance; + uint8_t xsd_metric_type; + uint16_t xsd_metric_value; +} GreenMetaData; + +/** * Memory management control operation opcode. */ typedef enum MMCOOpcode { @@ -409,7 +426,8 @@ int mb_xy; int resync_mb_x; int resync_mb_y; - int mb_index_end; + // index of the first MB of the next slice + int next_slice_idx; int mb_skip_run; int is_complex; @@ -519,6 +537,14 @@ int width, height; int chroma_x_shift, chroma_y_shift; + /** + * Backup frame properties: needed, because they can be different + * between returned frame and last decoded frame. + **/ + int backup_width; + int backup_height; + enum AVPixelFormat backup_pix_fmt; + int droppable; int coded_picture_number; int low_delay; @@ -716,6 +742,14 @@ int sei_hflip, sei_vflip; /** + * User data registered by Rec. ITU-T T.35 SEI + */ + int sei_reguserdata_afd_present; + uint8_t active_format_description; + int a53_caption_size; + uint8_t *a53_caption; + + /** * Bit set of clock types for fields/frames in picture timing SEI message. * For each found ct_type, appropriate bit is set (e.g., bit 1 for * interlaced). @@ -773,6 +807,11 @@ int missing_fields; +/* for frame threading, this is set to 1 + * after finish_setup() has been called, so we cannot modify + * some context properties (which are supposed to stay constant between + * slices) anymore */ + int setup_finished; // Timestamp stuff int sei_buffering_period_present; ///< Buffering period SEI flag @@ -796,6 +835,10 @@ /* Motion Estimation */ qpel_mc_func (*qpel_put)[16]; qpel_mc_func (*qpel_avg)[16]; + + /*Green Metadata */ + GreenMetaData sei_green_metadata; + } H264Context; extern const uint8_t ff_h264_chroma_qp[7][QP_MAX_NUM + 1]; ///< One chroma qp table for each possible bit depth (8-14). diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_loopfilter.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_loopfilter.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_loopfilter.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_loopfilter.c 2015-07-28 17:20:07.000000000 +0000 @@ -242,7 +242,7 @@ unsigned int uvlinesize, int pixel_shift) { - int chroma = CHROMA(h) && !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY)); + int chroma = CHROMA(h) && !(CONFIG_GRAY && (h->flags & AV_CODEC_FLAG_GRAY)); int chroma444 = CHROMA444(h); int chroma422 = CHROMA422(h); @@ -723,7 +723,7 @@ const int mb_type = h->cur_pic.mb_type[mb_xy]; const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4; int first_vertical_edge_done = 0; - int chroma = CHROMA(h) && !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY)); + int chroma = CHROMA(h) && !(CONFIG_GRAY && (h->flags & AV_CODEC_FLAG_GRAY)); int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); int a = 52 + sl->slice_alpha_c0_offset - qp_bd_offset; int b = 52 + sl->slice_beta_offset - qp_bd_offset; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_mb.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_mb.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_mb.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_mb.c 2015-07-28 17:20:07.000000000 +0000 @@ -250,7 +250,7 @@ if (!square) qpix_op[luma_xy](dest_y + delta, src_y + delta, sl->mb_linesize); - if (CONFIG_GRAY && h->flags & CODEC_FLAG_GRAY) + if (CONFIG_GRAY && h->flags & AV_CODEC_FLAG_GRAY) return; if (chroma_idc == 3 /* yuv444 */) { @@ -425,7 +425,7 @@ int weight1 = 64 - weight0; luma_weight_avg(dest_y, tmp_y, sl->mb_linesize, height, 5, weight0, weight1, 0); - if (!CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) { chroma_weight_avg(dest_cb, tmp_cb, sl->mb_uvlinesize, chroma_height, 5, weight0, weight1, 0); chroma_weight_avg(dest_cr, tmp_cr, sl->mb_uvlinesize, @@ -438,7 +438,7 @@ sl->luma_weight[refn1][1][0], sl->luma_weight[refn0][0][1] + sl->luma_weight[refn1][1][1]); - if (!CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) { chroma_weight_avg(dest_cb, tmp_cb, sl->mb_uvlinesize, chroma_height, sl->chroma_log2_weight_denom, sl->chroma_weight[refn0][0][0][0], @@ -465,7 +465,7 @@ sl->luma_log2_weight_denom, sl->luma_weight[refn][list][0], sl->luma_weight[refn][list][1]); - if (!CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) { if (sl->use_weight_chroma) { chroma_weight_op(dest_cb, sl->mb_uvlinesize, chroma_height, sl->chroma_log2_weight_denom, @@ -566,7 +566,7 @@ XCHG(sl->top_borders[top_idx][sl->mb_x + 1], src_y + (17 << pixel_shift), 1); } - if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { + if (simple || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) { if (chroma444) { if (deblock_topleft) { XCHG(top_border_m1 + (24 << pixel_shift), src_cb - (7 << pixel_shift), 1); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_mb_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_mb_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_mb_template.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_mb_template.c 2015-07-28 17:20:07.000000000 +0000 @@ -112,7 +112,7 @@ for (j = 0; j < 16; j++) tmp_y[j] = get_bits(&gb, bit_depth); } - if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { + if (SIMPLE || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) { if (!h->sps.chroma_format_idc) { for (i = 0; i < block_h; i++) { uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize); @@ -137,7 +137,7 @@ } else { for (i = 0; i < 16; i++) memcpy(dest_y + i * linesize, sl->intra_pcm_ptr + i * 16, 16); - if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { + if (SIMPLE || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) { if (!h->sps.chroma_format_idc) { for (i = 0; i < 8; i++) { memset(dest_cb + i * uvlinesize, 1 << (bit_depth - 1), 8); @@ -159,7 +159,7 @@ xchg_mb_border(h, sl, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1, 0, SIMPLE, PIXEL_SHIFT); - if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { + if (SIMPLE || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) { h->hpc.pred8x8[sl->chroma_pred_mode](dest_cb, uvlinesize); h->hpc.pred8x8[sl->chroma_pred_mode](dest_cr, uvlinesize); } @@ -190,7 +190,7 @@ hl_decode_mb_idct_luma(h, sl, mb_type, is_h264, SIMPLE, transform_bypass, PIXEL_SHIFT, block_offset, linesize, dest_y, 0); - if ((SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) && + if ((SIMPLE || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) && (sl->cbp & 0x30)) { uint8_t *dest[2] = { dest_cb, dest_cr }; if (transform_bypass) { @@ -280,7 +280,7 @@ int i, j, p; const int *block_offset = &h->block_offset[0]; const int transform_bypass = !SIMPLE && (sl->qscale == 0 && h->sps.transform_bypass); - const int plane_count = (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) ? 3 : 1; + const int plane_count = (SIMPLE || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) ? 3 : 1; for (p = 0; p < plane_count; p++) { dest[p] = h->cur_pic.f->data[p] + diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_mp4toannexb_bsf.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_mp4toannexb_bsf.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_mp4toannexb_bsf.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_mp4toannexb_bsf.c 2015-07-28 17:20:07.000000000 +0000 @@ -33,6 +33,18 @@ uint8_t idr_sps_seen; uint8_t idr_pps_seen; int extradata_parsed; + + /* When private_spspps is zero then spspps_buf points to global extradata + and bsf does replace a global extradata to own-allocated version (default + behaviour). + When private_spspps is non-zero the bsf uses a private version of spspps buf. + This mode necessary when bsf uses in decoder, else bsf has issues after + decoder re-initialization. Use the "private_spspps_buf" argument to + activate this mode. + */ + int private_spspps; + uint8_t *spspps_buf; + uint32_t spspps_size; } H264BSFContext; static int alloc_and_copy(uint8_t **poutbuf, int *poutbuf_size, @@ -45,7 +57,7 @@ *poutbuf_size += sps_pps_size + in_size + nal_header_size; if ((err = av_reallocp(poutbuf, - *poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE)) < 0) { + *poutbuf_size + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) { *poutbuf_size = 0; return err; } @@ -129,9 +141,13 @@ "Warning: PPS NALU missing or invalid. " "The resulting stream may not play.\n"); - av_free(avctx->extradata); - avctx->extradata = out; - avctx->extradata_size = total_size; + if (!ctx->private_spspps) { + av_free(avctx->extradata); + avctx->extradata = out; + avctx->extradata_size = total_size; + } + ctx->spspps_buf = out; + ctx->spspps_size = total_size; return length_size; } @@ -159,7 +175,10 @@ /* retrieve sps and pps NAL units from extradata */ if (!ctx->extradata_parsed) { - ret = h264_extradata_to_annexb(ctx, avctx, FF_INPUT_BUFFER_PADDING_SIZE); + if (args && strstr(args, "private_spspps_buf")) + ctx->private_spspps = 1; + + ret = h264_extradata_to_annexb(ctx, avctx, AV_INPUT_BUFFER_PADDING_SIZE); if (ret < 0) return ret; ctx->length_size = ret; @@ -195,8 +214,8 @@ av_log(avctx, AV_LOG_WARNING, "SPS not present in the stream, nor in AVCC, stream may be unreadable\n"); else { if ((ret = alloc_and_copy(poutbuf, poutbuf_size, - avctx->extradata + ctx->sps_offset, - ctx->pps_offset != -1 ? ctx->pps_offset : avctx->extradata_size - ctx->sps_offset, + ctx->spspps_buf + ctx->sps_offset, + ctx->pps_offset != -1 ? ctx->pps_offset : ctx->spspps_size - ctx->sps_offset, buf, nal_size)) < 0) goto fail; ctx->idr_sps_seen = 1; @@ -214,7 +233,7 @@ /* prepend only to the first type 5 NAL unit of an IDR picture, if no sps/pps are already present */ if (ctx->new_idr && unit_type == 5 && !ctx->idr_sps_seen && !ctx->idr_pps_seen) { if ((ret=alloc_and_copy(poutbuf, poutbuf_size, - avctx->extradata, avctx->extradata_size, + ctx->spspps_buf, ctx->spspps_size, buf, nal_size)) < 0) goto fail; ctx->new_idr = 0; @@ -226,7 +245,7 @@ NULL, 0, buf, nal_size)) < 0) goto fail; } else if ((ret = alloc_and_copy(poutbuf, poutbuf_size, - avctx->extradata + ctx->pps_offset, avctx->extradata_size - ctx->pps_offset, + ctx->spspps_buf + ctx->pps_offset, ctx->spspps_size - ctx->pps_offset, buf, nal_size)) < 0) goto fail; } else { @@ -253,8 +272,16 @@ return ret; } +static void h264_mp4toannexb_filter_close(AVBitStreamFilterContext *bsfc) +{ + H264BSFContext *ctx = bsfc->priv_data; + if (ctx->private_spspps) + av_free(ctx->spspps_buf); +} + AVBitStreamFilter ff_h264_mp4toannexb_bsf = { .name = "h264_mp4toannexb", .priv_data_size = sizeof(H264BSFContext), .filter = h264_mp4toannexb_filter, + .close = h264_mp4toannexb_filter_close, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_mvpred.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_mvpred.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_mvpred.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_mvpred.h 2015-07-01 17:20:03.000000000 +0000 @@ -771,7 +771,7 @@ #define MAP_F2F(idx, mb_type) \ if (!IS_INTERLACED(mb_type) && sl->ref_cache[list][idx] >= 0) { \ - sl->ref_cache[list][idx] <<= 1; \ + sl->ref_cache[list][idx] *= 2; \ sl->mv_cache[list][idx][1] /= 2; \ sl->mvd_cache[list][idx][1] >>= 1; \ } @@ -783,7 +783,7 @@ #define MAP_F2F(idx, mb_type) \ if (IS_INTERLACED(mb_type) && sl->ref_cache[list][idx] >= 0) { \ sl->ref_cache[list][idx] >>= 1; \ - sl->mv_cache[list][idx][1] <<= 1; \ + sl->mv_cache[list][idx][1] *= 2; \ sl->mvd_cache[list][idx][1] <<= 1; \ } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_picture.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_picture.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_picture.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_picture.c 2015-07-28 17:20:07.000000000 +0000 @@ -158,7 +158,7 @@ h->mb_y = 0; if (CONFIG_H264_VDPAU_DECODER && - h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) + h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) ff_vdpau_h264_set_reference_frames(h); if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) { @@ -178,7 +178,7 @@ } if (CONFIG_H264_VDPAU_DECODER && - h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) + h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) ff_vdpau_h264_picture_complete(h); #if CONFIG_ERROR_RESILIENCE diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264pred.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264pred.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264pred.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264pred.c 2015-07-21 17:20:03.000000000 +0000 @@ -592,6 +592,12 @@ break; } - if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc); - if (ARCH_X86) ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc); + if (ARCH_AARCH64) + ff_h264_pred_init_aarch64(h, codec_id, bit_depth, chroma_format_idc); + if (ARCH_ARM) + ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc); + if (ARCH_X86) + ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc); + if (ARCH_MIPS) + ff_h264_pred_init_mips(h, codec_id, bit_depth, chroma_format_idc); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264pred.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264pred.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264pred.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264pred.h 2015-07-21 17:20:03.000000000 +0000 @@ -113,9 +113,14 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); +void ff_h264_pred_init_aarch64(H264PredContext *h, int codec_id, + const int bit_depth, + const int chroma_format_idc); void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); +void ff_h264_pred_init_mips(H264PredContext *h, int codec_id, + const int bit_depth, const int chroma_format_idc); #endif /* AVCODEC_H264PRED_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_ps.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_ps.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_ps.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_ps.c 2015-07-28 17:20:07.000000000 +0000 @@ -464,7 +464,7 @@ int width = 16 * sps->mb_width; int height = 16 * sps->mb_height * (2 - sps->frame_mbs_only_flag); - if (h->avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) { + if (h->avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) { av_log(h->avctx, AV_LOG_DEBUG, "discarding sps cropping, original " "values are l:%d r:%d t:%d b:%d\n", crop_left, crop_right, crop_top, crop_bottom); @@ -481,7 +481,7 @@ int step_y = (2 - sps->frame_mbs_only_flag) << vsub; if (crop_left & (0x1F >> (sps->bit_depth_luma > 8)) && - !(h->avctx->flags & CODEC_FLAG_UNALIGNED)) { + !(h->avctx->flags & AV_CODEC_FLAG_UNALIGNED)) { crop_left &= ~(0x1F >> (sps->bit_depth_luma > 8)); av_log(h->avctx, AV_LOG_WARNING, "Reducing left cropping to %d " diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264qpel.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264qpel.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264qpel.c 2015-06-18 18:54:58.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264qpel.c 2015-06-13 17:20:02.000000000 +0000 @@ -104,4 +104,6 @@ ff_h264qpel_init_ppc(c, bit_depth); if (ARCH_X86) ff_h264qpel_init_x86(c, bit_depth); + if (ARCH_MIPS) + ff_h264qpel_init_mips(c, bit_depth); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264qpel.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264qpel.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264qpel.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264qpel.h 2015-06-13 17:20:02.000000000 +0000 @@ -35,5 +35,6 @@ void ff_h264qpel_init_arm(H264QpelContext *c, int bit_depth); void ff_h264qpel_init_ppc(H264QpelContext *c, int bit_depth); void ff_h264qpel_init_x86(H264QpelContext *c, int bit_depth); +void ff_h264qpel_init_mips(H264QpelContext *c, int bit_depth); #endif /* AVCODEC_H264QPEL_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_refs.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_refs.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_refs.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_refs.c 2015-07-29 17:20:04.000000000 +0000 @@ -125,6 +125,7 @@ int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl) { int i, len; + int j; if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { H264Picture *sorted[32]; @@ -188,6 +189,21 @@ } } #endif + + for (j = 0; j<1+(sl->slice_type_nos == AV_PICTURE_TYPE_B); j++) { + for (i = 0; i < sl->ref_count[j]; i++) { + if (h->default_ref_list[j][i].parent) { + AVFrame *f = h->default_ref_list[j][i].parent->f; + if (h->cur_pic_ptr->f->width != f->width || + h->cur_pic_ptr->f->height != f->height || + h->cur_pic_ptr->f->format != f->format) { + av_log(h->avctx, AV_LOG_ERROR, "Discarding mismatching reference\n"); + memset(&h->default_ref_list[j][i], 0, sizeof(h->default_ref_list[j][i])); + } + } + } + } + return 0; } @@ -601,6 +617,7 @@ { int i, av_uninit(j); int pps_count; + int pps_ref_count[2] = {0}; int current_ref_assigned = 0, err = 0; H264Picture *av_uninit(pic); @@ -667,15 +684,18 @@ remove_short_at_index(h, 0); } - if (h->long_ref[mmco[i].long_arg] != h->cur_pic_ptr) { - if (h->cur_pic_ptr->long_ref) { - for(j=0; j<16; j++) { - if(h->long_ref[j] == h->cur_pic_ptr) { - remove_long(h, j, 0); + /* make sure the current picture is not already assigned as a long ref */ + if (h->cur_pic_ptr->long_ref) { + for (j = 0; j < FF_ARRAY_ELEMS(h->long_ref); j++) { + if (h->long_ref[j] == h->cur_pic_ptr) { + if (j != mmco[i].long_arg) av_log(h->avctx, AV_LOG_ERROR, "mmco: cannot assign current picture to 2 long term references\n"); - } + remove_long(h, j, 0); } } + } + + if (h->long_ref[mmco[i].long_arg] != h->cur_pic_ptr) { av_assert0(!h->cur_pic_ptr->long_ref); remove_long(h, mmco[i].long_arg, 0); @@ -782,13 +802,17 @@ print_long_term(h); pps_count = 0; - for (i = 0; i < FF_ARRAY_ELEMS(h->pps_buffers); i++) + for (i = 0; i < FF_ARRAY_ELEMS(h->pps_buffers); i++) { pps_count += !!h->pps_buffers[i]; + pps_ref_count[0] = FFMAX(pps_ref_count[0], h->pps.ref_count[0]); + pps_ref_count[1] = FFMAX(pps_ref_count[1], h->pps.ref_count[1]); + } if ( err >= 0 && h->long_ref_count==0 - && (h->short_ref_count<=2 || h->pps.ref_count[0] <= 1 && h->pps.ref_count[1] <= 1 && pps_count == 1) - && h->pps.ref_count[0]<=2 + (h->picture_structure != PICT_FRAME) + (2*!h->has_recovery_point) + && ( h->short_ref_count<=2 + || pps_ref_count[0] <= 1 + (h->picture_structure != PICT_FRAME) && pps_ref_count[1] <= 1) + && pps_ref_count[0]<=2 + (h->picture_structure != PICT_FRAME) + (2*!h->has_recovery_point) && h->cur_pic_ptr->f->pict_type == AV_PICTURE_TYPE_I){ h->cur_pic_ptr->recovered |= 1; if(!h->avctx->has_b_frames) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_sei.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_sei.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_sei.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_sei.c 2015-08-02 17:20:02.000000000 +0000 @@ -42,6 +42,10 @@ h->sei_buffering_period_present = 0; h->sei_frame_packing_present = 0; h->sei_display_orientation_present = 0; + h->sei_reguserdata_afd_present = 0; + + h->a53_caption_size = 0; + av_freep(&h->a53_caption); } static int decode_picture_timing(H264Context *h) @@ -108,35 +112,104 @@ return 0; } -static int decode_user_data_itu_t_t35(H264Context *h, int size) +static int decode_registered_user_data_afd(H264Context *h, int size) +{ + int flag; + + if (size-- < 1) + return AVERROR_INVALIDDATA; + skip_bits(&h->gb, 1); // 0 + flag = get_bits(&h->gb, 1); // active_format_flag + skip_bits(&h->gb, 6); // reserved + + if (flag) { + if (size-- < 1) + return AVERROR_INVALIDDATA; + skip_bits(&h->gb, 4); // reserved + h->active_format_description = get_bits(&h->gb, 4); + h->sei_reguserdata_afd_present = 1; +#if FF_API_AFD +FF_DISABLE_DEPRECATION_WARNINGS + h->avctx->dtg_active_format = h->active_format_description; +FF_ENABLE_DEPRECATION_WARNINGS +#endif /* FF_API_AFD */ + } + + return 0; +} + +static int decode_registered_user_data_closed_caption(H264Context *h, int size) +{ + int flag; + int user_data_type_code; + int cc_count; + + if (size < 3) + return AVERROR(EINVAL); + + user_data_type_code = get_bits(&h->gb, 8); + if (user_data_type_code == 0x3) { + skip_bits(&h->gb, 1); // reserved + + flag = get_bits(&h->gb, 1); // process_cc_data_flag + if (flag) { + skip_bits(&h->gb, 1); // zero bit + cc_count = get_bits(&h->gb, 5); + skip_bits(&h->gb, 8); // reserved + size -= 2; + + if (cc_count && size >= cc_count * 3) { + const uint64_t new_size = (h->a53_caption_size + cc_count + * UINT64_C(3)); + int i, ret; + + if (new_size > INT_MAX) + return AVERROR(EINVAL); + + /* Allow merging of the cc data from two fields. */ + ret = av_reallocp(&h->a53_caption, new_size); + if (ret < 0) + return ret; + + for (i = 0; i < cc_count; i++) { + h->a53_caption[h->a53_caption_size++] = get_bits(&h->gb, 8); + h->a53_caption[h->a53_caption_size++] = get_bits(&h->gb, 8); + h->a53_caption[h->a53_caption_size++] = get_bits(&h->gb, 8); + } + + skip_bits(&h->gb, 8); // marker_bits + } + } + } + + return 0; +} + +static int decode_registered_user_data(H264Context *h, int size) { + uint32_t country_code; uint32_t user_identifier; - int dtg_active_format; if (size < 7) - return -1; + return AVERROR_INVALIDDATA; size -= 7; - skip_bits(&h->gb, 8); // country_code - skip_bits(&h->gb, 16); // provider_code + country_code = get_bits(&h->gb, 8); // itu_t_t35_country_code + if (country_code == 0xFF) { + skip_bits(&h->gb, 8); // itu_t_t35_country_code_extension_byte + size--; + } + + /* itu_t_t35_payload_byte follows */ + skip_bits(&h->gb, 8); // terminal provider code + skip_bits(&h->gb, 8); // terminal provider oriented code user_identifier = get_bits_long(&h->gb, 32); switch (user_identifier) { - case 0x44544731: // "DTG1" - AFD_data - if (size < 1) - return -1; - skip_bits(&h->gb, 1); - if (get_bits(&h->gb, 1)) { - skip_bits(&h->gb, 6); - if (size < 2) - return -1; - skip_bits(&h->gb, 4); - dtg_active_format = get_bits(&h->gb, 4); - h->avctx->dtg_active_format = dtg_active_format; - } else { - skip_bits(&h->gb, 6); - } - break; + case MKBETAG('D', 'T', 'G', '1'): // afd_data + return decode_registered_user_data_afd(h, size); + case MKBETAG('G', 'A', '9', '4'): // closed captions + return decode_registered_user_data_closed_caption(h, size); default: skip_bits(&h->gb, size * 8); break; @@ -279,6 +352,66 @@ return 0; } +static int decode_GreenMetadata(H264Context *h) +{ + if (h->avctx->debug & FF_DEBUG_GREEN_MD) + av_log(h->avctx, AV_LOG_DEBUG, "Green Metadata Info SEI message\n"); + + h->sei_green_metadata.green_metadata_type=get_bits(&h->gb, 8); + + if (h->avctx->debug & FF_DEBUG_GREEN_MD) + av_log(h->avctx, AV_LOG_DEBUG, "green_metadata_type = %d\n", + h->sei_green_metadata.green_metadata_type); + + if (h->sei_green_metadata.green_metadata_type==0){ + h->sei_green_metadata.period_type=get_bits(&h->gb, 8); + + if (h->avctx->debug & FF_DEBUG_GREEN_MD) + av_log(h->avctx, AV_LOG_DEBUG, "green_metadata_period_type = %d\n", + h->sei_green_metadata.period_type); + + if (h->sei_green_metadata.green_metadata_type==2){ + h->sei_green_metadata.num_seconds = get_bits(&h->gb, 16); + if (h->avctx->debug & FF_DEBUG_GREEN_MD) + av_log(h->avctx, AV_LOG_DEBUG, "green_metadata_num_seconds = %d\n", + h->sei_green_metadata.num_seconds); + } + else if (h->sei_green_metadata.period_type==3){ + h->sei_green_metadata.num_pictures = get_bits(&h->gb, 16); + if (h->avctx->debug & FF_DEBUG_GREEN_MD) + av_log(h->avctx, AV_LOG_DEBUG, "green_metadata_num_pictures = %d\n", + h->sei_green_metadata.num_pictures); + } + + h->sei_green_metadata.percent_non_zero_macroblocks=get_bits(&h->gb, 8); + h->sei_green_metadata.percent_intra_coded_macroblocks=get_bits(&h->gb, 8); + h->sei_green_metadata.percent_six_tap_filtering=get_bits(&h->gb, 8); + h->sei_green_metadata.percent_alpha_point_deblocking_instance=get_bits(&h->gb, 8); + + if (h->avctx->debug & FF_DEBUG_GREEN_MD) + av_log(h->avctx, AV_LOG_DEBUG, "SEI GREEN Complexity Metrics = %f %f %f %f\n", + (float)h->sei_green_metadata.percent_non_zero_macroblocks/255, + (float)h->sei_green_metadata.percent_intra_coded_macroblocks/255, + (float)h->sei_green_metadata.percent_six_tap_filtering/255, + (float)h->sei_green_metadata.percent_alpha_point_deblocking_instance/255); + + }else if( h->sei_green_metadata.green_metadata_type==1){ + h->sei_green_metadata.xsd_metric_type=get_bits(&h->gb, 8); + h->sei_green_metadata.xsd_metric_value=get_bits(&h->gb, 16); + + if (h->avctx->debug & FF_DEBUG_GREEN_MD) + av_log(h->avctx, AV_LOG_DEBUG, "xsd_metric_type = %d\n", + h->sei_green_metadata.xsd_metric_type); + if ( h->sei_green_metadata.xsd_metric_type==0){ + if (h->avctx->debug & FF_DEBUG_GREEN_MD) + av_log(h->avctx, AV_LOG_DEBUG, "xsd_metric_value = %f\n", + (float)h->sei_green_metadata.xsd_metric_value/100); + } + } + + return 0; +} + int ff_h264_decode_sei(H264Context *h) { while (get_bits_left(&h->gb) > 16 && show_bits(&h->gb, 16)) { @@ -312,41 +445,34 @@ switch (type) { case SEI_TYPE_PIC_TIMING: // Picture timing SEI ret = decode_picture_timing(h); - if (ret < 0) - return ret; break; - case SEI_TYPE_USER_DATA_ITU_T_T35: - if (decode_user_data_itu_t_t35(h, size) < 0) - return -1; + case SEI_TYPE_USER_DATA_REGISTERED: + ret = decode_registered_user_data(h, size); break; case SEI_TYPE_USER_DATA_UNREGISTERED: ret = decode_unregistered_user_data(h, size); - if (ret < 0) - return ret; break; case SEI_TYPE_RECOVERY_POINT: ret = decode_recovery_point(h); - if (ret < 0) - return ret; break; case SEI_TYPE_BUFFERING_PERIOD: ret = decode_buffering_period(h); - if (ret < 0) - return ret; break; case SEI_TYPE_FRAME_PACKING: ret = decode_frame_packing_arrangement(h); - if (ret < 0) - return ret; break; case SEI_TYPE_DISPLAY_ORIENTATION: ret = decode_display_orientation(h); - if (ret < 0) - return ret; + break; + case SEI_TYPE_GREEN_METADATA: + ret = decode_GreenMetadata(h); break; default: av_log(h->avctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type); } + if (ret < 0) + return ret; + skip_bits_long(&h->gb, next - get_bits_count(&h->gb)); // FIXME check bits here diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_slice.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_slice.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/h264_slice.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/h264_slice.c 2015-08-03 17:20:02.000000000 +0000 @@ -246,7 +246,7 @@ pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data; } } - if (CONFIG_GRAY && !h->avctx->hwaccel && h->flags & CODEC_FLAG_GRAY && pic->f->data[2]) { + if (CONFIG_GRAY && !h->avctx->hwaccel && h->flags & AV_CODEC_FLAG_GRAY && pic->f->data[2]) { int h_chroma_shift, v_chroma_shift; av_pix_fmt_get_chroma_sub_sample(pic->f->format, &h_chroma_shift, &v_chroma_shift); @@ -383,7 +383,7 @@ } } -#define IN_RANGE(a, b, size) (((a) >= (b)) && ((a) < ((b) + (size)))) +#define IN_RANGE(a, b, size) (((void*)(a) >= (void*)(b)) && ((void*)(a) < (void*)((b) + (size)))) #define REBASE_PICTURE(pic, new_ctx, old_ctx) \ (((pic) && (pic) >= (old_ctx)->DPB && \ @@ -397,10 +397,9 @@ int i; for (i = 0; i < count; i++) { - av_assert1((IN_RANGE(from[i], old_base, 1) || - IN_RANGE(from[i], old_base->DPB, - H264_MAX_PICTURE_COUNT) || - !from[i])); + av_assert1(!from[i] || + IN_RANGE(from[i], old_base, 1) || + IN_RANGE(from[i], old_base->DPB, H264_MAX_PICTURE_COUNT)); to[i] = REBASE_PICTURE(from[i], new_base, old_base); } } @@ -497,6 +496,9 @@ h->picture_structure = h1->picture_structure; h->droppable = h1->droppable; h->low_delay = h1->low_delay; + h->backup_width = h1->backup_width; + h->backup_height = h1->backup_height; + h->backup_pix_fmt = h1->backup_pix_fmt; for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) { ff_h264_unref_picture(h, &h->DPB[i]); @@ -611,7 +613,7 @@ if ((ret = alloc_picture(h, pic)) < 0) return ret; if(!h->frame_recovered && !h->avctx->hwaccel && - !(h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) + !(h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU)) avpriv_color_frame(pic->f, c); h->cur_pic_ptr = pic; @@ -683,7 +685,7 @@ AV_COPY128(top_border, src_y + 15 * linesize); if (pixel_shift) AV_COPY128(top_border + 16, src_y + 15 * linesize + 16); - if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { + if (simple || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) { if (chroma444) { if (pixel_shift) { AV_COPY128(top_border + 32, src_cb + 15 * uvlinesize); @@ -726,7 +728,7 @@ if (pixel_shift) AV_COPY128(top_border + 16, src_y + 16 * linesize + 16); - if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { + if (simple || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) { if (chroma444) { if (pixel_shift) { AV_COPY128(top_border + 32, src_cb + 16 * linesize); @@ -866,6 +868,7 @@ CONFIG_H264_D3D11VA_HWACCEL + \ CONFIG_H264_VAAPI_HWACCEL + \ (CONFIG_H264_VDA_HWACCEL * 2) + \ + CONFIG_H264_VIDEOTOOLBOX_HWACCEL + \ CONFIG_H264_VDPAU_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; const enum AVPixelFormat *choices = pix_fmts; @@ -946,6 +949,9 @@ *fmt++ = AV_PIX_FMT_VDA_VLD; *fmt++ = AV_PIX_FMT_VDA; #endif +#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL + *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; +#endif if (h->avctx->codec->pix_fmts) choices = h->avctx->codec->pix_fmts; else if (h->avctx->color_range == AVCOL_RANGE_JPEG) @@ -973,15 +979,15 @@ { int width = h->width - (h->sps.crop_right + h->sps.crop_left); int height = h->height - (h->sps.crop_top + h->sps.crop_bottom); - int crop_present = h->sps.crop_left || h->sps.crop_top || - h->sps.crop_right || h->sps.crop_bottom; av_assert0(h->sps.crop_right + h->sps.crop_left < (unsigned)h->width); av_assert0(h->sps.crop_top + h->sps.crop_bottom < (unsigned)h->height); /* handle container cropping */ - if (!crop_present && - FFALIGN(h->avctx->width, 16) == h->width && - FFALIGN(h->avctx->height, 16) == h->height) { + if (FFALIGN(h->avctx->width, 16) == FFALIGN(width, 16) && + FFALIGN(h->avctx->height, 16) == FFALIGN(height, 16) && + h->avctx->width <= width && + h->avctx->height <= height + ) { width = h->avctx->width; height = h->avctx->height; } @@ -1043,7 +1049,7 @@ } if (h->avctx->codec && - h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU && + h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU && (h->sps.bit_depth_luma != 8 || h->sps.chroma_format_idc > 1)) { av_log(h->avctx, AV_LOG_ERROR, "VDPAU decoding does not support video colorspace.\n"); @@ -1148,10 +1154,13 @@ int needs_reinit = 0; int field_pic_flag, bottom_field_flag; int first_slice = sl == h->slice_ctx && !h->current_slice; - int frame_num, picture_structure, droppable; + int frame_num, droppable, picture_structure; int mb_aff_frame, last_mb_aff_frame; PPS *pps; + if (first_slice) + av_assert0(!h->setup_finished); + h->qpel_put = h->h264qpel.put_h264_qpel_pixels_tab; h->qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab; @@ -1159,6 +1168,7 @@ if (first_mb_in_slice == 0) { // FIXME better field boundary detection if (h->current_slice) { + av_assert0(!h->setup_finished); if (h->cur_pic_ptr && FIELD_PICTURE(h) && h->first_field) { ff_h264_field_end(h, h->slice_ctx, 1); h->current_slice = 0; @@ -1206,17 +1216,20 @@ return AVERROR_INVALIDDATA; } - if ( - (h->avctx->skip_frame >= AVDISCARD_NONREF && !h->nal_ref_idc) || - (h->avctx->skip_frame >= AVDISCARD_BIDIR && sl->slice_type_nos == AV_PICTURE_TYPE_B) || - (h->avctx->skip_frame >= AVDISCARD_NONINTRA && sl->slice_type_nos != AV_PICTURE_TYPE_I) || - (h->avctx->skip_frame >= AVDISCARD_NONKEY && h->nal_unit_type != NAL_IDR_SLICE) || - h->avctx->skip_frame >= AVDISCARD_ALL) { - return SLICE_SKIPED; - } + if (h->current_slice == 0 && !h->first_field) { + if ( + (h->avctx->skip_frame >= AVDISCARD_NONREF && !h->nal_ref_idc) || + (h->avctx->skip_frame >= AVDISCARD_BIDIR && sl->slice_type_nos == AV_PICTURE_TYPE_B) || + (h->avctx->skip_frame >= AVDISCARD_NONINTRA && sl->slice_type_nos != AV_PICTURE_TYPE_I) || + (h->avctx->skip_frame >= AVDISCARD_NONKEY && h->nal_unit_type != NAL_IDR_SLICE && h->sei_recovery_frame_cnt < 0) || + h->avctx->skip_frame >= AVDISCARD_ALL) { + return SLICE_SKIPED; + } + } // to make a few old functions happy, it's wrong though - h->pict_type = sl->slice_type; + if (!h->setup_finished) + h->pict_type = sl->slice_type; pps_id = get_ue_golomb(&sl->gb); if (pps_id >= MAX_PPS_COUNT) { @@ -1244,8 +1257,13 @@ h->pps.sps_id); return AVERROR_INVALIDDATA; } - if (first_slice) + + if (first_slice) { h->pps = *h->pps_buffers[pps_id]; + } else if (h->setup_finished && h->dequant_coeff_pps != pps_id) { + av_log(h->avctx, AV_LOG_ERROR, "PPS changed between slices\n"); + return AVERROR_INVALIDDATA; + } if (pps->sps_id != h->sps.sps_id || pps->sps_id != h->current_sps_id || @@ -1270,7 +1288,7 @@ h->chroma_format_idc != h->sps.chroma_format_idc) needs_reinit = 1; - if (h->flags & CODEC_FLAG_LOW_DELAY || + if (h->flags & AV_CODEC_FLAG_LOW_DELAY || (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames)) { if (h->avctx->has_b_frames > 1 || h->delayed_pic[0]) @@ -1285,10 +1303,6 @@ } - h->avctx->profile = ff_h264_get_profile(&h->sps); - h->avctx->level = h->sps.level_idc; - h->avctx->refs = h->sps.ref_frame_count; - must_reinit = (h->context_initialized && ( 16*h->sps.mb_width != h->avctx->coded_width || 16*h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag) != h->avctx->coded_height @@ -1304,31 +1318,37 @@ if (first_slice && av_cmp_q(h->sps.sar, h->avctx->sample_aspect_ratio)) must_reinit = 1; - h->mb_width = h->sps.mb_width; - h->mb_height = h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag); - h->mb_num = h->mb_width * h->mb_height; - h->mb_stride = h->mb_width + 1; + if (!h->setup_finished) { + h->avctx->profile = ff_h264_get_profile(&h->sps); + h->avctx->level = h->sps.level_idc; + h->avctx->refs = h->sps.ref_frame_count; - h->b_stride = h->mb_width * 4; + h->mb_width = h->sps.mb_width; + h->mb_height = h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag); + h->mb_num = h->mb_width * h->mb_height; + h->mb_stride = h->mb_width + 1; - h->chroma_y_shift = h->sps.chroma_format_idc <= 1; // 400 uses yuv420p + h->b_stride = h->mb_width * 4; - h->width = 16 * h->mb_width; - h->height = 16 * h->mb_height; + h->chroma_y_shift = h->sps.chroma_format_idc <= 1; // 400 uses yuv420p - ret = init_dimensions(h); - if (ret < 0) - return ret; + h->width = 16 * h->mb_width; + h->height = 16 * h->mb_height; - if (h->sps.video_signal_type_present_flag) { - h->avctx->color_range = h->sps.full_range>0 ? AVCOL_RANGE_JPEG - : AVCOL_RANGE_MPEG; - if (h->sps.colour_description_present_flag) { - if (h->avctx->colorspace != h->sps.colorspace) - needs_reinit = 1; - h->avctx->color_primaries = h->sps.color_primaries; - h->avctx->color_trc = h->sps.color_trc; - h->avctx->colorspace = h->sps.colorspace; + ret = init_dimensions(h); + if (ret < 0) + return ret; + + if (h->sps.video_signal_type_present_flag) { + h->avctx->color_range = h->sps.full_range>0 ? AVCOL_RANGE_JPEG + : AVCOL_RANGE_MPEG; + if (h->sps.colour_description_present_flag) { + if (h->avctx->colorspace != h->sps.colorspace) + needs_reinit = 1; + h->avctx->color_primaries = h->sps.color_primaries; + h->avctx->color_trc = h->sps.color_trc; + h->avctx->colorspace = h->sps.colorspace; + } } } @@ -1394,12 +1414,16 @@ } } + if (!h->setup_finished) + h->frame_num = frame_num; + sl->mb_mbaff = 0; mb_aff_frame = 0; last_mb_aff_frame = h->mb_aff_frame; last_pic_structure = h->picture_structure; last_pic_droppable = h->droppable; - droppable = h->nal_ref_idc == 0; + + droppable = h->nal_ref_idc == 0; if (h->sps.frame_mbs_only_flag) { picture_structure = PICT_FRAME; } else { @@ -1417,6 +1441,7 @@ mb_aff_frame = h->sps.mb_aff; } } + if (h->current_slice) { if (last_pic_structure != picture_structure || last_pic_droppable != droppable || @@ -1434,9 +1459,11 @@ } h->picture_structure = picture_structure; - h->droppable = droppable; - h->frame_num = frame_num; - h->mb_aff_frame = mb_aff_frame; + if (!h->setup_finished) { + h->droppable = droppable; + h->picture_structure = picture_structure; + h->mb_aff_frame = mb_aff_frame; + } sl->mb_field_decoding_flag = picture_structure != PICT_FRAME; if (h->current_slice == 0) { @@ -1558,8 +1585,8 @@ (const uint8_t **)prev->f->data, prev->f->linesize, prev->f->format, - h->mb_width * 16, - h->mb_height * 16); + prev->f->width, + prev->f->height); h->short_ref[0]->poc = prev->poc + 2; } h->short_ref[0]->frame_num = h->prev_frame_num; @@ -1621,8 +1648,8 @@ h->last_slice_type = -1; } - - h->cur_pic_ptr->frame_num = h->frame_num; // FIXME frame_num cleanup + if (!h->setup_finished) + h->cur_pic_ptr->frame_num = h->frame_num; // FIXME frame_num cleanup av_assert1(h->mb_num == h->mb_width * h->mb_height); if (first_mb_in_slice << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num || @@ -1649,20 +1676,34 @@ get_ue_golomb(&sl->gb); /* idr_pic_id */ if (h->sps.poc_type == 0) { - h->poc_lsb = get_bits(&sl->gb, h->sps.log2_max_poc_lsb); + int poc_lsb = get_bits(&sl->gb, h->sps.log2_max_poc_lsb); + + if (!h->setup_finished) + h->poc_lsb = poc_lsb; - if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME) - h->delta_poc_bottom = get_se_golomb(&sl->gb); + if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME) { + int delta_poc_bottom = get_se_golomb(&sl->gb); + if (!h->setup_finished) + h->delta_poc_bottom = delta_poc_bottom; + } } if (h->sps.poc_type == 1 && !h->sps.delta_pic_order_always_zero_flag) { - h->delta_poc[0] = get_se_golomb(&sl->gb); + int delta_poc = get_se_golomb(&sl->gb); + + if (!h->setup_finished) + h->delta_poc[0] = delta_poc; - if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME) - h->delta_poc[1] = get_se_golomb(&sl->gb); + if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME) { + delta_poc = get_se_golomb(&sl->gb); + + if (!h->setup_finished) + h->delta_poc[1] = delta_poc; + } } - ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc); + if (!h->setup_finished) + ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc); if (h->pps.redundant_pic_cnt_present) sl->redundant_pic_count = get_ue_golomb(&sl->gb); @@ -1794,7 +1835,7 @@ sl->deblocking_filter = 0; if (sl->deblocking_filter == 1 && h->max_contexts > 1) { - if (h->avctx->flags2 & CODEC_FLAG2_FAST) { + if (h->avctx->flags2 & AV_CODEC_FLAG2_FAST) { /* Cheat slightly for speed: * Do not bother to deblock across slices. */ sl->deblocking_filter = 2; @@ -2292,7 +2333,7 @@ sl->is_complex = FRAME_MBAFF(h) || h->picture_structure != PICT_FRAME || avctx->codec_id != AV_CODEC_ID_H264 || - (CONFIG_GRAY && (h->flags & CODEC_FLAG_GRAY)); + (CONFIG_GRAY && (h->flags & AV_CODEC_FLAG_GRAY)); if (!(h->avctx->active_thread_type & FF_THREAD_SLICE) && h->picture_structure == PICT_FRAME && h->slice_ctx[0].er.error_status_table) { const int start_i = av_clip(sl->resync_mb_x + sl->resync_mb_y * h->mb_width, 0, h->mb_num - 1); @@ -2318,10 +2359,9 @@ for (;;) { // START_TIMER int ret, eos; - - if (sl->mb_x + sl->mb_y * h->mb_width >= sl->mb_index_end) { - av_log(h->avctx, AV_LOG_ERROR, "Slice overlaps next at %d\n", - sl->mb_index_end); + if (sl->mb_x + sl->mb_y * h->mb_width >= sl->next_slice_idx) { + av_log(h->avctx, AV_LOG_ERROR, "Slice overlaps with next at %d\n", + sl->next_slice_idx); er_add_slice(sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x, sl->mb_y, ER_MB_ERROR); return AVERROR_INVALIDDATA; @@ -2391,9 +2431,9 @@ for (;;) { int ret; - if (sl->mb_x + sl->mb_y * h->mb_width >= sl->mb_index_end) { - av_log(h->avctx, AV_LOG_ERROR, "Slice overlaps next at %d\n", - sl->mb_index_end); + if (sl->mb_x + sl->mb_y * h->mb_width >= sl->next_slice_idx) { + av_log(h->avctx, AV_LOG_ERROR, "Slice overlaps with next at %d\n", + sl->next_slice_idx); er_add_slice(sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x, sl->mb_y, ER_MB_ERROR); return AVERROR_INVALIDDATA; @@ -2483,38 +2523,45 @@ { AVCodecContext *const avctx = h->avctx; H264SliceContext *sl; - int i; + int i, j; av_assert0(context_count && h->slice_ctx[context_count - 1].mb_y < h->mb_height); - h->slice_ctx[0].mb_index_end = INT_MAX; + h->slice_ctx[0].next_slice_idx = INT_MAX; if (h->avctx->hwaccel || - h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) + h->avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) return 0; if (context_count == 1) { - int ret = decode_slice(avctx, &h->slice_ctx[0]); + int ret; + + h->slice_ctx[0].next_slice_idx = h->mb_width * h->mb_height; + + ret = decode_slice(avctx, &h->slice_ctx[0]); h->mb_y = h->slice_ctx[0].mb_y; return ret; } else { - int j, mb_index; av_assert0(context_count > 0); for (i = 0; i < context_count; i++) { - int mb_index_end = h->mb_width * h->mb_height; + int next_slice_idx = h->mb_width * h->mb_height; + int slice_idx; + sl = &h->slice_ctx[i]; - mb_index = sl->resync_mb_x + sl->resync_mb_y * h->mb_width; if (CONFIG_ERROR_RESILIENCE) { sl->er.error_count = 0; } + + /* make sure none of those slices overlap */ + slice_idx = sl->mb_y * h->mb_width + sl->mb_x; for (j = 0; j < context_count; j++) { H264SliceContext *sl2 = &h->slice_ctx[j]; - int mb_index2 = sl2->resync_mb_x + sl2->resync_mb_y * h->mb_width; + int slice_idx2 = sl2->mb_y * h->mb_width + sl2->mb_x; - if (i==j || mb_index > mb_index2) + if (i == j || slice_idx2 < slice_idx) continue; - mb_index_end = FFMIN(mb_index_end, mb_index2); + next_slice_idx = FFMIN(next_slice_idx, slice_idx2); } - sl->mb_index_end = mb_index_end; + sl->next_slice_idx = next_slice_idx; } avctx->execute(avctx, decode_slice, h->slice_ctx, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hap.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hap.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hap.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hap.c 2015-07-22 17:20:04.000000000 +0000 @@ -0,0 +1,55 @@ +/* + * Vidvox Hap utility functions + * Copyright (C) 2015 Tom Butterworth + * + * 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 + */ + +/** + * @file + * Hap utilities + */ +#include "hap.h" + +int ff_hap_set_chunk_count(HapContext *ctx, int count, int first_in_frame) +{ + int ret = 0; + if (first_in_frame == 1 && ctx->chunk_count != count) { + int ret = av_reallocp_array(&ctx->chunks, count, sizeof(HapChunk)); + if (ret == 0) + ret = av_reallocp_array(&ctx->chunk_results, count, sizeof(int)); + if (ret < 0) { + ctx->chunk_count = 0; + } else { + ctx->chunk_count = count; + } + } else if (ctx->chunk_count != count) { + /* If this is not the first chunk count calculated for a frame and a + * different count has already been encountered, then reject the frame: + * each table in the Decode Instructions Container must describe the + * same number of chunks. */ + ret = AVERROR_INVALIDDATA; + } + return ret; +} + +av_cold void ff_hap_free_context(HapContext *ctx) +{ + av_freep(&ctx->tex_buf); + av_freep(&ctx->chunks); + av_freep(&ctx->chunk_results); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hapdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hapdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hapdec.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hapdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -0,0 +1,441 @@ +/* + * Vidvox Hap decoder + * Copyright (C) 2015 Vittorio Giovara + * Copyright (C) 2015 Tom Butterworth + * + * 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 + */ + +/** + * @file + * Hap decoder + * + * Fourcc: Hap1, Hap5, HapY + * + * https://github.com/Vidvox/hap/blob/master/documentation/HapVideoDRAFT.md + */ + +#include + +#include "libavutil/imgutils.h" + +#include "avcodec.h" +#include "bytestream.h" +#include "hap.h" +#include "internal.h" +#include "memory.h" +#include "snappy.h" +#include "texturedsp.h" +#include "thread.h" + +/* The first three bytes are the size of the section past the header, or zero + * if the length is stored in the next long word. The fourth byte in the first + * long word indicates the type of the current section. */ +static int parse_section_header(GetByteContext *gbc, int *section_size, + enum HapSectionType *section_type) +{ + if (bytestream2_get_bytes_left(gbc) < 4) + return AVERROR_INVALIDDATA; + + *section_size = bytestream2_get_le24(gbc); + *section_type = bytestream2_get_byte(gbc); + + if (*section_size == 0) { + if (bytestream2_get_bytes_left(gbc) < 4) + return AVERROR_INVALIDDATA; + + *section_size = bytestream2_get_le32(gbc); + } + + if (*section_size > bytestream2_get_bytes_left(gbc)) + return AVERROR_INVALIDDATA; + else + return 0; +} + +static int hap_parse_decode_instructions(HapContext *ctx, int size) +{ + GetByteContext *gbc = &ctx->gbc; + int section_size; + enum HapSectionType section_type; + int is_first_table = 1, had_offsets = 0, had_compressors = 0, had_sizes = 0; + int i, ret; + + while (size > 0) { + int stream_remaining = bytestream2_get_bytes_left(gbc); + ret = parse_section_header(gbc, §ion_size, §ion_type); + if (ret != 0) + return ret; + + size -= stream_remaining - bytestream2_get_bytes_left(gbc); + + switch (section_type) { + case HAP_ST_COMPRESSOR_TABLE: + ret = ff_hap_set_chunk_count(ctx, section_size, is_first_table); + if (ret != 0) + return ret; + for (i = 0; i < section_size; i++) { + ctx->chunks[i].compressor = bytestream2_get_byte(gbc) << 4; + } + had_compressors = 1; + is_first_table = 0; + break; + case HAP_ST_SIZE_TABLE: + ret = ff_hap_set_chunk_count(ctx, section_size / 4, is_first_table); + if (ret != 0) + return ret; + for (i = 0; i < section_size / 4; i++) { + ctx->chunks[i].compressed_size = bytestream2_get_le32(gbc); + } + had_sizes = 1; + is_first_table = 0; + break; + case HAP_ST_OFFSET_TABLE: + ret = ff_hap_set_chunk_count(ctx, section_size / 4, is_first_table); + if (ret != 0) + return ret; + for (i = 0; i < section_size / 4; i++) { + ctx->chunks[i].compressed_offset = bytestream2_get_le32(gbc); + } + had_offsets = 1; + is_first_table = 0; + break; + default: + break; + } + size -= section_size; + } + + if (!had_sizes || !had_compressors) + return AVERROR_INVALIDDATA; + + /* The offsets table is optional. If not present than calculate offsets by + * summing the sizes of preceding chunks. */ + if (!had_offsets) { + size_t running_size = 0; + for (i = 0; i < ctx->chunk_count; i++) { + ctx->chunks[i].compressed_offset = running_size; + running_size += ctx->chunks[i].compressed_size; + } + } + + return 0; +} + +static int hap_can_use_tex_in_place(HapContext *ctx) +{ + int i; + size_t running_offset = 0; + for (i = 0; i < ctx->chunk_count; i++) { + if (ctx->chunks[i].compressed_offset != running_offset + || ctx->chunks[i].compressor != HAP_COMP_NONE) + return 0; + running_offset += ctx->chunks[i].compressed_size; + } + return 1; +} + +static int hap_parse_frame_header(AVCodecContext *avctx) +{ + HapContext *ctx = avctx->priv_data; + GetByteContext *gbc = &ctx->gbc; + int section_size; + enum HapSectionType section_type; + const char *compressorstr; + int i, ret; + + ret = parse_section_header(gbc, §ion_size, §ion_type); + if (ret != 0) + return ret; + + if ((avctx->codec_tag == MKTAG('H','a','p','1') && (section_type & 0x0F) != HAP_FMT_RGBDXT1) || + (avctx->codec_tag == MKTAG('H','a','p','5') && (section_type & 0x0F) != HAP_FMT_RGBADXT5) || + (avctx->codec_tag == MKTAG('H','a','p','Y') && (section_type & 0x0F) != HAP_FMT_YCOCGDXT5)) { + av_log(avctx, AV_LOG_ERROR, + "Invalid texture format %#04x.\n", section_type & 0x0F); + return AVERROR_INVALIDDATA; + } + + switch (section_type & 0xF0) { + case HAP_COMP_NONE: + case HAP_COMP_SNAPPY: + ret = ff_hap_set_chunk_count(ctx, 1, 1); + if (ret == 0) { + ctx->chunks[0].compressor = section_type & 0xF0; + ctx->chunks[0].compressed_offset = 0; + ctx->chunks[0].compressed_size = section_size; + } + if (ctx->chunks[0].compressor == HAP_COMP_NONE) { + compressorstr = "none"; + } else { + compressorstr = "snappy"; + } + break; + case HAP_COMP_COMPLEX: + ret = parse_section_header(gbc, §ion_size, §ion_type); + if (ret == 0 && section_type != HAP_ST_DECODE_INSTRUCTIONS) + ret = AVERROR_INVALIDDATA; + if (ret == 0) + ret = hap_parse_decode_instructions(ctx, section_size); + compressorstr = "complex"; + break; + default: + ret = AVERROR_INVALIDDATA; + break; + } + + if (ret != 0) + return ret; + + /* Check the frame is valid and read the uncompressed chunk sizes */ + ctx->tex_size = 0; + for (i = 0; i < ctx->chunk_count; i++) { + HapChunk *chunk = &ctx->chunks[i]; + + /* Check the compressed buffer is valid */ + if (chunk->compressed_offset + chunk->compressed_size > bytestream2_get_bytes_left(gbc)) + return AVERROR_INVALIDDATA; + + /* Chunks are unpacked sequentially, ctx->tex_size is the uncompressed + * size thus far */ + chunk->uncompressed_offset = ctx->tex_size; + + /* Fill out uncompressed size */ + if (chunk->compressor == HAP_COMP_SNAPPY) { + GetByteContext gbc_tmp; + int64_t uncompressed_size; + bytestream2_init(&gbc_tmp, gbc->buffer + chunk->compressed_offset, + chunk->compressed_size); + uncompressed_size = ff_snappy_peek_uncompressed_length(&gbc_tmp); + if (uncompressed_size < 0) { + return uncompressed_size; + } + chunk->uncompressed_size = uncompressed_size; + } else if (chunk->compressor == HAP_COMP_NONE) { + chunk->uncompressed_size = chunk->compressed_size; + } else { + return AVERROR_INVALIDDATA; + } + ctx->tex_size += chunk->uncompressed_size; + } + + av_log(avctx, AV_LOG_DEBUG, "%s compressor\n", compressorstr); + + return ret; +} + +static int decompress_chunks_thread(AVCodecContext *avctx, void *arg, + int chunk_nb, int thread_nb) +{ + HapContext *ctx = avctx->priv_data; + + HapChunk *chunk = &ctx->chunks[chunk_nb]; + GetByteContext gbc; + uint8_t *dst = ctx->tex_buf + chunk->uncompressed_offset; + + bytestream2_init(&gbc, ctx->gbc.buffer + chunk->compressed_offset, chunk->compressed_size); + + if (chunk->compressor == HAP_COMP_SNAPPY) { + int ret; + int64_t uncompressed_size = ctx->tex_size; + + /* Uncompress the frame */ + ret = ff_snappy_uncompress(&gbc, dst, &uncompressed_size); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Snappy uncompress error\n"); + return ret; + } + } else if (chunk->compressor == HAP_COMP_NONE) { + bytestream2_get_buffer(&gbc, dst, chunk->compressed_size); + } + + return 0; +} + +static int decompress_texture_thread(AVCodecContext *avctx, void *arg, + int slice, int thread_nb) +{ + HapContext *ctx = avctx->priv_data; + AVFrame *frame = arg; + const uint8_t *d = ctx->tex_data; + int w_block = avctx->coded_width / TEXTURE_BLOCK_W; + int h_block = avctx->coded_height / TEXTURE_BLOCK_H; + int x, y; + int start_slice, end_slice; + int base_blocks_per_slice = h_block / ctx->slice_count; + int remainder_blocks = h_block % ctx->slice_count; + + /* When the frame height (in blocks) doesn't divide evenly between the + * number of slices, spread the remaining blocks evenly between the first + * operations */ + start_slice = slice * base_blocks_per_slice; + /* Add any extra blocks (one per slice) that have been added before this slice */ + start_slice += FFMIN(slice, remainder_blocks); + + end_slice = start_slice + base_blocks_per_slice; + /* Add an extra block if there are still remainder blocks to be accounted for */ + if (slice < remainder_blocks) + end_slice++; + + for (y = start_slice; y < end_slice; y++) { + uint8_t *p = frame->data[0] + y * frame->linesize[0] * TEXTURE_BLOCK_H; + int off = y * w_block; + for (x = 0; x < w_block; x++) { + ctx->tex_fun(p + x * 16, frame->linesize[0], + d + (off + x) * ctx->tex_rat); + } + } + + return 0; +} + +static int hap_decode(AVCodecContext *avctx, void *data, + int *got_frame, AVPacket *avpkt) +{ + HapContext *ctx = avctx->priv_data; + ThreadFrame tframe; + int ret, i; + int tex_size; + + bytestream2_init(&ctx->gbc, avpkt->data, avpkt->size); + + /* Check for section header */ + ret = hap_parse_frame_header(avctx); + if (ret < 0) + return ret; + + /* Get the output frame ready to receive data */ + tframe.f = data; + ret = ff_thread_get_buffer(avctx, &tframe, 0); + if (ret < 0) + return ret; + if (avctx->codec->update_thread_context) + ff_thread_finish_setup(avctx); + + /* Unpack the DXT texture */ + if (hap_can_use_tex_in_place(ctx)) { + /* Only DXTC texture compression in a contiguous block */ + ctx->tex_data = ctx->gbc.buffer; + tex_size = bytestream2_get_bytes_left(&ctx->gbc); + } else { + /* Perform the second-stage decompression */ + ret = av_reallocp(&ctx->tex_buf, ctx->tex_size); + if (ret < 0) + return ret; + + avctx->execute2(avctx, decompress_chunks_thread, NULL, + ctx->chunk_results, ctx->chunk_count); + + for (i = 0; i < ctx->chunk_count; i++) { + if (ctx->chunk_results[i] < 0) + return ctx->chunk_results[i]; + } + + ctx->tex_data = ctx->tex_buf; + tex_size = ctx->tex_size; + } + + if (tex_size < (avctx->coded_width / TEXTURE_BLOCK_W) + *(avctx->coded_height / TEXTURE_BLOCK_H) + *ctx->tex_rat) { + av_log(avctx, AV_LOG_ERROR, "Insufficient data\n"); + return AVERROR_INVALIDDATA; + } + + /* Use the decompress function on the texture, one block per thread */ + avctx->execute2(avctx, decompress_texture_thread, tframe.f, NULL, ctx->slice_count); + + /* Frame is ready to be output */ + tframe.f->pict_type = AV_PICTURE_TYPE_I; + tframe.f->key_frame = 1; + *got_frame = 1; + + return avpkt->size; +} + +static av_cold int hap_init(AVCodecContext *avctx) +{ + HapContext *ctx = avctx->priv_data; + const char *texture_name; + int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx); + + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid video size %dx%d.\n", + avctx->width, avctx->height); + return ret; + } + + /* Since codec is based on 4x4 blocks, size is aligned to 4 */ + avctx->coded_width = FFALIGN(avctx->width, TEXTURE_BLOCK_W); + avctx->coded_height = FFALIGN(avctx->height, TEXTURE_BLOCK_H); + + /* Technically only one mode has alpha, but 32 bits are easier to handle */ + avctx->pix_fmt = AV_PIX_FMT_RGBA; + + ff_texturedsp_init(&ctx->dxtc); + + switch (avctx->codec_tag) { + case MKTAG('H','a','p','1'): + texture_name = "DXT1"; + ctx->tex_rat = 8; + ctx->tex_fun = ctx->dxtc.dxt1_block; + break; + case MKTAG('H','a','p','5'): + texture_name = "DXT5"; + ctx->tex_rat = 16; + ctx->tex_fun = ctx->dxtc.dxt5_block; + break; + case MKTAG('H','a','p','Y'): + texture_name = "DXT5-YCoCg-scaled"; + ctx->tex_rat = 16; + ctx->tex_fun = ctx->dxtc.dxt5ys_block; + break; + default: + return AVERROR_DECODER_NOT_FOUND; + } + + av_log(avctx, AV_LOG_DEBUG, "%s texture\n", texture_name); + + ctx->slice_count = av_clip(avctx->thread_count, 1, + avctx->coded_height / TEXTURE_BLOCK_H); + + return 0; +} + +static av_cold int hap_close(AVCodecContext *avctx) +{ + HapContext *ctx = avctx->priv_data; + + ff_hap_free_context(ctx); + + return 0; +} + +AVCodec ff_hap_decoder = { + .name = "hap", + .long_name = NULL_IF_CONFIG_SMALL("Vidvox Hap decoder"), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_HAP, + .init = hap_init, + .decode = hap_decode, + .close = hap_close, + .priv_data_size = sizeof(HapContext), + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_INIT_CLEANUP, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hapenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hapenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hapenc.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hapenc.c 2015-07-24 17:20:02.000000000 +0000 @@ -0,0 +1,331 @@ +/* + * Vidvox Hap encoder + * Copyright (C) 2015 Vittorio Giovara + * Copyright (C) 2015 Tom Butterworth + * + * 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 + */ + +/** + * @file + * Hap encoder + * + * Fourcc: Hap1, Hap5, HapY + * + * https://github.com/Vidvox/hap/blob/master/documentation/HapVideoDRAFT.md + */ + +#include +#include "snappy-c.h" + +#include "libavutil/frame.h" +#include "libavutil/imgutils.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/opt.h" + +#include "avcodec.h" +#include "bytestream.h" +#include "hap.h" +#include "internal.h" +#include "texturedsp.h" + +#define HAP_MAX_CHUNKS 64 + +enum HapHeaderLength { + /* Short header: four bytes with a 24 bit size value */ + HAP_HDR_SHORT = 4, + /* Long header: eight bytes with a 32 bit size value */ + HAP_HDR_LONG = 8, +}; + +static void compress_texture(AVCodecContext *avctx, const AVFrame *f) +{ + HapContext *ctx = avctx->priv_data; + uint8_t *out = ctx->tex_buf; + int i, j; + + for (j = 0; j < avctx->height; j += 4) { + for (i = 0; i < avctx->width; i += 4) { + uint8_t *p = f->data[0] + i * 4 + j * f->linesize[0]; + const int step = ctx->tex_fun(out, f->linesize[0], p); + out += step; + } + } +} + +/* section_length does not include the header */ +static void hap_write_section_header(PutByteContext *pbc, + enum HapHeaderLength header_length, + int section_length, + enum HapSectionType section_type) +{ + /* The first three bytes are the length of the section (not including the + * header) or zero if using an eight-byte header. + * For an eight-byte header, the length is in the last four bytes. + * The fourth byte stores the section type. */ + bytestream2_put_le24(pbc, header_length == HAP_HDR_LONG ? 0 : section_length); + bytestream2_put_byte(pbc, section_type); + + if (header_length == HAP_HDR_LONG) { + bytestream2_put_le32(pbc, section_length); + } +} + +static int hap_compress_frame(AVCodecContext *avctx, uint8_t *dst) +{ + HapContext *ctx = avctx->priv_data; + int i, final_size = 0; + + for (i = 0; i < ctx->chunk_count; i++) { + HapChunk *chunk = &ctx->chunks[i]; + uint8_t *chunk_src, *chunk_dst; + int ret; + + if (i == 0) { + chunk->compressed_offset = 0; + } else { + chunk->compressed_offset = ctx->chunks[i-1].compressed_offset + + ctx->chunks[i-1].compressed_size; + } + chunk->uncompressed_size = ctx->tex_size / ctx->chunk_count; + chunk->uncompressed_offset = i * chunk->uncompressed_size; + chunk->compressed_size = ctx->max_snappy; + chunk_src = ctx->tex_buf + chunk->uncompressed_offset; + chunk_dst = dst + chunk->compressed_offset; + + /* Compress with snappy too, write directly on packet buffer. */ + ret = snappy_compress(chunk_src, chunk->uncompressed_size, + chunk_dst, &chunk->compressed_size); + if (ret != SNAPPY_OK) { + av_log(avctx, AV_LOG_ERROR, "Snappy compress error.\n"); + return AVERROR_BUG; + } + + /* If there is no gain from snappy, just use the raw texture. */ + if (chunk->compressed_size >= chunk->uncompressed_size) { + av_log(avctx, AV_LOG_VERBOSE, + "Snappy buffer bigger than uncompressed (%lu >= %lu bytes).\n", + chunk->compressed_size, chunk->uncompressed_size); + memcpy(chunk_dst, chunk_src, chunk->uncompressed_size); + chunk->compressor = HAP_COMP_NONE; + chunk->compressed_size = chunk->uncompressed_size; + } else { + chunk->compressor = HAP_COMP_SNAPPY; + } + + final_size += chunk->compressed_size; + } + + return final_size; +} + +static int hap_decode_instructions_length(HapContext *ctx) +{ + /* Second-Stage Compressor Table (one byte per entry) + * + Chunk Size Table (four bytes per entry) + * + headers for both sections (short versions) + * = chunk_count + (4 * chunk_count) + 4 + 4 */ + return (5 * ctx->chunk_count) + 8; +} + +static int hap_header_length(HapContext *ctx) +{ + /* Top section header (long version) */ + int length = HAP_HDR_LONG; + + if (ctx->chunk_count > 1) { + /* Decode Instructions header (short) + Decode Instructions Container */ + length += HAP_HDR_SHORT + hap_decode_instructions_length(ctx); + } + + return length; +} + +static void hap_write_frame_header(HapContext *ctx, uint8_t *dst, int frame_length) +{ + PutByteContext pbc; + int i; + + bytestream2_init_writer(&pbc, dst, frame_length); + if (ctx->chunk_count == 1) { + /* Write a simple header */ + hap_write_section_header(&pbc, HAP_HDR_LONG, frame_length - 8, + ctx->chunks[0].compressor | ctx->opt_tex_fmt); + } else { + /* Write a complex header with Decode Instructions Container */ + hap_write_section_header(&pbc, HAP_HDR_LONG, frame_length - 8, + HAP_COMP_COMPLEX | ctx->opt_tex_fmt); + hap_write_section_header(&pbc, HAP_HDR_SHORT, hap_decode_instructions_length(ctx), + HAP_ST_DECODE_INSTRUCTIONS); + hap_write_section_header(&pbc, HAP_HDR_SHORT, ctx->chunk_count, + HAP_ST_COMPRESSOR_TABLE); + + for (i = 0; i < ctx->chunk_count; i++) { + bytestream2_put_byte(&pbc, ctx->chunks[i].compressor >> 4); + } + + hap_write_section_header(&pbc, HAP_HDR_SHORT, ctx->chunk_count * 4, + HAP_ST_SIZE_TABLE); + + for (i = 0; i < ctx->chunk_count; i++) { + bytestream2_put_le32(&pbc, ctx->chunks[i].compressed_size); + } + } +} + +static int hap_encode(AVCodecContext *avctx, AVPacket *pkt, + const AVFrame *frame, int *got_packet) +{ + HapContext *ctx = avctx->priv_data; + int header_length = hap_header_length(ctx); + int final_data_size, ret; + int pktsize = FFMAX(ctx->tex_size, ctx->max_snappy * ctx->chunk_count) + header_length; + + /* Allocate maximum size packet, shrink later. */ + ret = ff_alloc_packet(pkt, pktsize); + if (ret < 0) + return ret; + + /* DXTC compression. */ + compress_texture(avctx, frame); + + /* Compress (using Snappy) the frame */ + final_data_size = hap_compress_frame(avctx, pkt->data + header_length); + if (final_data_size < 0) + return final_data_size; + + /* Write header at the start. */ + hap_write_frame_header(ctx, pkt->data, final_data_size + header_length); + + av_shrink_packet(pkt, final_data_size + header_length); + pkt->flags |= AV_PKT_FLAG_KEY; + *got_packet = 1; + return 0; +} + +static av_cold int hap_init(AVCodecContext *avctx) +{ + HapContext *ctx = avctx->priv_data; + int ratio; + int corrected_chunk_count; + int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx); + + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid video size %dx%d.\n", + avctx->width, avctx->height); + return ret; + } + + if (avctx->width % 4 || avctx->height % 4) { + av_log(avctx, AV_LOG_ERROR, "Video size %dx%d is not multiple of 4.\n", + avctx->width, avctx->height); + return AVERROR_INVALIDDATA; + } + + ff_texturedspenc_init(&ctx->dxtc); + + switch (ctx->opt_tex_fmt) { + case HAP_FMT_RGBDXT1: + ratio = 8; + avctx->codec_tag = MKTAG('H', 'a', 'p', '1'); + ctx->tex_fun = ctx->dxtc.dxt1_block; + break; + case HAP_FMT_RGBADXT5: + ratio = 4; + avctx->codec_tag = MKTAG('H', 'a', 'p', '5'); + ctx->tex_fun = ctx->dxtc.dxt5_block; + break; + case HAP_FMT_YCOCGDXT5: + ratio = 4; + avctx->codec_tag = MKTAG('H', 'a', 'p', 'Y'); + ctx->tex_fun = ctx->dxtc.dxt5ys_block; + break; + default: + av_log(avctx, AV_LOG_ERROR, "Invalid format %02X\n", ctx->opt_tex_fmt); + return AVERROR_INVALIDDATA; + } + + /* Texture compression ratio is constant, so can we computer + * beforehand the final size of the uncompressed buffer. */ + ctx->tex_size = FFALIGN(avctx->width, TEXTURE_BLOCK_W) * + FFALIGN(avctx->height, TEXTURE_BLOCK_H) * 4 / ratio; + + /* Round the chunk count to divide evenly on DXT block edges */ + corrected_chunk_count = av_clip(ctx->opt_chunk_count, 1, HAP_MAX_CHUNKS); + while ((ctx->tex_size / (64 / ratio)) % corrected_chunk_count != 0) { + corrected_chunk_count--; + } + if (corrected_chunk_count != ctx->opt_chunk_count) { + av_log(avctx, AV_LOG_INFO, "%d chunks requested but %d used.\n", + ctx->opt_chunk_count, corrected_chunk_count); + } + ret = ff_hap_set_chunk_count(ctx, corrected_chunk_count, 1); + if (ret != 0) + return ret; + + ctx->max_snappy = snappy_max_compressed_length(ctx->tex_size / corrected_chunk_count); + + ctx->tex_buf = av_malloc(ctx->tex_size); + if (!ctx->tex_buf) + return AVERROR(ENOMEM); + + return 0; +} + +static av_cold int hap_close(AVCodecContext *avctx) +{ + HapContext *ctx = avctx->priv_data; + + ff_hap_free_context(ctx); + + return 0; +} + +#define OFFSET(x) offsetof(HapContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "format", NULL, OFFSET(opt_tex_fmt), AV_OPT_TYPE_INT, { .i64 = HAP_FMT_RGBDXT1 }, HAP_FMT_RGBDXT1, HAP_FMT_YCOCGDXT5, FLAGS, "format" }, + { "hap", "Hap 1 (DXT1 textures)", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_FMT_RGBDXT1 }, 0, 0, FLAGS, "format" }, + { "hap_alpha", "Hap Alpha (DXT5 textures)", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_FMT_RGBADXT5 }, 0, 0, FLAGS, "format" }, + { "hap_q", "Hap Q (DXT5-YCoCg textures)", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_FMT_YCOCGDXT5 }, 0, 0, FLAGS, "format" }, + { "chunks", "chunk count", OFFSET(opt_chunk_count), AV_OPT_TYPE_INT, {.i64 = 1 }, 1, HAP_MAX_CHUNKS, FLAGS, }, + { NULL }, +}; + +static const AVClass hapenc_class = { + .class_name = "Hap encoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +AVCodec ff_hap_encoder = { + .name = "hap", + .long_name = NULL_IF_CONFIG_SMALL("Vidvox Hap encoder"), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_HAP, + .priv_data_size = sizeof(HapContext), + .priv_class = &hapenc_class, + .init = hap_init, + .encode2 = hap_encode, + .close = hap_close, + .pix_fmts = (const enum AVPixelFormat[]) { + AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE, + }, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_INIT_CLEANUP, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hap.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/hap.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hap.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hap.h 2015-07-28 17:20:07.000000000 +0000 @@ -0,0 +1,98 @@ +/* + * Vidvox Hap + * Copyright (C) 2015 Vittorio Giovara + * Copyright (C) 2015 Tom Butterworth + * + * 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 + */ + +#ifndef AVCODEC_HAP_H +#define AVCODEC_HAP_H + +#include + +#include "libavutil/opt.h" + +#include "bytestream.h" +#include "texturedsp.h" + +enum HapTextureFormat { + HAP_FMT_RGBDXT1 = 0x0B, + HAP_FMT_RGBADXT5 = 0x0E, + HAP_FMT_YCOCGDXT5 = 0x0F, +}; + +enum HapCompressor { + HAP_COMP_NONE = 0xA0, + HAP_COMP_SNAPPY = 0xB0, + HAP_COMP_COMPLEX = 0xC0, +}; + +enum HapSectionType { + HAP_ST_DECODE_INSTRUCTIONS = 0x01, + HAP_ST_COMPRESSOR_TABLE = 0x02, + HAP_ST_SIZE_TABLE = 0x03, + HAP_ST_OFFSET_TABLE = 0x04, +}; + +typedef struct HapChunk { + enum HapCompressor compressor; + int compressed_offset; + size_t compressed_size; + int uncompressed_offset; + size_t uncompressed_size; +} HapChunk; + +typedef struct HapContext { + AVClass *class; + + TextureDSPContext dxtc; + GetByteContext gbc; + + enum HapTextureFormat opt_tex_fmt; /* Texture type (encoder only) */ + int opt_chunk_count; /* User-requested chunk count (encoder only) */ + + int chunk_count; + HapChunk *chunks; + int *chunk_results; /* Results from threaded operations */ + + int tex_rat; /* Compression ratio */ + const uint8_t *tex_data; /* Compressed texture */ + uint8_t *tex_buf; /* Buffer for compressed texture */ + size_t tex_size; /* Size of the compressed texture */ + + size_t max_snappy; /* Maximum compressed size for snappy buffer */ + + int slice_count; /* Number of slices for threaded operations */ + + /* Pointer to the selected compress or decompress function */ + int (*tex_fun)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block); +} HapContext; + +/* + * Set the number of chunks in the frame. Returns 0 on success or an error if: + * - first_in_frame is 0 and the number of chunks has changed + * - any other error occurs + */ +int ff_hap_set_chunk_count(HapContext *ctx, int count, int first_in_frame); + +/* + * Free resources associated with the context + */ +av_cold void ff_hap_free_context(HapContext *ctx); + +#endif /* AVCODEC_HAP_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc.c 2015-07-28 17:20:07.000000000 +0000 @@ -149,7 +149,7 @@ if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) av_log(s->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom); s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3); - if (s->sps->chroma_format_idc != 0) { + if (s->ps.sps->chroma_format_idc != 0) { int delta = get_se_golomb(gb); s->sh.chroma_log2_weight_denom = av_clip_uintp2(s->sh.luma_log2_weight_denom + delta, 3); } @@ -161,7 +161,7 @@ s->sh.luma_offset_l0[i] = 0; } } - if (s->sps->chroma_format_idc != 0) { + if (s->ps.sps->chroma_format_idc != 0) { for (i = 0; i < s->sh.nb_refs[L0]; i++) chroma_weight_l0_flag[i] = get_bits1(gb); } else { @@ -197,7 +197,7 @@ s->sh.luma_offset_l1[i] = 0; } } - if (s->sps->chroma_format_idc != 0) { + if (s->ps.sps->chroma_format_idc != 0) { for (i = 0; i < s->sh.nb_refs[L1]; i++) chroma_weight_l1_flag[i] = get_bits1(gb); } else { @@ -230,7 +230,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb) { - const HEVCSPS *sps = s->sps; + const HEVCSPS *sps = s->ps.sps; int max_poc_lsb = 1 << sps->log2_max_poc_lsb; int prev_delta_msb = 0; unsigned int nb_sps = 0, nb_sh; @@ -280,10 +280,10 @@ return 0; } -static void export_stream_params(AVCodecContext *avctx, - const HEVCContext *s, const HEVCSPS *sps) +static void export_stream_params(AVCodecContext *avctx, const HEVCParamSets *ps, + const HEVCSPS *sps) { - const HEVCVPS *vps = (const HEVCVPS*)s->vps_list[sps->vps_id]->data; + const HEVCVPS *vps = (const HEVCVPS*)ps->vps_list[sps->vps_id]->data; unsigned int num = 0, den = 0; avctx->pix_fmt = sps->pix_fmt; @@ -328,17 +328,23 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps, enum AVPixelFormat pix_fmt) { - #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL) + #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL + CONFIG_HEVC_VDPAU_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; int ret, i; - export_stream_params(s->avctx, s, sps); - pic_arrays_free(s); + s->ps.sps = NULL; + s->ps.vps = NULL; + + if (!sps) + return 0; + ret = pic_arrays_init(s, sps); if (ret < 0) goto fail; + export_stream_params(s->avctx, &s->ps, sps); + if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420P) { #if CONFIG_HEVC_DXVA2_HWACCEL *fmt++ = AV_PIX_FMT_DXVA2_VLD; @@ -346,6 +352,9 @@ #if CONFIG_HEVC_D3D11VA_HWACCEL *fmt++ = AV_PIX_FMT_D3D11VA_VLD; #endif +#if CONFIG_HEVC_VDPAU_HWACCEL + *fmt++ = AV_PIX_FMT_VDPAU; +#endif } if (pix_fmt == AV_PIX_FMT_NONE) { @@ -386,14 +395,14 @@ } } - s->sps = sps; - s->vps = (HEVCVPS*) s->vps_list[s->sps->vps_id]->data; + s->ps.sps = sps; + s->ps.vps = (HEVCVPS*) s->ps.vps_list[s->ps.sps->vps_id]->data; return 0; fail: pic_arrays_free(s); - s->sps = NULL; + s->ps.sps = NULL; return ret; } @@ -416,30 +425,30 @@ sh->no_output_of_prior_pics_flag = get_bits1(gb); sh->pps_id = get_ue_golomb_long(gb); - if (sh->pps_id >= MAX_PPS_COUNT || !s->pps_list[sh->pps_id]) { + if (sh->pps_id >= MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) { av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id); return AVERROR_INVALIDDATA; } if (!sh->first_slice_in_pic_flag && - s->pps != (HEVCPPS*)s->pps_list[sh->pps_id]->data) { + s->ps.pps != (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data) { av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n"); return AVERROR_INVALIDDATA; } - s->pps = (HEVCPPS*)s->pps_list[sh->pps_id]->data; + s->ps.pps = (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data; if (s->nal_unit_type == NAL_CRA_NUT && s->last_eos == 1) sh->no_output_of_prior_pics_flag = 1; - if (s->sps != (HEVCSPS*)s->sps_list[s->pps->sps_id]->data) { - const HEVCSPS* last_sps = s->sps; - s->sps = (HEVCSPS*)s->sps_list[s->pps->sps_id]->data; + if (s->ps.sps != (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data) { + const HEVCSPS* last_sps = s->ps.sps; + s->ps.sps = (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data; if (last_sps && IS_IRAP(s) && s->nal_unit_type != NAL_CRA_NUT) { - if (s->sps->width != last_sps->width || s->sps->height != last_sps->height || - s->sps->temporal_layer[s->sps->max_sub_layers - 1].max_dec_pic_buffering != + if (s->ps.sps->width != last_sps->width || s->ps.sps->height != last_sps->height || + s->ps.sps->temporal_layer[s->ps.sps->max_sub_layers - 1].max_dec_pic_buffering != last_sps->temporal_layer[last_sps->max_sub_layers - 1].max_dec_pic_buffering) sh->no_output_of_prior_pics_flag = 0; } ff_hevc_clear_refs(s); - ret = set_sps(s, s->sps, AV_PIX_FMT_NONE); + ret = set_sps(s, s->ps.sps, AV_PIX_FMT_NONE); if (ret < 0) return ret; @@ -451,13 +460,13 @@ if (!sh->first_slice_in_pic_flag) { int slice_address_length; - if (s->pps->dependent_slice_segments_enabled_flag) + if (s->ps.pps->dependent_slice_segments_enabled_flag) sh->dependent_slice_segment_flag = get_bits1(gb); - slice_address_length = av_ceil_log2(s->sps->ctb_width * - s->sps->ctb_height); - sh->slice_segment_addr = get_bits(gb, slice_address_length); - if (sh->slice_segment_addr >= s->sps->ctb_width * s->sps->ctb_height) { + slice_address_length = av_ceil_log2(s->ps.sps->ctb_width * + s->ps.sps->ctb_height); + sh->slice_segment_addr = slice_address_length ? get_bits(gb, slice_address_length) : 0; + if (sh->slice_segment_addr >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) { av_log(s->avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n", sh->slice_segment_addr); @@ -477,7 +486,7 @@ if (!sh->dependent_slice_segment_flag) { s->slice_initialized = 0; - for (i = 0; i < s->pps->num_extra_slice_header_bits; i++) + for (i = 0; i < s->ps.pps->num_extra_slice_header_bits; i++) skip_bits(gb, 1); // slice_reserved_undetermined_flag[] sh->slice_type = get_ue_golomb_long(gb); @@ -495,16 +504,16 @@ // when flag is not present, picture is inferred to be output sh->pic_output_flag = 1; - if (s->pps->output_flag_present_flag) + if (s->ps.pps->output_flag_present_flag) sh->pic_output_flag = get_bits1(gb); - if (s->sps->separate_colour_plane_flag) + if (s->ps.sps->separate_colour_plane_flag) sh->colour_plane_id = get_bits(gb, 2); if (!IS_IDR(s)) { - int poc; + int poc, pos; - sh->pic_order_cnt_lsb = get_bits(gb, s->sps->log2_max_poc_lsb); + sh->pic_order_cnt_lsb = get_bits(gb, s->ps.sps->log2_max_poc_lsb); poc = ff_hevc_compute_poc(s, sh->pic_order_cnt_lsb); if (!sh->first_slice_in_pic_flag && poc != s->poc) { av_log(s->avctx, AV_LOG_WARNING, @@ -516,35 +525,37 @@ s->poc = poc; sh->short_term_ref_pic_set_sps_flag = get_bits1(gb); + pos = get_bits_left(gb); if (!sh->short_term_ref_pic_set_sps_flag) { - int pos = get_bits_left(gb); - ret = ff_hevc_decode_short_term_rps(s, &sh->slice_rps, s->sps, 1); + ret = ff_hevc_decode_short_term_rps(gb, s->avctx, &sh->slice_rps, s->ps.sps, 1); if (ret < 0) return ret; - sh->short_term_ref_pic_set_size = pos - get_bits_left(gb); sh->short_term_rps = &sh->slice_rps; } else { int numbits, rps_idx; - if (!s->sps->nb_st_rps) { + if (!s->ps.sps->nb_st_rps) { av_log(s->avctx, AV_LOG_ERROR, "No ref lists in the SPS.\n"); return AVERROR_INVALIDDATA; } - numbits = av_ceil_log2(s->sps->nb_st_rps); + numbits = av_ceil_log2(s->ps.sps->nb_st_rps); rps_idx = numbits > 0 ? get_bits(gb, numbits) : 0; - sh->short_term_rps = &s->sps->st_rps[rps_idx]; + sh->short_term_rps = &s->ps.sps->st_rps[rps_idx]; } + sh->short_term_ref_pic_set_size = pos - get_bits_left(gb); + pos = get_bits_left(gb); ret = decode_lt_rps(s, &sh->long_term_rps, gb); if (ret < 0) { av_log(s->avctx, AV_LOG_WARNING, "Invalid long term RPS.\n"); if (s->avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } + sh->long_term_ref_pic_set_size = pos - get_bits_left(gb); - if (s->sps->sps_temporal_mvp_enabled_flag) + if (s->ps.sps->sps_temporal_mvp_enabled_flag) sh->slice_temporal_mvp_enabled_flag = get_bits1(gb); else sh->slice_temporal_mvp_enabled_flag = 0; @@ -564,9 +575,9 @@ s->nal_unit_type != NAL_RASL_R) s->pocTid0 = s->poc; - if (s->sps->sao_enabled) { + if (s->ps.sps->sao_enabled) { sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb); - if (s->sps->chroma_format_idc) { + if (s->ps.sps->chroma_format_idc) { sh->slice_sample_adaptive_offset_flag[1] = sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb); } @@ -580,9 +591,9 @@ if (sh->slice_type == P_SLICE || sh->slice_type == B_SLICE) { int nb_refs; - sh->nb_refs[L0] = s->pps->num_ref_idx_l0_default_active; + sh->nb_refs[L0] = s->ps.pps->num_ref_idx_l0_default_active; if (sh->slice_type == B_SLICE) - sh->nb_refs[L1] = s->pps->num_ref_idx_l1_default_active; + sh->nb_refs[L1] = s->ps.pps->num_ref_idx_l1_default_active; if (get_bits1(gb)) { // num_ref_idx_active_override_flag sh->nb_refs[L0] = get_ue_golomb_long(gb) + 1; @@ -603,7 +614,7 @@ return AVERROR_INVALIDDATA; } - if (s->pps->lists_modification_present_flag && nb_refs > 1) { + if (s->ps.pps->lists_modification_present_flag && nb_refs > 1) { sh->rpl_modification_flag[0] = get_bits1(gb); if (sh->rpl_modification_flag[0]) { for (i = 0; i < sh->nb_refs[L0]; i++) @@ -621,7 +632,7 @@ if (sh->slice_type == B_SLICE) sh->mvd_l1_zero_flag = get_bits1(gb); - if (s->pps->cabac_init_present_flag) + if (s->ps.pps->cabac_init_present_flag) sh->cabac_init_flag = get_bits1(gb); else sh->cabac_init_flag = 0; @@ -643,8 +654,8 @@ } } - if ((s->pps->weighted_pred_flag && sh->slice_type == P_SLICE) || - (s->pps->weighted_bipred_flag && sh->slice_type == B_SLICE)) { + if ((s->ps.pps->weighted_pred_flag && sh->slice_type == P_SLICE) || + (s->ps.pps->weighted_bipred_flag && sh->slice_type == B_SLICE)) { pred_weight_table(s, gb); } @@ -659,7 +670,7 @@ sh->slice_qp_delta = get_se_golomb(gb); - if (s->pps->pic_slice_level_chroma_qp_offsets_present_flag) { + if (s->ps.pps->pic_slice_level_chroma_qp_offsets_present_flag) { sh->slice_cb_qp_offset = get_se_golomb(gb); sh->slice_cr_qp_offset = get_se_golomb(gb); } else { @@ -667,15 +678,15 @@ sh->slice_cr_qp_offset = 0; } - if (s->pps->chroma_qp_offset_list_enabled_flag) + if (s->ps.pps->chroma_qp_offset_list_enabled_flag) sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb); else sh->cu_chroma_qp_offset_enabled_flag = 0; - if (s->pps->deblocking_filter_control_present_flag) { + if (s->ps.pps->deblocking_filter_control_present_flag) { int deblocking_filter_override_flag = 0; - if (s->pps->deblocking_filter_override_enabled_flag) + if (s->ps.pps->deblocking_filter_override_enabled_flag) deblocking_filter_override_flag = get_bits1(gb); if (deblocking_filter_override_flag) { @@ -685,9 +696,9 @@ sh->tc_offset = get_se_golomb(gb) * 2; } } else { - sh->disable_deblocking_filter_flag = s->pps->disable_dbf; - sh->beta_offset = s->pps->beta_offset; - sh->tc_offset = s->pps->tc_offset; + sh->disable_deblocking_filter_flag = s->ps.pps->disable_dbf; + sh->beta_offset = s->ps.pps->beta_offset; + sh->tc_offset = s->ps.pps->tc_offset; } } else { sh->disable_deblocking_filter_flag = 0; @@ -695,13 +706,13 @@ sh->tc_offset = 0; } - if (s->pps->seq_loop_filter_across_slices_enabled_flag && + if (s->ps.pps->seq_loop_filter_across_slices_enabled_flag && (sh->slice_sample_adaptive_offset_flag[0] || sh->slice_sample_adaptive_offset_flag[1] || !sh->disable_deblocking_filter_flag)) { sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb); } else { - sh->slice_loop_filter_across_slices_enabled_flag = s->pps->seq_loop_filter_across_slices_enabled_flag; + sh->slice_loop_filter_across_slices_enabled_flag = s->ps.pps->seq_loop_filter_across_slices_enabled_flag; } } else if (!s->slice_initialized) { av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n"); @@ -709,7 +720,7 @@ } sh->num_entry_point_offsets = 0; - if (s->pps->tiles_enabled_flag || s->pps->entropy_coding_sync_enabled_flag) { + if (s->ps.pps->tiles_enabled_flag || s->ps.pps->entropy_coding_sync_enabled_flag) { unsigned num_entry_point_offsets = get_ue_golomb_long(gb); // It would be possible to bound this tighter but this here is simpler if (num_entry_point_offsets > get_bits_left(gb)) { @@ -742,7 +753,7 @@ unsigned val = get_bits_long(gb, offset_len); sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the size } - if (s->threads_number > 1 && (s->pps->num_tile_rows > 1 || s->pps->num_tile_columns > 1)) { + if (s->threads_number > 1 && (s->ps.pps->num_tile_rows > 1 || s->ps.pps->num_tile_columns > 1)) { s->enable_parallel_tiles = 0; // TODO: you can enable tiles in parallel here s->threads_number = 1; } else @@ -751,7 +762,7 @@ s->enable_parallel_tiles = 0; } - if (s->pps->slice_header_extension_present_flag) { + if (s->ps.pps->slice_header_extension_present_flag) { unsigned int length = get_ue_golomb_long(gb); if (length*8LL > get_bits_left(gb)) { av_log(s->avctx, AV_LOG_ERROR, "too many slice_header_extension_data_bytes\n"); @@ -762,14 +773,14 @@ } // Inferred parameters - sh->slice_qp = 26U + s->pps->pic_init_qp_minus26 + sh->slice_qp_delta; + sh->slice_qp = 26U + s->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta; if (sh->slice_qp > 51 || - sh->slice_qp < -s->sps->qp_bd_offset) { + sh->slice_qp < -s->ps.sps->qp_bd_offset) { av_log(s->avctx, AV_LOG_ERROR, "The slice_qp %d is outside the valid range " "[%d, 51].\n", sh->slice_qp, - -s->sps->qp_bd_offset); + -s->ps.sps->qp_bd_offset); return AVERROR_INVALIDDATA; } @@ -788,7 +799,7 @@ s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag; - if (!s->pps->cu_qp_delta_enabled_flag) + if (!s->ps.pps->cu_qp_delta_enabled_flag) s->HEVClc->qp_y = s->sh.slice_qp; s->slice_initialized = 1; @@ -798,7 +809,7 @@ return 0; } -#define CTB(tab, x, y) ((tab)[(y) * s->sps->ctb_width + (x)]) +#define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)]) #define SET_SAO(elem, value) \ do { \ @@ -832,9 +843,9 @@ } } - for (c_idx = 0; c_idx < (s->sps->chroma_format_idc ? 3 : 1); c_idx++) { - int log2_sao_offset_scale = c_idx == 0 ? s->pps->log2_sao_offset_scale_luma : - s->pps->log2_sao_offset_scale_chroma; + for (c_idx = 0; c_idx < (s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) { + int log2_sao_offset_scale = c_idx == 0 ? s->ps.pps->log2_sao_offset_scale_luma : + s->ps.pps->log2_sao_offset_scale_chroma; if (!s->sh.slice_sample_adaptive_offset_flag[c_idx]) { sao->type_idx[c_idx] = SAO_NOT_APPLIED; @@ -908,7 +919,7 @@ int blk_idx, int cbf_luma, int *cbf_cb, int *cbf_cr) { HEVCLocalContext *lc = s->HEVClc; - const int log2_trafo_size_c = log2_trafo_size - s->sps->hshift[1]; + const int log2_trafo_size_c = log2_trafo_size - s->ps.sps->hshift[1]; int i; if (lc->cu.pred_mode == MODE_INTRA) { @@ -919,28 +930,28 @@ } if (cbf_luma || cbf_cb[0] || cbf_cr[0] || - (s->sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) { + (s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) { int scan_idx = SCAN_DIAG; int scan_idx_c = SCAN_DIAG; int cbf_chroma = cbf_cb[0] || cbf_cr[0] || - (s->sps->chroma_format_idc == 2 && + (s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1])); - if (s->pps->cu_qp_delta_enabled_flag && !lc->tu.is_cu_qp_delta_coded) { + if (s->ps.pps->cu_qp_delta_enabled_flag && !lc->tu.is_cu_qp_delta_coded) { lc->tu.cu_qp_delta = ff_hevc_cu_qp_delta_abs(s); if (lc->tu.cu_qp_delta != 0) if (ff_hevc_cu_qp_delta_sign_flag(s) == 1) lc->tu.cu_qp_delta = -lc->tu.cu_qp_delta; lc->tu.is_cu_qp_delta_coded = 1; - if (lc->tu.cu_qp_delta < -(26 + s->sps->qp_bd_offset / 2) || - lc->tu.cu_qp_delta > (25 + s->sps->qp_bd_offset / 2)) { + if (lc->tu.cu_qp_delta < -(26 + s->ps.sps->qp_bd_offset / 2) || + lc->tu.cu_qp_delta > (25 + s->ps.sps->qp_bd_offset / 2)) { av_log(s->avctx, AV_LOG_ERROR, "The cu_qp_delta %d is outside the valid range " "[%d, %d].\n", lc->tu.cu_qp_delta, - -(26 + s->sps->qp_bd_offset / 2), - (25 + s->sps->qp_bd_offset / 2)); + -(26 + s->ps.sps->qp_bd_offset / 2), + (25 + s->ps.sps->qp_bd_offset / 2)); return AVERROR_INVALIDDATA; } @@ -952,13 +963,13 @@ int cu_chroma_qp_offset_flag = ff_hevc_cu_chroma_qp_offset_flag(s); if (cu_chroma_qp_offset_flag) { int cu_chroma_qp_offset_idx = 0; - if (s->pps->chroma_qp_offset_list_len_minus1 > 0) { + if (s->ps.pps->chroma_qp_offset_list_len_minus1 > 0) { cu_chroma_qp_offset_idx = ff_hevc_cu_chroma_qp_offset_idx(s); av_log(s->avctx, AV_LOG_ERROR, "cu_chroma_qp_offset_idx not yet tested.\n"); } - lc->tu.cu_qp_offset_cb = s->pps->cb_qp_offset_list[cu_chroma_qp_offset_idx]; - lc->tu.cu_qp_offset_cr = s->pps->cr_qp_offset_list[cu_chroma_qp_offset_idx]; + lc->tu.cu_qp_offset_cb = s->ps.pps->cb_qp_offset_list[cu_chroma_qp_offset_idx]; + lc->tu.cu_qp_offset_cr = s->ps.pps->cr_qp_offset_list[cu_chroma_qp_offset_idx]; } else { lc->tu.cu_qp_offset_cb = 0; lc->tu.cu_qp_offset_cr = 0; @@ -988,17 +999,17 @@ if (cbf_luma) ff_hevc_hls_residual_coding(s, x0, y0, log2_trafo_size, scan_idx, 0); - if (s->sps->chroma_format_idc && (log2_trafo_size > 2 || s->sps->chroma_format_idc == 3)) { - int trafo_size_h = 1 << (log2_trafo_size_c + s->sps->hshift[1]); - int trafo_size_v = 1 << (log2_trafo_size_c + s->sps->vshift[1]); - lc->tu.cross_pf = (s->pps->cross_component_prediction_enabled_flag && cbf_luma && + if (s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3)) { + int trafo_size_h = 1 << (log2_trafo_size_c + s->ps.sps->hshift[1]); + int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]); + lc->tu.cross_pf = (s->ps.pps->cross_component_prediction_enabled_flag && cbf_luma && (lc->cu.pred_mode == MODE_INTER || (lc->tu.chroma_mode_c == 4))); if (lc->tu.cross_pf) { hls_cross_component_pred(s, 0); } - for (i = 0; i < (s->sps->chroma_format_idc == 2 ? 2 : 1); i++) { + for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) { if (lc->cu.pred_mode == MODE_INTRA) { ff_hevc_set_neighbour_available(s, x0, y0 + (i << log2_trafo_size_c), trafo_size_h, trafo_size_v); s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0 + (i << log2_trafo_size_c), 1); @@ -1009,14 +1020,14 @@ else if (lc->tu.cross_pf) { ptrdiff_t stride = s->frame->linesize[1]; - int hshift = s->sps->hshift[1]; - int vshift = s->sps->vshift[1]; + int hshift = s->ps.sps->hshift[1]; + int vshift = s->ps.sps->vshift[1]; int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer; int16_t *coeffs = (int16_t*)lc->edge_emu_buffer2; int size = 1 << log2_trafo_size_c; uint8_t *dst = &s->frame->data[1][(y0 >> vshift) * stride + - ((x0 >> hshift) << s->sps->pixel_shift)]; + ((x0 >> hshift) << s->ps.sps->pixel_shift)]; for (i = 0; i < (size * size); i++) { coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3); } @@ -1027,7 +1038,7 @@ if (lc->tu.cross_pf) { hls_cross_component_pred(s, 1); } - for (i = 0; i < (s->sps->chroma_format_idc == 2 ? 2 : 1); i++) { + for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) { if (lc->cu.pred_mode == MODE_INTRA) { ff_hevc_set_neighbour_available(s, x0, y0 + (i << log2_trafo_size_c), trafo_size_h, trafo_size_v); s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0 + (i << log2_trafo_size_c), 2); @@ -1038,24 +1049,24 @@ else if (lc->tu.cross_pf) { ptrdiff_t stride = s->frame->linesize[2]; - int hshift = s->sps->hshift[2]; - int vshift = s->sps->vshift[2]; + int hshift = s->ps.sps->hshift[2]; + int vshift = s->ps.sps->vshift[2]; int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer; int16_t *coeffs = (int16_t*)lc->edge_emu_buffer2; int size = 1 << log2_trafo_size_c; uint8_t *dst = &s->frame->data[2][(y0 >> vshift) * stride + - ((x0 >> hshift) << s->sps->pixel_shift)]; + ((x0 >> hshift) << s->ps.sps->pixel_shift)]; for (i = 0; i < (size * size); i++) { coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3); } s->hevcdsp.transform_add[log2_trafo_size_c-2](dst, coeffs, stride); } } - } else if (s->sps->chroma_format_idc && blk_idx == 3) { + } else if (s->ps.sps->chroma_format_idc && blk_idx == 3) { int trafo_size_h = 1 << (log2_trafo_size + 1); - int trafo_size_v = 1 << (log2_trafo_size + s->sps->vshift[1]); - for (i = 0; i < (s->sps->chroma_format_idc == 2 ? 2 : 1); i++) { + int trafo_size_v = 1 << (log2_trafo_size + s->ps.sps->vshift[1]); + for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) { if (lc->cu.pred_mode == MODE_INTRA) { ff_hevc_set_neighbour_available(s, xBase, yBase + (i << log2_trafo_size), trafo_size_h, trafo_size_v); @@ -1065,7 +1076,7 @@ ff_hevc_hls_residual_coding(s, xBase, yBase + (i << log2_trafo_size), log2_trafo_size, scan_idx_c, 1); } - for (i = 0; i < (s->sps->chroma_format_idc == 2 ? 2 : 1); i++) { + for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) { if (lc->cu.pred_mode == MODE_INTRA) { ff_hevc_set_neighbour_available(s, xBase, yBase + (i << log2_trafo_size), trafo_size_h, trafo_size_v); @@ -1076,14 +1087,14 @@ log2_trafo_size, scan_idx_c, 2); } } - } else if (s->sps->chroma_format_idc && lc->cu.pred_mode == MODE_INTRA) { - if (log2_trafo_size > 2 || s->sps->chroma_format_idc == 3) { - int trafo_size_h = 1 << (log2_trafo_size_c + s->sps->hshift[1]); - int trafo_size_v = 1 << (log2_trafo_size_c + s->sps->vshift[1]); + } else if (s->ps.sps->chroma_format_idc && lc->cu.pred_mode == MODE_INTRA) { + if (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3) { + int trafo_size_h = 1 << (log2_trafo_size_c + s->ps.sps->hshift[1]); + int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]); ff_hevc_set_neighbour_available(s, x0, y0, trafo_size_h, trafo_size_v); s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0, 1); s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0, 2); - if (s->sps->chroma_format_idc == 2) { + if (s->ps.sps->chroma_format_idc == 2) { ff_hevc_set_neighbour_available(s, x0, y0 + (1 << log2_trafo_size_c), trafo_size_h, trafo_size_v); s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0 + (1 << log2_trafo_size_c), 1); @@ -1091,12 +1102,12 @@ } } else if (blk_idx == 3) { int trafo_size_h = 1 << (log2_trafo_size + 1); - int trafo_size_v = 1 << (log2_trafo_size + s->sps->vshift[1]); + int trafo_size_v = 1 << (log2_trafo_size + s->ps.sps->vshift[1]); ff_hevc_set_neighbour_available(s, xBase, yBase, trafo_size_h, trafo_size_v); s->hpc.intra_pred[log2_trafo_size - 2](s, xBase, yBase, 1); s->hpc.intra_pred[log2_trafo_size - 2](s, xBase, yBase, 2); - if (s->sps->chroma_format_idc == 2) { + if (s->ps.sps->chroma_format_idc == 2) { ff_hevc_set_neighbour_available(s, xBase, yBase + (1 << (log2_trafo_size)), trafo_size_h, trafo_size_v); s->hpc.intra_pred[log2_trafo_size - 2](s, xBase, yBase + (1 << (log2_trafo_size)), 1); @@ -1111,11 +1122,11 @@ static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_size) { int cb_size = 1 << log2_cb_size; - int log2_min_pu_size = s->sps->log2_min_pu_size; + int log2_min_pu_size = s->ps.sps->log2_min_pu_size; - int min_pu_width = s->sps->min_pu_width; - int x_end = FFMIN(x0 + cb_size, s->sps->width); - int y_end = FFMIN(y0 + cb_size, s->sps->height); + int min_pu_width = s->ps.sps->min_pu_width; + int x_end = FFMIN(x0 + cb_size, s->ps.sps->width); + int y_end = FFMIN(y0 + cb_size, s->ps.sps->height); int i, j; for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++) @@ -1143,7 +1154,7 @@ if (lc->cu.intra_split_flag) { if (trafo_depth == 1) { lc->tu.intra_pred_mode = lc->pu.intra_pred_mode[blk_idx]; - if (s->sps->chroma_format_idc == 3) { + if (s->ps.sps->chroma_format_idc == 3) { lc->tu.intra_pred_mode_c = lc->pu.intra_pred_mode_c[blk_idx]; lc->tu.chroma_mode_c = lc->pu.chroma_mode_c[blk_idx]; } else { @@ -1157,33 +1168,33 @@ lc->tu.chroma_mode_c = lc->pu.chroma_mode_c[0]; } - if (log2_trafo_size <= s->sps->log2_max_trafo_size && - log2_trafo_size > s->sps->log2_min_tb_size && + if (log2_trafo_size <= s->ps.sps->log2_max_trafo_size && + log2_trafo_size > s->ps.sps->log2_min_tb_size && trafo_depth < lc->cu.max_trafo_depth && !(lc->cu.intra_split_flag && trafo_depth == 0)) { split_transform_flag = ff_hevc_split_transform_flag_decode(s, log2_trafo_size); } else { - int inter_split = s->sps->max_transform_hierarchy_depth_inter == 0 && + int inter_split = s->ps.sps->max_transform_hierarchy_depth_inter == 0 && lc->cu.pred_mode == MODE_INTER && lc->cu.part_mode != PART_2Nx2N && trafo_depth == 0; - split_transform_flag = log2_trafo_size > s->sps->log2_max_trafo_size || + split_transform_flag = log2_trafo_size > s->ps.sps->log2_max_trafo_size || (lc->cu.intra_split_flag && trafo_depth == 0) || inter_split; } - if (s->sps->chroma_format_idc && (log2_trafo_size > 2 || s->sps->chroma_format_idc == 3)) { + if (s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3)) { if (trafo_depth == 0 || cbf_cb[0]) { cbf_cb[0] = ff_hevc_cbf_cb_cr_decode(s, trafo_depth); - if (s->sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) { + if (s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) { cbf_cb[1] = ff_hevc_cbf_cb_cr_decode(s, trafo_depth); } } if (trafo_depth == 0 || cbf_cr[0]) { cbf_cr[0] = ff_hevc_cbf_cb_cr_decode(s, trafo_depth); - if (s->sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) { + if (s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) { cbf_cr[1] = ff_hevc_cbf_cb_cr_decode(s, trafo_depth); } } @@ -1210,14 +1221,14 @@ #undef SUBDIVIDE } else { - int min_tu_size = 1 << s->sps->log2_min_tb_size; - int log2_min_tu_size = s->sps->log2_min_tb_size; - int min_tu_width = s->sps->min_tb_width; + int min_tu_size = 1 << s->ps.sps->log2_min_tb_size; + int log2_min_tu_size = s->ps.sps->log2_min_tb_size; + int min_tu_width = s->ps.sps->min_tb_width; int cbf_luma = 1; if (lc->cu.pred_mode == MODE_INTRA || trafo_depth != 0 || cbf_cb[0] || cbf_cr[0] || - (s->sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) { + (s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) { cbf_luma = ff_hevc_cbf_luma_decode(s, trafo_depth); } @@ -1238,7 +1249,7 @@ } if (!s->sh.disable_deblocking_filter_flag) { ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_trafo_size); - if (s->pps->transquant_bypass_enable_flag && + if (s->ps.pps->transquant_bypass_enable_flag && lc->cu.cu_transquant_bypass_flag) set_deblocking_bypass(s, x0, y0, log2_trafo_size); } @@ -1252,16 +1263,16 @@ GetBitContext gb; int cb_size = 1 << log2_cb_size; int stride0 = s->frame->linesize[0]; - uint8_t *dst0 = &s->frame->data[0][y0 * stride0 + (x0 << s->sps->pixel_shift)]; + uint8_t *dst0 = &s->frame->data[0][y0 * stride0 + (x0 << s->ps.sps->pixel_shift)]; int stride1 = s->frame->linesize[1]; - uint8_t *dst1 = &s->frame->data[1][(y0 >> s->sps->vshift[1]) * stride1 + ((x0 >> s->sps->hshift[1]) << s->sps->pixel_shift)]; + uint8_t *dst1 = &s->frame->data[1][(y0 >> s->ps.sps->vshift[1]) * stride1 + ((x0 >> s->ps.sps->hshift[1]) << s->ps.sps->pixel_shift)]; int stride2 = s->frame->linesize[2]; - uint8_t *dst2 = &s->frame->data[2][(y0 >> s->sps->vshift[2]) * stride2 + ((x0 >> s->sps->hshift[2]) << s->sps->pixel_shift)]; + uint8_t *dst2 = &s->frame->data[2][(y0 >> s->ps.sps->vshift[2]) * stride2 + ((x0 >> s->ps.sps->hshift[2]) << s->ps.sps->pixel_shift)]; - int length = cb_size * cb_size * s->sps->pcm.bit_depth + - (((cb_size >> s->sps->hshift[1]) * (cb_size >> s->sps->vshift[1])) + - ((cb_size >> s->sps->hshift[2]) * (cb_size >> s->sps->vshift[2]))) * - s->sps->pcm.bit_depth_chroma; + int length = cb_size * cb_size * s->ps.sps->pcm.bit_depth + + (((cb_size >> s->ps.sps->hshift[1]) * (cb_size >> s->ps.sps->vshift[1])) + + ((cb_size >> s->ps.sps->hshift[2]) * (cb_size >> s->ps.sps->vshift[2]))) * + s->ps.sps->pcm.bit_depth_chroma; const uint8_t *pcm = skip_bytes(&lc->cc, (length + 7) >> 3); int ret; @@ -1272,16 +1283,16 @@ if (ret < 0) return ret; - s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb, s->sps->pcm.bit_depth); - if (s->sps->chroma_format_idc) { + s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb, s->ps.sps->pcm.bit_depth); + if (s->ps.sps->chroma_format_idc) { s->hevcdsp.put_pcm(dst1, stride1, - cb_size >> s->sps->hshift[1], - cb_size >> s->sps->vshift[1], - &gb, s->sps->pcm.bit_depth_chroma); + cb_size >> s->ps.sps->hshift[1], + cb_size >> s->ps.sps->vshift[1], + &gb, s->ps.sps->pcm.bit_depth_chroma); s->hevcdsp.put_pcm(dst2, stride2, - cb_size >> s->sps->hshift[2], - cb_size >> s->sps->vshift[2], - &gb, s->sps->pcm.bit_depth_chroma); + cb_size >> s->ps.sps->hshift[2], + cb_size >> s->ps.sps->vshift[2], + &gb, s->ps.sps->pcm.bit_depth_chroma); } return 0; @@ -1310,24 +1321,24 @@ HEVCLocalContext *lc = s->HEVClc; uint8_t *src = ref->data[0]; ptrdiff_t srcstride = ref->linesize[0]; - int pic_width = s->sps->width; - int pic_height = s->sps->height; + int pic_width = s->ps.sps->width; + int pic_height = s->ps.sps->height; int mx = mv->x & 3; int my = mv->y & 3; - int weight_flag = (s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || - (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag); + int weight_flag = (s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) || + (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag); int idx = ff_hevc_pel_weight[block_w]; x_off += mv->x >> 2; y_off += mv->y >> 2; - src += y_off * srcstride + x_off * (1 << s->sps->pixel_shift); + src += y_off * srcstride + x_off * (1 << s->ps.sps->pixel_shift); if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER || x_off >= pic_width - block_w - QPEL_EXTRA_AFTER || y_off >= pic_height - block_h - QPEL_EXTRA_AFTER) { - const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift; - int offset = QPEL_EXTRA_BEFORE * srcstride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift); - int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift); + const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; + int offset = QPEL_EXTRA_BEFORE * srcstride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); + int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src - offset, edge_emu_stride, srcstride, @@ -1371,29 +1382,29 @@ HEVCLocalContext *lc = s->HEVClc; ptrdiff_t src0stride = ref0->linesize[0]; ptrdiff_t src1stride = ref1->linesize[0]; - int pic_width = s->sps->width; - int pic_height = s->sps->height; + int pic_width = s->ps.sps->width; + int pic_height = s->ps.sps->height; int mx0 = mv0->x & 3; int my0 = mv0->y & 3; int mx1 = mv1->x & 3; int my1 = mv1->y & 3; - int weight_flag = (s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || - (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag); + int weight_flag = (s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) || + (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag); int x_off0 = x_off + (mv0->x >> 2); int y_off0 = y_off + (mv0->y >> 2); int x_off1 = x_off + (mv1->x >> 2); int y_off1 = y_off + (mv1->y >> 2); int idx = ff_hevc_pel_weight[block_w]; - uint8_t *src0 = ref0->data[0] + y_off0 * src0stride + (int)((unsigned)x_off0 << s->sps->pixel_shift); - uint8_t *src1 = ref1->data[0] + y_off1 * src1stride + (int)((unsigned)x_off1 << s->sps->pixel_shift); + uint8_t *src0 = ref0->data[0] + y_off0 * src0stride + (int)((unsigned)x_off0 << s->ps.sps->pixel_shift); + uint8_t *src1 = ref1->data[0] + y_off1 * src1stride + (int)((unsigned)x_off1 << s->ps.sps->pixel_shift); if (x_off0 < QPEL_EXTRA_BEFORE || y_off0 < QPEL_EXTRA_AFTER || x_off0 >= pic_width - block_w - QPEL_EXTRA_AFTER || y_off0 >= pic_height - block_h - QPEL_EXTRA_AFTER) { - const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift; - int offset = QPEL_EXTRA_BEFORE * src0stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift); - int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift); + const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; + int offset = QPEL_EXTRA_BEFORE * src0stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); + int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src0 - offset, edge_emu_stride, src0stride, @@ -1408,9 +1419,9 @@ if (x_off1 < QPEL_EXTRA_BEFORE || y_off1 < QPEL_EXTRA_AFTER || x_off1 >= pic_width - block_w - QPEL_EXTRA_AFTER || y_off1 >= pic_height - block_h - QPEL_EXTRA_AFTER) { - const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift; - int offset = QPEL_EXTRA_BEFORE * src1stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift); - int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift); + const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; + int offset = QPEL_EXTRA_BEFORE * src1stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); + int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); s->vdsp.emulated_edge_mc(lc->edge_emu_buffer2, src1 - offset, edge_emu_stride, src1stride, @@ -1460,14 +1471,14 @@ int x_off, int y_off, int block_w, int block_h, struct MvField *current_mv, int chroma_weight, int chroma_offset) { HEVCLocalContext *lc = s->HEVClc; - int pic_width = s->sps->width >> s->sps->hshift[1]; - int pic_height = s->sps->height >> s->sps->vshift[1]; + int pic_width = s->ps.sps->width >> s->ps.sps->hshift[1]; + int pic_height = s->ps.sps->height >> s->ps.sps->vshift[1]; const Mv *mv = ¤t_mv->mv[reflist]; - int weight_flag = (s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || - (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag); + int weight_flag = (s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) || + (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag); int idx = ff_hevc_pel_weight[block_w]; - int hshift = s->sps->hshift[1]; - int vshift = s->sps->vshift[1]; + int hshift = s->ps.sps->hshift[1]; + int vshift = s->ps.sps->vshift[1]; intptr_t mx = av_mod_uintp2(mv->x, 2 + hshift); intptr_t my = av_mod_uintp2(mv->y, 2 + vshift); intptr_t _mx = mx << (1 - hshift); @@ -1475,15 +1486,15 @@ x_off += mv->x >> (2 + hshift); y_off += mv->y >> (2 + vshift); - src0 += y_off * srcstride + x_off * (1 << s->sps->pixel_shift); + src0 += y_off * srcstride + x_off * (1 << s->ps.sps->pixel_shift); if (x_off < EPEL_EXTRA_BEFORE || y_off < EPEL_EXTRA_AFTER || x_off >= pic_width - block_w - EPEL_EXTRA_AFTER || y_off >= pic_height - block_h - EPEL_EXTRA_AFTER) { - const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift; - int offset0 = EPEL_EXTRA_BEFORE * (srcstride + (1 << s->sps->pixel_shift)); + const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; + int offset0 = EPEL_EXTRA_BEFORE * (srcstride + (1 << s->ps.sps->pixel_shift)); int buf_offset0 = EPEL_EXTRA_BEFORE * - (edge_emu_stride + (1 << s->sps->pixel_shift)); + (edge_emu_stride + (1 << s->ps.sps->pixel_shift)); s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src0 - offset0, edge_emu_stride, srcstride, block_w + EPEL_EXTRA, block_h + EPEL_EXTRA, @@ -1528,14 +1539,14 @@ uint8_t *src2 = ref1->data[cidx+1]; ptrdiff_t src1stride = ref0->linesize[cidx+1]; ptrdiff_t src2stride = ref1->linesize[cidx+1]; - int weight_flag = (s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || - (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag); - int pic_width = s->sps->width >> s->sps->hshift[1]; - int pic_height = s->sps->height >> s->sps->vshift[1]; + int weight_flag = (s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) || + (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag); + int pic_width = s->ps.sps->width >> s->ps.sps->hshift[1]; + int pic_height = s->ps.sps->height >> s->ps.sps->vshift[1]; Mv *mv0 = ¤t_mv->mv[0]; Mv *mv1 = ¤t_mv->mv[1]; - int hshift = s->sps->hshift[1]; - int vshift = s->sps->vshift[1]; + int hshift = s->ps.sps->hshift[1]; + int vshift = s->ps.sps->vshift[1]; intptr_t mx0 = av_mod_uintp2(mv0->x, 2 + hshift); intptr_t my0 = av_mod_uintp2(mv0->y, 2 + vshift); @@ -1551,16 +1562,16 @@ int x_off1 = x_off + (mv1->x >> (2 + hshift)); int y_off1 = y_off + (mv1->y >> (2 + vshift)); int idx = ff_hevc_pel_weight[block_w]; - src1 += y_off0 * src1stride + (int)((unsigned)x_off0 << s->sps->pixel_shift); - src2 += y_off1 * src2stride + (int)((unsigned)x_off1 << s->sps->pixel_shift); + src1 += y_off0 * src1stride + (int)((unsigned)x_off0 << s->ps.sps->pixel_shift); + src2 += y_off1 * src2stride + (int)((unsigned)x_off1 << s->ps.sps->pixel_shift); if (x_off0 < EPEL_EXTRA_BEFORE || y_off0 < EPEL_EXTRA_AFTER || x_off0 >= pic_width - block_w - EPEL_EXTRA_AFTER || y_off0 >= pic_height - block_h - EPEL_EXTRA_AFTER) { - const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift; - int offset1 = EPEL_EXTRA_BEFORE * (src1stride + (1 << s->sps->pixel_shift)); + const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; + int offset1 = EPEL_EXTRA_BEFORE * (src1stride + (1 << s->ps.sps->pixel_shift)); int buf_offset1 = EPEL_EXTRA_BEFORE * - (edge_emu_stride + (1 << s->sps->pixel_shift)); + (edge_emu_stride + (1 << s->ps.sps->pixel_shift)); s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src1 - offset1, edge_emu_stride, src1stride, @@ -1576,10 +1587,10 @@ if (x_off1 < EPEL_EXTRA_BEFORE || y_off1 < EPEL_EXTRA_AFTER || x_off1 >= pic_width - block_w - EPEL_EXTRA_AFTER || y_off1 >= pic_height - block_h - EPEL_EXTRA_AFTER) { - const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift; - int offset1 = EPEL_EXTRA_BEFORE * (src2stride + (1 << s->sps->pixel_shift)); + const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; + int offset1 = EPEL_EXTRA_BEFORE * (src2stride + (1 << s->ps.sps->pixel_shift)); int buf_offset1 = EPEL_EXTRA_BEFORE * - (edge_emu_stride + (1 << s->sps->pixel_shift)); + (edge_emu_stride + (1 << s->ps.sps->pixel_shift)); s->vdsp.emulated_edge_mc(lc->edge_emu_buffer2, src2 - offset1, edge_emu_stride, src2stride, @@ -1669,13 +1680,13 @@ int log2_cb_size, int partIdx, int idx) { #define POS(c_idx, x, y) \ - &s->frame->data[c_idx][((y) >> s->sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \ - (((x) >> s->sps->hshift[c_idx]) << s->sps->pixel_shift)] + &s->frame->data[c_idx][((y) >> s->ps.sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \ + (((x) >> s->ps.sps->hshift[c_idx]) << s->ps.sps->pixel_shift)] HEVCLocalContext *lc = s->HEVClc; int merge_idx = 0; struct MvField current_mv = {{{ 0 }}}; - int min_pu_width = s->sps->min_pu_width; + int min_pu_width = s->ps.sps->min_pu_width; MvField *tab_mvf = s->ref->tab_mvf; RefPicList *refPicList = s->ref->refPicList; @@ -1683,8 +1694,8 @@ uint8_t *dst0 = POS(0, x0, y0); uint8_t *dst1 = POS(1, x0, y0); uint8_t *dst2 = POS(2, x0, y0); - int log2_min_cb_size = s->sps->log2_min_cb_size; - int min_cb_width = s->sps->min_cb_width; + int log2_min_cb_size = s->ps.sps->log2_min_cb_size; + int min_cb_width = s->ps.sps->min_cb_width; int x_cb = x0 >> log2_min_cb_size; int y_cb = y0 >> log2_min_cb_size; int x_pu, y_pu; @@ -1708,11 +1719,11 @@ partIdx, merge_idx, ¤t_mv); } - x_pu = x0 >> s->sps->log2_min_pu_size; - y_pu = y0 >> s->sps->log2_min_pu_size; + x_pu = x0 >> s->ps.sps->log2_min_pu_size; + y_pu = y0 >> s->ps.sps->log2_min_pu_size; - for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++) - for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++) + for (j = 0; j < nPbH >> s->ps.sps->log2_min_pu_size; j++) + for (i = 0; i < nPbW >> s->ps.sps->log2_min_pu_size; i++) tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv; if (current_mv.pred_flag & PF_L0) { @@ -1729,17 +1740,17 @@ } if (current_mv.pred_flag == PF_L0) { - int x0_c = x0 >> s->sps->hshift[1]; - int y0_c = y0 >> s->sps->vshift[1]; - int nPbW_c = nPbW >> s->sps->hshift[1]; - int nPbH_c = nPbH >> s->sps->vshift[1]; + int x0_c = x0 >> s->ps.sps->hshift[1]; + int y0_c = y0 >> s->ps.sps->vshift[1]; + int nPbW_c = nPbW >> s->ps.sps->hshift[1]; + int nPbH_c = nPbH >> s->ps.sps->vshift[1]; luma_mc_uni(s, dst0, s->frame->linesize[0], ref0->frame, ¤t_mv.mv[0], x0, y0, nPbW, nPbH, s->sh.luma_weight_l0[current_mv.ref_idx[0]], s->sh.luma_offset_l0[current_mv.ref_idx[0]]); - if (s->sps->chroma_format_idc) { + if (s->ps.sps->chroma_format_idc) { chroma_mc_uni(s, dst1, s->frame->linesize[1], ref0->frame->data[1], ref0->frame->linesize[1], 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0]); @@ -1748,17 +1759,17 @@ s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1]); } } else if (current_mv.pred_flag == PF_L1) { - int x0_c = x0 >> s->sps->hshift[1]; - int y0_c = y0 >> s->sps->vshift[1]; - int nPbW_c = nPbW >> s->sps->hshift[1]; - int nPbH_c = nPbH >> s->sps->vshift[1]; + int x0_c = x0 >> s->ps.sps->hshift[1]; + int y0_c = y0 >> s->ps.sps->vshift[1]; + int nPbW_c = nPbW >> s->ps.sps->hshift[1]; + int nPbH_c = nPbH >> s->ps.sps->vshift[1]; luma_mc_uni(s, dst0, s->frame->linesize[0], ref1->frame, ¤t_mv.mv[1], x0, y0, nPbW, nPbH, s->sh.luma_weight_l1[current_mv.ref_idx[1]], s->sh.luma_offset_l1[current_mv.ref_idx[1]]); - if (s->sps->chroma_format_idc) { + if (s->ps.sps->chroma_format_idc) { chroma_mc_uni(s, dst1, s->frame->linesize[1], ref1->frame->data[1], ref1->frame->linesize[1], 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0]); @@ -1768,16 +1779,16 @@ s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1]); } } else if (current_mv.pred_flag == PF_BI) { - int x0_c = x0 >> s->sps->hshift[1]; - int y0_c = y0 >> s->sps->vshift[1]; - int nPbW_c = nPbW >> s->sps->hshift[1]; - int nPbH_c = nPbH >> s->sps->vshift[1]; + int x0_c = x0 >> s->ps.sps->hshift[1]; + int y0_c = y0 >> s->ps.sps->vshift[1]; + int nPbW_c = nPbW >> s->ps.sps->hshift[1]; + int nPbH_c = nPbH >> s->ps.sps->vshift[1]; luma_mc_bi(s, dst0, s->frame->linesize[0], ref0->frame, ¤t_mv.mv[0], x0, y0, nPbW, nPbH, ref1->frame, ¤t_mv.mv[1], ¤t_mv); - if (s->sps->chroma_format_idc) { + if (s->ps.sps->chroma_format_idc) { chroma_mc_bi(s, dst1, s->frame->linesize[1], ref0->frame, ref1->frame, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0); @@ -1794,19 +1805,19 @@ int prev_intra_luma_pred_flag) { HEVCLocalContext *lc = s->HEVClc; - int x_pu = x0 >> s->sps->log2_min_pu_size; - int y_pu = y0 >> s->sps->log2_min_pu_size; - int min_pu_width = s->sps->min_pu_width; - int size_in_pus = pu_size >> s->sps->log2_min_pu_size; - int x0b = av_mod_uintp2(x0, s->sps->log2_ctb_size); - int y0b = av_mod_uintp2(y0, s->sps->log2_ctb_size); + int x_pu = x0 >> s->ps.sps->log2_min_pu_size; + int y_pu = y0 >> s->ps.sps->log2_min_pu_size; + int min_pu_width = s->ps.sps->min_pu_width; + int size_in_pus = pu_size >> s->ps.sps->log2_min_pu_size; + int x0b = av_mod_uintp2(x0, s->ps.sps->log2_ctb_size); + int y0b = av_mod_uintp2(y0, s->ps.sps->log2_ctb_size); int cand_up = (lc->ctb_up_flag || y0b) ? s->tab_ipm[(y_pu - 1) * min_pu_width + x_pu] : INTRA_DC; int cand_left = (lc->ctb_left_flag || x0b) ? s->tab_ipm[y_pu * min_pu_width + x_pu - 1] : INTRA_DC; - int y_ctb = (y0 >> (s->sps->log2_ctb_size)) << (s->sps->log2_ctb_size); + int y_ctb = (y0 >> (s->ps.sps->log2_ctb_size)) << (s->ps.sps->log2_ctb_size); MvField *tab_mvf = s->ref->tab_mvf; int intra_pred_mode; @@ -1873,13 +1884,13 @@ static av_always_inline void set_ct_depth(HEVCContext *s, int x0, int y0, int log2_cb_size, int ct_depth) { - int length = (1 << log2_cb_size) >> s->sps->log2_min_cb_size; - int x_cb = x0 >> s->sps->log2_min_cb_size; - int y_cb = y0 >> s->sps->log2_min_cb_size; + int length = (1 << log2_cb_size) >> s->ps.sps->log2_min_cb_size; + int x_cb = x0 >> s->ps.sps->log2_min_cb_size; + int y_cb = y0 >> s->ps.sps->log2_min_cb_size; int y; for (y = 0; y < length; y++) - memset(&s->tab_ct_depth[(y_cb + y) * s->sps->min_cb_width + x_cb], + memset(&s->tab_ct_depth[(y_cb + y) * s->ps.sps->min_cb_width + x_cb], ct_depth, length); } @@ -1916,7 +1927,7 @@ } } - if (s->sps->chroma_format_idc == 3) { + if (s->ps.sps->chroma_format_idc == 3) { for (i = 0; i < side; i++) { for (j = 0; j < side; j++) { lc->pu.chroma_mode_c[2 * i + j] = chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(s); @@ -1930,7 +1941,7 @@ } } } - } else if (s->sps->chroma_format_idc == 2) { + } else if (s->ps.sps->chroma_format_idc == 2) { int mode_idx; lc->pu.chroma_mode_c[0] = chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(s); if (chroma_mode != 4) { @@ -1942,7 +1953,7 @@ mode_idx = lc->pu.intra_pred_mode[0]; } lc->pu.intra_pred_mode_c[0] = tab_mode_idx[mode_idx]; - } else if (s->sps->chroma_format_idc != 0) { + } else if (s->ps.sps->chroma_format_idc != 0) { chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(s); if (chroma_mode != 4) { if (lc->pu.intra_pred_mode[0] == intra_chroma_table[chroma_mode]) @@ -1961,11 +1972,11 @@ { HEVCLocalContext *lc = s->HEVClc; int pb_size = 1 << log2_cb_size; - int size_in_pus = pb_size >> s->sps->log2_min_pu_size; - int min_pu_width = s->sps->min_pu_width; + int size_in_pus = pb_size >> s->ps.sps->log2_min_pu_size; + int min_pu_width = s->ps.sps->min_pu_width; MvField *tab_mvf = s->ref->tab_mvf; - int x_pu = x0 >> s->sps->log2_min_pu_size; - int y_pu = y0 >> s->sps->log2_min_pu_size; + int x_pu = x0 >> s->ps.sps->log2_min_pu_size; + int y_pu = y0 >> s->ps.sps->log2_min_pu_size; int j, k; if (size_in_pus == 0) @@ -1982,13 +1993,13 @@ { int cb_size = 1 << log2_cb_size; HEVCLocalContext *lc = s->HEVClc; - int log2_min_cb_size = s->sps->log2_min_cb_size; + int log2_min_cb_size = s->ps.sps->log2_min_cb_size; int length = cb_size >> log2_min_cb_size; - int min_cb_width = s->sps->min_cb_width; + int min_cb_width = s->ps.sps->min_cb_width; int x_cb = x0 >> log2_min_cb_size; int y_cb = y0 >> log2_min_cb_size; int idx = log2_cb_size - 2; - int qp_block_mask = (1<<(s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1; + int qp_block_mask = (1<<(s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth)) - 1; int x, y, ret; lc->cu.x = x0; @@ -2000,7 +2011,7 @@ SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0; for (x = 0; x < 4; x++) lc->pu.intra_pred_mode[x] = 1; - if (s->pps->transquant_bypass_enable_flag) { + if (s->ps.pps->transquant_bypass_enable_flag) { lc->cu.cu_transquant_bypass_flag = ff_hevc_cu_transquant_bypass_flag_decode(s); if (lc->cu.cu_transquant_bypass_flag) set_deblocking_bypass(s, x0, y0, log2_cb_size); @@ -2036,22 +2047,22 @@ if (s->sh.slice_type != I_SLICE) lc->cu.pred_mode = ff_hevc_pred_mode_decode(s); if (lc->cu.pred_mode != MODE_INTRA || - log2_cb_size == s->sps->log2_min_cb_size) { + log2_cb_size == s->ps.sps->log2_min_cb_size) { lc->cu.part_mode = ff_hevc_part_mode_decode(s, log2_cb_size); lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN && lc->cu.pred_mode == MODE_INTRA; } if (lc->cu.pred_mode == MODE_INTRA) { - if (lc->cu.part_mode == PART_2Nx2N && s->sps->pcm_enabled_flag && - log2_cb_size >= s->sps->pcm.log2_min_pcm_cb_size && - log2_cb_size <= s->sps->pcm.log2_max_pcm_cb_size) { + if (lc->cu.part_mode == PART_2Nx2N && s->ps.sps->pcm_enabled_flag && + log2_cb_size >= s->ps.sps->pcm.log2_min_pcm_cb_size && + log2_cb_size <= s->ps.sps->pcm.log2_max_pcm_cb_size) { pcm_flag = ff_hevc_pcm_flag_decode(s); } if (pcm_flag) { intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); ret = hls_pcm_sample(s, x0, y0, log2_cb_size); - if (s->sps->pcm.loop_filter_disable_flag) + if (s->ps.sps->pcm.loop_filter_disable_flag) set_deblocking_bypass(s, x0, y0, log2_cb_size); if (ret < 0) @@ -2108,8 +2119,8 @@ if (rqt_root_cbf) { const static int cbf[2] = { 0 }; lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ? - s->sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag : - s->sps->max_transform_hierarchy_depth_inter; + s->ps.sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag : + s->ps.sps->max_transform_hierarchy_depth_inter; ret = hls_transform_tree(s, x0, y0, x0, y0, x0, y0, log2_cb_size, log2_cb_size, 0, 0, cbf, cbf); @@ -2122,7 +2133,7 @@ } } - if (s->pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0) + if (s->ps.pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0) ff_hevc_set_qPy(s, x0, y0, log2_cb_size); x = y_cb * min_cb_width + x_cb; @@ -2150,26 +2161,26 @@ int split_cu; lc->ct_depth = cb_depth; - if (x0 + cb_size <= s->sps->width && - y0 + cb_size <= s->sps->height && - log2_cb_size > s->sps->log2_min_cb_size) { + if (x0 + cb_size <= s->ps.sps->width && + y0 + cb_size <= s->ps.sps->height && + log2_cb_size > s->ps.sps->log2_min_cb_size) { split_cu = ff_hevc_split_coding_unit_flag_decode(s, cb_depth, x0, y0); } else { - split_cu = (log2_cb_size > s->sps->log2_min_cb_size); + split_cu = (log2_cb_size > s->ps.sps->log2_min_cb_size); } - if (s->pps->cu_qp_delta_enabled_flag && - log2_cb_size >= s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth) { + if (s->ps.pps->cu_qp_delta_enabled_flag && + log2_cb_size >= s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth) { lc->tu.is_cu_qp_delta_coded = 0; lc->tu.cu_qp_delta = 0; } if (s->sh.cu_chroma_qp_offset_enabled_flag && - log2_cb_size >= s->sps->log2_ctb_size - s->pps->diff_cu_chroma_qp_offset_depth) { + log2_cb_size >= s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_chroma_qp_offset_depth) { lc->tu.is_cu_chroma_qp_offset_coded = 0; } if (split_cu) { - int qp_block_mask = (1<<(s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1; + int qp_block_mask = (1<<(s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth)) - 1; const int cb_size_split = cb_size >> 1; const int x1 = x0 + cb_size_split; const int y1 = y0 + cb_size_split; @@ -2180,18 +2191,18 @@ if (more_data < 0) return more_data; - if (more_data && x1 < s->sps->width) { + if (more_data && x1 < s->ps.sps->width) { more_data = hls_coding_quadtree(s, x1, y0, log2_cb_size - 1, cb_depth + 1); if (more_data < 0) return more_data; } - if (more_data && y1 < s->sps->height) { + if (more_data && y1 < s->ps.sps->height) { more_data = hls_coding_quadtree(s, x0, y1, log2_cb_size - 1, cb_depth + 1); if (more_data < 0) return more_data; } - if (more_data && x1 < s->sps->width && - y1 < s->sps->height) { + if (more_data && x1 < s->ps.sps->width && + y1 < s->ps.sps->height) { more_data = hls_coding_quadtree(s, x1, y1, log2_cb_size - 1, cb_depth + 1); if (more_data < 0) return more_data; @@ -2202,8 +2213,8 @@ lc->qPy_pred = lc->qp_y; if (more_data) - return ((x1 + cb_size_split) < s->sps->width || - (y1 + cb_size_split) < s->sps->height); + return ((x1 + cb_size_split) < s->ps.sps->width || + (y1 + cb_size_split) < s->ps.sps->height); else return 0; } else { @@ -2211,11 +2222,11 @@ if (ret < 0) return ret; if ((!((x0 + cb_size) % - (1 << (s->sps->log2_ctb_size))) || - (x0 + cb_size >= s->sps->width)) && + (1 << (s->ps.sps->log2_ctb_size))) || + (x0 + cb_size >= s->ps.sps->width)) && (!((y0 + cb_size) % - (1 << (s->sps->log2_ctb_size))) || - (y0 + cb_size >= s->sps->height))) { + (1 << (s->ps.sps->log2_ctb_size))) || + (y0 + cb_size >= s->ps.sps->height))) { int end_of_slice_flag = ff_hevc_end_of_slice_flag_decode(s); return !end_of_slice_flag; } else { @@ -2230,59 +2241,59 @@ int ctb_addr_ts) { HEVCLocalContext *lc = s->HEVClc; - int ctb_size = 1 << s->sps->log2_ctb_size; - int ctb_addr_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts]; + int ctb_size = 1 << s->ps.sps->log2_ctb_size; + int ctb_addr_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts]; int ctb_addr_in_slice = ctb_addr_rs - s->sh.slice_addr; s->tab_slice_address[ctb_addr_rs] = s->sh.slice_addr; - if (s->pps->entropy_coding_sync_enabled_flag) { + if (s->ps.pps->entropy_coding_sync_enabled_flag) { if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0) lc->first_qp_group = 1; - lc->end_of_tiles_x = s->sps->width; - } else if (s->pps->tiles_enabled_flag) { - if (ctb_addr_ts && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[ctb_addr_ts - 1]) { - int idxX = s->pps->col_idxX[x_ctb >> s->sps->log2_ctb_size]; - lc->end_of_tiles_x = x_ctb + (s->pps->column_width[idxX] << s->sps->log2_ctb_size); + lc->end_of_tiles_x = s->ps.sps->width; + } else if (s->ps.pps->tiles_enabled_flag) { + if (ctb_addr_ts && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]) { + int idxX = s->ps.pps->col_idxX[x_ctb >> s->ps.sps->log2_ctb_size]; + lc->end_of_tiles_x = x_ctb + (s->ps.pps->column_width[idxX] << s->ps.sps->log2_ctb_size); lc->first_qp_group = 1; } } else { - lc->end_of_tiles_x = s->sps->width; + lc->end_of_tiles_x = s->ps.sps->width; } - lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, s->sps->height); + lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, s->ps.sps->height); lc->boundary_flags = 0; - if (s->pps->tiles_enabled_flag) { - if (x_ctb > 0 && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs - 1]]) + if (s->ps.pps->tiles_enabled_flag) { + if (x_ctb > 0 && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs - 1]]) lc->boundary_flags |= BOUNDARY_LEFT_TILE; if (x_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - 1]) lc->boundary_flags |= BOUNDARY_LEFT_SLICE; - if (y_ctb > 0 && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs - s->sps->ctb_width]]) + if (y_ctb > 0 && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs - s->ps.sps->ctb_width]]) lc->boundary_flags |= BOUNDARY_UPPER_TILE; - if (y_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - s->sps->ctb_width]) + if (y_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - s->ps.sps->ctb_width]) lc->boundary_flags |= BOUNDARY_UPPER_SLICE; } else { if (ctb_addr_in_slice <= 0) lc->boundary_flags |= BOUNDARY_LEFT_SLICE; - if (ctb_addr_in_slice < s->sps->ctb_width) + if (ctb_addr_in_slice < s->ps.sps->ctb_width) lc->boundary_flags |= BOUNDARY_UPPER_SLICE; } lc->ctb_left_flag = ((x_ctb > 0) && (ctb_addr_in_slice > 0) && !(lc->boundary_flags & BOUNDARY_LEFT_TILE)); - lc->ctb_up_flag = ((y_ctb > 0) && (ctb_addr_in_slice >= s->sps->ctb_width) && !(lc->boundary_flags & BOUNDARY_UPPER_TILE)); - lc->ctb_up_right_flag = ((y_ctb > 0) && (ctb_addr_in_slice+1 >= s->sps->ctb_width) && (s->pps->tile_id[ctb_addr_ts] == s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs+1 - s->sps->ctb_width]])); - lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0) && (ctb_addr_in_slice-1 >= s->sps->ctb_width) && (s->pps->tile_id[ctb_addr_ts] == s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - s->sps->ctb_width]])); + lc->ctb_up_flag = ((y_ctb > 0) && (ctb_addr_in_slice >= s->ps.sps->ctb_width) && !(lc->boundary_flags & BOUNDARY_UPPER_TILE)); + lc->ctb_up_right_flag = ((y_ctb > 0) && (ctb_addr_in_slice+1 >= s->ps.sps->ctb_width) && (s->ps.pps->tile_id[ctb_addr_ts] == s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs+1 - s->ps.sps->ctb_width]])); + lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0) && (ctb_addr_in_slice-1 >= s->ps.sps->ctb_width) && (s->ps.pps->tile_id[ctb_addr_ts] == s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - s->ps.sps->ctb_width]])); } static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread) { HEVCContext *s = avctxt->priv_data; - int ctb_size = 1 << s->sps->log2_ctb_size; + int ctb_size = 1 << s->ps.sps->log2_ctb_size; int more_data = 1; int x_ctb = 0; int y_ctb = 0; - int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]; + int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]; if (!ctb_addr_ts && s->sh.dependent_slice_segment_flag) { av_log(s->avctx, AV_LOG_ERROR, "Impossible initial tile.\n"); @@ -2290,29 +2301,29 @@ } if (s->sh.dependent_slice_segment_flag) { - int prev_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1]; + int prev_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1]; if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) { av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n"); return AVERROR_INVALIDDATA; } } - while (more_data && ctb_addr_ts < s->sps->ctb_size) { - int ctb_addr_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts]; + while (more_data && ctb_addr_ts < s->ps.sps->ctb_size) { + int ctb_addr_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts]; - x_ctb = (ctb_addr_rs % ((s->sps->width + ctb_size - 1) >> s->sps->log2_ctb_size)) << s->sps->log2_ctb_size; - y_ctb = (ctb_addr_rs / ((s->sps->width + ctb_size - 1) >> s->sps->log2_ctb_size)) << s->sps->log2_ctb_size; + x_ctb = (ctb_addr_rs % ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size; + y_ctb = (ctb_addr_rs / ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size; hls_decode_neighbour(s, x_ctb, y_ctb, ctb_addr_ts); ff_hevc_cabac_init(s, ctb_addr_ts); - hls_sao_param(s, x_ctb >> s->sps->log2_ctb_size, y_ctb >> s->sps->log2_ctb_size); + hls_sao_param(s, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size); s->deblock[ctb_addr_rs].beta_offset = s->sh.beta_offset; s->deblock[ctb_addr_rs].tc_offset = s->sh.tc_offset; s->filter_slice_edges[ctb_addr_rs] = s->sh.slice_loop_filter_across_slices_enabled_flag; - more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->sps->log2_ctb_size, 0); + more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->ps.sps->log2_ctb_size, 0); if (more_data < 0) { s->tab_slice_address[ctb_addr_rs] = -1; return more_data; @@ -2324,8 +2335,8 @@ ff_hevc_hls_filters(s, x_ctb, y_ctb, ctb_size); } - if (x_ctb + ctb_size >= s->sps->width && - y_ctb + ctb_size >= s->sps->height) + if (x_ctb + ctb_size >= s->ps.sps->width && + y_ctb + ctb_size >= s->ps.sps->height) ff_hevc_hls_filter(s, x_ctb, y_ctb, ctb_size); return ctb_addr_ts; @@ -2346,12 +2357,12 @@ { HEVCContext *s1 = avctxt->priv_data, *s; HEVCLocalContext *lc; - int ctb_size = 1<< s1->sps->log2_ctb_size; + int ctb_size = 1<< s1->ps.sps->log2_ctb_size; int more_data = 1; int *ctb_row_p = input_ctb_row; int ctb_row = ctb_row_p[job]; - int ctb_addr_rs = s1->sh.slice_ctb_addr_rs + ctb_row * ((s1->sps->width + ctb_size - 1) >> s1->sps->log2_ctb_size); - int ctb_addr_ts = s1->pps->ctb_addr_rs_to_ts[ctb_addr_rs]; + int ctb_addr_rs = s1->sh.slice_ctb_addr_rs + ctb_row * ((s1->ps.sps->width + ctb_size - 1) >> s1->ps.sps->log2_ctb_size); + int ctb_addr_ts = s1->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs]; int thread = ctb_row % s1->threads_number; int ret; @@ -2366,9 +2377,9 @@ ff_init_cabac_decoder(&lc->cc, s->data + s->sh.offset[(ctb_row)-1], s->sh.size[ctb_row - 1]); } - while(more_data && ctb_addr_ts < s->sps->ctb_size) { - int x_ctb = (ctb_addr_rs % s->sps->ctb_width) << s->sps->log2_ctb_size; - int y_ctb = (ctb_addr_rs / s->sps->ctb_width) << s->sps->log2_ctb_size; + while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) { + int x_ctb = (ctb_addr_rs % s->ps.sps->ctb_width) << s->ps.sps->log2_ctb_size; + int y_ctb = (ctb_addr_rs / s->ps.sps->ctb_width) << s->ps.sps->log2_ctb_size; hls_decode_neighbour(s, x_ctb, y_ctb, ctb_addr_ts); @@ -2380,8 +2391,8 @@ } ff_hevc_cabac_init(s, ctb_addr_ts); - hls_sao_param(s, x_ctb >> s->sps->log2_ctb_size, y_ctb >> s->sps->log2_ctb_size); - more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->sps->log2_ctb_size, 0); + hls_sao_param(s, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size); + more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->ps.sps->log2_ctb_size, 0); if (more_data < 0) { s->tab_slice_address[ctb_addr_rs] = -1; @@ -2394,21 +2405,21 @@ ff_thread_report_progress2(s->avctx, ctb_row, thread, 1); ff_hevc_hls_filters(s, x_ctb, y_ctb, ctb_size); - if (!more_data && (x_ctb+ctb_size) < s->sps->width && ctb_row != s->sh.num_entry_point_offsets) { + if (!more_data && (x_ctb+ctb_size) < s->ps.sps->width && ctb_row != s->sh.num_entry_point_offsets) { avpriv_atomic_int_set(&s1->wpp_err, 1); ff_thread_report_progress2(s->avctx, ctb_row ,thread, SHIFT_CTB_WPP); return 0; } - if ((x_ctb+ctb_size) >= s->sps->width && (y_ctb+ctb_size) >= s->sps->height ) { + if ((x_ctb+ctb_size) >= s->ps.sps->width && (y_ctb+ctb_size) >= s->ps.sps->height ) { ff_hevc_hls_filter(s, x_ctb, y_ctb, ctb_size); ff_thread_report_progress2(s->avctx, ctb_row , thread, SHIFT_CTB_WPP); return ctb_addr_ts; } - ctb_addr_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts]; + ctb_addr_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts]; x_ctb+=ctb_size; - if(x_ctb >= s->sps->width) { + if(x_ctb >= s->ps.sps->width) { break; } } @@ -2417,8 +2428,10 @@ return 0; } -static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length) +static int hls_slice_data_wpp(HEVCContext *s, const HEVCNAL *nal) { + const uint8_t *data = nal->data; + int length = nal->size; HEVCLocalContext *lc = s->HEVClc; int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int)); int *arg = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int)); @@ -2447,8 +2460,8 @@ offset = (lc->gb.index >> 3); - for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < s->skipped_bytes; j++) { - if (s->skipped_bytes_pos[j] >= offset && s->skipped_bytes_pos[j] < startheader) { + for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) { + if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) { startheader--; cmpt++; } @@ -2457,8 +2470,8 @@ for (i = 1; i < s->sh.num_entry_point_offsets; i++) { offset += (s->sh.entry_point_offset[i - 1] - cmpt); for (j = 0, cmpt = 0, startheader = offset - + s->sh.entry_point_offset[i]; j < s->skipped_bytes; j++) { - if (s->skipped_bytes_pos[j] >= offset && s->skipped_bytes_pos[j] < startheader) { + + s->sh.entry_point_offset[i]; j < nal->skipped_bytes; j++) { + if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) { startheader--; cmpt++; } @@ -2473,7 +2486,7 @@ s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset; } - s->data = nal; + s->data = data; for (i = 1; i < s->threads_number; i++) { s->sList[i]->HEVClc->first_qp_group = 1; @@ -2490,7 +2503,7 @@ ret[i] = 0; } - if (s->pps->entropy_coding_sync_enabled_flag) + if (s->ps.pps->entropy_coding_sync_enabled_flag) s->avctx->execute2(s->avctx, (void *) hls_decode_entry_wpp, arg, ret, s->sh.num_entry_point_offsets + 1); for (i = 0; i <= s->sh.num_entry_point_offsets; i++) @@ -2500,32 +2513,6 @@ return res; } -/** - * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit, - * 0 if the unit should be skipped, 1 otherwise - */ -static int hls_nal_unit(HEVCContext *s) -{ - GetBitContext *gb = &s->HEVClc->gb; - int nuh_layer_id; - - if (get_bits1(gb) != 0) - return AVERROR_INVALIDDATA; - - s->nal_unit_type = get_bits(gb, 6); - - nuh_layer_id = get_bits(gb, 6); - s->temporal_id = get_bits(gb, 3) - 1; - if (s->temporal_id < 0) - return AVERROR_INVALIDDATA; - - av_log(s->avctx, AV_LOG_DEBUG, - "nal_unit_type: %d, nuh_layer_id: %d, temporal_id: %d\n", - s->nal_unit_type, nuh_layer_id, s->temporal_id); - - return nuh_layer_id == 0; -} - static int set_side_data(HEVCContext *s) { AVFrame *out = s->ref->frame; @@ -2578,21 +2565,21 @@ static int hevc_frame_start(HEVCContext *s) { HEVCLocalContext *lc = s->HEVClc; - int pic_size_in_ctb = ((s->sps->width >> s->sps->log2_min_cb_size) + 1) * - ((s->sps->height >> s->sps->log2_min_cb_size) + 1); + int pic_size_in_ctb = ((s->ps.sps->width >> s->ps.sps->log2_min_cb_size) + 1) * + ((s->ps.sps->height >> s->ps.sps->log2_min_cb_size) + 1); int ret; memset(s->horizontal_bs, 0, s->bs_width * s->bs_height); memset(s->vertical_bs, 0, s->bs_width * s->bs_height); - memset(s->cbf_luma, 0, s->sps->min_tb_width * s->sps->min_tb_height); - memset(s->is_pcm, 0, (s->sps->min_pu_width + 1) * (s->sps->min_pu_height + 1)); + memset(s->cbf_luma, 0, s->ps.sps->min_tb_width * s->ps.sps->min_tb_height); + memset(s->is_pcm, 0, (s->ps.sps->min_pu_width + 1) * (s->ps.sps->min_pu_height + 1)); memset(s->tab_slice_address, -1, pic_size_in_ctb * sizeof(*s->tab_slice_address)); s->is_decoded = 0; s->first_nal_type = s->nal_unit_type; - if (s->pps->tiles_enabled_flag) - lc->end_of_tiles_x = s->pps->column_width[0] << s->sps->log2_ctb_size; + if (s->ps.pps->tiles_enabled_flag) + lc->end_of_tiles_x = s->ps.pps->column_width[0] << s->ps.sps->log2_ctb_size; ret = ff_hevc_set_new_ref(s, &s->frame, s->poc); if (ret < 0) @@ -2638,31 +2625,24 @@ GetBitContext *gb = &lc->gb; int ctb_addr_ts, ret; - ret = init_get_bits8(gb, nal->data, nal->size); - if (ret < 0) - return ret; - - ret = hls_nal_unit(s); - if (ret < 0) { - av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n", - s->nal_unit_type); - goto fail; - } else if (!ret) - return 0; + *gb = nal->gb; + s->nal_unit_type = nal->type; + s->temporal_id = nal->temporal_id; switch (s->nal_unit_type) { case NAL_VPS: - ret = ff_hevc_decode_nal_vps(s); + ret = ff_hevc_decode_nal_vps(gb, s->avctx, &s->ps); if (ret < 0) goto fail; break; case NAL_SPS: - ret = ff_hevc_decode_nal_sps(s); + ret = ff_hevc_decode_nal_sps(gb, s->avctx, &s->ps, + s->apply_defdispwin); if (ret < 0) goto fail; break; case NAL_PPS: - ret = ff_hevc_decode_nal_pps(s); + ret = ff_hevc_decode_nal_pps(gb, s->avctx, &s->ps); if (ret < 0) goto fail; break; @@ -2748,10 +2728,10 @@ goto fail; } else { if (s->threads_number > 1 && s->sh.num_entry_point_offsets > 0) - ctb_addr_ts = hls_slice_data_wpp(s, nal->data, nal->size); + ctb_addr_ts = hls_slice_data_wpp(s, nal); else ctb_addr_ts = hls_slice_data(s); - if (ctb_addr_ts >= (s->sps->ctb_width * s->sps->ctb_height)) { + if (ctb_addr_ts >= (s->ps.sps->ctb_width * s->ps.sps->ctb_height)) { s->is_decoded = 1; } @@ -2781,122 +2761,9 @@ return 0; } -/* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication - * between these functions would be nice. */ -int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length, - HEVCNAL *nal) -{ - int i, si, di; - uint8_t *dst; - - s->skipped_bytes = 0; -#define STARTCODE_TEST \ - if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \ - if (src[i + 2] != 3) { \ - /* startcode, so we must be past the end */ \ - length = i; \ - } \ - break; \ - } -#if HAVE_FAST_UNALIGNED -#define FIND_FIRST_ZERO \ - if (i > 0 && !src[i]) \ - i--; \ - while (src[i]) \ - i++ -#if HAVE_FAST_64BIT - for (i = 0; i + 1 < length; i += 9) { - if (!((~AV_RN64A(src + i) & - (AV_RN64A(src + i) - 0x0100010001000101ULL)) & - 0x8000800080008080ULL)) - continue; - FIND_FIRST_ZERO; - STARTCODE_TEST; - i -= 7; - } -#else - for (i = 0; i + 1 < length; i += 5) { - if (!((~AV_RN32A(src + i) & - (AV_RN32A(src + i) - 0x01000101U)) & - 0x80008080U)) - continue; - FIND_FIRST_ZERO; - STARTCODE_TEST; - i -= 3; - } -#endif /* HAVE_FAST_64BIT */ -#else - for (i = 0; i + 1 < length; i += 2) { - if (src[i]) - continue; - if (i > 0 && src[i - 1] == 0) - i--; - STARTCODE_TEST; - } -#endif /* HAVE_FAST_UNALIGNED */ - - if (i >= length - 1) { // no escaped 0 - nal->data = - nal->raw_data = src; - nal->size = - nal->raw_size = length; - return length; - } - - av_fast_malloc(&nal->rbsp_buffer, &nal->rbsp_buffer_size, - length + FF_INPUT_BUFFER_PADDING_SIZE); - if (!nal->rbsp_buffer) - return AVERROR(ENOMEM); - - dst = nal->rbsp_buffer; - - memcpy(dst, src, i); - si = di = i; - while (si + 2 < length) { - // remove escapes (very rare 1:2^22) - if (src[si + 2] > 3) { - dst[di++] = src[si++]; - dst[di++] = src[si++]; - } else if (src[si] == 0 && src[si + 1] == 0) { - if (src[si + 2] == 3) { // escape - dst[di++] = 0; - dst[di++] = 0; - si += 3; - - s->skipped_bytes++; - if (s->skipped_bytes_pos_size < s->skipped_bytes) { - s->skipped_bytes_pos_size *= 2; - av_reallocp_array(&s->skipped_bytes_pos, - s->skipped_bytes_pos_size, - sizeof(*s->skipped_bytes_pos)); - if (!s->skipped_bytes_pos) - return AVERROR(ENOMEM); - } - if (s->skipped_bytes_pos) - s->skipped_bytes_pos[s->skipped_bytes-1] = di - 1; - continue; - } else // next start code - goto nsc; - } - - dst[di++] = src[si++]; - } - while (si < length) - dst[di++] = src[si++]; - -nsc: - memset(dst + di, 0, FF_INPUT_BUFFER_PADDING_SIZE); - - nal->data = dst; - nal->size = di; - nal->raw_data = src; - nal->raw_size = si; - return si; -} - static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) { - int i, consumed, ret = 0; + int i, ret = 0; s->ref = NULL; s->last_eos = s->eos; @@ -2904,109 +2771,23 @@ /* split the input packet into NAL units, so we know the upper bound on the * number of slices in the frame */ - s->nb_nals = 0; - while (length >= 4) { - HEVCNAL *nal; - int extract_length = 0; - - if (s->is_nalff) { - int i; - for (i = 0; i < s->nal_length_size; i++) - extract_length = (extract_length << 8) | buf[i]; - buf += s->nal_length_size; - length -= s->nal_length_size; - - if (extract_length > length) { - av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit size.\n"); - ret = AVERROR_INVALIDDATA; - goto fail; - } - } else { - /* search start code */ - while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) { - ++buf; - --length; - if (length < 4) { - av_log(s->avctx, AV_LOG_ERROR, "No start code is found.\n"); - ret = AVERROR_INVALIDDATA; - goto fail; - } - } - - buf += 3; - length -= 3; - } - - if (!s->is_nalff) - extract_length = length; - - if (s->nals_allocated < s->nb_nals + 1) { - int new_size = s->nals_allocated + 1; - void *tmp = av_realloc_array(s->nals, new_size, sizeof(*s->nals)); - ret = AVERROR(ENOMEM); - if (!tmp) { - goto fail; - } - s->nals = tmp; - memset(s->nals + s->nals_allocated, 0, - (new_size - s->nals_allocated) * sizeof(*s->nals)); - - tmp = av_realloc_array(s->skipped_bytes_nal, new_size, sizeof(*s->skipped_bytes_nal)); - if (!tmp) - goto fail; - s->skipped_bytes_nal = tmp; - - tmp = av_realloc_array(s->skipped_bytes_pos_size_nal, new_size, sizeof(*s->skipped_bytes_pos_size_nal)); - if (!tmp) - goto fail; - s->skipped_bytes_pos_size_nal = tmp; - - tmp = av_realloc_array(s->skipped_bytes_pos_nal, new_size, sizeof(*s->skipped_bytes_pos_nal)); - if (!tmp) - goto fail; - s->skipped_bytes_pos_nal = tmp; - - s->skipped_bytes_pos_size_nal[s->nals_allocated] = 1024; // initial buffer size - s->skipped_bytes_pos_nal[s->nals_allocated] = av_malloc_array(s->skipped_bytes_pos_size_nal[s->nals_allocated], sizeof(*s->skipped_bytes_pos)); - if (!s->skipped_bytes_pos_nal[s->nals_allocated]) - goto fail; - s->nals_allocated = new_size; - } - s->skipped_bytes_pos_size = s->skipped_bytes_pos_size_nal[s->nb_nals]; - s->skipped_bytes_pos = s->skipped_bytes_pos_nal[s->nb_nals]; - nal = &s->nals[s->nb_nals]; - - consumed = ff_hevc_extract_rbsp(s, buf, extract_length, nal); - - s->skipped_bytes_nal[s->nb_nals] = s->skipped_bytes; - s->skipped_bytes_pos_size_nal[s->nb_nals] = s->skipped_bytes_pos_size; - s->skipped_bytes_pos_nal[s->nb_nals++] = s->skipped_bytes_pos; - - - if (consumed < 0) { - ret = consumed; - goto fail; - } - - ret = init_get_bits8(&s->HEVClc->gb, nal->data, nal->size); - if (ret < 0) - goto fail; - hls_nal_unit(s); + ret = ff_hevc_split_packet(s, &s->pkt, buf, length, s->avctx, s->is_nalff, + s->nal_length_size); + if (ret < 0) { + av_log(s->avctx, AV_LOG_ERROR, + "Error splitting the input into NAL units.\n"); + return ret; + } - if (s->nal_unit_type == NAL_EOB_NUT || - s->nal_unit_type == NAL_EOS_NUT) + for (i = 0; i < s->pkt.nb_nals; i++) { + if (s->pkt.nals[i].type == NAL_EOB_NUT || + s->pkt.nals[i].type == NAL_EOS_NUT) s->eos = 1; - - buf += consumed; - length -= consumed; } - /* parse the NAL units */ - for (i = 0; i < s->nb_nals; i++) { - s->skipped_bytes = s->skipped_bytes_nal[i]; - s->skipped_bytes_pos = s->skipped_bytes_pos_nal[i]; - - ret = decode_nal_unit(s, &s->nals[i]); + /* decode the NAL units */ + for (i = 0; i < s->pkt.nb_nals; i++) { + ret = decode_nal_unit(s, &s->pkt.nals[i]); if (ret < 0) { av_log(s->avctx, AV_LOG_WARNING, "Error parsing NAL unit #%d.\n", i); @@ -3194,13 +2975,6 @@ av_freep(&s->md5_ctx); - for(i=0; i < s->nals_allocated; i++) { - av_freep(&s->skipped_bytes_pos_nal[i]); - } - av_freep(&s->skipped_bytes_pos_size_nal); - av_freep(&s->skipped_bytes_nal); - av_freep(&s->skipped_bytes_pos_nal); - av_freep(&s->cabac_state); for (i = 0; i < 3; i++) { @@ -3214,15 +2988,15 @@ av_frame_free(&s->DPB[i].frame); } - for (i = 0; i < FF_ARRAY_ELEMS(s->vps_list); i++) - av_buffer_unref(&s->vps_list[i]); - for (i = 0; i < FF_ARRAY_ELEMS(s->sps_list); i++) - av_buffer_unref(&s->sps_list[i]); - for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++) - av_buffer_unref(&s->pps_list[i]); - s->sps = NULL; - s->pps = NULL; - s->vps = NULL; + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.vps_list); i++) + av_buffer_unref(&s->ps.vps_list[i]); + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) + av_buffer_unref(&s->ps.sps_list[i]); + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.pps_list); i++) + av_buffer_unref(&s->ps.pps_list[i]); + s->ps.sps = NULL; + s->ps.pps = NULL; + s->ps.vps = NULL; av_freep(&s->sh.entry_point_offset); av_freep(&s->sh.offset); @@ -3239,10 +3013,12 @@ s->HEVClc = NULL; av_freep(&s->HEVClcList[0]); - for (i = 0; i < s->nals_allocated; i++) - av_freep(&s->nals[i].rbsp_buffer); - av_freep(&s->nals); - s->nals_allocated = 0; + for (i = 0; i < s->pkt.nals_allocated; i++) { + av_freep(&s->pkt.nals[i].rbsp_buffer); + av_freep(&s->pkt.nals[i].skipped_bytes_pos); + } + av_freep(&s->pkt.nals); + s->pkt.nals_allocated = 0; return 0; } @@ -3315,37 +3091,37 @@ } } - if (s->sps != s0->sps) - s->sps = NULL; - for (i = 0; i < FF_ARRAY_ELEMS(s->vps_list); i++) { - av_buffer_unref(&s->vps_list[i]); - if (s0->vps_list[i]) { - s->vps_list[i] = av_buffer_ref(s0->vps_list[i]); - if (!s->vps_list[i]) + if (s->ps.sps != s0->ps.sps) + s->ps.sps = NULL; + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.vps_list); i++) { + av_buffer_unref(&s->ps.vps_list[i]); + if (s0->ps.vps_list[i]) { + s->ps.vps_list[i] = av_buffer_ref(s0->ps.vps_list[i]); + if (!s->ps.vps_list[i]) return AVERROR(ENOMEM); } } - for (i = 0; i < FF_ARRAY_ELEMS(s->sps_list); i++) { - av_buffer_unref(&s->sps_list[i]); - if (s0->sps_list[i]) { - s->sps_list[i] = av_buffer_ref(s0->sps_list[i]); - if (!s->sps_list[i]) + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) { + av_buffer_unref(&s->ps.sps_list[i]); + if (s0->ps.sps_list[i]) { + s->ps.sps_list[i] = av_buffer_ref(s0->ps.sps_list[i]); + if (!s->ps.sps_list[i]) return AVERROR(ENOMEM); } } - for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++) { - av_buffer_unref(&s->pps_list[i]); - if (s0->pps_list[i]) { - s->pps_list[i] = av_buffer_ref(s0->pps_list[i]); - if (!s->pps_list[i]) + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.pps_list); i++) { + av_buffer_unref(&s->ps.pps_list[i]); + if (s0->ps.pps_list[i]) { + s->ps.pps_list[i] = av_buffer_ref(s0->ps.pps_list[i]); + if (!s->ps.pps_list[i]) return AVERROR(ENOMEM); } } - if (s->sps != s0->sps) - if ((ret = set_sps(s, s0->sps, src->pix_fmt)) < 0) + if (s->ps.sps != s0->ps.sps) + if ((ret = set_sps(s, s0->ps.sps, src->pix_fmt)) < 0) return ret; s->seq_decode = s0->seq_decode; @@ -3431,10 +3207,10 @@ } /* export stream parameters from the first SPS */ - for (i = 0; i < FF_ARRAY_ELEMS(s->sps_list); i++) { - if (s->sps_list[i]) { - const HEVCSPS *sps = (const HEVCSPS*)s->sps_list[i]->data; - export_stream_params(s->avctx, s, sps); + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) { + if (s->ps.sps_list[i]) { + const HEVCSPS *sps = (const HEVCSPS*)s->ps.sps_list[i]->data; + export_stream_params(s->avctx, &s->ps, sps); break; } } @@ -3539,7 +3315,7 @@ .flush = hevc_decode_flush, .update_thread_context = hevc_update_thread_context, .init_thread_copy = hevc_init_thread_copy, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | - CODEC_CAP_SLICE_THREADS | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, .profiles = NULL_IF_CONFIG_SMALL(profiles), }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_cabac.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_cabac.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_cabac.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_cabac.c 2015-07-13 17:20:03.000000000 +0000 @@ -427,20 +427,6 @@ { 1, 3, }, }; -const uint8_t ff_hevc_diag_scan4x4_x[16] = { - 0, 0, 1, 0, - 1, 2, 0, 1, - 2, 3, 1, 2, - 3, 2, 3, 3, -}; - -const uint8_t ff_hevc_diag_scan4x4_y[16] = { - 0, 1, 0, 2, - 1, 0, 3, 2, - 1, 0, 3, 2, - 1, 3, 2, 3, -}; - static const uint8_t diag_scan4x4_inv[4][4] = { { 0, 2, 5, 9, }, { 1, 4, 8, 12, }, @@ -448,44 +434,6 @@ { 6, 10, 13, 15, }, }; -const uint8_t ff_hevc_diag_scan8x8_x[64] = { - 0, 0, 1, 0, - 1, 2, 0, 1, - 2, 3, 0, 1, - 2, 3, 4, 0, - 1, 2, 3, 4, - 5, 0, 1, 2, - 3, 4, 5, 6, - 0, 1, 2, 3, - 4, 5, 6, 7, - 1, 2, 3, 4, - 5, 6, 7, 2, - 3, 4, 5, 6, - 7, 3, 4, 5, - 6, 7, 4, 5, - 6, 7, 5, 6, - 7, 6, 7, 7, -}; - -const uint8_t ff_hevc_diag_scan8x8_y[64] = { - 0, 1, 0, 2, - 1, 0, 3, 2, - 1, 0, 4, 3, - 2, 1, 0, 5, - 4, 3, 2, 1, - 0, 6, 5, 4, - 3, 2, 1, 0, - 7, 6, 5, 4, - 3, 2, 1, 0, - 7, 6, 5, 4, - 3, 2, 1, 7, - 6, 5, 4, 3, - 2, 7, 6, 5, - 4, 3, 7, 6, - 5, 4, 7, 6, - 5, 7, 6, 7, -}; - static const uint8_t diag_scan8x8_inv[8][8] = { { 0, 2, 5, 9, 14, 20, 27, 35, }, { 1, 4, 8, 13, 19, 26, 34, 42, }, @@ -499,10 +447,10 @@ void ff_hevc_save_states(HEVCContext *s, int ctb_addr_ts) { - if (s->pps->entropy_coding_sync_enabled_flag && - (ctb_addr_ts % s->sps->ctb_width == 2 || - (s->sps->ctb_width == 2 && - ctb_addr_ts % s->sps->ctb_width == 0))) { + if (s->ps.pps->entropy_coding_sync_enabled_flag && + (ctb_addr_ts % s->ps.sps->ctb_width == 2 || + (s->ps.sps->ctb_width == 2 && + ctb_addr_ts % s->ps.sps->ctb_width == 0))) { memcpy(s->cabac_state, s->HEVClc->cabac_state, HEVC_CONTEXTS); } } @@ -553,40 +501,40 @@ void ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts) { - if (ctb_addr_ts == s->pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) { + if (ctb_addr_ts == s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) { cabac_init_decoder(s); if (s->sh.dependent_slice_segment_flag == 0 || - (s->pps->tiles_enabled_flag && - s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[ctb_addr_ts - 1])) + (s->ps.pps->tiles_enabled_flag && + s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1])) cabac_init_state(s); if (!s->sh.first_slice_in_pic_flag && - s->pps->entropy_coding_sync_enabled_flag) { - if (ctb_addr_ts % s->sps->ctb_width == 0) { - if (s->sps->ctb_width == 1) + s->ps.pps->entropy_coding_sync_enabled_flag) { + if (ctb_addr_ts % s->ps.sps->ctb_width == 0) { + if (s->ps.sps->ctb_width == 1) cabac_init_state(s); else if (s->sh.dependent_slice_segment_flag == 1) load_states(s); } } } else { - if (s->pps->tiles_enabled_flag && - s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[ctb_addr_ts - 1]) { + if (s->ps.pps->tiles_enabled_flag && + s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]) { if (s->threads_number == 1) cabac_reinit(s->HEVClc); else cabac_init_decoder(s); cabac_init_state(s); } - if (s->pps->entropy_coding_sync_enabled_flag) { - if (ctb_addr_ts % s->sps->ctb_width == 0) { + if (s->ps.pps->entropy_coding_sync_enabled_flag) { + if (ctb_addr_ts % s->ps.sps->ctb_width == 0) { get_cabac_terminate(&s->HEVClc->cc); if (s->threads_number == 1) cabac_reinit(s->HEVClc); else cabac_init_decoder(s); - if (s->sps->ctb_width == 1) + if (s->ps.sps->ctb_width == 1) cabac_init_state(s); else load_states(s); @@ -625,7 +573,7 @@ int ff_hevc_sao_offset_abs_decode(HEVCContext *s) { int i = 0; - int length = (1 << (FFMIN(s->sps->bit_depth, 10) - 5)) - 1; + int length = (1 << (FFMIN(s->ps.sps->bit_depth, 10) - 5)) - 1; while (i < length && get_cabac_bypass(&s->HEVClc->cc)) i++; @@ -656,10 +604,10 @@ int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0, int x_cb, int y_cb) { - int min_cb_width = s->sps->min_cb_width; + int min_cb_width = s->ps.sps->min_cb_width; int inc = 0; - int x0b = av_mod_uintp2(x0, s->sps->log2_ctb_size); - int y0b = av_mod_uintp2(y0, s->sps->log2_ctb_size); + int x0b = av_mod_uintp2(x0, s->ps.sps->log2_ctb_size); + int y0b = av_mod_uintp2(y0, s->ps.sps->log2_ctb_size); if (s->HEVClc->ctb_left_flag || x0b) inc = !!SAMPLE_CTB(s->skip_flag, x_cb - 1, y_cb); @@ -706,7 +654,7 @@ int ff_hevc_cu_chroma_qp_offset_idx(HEVCContext *s) { - int c_max= FFMAX(5, s->pps->chroma_qp_offset_list_len_minus1); + int c_max= FFMAX(5, s->ps.pps->chroma_qp_offset_list_len_minus1); int i = 0; while (i < c_max && GET_CABAC(elem_offset[CU_CHROMA_QP_OFFSET_IDX])) @@ -723,15 +671,15 @@ int ff_hevc_split_coding_unit_flag_decode(HEVCContext *s, int ct_depth, int x0, int y0) { int inc = 0, depth_left = 0, depth_top = 0; - int x0b = av_mod_uintp2(x0, s->sps->log2_ctb_size); - int y0b = av_mod_uintp2(y0, s->sps->log2_ctb_size); - int x_cb = x0 >> s->sps->log2_min_cb_size; - int y_cb = y0 >> s->sps->log2_min_cb_size; + int x0b = av_mod_uintp2(x0, s->ps.sps->log2_ctb_size); + int y0b = av_mod_uintp2(y0, s->ps.sps->log2_ctb_size); + int x_cb = x0 >> s->ps.sps->log2_min_cb_size; + int y_cb = y0 >> s->ps.sps->log2_min_cb_size; if (s->HEVClc->ctb_left_flag || x0b) - depth_left = s->tab_ct_depth[(y_cb) * s->sps->min_cb_width + x_cb - 1]; + depth_left = s->tab_ct_depth[(y_cb) * s->ps.sps->min_cb_width + x_cb - 1]; if (s->HEVClc->ctb_up_flag || y0b) - depth_top = s->tab_ct_depth[(y_cb - 1) * s->sps->min_cb_width + x_cb]; + depth_top = s->tab_ct_depth[(y_cb - 1) * s->ps.sps->min_cb_width + x_cb]; inc += (depth_left > ct_depth); inc += (depth_top > ct_depth); @@ -743,7 +691,7 @@ { if (GET_CABAC(elem_offset[PART_MODE])) // 1 return PART_2Nx2N; - if (log2_cb_size == s->sps->log2_min_cb_size) { + if (log2_cb_size == s->ps.sps->log2_min_cb_size) { if (s->HEVClc->cu.pred_mode == MODE_INTRA) // 0 return PART_NxN; if (GET_CABAC(elem_offset[PART_MODE] + 1)) // 01 @@ -755,7 +703,7 @@ return PART_NxN; // 000 } - if (!s->sps->amp_enabled_flag) { + if (!s->ps.sps->amp_enabled_flag) { if (GET_CABAC(elem_offset[PART_MODE] + 1)) // 01 return PART_2NxN; return PART_Nx2N; @@ -1075,10 +1023,10 @@ const uint8_t *scan_x_cg, *scan_y_cg, *scan_x_off, *scan_y_off; ptrdiff_t stride = s->frame->linesize[c_idx]; - int hshift = s->sps->hshift[c_idx]; - int vshift = s->sps->vshift[c_idx]; + int hshift = s->ps.sps->hshift[c_idx]; + int vshift = s->ps.sps->vshift[c_idx]; uint8_t *dst = &s->frame->data[c_idx][(y0 >> vshift) * stride + - ((x0 >> hshift) << s->sps->pixel_shift)]; + ((x0 >> hshift) << s->ps.sps->pixel_shift)]; int16_t *coeffs = (int16_t*)(c_idx ? lc->edge_emu_buffer2 : lc->edge_emu_buffer); uint8_t significant_coeff_group_flag[8][8] = {{0}}; int explicit_rdpcm_flag = 0; @@ -1113,25 +1061,25 @@ }; int qp_y = lc->qp_y; - if (s->pps->transform_skip_enabled_flag && - log2_trafo_size <= s->pps->log2_max_transform_skip_block_size) { + if (s->ps.pps->transform_skip_enabled_flag && + log2_trafo_size <= s->ps.pps->log2_max_transform_skip_block_size) { transform_skip_flag = hevc_transform_skip_flag_decode(s, c_idx); } if (c_idx == 0) { - qp = qp_y + s->sps->qp_bd_offset; + qp = qp_y + s->ps.sps->qp_bd_offset; } else { int qp_i, offset; if (c_idx == 1) - offset = s->pps->cb_qp_offset + s->sh.slice_cb_qp_offset + + offset = s->ps.pps->cb_qp_offset + s->sh.slice_cb_qp_offset + lc->tu.cu_qp_offset_cb; else - offset = s->pps->cr_qp_offset + s->sh.slice_cr_qp_offset + + offset = s->ps.pps->cr_qp_offset + s->sh.slice_cr_qp_offset + lc->tu.cu_qp_offset_cr; - qp_i = av_clip(qp_y + offset, - s->sps->qp_bd_offset, 57); - if (s->sps->chroma_format_idc == 1) { + qp_i = av_clip(qp_y + offset, - s->ps.sps->qp_bd_offset, 57); + if (s->ps.sps->chroma_format_idc == 1) { if (qp_i < 30) qp = qp_i; else if (qp_i > 43) @@ -1145,18 +1093,18 @@ qp = qp_i; } - qp += s->sps->qp_bd_offset; + qp += s->ps.sps->qp_bd_offset; } - shift = s->sps->bit_depth + log2_trafo_size - 5; + shift = s->ps.sps->bit_depth + log2_trafo_size - 5; add = 1 << (shift-1); scale = level_scale[rem6[qp]] << (div6[qp]); scale_m = 16; // default when no custom scaling lists. dc_scale = 16; - if (s->sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) { - const ScalingList *sl = s->pps->scaling_list_data_present_flag ? - &s->pps->scaling_list : &s->sps->scaling_list; + if (s->ps.sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) { + const ScalingList *sl = s->ps.pps->scaling_list_data_present_flag ? + &s->ps.pps->scaling_list : &s->ps.sps->scaling_list; int matrix_id = lc->cu.pred_mode != MODE_INTRA; matrix_id = 3 * matrix_id + c_idx; @@ -1172,7 +1120,7 @@ dc_scale = 0; } - if (lc->cu.pred_mode == MODE_INTER && s->sps->explicit_rdpcm_enabled_flag && + if (lc->cu.pred_mode == MODE_INTER && s->ps.sps->explicit_rdpcm_enabled_flag && (transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) { explicit_rdpcm_flag = explicit_rdpcm_flag_decode(s, c_idx); if (explicit_rdpcm_flag) { @@ -1303,7 +1251,7 @@ }; const uint8_t *ctx_idx_map_p; int scf_offset = 0; - if (s->sps->transform_skip_context_enabled_flag && + if (s->ps.sps->transform_skip_context_enabled_flag && (transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) { ctx_idx_map_p = (uint8_t*) &ctx_idx_map[4 * 16]; if (c_idx == 0) { @@ -1344,7 +1292,7 @@ } } if (implicit_non_zero_coeff == 0) { - if (s->sps->transform_skip_context_enabled_flag && + if (s->ps.sps->transform_skip_context_enabled_flag && (transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) { if (c_idx == 0) { scf_offset = 42; @@ -1389,7 +1337,7 @@ // initialize first elem of coeff_bas_level_greater1_flag int ctx_set = (i > 0 && c_idx == 0) ? 2 : 0; - if (s->sps->persistent_rice_adaptation_enabled_flag) { + if (s->ps.sps->persistent_rice_adaptation_enabled_flag) { if (!transform_skip_flag && !lc->cu.cu_transquant_bypass_flag) sb_type = 2 * (c_idx == 0 ? 1 : 0); else @@ -1418,7 +1366,7 @@ if (lc->cu.cu_transquant_bypass_flag || (lc->cu.pred_mode == MODE_INTRA && - s->sps->implicit_rdpcm_enabled_flag && transform_skip_flag && + s->ps.sps->implicit_rdpcm_enabled_flag && transform_skip_flag && (pred_mode_intra == 10 || pred_mode_intra == 26 )) || explicit_rdpcm_flag) sign_hidden = 0; @@ -1428,7 +1376,7 @@ if (first_greater1_coeff_idx != -1) { coeff_abs_level_greater1_flag[first_greater1_coeff_idx] += coeff_abs_level_greater2_flag_decode(s, c_idx, ctx_set); } - if (!s->pps->sign_data_hiding_flag || !sign_hidden ) { + if (!s->ps.pps->sign_data_hiding_flag || !sign_hidden ) { coeff_sign_flag = coeff_sign_flag_decode(s, nb_significant_coeff_flag) << (16 - nb_significant_coeff_flag); } else { coeff_sign_flag = coeff_sign_flag_decode(s, nb_significant_coeff_flag - 1) << (16 - (nb_significant_coeff_flag - 1)); @@ -1444,8 +1392,8 @@ trans_coeff_level += last_coeff_abs_level_remaining; if (trans_coeff_level > (3 << c_rice_param)) - c_rice_param = s->sps->persistent_rice_adaptation_enabled_flag ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4); - if (s->sps->persistent_rice_adaptation_enabled_flag && !rice_init) { + c_rice_param = s->ps.sps->persistent_rice_adaptation_enabled_flag ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4); + if (s->ps.sps->persistent_rice_adaptation_enabled_flag && !rice_init) { int c_rice_p_init = lc->stat_coeff[sb_type] / 4; if (last_coeff_abs_level_remaining >= (3 << c_rice_p_init)) lc->stat_coeff[sb_type]++; @@ -1460,8 +1408,8 @@ trans_coeff_level = 1 + last_coeff_abs_level_remaining; if (trans_coeff_level > (3 << c_rice_param)) - c_rice_param = s->sps->persistent_rice_adaptation_enabled_flag ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4); - if (s->sps->persistent_rice_adaptation_enabled_flag && !rice_init) { + c_rice_param = s->ps.sps->persistent_rice_adaptation_enabled_flag ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4); + if (s->ps.sps->persistent_rice_adaptation_enabled_flag && !rice_init) { int c_rice_p_init = lc->stat_coeff[sb_type] / 4; if (last_coeff_abs_level_remaining >= (3 << c_rice_p_init)) lc->stat_coeff[sb_type]++; @@ -1471,7 +1419,7 @@ rice_init = 1; } } - if (s->pps->sign_data_hiding_flag && sign_hidden) { + if (s->ps.pps->sign_data_hiding_flag && sign_hidden) { sum_abs += trans_coeff_level; if (n == first_nz_pos_in_cg && (sum_abs&1)) trans_coeff_level = -trans_coeff_level; @@ -1480,7 +1428,7 @@ trans_coeff_level = -trans_coeff_level; coeff_sign_flag <<= 1; if(!lc->cu.cu_transquant_bypass_flag) { - if (s->sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) { + if (s->ps.sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) { if(y_c || x_c || log2_trafo_size < 4) { switch(log2_trafo_size) { case 3: pos = (y_c << 3) + x_c; break; @@ -1508,15 +1456,15 @@ } if (lc->cu.cu_transquant_bypass_flag) { - if (explicit_rdpcm_flag || (s->sps->implicit_rdpcm_enabled_flag && + if (explicit_rdpcm_flag || (s->ps.sps->implicit_rdpcm_enabled_flag && (pred_mode_intra == 10 || pred_mode_intra == 26))) { - int mode = s->sps->implicit_rdpcm_enabled_flag ? (pred_mode_intra == 26) : explicit_rdpcm_dir_flag; + int mode = s->ps.sps->implicit_rdpcm_enabled_flag ? (pred_mode_intra == 26) : explicit_rdpcm_dir_flag; s->hevcdsp.transform_rdpcm(coeffs, log2_trafo_size, mode); } } else { if (transform_skip_flag) { - int rot = s->sps->transform_skip_rotation_enabled_flag && + int rot = s->ps.sps->transform_skip_rotation_enabled_flag && log2_trafo_size == 2 && lc->cu.pred_mode == MODE_INTRA; if (rot) { @@ -1526,7 +1474,7 @@ s->hevcdsp.transform_skip(coeffs, log2_trafo_size); - if (explicit_rdpcm_flag || (s->sps->implicit_rdpcm_enabled_flag && + if (explicit_rdpcm_flag || (s->ps.sps->implicit_rdpcm_enabled_flag && lc->cu.pred_mode == MODE_INTRA && (pred_mode_intra == 10 || pred_mode_intra == 26))) { int mode = explicit_rdpcm_flag ? explicit_rdpcm_dir_flag : (pred_mode_intra == 26); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_data.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_data.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_data.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_data.c 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,75 @@ +/* + * HEVC shared tables + * + * 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 + +#include "hevc.h" + +const uint8_t ff_hevc_diag_scan4x4_x[16] = { + 0, 0, 1, 0, + 1, 2, 0, 1, + 2, 3, 1, 2, + 3, 2, 3, 3, +}; + +const uint8_t ff_hevc_diag_scan4x4_y[16] = { + 0, 1, 0, 2, + 1, 0, 3, 2, + 1, 0, 3, 2, + 1, 3, 2, 3, +}; + +const uint8_t ff_hevc_diag_scan8x8_x[64] = { + 0, 0, 1, 0, + 1, 2, 0, 1, + 2, 3, 0, 1, + 2, 3, 4, 0, + 1, 2, 3, 4, + 5, 0, 1, 2, + 3, 4, 5, 6, + 0, 1, 2, 3, + 4, 5, 6, 7, + 1, 2, 3, 4, + 5, 6, 7, 2, + 3, 4, 5, 6, + 7, 3, 4, 5, + 6, 7, 4, 5, + 6, 7, 5, 6, + 7, 6, 7, 7, +}; + +const uint8_t ff_hevc_diag_scan8x8_y[64] = { + 0, 1, 0, 2, + 1, 0, 3, 2, + 1, 0, 4, 3, + 2, 1, 0, 5, + 4, 3, 2, 1, + 0, 6, 5, 4, + 3, 2, 1, 0, + 7, 6, 5, 4, + 3, 2, 1, 0, + 7, 6, 5, 4, + 3, 2, 1, 7, + 6, 5, 4, 3, + 2, 7, 6, 5, + 4, 3, 7, 6, + 5, 4, 7, 6, + 5, 7, 6, 7, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevcdsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevcdsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevcdsp.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevcdsp.h 2015-07-28 17:20:07.000000000 +0000 @@ -61,7 +61,7 @@ void (*sao_band_filter[5])(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, int16_t *sao_offset_val, int sao_left_class, int width, int height); - /* implicit stride_src parameter has value of 2 * MAX_PB_SIZE + FF_INPUT_BUFFER_PADDING_SIZE */ + /* implicit stride_src parameter has value of 2 * MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE */ void (*sao_edge_filter[5])(uint8_t *_dst /* align 16 */, uint8_t *_src /* align 32 */, ptrdiff_t stride_dst, int16_t *sao_offset_val, int sao_eo_class, int width, int height); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevcdsp_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevcdsp_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevcdsp_template.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevcdsp_template.c 2015-07-28 17:20:07.000000000 +0000 @@ -341,7 +341,7 @@ pixel *src = (pixel *)_src; int a_stride, b_stride; int x, y; - ptrdiff_t stride_src = (2*MAX_PB_SIZE + FF_INPUT_BUFFER_PADDING_SIZE) / sizeof(pixel); + ptrdiff_t stride_src = (2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) / sizeof(pixel); stride_dst /= sizeof(pixel); a_stride = pos[eo][0][0] + pos[eo][0][1] * stride_src; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_filter.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_filter.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_filter.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_filter.c 2015-07-28 17:20:07.000000000 +0000 @@ -56,12 +56,12 @@ // slice qp offset is not used for deblocking if (c_idx == 1) - offset = s->pps->cb_qp_offset; + offset = s->ps.pps->cb_qp_offset; else - offset = s->pps->cr_qp_offset; + offset = s->ps.pps->cr_qp_offset; qp_i = av_clip(qp_y + offset, 0, 57); - if (s->sps->chroma_format_idc == 1) { + if (s->ps.sps->chroma_format_idc == 1) { if (qp_i < 30) qp = qp_i; else if (qp_i > 43) @@ -79,14 +79,14 @@ static int get_qPy_pred(HEVCContext *s, int xBase, int yBase, int log2_cb_size) { HEVCLocalContext *lc = s->HEVClc; - int ctb_size_mask = (1 << s->sps->log2_ctb_size) - 1; - int MinCuQpDeltaSizeMask = (1 << (s->sps->log2_ctb_size - - s->pps->diff_cu_qp_delta_depth)) - 1; + int ctb_size_mask = (1 << s->ps.sps->log2_ctb_size) - 1; + int MinCuQpDeltaSizeMask = (1 << (s->ps.sps->log2_ctb_size - + s->ps.pps->diff_cu_qp_delta_depth)) - 1; int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask); int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask); - int min_cb_width = s->sps->min_cb_width; - int x_cb = xQgBase >> s->sps->log2_min_cb_size; - int y_cb = yQgBase >> s->sps->log2_min_cb_size; + int min_cb_width = s->ps.sps->min_cb_width; + int x_cb = xQgBase >> s->ps.sps->log2_min_cb_size; + int y_cb = yQgBase >> s->ps.sps->log2_min_cb_size; int availableA = (xBase & ctb_size_mask) && (xQgBase & ctb_size_mask); int availableB = (yBase & ctb_size_mask) && @@ -113,8 +113,8 @@ else qPy_b = s->qp_y_tab[x_cb + (y_cb - 1) * min_cb_width]; - av_assert2(qPy_a >= -s->sps->qp_bd_offset && qPy_a < 52); - av_assert2(qPy_b >= -s->sps->qp_bd_offset && qPy_b < 52); + av_assert2(qPy_a >= -s->ps.sps->qp_bd_offset && qPy_a < 52); + av_assert2(qPy_b >= -s->ps.sps->qp_bd_offset && qPy_b < 52); return (qPy_a + qPy_b + 1) >> 1; } @@ -124,7 +124,7 @@ int qp_y = get_qPy_pred(s, xBase, yBase, log2_cb_size); if (s->HEVClc->tu.cu_qp_delta != 0) { - int off = s->sps->qp_bd_offset; + int off = s->ps.sps->qp_bd_offset; s->HEVClc->qp_y = FFUMOD(qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off, 52 + off) - off; } else @@ -133,10 +133,10 @@ static int get_qPy(HEVCContext *s, int xC, int yC) { - int log2_min_cb_size = s->sps->log2_min_cb_size; + int log2_min_cb_size = s->ps.sps->log2_min_cb_size; int x = xC >> log2_min_cb_size; int y = yC >> log2_min_cb_size; - return s->qp_y_tab[x + y * s->sps->min_cb_width]; + return s->qp_y_tab[x + y * s->ps.sps->min_cb_width]; } static void copy_CTB(uint8_t *dst, const uint8_t *src, int width, int height, @@ -193,9 +193,9 @@ int stride_src, int x, int y, int width, int height, int c_idx, int x_ctb, int y_ctb) { - int sh = s->sps->pixel_shift; - int w = s->sps->width >> s->sps->hshift[c_idx]; - int h = s->sps->height >> s->sps->vshift[c_idx]; + int sh = s->ps.sps->pixel_shift; + int w = s->ps.sps->width >> s->ps.sps->hshift[c_idx]; + int h = s->ps.sps->height >> s->ps.sps->vshift[c_idx]; /* copy horizontal edges */ memcpy(s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb) * w + x) << sh), @@ -214,23 +214,23 @@ ptrdiff_t stride_src, ptrdiff_t stride_dst, int x0, int y0, int width, int height, int c_idx) { - if ( s->pps->transquant_bypass_enable_flag || - (s->sps->pcm.loop_filter_disable_flag && s->sps->pcm_enabled_flag)) { + if ( s->ps.pps->transquant_bypass_enable_flag || + (s->ps.sps->pcm.loop_filter_disable_flag && s->ps.sps->pcm_enabled_flag)) { int x, y; - int min_pu_size = 1 << s->sps->log2_min_pu_size; - int hshift = s->sps->hshift[c_idx]; - int vshift = s->sps->vshift[c_idx]; - int x_min = ((x0 ) >> s->sps->log2_min_pu_size); - int y_min = ((y0 ) >> s->sps->log2_min_pu_size); - int x_max = ((x0 + width ) >> s->sps->log2_min_pu_size); - int y_max = ((y0 + height) >> s->sps->log2_min_pu_size); - int len = (min_pu_size >> hshift) << s->sps->pixel_shift; + int min_pu_size = 1 << s->ps.sps->log2_min_pu_size; + int hshift = s->ps.sps->hshift[c_idx]; + int vshift = s->ps.sps->vshift[c_idx]; + int x_min = ((x0 ) >> s->ps.sps->log2_min_pu_size); + int y_min = ((y0 ) >> s->ps.sps->log2_min_pu_size); + int x_max = ((x0 + width ) >> s->ps.sps->log2_min_pu_size); + int y_max = ((y0 + height) >> s->ps.sps->log2_min_pu_size); + int len = (min_pu_size >> hshift) << s->ps.sps->pixel_shift; for (y = y_min; y < y_max; y++) { for (x = x_min; x < x_max; x++) { - if (s->is_pcm[y * s->sps->min_pu_width + x]) { + if (s->is_pcm[y * s->ps.sps->min_pu_width + x]) { int n; - uint8_t *src = src1 + (((y << s->sps->log2_min_pu_size) - y0) >> vshift) * stride_src + ((((x << s->sps->log2_min_pu_size) - x0) >> hshift) << s->sps->pixel_shift); - const uint8_t *dst = dst1 + (((y << s->sps->log2_min_pu_size) - y0) >> vshift) * stride_dst + ((((x << s->sps->log2_min_pu_size) - x0) >> hshift) << s->sps->pixel_shift); + uint8_t *src = src1 + (((y << s->ps.sps->log2_min_pu_size) - y0) >> vshift) * stride_src + ((((x << s->ps.sps->log2_min_pu_size) - x0) >> hshift) << s->ps.sps->pixel_shift); + const uint8_t *dst = dst1 + (((y << s->ps.sps->log2_min_pu_size) - y0) >> vshift) * stride_dst + ((((x << s->ps.sps->log2_min_pu_size) - x0) >> hshift) << s->ps.sps->pixel_shift); for (n = 0; n < (min_pu_size >> vshift); n++) { memcpy(src, dst, len); src += stride_src; @@ -242,7 +242,7 @@ } } -#define CTB(tab, x, y) ((tab)[(y) * s->sps->ctb_width + (x)]) +#define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)]) static void sao_filter_CTB(HEVCContext *s, int x, int y) { @@ -250,18 +250,18 @@ HEVCLocalContext *lc = s->HEVClc; int c_idx; int edges[4]; // 0 left 1 top 2 right 3 bottom - int x_ctb = x >> s->sps->log2_ctb_size; - int y_ctb = y >> s->sps->log2_ctb_size; - int ctb_addr_rs = y_ctb * s->sps->ctb_width + x_ctb; - int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[ctb_addr_rs]; + int x_ctb = x >> s->ps.sps->log2_ctb_size; + int y_ctb = y >> s->ps.sps->log2_ctb_size; + int ctb_addr_rs = y_ctb * s->ps.sps->ctb_width + x_ctb; + int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs]; SAOParams *sao = &CTB(s->sao, x_ctb, y_ctb); // flags indicating unfilterable edges uint8_t vert_edge[] = { 0, 0 }; uint8_t horiz_edge[] = { 0, 0 }; uint8_t diag_edge[] = { 0, 0, 0, 0 }; uint8_t lfase = CTB(s->filter_slice_edges, x_ctb, y_ctb); - uint8_t no_tile_filter = s->pps->tiles_enabled_flag && - !s->pps->loop_filter_across_tiles_enabled_flag; + uint8_t no_tile_filter = s->ps.pps->tiles_enabled_flag && + !s->ps.pps->loop_filter_across_tiles_enabled_flag; uint8_t restore = no_tile_filter || !lfase; uint8_t left_tile_edge = 0; uint8_t right_tile_edge = 0; @@ -270,24 +270,24 @@ edges[0] = x_ctb == 0; edges[1] = y_ctb == 0; - edges[2] = x_ctb == s->sps->ctb_width - 1; - edges[3] = y_ctb == s->sps->ctb_height - 1; + edges[2] = x_ctb == s->ps.sps->ctb_width - 1; + edges[3] = y_ctb == s->ps.sps->ctb_height - 1; if (restore) { if (!edges[0]) { - left_tile_edge = no_tile_filter && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs-1]]; + left_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1]]; vert_edge[0] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb - 1, y_ctb)) || left_tile_edge; } if (!edges[2]) { - right_tile_edge = no_tile_filter && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs+1]]; + right_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs+1]]; vert_edge[1] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb + 1, y_ctb)) || right_tile_edge; } if (!edges[1]) { - up_tile_edge = no_tile_filter && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs - s->sps->ctb_width]]; + up_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs - s->ps.sps->ctb_width]]; horiz_edge[0] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb, y_ctb - 1)) || up_tile_edge; } if (!edges[3]) { - bottom_tile_edge = no_tile_filter && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs + s->sps->ctb_width]]; + bottom_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs + s->ps.sps->ctb_width]]; horiz_edge[1] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb, y_ctb + 1)) || bottom_tile_edge; } if (!edges[0] && !edges[1]) { @@ -304,16 +304,16 @@ } } - for (c_idx = 0; c_idx < (s->sps->chroma_format_idc ? 3 : 1); c_idx++) { - int x0 = x >> s->sps->hshift[c_idx]; - int y0 = y >> s->sps->vshift[c_idx]; + for (c_idx = 0; c_idx < (s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) { + int x0 = x >> s->ps.sps->hshift[c_idx]; + int y0 = y >> s->ps.sps->vshift[c_idx]; int stride_src = s->frame->linesize[c_idx]; - int ctb_size_h = (1 << (s->sps->log2_ctb_size)) >> s->sps->hshift[c_idx]; - int ctb_size_v = (1 << (s->sps->log2_ctb_size)) >> s->sps->vshift[c_idx]; - int width = FFMIN(ctb_size_h, (s->sps->width >> s->sps->hshift[c_idx]) - x0); - int height = FFMIN(ctb_size_v, (s->sps->height >> s->sps->vshift[c_idx]) - y0); + int ctb_size_h = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->hshift[c_idx]; + int ctb_size_v = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->vshift[c_idx]; + int width = FFMIN(ctb_size_h, (s->ps.sps->width >> s->ps.sps->hshift[c_idx]) - x0); + int height = FFMIN(ctb_size_v, (s->ps.sps->height >> s->ps.sps->vshift[c_idx]) - y0); int tab = sao_tab[(FFALIGN(width, 8) >> 3) - 1]; - uint8_t *src = &s->frame->data[c_idx][y0 * stride_src + (x0 << s->sps->pixel_shift)]; + uint8_t *src = &s->frame->data[c_idx][y0 * stride_src + (x0 << s->ps.sps->pixel_shift)]; int stride_dst; uint8_t *dst; @@ -321,11 +321,11 @@ case SAO_BAND: copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx, x_ctb, y_ctb); - if (s->pps->transquant_bypass_enable_flag || - (s->sps->pcm.loop_filter_disable_flag && s->sps->pcm_enabled_flag)) { + if (s->ps.pps->transquant_bypass_enable_flag || + (s->ps.sps->pcm.loop_filter_disable_flag && s->ps.sps->pcm_enabled_flag)) { dst = lc->edge_emu_buffer; stride_dst = 2*MAX_PB_SIZE; - copy_CTB(dst, src, width << s->sps->pixel_shift, height, stride_dst, stride_src); + copy_CTB(dst, src, width << s->ps.sps->pixel_shift, height, stride_dst, stride_src); s->hevcdsp.sao_band_filter[tab](src, dst, stride_src, stride_dst, sao->offset_val[c_idx], sao->band_position[c_idx], width, height); @@ -340,17 +340,17 @@ break; case SAO_EDGE: { - int w = s->sps->width >> s->sps->hshift[c_idx]; - int h = s->sps->height >> s->sps->vshift[c_idx]; + int w = s->ps.sps->width >> s->ps.sps->hshift[c_idx]; + int h = s->ps.sps->height >> s->ps.sps->vshift[c_idx]; int left_edge = edges[0]; int top_edge = edges[1]; int right_edge = edges[2]; int bottom_edge = edges[3]; - int sh = s->sps->pixel_shift; + int sh = s->ps.sps->pixel_shift; int left_pixels, right_pixels; - stride_dst = 2*MAX_PB_SIZE + FF_INPUT_BUFFER_PADDING_SIZE; - dst = lc->edge_emu_buffer + stride_dst + FF_INPUT_BUFFER_PADDING_SIZE; + stride_dst = 2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE; + dst = lc->edge_emu_buffer + stride_dst + AV_INPUT_BUFFER_PADDING_SIZE; if (!top_edge) { int left = 1 - left_edge; @@ -455,7 +455,7 @@ static int get_pcm(HEVCContext *s, int x, int y) { - int log2_min_pu_size = s->sps->log2_min_pu_size; + int log2_min_pu_size = s->ps.sps->log2_min_pu_size; int x_pu, y_pu; if (x < 0 || y < 0) @@ -464,9 +464,9 @@ x_pu = x >> log2_min_pu_size; y_pu = y >> log2_min_pu_size; - if (x_pu >= s->sps->min_pu_width || y_pu >= s->sps->min_pu_height) + if (x_pu >= s->ps.sps->min_pu_width || y_pu >= s->ps.sps->min_pu_height) return 2; - return s->is_pcm[y_pu * s->sps->min_pu_width + x_pu]; + return s->is_pcm[y_pu * s->ps.sps->min_pu_width + x_pu]; } #define TC_CALC(qp, bs) \ @@ -483,18 +483,18 @@ uint8_t no_p[2] = { 0 }; uint8_t no_q[2] = { 0 }; - int log2_ctb_size = s->sps->log2_ctb_size; + int log2_ctb_size = s->ps.sps->log2_ctb_size; int x_end, x_end2, y_end; int ctb_size = 1 << log2_ctb_size; int ctb = (x0 >> log2_ctb_size) + - (y0 >> log2_ctb_size) * s->sps->ctb_width; + (y0 >> log2_ctb_size) * s->ps.sps->ctb_width; int cur_tc_offset = s->deblock[ctb].tc_offset; int cur_beta_offset = s->deblock[ctb].beta_offset; int left_tc_offset, left_beta_offset; int tc_offset, beta_offset; - int pcmf = (s->sps->pcm_enabled_flag && - s->sps->pcm.loop_filter_disable_flag) || - s->pps->transquant_bypass_enable_flag; + int pcmf = (s->ps.sps->pcm_enabled_flag && + s->ps.sps->pcm.loop_filter_disable_flag) || + s->ps.pps->transquant_bypass_enable_flag; if (x0) { left_tc_offset = s->deblock[ctb - 1].tc_offset; @@ -505,17 +505,17 @@ } x_end = x0 + ctb_size; - if (x_end > s->sps->width) - x_end = s->sps->width; + if (x_end > s->ps.sps->width) + x_end = s->ps.sps->width; y_end = y0 + ctb_size; - if (y_end > s->sps->height) - y_end = s->sps->height; + if (y_end > s->ps.sps->height) + y_end = s->ps.sps->height; tc_offset = cur_tc_offset; beta_offset = cur_beta_offset; x_end2 = x_end; - if (x_end2 != s->sps->width) + if (x_end2 != s->ps.sps->width) x_end2 -= 8; for (y = y0; y < y_end; y += 8) { // vertical filtering luma @@ -529,7 +529,7 @@ tc[0] = bs0 ? TC_CALC(qp, bs0) : 0; tc[1] = bs1 ? TC_CALC(qp, bs1) : 0; - src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)]; + src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->ps.sps->pixel_shift)]; if (pcmf) { no_p[0] = get_pcm(s, x - 1, y); no_p[1] = get_pcm(s, x - 1, y + 4); @@ -561,7 +561,7 @@ beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)]; tc[0] = bs0 ? TC_CALC(qp, bs0) : 0; tc[1] = bs1 ? TC_CALC(qp, bs1) : 0; - src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)]; + src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->ps.sps->pixel_shift)]; if (pcmf) { no_p[0] = get_pcm(s, x, y - 1); no_p[1] = get_pcm(s, x + 4, y - 1); @@ -578,10 +578,10 @@ } } - if (s->sps->chroma_format_idc) { + if (s->ps.sps->chroma_format_idc) { for (chroma = 1; chroma <= 2; chroma++) { - int h = 1 << s->sps->hshift[chroma]; - int v = 1 << s->sps->vshift[chroma]; + int h = 1 << s->ps.sps->hshift[chroma]; + int v = 1 << s->ps.sps->vshift[chroma]; // vertical filtering chroma for (y = y0; y < y_end; y += (8 * v)) { @@ -595,7 +595,7 @@ c_tc[0] = (bs0 == 2) ? chroma_tc(s, qp0, chroma, tc_offset) : 0; c_tc[1] = (bs1 == 2) ? chroma_tc(s, qp1, chroma, tc_offset) : 0; - src = &s->frame->data[chroma][(y >> s->sps->vshift[chroma]) * s->frame->linesize[chroma] + ((x >> s->sps->hshift[chroma]) << s->sps->pixel_shift)]; + src = &s->frame->data[chroma][(y >> s->ps.sps->vshift[chroma]) * s->frame->linesize[chroma] + ((x >> s->ps.sps->hshift[chroma]) << s->ps.sps->pixel_shift)]; if (pcmf) { no_p[0] = get_pcm(s, x - 1, y); no_p[1] = get_pcm(s, x - 1, y + (4 * v)); @@ -617,7 +617,7 @@ // horizontal filtering chroma tc_offset = x0 ? left_tc_offset : cur_tc_offset; x_end2 = x_end; - if (x_end != s->sps->width) + if (x_end != s->ps.sps->width) x_end2 = x_end - 8 * h; for (x = x0 ? x0 - 8 * h : 0; x < x_end2; x += (8 * h)) { const int bs0 = s->horizontal_bs[( x + y * s->bs_width) >> 2]; @@ -628,7 +628,7 @@ c_tc[0] = bs0 == 2 ? chroma_tc(s, qp0, chroma, tc_offset) : 0; c_tc[1] = bs1 == 2 ? chroma_tc(s, qp1, chroma, cur_tc_offset) : 0; - src = &s->frame->data[chroma][(y >> s->sps->vshift[1]) * s->frame->linesize[chroma] + ((x >> s->sps->hshift[1]) << s->sps->pixel_shift)]; + src = &s->frame->data[chroma][(y >> s->ps.sps->vshift[1]) * s->frame->linesize[chroma] + ((x >> s->ps.sps->hshift[1]) << s->ps.sps->pixel_shift)]; if (pcmf) { no_p[0] = get_pcm(s, x, y - 1); no_p[1] = get_pcm(s, x + (4 * h), y - 1); @@ -717,10 +717,10 @@ { HEVCLocalContext *lc = s->HEVClc; MvField *tab_mvf = s->ref->tab_mvf; - int log2_min_pu_size = s->sps->log2_min_pu_size; - int log2_min_tu_size = s->sps->log2_min_tb_size; - int min_pu_width = s->sps->min_pu_width; - int min_tu_width = s->sps->min_tb_width; + int log2_min_pu_size = s->ps.sps->log2_min_pu_size; + int log2_min_tu_size = s->ps.sps->log2_min_tb_size; + int min_pu_width = s->ps.sps->min_pu_width; + int min_tu_width = s->ps.sps->min_tb_width; int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width + (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA; int boundary_upper, boundary_left; @@ -730,10 +730,10 @@ if (boundary_upper && ((!s->sh.slice_loop_filter_across_slices_enabled_flag && lc->boundary_flags & BOUNDARY_UPPER_SLICE && - (y0 % (1 << s->sps->log2_ctb_size)) == 0) || - (!s->pps->loop_filter_across_tiles_enabled_flag && + (y0 % (1 << s->ps.sps->log2_ctb_size)) == 0) || + (!s->ps.pps->loop_filter_across_tiles_enabled_flag && lc->boundary_flags & BOUNDARY_UPPER_TILE && - (y0 % (1 << s->sps->log2_ctb_size)) == 0))) + (y0 % (1 << s->ps.sps->log2_ctb_size)) == 0))) boundary_upper = 0; if (boundary_upper) { @@ -768,10 +768,10 @@ if (boundary_left && ((!s->sh.slice_loop_filter_across_slices_enabled_flag && lc->boundary_flags & BOUNDARY_LEFT_SLICE && - (x0 % (1 << s->sps->log2_ctb_size)) == 0) || - (!s->pps->loop_filter_across_tiles_enabled_flag && + (x0 % (1 << s->ps.sps->log2_ctb_size)) == 0) || + (!s->ps.pps->loop_filter_across_tiles_enabled_flag && lc->boundary_flags & BOUNDARY_LEFT_TILE && - (x0 % (1 << s->sps->log2_ctb_size)) == 0))) + (x0 % (1 << s->ps.sps->log2_ctb_size)) == 0))) boundary_left = 0; if (boundary_left) { @@ -842,10 +842,11 @@ void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size) { - int x_end = x >= s->sps->width - ctb_size; - deblocking_filter_CTB(s, x, y); - if (s->sps->sao_enabled) { - int y_end = y >= s->sps->height - ctb_size; + int x_end = x >= s->ps.sps->width - ctb_size; + if (s->avctx->skip_loop_filter < AVDISCARD_ALL) + deblocking_filter_CTB(s, x, y); + if (s->ps.sps->sao_enabled) { + int y_end = y >= s->ps.sps->height - ctb_size; if (y && x) sao_filter_CTB(s, x - ctb_size, y - ctb_size); if (x && y_end) @@ -866,8 +867,8 @@ void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size) { - int x_end = x_ctb >= s->sps->width - ctb_size; - int y_end = y_ctb >= s->sps->height - ctb_size; + int x_end = x_ctb >= s->ps.sps->width - ctb_size; + int y_end = y_ctb >= s->ps.sps->height - ctb_size; if (y_ctb && x_ctb) ff_hevc_hls_filter(s, x_ctb - ctb_size, y_ctb - ctb_size, ctb_size); if (y_ctb && x_end) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc.h 2015-08-03 17:20:02.000000000 +0000 @@ -276,6 +276,7 @@ typedef struct ShortTermRPS { unsigned int num_negative_pics; int num_delta_pocs; + int rps_idx_num_delta_pocs; int32_t delta_poc[32]; uint8_t used[32]; } ShortTermRPS; @@ -557,6 +558,17 @@ int *min_tb_addr_zs_tab;///< MinTbAddrZS } HEVCPPS; +typedef struct HEVCParamSets { + AVBufferRef *vps_list[MAX_VPS_COUNT]; + AVBufferRef *sps_list[MAX_SPS_COUNT]; + AVBufferRef *pps_list[MAX_PPS_COUNT]; + + /* currently active parameter sets */ + const HEVCVPS *vps; + const HEVCSPS *sps; + const HEVCPPS *pps; +} HEVCParamSets; + typedef struct SliceHeader { unsigned int pps_id; @@ -579,6 +591,7 @@ int short_term_ref_pic_set_size; ShortTermRPS slice_rps; const ShortTermRPS *short_term_rps; + int long_term_ref_pic_set_size; LongTermRPS long_term_rps; unsigned int list_entry_lx[2][32]; @@ -742,8 +755,24 @@ int raw_size; const uint8_t *raw_data; + + GetBitContext gb; + + enum NALUnitType type; + int temporal_id; + + int skipped_bytes; + int skipped_bytes_pos_size; + int *skipped_bytes_pos; } HEVCNAL; +/* an input packet split into unescaped NAL units */ +typedef struct HEVCPacket { + HEVCNAL *nals; + int nb_nals; + int nals_allocated; +} HEVCPacket; + typedef struct HEVCLocalContext { uint8_t cabac_state[HEVC_CONTEXTS]; @@ -812,12 +841,7 @@ uint8_t *sao_pixel_buffer_h[3]; uint8_t *sao_pixel_buffer_v[3]; - const HEVCVPS *vps; - const HEVCSPS *sps; - const HEVCPPS *pps; - AVBufferRef *vps_list[MAX_VPS_COUNT]; - AVBufferRef *sps_list[MAX_SPS_COUNT]; - AVBufferRef *pps_list[MAX_PPS_COUNT]; + HEVCParamSets ps; AVBufferPool *tab_mvf_pool; AVBufferPool *rpl_tab_pool; @@ -878,19 +902,10 @@ int enable_parallel_tiles; int wpp_err; - int skipped_bytes; - int *skipped_bytes_pos; - int skipped_bytes_pos_size; - - int *skipped_bytes_nal; - int **skipped_bytes_pos_nal; - int *skipped_bytes_pos_size_nal; const uint8_t *data; - HEVCNAL *nals; - int nb_nals; - int nals_allocated; + HEVCPacket pkt; // type of the first VCL NAL of the current frame enum NALUnitType first_nal_type; @@ -923,15 +938,28 @@ int picture_struct; } HEVCContext; -int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps, - const HEVCSPS *sps, int is_slice_header); -int ff_hevc_decode_nal_vps(HEVCContext *s); -int ff_hevc_decode_nal_sps(HEVCContext *s); -int ff_hevc_decode_nal_pps(HEVCContext *s); -int ff_hevc_decode_nal_sei(HEVCContext *s); +int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, + ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header); -int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length, - HEVCNAL *nal); +/** + * Parse the SPS from the bitstream into the provided HEVCSPS struct. + * + * @param sps_id the SPS id will be written here + * @param apply_defdispwin if set 1, the default display window from the VUI + * will be applied to the video dimensions + * @param vps_list if non-NULL, this function will validate that the SPS refers + * to an existing VPS + */ +int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, + int apply_defdispwin, AVBufferRef **vps_list, AVCodecContext *avctx); + +int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, + HEVCParamSets *ps); +int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx, + HEVCParamSets *ps, int apply_defdispwin); +int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, + HEVCParamSets *ps); +int ff_hevc_decode_nal_sei(HEVCContext *s); /** * Mark all frames in DPB as unused for reference. @@ -1037,6 +1065,21 @@ void ff_hevc_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size); +/** + * Extract the raw (unescaped) HEVC bitstream. + */ +int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length, + HEVCNAL *nal); + +/** + * Split an input packet into NAL units. + */ +int ff_hevc_split_packet(HEVCContext *s, HEVCPacket *pkt, const uint8_t *buf, int length, + AVCodecContext *avctx, int is_nalff, int nal_length_size); + +int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id, + uint8_t *buf, int buf_size); + extern const uint8_t ff_hevc_qpel_extra_before[4]; extern const uint8_t ff_hevc_qpel_extra_after[4]; extern const uint8_t ff_hevc_qpel_extra[4]; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_mp4toannexb_bsf.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_mp4toannexb_bsf.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_mp4toannexb_bsf.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_mp4toannexb_bsf.c 2015-08-02 17:20:02.000000000 +0000 @@ -0,0 +1,212 @@ +/* + * HEVC MP4 to Annex B byte stream format filter + * copyright (c) 2015 Anton Khirnov + * + * 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 + +#include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" + +#include "avcodec.h" +#include "bytestream.h" +#include "hevc.h" + +#define MIN_HEVCC_LENGTH 23 + +typedef struct HEVCBSFContext { + uint8_t length_size; + int extradata_parsed; + + int logged_nonmp4_warning; + + /* When private_spspps is zero then spspps_buf points to global extradata + and bsf does replace a global extradata to own-allocated version (default + behaviour). + When private_spspps is non-zero the bsf uses a private version of spspps buf. + This mode necessary when bsf uses in decoder, else bsf has issues after + decoder re-initialization. Use the "private_spspps_buf" argument to + activate this mode. + */ + int private_spspps; + uint8_t *spspps_buf; + uint32_t spspps_size; +} HEVCBSFContext; + +static int hevc_extradata_to_annexb(HEVCBSFContext* ctx, AVCodecContext *avctx) +{ + GetByteContext gb; + int length_size, num_arrays, i, j; + int ret = 0; + + uint8_t *new_extradata = NULL; + size_t new_extradata_size = 0; + + bytestream2_init(&gb, avctx->extradata, avctx->extradata_size); + + bytestream2_skip(&gb, 21); + length_size = (bytestream2_get_byte(&gb) & 3) + 1; + num_arrays = bytestream2_get_byte(&gb); + + for (i = 0; i < num_arrays; i++) { + int type = bytestream2_get_byte(&gb) & 0x3f; + int cnt = bytestream2_get_be16(&gb); + + if (!(type == NAL_VPS || type == NAL_SPS || type == NAL_PPS || + type == NAL_SEI_PREFIX || type == NAL_SEI_SUFFIX)) { + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit type in extradata: %d\n", + type); + ret = AVERROR_INVALIDDATA; + goto fail; + } + + for (j = 0; j < cnt; j++) { + int nalu_len = bytestream2_get_be16(&gb); + + if (4 + AV_INPUT_BUFFER_PADDING_SIZE + nalu_len > SIZE_MAX - new_extradata_size) { + ret = AVERROR_INVALIDDATA; + goto fail; + } + ret = av_reallocp(&new_extradata, new_extradata_size + nalu_len + 4 + AV_INPUT_BUFFER_PADDING_SIZE); + if (ret < 0) + goto fail; + + AV_WB32(new_extradata + new_extradata_size, 1); // add the startcode + bytestream2_get_buffer(&gb, new_extradata + new_extradata_size + 4, nalu_len); + new_extradata_size += 4 + nalu_len; + memset(new_extradata + new_extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); + } + } + + if (!ctx->private_spspps) { + av_freep(&avctx->extradata); + avctx->extradata = new_extradata; + avctx->extradata_size = new_extradata_size; + } + ctx->spspps_buf = new_extradata; + ctx->spspps_size = new_extradata_size; + + if (!new_extradata_size) + av_log(avctx, AV_LOG_WARNING, "No parameter sets in the extradata\n"); + + return length_size; +fail: + av_freep(&new_extradata); + return ret; +} + +static int hevc_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, + AVCodecContext *avctx, const char *args, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, + int keyframe) +{ + HEVCBSFContext *ctx = bsfc->priv_data; + GetByteContext gb; + + uint8_t *out = NULL; + size_t out_size = 0; + int got_irap = 0; + int i, ret = 0; + + if (!ctx->extradata_parsed) { + if (avctx->extradata_size < MIN_HEVCC_LENGTH || + AV_RB24(avctx->extradata) == 1 || + AV_RB32(avctx->extradata) == 1) { + if (!ctx->logged_nonmp4_warning) { + av_log(avctx, AV_LOG_VERBOSE, + "The input looks like it is Annex B already\n"); + ctx->logged_nonmp4_warning = 1; + } + *poutbuf = buf; + *poutbuf_size = buf_size; + return 0; + } + if (args && strstr(args, "private_spspps_buf")) + ctx->private_spspps = 1; + + ret = hevc_extradata_to_annexb(ctx, avctx); + if (ret < 0) + return ret; + ctx->length_size = ret; + ctx->extradata_parsed = 1; + } + + *poutbuf_size = 0; + *poutbuf = NULL; + + bytestream2_init(&gb, buf, buf_size); + + while (bytestream2_get_bytes_left(&gb)) { + uint32_t nalu_size = 0; + int nalu_type; + int is_irap, add_extradata, extra_size; + + for (i = 0; i < ctx->length_size; i++) + nalu_size = (nalu_size << 8) | bytestream2_get_byte(&gb); + + nalu_type = (bytestream2_peek_byte(&gb) >> 1) & 0x3f; + + /* prepend extradata to IRAP frames */ + is_irap = nalu_type >= 16 && nalu_type <= 23; + add_extradata = is_irap && !got_irap; + extra_size = add_extradata * ctx->spspps_size; + got_irap |= is_irap; + + if (SIZE_MAX - out_size < 4 || + SIZE_MAX - out_size - 4 < nalu_size || + SIZE_MAX - out_size - 4 - nalu_size < extra_size) { + ret = AVERROR_INVALIDDATA; + goto fail; + } + + ret = av_reallocp(&out, out_size + 4 + nalu_size + extra_size); + if (ret < 0) + goto fail; + + if (add_extradata) + memcpy(out + out_size, ctx->spspps_buf, extra_size); + AV_WB32(out + out_size + extra_size, 1); + bytestream2_get_buffer(&gb, out + out_size + 4 + extra_size, nalu_size); + out_size += 4 + nalu_size + extra_size; + } + + *poutbuf = out; + *poutbuf_size = out_size; + + return 1; + +fail: + av_freep(&out); + return ret; +} + +static void hevc_mp4toannexb_close(AVBitStreamFilterContext *bsfc) +{ + HEVCBSFContext *ctx = bsfc->priv_data; + if (ctx->private_spspps) + av_freep(&ctx->spspps_buf); +} + +AVBitStreamFilter ff_hevc_mp4toannexb_bsf = { + "hevc_mp4toannexb", + sizeof(HEVCBSFContext), + hevc_mp4toannexb_filter, + hevc_mp4toannexb_close, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_mvs.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_mvs.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_mvs.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_mvs.c 2015-07-13 17:20:03.000000000 +0000 @@ -42,14 +42,14 @@ int nPbW, int nPbH) { HEVCLocalContext *lc = s->HEVClc; - int x0b = av_mod_uintp2(x0, s->sps->log2_ctb_size); - int y0b = av_mod_uintp2(y0, s->sps->log2_ctb_size); + int x0b = av_mod_uintp2(x0, s->ps.sps->log2_ctb_size); + int y0b = av_mod_uintp2(y0, s->ps.sps->log2_ctb_size); lc->na.cand_up = (lc->ctb_up_flag || y0b); lc->na.cand_left = (lc->ctb_left_flag || x0b); lc->na.cand_up_left = (!x0b && !y0b) ? lc->ctb_up_left_flag : lc->na.cand_left && lc->na.cand_up; lc->na.cand_up_right_sap = - ((x0b + nPbW) == (1 << s->sps->log2_ctb_size)) ? + ((x0b + nPbW) == (1 << s->ps.sps->log2_ctb_size)) ? lc->ctb_up_right_flag && !y0b : lc->na.cand_up; lc->na.cand_up_right = lc->na.cand_up_right_sap @@ -64,19 +64,19 @@ int xN, int yN) { #define MIN_TB_ADDR_ZS(x, y) \ - s->pps->min_tb_addr_zs[(y) * (s->sps->tb_mask+2) + (x)] + s->ps.pps->min_tb_addr_zs[(y) * (s->ps.sps->tb_mask+2) + (x)] - int xCurr_ctb = xCurr >> s->sps->log2_ctb_size; - int yCurr_ctb = yCurr >> s->sps->log2_ctb_size; - int xN_ctb = xN >> s->sps->log2_ctb_size; - int yN_ctb = yN >> s->sps->log2_ctb_size; + int xCurr_ctb = xCurr >> s->ps.sps->log2_ctb_size; + int yCurr_ctb = yCurr >> s->ps.sps->log2_ctb_size; + int xN_ctb = xN >> s->ps.sps->log2_ctb_size; + int yN_ctb = yN >> s->ps.sps->log2_ctb_size; if( yN_ctb < yCurr_ctb || xN_ctb < xCurr_ctb ) return 1; else { - int Curr = MIN_TB_ADDR_ZS((xCurr >> s->sps->log2_min_tb_size) & s->sps->tb_mask, - (yCurr >> s->sps->log2_min_tb_size) & s->sps->tb_mask); - int N = MIN_TB_ADDR_ZS((xN >> s->sps->log2_min_tb_size) & s->sps->tb_mask, - (yN >> s->sps->log2_min_tb_size) & s->sps->tb_mask); + int Curr = MIN_TB_ADDR_ZS((xCurr >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask, + (yCurr >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask); + int N = MIN_TB_ADDR_ZS((xN >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask, + (yN >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask); return N <= Curr; } } @@ -84,7 +84,7 @@ //check if the two luma locations belong to the same mostion estimation region static av_always_inline int is_diff_mer(HEVCContext *s, int xN, int yN, int xP, int yP) { - uint8_t plevel = s->pps->log2_parallel_merge_level; + uint8_t plevel = s->ps.pps->log2_parallel_merge_level; return xN >> plevel == xP >> plevel && yN >> plevel == yP >> plevel; @@ -203,8 +203,8 @@ tab_mvf[(y) * min_pu_width + x] #define TAB_MVF_PU(v) \ - TAB_MVF(((x ## v) >> s->sps->log2_min_pu_size), \ - ((y ## v) >> s->sps->log2_min_pu_size)) + TAB_MVF(((x ## v) >> s->ps.sps->log2_min_pu_size), \ + ((y ## v) >> s->ps.sps->log2_min_pu_size)) #define DERIVE_TEMPORAL_COLOCATED_MVS \ derive_temporal_colocated_mvs(s, temp_col, \ @@ -221,7 +221,7 @@ MvField *tab_mvf; MvField temp_col; int x, y, x_pu, y_pu; - int min_pu_width = s->sps->min_pu_width; + int min_pu_width = s->ps.sps->min_pu_width; int availableFlagLXCol = 0; int colPic; @@ -240,15 +240,15 @@ y = y0 + nPbH; if (tab_mvf && - (y0 >> s->sps->log2_ctb_size) == (y >> s->sps->log2_ctb_size) && - y < s->sps->height && - x < s->sps->width) { + (y0 >> s->ps.sps->log2_ctb_size) == (y >> s->ps.sps->log2_ctb_size) && + y < s->ps.sps->height && + x < s->ps.sps->width) { x &= ~15; y &= ~15; if (s->threads_type == FF_THREAD_FRAME) ff_thread_await_progress(&ref->tf, y, 0); - x_pu = x >> s->sps->log2_min_pu_size; - y_pu = y >> s->sps->log2_min_pu_size; + x_pu = x >> s->ps.sps->log2_min_pu_size; + y_pu = y >> s->ps.sps->log2_min_pu_size; temp_col = TAB_MVF(x_pu, y_pu); availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS; } @@ -261,8 +261,8 @@ y &= ~15; if (s->threads_type == FF_THREAD_FRAME) ff_thread_await_progress(&ref->tf, y, 0); - x_pu = x >> s->sps->log2_min_pu_size; - y_pu = y >> s->sps->log2_min_pu_size; + x_pu = x >> s->ps.sps->log2_min_pu_size; + y_pu = y >> s->ps.sps->log2_min_pu_size; temp_col = TAB_MVF(x_pu, y_pu); availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS; } @@ -292,7 +292,7 @@ RefPicList *refPicList = s->ref->refPicList; MvField *tab_mvf = s->ref->tab_mvf; - const int min_pu_width = s->sps->min_pu_width; + const int min_pu_width = s->ps.sps->min_pu_width; const int cand_bottom_left = lc->na.cand_bottom_left; const int cand_left = lc->na.cand_left; @@ -365,7 +365,7 @@ // above right spatial merge candidate is_available_b0 = AVAILABLE(cand_up_right, B0) && - xB0 < s->sps->width && + xB0 < s->ps.sps->width && PRED_BLOCK_AVAILABLE(B0) && !is_diff_mer(s, xB0, yB0, x0, y0); @@ -379,7 +379,7 @@ // left bottom spatial merge candidate is_available_a0 = AVAILABLE(cand_bottom_left, A0) && - yA0 < s->sps->height && + yA0 < s->ps.sps->height && PRED_BLOCK_AVAILABLE(A0) && !is_diff_mer(s, xA0, yA0, x0, y0); @@ -486,7 +486,7 @@ int nPbH2 = nPbH; HEVCLocalContext *lc = s->HEVClc; - if (s->pps->log2_parallel_merge_level > 2 && nCS == 8) { + if (s->ps.pps->log2_parallel_merge_level > 2 && nCS == 8) { singleMCLFlag = 1; x0 = lc->cu.x; y0 = lc->cu.y; @@ -529,7 +529,7 @@ Mv *mv, int ref_idx_curr, int ref_idx) { MvField *tab_mvf = s->ref->tab_mvf; - int min_pu_width = s->sps->min_pu_width; + int min_pu_width = s->ps.sps->min_pu_width; RefPicList *refPicList = s->ref->refPicList; @@ -545,7 +545,7 @@ Mv *mv, int ref_idx_curr, int ref_idx) { MvField *tab_mvf = s->ref->tab_mvf; - int min_pu_width = s->sps->min_pu_width; + int min_pu_width = s->ps.sps->min_pu_width; RefPicList *refPicList = s->ref->refPicList; @@ -568,14 +568,14 @@ #define MP_MX(v, pred, mx) \ mv_mp_mode_mx(s, \ - (x ## v) >> s->sps->log2_min_pu_size, \ - (y ## v) >> s->sps->log2_min_pu_size, \ + (x ## v) >> s->ps.sps->log2_min_pu_size, \ + (y ## v) >> s->ps.sps->log2_min_pu_size, \ pred, &mx, ref_idx_curr, ref_idx) #define MP_MX_LT(v, pred, mx) \ mv_mp_mode_mx_lt(s, \ - (x ## v) >> s->sps->log2_min_pu_size, \ - (y ## v) >> s->sps->log2_min_pu_size, \ + (x ## v) >> s->ps.sps->log2_min_pu_size, \ + (y ## v) >> s->ps.sps->log2_min_pu_size, \ pred, &mx, ref_idx_curr, ref_idx) void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW, @@ -589,7 +589,7 @@ int availableFlagLXA0 = 1; int availableFlagLXB0 = 1; int numMVPCandLX = 0; - int min_pu_width = s->sps->min_pu_width; + int min_pu_width = s->ps.sps->min_pu_width; int xA0, yA0; int is_available_a0; @@ -625,7 +625,7 @@ yA0 = y0 + nPbH; is_available_a0 = AVAILABLE(cand_bottom_left, A0) && - yA0 < s->sps->height && + yA0 < s->ps.sps->height && PRED_BLOCK_AVAILABLE(A0); //left spatial merge candidate @@ -680,7 +680,7 @@ yB0 = y0 - 1; is_available_b0 = AVAILABLE(cand_up_right, B0) && - xB0 < s->sps->width && + xB0 < s->ps.sps->width && PRED_BLOCK_AVAILABLE(B0); // above spatial merge candidate diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_parse.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_parse.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_parse.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_parse.c 2015-07-28 17:20:07.000000000 +0000 @@ -0,0 +1,291 @@ +/* + * HEVC common code + * + * 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 + +#include "config.h" + +#include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" + +#include "hevc.h" + +/* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication + * between these functions would be nice. */ +int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length, + HEVCNAL *nal) +{ + int i, si, di; + uint8_t *dst; + + if (s) + nal->skipped_bytes = 0; +#define STARTCODE_TEST \ + if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \ + if (src[i + 2] != 3) { \ + /* startcode, so we must be past the end */ \ + length = i; \ + } \ + break; \ + } +#if HAVE_FAST_UNALIGNED +#define FIND_FIRST_ZERO \ + if (i > 0 && !src[i]) \ + i--; \ + while (src[i]) \ + i++ +#if HAVE_FAST_64BIT + for (i = 0; i + 1 < length; i += 9) { + if (!((~AV_RN64A(src + i) & + (AV_RN64A(src + i) - 0x0100010001000101ULL)) & + 0x8000800080008080ULL)) + continue; + FIND_FIRST_ZERO; + STARTCODE_TEST; + i -= 7; + } +#else + for (i = 0; i + 1 < length; i += 5) { + if (!((~AV_RN32A(src + i) & + (AV_RN32A(src + i) - 0x01000101U)) & + 0x80008080U)) + continue; + FIND_FIRST_ZERO; + STARTCODE_TEST; + i -= 3; + } +#endif /* HAVE_FAST_64BIT */ +#else + for (i = 0; i + 1 < length; i += 2) { + if (src[i]) + continue; + if (i > 0 && src[i - 1] == 0) + i--; + STARTCODE_TEST; + } +#endif /* HAVE_FAST_UNALIGNED */ + + if (i >= length - 1) { // no escaped 0 + nal->data = + nal->raw_data = src; + nal->size = + nal->raw_size = length; + return length; + } + + av_fast_malloc(&nal->rbsp_buffer, &nal->rbsp_buffer_size, + length + AV_INPUT_BUFFER_PADDING_SIZE); + if (!nal->rbsp_buffer) + return AVERROR(ENOMEM); + + dst = nal->rbsp_buffer; + + memcpy(dst, src, i); + si = di = i; + while (si + 2 < length) { + // remove escapes (very rare 1:2^22) + if (src[si + 2] > 3) { + dst[di++] = src[si++]; + dst[di++] = src[si++]; + } else if (src[si] == 0 && src[si + 1] == 0) { + if (src[si + 2] == 3) { // escape + dst[di++] = 0; + dst[di++] = 0; + si += 3; + + if (s && nal->skipped_bytes_pos) { + nal->skipped_bytes++; + if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { + nal->skipped_bytes_pos_size *= 2; + av_assert0(nal->skipped_bytes_pos_size >= nal->skipped_bytes); + av_reallocp_array(&nal->skipped_bytes_pos, + nal->skipped_bytes_pos_size, + sizeof(*nal->skipped_bytes_pos)); + if (!nal->skipped_bytes_pos) { + nal->skipped_bytes_pos_size = 0; + return AVERROR(ENOMEM); + } + } + if (nal->skipped_bytes_pos) + nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1; + } + continue; + } else // next start code + goto nsc; + } + + dst[di++] = src[si++]; + } + while (si < length) + dst[di++] = src[si++]; + +nsc: + memset(dst + di, 0, AV_INPUT_BUFFER_PADDING_SIZE); + + nal->data = dst; + nal->size = di; + nal->raw_data = src; + nal->raw_size = si; + return si; +} + +static const char *nal_unit_name(int nal_type) +{ + switch(nal_type) { + case NAL_TRAIL_N : return "TRAIL_N"; + case NAL_TRAIL_R : return "TRAIL_R"; + case NAL_TSA_N : return "TSA_N"; + case NAL_TSA_R : return "TSA_R"; + case NAL_STSA_N : return "STSA_N"; + case NAL_STSA_R : return "STSA_R"; + case NAL_RADL_N : return "RADL_N"; + case NAL_RADL_R : return "RADL_R"; + case NAL_RASL_N : return "RASL_N"; + case NAL_RASL_R : return "RASL_R"; + case NAL_BLA_W_LP : return "BLA_W_LP"; + case NAL_BLA_W_RADL : return "BLA_W_RADL"; + case NAL_BLA_N_LP : return "BLA_N_LP"; + case NAL_IDR_W_RADL : return "IDR_W_RADL"; + case NAL_IDR_N_LP : return "IDR_N_LP"; + case NAL_CRA_NUT : return "CRA_NUT"; + case NAL_VPS : return "VPS"; + case NAL_SPS : return "SPS"; + case NAL_PPS : return "PPS"; + case NAL_AUD : return "AUD"; + case NAL_EOS_NUT : return "EOS_NUT"; + case NAL_EOB_NUT : return "EOB_NUT"; + case NAL_FD_NUT : return "FD_NUT"; + case NAL_SEI_PREFIX : return "SEI_PREFIX"; + case NAL_SEI_SUFFIX : return "SEI_SUFFIX"; + default : return "?"; + } +} + +/** + * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit, + * 0 if the unit should be skipped, 1 otherwise + */ +static int hls_nal_unit(HEVCNAL *nal, AVCodecContext *avctx) +{ + GetBitContext *gb = &nal->gb; + int nuh_layer_id; + + if (get_bits1(gb) != 0) + return AVERROR_INVALIDDATA; + + nal->type = get_bits(gb, 6); + + nuh_layer_id = get_bits(gb, 6); + nal->temporal_id = get_bits(gb, 3) - 1; + if (nal->temporal_id < 0) + return AVERROR_INVALIDDATA; + + av_log(avctx, AV_LOG_DEBUG, + "nal_unit_type: %d(%s), nuh_layer_id: %d, temporal_id: %d\n", + nal->type, nal_unit_name(nal->type), nuh_layer_id, nal->temporal_id); + + return nuh_layer_id == 0; +} + + +int ff_hevc_split_packet(HEVCContext *s, HEVCPacket *pkt, const uint8_t *buf, int length, + AVCodecContext *avctx, int is_nalff, int nal_length_size) +{ + int consumed, ret = 0; + + pkt->nb_nals = 0; + while (length >= 4) { + HEVCNAL *nal; + int extract_length = 0; + + if (is_nalff) { + int i; + for (i = 0; i < nal_length_size; i++) + extract_length = (extract_length << 8) | buf[i]; + buf += nal_length_size; + length -= nal_length_size; + + if (extract_length > length) { + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit size.\n"); + return AVERROR_INVALIDDATA; + } + } else { + /* search start code */ + while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) { + ++buf; + --length; + if (length < 4) { + av_log(avctx, AV_LOG_ERROR, "No start code is found.\n"); + return AVERROR_INVALIDDATA; + } + } + + buf += 3; + length -= 3; + extract_length = length; + } + + if (pkt->nals_allocated < pkt->nb_nals + 1) { + int new_size = pkt->nals_allocated + 1; + void *tmp = av_realloc_array(pkt->nals, new_size, sizeof(*pkt->nals)); + + if (!tmp) + return AVERROR(ENOMEM); + + pkt->nals = tmp; + memset(pkt->nals + pkt->nals_allocated, 0, + (new_size - pkt->nals_allocated) * sizeof(*pkt->nals)); + + nal = &pkt->nals[pkt->nb_nals]; + nal->skipped_bytes_pos_size = 1024; // initial buffer size + nal->skipped_bytes_pos = av_malloc_array(nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos)); + if (!nal->skipped_bytes_pos) + return AVERROR(ENOMEM); + + pkt->nals_allocated = new_size; + } + nal = &pkt->nals[pkt->nb_nals]; + + consumed = ff_hevc_extract_rbsp(s, buf, extract_length, nal); + if (consumed < 0) + return consumed; + + pkt->nb_nals++; + + ret = init_get_bits8(&nal->gb, nal->data, nal->size); + if (ret < 0) + return ret; + + ret = hls_nal_unit(nal, avctx); + if (ret <= 0) { + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n", + nal->type); + } + pkt->nb_nals--; + } + + buf += consumed; + length -= consumed; + } + + return 0; +} + diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_parser.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_parser.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_parser.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_parser.c 2015-07-19 17:20:03.000000000 +0000 @@ -22,16 +22,112 @@ #include "libavutil/common.h" -#include "parser.h" -#include "hevc.h" #include "golomb.h" +#include "hevc.h" +#include "parser.h" #define START_CODE 0x000001 ///< start_code_prefix_one_3bytes -typedef struct HEVCParseContext { - HEVCContext h; +#define IS_IRAP_NAL(nal) (nal->type >= 16 && nal->type <= 23) + +#define ADVANCED_PARSER CONFIG_HEVC_DECODER + +typedef struct HEVCParserContext { ParseContext pc; -} HEVCParseContext; + + HEVCPacket pkt; + HEVCParamSets ps; + + int parsed_extradata; + +#if ADVANCED_PARSER + HEVCContext h; +#endif +} HEVCParserContext; + +#if !ADVANCED_PARSER +static int hevc_parse_slice_header(AVCodecParserContext *s, HEVCNAL *nal, + AVCodecContext *avctx) +{ + HEVCParserContext *ctx = s->priv_data; + GetBitContext *gb = &nal->gb; + + HEVCPPS *pps; + HEVCSPS *sps; + unsigned int pps_id; + + get_bits1(gb); // first slice in pic + if (IS_IRAP_NAL(nal)) + get_bits1(gb); // no output of prior pics + + pps_id = get_ue_golomb_long(gb); + if (pps_id >= MAX_PPS_COUNT || !ctx->ps.pps_list[pps_id]) { + av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id); + return AVERROR_INVALIDDATA; + } + pps = (HEVCPPS*)ctx->ps.pps_list[pps_id]->data; + sps = (HEVCSPS*)ctx->ps.sps_list[pps->sps_id]->data; + + /* export the stream parameters */ + s->coded_width = sps->width; + s->coded_height = sps->height; + s->width = sps->output_width; + s->height = sps->output_height; + s->format = sps->pix_fmt; + avctx->profile = sps->ptl.general_ptl.profile_idc; + avctx->level = sps->ptl.general_ptl.level_idc; + + /* ignore the rest for now*/ + + return 0; +} + +static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, + int buf_size, AVCodecContext *avctx) +{ + HEVCParserContext *ctx = s->priv_data; + int ret, i; + + ret = ff_hevc_split_packet(NULL, &ctx->pkt, buf, buf_size, avctx, 0, 0); + if (ret < 0) + return ret; + + for (i = 0; i < ctx->pkt.nb_nals; i++) { + HEVCNAL *nal = &ctx->pkt.nals[i]; + + /* ignore everything except parameter sets and VCL NALUs */ + switch (nal->type) { + case NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, avctx, &ctx->ps); break; + case NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, avctx, &ctx->ps, 1); break; + case NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, avctx, &ctx->ps); break; + case NAL_TRAIL_R: + case NAL_TRAIL_N: + case NAL_TSA_N: + case NAL_TSA_R: + case NAL_STSA_N: + case NAL_STSA_R: + case NAL_BLA_W_LP: + case NAL_BLA_W_RADL: + case NAL_BLA_N_LP: + case NAL_IDR_W_RADL: + case NAL_IDR_N_LP: + case NAL_CRA_NUT: + case NAL_RADL_N: + case NAL_RADL_R: + case NAL_RASL_N: + case NAL_RASL_R: + if (buf == avctx->extradata) { + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", nal->type); + return AVERROR_INVALIDDATA; + } + hevc_parse_slice_header(s, nal, avctx); + break; + } + } + + return 0; +} +#endif /** * Find the end of the current frame in the bitstream. @@ -41,7 +137,7 @@ int buf_size) { int i; - ParseContext *pc = &((HEVCParseContext *)s->priv_data)->pc; + ParseContext *pc = s->priv_data; for (i = 0; i < buf_size; i++) { int nut; @@ -76,6 +172,7 @@ return END_NOT_FOUND; } +#if ADVANCED_PARSER /** * Parse NAL units of found picture and decode some basic information. * @@ -84,15 +181,26 @@ * @param buf buffer with field/frame data. * @param buf_size size of the buffer. */ -static inline int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, - const uint8_t *buf, int buf_size) +static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, + int buf_size, AVCodecContext *avctx) { - HEVCContext *h = &((HEVCParseContext *)s->priv_data)->h; - GetBitContext *gb = &h->HEVClc->gb; - SliceHeader *sh = &h->sh; + HEVCParserContext *ctx = s->priv_data; + HEVCContext *h = &ctx->h; + GetBitContext *gb; + SliceHeader *sh = &h->sh; + HEVCParamSets *ps = &h->ps; + HEVCPacket *pkt = &ctx->pkt; const uint8_t *buf_end = buf + buf_size; int state = -1, i; HEVCNAL *nal; + int is_global = buf == avctx->extradata; + + if (!h->HEVClc) + h->HEVClc = av_mallocz(sizeof(HEVCLocalContext)); + if (!h->HEVClc) + return AVERROR(ENOMEM); + + gb = &h->HEVClc->gb; /* set some sane default values */ s->pict_type = AV_PICTURE_TYPE_I; @@ -104,16 +212,16 @@ if (!buf_size) return 0; - if (h->nals_allocated < 1) { - HEVCNAL *tmp = av_realloc_array(h->nals, 1, sizeof(*tmp)); + if (pkt->nals_allocated < 1) { + HEVCNAL *tmp = av_realloc_array(pkt->nals, 1, sizeof(*tmp)); if (!tmp) return AVERROR(ENOMEM); - h->nals = tmp; - memset(h->nals, 0, sizeof(*tmp)); - h->nals_allocated = 1; + pkt->nals = tmp; + memset(pkt->nals, 0, sizeof(*tmp)); + pkt->nals_allocated = 1; } - nal = &h->nals[0]; + nal = &pkt->nals[0]; for (;;) { int src_length, consumed; @@ -130,20 +238,20 @@ src_length = 20; } - consumed = ff_hevc_extract_rbsp(h, buf, src_length, nal); + consumed = ff_hevc_extract_rbsp(NULL, buf, src_length, nal); if (consumed < 0) return consumed; init_get_bits8(gb, nal->data + 2, nal->size); switch (h->nal_unit_type) { case NAL_VPS: - ff_hevc_decode_nal_vps(h); + ff_hevc_decode_nal_vps(gb, avctx, ps); break; case NAL_SPS: - ff_hevc_decode_nal_sps(h); + ff_hevc_decode_nal_sps(gb, avctx, ps, 1); break; case NAL_PPS: - ff_hevc_decode_nal_pps(h); + ff_hevc_decode_nal_pps(gb, avctx, ps); break; case NAL_SEI_PREFIX: case NAL_SEI_SUFFIX: @@ -165,6 +273,12 @@ case NAL_IDR_W_RADL: case NAL_IDR_N_LP: case NAL_CRA_NUT: + + if (is_global) { + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", h->nal_unit_type); + return AVERROR_INVALIDDATA; + } + sh->first_slice_in_pic_flag = get_bits1(gb); s->picture_structure = h->picture_struct; s->field_order = h->picture_struct; @@ -175,34 +289,34 @@ } sh->pps_id = get_ue_golomb(gb); - if (sh->pps_id >= MAX_PPS_COUNT || !h->pps_list[sh->pps_id]) { - av_log(h->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id); + if (sh->pps_id >= MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) { + av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id); return AVERROR_INVALIDDATA; } - h->pps = (HEVCPPS*)h->pps_list[sh->pps_id]->data; + ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data; - if (h->pps->sps_id >= MAX_SPS_COUNT || !h->sps_list[h->pps->sps_id]) { - av_log(h->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", h->pps->sps_id); + if (ps->pps->sps_id >= MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) { + av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id); return AVERROR_INVALIDDATA; } - if (h->sps != (HEVCSPS*)h->sps_list[h->pps->sps_id]->data) { - h->sps = (HEVCSPS*)h->sps_list[h->pps->sps_id]->data; - h->vps = (HEVCVPS*)h->vps_list[h->sps->vps_id]->data; + if (ps->sps != (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data) { + ps->sps = (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data; + ps->vps = (HEVCVPS*)ps->vps_list[ps->sps->vps_id]->data; } if (!sh->first_slice_in_pic_flag) { int slice_address_length; - if (h->pps->dependent_slice_segments_enabled_flag) + if (ps->pps->dependent_slice_segments_enabled_flag) sh->dependent_slice_segment_flag = get_bits1(gb); else sh->dependent_slice_segment_flag = 0; - slice_address_length = av_ceil_log2_c(h->sps->ctb_width * - h->sps->ctb_height); - sh->slice_segment_addr = get_bits(gb, slice_address_length); - if (sh->slice_segment_addr >= h->sps->ctb_width * h->sps->ctb_height) { - av_log(h->avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n", + slice_address_length = av_ceil_log2_c(ps->sps->ctb_width * + ps->sps->ctb_height); + sh->slice_segment_addr = slice_address_length ? get_bits(gb, slice_address_length) : 0; + if (sh->slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) { + av_log(avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n", sh->slice_segment_addr); return AVERROR_INVALIDDATA; } @@ -212,13 +326,13 @@ if (sh->dependent_slice_segment_flag) break; - for (i = 0; i < h->pps->num_extra_slice_header_bits; i++) + for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++) skip_bits(gb, 1); // slice_reserved_undetermined_flag[] sh->slice_type = get_ue_golomb(gb); if (!(sh->slice_type == I_SLICE || sh->slice_type == P_SLICE || sh->slice_type == B_SLICE)) { - av_log(h->avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n", + av_log(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n", sh->slice_type); return AVERROR_INVALIDDATA; } @@ -226,14 +340,14 @@ sh->slice_type == P_SLICE ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; - if (h->pps->output_flag_present_flag) + if (ps->pps->output_flag_present_flag) sh->pic_output_flag = get_bits1(gb); - if (h->sps->separate_colour_plane_flag) + if (ps->sps->separate_colour_plane_flag) sh->colour_plane_id = get_bits(gb, 2); if (!IS_IDR(h)) { - sh->pic_order_cnt_lsb = get_bits(gb, h->sps->log2_max_poc_lsb); + sh->pic_order_cnt_lsb = get_bits(gb, ps->sps->log2_max_poc_lsb); s->output_picture_number = h->poc = ff_hevc_compute_poc(h, sh->pic_order_cnt_lsb); } else s->output_picture_number = h->poc = 0; @@ -253,9 +367,11 @@ buf += consumed; } /* didn't find a picture! */ - av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit\n"); + if (!is_global) + av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit\n"); return -1; } +#endif static int hevc_parse(AVCodecParserContext *s, AVCodecContext *avctx, @@ -263,7 +379,13 @@ const uint8_t *buf, int buf_size) { int next; - ParseContext *pc = &((HEVCParseContext *)s->priv_data)->pc; + HEVCParserContext *ctx = s->priv_data; + ParseContext *pc = &ctx->pc; + + if (avctx->extradata && !ctx->parsed_extradata) { + parse_nal_units(s, avctx->extradata, avctx->extradata_size, avctx); + ctx->parsed_extradata = 1; + } if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { next = buf_size; @@ -276,7 +398,7 @@ } } - parse_nal_units(s, avctx, buf, buf_size); + parse_nal_units(s, buf, buf_size, avctx); *poutbuf = buf; *poutbuf_size = buf_size; @@ -305,47 +427,49 @@ return 0; } -static int hevc_init(AVCodecParserContext *s) +static void hevc_parser_close(AVCodecParserContext *s) { - HEVCContext *h = &((HEVCParseContext *)s->priv_data)->h; - h->HEVClc = av_mallocz(sizeof(HEVCLocalContext)); - if (!h->HEVClc) - return AVERROR(ENOMEM); - h->skipped_bytes_pos_size = INT_MAX; + HEVCParserContext *ctx = s->priv_data; + int i; - return 0; -} +#if ADVANCED_PARSER + HEVCContext *h = &ctx->h; -static void hevc_close(AVCodecParserContext *s) -{ - int i; - HEVCContext *h = &((HEVCParseContext *)s->priv_data)->h; - ParseContext *pc = &((HEVCParseContext *)s->priv_data)->pc; + for (i = 0; i < FF_ARRAY_ELEMS(h->ps.vps_list); i++) + av_buffer_unref(&h->ps.vps_list[i]); + for (i = 0; i < FF_ARRAY_ELEMS(h->ps.sps_list); i++) + av_buffer_unref(&h->ps.sps_list[i]); + for (i = 0; i < FF_ARRAY_ELEMS(h->ps.pps_list); i++) + av_buffer_unref(&h->ps.pps_list[i]); + + h->ps.sps = NULL; - av_freep(&h->skipped_bytes_pos); av_freep(&h->HEVClc); - av_freep(&pc->buffer); +#endif + + for (i = 0; i < FF_ARRAY_ELEMS(ctx->ps.vps_list); i++) + av_buffer_unref(&ctx->ps.vps_list[i]); + for (i = 0; i < FF_ARRAY_ELEMS(ctx->ps.sps_list); i++) + av_buffer_unref(&ctx->ps.sps_list[i]); + for (i = 0; i < FF_ARRAY_ELEMS(ctx->ps.pps_list); i++) + av_buffer_unref(&ctx->ps.pps_list[i]); + + ctx->ps.sps = NULL; + + for (i = 0; i < ctx->pkt.nals_allocated; i++) { + av_freep(&ctx->pkt.nals[i].rbsp_buffer); + av_freep(&ctx->pkt.nals[i].skipped_bytes_pos); + } + av_freep(&ctx->pkt.nals); + ctx->pkt.nals_allocated = 0; - for (i = 0; i < FF_ARRAY_ELEMS(h->vps_list); i++) - av_buffer_unref(&h->vps_list[i]); - for (i = 0; i < FF_ARRAY_ELEMS(h->sps_list); i++) - av_buffer_unref(&h->sps_list[i]); - for (i = 0; i < FF_ARRAY_ELEMS(h->pps_list); i++) - av_buffer_unref(&h->pps_list[i]); - - h->sps = NULL; - - for (i = 0; i < h->nals_allocated; i++) - av_freep(&h->nals[i].rbsp_buffer); - av_freep(&h->nals); - h->nals_allocated = 0; + av_freep(&ctx->pc.buffer); } AVCodecParser ff_hevc_parser = { .codec_ids = { AV_CODEC_ID_HEVC }, - .priv_data_size = sizeof(HEVCParseContext), - .parser_init = hevc_init, + .priv_data_size = sizeof(HEVCParserContext), .parser_parse = hevc_parse, - .parser_close = hevc_close, + .parser_close = hevc_parser_close, .split = hevc_split, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevcpred.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevcpred.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevcpred.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevcpred.c 2015-06-10 17:20:04.000000000 +0000 @@ -74,4 +74,7 @@ HEVC_PRED(8); break; } + + if (ARCH_MIPS) + ff_hevc_pred_init_mips(hpc, bit_depth); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevcpred.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevcpred.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevcpred.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevcpred.h 2015-06-10 17:20:04.000000000 +0000 @@ -41,5 +41,6 @@ } HEVCPredContext; void ff_hevc_pred_init(HEVCPredContext *hpc, int bit_depth); +void ff_hevc_pred_init_mips(HEVCPredContext *hpc, int bit_depth); #endif /* AVCODEC_HEVCPRED_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevcpred_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevcpred_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevcpred_template.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevcpred_template.c 2015-07-13 17:20:03.000000000 +0000 @@ -31,7 +31,7 @@ int log2_size, int c_idx) { #define PU(x) \ - ((x) >> s->sps->log2_min_pu_size) + ((x) >> s->ps.sps->log2_min_pu_size) #define MVF(x, y) \ (s->ref->tab_mvf[(x) + (y) * min_pu_width]) #define MVF_PU(x, y) \ @@ -39,7 +39,7 @@ #define IS_INTRA(x, y) \ (MVF_PU(x, y).pred_flag == PF_INTRA) #define MIN_TB_ADDR_ZS(x, y) \ - s->pps->min_tb_addr_zs[(y) * (s->sps->tb_mask+2) + (x)] + s->ps.pps->min_tb_addr_zs[(y) * (s->ps.sps->tb_mask+2) + (x)] #define EXTEND(ptr, val, len) \ do { \ pixel4 pix = PIXEL_SPLAT_X4(val); \ @@ -72,24 +72,24 @@ HEVCLocalContext *lc = s->HEVClc; int i; - int hshift = s->sps->hshift[c_idx]; - int vshift = s->sps->vshift[c_idx]; + int hshift = s->ps.sps->hshift[c_idx]; + int vshift = s->ps.sps->vshift[c_idx]; int size = (1 << log2_size); int size_in_luma_h = size << hshift; - int size_in_tbs_h = size_in_luma_h >> s->sps->log2_min_tb_size; + int size_in_tbs_h = size_in_luma_h >> s->ps.sps->log2_min_tb_size; int size_in_luma_v = size << vshift; - int size_in_tbs_v = size_in_luma_v >> s->sps->log2_min_tb_size; + int size_in_tbs_v = size_in_luma_v >> s->ps.sps->log2_min_tb_size; int x = x0 >> hshift; int y = y0 >> vshift; - int x_tb = (x0 >> s->sps->log2_min_tb_size) & s->sps->tb_mask; - int y_tb = (y0 >> s->sps->log2_min_tb_size) & s->sps->tb_mask; + int x_tb = (x0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask; + int y_tb = (y0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask; int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb); ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(pixel); pixel *src = (pixel*)s->frame->data[c_idx] + x + y * stride; - int min_pu_width = s->sps->min_pu_width; + int min_pu_width = s->ps.sps->min_pu_width; enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c : lc->tu.intra_pred_mode; @@ -103,28 +103,28 @@ pixel *top = top_array + 1; pixel *filtered_left = filtered_left_array + 1; pixel *filtered_top = filtered_top_array + 1; - int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS( x_tb - 1, (y_tb + size_in_tbs_v) & s->sps->tb_mask); + int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS( x_tb - 1, (y_tb + size_in_tbs_v) & s->ps.sps->tb_mask); int cand_left = lc->na.cand_left; int cand_up_left = lc->na.cand_up_left; int cand_up = lc->na.cand_up; - int cand_up_right = lc->na.cand_up_right && cur_tb_addr > MIN_TB_ADDR_ZS((x_tb + size_in_tbs_h) & s->sps->tb_mask, y_tb - 1); + int cand_up_right = lc->na.cand_up_right && cur_tb_addr > MIN_TB_ADDR_ZS((x_tb + size_in_tbs_h) & s->ps.sps->tb_mask, y_tb - 1); - int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, s->sps->height) - + int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, s->ps.sps->height) - (y0 + size_in_luma_v)) >> vshift; - int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, s->sps->width) - + int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, s->ps.sps->width) - (x0 + size_in_luma_h)) >> hshift; - if (s->pps->constrained_intra_pred_flag == 1) { + if (s->ps.pps->constrained_intra_pred_flag == 1) { int size_in_luma_pu_v = PU(size_in_luma_v); int size_in_luma_pu_h = PU(size_in_luma_h); - int on_pu_edge_x = !av_mod_uintp2(x0, s->sps->log2_min_pu_size); - int on_pu_edge_y = !av_mod_uintp2(y0, s->sps->log2_min_pu_size); + int on_pu_edge_x = !av_mod_uintp2(x0, s->ps.sps->log2_min_pu_size); + int on_pu_edge_y = !av_mod_uintp2(y0, s->ps.sps->log2_min_pu_size); if (!size_in_luma_pu_h) size_in_luma_pu_h++; if (cand_bottom_left == 1 && on_pu_edge_x) { int x_left_pu = PU(x0 - 1); int y_bottom_pu = PU(y0 + size_in_luma_v); - int max = FFMIN(size_in_luma_pu_v, s->sps->min_pu_height - y_bottom_pu); + int max = FFMIN(size_in_luma_pu_v, s->ps.sps->min_pu_height - y_bottom_pu); cand_bottom_left = 0; for (i = 0; i < max; i += 2) cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA); @@ -132,7 +132,7 @@ if (cand_left == 1 && on_pu_edge_x) { int x_left_pu = PU(x0 - 1); int y_left_pu = PU(y0); - int max = FFMIN(size_in_luma_pu_v, s->sps->min_pu_height - y_left_pu); + int max = FFMIN(size_in_luma_pu_v, s->ps.sps->min_pu_height - y_left_pu); cand_left = 0; for (i = 0; i < max; i += 2) cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA); @@ -145,7 +145,7 @@ if (cand_up == 1 && on_pu_edge_y) { int x_top_pu = PU(x0); int y_top_pu = PU(y0 - 1); - int max = FFMIN(size_in_luma_pu_h, s->sps->min_pu_width - x_top_pu); + int max = FFMIN(size_in_luma_pu_h, s->ps.sps->min_pu_width - x_top_pu); cand_up = 0; for (i = 0; i < max; i += 2) cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA); @@ -153,7 +153,7 @@ if (cand_up_right == 1 && on_pu_edge_y) { int y_top_pu = PU(y0 - 1); int x_right_pu = PU(x0 + size_in_luma_h); - int max = FFMIN(size_in_luma_pu_h, s->sps->min_pu_width - x_right_pu); + int max = FFMIN(size_in_luma_pu_h, s->ps.sps->min_pu_width - x_right_pu); cand_up_right = 0; for (i = 0; i < max; i += 2) cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA); @@ -183,20 +183,20 @@ size - bottom_left_size); } - if (s->pps->constrained_intra_pred_flag == 1) { + if (s->ps.pps->constrained_intra_pred_flag == 1) { if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) { - int size_max_x = x0 + ((2 * size) << hshift) < s->sps->width ? - 2 * size : (s->sps->width - x0) >> hshift; - int size_max_y = y0 + ((2 * size) << vshift) < s->sps->height ? - 2 * size : (s->sps->height - y0) >> vshift; + int size_max_x = x0 + ((2 * size) << hshift) < s->ps.sps->width ? + 2 * size : (s->ps.sps->width - x0) >> hshift; + int size_max_y = y0 + ((2 * size) << vshift) < s->ps.sps->height ? + 2 * size : (s->ps.sps->height - y0) >> vshift; int j = size + (cand_bottom_left? bottom_left_size: 0) -1; if (!cand_up_right) { - size_max_x = x0 + ((size) << hshift) < s->sps->width ? - size : (s->sps->width - x0) >> hshift; + size_max_x = x0 + ((size) << hshift) < s->ps.sps->width ? + size : (s->ps.sps->width - x0) >> hshift; } if (!cand_bottom_left) { - size_max_y = y0 + (( size) << vshift) < s->sps->height ? - size : (s->sps->height - y0) >> vshift; + size_max_y = y0 + (( size) << vshift) < s->ps.sps->height ? + size : (s->ps.sps->height - y0) >> vshift; } if (cand_bottom_left || cand_left || cand_up_left) { while (j > -1 && !IS_INTRA(-1, j)) @@ -287,14 +287,14 @@ top[-1] = left[-1]; // Filtering process - if (!s->sps->intra_smoothing_disabled_flag && (c_idx == 0 || s->sps->chroma_format_idc == 3)) { + if (!s->ps.sps->intra_smoothing_disabled_flag && (c_idx == 0 || s->ps.sps->chroma_format_idc == 3)) { if (mode != INTRA_DC && size != 4){ int intra_hor_ver_dist_thresh[] = { 7, 1, 0 }; int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)), FFABS((int)(mode - 10U))); if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) { int threshold = 1 << (BIT_DEPTH - 5); - if (s->sps->sps_strong_intra_smoothing_enable_flag && c_idx == 0 && + if (s->ps.sps->sps_strong_intra_smoothing_enable_flag && c_idx == 0 && log2_size == 5 && FFABS(top[-1] + top[63] - 2 * top[31]) < threshold && FFABS(left[-1] + left[63] - 2 * left[31]) < threshold) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_ps.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_ps.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_ps.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_ps.c 2015-08-03 17:20:02.000000000 +0000 @@ -69,14 +69,14 @@ { 2, 1 }, }; -static void remove_pps(HEVCContext *s, int id) +static void remove_pps(HEVCParamSets *s, int id) { if (s->pps_list[id] && s->pps == (const HEVCPPS*)s->pps_list[id]->data) s->pps = NULL; av_buffer_unref(&s->pps_list[id]); } -static void remove_sps(HEVCContext *s, int id) +static void remove_sps(HEVCParamSets *s, int id) { int i; if (s->sps_list[id]) { @@ -93,7 +93,7 @@ av_buffer_unref(&s->sps_list[id]); } -static void remove_vps(HEVCContext *s, int id) +static void remove_vps(HEVCParamSets *s, int id) { int i; if (s->vps_list[id]) { @@ -107,10 +107,9 @@ av_buffer_unref(&s->vps_list[id]); } -int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps, - const HEVCSPS *sps, int is_slice_header) +int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, + ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header) { - HEVCLocalContext *lc = s->HEVClc; uint8_t rps_predict = 0; int delta_poc; int k0 = 0; @@ -118,8 +117,6 @@ int k = 0; int i; - GetBitContext *gb = &lc->gb; - if (rps != sps->st_rps && sps->nb_st_rps) rps_predict = get_bits1(gb); @@ -133,19 +130,20 @@ if (is_slice_header) { unsigned int delta_idx = get_ue_golomb_long(gb) + 1; if (delta_idx > sps->nb_st_rps) { - av_log(s->avctx, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "Invalid value of delta_idx in slice header RPS: %d > %d.\n", delta_idx, sps->nb_st_rps); return AVERROR_INVALIDDATA; } rps_ridx = &sps->st_rps[sps->nb_st_rps - delta_idx]; + rps->rps_idx_num_delta_pocs = rps_ridx->num_delta_pocs; } else rps_ridx = &sps->st_rps[rps - sps->st_rps - 1]; delta_rps_sign = get_bits1(gb); abs_delta_rps = get_ue_golomb_long(gb) + 1; if (abs_delta_rps < 1 || abs_delta_rps > 32768) { - av_log(s->avctx, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "Invalid value of abs_delta_rps: %d\n", abs_delta_rps); return AVERROR_INVALIDDATA; @@ -211,7 +209,7 @@ if (rps->num_negative_pics >= MAX_REFS || nb_positive_pics >= MAX_REFS) { - av_log(s->avctx, AV_LOG_ERROR, "Too many refs in a short term RPS.\n"); + av_log(avctx, AV_LOG_ERROR, "Too many refs in a short term RPS.\n"); return AVERROR_INVALIDDATA; } @@ -237,11 +235,10 @@ } -static int decode_profile_tier_level(HEVCContext *s, PTLCommon *ptl) +static int decode_profile_tier_level(GetBitContext *gb, AVCodecContext *avctx, + PTLCommon *ptl) { int i; - HEVCLocalContext *lc = s->HEVClc; - GetBitContext *gb = &lc->gb; if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 16 + 16 + 12) return -1; @@ -250,15 +247,15 @@ ptl->tier_flag = get_bits1(gb); ptl->profile_idc = get_bits(gb, 5); if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN) - av_log(s->avctx, AV_LOG_DEBUG, "Main profile bitstream\n"); + av_log(avctx, AV_LOG_DEBUG, "Main profile bitstream\n"); else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_10) - av_log(s->avctx, AV_LOG_DEBUG, "Main 10 profile bitstream\n"); + av_log(avctx, AV_LOG_DEBUG, "Main 10 profile bitstream\n"); else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_STILL_PICTURE) - av_log(s->avctx, AV_LOG_DEBUG, "Main Still Picture profile bitstream\n"); + av_log(avctx, AV_LOG_DEBUG, "Main Still Picture profile bitstream\n"); else if (ptl->profile_idc == FF_PROFILE_HEVC_REXT) - av_log(s->avctx, AV_LOG_DEBUG, "Range Extension profile bitstream\n"); + av_log(avctx, AV_LOG_DEBUG, "Range Extension profile bitstream\n"); else - av_log(s->avctx, AV_LOG_WARNING, "Unknown HEVC profile: %d\n", ptl->profile_idc); + av_log(avctx, AV_LOG_WARNING, "Unknown HEVC profile: %d\n", ptl->profile_idc); for (i = 0; i < 32; i++) ptl->profile_compatibility_flag[i] = get_bits1(gb); @@ -274,14 +271,13 @@ return 0; } -static int parse_ptl(HEVCContext *s, PTL *ptl, int max_num_sub_layers) +static int parse_ptl(GetBitContext *gb, AVCodecContext *avctx, + PTL *ptl, int max_num_sub_layers) { int i; - HEVCLocalContext *lc = s->HEVClc; - GetBitContext *gb = &lc->gb; - if (decode_profile_tier_level(s, &ptl->general_ptl) < 0 || + if (decode_profile_tier_level(gb, avctx, &ptl->general_ptl) < 0 || get_bits_left(gb) < 8 + 8*2) { - av_log(s->avctx, AV_LOG_ERROR, "PTL information too short\n"); + av_log(avctx, AV_LOG_ERROR, "PTL information too short\n"); return -1; } @@ -297,14 +293,14 @@ skip_bits(gb, 2); // reserved_zero_2bits[i] for (i = 0; i < max_num_sub_layers - 1; i++) { if (ptl->sub_layer_profile_present_flag[i] && - decode_profile_tier_level(s, &ptl->sub_layer_ptl[i]) < 0) { - av_log(s->avctx, AV_LOG_ERROR, + decode_profile_tier_level(gb, avctx, &ptl->sub_layer_ptl[i]) < 0) { + av_log(avctx, AV_LOG_ERROR, "PTL information for sublayer %i too short\n", i); return -1; } if (ptl->sub_layer_level_present_flag[i]) { if (get_bits_left(gb) < 8) { - av_log(s->avctx, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "Not enough data for sublayer %i level_idc\n", i); return -1; } else @@ -315,10 +311,9 @@ return 0; } -static void decode_sublayer_hrd(HEVCContext *s, unsigned int nb_cpb, +static void decode_sublayer_hrd(GetBitContext *gb, unsigned int nb_cpb, int subpic_params_present) { - GetBitContext *gb = &s->HEVClc->gb; int i; for (i = 0; i < nb_cpb; i++) { @@ -333,10 +328,9 @@ } } -static int decode_hrd(HEVCContext *s, int common_inf_present, +static int decode_hrd(GetBitContext *gb, int common_inf_present, int max_sublayers) { - GetBitContext *gb = &s->HEVClc->gb; int nal_params_present = 0, vcl_params_present = 0; int subpic_params_present = 0; int i; @@ -383,23 +377,23 @@ if (!low_delay) { nb_cpb = get_ue_golomb_long(gb) + 1; if (nb_cpb < 1 || nb_cpb > 32) { - av_log(s->avctx, AV_LOG_ERROR, "nb_cpb %d invalid\n", nb_cpb); + av_log(NULL, AV_LOG_ERROR, "nb_cpb %d invalid\n", nb_cpb); return AVERROR_INVALIDDATA; } } if (nal_params_present) - decode_sublayer_hrd(s, nb_cpb, subpic_params_present); + decode_sublayer_hrd(gb, nb_cpb, subpic_params_present); if (vcl_params_present) - decode_sublayer_hrd(s, nb_cpb, subpic_params_present); + decode_sublayer_hrd(gb, nb_cpb, subpic_params_present); } return 0; } -int ff_hevc_decode_nal_vps(HEVCContext *s) +int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, + HEVCParamSets *ps) { int i,j; - GetBitContext *gb = &s->HEVClc->gb; int vps_id = 0; HEVCVPS *vps; AVBufferRef *vps_buf = av_buffer_allocz(sizeof(*vps)); @@ -408,16 +402,16 @@ return AVERROR(ENOMEM); vps = (HEVCVPS*)vps_buf->data; - av_log(s->avctx, AV_LOG_DEBUG, "Decoding VPS\n"); + av_log(avctx, AV_LOG_DEBUG, "Decoding VPS\n"); vps_id = get_bits(gb, 4); if (vps_id >= MAX_VPS_COUNT) { - av_log(s->avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id); + av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id); goto err; } if (get_bits(gb, 2) != 3) { // vps_reserved_three_2bits - av_log(s->avctx, AV_LOG_ERROR, "vps_reserved_three_2bits is not three\n"); + av_log(avctx, AV_LOG_ERROR, "vps_reserved_three_2bits is not three\n"); goto err; } @@ -426,17 +420,17 @@ vps->vps_temporal_id_nesting_flag = get_bits1(gb); if (get_bits(gb, 16) != 0xffff) { // vps_reserved_ffff_16bits - av_log(s->avctx, AV_LOG_ERROR, "vps_reserved_ffff_16bits is not 0xffff\n"); + av_log(avctx, AV_LOG_ERROR, "vps_reserved_ffff_16bits is not 0xffff\n"); goto err; } if (vps->vps_max_sub_layers > MAX_SUB_LAYERS) { - av_log(s->avctx, AV_LOG_ERROR, "vps_max_sub_layers out of range: %d\n", + av_log(avctx, AV_LOG_ERROR, "vps_max_sub_layers out of range: %d\n", vps->vps_max_sub_layers); goto err; } - if (parse_ptl(s, &vps->ptl, vps->vps_max_sub_layers) < 0) + if (parse_ptl(gb, avctx, &vps->ptl, vps->vps_max_sub_layers) < 0) goto err; vps->vps_sub_layer_ordering_info_present_flag = get_bits1(gb); @@ -448,14 +442,14 @@ vps->vps_max_latency_increase[i] = get_ue_golomb_long(gb) - 1; if (vps->vps_max_dec_pic_buffering[i] > MAX_DPB_SIZE || !vps->vps_max_dec_pic_buffering[i]) { - av_log(s->avctx, AV_LOG_ERROR, "vps_max_dec_pic_buffering_minus1 out of range: %d\n", + av_log(avctx, AV_LOG_ERROR, "vps_max_dec_pic_buffering_minus1 out of range: %d\n", vps->vps_max_dec_pic_buffering[i] - 1); goto err; } if (vps->vps_num_reorder_pics[i] > vps->vps_max_dec_pic_buffering[i] - 1) { - av_log(s->avctx, AV_LOG_WARNING, "vps_max_num_reorder_pics out of range: %d\n", + av_log(avctx, AV_LOG_WARNING, "vps_max_num_reorder_pics out of range: %d\n", vps->vps_num_reorder_pics[i]); - if (s->avctx->err_recognition & AV_EF_EXPLODE) + if (avctx->err_recognition & AV_EF_EXPLODE) goto err; } } @@ -464,7 +458,7 @@ vps->vps_num_layer_sets = get_ue_golomb_long(gb) + 1; if (vps->vps_num_layer_sets < 1 || vps->vps_num_layer_sets > 1024 || (vps->vps_num_layer_sets - 1LL) * (vps->vps_max_layer_id + 1LL) > get_bits_left(gb)) { - av_log(s->avctx, AV_LOG_ERROR, "too many layer_id_included_flags\n"); + av_log(avctx, AV_LOG_ERROR, "too many layer_id_included_flags\n"); goto err; } @@ -481,7 +475,7 @@ vps->vps_num_ticks_poc_diff_one = get_ue_golomb_long(gb) + 1; vps->vps_num_hrd_parameters = get_ue_golomb_long(gb); if (vps->vps_num_hrd_parameters > (unsigned)vps->vps_num_layer_sets) { - av_log(s->avctx, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "vps_num_hrd_parameters %d is invalid\n", vps->vps_num_hrd_parameters); goto err; } @@ -491,24 +485,24 @@ get_ue_golomb_long(gb); // hrd_layer_set_idx if (i) common_inf_present = get_bits1(gb); - decode_hrd(s, common_inf_present, vps->vps_max_sub_layers); + decode_hrd(gb, common_inf_present, vps->vps_max_sub_layers); } } get_bits1(gb); /* vps_extension_flag */ if (get_bits_left(gb) < 0) { - av_log(s->avctx, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "Overread VPS by %d bits\n", -get_bits_left(gb)); - if (s->vps_list[vps_id]) + if (ps->vps_list[vps_id]) goto err; } - if (s->vps_list[vps_id] && - !memcmp(s->vps_list[vps_id]->data, vps_buf->data, vps_buf->size)) { + if (ps->vps_list[vps_id] && + !memcmp(ps->vps_list[vps_id]->data, vps_buf->data, vps_buf->size)) { av_buffer_unref(&vps_buf); } else { - remove_vps(s, vps_id); - s->vps_list[vps_id] = vps_buf; + remove_vps(ps, vps_id); + ps->vps_list[vps_id] = vps_buf; } return 0; @@ -518,14 +512,14 @@ return AVERROR_INVALIDDATA; } -static void decode_vui(HEVCContext *s, HEVCSPS *sps) +static void decode_vui(GetBitContext *gb, AVCodecContext *avctx, + int apply_defdispwin, HEVCSPS *sps) { VUI *vui = &sps->vui; - GetBitContext *gb = &s->HEVClc->gb; GetBitContext backup; int sar_present, alt = 0; - av_log(s->avctx, AV_LOG_DEBUG, "Decoding VUI\n"); + av_log(avctx, AV_LOG_DEBUG, "Decoding VUI\n"); sar_present = get_bits1(gb); if (sar_present) { @@ -536,7 +530,7 @@ vui->sar.num = get_bits(gb, 16); vui->sar.den = get_bits(gb, 16); } else - av_log(s->avctx, AV_LOG_WARNING, + av_log(avctx, AV_LOG_WARNING, "Unknown SAR index: %u.\n", sar_idx); } @@ -578,7 +572,7 @@ if (get_bits_left(gb) >= 68 && show_bits_long(gb, 21) == 0x100000) { vui->default_display_window_flag = 0; - av_log(s->avctx, AV_LOG_WARNING, "Invalid default display window\n"); + av_log(avctx, AV_LOG_WARNING, "Invalid default display window\n"); } else vui->default_display_window_flag = get_bits1(gb); // Backup context in case an alternate header is detected @@ -591,9 +585,9 @@ vui->def_disp_win.top_offset = get_ue_golomb_long(gb) * 2; vui->def_disp_win.bottom_offset = get_ue_golomb_long(gb) * 2; - if (s->apply_defdispwin && - s->avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) { - av_log(s->avctx, AV_LOG_DEBUG, + if (apply_defdispwin && + avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) { + av_log(avctx, AV_LOG_DEBUG, "discarding vui default display window, " "original values are l:%u r:%u t:%u b:%u\n", vui->def_disp_win.left_offset, @@ -614,7 +608,7 @@ if( get_bits_left(gb) < 66) { // The alternate syntax seem to have timing info located // at where def_disp_win is normally located - av_log(s->avctx, AV_LOG_WARNING, + av_log(avctx, AV_LOG_WARNING, "Strange VUI timing information, retrying...\n"); vui->default_display_window_flag = 0; memset(&vui->def_disp_win, 0, sizeof(vui->def_disp_win)); @@ -624,7 +618,7 @@ vui->vui_num_units_in_tick = get_bits_long(gb, 32); vui->vui_time_scale = get_bits_long(gb, 32); if (alt) { - av_log(s->avctx, AV_LOG_INFO, "Retry got %i/%i fps\n", + av_log(avctx, AV_LOG_INFO, "Retry got %i/%i fps\n", vui->vui_time_scale, vui->vui_num_units_in_tick); } vui->vui_poc_proportional_to_timing_flag = get_bits1(gb); @@ -632,7 +626,7 @@ vui->vui_num_ticks_poc_diff_one_minus1 = get_ue_golomb_long(gb); vui->vui_hrd_parameters_present_flag = get_bits1(gb); if (vui->vui_hrd_parameters_present_flag) - decode_hrd(s, 1, sps->max_sub_layers); + decode_hrd(gb, 1, sps->max_sub_layers); } vui->bitstream_restriction_flag = get_bits1(gb); @@ -678,9 +672,8 @@ memcpy(sl->sl[3][5], default_scaling_list_inter, 64); } -static int scaling_list_data(HEVCContext *s, ScalingList *sl, HEVCSPS *sps) +static int scaling_list_data(GetBitContext *gb, AVCodecContext *avctx, ScalingList *sl, HEVCSPS *sps) { - GetBitContext *gb = &s->HEVClc->gb; uint8_t scaling_list_pred_mode_flag; int32_t scaling_list_dc_coef[2][6]; int size_id, matrix_id, pos; @@ -696,7 +689,7 @@ if (delta) { // Copy from previous array. if (matrix_id < delta) { - av_log(s->avctx, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "Invalid delta in scaling list data: %d.\n", delta); return AVERROR_INVALIDDATA; } @@ -750,59 +743,94 @@ return 0; } -int ff_hevc_decode_nal_sps(HEVCContext *s) +static int map_pixel_format(AVCodecContext *avctx, HEVCSPS *sps) { const AVPixFmtDescriptor *desc; - GetBitContext *gb = &s->HEVClc->gb; + switch (sps->bit_depth) { + case 8: + if (sps->chroma_format_idc == 0) sps->pix_fmt = AV_PIX_FMT_GRAY8; + if (sps->chroma_format_idc == 1) sps->pix_fmt = AV_PIX_FMT_YUV420P; + if (sps->chroma_format_idc == 2) sps->pix_fmt = AV_PIX_FMT_YUV422P; + if (sps->chroma_format_idc == 3) sps->pix_fmt = AV_PIX_FMT_YUV444P; + break; + case 9: + if (sps->chroma_format_idc == 0) sps->pix_fmt = AV_PIX_FMT_GRAY16; + if (sps->chroma_format_idc == 1) sps->pix_fmt = AV_PIX_FMT_YUV420P9; + if (sps->chroma_format_idc == 2) sps->pix_fmt = AV_PIX_FMT_YUV422P9; + if (sps->chroma_format_idc == 3) sps->pix_fmt = AV_PIX_FMT_YUV444P9; + break; + case 10: + if (sps->chroma_format_idc == 0) sps->pix_fmt = AV_PIX_FMT_GRAY16; + if (sps->chroma_format_idc == 1) sps->pix_fmt = AV_PIX_FMT_YUV420P10; + if (sps->chroma_format_idc == 2) sps->pix_fmt = AV_PIX_FMT_YUV422P10; + if (sps->chroma_format_idc == 3) sps->pix_fmt = AV_PIX_FMT_YUV444P10; + break; + case 12: + if (sps->chroma_format_idc == 0) sps->pix_fmt = AV_PIX_FMT_GRAY16; + if (sps->chroma_format_idc == 1) sps->pix_fmt = AV_PIX_FMT_YUV420P12; + if (sps->chroma_format_idc == 2) sps->pix_fmt = AV_PIX_FMT_YUV422P12; + if (sps->chroma_format_idc == 3) sps->pix_fmt = AV_PIX_FMT_YUV444P12; + break; + default: + av_log(avctx, AV_LOG_ERROR, + "4:2:0, 4:2:2, 4:4:4 supports are currently specified for 8, 10 and 12 bits.\n"); + av_log(avctx, AV_LOG_ERROR, + "chroma_format_idc is %d, depth is %d", + sps->chroma_format_idc, sps->bit_depth); + return AVERROR_INVALIDDATA; + } + + desc = av_pix_fmt_desc_get(sps->pix_fmt); + if (!desc) + return AVERROR(EINVAL); + + sps->hshift[0] = sps->vshift[0] = 0; + sps->hshift[2] = sps->hshift[1] = desc->log2_chroma_w; + sps->vshift[2] = sps->vshift[1] = desc->log2_chroma_h; + + sps->pixel_shift = sps->bit_depth > 8; + + return 0; +} + +int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, + int apply_defdispwin, AVBufferRef **vps_list, AVCodecContext *avctx) +{ int ret = 0; - unsigned int sps_id = 0; int log2_diff_max_min_transform_block_size; int bit_depth_chroma, start, vui_present, sublayer_ordering_info; int i; - HEVCSPS *sps; - AVBufferRef *sps_buf = av_buffer_allocz(sizeof(*sps)); - - if (!sps_buf) - return AVERROR(ENOMEM); - sps = (HEVCSPS*)sps_buf->data; - - av_log(s->avctx, AV_LOG_DEBUG, "Decoding SPS\n"); - // Coded parameters sps->vps_id = get_bits(gb, 4); if (sps->vps_id >= MAX_VPS_COUNT) { - av_log(s->avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", sps->vps_id); - ret = AVERROR_INVALIDDATA; - goto err; + av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", sps->vps_id); + return AVERROR_INVALIDDATA; } - if (!s->vps_list[sps->vps_id]) { - av_log(s->avctx, AV_LOG_ERROR, "VPS %d does not exist\n", + if (vps_list && !vps_list[sps->vps_id]) { + av_log(avctx, AV_LOG_ERROR, "VPS %d does not exist\n", sps->vps_id); - ret = AVERROR_INVALIDDATA; - goto err; + return AVERROR_INVALIDDATA; } sps->max_sub_layers = get_bits(gb, 3) + 1; if (sps->max_sub_layers > MAX_SUB_LAYERS) { - av_log(s->avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n", + av_log(avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n", sps->max_sub_layers); - ret = AVERROR_INVALIDDATA; - goto err; + return AVERROR_INVALIDDATA; } skip_bits1(gb); // temporal_id_nesting_flag - if (parse_ptl(s, &sps->ptl, sps->max_sub_layers) < 0) - goto err; + if ((ret = parse_ptl(gb, avctx, &sps->ptl, sps->max_sub_layers)) < 0) + return ret; - sps_id = get_ue_golomb_long(gb); - if (sps_id >= MAX_SPS_COUNT) { - av_log(s->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", sps_id); - ret = AVERROR_INVALIDDATA; - goto err; + *sps_id = get_ue_golomb_long(gb); + if (*sps_id >= MAX_SPS_COUNT) { + av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", *sps_id); + return AVERROR_INVALIDDATA; } sps->chroma_format_idc = get_ue_golomb_long(gb); @@ -816,8 +844,8 @@ sps->width = get_ue_golomb_long(gb); sps->height = get_ue_golomb_long(gb); if ((ret = av_image_check_size(sps->width, - sps->height, 0, s->avctx)) < 0) - goto err; + sps->height, 0, avctx)) < 0) + return ret; if (get_bits1(gb)) { // pic_conformance_flag //TODO: * 2 is only valid for 420 @@ -826,8 +854,8 @@ sps->pic_conf_win.top_offset = get_ue_golomb_long(gb) * 2; sps->pic_conf_win.bottom_offset = get_ue_golomb_long(gb) * 2; - if (s->avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) { - av_log(s->avctx, AV_LOG_DEBUG, + if (avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) { + av_log(avctx, AV_LOG_DEBUG, "discarding sps conformance window, " "original values are l:%u r:%u t:%u b:%u\n", sps->pic_conf_win.left_offset, @@ -846,64 +874,22 @@ sps->bit_depth = get_ue_golomb_long(gb) + 8; bit_depth_chroma = get_ue_golomb_long(gb) + 8; if (sps->chroma_format_idc && bit_depth_chroma != sps->bit_depth) { - av_log(s->avctx, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "Luma bit depth (%d) is different from chroma bit depth (%d), " "this is unsupported.\n", sps->bit_depth, bit_depth_chroma); - ret = AVERROR_INVALIDDATA; - goto err; - } - - switch (sps->bit_depth) { - case 8: - if (sps->chroma_format_idc == 0) sps->pix_fmt = AV_PIX_FMT_GRAY8; - if (sps->chroma_format_idc == 1) sps->pix_fmt = AV_PIX_FMT_YUV420P; - if (sps->chroma_format_idc == 2) sps->pix_fmt = AV_PIX_FMT_YUV422P; - if (sps->chroma_format_idc == 3) sps->pix_fmt = AV_PIX_FMT_YUV444P; - break; - case 9: - if (sps->chroma_format_idc == 0) sps->pix_fmt = AV_PIX_FMT_GRAY16; - if (sps->chroma_format_idc == 1) sps->pix_fmt = AV_PIX_FMT_YUV420P9; - if (sps->chroma_format_idc == 2) sps->pix_fmt = AV_PIX_FMT_YUV422P9; - if (sps->chroma_format_idc == 3) sps->pix_fmt = AV_PIX_FMT_YUV444P9; - break; - case 10: - if (sps->chroma_format_idc == 0) sps->pix_fmt = AV_PIX_FMT_GRAY16; - if (sps->chroma_format_idc == 1) sps->pix_fmt = AV_PIX_FMT_YUV420P10; - if (sps->chroma_format_idc == 2) sps->pix_fmt = AV_PIX_FMT_YUV422P10; - if (sps->chroma_format_idc == 3) sps->pix_fmt = AV_PIX_FMT_YUV444P10; - break; - case 12: - if (sps->chroma_format_idc == 0) sps->pix_fmt = AV_PIX_FMT_GRAY16; - if (sps->chroma_format_idc == 1) sps->pix_fmt = AV_PIX_FMT_YUV420P12; - if (sps->chroma_format_idc == 2) sps->pix_fmt = AV_PIX_FMT_YUV422P12; - if (sps->chroma_format_idc == 3) sps->pix_fmt = AV_PIX_FMT_YUV444P12; - break; - default: - av_log(s->avctx, AV_LOG_ERROR, - "4:2:0, 4:2:2, 4:4:4 supports are currently specified for 8, 10 and 12 bits.\n"); - ret = AVERROR_PATCHWELCOME; - goto err; + return AVERROR_INVALIDDATA; } - desc = av_pix_fmt_desc_get(sps->pix_fmt); - if (!desc) { - ret = AVERROR(EINVAL); - goto err; - } - - sps->hshift[0] = sps->vshift[0] = 0; - sps->hshift[2] = sps->hshift[1] = desc->log2_chroma_w; - sps->vshift[2] = sps->vshift[1] = desc->log2_chroma_h; - - sps->pixel_shift = sps->bit_depth > 8; + ret = map_pixel_format(avctx, sps); + if (ret < 0) + return ret; sps->log2_max_poc_lsb = get_ue_golomb_long(gb) + 4; if (sps->log2_max_poc_lsb > 16) { - av_log(s->avctx, AV_LOG_ERROR, "log2_max_pic_order_cnt_lsb_minus4 out range: %d\n", + av_log(avctx, AV_LOG_ERROR, "log2_max_pic_order_cnt_lsb_minus4 out range: %d\n", sps->log2_max_poc_lsb - 4); - ret = AVERROR_INVALIDDATA; - goto err; + return AVERROR_INVALIDDATA; } sublayer_ordering_info = get_bits1(gb); @@ -913,18 +899,16 @@ sps->temporal_layer[i].num_reorder_pics = get_ue_golomb_long(gb); sps->temporal_layer[i].max_latency_increase = get_ue_golomb_long(gb) - 1; if (sps->temporal_layer[i].max_dec_pic_buffering > MAX_DPB_SIZE) { - av_log(s->avctx, AV_LOG_ERROR, "sps_max_dec_pic_buffering_minus1 out of range: %d\n", + av_log(avctx, AV_LOG_ERROR, "sps_max_dec_pic_buffering_minus1 out of range: %d\n", sps->temporal_layer[i].max_dec_pic_buffering - 1); - ret = AVERROR_INVALIDDATA; - goto err; + return AVERROR_INVALIDDATA; } if (sps->temporal_layer[i].num_reorder_pics > sps->temporal_layer[i].max_dec_pic_buffering - 1) { - av_log(s->avctx, AV_LOG_WARNING, "sps_max_num_reorder_pics out of range: %d\n", + av_log(avctx, AV_LOG_WARNING, "sps_max_num_reorder_pics out of range: %d\n", sps->temporal_layer[i].num_reorder_pics); - if (s->avctx->err_recognition & AV_EF_EXPLODE || + if (avctx->err_recognition & AV_EF_EXPLODE || sps->temporal_layer[i].num_reorder_pics > MAX_DPB_SIZE - 1) { - ret = AVERROR_INVALIDDATA; - goto err; + return AVERROR_INVALIDDATA; } sps->temporal_layer[i].max_dec_pic_buffering = sps->temporal_layer[i].num_reorder_pics + 1; } @@ -946,27 +930,23 @@ sps->log2_min_tb_size; if (sps->log2_min_cb_size < 3 || sps->log2_min_cb_size > 30) { - av_log(s->avctx, AV_LOG_ERROR, "Invalid value %d for log2_min_cb_size", sps->log2_min_cb_size); - ret = AVERROR_INVALIDDATA; - goto err; + av_log(avctx, AV_LOG_ERROR, "Invalid value %d for log2_min_cb_size", sps->log2_min_cb_size); + return AVERROR_INVALIDDATA; } if (sps->log2_diff_max_min_coding_block_size > 30) { - av_log(s->avctx, AV_LOG_ERROR, "Invalid value %d for log2_diff_max_min_coding_block_size", sps->log2_diff_max_min_coding_block_size); - ret = AVERROR_INVALIDDATA; - goto err; + av_log(avctx, AV_LOG_ERROR, "Invalid value %d for log2_diff_max_min_coding_block_size", sps->log2_diff_max_min_coding_block_size); + return AVERROR_INVALIDDATA; } if (sps->log2_min_tb_size >= sps->log2_min_cb_size || sps->log2_min_tb_size < 2) { - av_log(s->avctx, AV_LOG_ERROR, "Invalid value for log2_min_tb_size"); - ret = AVERROR_INVALIDDATA; - goto err; + av_log(avctx, AV_LOG_ERROR, "Invalid value for log2_min_tb_size"); + return AVERROR_INVALIDDATA; } if (log2_diff_max_min_transform_block_size < 0 || log2_diff_max_min_transform_block_size > 30) { - av_log(s->avctx, AV_LOG_ERROR, "Invalid value %d for log2_diff_max_min_transform_block_size", log2_diff_max_min_transform_block_size); - ret = AVERROR_INVALIDDATA; - goto err; + av_log(avctx, AV_LOG_ERROR, "Invalid value %d for log2_diff_max_min_transform_block_size", log2_diff_max_min_transform_block_size); + return AVERROR_INVALIDDATA; } sps->max_transform_hierarchy_depth_inter = get_ue_golomb_long(gb); @@ -977,9 +957,9 @@ set_default_scaling_list_data(&sps->scaling_list); if (get_bits1(gb)) { - ret = scaling_list_data(s, &sps->scaling_list, sps); + ret = scaling_list_data(gb, avctx, &sps->scaling_list, sps); if (ret < 0) - goto err; + return ret; } } @@ -994,11 +974,10 @@ sps->pcm.log2_max_pcm_cb_size = sps->pcm.log2_min_pcm_cb_size + get_ue_golomb_long(gb); if (sps->pcm.bit_depth > sps->bit_depth) { - av_log(s->avctx, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "PCM bit depth (%d) is greater than normal bit depth (%d)\n", sps->pcm.bit_depth, sps->bit_depth); - ret = AVERROR_INVALIDDATA; - goto err; + return AVERROR_INVALIDDATA; } sps->pcm.loop_filter_disable_flag = get_bits1(gb); @@ -1006,24 +985,23 @@ sps->nb_st_rps = get_ue_golomb_long(gb); if (sps->nb_st_rps > MAX_SHORT_TERM_RPS_COUNT) { - av_log(s->avctx, AV_LOG_ERROR, "Too many short term RPS: %d.\n", + av_log(avctx, AV_LOG_ERROR, "Too many short term RPS: %d.\n", sps->nb_st_rps); - ret = AVERROR_INVALIDDATA; - goto err; + return AVERROR_INVALIDDATA; } for (i = 0; i < sps->nb_st_rps; i++) { - if ((ret = ff_hevc_decode_short_term_rps(s, &sps->st_rps[i], + if ((ret = ff_hevc_decode_short_term_rps(gb, avctx, &sps->st_rps[i], sps, 0)) < 0) - goto err; + return ret; } sps->long_term_ref_pics_present_flag = get_bits1(gb); if (sps->long_term_ref_pics_present_flag) { sps->num_long_term_ref_pics_sps = get_ue_golomb_long(gb); if (sps->num_long_term_ref_pics_sps > 31U) { - av_log(s->avctx, AV_LOG_ERROR, "num_long_term_ref_pics_sps %d is out of range.\n", + av_log(avctx, AV_LOG_ERROR, "num_long_term_ref_pics_sps %d is out of range.\n", sps->num_long_term_ref_pics_sps); - goto err; + return AVERROR_INVALIDDATA; } for (i = 0; i < sps->num_long_term_ref_pics_sps; i++) { sps->lt_ref_pic_poc_lsb_sps[i] = get_bits(gb, sps->log2_max_poc_lsb); @@ -1036,7 +1014,7 @@ sps->vui.sar = (AVRational){0, 1}; vui_present = get_bits1(gb); if (vui_present) - decode_vui(s, sps); + decode_vui(gb, avctx, apply_defdispwin, sps); if (get_bits1(gb)) { // sps_extension_flag int sps_extension_flag[1]; @@ -1056,33 +1034,33 @@ extended_precision_processing_flag = get_bits1(gb); if (extended_precision_processing_flag) - av_log(s->avctx, AV_LOG_WARNING, + av_log(avctx, AV_LOG_WARNING, "extended_precision_processing_flag not yet implemented\n"); sps->intra_smoothing_disabled_flag = get_bits1(gb); high_precision_offsets_enabled_flag = get_bits1(gb); if (high_precision_offsets_enabled_flag) - av_log(s->avctx, AV_LOG_WARNING, + av_log(avctx, AV_LOG_WARNING, "high_precision_offsets_enabled_flag not yet implemented\n"); sps->persistent_rice_adaptation_enabled_flag = get_bits1(gb); cabac_bypass_alignment_enabled_flag = get_bits1(gb); if (cabac_bypass_alignment_enabled_flag) - av_log(s->avctx, AV_LOG_WARNING, + av_log(avctx, AV_LOG_WARNING, "cabac_bypass_alignment_enabled_flag not yet implemented\n"); } } - if (s->apply_defdispwin) { + if (apply_defdispwin) { sps->output_window.left_offset += sps->vui.def_disp_win.left_offset; sps->output_window.right_offset += sps->vui.def_disp_win.right_offset; sps->output_window.top_offset += sps->vui.def_disp_win.top_offset; sps->output_window.bottom_offset += sps->vui.def_disp_win.bottom_offset; } if (sps->output_window.left_offset & (0x1F >> (sps->pixel_shift)) && - !(s->avctx->flags & CODEC_FLAG_UNALIGNED)) { + !(avctx->flags & AV_CODEC_FLAG_UNALIGNED)) { sps->output_window.left_offset &= ~(0x1F >> (sps->pixel_shift)); - av_log(s->avctx, AV_LOG_WARNING, "Reducing left output window to %d " + av_log(avctx, AV_LOG_WARNING, "Reducing left output window to %d " "chroma samples to preserve alignment.\n", sps->output_window.left_offset); } @@ -1092,13 +1070,12 @@ (sps->output_window.top_offset + sps->output_window.bottom_offset); if (sps->width <= sps->output_window.left_offset + (int64_t)sps->output_window.right_offset || sps->height <= sps->output_window.top_offset + (int64_t)sps->output_window.bottom_offset) { - av_log(s->avctx, AV_LOG_WARNING, "Invalid visible frame dimensions: %dx%d.\n", + av_log(avctx, AV_LOG_WARNING, "Invalid visible frame dimensions: %dx%d.\n", sps->output_width, sps->output_height); - if (s->avctx->err_recognition & AV_EF_EXPLODE) { - ret = AVERROR_INVALIDDATA; - goto err; + if (avctx->err_recognition & AV_EF_EXPLODE) { + return AVERROR_INVALIDDATA; } - av_log(s->avctx, AV_LOG_WARNING, + av_log(avctx, AV_LOG_WARNING, "Displaying the whole video surface.\n"); memset(&sps->pic_conf_win, 0, sizeof(sps->pic_conf_win)); memset(&sps->output_window, 0, sizeof(sps->output_window)); @@ -1112,16 +1089,16 @@ sps->log2_min_pu_size = sps->log2_min_cb_size - 1; if (sps->log2_ctb_size > MAX_LOG2_CTB_SIZE) { - av_log(s->avctx, AV_LOG_ERROR, "CTB size out of range: 2^%d\n", sps->log2_ctb_size); - goto err; + av_log(avctx, AV_LOG_ERROR, "CTB size out of range: 2^%d\n", sps->log2_ctb_size); + return AVERROR_INVALIDDATA; } if (sps->log2_ctb_size < 4) { - av_log(s->avctx, + av_log(avctx, AV_LOG_ERROR, "log2_ctb_size %d differs from the bounds of any known profile\n", sps->log2_ctb_size); - avpriv_request_sample(s->avctx, "log2_ctb_size %d", sps->log2_ctb_size); - goto err; + avpriv_request_sample(avctx, "log2_ctb_size %d", sps->log2_ctb_size); + return AVERROR_INVALIDDATA; } sps->ctb_width = (sps->width + (1 << sps->log2_ctb_size) - 1) >> sps->log2_ctb_size; @@ -1140,35 +1117,60 @@ if (av_mod_uintp2(sps->width, sps->log2_min_cb_size) || av_mod_uintp2(sps->height, sps->log2_min_cb_size)) { - av_log(s->avctx, AV_LOG_ERROR, "Invalid coded frame dimensions.\n"); - goto err; + av_log(avctx, AV_LOG_ERROR, "Invalid coded frame dimensions.\n"); + return AVERROR_INVALIDDATA; } if (sps->max_transform_hierarchy_depth_inter > sps->log2_ctb_size - sps->log2_min_tb_size) { - av_log(s->avctx, AV_LOG_ERROR, "max_transform_hierarchy_depth_inter out of range: %d\n", + av_log(avctx, AV_LOG_ERROR, "max_transform_hierarchy_depth_inter out of range: %d\n", sps->max_transform_hierarchy_depth_inter); - goto err; + return AVERROR_INVALIDDATA; } if (sps->max_transform_hierarchy_depth_intra > sps->log2_ctb_size - sps->log2_min_tb_size) { - av_log(s->avctx, AV_LOG_ERROR, "max_transform_hierarchy_depth_intra out of range: %d\n", + av_log(avctx, AV_LOG_ERROR, "max_transform_hierarchy_depth_intra out of range: %d\n", sps->max_transform_hierarchy_depth_intra); - goto err; + return AVERROR_INVALIDDATA; } if (sps->log2_max_trafo_size > FFMIN(sps->log2_ctb_size, 5)) { - av_log(s->avctx, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "max transform block size out of range: %d\n", sps->log2_max_trafo_size); - goto err; + return AVERROR_INVALIDDATA; } if (get_bits_left(gb) < 0) { - av_log(s->avctx, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "Overread SPS by %d bits\n", -get_bits_left(gb)); - goto err; + return AVERROR_INVALIDDATA; + } + + return 0; +} + +int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx, + HEVCParamSets *ps, int apply_defdispwin) +{ + HEVCSPS *sps; + AVBufferRef *sps_buf = av_buffer_allocz(sizeof(*sps)); + unsigned int sps_id; + int ret; + + if (!sps_buf) + return AVERROR(ENOMEM); + sps = (HEVCSPS*)sps_buf->data; + + av_log(avctx, AV_LOG_DEBUG, "Decoding SPS\n"); + + ret = ff_hevc_parse_sps(sps, gb, &sps_id, + apply_defdispwin, + ps->vps_list, avctx); + if (ret < 0) { + av_buffer_unref(&sps_buf); + return ret; } - if (s->avctx->debug & FF_DEBUG_BITSTREAM) { - av_log(s->avctx, AV_LOG_DEBUG, + if (avctx->debug & FF_DEBUG_BITSTREAM) { + av_log(avctx, AV_LOG_DEBUG, "Parsed SPS: id %d; coded wxh: %dx%d; " "cropped wxh: %dx%d; pix_fmt: %s.\n", sps_id, sps->width, sps->height, @@ -1179,19 +1181,15 @@ /* check if this is a repeat of an already parsed SPS, then keep the * original one. * otherwise drop all PPSes that depend on it */ - if (s->sps_list[sps_id] && - !memcmp(s->sps_list[sps_id]->data, sps_buf->data, sps_buf->size)) { + if (ps->sps_list[sps_id] && + !memcmp(ps->sps_list[sps_id]->data, sps_buf->data, sps_buf->size)) { av_buffer_unref(&sps_buf); } else { - remove_sps(s, sps_id); - s->sps_list[sps_id] = sps_buf; + remove_sps(ps, sps_id); + ps->sps_list[sps_id] = sps_buf; } return 0; - -err: - av_buffer_unref(&sps_buf); - return ret; } static void hevc_pps_free(void *opaque, uint8_t *data) @@ -1212,8 +1210,8 @@ av_freep(&pps); } -static int pps_range_extensions(HEVCContext *s, HEVCPPS *pps, HEVCSPS *sps) { - GetBitContext *gb = &s->HEVClc->gb; +static int pps_range_extensions(GetBitContext *gb, AVCodecContext *avctx, + HEVCPPS *pps, HEVCSPS *sps) { int i; if (pps->transform_skip_enabled_flag) { @@ -1225,19 +1223,19 @@ pps->diff_cu_chroma_qp_offset_depth = get_ue_golomb_long(gb); pps->chroma_qp_offset_list_len_minus1 = get_ue_golomb_long(gb); if (pps->chroma_qp_offset_list_len_minus1 && pps->chroma_qp_offset_list_len_minus1 >= 5) { - av_log(s->avctx, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "chroma_qp_offset_list_len_minus1 shall be in the range [0, 5].\n"); return AVERROR_INVALIDDATA; } for (i = 0; i <= pps->chroma_qp_offset_list_len_minus1; i++) { pps->cb_qp_offset_list[i] = get_se_golomb_long(gb); if (pps->cb_qp_offset_list[i]) { - av_log(s->avctx, AV_LOG_WARNING, + av_log(avctx, AV_LOG_WARNING, "cb_qp_offset_list not tested yet.\n"); } pps->cr_qp_offset_list[i] = get_se_golomb_long(gb); if (pps->cr_qp_offset_list[i]) { - av_log(s->avctx, AV_LOG_WARNING, + av_log(avctx, AV_LOG_WARNING, "cb_qp_offset_list not tested yet.\n"); } } @@ -1248,14 +1246,143 @@ return(0); } -int ff_hevc_decode_nal_pps(HEVCContext *s) +static inline int setup_pps(AVCodecContext *avctx, GetBitContext *gb, + HEVCPPS *pps, HEVCSPS *sps) { - GetBitContext *gb = &s->HEVClc->gb; - HEVCSPS *sps = NULL; + int log2_diff; int pic_area_in_ctbs; - int log2_diff_ctb_min_tb_size; int i, j, x, y, ctb_addr_rs, tile_id; - int ret = 0; + + // Inferred parameters + pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd)); + pps->row_bd = av_malloc_array(pps->num_tile_rows + 1, sizeof(*pps->row_bd)); + pps->col_idxX = av_malloc_array(sps->ctb_width, sizeof(*pps->col_idxX)); + if (!pps->col_bd || !pps->row_bd || !pps->col_idxX) + return AVERROR(ENOMEM); + + if (pps->uniform_spacing_flag) { + if (!pps->column_width) { + pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width)); + pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height)); + } + if (!pps->column_width || !pps->row_height) + return AVERROR(ENOMEM); + + for (i = 0; i < pps->num_tile_columns; i++) { + pps->column_width[i] = ((i + 1) * sps->ctb_width) / pps->num_tile_columns - + (i * sps->ctb_width) / pps->num_tile_columns; + } + + for (i = 0; i < pps->num_tile_rows; i++) { + pps->row_height[i] = ((i + 1) * sps->ctb_height) / pps->num_tile_rows - + (i * sps->ctb_height) / pps->num_tile_rows; + } + } + + pps->col_bd[0] = 0; + for (i = 0; i < pps->num_tile_columns; i++) + pps->col_bd[i + 1] = pps->col_bd[i] + pps->column_width[i]; + + pps->row_bd[0] = 0; + for (i = 0; i < pps->num_tile_rows; i++) + pps->row_bd[i + 1] = pps->row_bd[i] + pps->row_height[i]; + + for (i = 0, j = 0; i < sps->ctb_width; i++) { + if (i > pps->col_bd[j]) + j++; + pps->col_idxX[i] = j; + } + + /** + * 6.5 + */ + pic_area_in_ctbs = sps->ctb_width * sps->ctb_height; + + pps->ctb_addr_rs_to_ts = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_rs_to_ts)); + pps->ctb_addr_ts_to_rs = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_ts_to_rs)); + pps->tile_id = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->tile_id)); + pps->min_tb_addr_zs_tab = av_malloc_array((sps->tb_mask+2) * (sps->tb_mask+2), sizeof(*pps->min_tb_addr_zs_tab)); + if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs || + !pps->tile_id || !pps->min_tb_addr_zs_tab) { + return AVERROR(ENOMEM); + } + + for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) { + int tb_x = ctb_addr_rs % sps->ctb_width; + int tb_y = ctb_addr_rs / sps->ctb_width; + int tile_x = 0; + int tile_y = 0; + int val = 0; + + for (i = 0; i < pps->num_tile_columns; i++) { + if (tb_x < pps->col_bd[i + 1]) { + tile_x = i; + break; + } + } + + for (i = 0; i < pps->num_tile_rows; i++) { + if (tb_y < pps->row_bd[i + 1]) { + tile_y = i; + break; + } + } + + for (i = 0; i < tile_x; i++) + val += pps->row_height[tile_y] * pps->column_width[i]; + for (i = 0; i < tile_y; i++) + val += sps->ctb_width * pps->row_height[i]; + + val += (tb_y - pps->row_bd[tile_y]) * pps->column_width[tile_x] + + tb_x - pps->col_bd[tile_x]; + + pps->ctb_addr_rs_to_ts[ctb_addr_rs] = val; + pps->ctb_addr_ts_to_rs[val] = ctb_addr_rs; + } + + for (j = 0, tile_id = 0; j < pps->num_tile_rows; j++) + for (i = 0; i < pps->num_tile_columns; i++, tile_id++) + for (y = pps->row_bd[j]; y < pps->row_bd[j + 1]; y++) + for (x = pps->col_bd[i]; x < pps->col_bd[i + 1]; x++) + pps->tile_id[pps->ctb_addr_rs_to_ts[y * sps->ctb_width + x]] = tile_id; + + pps->tile_pos_rs = av_malloc_array(tile_id, sizeof(*pps->tile_pos_rs)); + if (!pps->tile_pos_rs) + return AVERROR(ENOMEM); + + for (j = 0; j < pps->num_tile_rows; j++) + for (i = 0; i < pps->num_tile_columns; i++) + pps->tile_pos_rs[j * pps->num_tile_columns + i] = + pps->row_bd[j] * sps->ctb_width + pps->col_bd[i]; + + log2_diff = sps->log2_ctb_size - sps->log2_min_tb_size; + pps->min_tb_addr_zs = &pps->min_tb_addr_zs_tab[1*(sps->tb_mask+2)+1]; + for (y = 0; y < sps->tb_mask+2; y++) { + pps->min_tb_addr_zs_tab[y*(sps->tb_mask+2)] = -1; + pps->min_tb_addr_zs_tab[y] = -1; + } + for (y = 0; y < sps->tb_mask+1; y++) { + for (x = 0; x < sps->tb_mask+1; x++) { + int tb_x = x >> log2_diff; + int tb_y = y >> log2_diff; + int rs = sps->ctb_width * tb_y + tb_x; + int val = pps->ctb_addr_rs_to_ts[rs] << (log2_diff * 2); + for (i = 0; i < log2_diff; i++) { + int m = 1 << i; + val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0); + } + pps->min_tb_addr_zs[y * (sps->tb_mask+2) + x] = val; + } + } + + return 0; +} + +int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, + HEVCParamSets *ps) +{ + HEVCSPS *sps = NULL; + int i, ret = 0; unsigned int pps_id = 0; AVBufferRef *pps_buf; @@ -1271,7 +1398,7 @@ return AVERROR(ENOMEM); } - av_log(s->avctx, AV_LOG_DEBUG, "Decoding PPS\n"); + av_log(avctx, AV_LOG_DEBUG, "Decoding PPS\n"); // Default values pps->loop_filter_across_tiles_enabled_flag = 1; @@ -1286,22 +1413,22 @@ // Coded parameters pps_id = get_ue_golomb_long(gb); if (pps_id >= MAX_PPS_COUNT) { - av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id); + av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id); ret = AVERROR_INVALIDDATA; goto err; } pps->sps_id = get_ue_golomb_long(gb); if (pps->sps_id >= MAX_SPS_COUNT) { - av_log(s->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id); + av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id); ret = AVERROR_INVALIDDATA; goto err; } - if (!s->sps_list[pps->sps_id]) { - av_log(s->avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id); + if (!ps->sps_list[pps->sps_id]) { + av_log(avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id); ret = AVERROR_INVALIDDATA; goto err; } - sps = (HEVCSPS *)s->sps_list[pps->sps_id]->data; + sps = (HEVCSPS *)ps->sps_list[pps->sps_id]->data; pps->dependent_slice_segments_enabled_flag = get_bits1(gb); pps->output_flag_present_flag = get_bits1(gb); @@ -1326,7 +1453,7 @@ if (pps->diff_cu_qp_delta_depth < 0 || pps->diff_cu_qp_delta_depth > sps->log2_diff_max_min_coding_block_size) { - av_log(s->avctx, AV_LOG_ERROR, "diff_cu_qp_delta_depth %d is invalid\n", + av_log(avctx, AV_LOG_ERROR, "diff_cu_qp_delta_depth %d is invalid\n", pps->diff_cu_qp_delta_depth); ret = AVERROR_INVALIDDATA; goto err; @@ -1334,14 +1461,14 @@ pps->cb_qp_offset = get_se_golomb(gb); if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) { - av_log(s->avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n", + av_log(avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n", pps->cb_qp_offset); ret = AVERROR_INVALIDDATA; goto err; } pps->cr_qp_offset = get_se_golomb(gb); if (pps->cr_qp_offset < -12 || pps->cr_qp_offset > 12) { - av_log(s->avctx, AV_LOG_ERROR, "pps_cr_qp_offset out of range: %d\n", + av_log(avctx, AV_LOG_ERROR, "pps_cr_qp_offset out of range: %d\n", pps->cr_qp_offset); ret = AVERROR_INVALIDDATA; goto err; @@ -1360,14 +1487,14 @@ pps->num_tile_rows = get_ue_golomb_long(gb) + 1; if (pps->num_tile_columns <= 0 || pps->num_tile_columns >= sps->width) { - av_log(s->avctx, AV_LOG_ERROR, "num_tile_columns_minus1 out of range: %d\n", + av_log(avctx, AV_LOG_ERROR, "num_tile_columns_minus1 out of range: %d\n", pps->num_tile_columns - 1); ret = AVERROR_INVALIDDATA; goto err; } if (pps->num_tile_rows <= 0 || pps->num_tile_rows >= sps->height) { - av_log(s->avctx, AV_LOG_ERROR, "num_tile_rows_minus1 out of range: %d\n", + av_log(avctx, AV_LOG_ERROR, "num_tile_rows_minus1 out of range: %d\n", pps->num_tile_rows - 1); ret = AVERROR_INVALIDDATA; goto err; @@ -1388,7 +1515,7 @@ sum += pps->column_width[i]; } if (sum >= sps->ctb_width) { - av_log(s->avctx, AV_LOG_ERROR, "Invalid tile widths.\n"); + av_log(avctx, AV_LOG_ERROR, "Invalid tile widths.\n"); ret = AVERROR_INVALIDDATA; goto err; } @@ -1400,7 +1527,7 @@ sum += pps->row_height[i]; } if (sum >= sps->ctb_height) { - av_log(s->avctx, AV_LOG_ERROR, "Invalid tile heights.\n"); + av_log(avctx, AV_LOG_ERROR, "Invalid tile heights.\n"); ret = AVERROR_INVALIDDATA; goto err; } @@ -1419,13 +1546,13 @@ pps->beta_offset = get_se_golomb(gb) * 2; pps->tc_offset = get_se_golomb(gb) * 2; if (pps->beta_offset/2 < -6 || pps->beta_offset/2 > 6) { - av_log(s->avctx, AV_LOG_ERROR, "pps_beta_offset_div2 out of range: %d\n", + av_log(avctx, AV_LOG_ERROR, "pps_beta_offset_div2 out of range: %d\n", pps->beta_offset/2); ret = AVERROR_INVALIDDATA; goto err; } if (pps->tc_offset/2 < -6 || pps->tc_offset/2 > 6) { - av_log(s->avctx, AV_LOG_ERROR, "pps_tc_offset_div2 out of range: %d\n", + av_log(avctx, AV_LOG_ERROR, "pps_tc_offset_div2 out of range: %d\n", pps->tc_offset/2); ret = AVERROR_INVALIDDATA; goto err; @@ -1436,14 +1563,14 @@ pps->scaling_list_data_present_flag = get_bits1(gb); if (pps->scaling_list_data_present_flag) { set_default_scaling_list_data(&pps->scaling_list); - ret = scaling_list_data(s, &pps->scaling_list, sps); + ret = scaling_list_data(gb, avctx, &pps->scaling_list, sps); if (ret < 0) goto err; } pps->lists_modification_present_flag = get_bits1(gb); pps->log2_parallel_merge_level = get_ue_golomb_long(gb) + 2; if (pps->log2_parallel_merge_level > sps->log2_ctb_size) { - av_log(s->avctx, AV_LOG_ERROR, "log2_parallel_merge_level_minus2 out of range: %d\n", + av_log(avctx, AV_LOG_ERROR, "log2_parallel_merge_level_minus2 out of range: %d\n", pps->log2_parallel_merge_level - 2); ret = AVERROR_INVALIDDATA; goto err; @@ -1455,148 +1582,23 @@ int pps_range_extensions_flag = get_bits1(gb); /* int pps_extension_7bits = */ get_bits(gb, 7); if (sps->ptl.general_ptl.profile_idc == FF_PROFILE_HEVC_REXT && pps_range_extensions_flag) { - if ((ret = pps_range_extensions(s, pps, sps)) < 0) + if ((ret = pps_range_extensions(gb, avctx, pps, sps)) < 0) goto err; } } - // Inferred parameters - pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd)); - pps->row_bd = av_malloc_array(pps->num_tile_rows + 1, sizeof(*pps->row_bd)); - pps->col_idxX = av_malloc_array(sps->ctb_width, sizeof(*pps->col_idxX)); - if (!pps->col_bd || !pps->row_bd || !pps->col_idxX) { - ret = AVERROR(ENOMEM); - goto err; - } - - if (pps->uniform_spacing_flag) { - if (!pps->column_width) { - pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width)); - pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height)); - } - if (!pps->column_width || !pps->row_height) { - ret = AVERROR(ENOMEM); - goto err; - } - - for (i = 0; i < pps->num_tile_columns; i++) { - pps->column_width[i] = ((i + 1) * sps->ctb_width) / pps->num_tile_columns - - (i * sps->ctb_width) / pps->num_tile_columns; - } - - for (i = 0; i < pps->num_tile_rows; i++) { - pps->row_height[i] = ((i + 1) * sps->ctb_height) / pps->num_tile_rows - - (i * sps->ctb_height) / pps->num_tile_rows; - } - } - - pps->col_bd[0] = 0; - for (i = 0; i < pps->num_tile_columns; i++) - pps->col_bd[i + 1] = pps->col_bd[i] + pps->column_width[i]; - - pps->row_bd[0] = 0; - for (i = 0; i < pps->num_tile_rows; i++) - pps->row_bd[i + 1] = pps->row_bd[i] + pps->row_height[i]; - - for (i = 0, j = 0; i < sps->ctb_width; i++) { - if (i > pps->col_bd[j]) - j++; - pps->col_idxX[i] = j; - } - - /** - * 6.5 - */ - pic_area_in_ctbs = sps->ctb_width * sps->ctb_height; - - pps->ctb_addr_rs_to_ts = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_rs_to_ts)); - pps->ctb_addr_ts_to_rs = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_ts_to_rs)); - pps->tile_id = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->tile_id)); - pps->min_tb_addr_zs_tab = av_malloc_array((sps->tb_mask+2) * (sps->tb_mask+2), sizeof(*pps->min_tb_addr_zs_tab)); - if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs || - !pps->tile_id || !pps->min_tb_addr_zs_tab) { - ret = AVERROR(ENOMEM); - goto err; - } - - for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) { - int tb_x = ctb_addr_rs % sps->ctb_width; - int tb_y = ctb_addr_rs / sps->ctb_width; - int tile_x = 0; - int tile_y = 0; - int val = 0; - - for (i = 0; i < pps->num_tile_columns; i++) { - if (tb_x < pps->col_bd[i + 1]) { - tile_x = i; - break; - } - } - - for (i = 0; i < pps->num_tile_rows; i++) { - if (tb_y < pps->row_bd[i + 1]) { - tile_y = i; - break; - } - } - - for (i = 0; i < tile_x; i++) - val += pps->row_height[tile_y] * pps->column_width[i]; - for (i = 0; i < tile_y; i++) - val += sps->ctb_width * pps->row_height[i]; - - val += (tb_y - pps->row_bd[tile_y]) * pps->column_width[tile_x] + - tb_x - pps->col_bd[tile_x]; - - pps->ctb_addr_rs_to_ts[ctb_addr_rs] = val; - pps->ctb_addr_ts_to_rs[val] = ctb_addr_rs; - } - - for (j = 0, tile_id = 0; j < pps->num_tile_rows; j++) - for (i = 0; i < pps->num_tile_columns; i++, tile_id++) - for (y = pps->row_bd[j]; y < pps->row_bd[j + 1]; y++) - for (x = pps->col_bd[i]; x < pps->col_bd[i + 1]; x++) - pps->tile_id[pps->ctb_addr_rs_to_ts[y * sps->ctb_width + x]] = tile_id; - - pps->tile_pos_rs = av_malloc_array(tile_id, sizeof(*pps->tile_pos_rs)); - if (!pps->tile_pos_rs) { - ret = AVERROR(ENOMEM); + ret = setup_pps(avctx, gb, pps, sps); + if (ret < 0) goto err; - } - - for (j = 0; j < pps->num_tile_rows; j++) - for (i = 0; i < pps->num_tile_columns; i++) - pps->tile_pos_rs[j * pps->num_tile_columns + i] = pps->row_bd[j] * sps->ctb_width + pps->col_bd[i]; - - log2_diff_ctb_min_tb_size = sps->log2_ctb_size - sps->log2_min_tb_size; - pps->min_tb_addr_zs = &pps->min_tb_addr_zs_tab[1*(sps->tb_mask+2)+1]; - for (y = 0; y < sps->tb_mask+2; y++) { - pps->min_tb_addr_zs_tab[y*(sps->tb_mask+2)] = -1; - pps->min_tb_addr_zs_tab[y] = -1; - } - for (y = 0; y < sps->tb_mask+1; y++) { - for (x = 0; x < sps->tb_mask+1; x++) { - int tb_x = x >> log2_diff_ctb_min_tb_size; - int tb_y = y >> log2_diff_ctb_min_tb_size; - int ctb_addr_rs = sps->ctb_width * tb_y + tb_x; - int val = pps->ctb_addr_rs_to_ts[ctb_addr_rs] << - (log2_diff_ctb_min_tb_size * 2); - for (i = 0; i < log2_diff_ctb_min_tb_size; i++) { - int m = 1 << i; - val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0); - } - pps->min_tb_addr_zs[y * (sps->tb_mask+2) + x] = val; - } - } if (get_bits_left(gb) < 0) { - av_log(s->avctx, AV_LOG_ERROR, + av_log(avctx, AV_LOG_ERROR, "Overread PPS by %d bits\n", -get_bits_left(gb)); goto err; } - remove_pps(s, pps_id); - s->pps_list[pps_id] = pps_buf; + remove_pps(ps, pps_id); + ps->pps_list[pps_id] = pps_buf; return 0; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_ps_enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_ps_enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_ps_enc.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_ps_enc.c 2015-07-09 17:20:03.000000000 +0000 @@ -0,0 +1,116 @@ +/* + * HEVC Parameter Set encoding + * + * 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 "golomb.h" +#include "hevc.h" +#include "put_bits.h" + +static void write_ptl_layer(PutBitContext *pb, PTLCommon *ptl) +{ + int i; + + put_bits(pb, 2, ptl->profile_space); + put_bits(pb, 1, ptl->tier_flag); + put_bits(pb, 5, ptl->profile_idc); + for (i = 0; i < 32; i++) + put_bits(pb, 1, ptl->profile_compatibility_flag[i]); + put_bits(pb, 1, ptl->progressive_source_flag); + put_bits(pb, 1, ptl->interlaced_source_flag); + put_bits(pb, 1, ptl->non_packed_constraint_flag); + put_bits(pb, 1, ptl->frame_only_constraint_flag); + put_bits32(pb, 0); // reserved + put_bits(pb, 12, 0); // reserved +} + +static void write_ptl(PutBitContext *pb, PTL *ptl, int max_num_sub_layers) +{ + int i; + + write_ptl_layer(pb, &ptl->general_ptl); + put_bits(pb, 8, ptl->general_ptl.level_idc); + + for (i = 0; i < max_num_sub_layers - 1; i++) { + put_bits(pb, 1, ptl->sub_layer_profile_present_flag[i]); + put_bits(pb, 1, ptl->sub_layer_level_present_flag[i]); + } + + if (max_num_sub_layers > 1) + for (i = max_num_sub_layers - 1; i < 8; i++) + put_bits(pb, 2, 0); // reserved + + for (i = 0; i < max_num_sub_layers - 1; i++) { + if (ptl->sub_layer_profile_present_flag[i]) + write_ptl_layer(pb, &ptl->sub_layer_ptl[i]); + if (ptl->sub_layer_level_present_flag[i]) + put_bits(pb, 8, ptl->sub_layer_ptl[i].level_idc); + } +} + +int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id, + uint8_t *buf, int buf_size) +{ + PutBitContext pb; + int i; + + init_put_bits(&pb, buf, buf_size); + put_bits(&pb, 4, id); + put_bits(&pb, 2, 3); // reserved + put_bits(&pb, 6, vps->vps_max_layers - 1); + put_bits(&pb, 3, vps->vps_max_sub_layers - 1); + put_bits(&pb, 1, vps->vps_temporal_id_nesting_flag); + put_bits(&pb, 16, 0xffff); // reserved + + write_ptl(&pb, &vps->ptl, vps->vps_max_sub_layers); + + put_bits(&pb, 1, vps->vps_sub_layer_ordering_info_present_flag); + for (i = vps->vps_sub_layer_ordering_info_present_flag ? 0 : vps->vps_max_layers - 1; + i < vps->vps_max_sub_layers; i++) { + set_ue_golomb(&pb, vps->vps_max_dec_pic_buffering[i] - 1); + set_ue_golomb(&pb, vps->vps_num_reorder_pics[i]); + set_ue_golomb(&pb, vps->vps_max_latency_increase[i] + 1); + } + + put_bits(&pb, 6, vps->vps_max_layer_id); + set_ue_golomb(&pb, vps->vps_num_layer_sets - 1); + + // writing layer_id_included_flag not supported + if (vps->vps_num_layer_sets > 1) + return AVERROR_PATCHWELCOME; + + put_bits(&pb, 1, vps->vps_timing_info_present_flag); + if (vps->vps_timing_info_present_flag) { + put_bits32(&pb, vps->vps_num_units_in_tick); + put_bits32(&pb, vps->vps_time_scale); + put_bits(&pb, 1, vps->vps_poc_proportional_to_timing_flag); + if (vps->vps_poc_proportional_to_timing_flag) + set_ue_golomb(&pb, vps->vps_num_ticks_poc_diff_one - 1); + + // writing HRD parameters not supported + if (vps->vps_num_hrd_parameters) + return AVERROR_PATCHWELCOME; + } + + put_bits(&pb, 1, 0); // extension flag + + put_bits(&pb, 1, 1); // stop bit + avpriv_align_put_bits(&pb); + + return put_bits_count(&pb) / 8; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_refs.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_refs.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_refs.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_refs.c 2015-07-13 17:20:03.000000000 +0000 @@ -55,10 +55,10 @@ RefPicList *ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *ref, int x0, int y0) { - int x_cb = x0 >> s->sps->log2_ctb_size; - int y_cb = y0 >> s->sps->log2_ctb_size; - int pic_width_cb = s->sps->ctb_width; - int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[y_cb * pic_width_cb + x_cb]; + int x_cb = x0 >> s->ps.sps->log2_ctb_size; + int y_cb = y0 >> s->ps.sps->log2_ctb_size; + int pic_width_cb = s->ps.sps->ctb_width; + int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[y_cb * pic_width_cb + x_cb]; return (RefPicList *)ref->rpl_tab[ctb_addr_ts]; } @@ -91,7 +91,7 @@ if (ret < 0) return NULL; - frame->rpl_buf = av_buffer_allocz(s->nb_nals * sizeof(RefPicListTab)); + frame->rpl_buf = av_buffer_allocz(s->pkt.nb_nals * sizeof(RefPicListTab)); if (!frame->rpl_buf) goto fail; @@ -104,7 +104,7 @@ if (!frame->rpl_tab_buf) goto fail; frame->rpl_tab = (RefPicListTab **)frame->rpl_tab_buf->data; - frame->ctb_count = s->sps->ctb_width * s->sps->ctb_height; + frame->ctb_count = s->ps.sps->ctb_width * s->ps.sps->ctb_height; for (j = 0; j < frame->ctb_count; j++) frame->rpl_tab[j] = (RefPicListTab *)frame->rpl_buf->data; @@ -162,7 +162,7 @@ ref->poc = poc; ref->sequence = s->seq_decode; - ref->window = s->sps->output_window; + ref->window = s->ps.sps->output_window; return 0; } @@ -197,8 +197,8 @@ } /* wait for more frames before output */ - if (!flush && s->seq_output == s->seq_decode && s->sps && - nb_output <= s->sps->temporal_layer[s->sps->max_sub_layers - 1].num_reorder_pics) + if (!flush && s->seq_output == s->seq_decode && s->ps.sps && + nb_output <= s->ps.sps->temporal_layer[s->ps.sps->max_sub_layers - 1].num_reorder_pics) return 0; if (nb_output) { @@ -252,7 +252,7 @@ } } - if (s->sps && dpb >= s->sps->temporal_layer[s->sps->max_sub_layers - 1].max_dec_pic_buffering) { + if (s->ps.sps && dpb >= s->ps.sps->temporal_layer[s->ps.sps->max_sub_layers - 1].max_dec_pic_buffering) { for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) { HEVCFrame *frame = &s->DPB[i]; if ((frame->flags) && @@ -281,7 +281,7 @@ { HEVCFrame *frame = s->ref; int ctb_count = frame->ctb_count; - int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[s->sh.slice_segment_addr]; + int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_segment_addr]; int i; if (s->slice_idx >= frame->rpl_buf->size / sizeof(RefPicListTab)) @@ -368,7 +368,7 @@ static HEVCFrame *find_ref_idx(HEVCContext *s, int poc) { int i; - int LtMask = (1 << s->sps->log2_max_poc_lsb) - 1; + int LtMask = (1 << s->ps.sps->log2_max_poc_lsb) - 1; for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) { HEVCFrame *ref = &s->DPB[i]; @@ -408,16 +408,16 @@ return NULL; if (!s->avctx->hwaccel) { - if (!s->sps->pixel_shift) { + if (!s->ps.sps->pixel_shift) { for (i = 0; frame->frame->buf[i]; i++) - memset(frame->frame->buf[i]->data, 1 << (s->sps->bit_depth - 1), + memset(frame->frame->buf[i]->data, 1 << (s->ps.sps->bit_depth - 1), frame->frame->buf[i]->size); } else { for (i = 0; frame->frame->data[i]; i++) - for (y = 0; y < (s->sps->height >> s->sps->vshift[i]); y++) - for (x = 0; x < (s->sps->width >> s->sps->hshift[i]); x++) { + for (y = 0; y < (s->ps.sps->height >> s->ps.sps->vshift[i]); y++) + for (x = 0; x < (s->ps.sps->width >> s->ps.sps->hshift[i]); x++) { AV_WN16(frame->frame->data[i] + y * frame->frame->linesize[i] + 2 * x, - 1 << (s->sps->bit_depth - 1)); + 1 << (s->ps.sps->bit_depth - 1)); } } } @@ -517,7 +517,7 @@ int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb) { - int max_poc_lsb = 1 << s->sps->log2_max_poc_lsb; + int max_poc_lsb = 1 << s->ps.sps->log2_max_poc_lsb; int prev_poc_lsb = s->pocTid0 % max_poc_lsb; int prev_poc_msb = s->pocTid0 - prev_poc_lsb; int poc_msb; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_sei.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_sei.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hevc_sei.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hevc_sei.c 2015-08-02 17:20:02.000000000 +0000 @@ -25,7 +25,35 @@ #include "golomb.h" #include "hevc.h" -static void decode_nal_sei_decoded_picture_hash(HEVCContext *s) +enum HEVC_SEI_TYPE { + SEI_TYPE_BUFFERING_PERIOD = 0, + SEI_TYPE_PICTURE_TIMING = 1, + SEI_TYPE_PAN_SCAN_RECT = 2, + SEI_TYPE_FILLER_PAYLOAD = 3, + SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35 = 4, + SEI_TYPE_USER_DATA_UNREGISTERED = 5, + SEI_TYPE_RECOVERY_POINT = 6, + SEI_TYPE_SCENE_INFO = 9, + SEI_TYPE_FULL_FRAME_SNAPSHOT = 15, + SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START = 16, + SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END = 17, + SEI_TYPE_FILM_GRAIN_CHARACTERISTICS = 19, + SEI_TYPE_POST_FILTER_HINT = 22, + SEI_TYPE_TONE_MAPPING_INFO = 23, + SEI_TYPE_FRAME_PACKING = 45, + SEI_TYPE_DISPLAY_ORIENTATION = 47, + SEI_TYPE_SOP_DESCRIPTION = 128, + SEI_TYPE_ACTIVE_PARAMETER_SETS = 129, + SEI_TYPE_DECODING_UNIT_INFO = 130, + SEI_TYPE_TEMPORAL_LEVEL0_INDEX = 131, + SEI_TYPE_DECODED_PICTURE_HASH = 132, + SEI_TYPE_SCALABLE_NESTING = 133, + SEI_TYPE_REGION_REFRESH_INFO = 134, + SEI_TYPE_MASTERING_DISPLAY_INFO = 137, + SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144, +}; + +static int decode_nal_sei_decoded_picture_hash(HEVCContext *s) { int cIdx, i; uint8_t hash_type; @@ -47,9 +75,10 @@ skip_bits(gb, 32); } } + return 0; } -static void decode_nal_sei_frame_packing_arrangement(HEVCContext *s) +static int decode_nal_sei_frame_packing_arrangement(HEVCContext *s) { GetBitContext *gb = &s->HEVClc->gb; @@ -72,9 +101,10 @@ skip_bits1(gb); // frame_packing_arrangement_persistance_flag } skip_bits1(gb); // upsampled_aspect_ratio_flag + return 0; } -static void decode_nal_sei_display_orientation(HEVCContext *s) +static int decode_nal_sei_display_orientation(HEVCContext *s) { GetBitContext *gb = &s->HEVClc->gb; @@ -87,6 +117,8 @@ s->sei_anticlockwise_rotation = get_bits(gb, 16); skip_bits1(gb); // display_orientation_persistence_flag } + + return 0; } static int decode_pic_timing(HEVCContext *s) @@ -94,9 +126,9 @@ GetBitContext *gb = &s->HEVClc->gb; HEVCSPS *sps; - if (!s->sps_list[s->active_seq_parameter_set_id]) + if (!s->ps.sps_list[s->active_seq_parameter_set_id]) return(AVERROR(ENOMEM)); - sps = (HEVCSPS*)s->sps_list[s->active_seq_parameter_set_id]->data; + sps = (HEVCSPS*)s->ps.sps_list[s->active_seq_parameter_set_id]->data; if (sps->vui.frame_field_info_present_flag) { int pic_struct = get_bits(gb, 4); @@ -144,6 +176,49 @@ return 0; } +static int decode_nal_sei_prefix(HEVCContext *s, int type, int size) +{ + GetBitContext *gb = &s->HEVClc->gb; + + switch (type) { + case 256: // Mismatched value from HM 8.1 + return decode_nal_sei_decoded_picture_hash(s); + case SEI_TYPE_FRAME_PACKING: + return decode_nal_sei_frame_packing_arrangement(s); + case SEI_TYPE_DISPLAY_ORIENTATION: + return decode_nal_sei_display_orientation(s); + case SEI_TYPE_PICTURE_TIMING: + { + int ret = decode_pic_timing(s); + av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type); + skip_bits(gb, 8 * size); + return ret; + } + case SEI_TYPE_ACTIVE_PARAMETER_SETS: + active_parameter_sets(s); + av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type); + return 0; + default: + av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type); + skip_bits_long(gb, 8 * size); + return 0; + } +} + +static int decode_nal_sei_suffix(HEVCContext *s, int type, int size) +{ + GetBitContext *gb = &s->HEVClc->gb; + + switch (type) { + case SEI_TYPE_DECODED_PICTURE_HASH: + return decode_nal_sei_decoded_picture_hash(s); + default: + av_log(s->avctx, AV_LOG_DEBUG, "Skipped SUFFIX SEI %d\n", type); + skip_bits_long(gb, 8 * size); + return 0; + } +} + static int decode_nal_sei_message(HEVCContext *s) { GetBitContext *gb = &s->HEVClc->gb; @@ -163,31 +238,9 @@ payload_size += byte; } if (s->nal_unit_type == NAL_SEI_PREFIX) { - if (payload_type == 256 /*&& s->decode_checksum_sei*/) { - decode_nal_sei_decoded_picture_hash(s); - } else if (payload_type == 45) { - decode_nal_sei_frame_packing_arrangement(s); - } else if (payload_type == 47) { - decode_nal_sei_display_orientation(s); - } else if (payload_type == 1){ - int ret = decode_pic_timing(s); - av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", payload_type); - skip_bits(gb, 8 * payload_size); - return ret; - } else if (payload_type == 129){ - active_parameter_sets(s); - av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", payload_type); - } else { - av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", payload_type); - skip_bits(gb, 8*payload_size); - } + return decode_nal_sei_prefix(s, payload_type, payload_size); } else { /* nal_unit_type == NAL_SEI_SUFFIX */ - if (payload_type == 132 /* && s->decode_checksum_sei */) - decode_nal_sei_decoded_picture_hash(s); - else { - av_log(s->avctx, AV_LOG_DEBUG, "Skipped SUFFIX SEI %d\n", payload_type); - skip_bits(gb, 8 * payload_size); - } + return decode_nal_sei_suffix(s, payload_type, payload_size); } return 1; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hnm4video.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hnm4video.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hnm4video.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hnm4video.c 2015-07-28 17:20:07.000000000 +0000 @@ -510,5 +510,5 @@ .init = hnm_decode_init, .close = hnm_decode_end, .decode = hnm_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hpeldsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hpeldsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hpeldsp.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hpeldsp.c 2015-06-19 17:20:03.000000000 +0000 @@ -365,4 +365,6 @@ ff_hpeldsp_init_ppc(c, flags); if (ARCH_X86) ff_hpeldsp_init_x86(c, flags); + if (ARCH_MIPS) + ff_hpeldsp_init_mips(c, flags); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hpeldsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/hpeldsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hpeldsp.h 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hpeldsp.h 2015-06-19 17:20:03.000000000 +0000 @@ -99,5 +99,6 @@ void ff_hpeldsp_init_arm(HpelDSPContext *c, int flags); void ff_hpeldsp_init_ppc(HpelDSPContext *c, int flags); void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags); +void ff_hpeldsp_init_mips(HpelDSPContext *c, int flags); #endif /* AVCODEC_HPELDSP_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hq_hqa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hq_hqa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hq_hqa.c 2015-06-19 20:44:38.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hq_hqa.c 2015-07-28 17:20:07.000000000 +0000 @@ -307,9 +307,11 @@ return AVERROR_INVALIDDATA; } - info_tag = bytestream2_get_le32(&ctx->gbc); + info_tag = bytestream2_peek_le32(&ctx->gbc); if (info_tag == MKTAG('I', 'N', 'F', 'O')) { - int info_size = bytestream2_get_le32(&ctx->gbc); + int info_size; + bytestream2_skip(&ctx->gbc, 4); + info_size = bytestream2_get_le32(&ctx->gbc); if (bytestream2_get_bytes_left(&ctx->gbc) < info_size) { av_log(avctx, AV_LOG_ERROR, "Invalid INFO size (%d).\n", info_size); return AVERROR_INVALIDDATA; @@ -379,7 +381,7 @@ .init = hq_hqa_decode_init, .decode = hq_hqa_decode_frame, .close = hq_hqa_decode_close, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/hqx.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/hqx.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/hqx.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/hqx.c 2015-07-28 17:20:07.000000000 +0000 @@ -536,7 +536,7 @@ .init = hqx_decode_init, .decode = hqx_decode_frame, .close = hqx_decode_close, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/huffyuvdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/huffyuvdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/huffyuvdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/huffyuvdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -37,10 +37,11 @@ #include "huffyuv.h" #include "huffyuvdsp.h" #include "thread.h" +#include "libavutil/imgutils.h" #include "libavutil/pixdesc.h" #define classic_shift_luma_table_size 42 -static const unsigned char classic_shift_luma[classic_shift_luma_table_size + FF_INPUT_BUFFER_PADDING_SIZE] = { +static const unsigned char classic_shift_luma[classic_shift_luma_table_size + AV_INPUT_BUFFER_PADDING_SIZE] = { 34, 36, 35, 69, 135, 232, 9, 16, 10, 24, 11, 23, 12, 16, 13, 10, 14, 8, 15, 8, 16, 8, 17, 20, 16, 10, 207, 206, 205, 236, 11, 8, 10, 21, 9, 23, 8, 8, 199, 70, 69, 68, 0, @@ -48,7 +49,7 @@ }; #define classic_shift_chroma_table_size 59 -static const unsigned char classic_shift_chroma[classic_shift_chroma_table_size + FF_INPUT_BUFFER_PADDING_SIZE] = { +static const unsigned char classic_shift_chroma[classic_shift_chroma_table_size + AV_INPUT_BUFFER_PADDING_SIZE] = { 66, 36, 37, 38, 39, 40, 41, 75, 76, 77, 110, 239, 144, 81, 82, 83, 84, 85, 118, 183, 56, 57, 88, 89, 56, 89, 154, 57, 58, 57, 26, 141, 57, 56, 58, 57, 58, 57, 184, 119, 214, 245, 116, 83, 82, 49, 80, 79, @@ -291,6 +292,10 @@ HYuvContext *s = avctx->priv_data; int ret; + ret = av_image_check_size(avctx->width, avctx->height, 0, avctx); + if (ret < 0) + return ret; + ff_huffyuvdsp_init(&s->hdsp); memset(s->vlc, 0, 4 * sizeof(VLC)); @@ -1033,7 +1038,7 @@ decode_422_bitstream(s, width - 2); lefty = s->hdsp.add_hfyu_left_pred(p->data[0] + 2, s->temp[0], width - 2, lefty); - if (!(s->flags & CODEC_FLAG_GRAY)) { + if (!(s->flags & AV_CODEC_FLAG_GRAY)) { leftu = s->hdsp.add_hfyu_left_pred(p->data[1] + 1, s->temp[1], width2 - 1, leftu); leftv = s->hdsp.add_hfyu_left_pred(p->data[2] + 1, s->temp[2], width2 - 1, leftv); } @@ -1066,14 +1071,14 @@ decode_422_bitstream(s, width); lefty = s->hdsp.add_hfyu_left_pred(ydst, s->temp[0], width, lefty); - if (!(s->flags & CODEC_FLAG_GRAY)) { + if (!(s->flags & AV_CODEC_FLAG_GRAY)) { leftu = s->hdsp.add_hfyu_left_pred(udst, s->temp[1], width2, leftu); leftv = s->hdsp.add_hfyu_left_pred(vdst, s->temp[2], width2, leftv); } if (s->predictor == PLANE) { if (cy > s->interlaced) { s->hdsp.add_bytes(ydst, ydst - fake_ystride, width); - if (!(s->flags & CODEC_FLAG_GRAY)) { + if (!(s->flags & AV_CODEC_FLAG_GRAY)) { s->hdsp.add_bytes(udst, udst - fake_ustride, width2); s->hdsp.add_bytes(vdst, vdst - fake_vstride, width2); } @@ -1088,7 +1093,7 @@ decode_422_bitstream(s, width - 2); lefty = s->hdsp.add_hfyu_left_pred(p->data[0] + 2, s->temp[0], width - 2, lefty); - if (!(s->flags & CODEC_FLAG_GRAY)) { + if (!(s->flags & AV_CODEC_FLAG_GRAY)) { leftu = s->hdsp.add_hfyu_left_pred(p->data[1] + 1, s->temp[1], width2 - 1, leftu); leftv = s->hdsp.add_hfyu_left_pred(p->data[2] + 1, s->temp[2], width2 - 1, leftv); } @@ -1100,7 +1105,7 @@ decode_422_bitstream(s, width); lefty = s->hdsp.add_hfyu_left_pred(p->data[0] + p->linesize[0], s->temp[0], width, lefty); - if (!(s->flags & CODEC_FLAG_GRAY)) { + if (!(s->flags & AV_CODEC_FLAG_GRAY)) { leftu = s->hdsp.add_hfyu_left_pred(p->data[1] + p->linesize[2], s->temp[1], width2, leftu); leftv = s->hdsp.add_hfyu_left_pred(p->data[2] + p->linesize[1], s->temp[2], width2, leftv); } @@ -1112,7 +1117,7 @@ decode_422_bitstream(s, 4); lefty = s->hdsp.add_hfyu_left_pred(p->data[0] + fake_ystride, s->temp[0], 4, lefty); - if (!(s->flags & CODEC_FLAG_GRAY)) { + if (!(s->flags & AV_CODEC_FLAG_GRAY)) { leftu = s->hdsp.add_hfyu_left_pred(p->data[1] + fake_ustride, s->temp[1], 2, leftu); leftv = s->hdsp.add_hfyu_left_pred(p->data[2] + fake_vstride, s->temp[2], 2, leftv); } @@ -1123,7 +1128,7 @@ s->hdsp.add_hfyu_median_pred(p->data[0] + fake_ystride + 4, p->data[0] + 4, s->temp[0], width - 4, &lefty, &lefttopy); - if (!(s->flags & CODEC_FLAG_GRAY)) { + if (!(s->flags & AV_CODEC_FLAG_GRAY)) { lefttopu = p->data[1][1]; lefttopv = p->data[2][1]; s->hdsp.add_hfyu_median_pred(p->data[1] + fake_ustride + 2, p->data[1] + 2, s->temp[1], width2 - 2, &leftu, &lefttopu); @@ -1158,7 +1163,7 @@ s->hdsp.add_hfyu_median_pred(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy); - if (!(s->flags & CODEC_FLAG_GRAY)) { + if (!(s->flags & AV_CODEC_FLAG_GRAY)) { s->hdsp.add_hfyu_median_pred(udst, udst - fake_ustride, s->temp[1], width2, &leftu, &lefttopu); s->hdsp.add_hfyu_median_pred(vdst, vdst - fake_vstride, s->temp[2], width2, &leftv, &lefttopv); } @@ -1238,8 +1243,8 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | - CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DRAW_HORIZ_BAND | + AV_CODEC_CAP_FRAME_THREADS, .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), }; @@ -1253,8 +1258,8 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | - CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DRAW_HORIZ_BAND | + AV_CODEC_CAP_FRAME_THREADS, .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), }; #endif /* CONFIG_FFVHUFF_DECODER */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/huffyuvenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/huffyuvenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/huffyuvenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/huffyuvenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -220,7 +220,7 @@ ff_huffyuvencdsp_init(&s->hencdsp); avctx->extradata = av_mallocz(3*MAX_N + 4); - if (s->flags&CODEC_FLAG_PASS1) { + if (s->flags&AV_CODEC_FLAG_PASS1) { #define STATS_OUT_SIZE 21*MAX_N*3 + 4 avctx->stats_out = av_mallocz(STATS_OUT_SIZE); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132 if (!avctx->stats_out) @@ -228,12 +228,15 @@ } s->version = 2; - avctx->coded_frame = av_frame_alloc(); - if (!avctx->extradata || !avctx->coded_frame) + if (!avctx->extradata) return AVERROR(ENOMEM); +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif s->bps = desc->comp[0].depth_minus1 + 1; s->yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) && desc->nb_components >= 2; @@ -311,10 +314,10 @@ avctx->bits_per_coded_sample = s->bitstream_bpp; s->decorrelate = s->bitstream_bpp >= 24 && !s->yuv && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR); s->predictor = avctx->prediction_method; - s->interlaced = avctx->flags&CODEC_FLAG_INTERLACED_ME ? 1 : 0; + s->interlaced = avctx->flags & AV_CODEC_FLAG_INTERLACED_ME ? 1 : 0; if (avctx->context_model == 1) { s->context = avctx->context_model; - if (s->flags & (CODEC_FLAG_PASS1|CODEC_FLAG_PASS2)) { + if (s->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) { av_log(avctx, AV_LOG_ERROR, "context=1 is not compatible with " "2 pass huffyuv encoding\n"); @@ -451,7 +454,7 @@ count /= 2; - if (s->flags & CODEC_FLAG_PASS1) { + if (s->flags & AV_CODEC_FLAG_PASS1) { for(i = 0; i < count; i++) { LOAD4; s->stats[0][y0]++; @@ -460,7 +463,7 @@ s->stats[2][v0]++; } } - if (s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT) + if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) return 0; if (s->context) { for (i = 0; i < count; i++) { @@ -536,7 +539,7 @@ put_bits(&s->pb, 2, y1&3); if (s->bps <= 8) { - if (s->flags & CODEC_FLAG_PASS1) { + if (s->flags & AV_CODEC_FLAG_PASS1) { for (i = 0; i < count; i++) { LOAD2; STAT2; @@ -546,7 +549,7 @@ STATEND; } } - if (s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT) + if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) return 0; if (s->context) { @@ -572,7 +575,7 @@ } } else if (s->bps <= 14) { int mask = s->n - 1; - if (s->flags & CODEC_FLAG_PASS1) { + if (s->flags & AV_CODEC_FLAG_PASS1) { for (i = 0; i < count; i++) { LOAD2_14; STAT2; @@ -582,7 +585,7 @@ STATEND; } } - if (s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT) + if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) return 0; if (s->context) { @@ -607,7 +610,7 @@ } } } else { - if (s->flags & CODEC_FLAG_PASS1) { + if (s->flags & AV_CODEC_FLAG_PASS1) { for (i = 0; i < count; i++) { LOAD2_16; STAT2_16; @@ -617,7 +620,7 @@ STATEND_16; } } - if (s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT) + if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) return 0; if (s->context) { @@ -669,13 +672,13 @@ count /= 2; - if (s->flags & CODEC_FLAG_PASS1) { + if (s->flags & AV_CODEC_FLAG_PASS1) { for (i = 0; i < count; i++) { LOAD2; STAT2; } } - if (s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT) + if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) return 0; if (s->context) { @@ -723,13 +726,13 @@ if (planes == 4) \ put_bits(&s->pb, s->len[2][a], s->bits[2][a]); - if ((s->flags & CODEC_FLAG_PASS1) && - (s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT)) { + if ((s->flags & AV_CODEC_FLAG_PASS1) && + (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT)) { for (i = 0; i < count; i++) { LOAD_GBRA; STAT_BGRA; } - } else if (s->context || (s->flags & CODEC_FLAG_PASS1)) { + } else if (s->context || (s->flags & AV_CODEC_FLAG_PASS1)) { for (i = 0; i < count; i++) { LOAD_GBRA; STAT_BGRA; @@ -757,7 +760,7 @@ const AVFrame * const p = pict; int i, j, size = 0, ret; - if ((ret = ff_alloc_packet2(avctx, pkt, width * height * 3 * 4 + FF_MIN_BUFFER_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, width * height * 3 * 4 + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return ret; if (s->context) { @@ -997,7 +1000,7 @@ put_bits(&s->pb, 15, 0); size /= 4; - if ((s->flags&CODEC_FLAG_PASS1) && (s->picture_number & 31) == 0) { + if ((s->flags & AV_CODEC_FLAG_PASS1) && (s->picture_number & 31) == 0) { int j; char *p = avctx->stats_out; char *end = p + STATS_OUT_SIZE; @@ -1014,7 +1017,7 @@ } } else if (avctx->stats_out) avctx->stats_out[0] = '\0'; - if (!(s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT)) { + if (!(s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT)) { flush_put_bits(&s->pb); s->bdsp.bswap_buf((uint32_t *) pkt->data, (uint32_t *) pkt->data, size); } @@ -1037,8 +1040,6 @@ av_freep(&avctx->extradata); av_freep(&avctx->stats_out); - av_frame_free(&avctx->coded_frame); - return 0; } @@ -1072,7 +1073,7 @@ .init = encode_init, .encode2 = encode_frame, .close = encode_end, - .capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY, + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .priv_class = &normal_class, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV422P, AV_PIX_FMT_RGB24, @@ -1092,7 +1093,7 @@ .init = encode_init, .encode2 = encode_frame, .close = encode_end, - .capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY, + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .priv_class = &ff_class, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV411P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/idcinvideo.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/idcinvideo.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/idcinvideo.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/idcinvideo.c 2015-07-28 17:20:07.000000000 +0000 @@ -248,5 +248,5 @@ .priv_data_size = sizeof(IdcinContext), .init = idcin_decode_init, .decode = idcin_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/idctdsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/idctdsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/idctdsp.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/idctdsp.c 2015-07-07 17:20:03.000000000 +0000 @@ -305,6 +305,8 @@ ff_idctdsp_init_ppc(c, avctx, high_bit_depth); if (ARCH_X86) ff_idctdsp_init_x86(c, avctx, high_bit_depth); + if (ARCH_MIPS) + ff_idctdsp_init_mips(c, avctx, high_bit_depth); ff_put_pixels_clamped = c->put_pixels_clamped; ff_add_pixels_clamped = c->add_pixels_clamped; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/idctdsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/idctdsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/idctdsp.h 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/idctdsp.h 2015-07-07 17:20:03.000000000 +0000 @@ -108,5 +108,7 @@ unsigned high_bit_depth); void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); +void ff_idctdsp_init_mips(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth); #endif /* AVCODEC_IDCTDSP_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/iff.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/iff.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/iff.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/iff.c 2015-07-28 17:20:07.000000000 +0000 @@ -240,7 +240,7 @@ avctx->pix_fmt = AV_PIX_FMT_RGB32; av_freep(&s->mask_buf); av_freep(&s->mask_palbuf); - s->mask_buf = av_malloc((s->planesize * 32) + FF_INPUT_BUFFER_PADDING_SIZE); + s->mask_buf = av_malloc((s->planesize * 32) + AV_INPUT_BUFFER_PADDING_SIZE); if (!s->mask_buf) return AVERROR(ENOMEM); if (s->bpp > 16) { @@ -248,7 +248,7 @@ av_freep(&s->mask_buf); return AVERROR(ENOMEM); } - s->mask_palbuf = av_malloc((2 << s->bpp) * sizeof(uint32_t) + FF_INPUT_BUFFER_PADDING_SIZE); + s->mask_palbuf = av_malloc((2 << s->bpp) * sizeof(uint32_t) + AV_INPUT_BUFFER_PADDING_SIZE); if (!s->mask_palbuf) { av_freep(&s->mask_buf); return AVERROR(ENOMEM); @@ -275,12 +275,12 @@ int ham_count; const uint8_t *const palette = avctx->extradata + AV_RB16(avctx->extradata); - s->ham_buf = av_malloc((s->planesize * 8) + FF_INPUT_BUFFER_PADDING_SIZE); + s->ham_buf = av_malloc((s->planesize * 8) + AV_INPUT_BUFFER_PADDING_SIZE); if (!s->ham_buf) return AVERROR(ENOMEM); ham_count = 8 * (1 << s->ham); - s->ham_palbuf = av_malloc((ham_count << !!(s->masking == MASK_HAS_MASK)) * sizeof (uint32_t) + FF_INPUT_BUFFER_PADDING_SIZE); + s->ham_palbuf = av_malloc((ham_count << !!(s->masking == MASK_HAS_MASK)) * sizeof (uint32_t) + AV_INPUT_BUFFER_PADDING_SIZE); if (!s->ham_palbuf) { av_freep(&s->ham_buf); return AVERROR(ENOMEM); @@ -366,7 +366,7 @@ if ((err = av_image_check_size(avctx->width, avctx->height, 0, avctx))) return err; s->planesize = FFALIGN(avctx->width, 16) >> 3; // Align plane size in bits to word-boundary - s->planebuf = av_malloc(s->planesize + FF_INPUT_BUFFER_PADDING_SIZE); + s->planebuf = av_malloc(s->planesize + AV_INPUT_BUFFER_PADDING_SIZE); if (!s->planebuf) return AVERROR(ENOMEM); @@ -887,7 +887,7 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif #if CONFIG_IFF_BYTERUN1_DECODER @@ -900,6 +900,6 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/imc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/imc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/imc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/imc.c 2015-07-28 17:20:07.000000000 +0000 @@ -256,7 +256,7 @@ return ret; } ff_bswapdsp_init(&q->bdsp); - q->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!q->fdsp) { ff_fft_end(&q->fft); @@ -426,7 +426,7 @@ pos = q->coef0_pos; flcoeffs1[pos] = 20000.0 / pow (2, levlCoeffBuf[0] * 0.18945); // 0.18945 = log2(10) * 0.05703125 - flcoeffs2[pos] = log2f(flcoeffs1[0]); + flcoeffs2[pos] = log2f(flcoeffs1[pos]); tmp = flcoeffs1[pos]; tmp2 = flcoeffs2[pos]; @@ -1021,7 +1021,7 @@ IMCContext *q = avctx->priv_data; - LOCAL_ALIGNED_16(uint16_t, buf16, [(IMC_BLOCK_SIZE + FF_INPUT_BUFFER_PADDING_SIZE) / 2]); + LOCAL_ALIGNED_16(uint16_t, buf16, [(IMC_BLOCK_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) / 2]); if (buf_size < IMC_BLOCK_SIZE * avctx->channels) { av_log(avctx, AV_LOG_ERROR, "frame too small!\n"); @@ -1085,7 +1085,7 @@ .close = imc_decode_close, .decode = imc_decode_frame, .flush = flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; @@ -1101,7 +1101,7 @@ .close = imc_decode_close, .decode = imc_decode_frame, .flush = flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/imgconvert.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/imgconvert.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/imgconvert.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/imgconvert.c 2015-06-13 17:20:02.000000000 +0000 @@ -201,12 +201,14 @@ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); int y_shift; int x_shift; + int max_step[4]; if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB) return -1; y_shift = desc->log2_chroma_h; x_shift = desc->log2_chroma_w; + av_image_fill_max_pixsteps(max_step, NULL, desc); if (is_yuv_planar(desc)) { dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band; @@ -215,9 +217,7 @@ } else{ if(top_band % (1<data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band; + dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + (left_band * max_step[0]); } dst->linesize[0] = src->linesize[0]; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/imx_dump_header_bsf.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/imx_dump_header_bsf.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/imx_dump_header_bsf.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/imx_dump_header_bsf.c 2015-07-28 17:20:07.000000000 +0000 @@ -42,7 +42,7 @@ return 0; } - *poutbuf = av_malloc(buf_size + 20 + FF_INPUT_BUFFER_PADDING_SIZE); + *poutbuf = av_malloc(buf_size + 20 + AV_INPUT_BUFFER_PADDING_SIZE); if (!*poutbuf) return AVERROR(ENOMEM); poutbufp = *poutbuf; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/indeo2.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/indeo2.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/indeo2.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/indeo2.c 2015-07-28 17:20:07.000000000 +0000 @@ -252,5 +252,5 @@ .init = ir2_decode_init, .close = ir2_decode_end, .decode = ir2_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/indeo3.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/indeo3.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/indeo3.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/indeo3.c 2015-07-28 17:20:07.000000000 +0000 @@ -1142,5 +1142,5 @@ .init = decode_init, .close = decode_close, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/indeo4.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/indeo4.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/indeo4.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/indeo4.c 2015-07-28 17:20:07.000000000 +0000 @@ -704,5 +704,5 @@ .init = decode_init, .close = ff_ivi_decode_close, .decode = ff_ivi_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/indeo5.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/indeo5.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/indeo5.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/indeo5.c 2015-07-28 17:20:07.000000000 +0000 @@ -688,5 +688,5 @@ .init = decode_init, .close = ff_ivi_decode_close, .decode = ff_ivi_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/intelh263dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/intelh263dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/intelh263dec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/intelh263dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -136,7 +136,7 @@ .init = ff_h263_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/internal.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/internal.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/internal.h 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/internal.h 2015-08-04 17:20:03.000000000 +0000 @@ -61,7 +61,11 @@ #endif -#define FF_SANE_NB_CHANNELS 63U +#if !FF_API_QUANT_BIAS +#define FF_DEFAULT_QUANT_BIAS 999999 +#endif + +#define FF_SANE_NB_CHANNELS 64U #define FF_SIGNBIT(x) ((x) >> CHAR_BIT * sizeof(x) - 1) @@ -196,7 +200,7 @@ * This value was chosen such that every bit of the buffer is * addressable by a 32-bit signed integer as used by get_bits. */ -#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - FF_INPUT_BUFFER_PADDING_SIZE) +#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE) /** * Check AVPacket size and/or allocate data. @@ -213,11 +217,20 @@ * avpkt->size is set to the specified size. * All other AVPacket fields will be reset with av_init_packet(). * @param size the minimum required packet size + * @param min_size This is a hint to the allocation algorithm, which indicates + * to what minimal size the caller might later shrink the packet + * to. Encoders often allocate packets which are larger than the + * amount of data that is written into them as the exact amount is + * not known at the time of allocation. min_size represents the + * size a packet might be shrunk to by the caller. Can be set to + * 0. setting this roughly correctly allows the allocation code + * to choose between several allocation strategies to improve + * speed slightly. * @return non negative on success, negative error code on failure */ -int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size); +int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size); -int ff_alloc_packet(AVPacket *avpkt, int size); +attribute_deprecated int ff_alloc_packet(AVPacket *avpkt, int size); /** * Rescale from sample rate to AVCodecContext.time_base. @@ -294,4 +307,6 @@ */ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame); +int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type); + #endif /* AVCODEC_INTERNAL_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/interplayvideo.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/interplayvideo.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/interplayvideo.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/interplayvideo.c 2015-07-28 17:20:07.000000000 +0000 @@ -1048,5 +1048,5 @@ .init = ipvideo_decode_init, .close = ipvideo_decode_end, .decode = ipvideo_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_PARAM_CHANGE, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_PARAM_CHANGE, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ituh263dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ituh263dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ituh263dec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ituh263dec.c 2015-07-01 17:20:03.000000000 +0000 @@ -31,16 +31,19 @@ #include #include "libavutil/attributes.h" +#include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/mathematics.h" #include "avcodec.h" #include "mpegvideo.h" #include "h263.h" +#include "h263data.h" #include "internal.h" #include "mathops.h" #include "mpegutils.h" #include "unary.h" #include "flv.h" +#include "rv10.h" #include "mpeg4video.h" #include "mpegvideodata.h" @@ -137,12 +140,12 @@ { int i, mb_pos; - for(i=0; i<6; i++){ - if(s->mb_num-1 <= ff_mba_max[i]) break; - } - mb_pos= get_bits(&s->gb, ff_mba_length[i]); - s->mb_x= mb_pos % s->mb_width; - s->mb_y= mb_pos / s->mb_width; + for (i = 0; i < 6; i++) + if (s->mb_num - 1 <= ff_mba_max[i]) + break; + mb_pos = get_bits(&s->gb, ff_mba_length[i]); + s->mb_x = mb_pos % s->mb_width; + s->mb_y = mb_pos / s->mb_width; return mb_pos; } @@ -872,7 +875,7 @@ /* most is hardcoded. should extend to handle all h263 streams */ int ff_h263_decode_picture_header(MpegEncContext *s) { - int format, width, height, i; + int format, width, height, i, ret; uint32_t startcode; align_get_bits(&s->gb); @@ -1082,10 +1085,9 @@ s->qscale = get_bits(&s->gb, 5); } - if (s->width == 0 || s->height == 0) { - av_log(s->avctx, AV_LOG_ERROR, "dimensions 0\n"); - return -1; - } + if ((ret = av_image_check_size(s->width, s->height, 0, s)) < 0) + return ret; + s->mb_width = (s->width + 15) / 16; s->mb_height = (s->height + 15) / 16; s->mb_num = s->mb_width * s->mb_height; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ituh263enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ituh263enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ituh263enc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ituh263enc.c 2015-07-28 17:20:07.000000000 +0000 @@ -34,6 +34,7 @@ #include "mpegvideo.h" #include "mpegvideodata.h" #include "h263.h" +#include "h263data.h" #include "mathops.h" #include "mpegutils.h" #include "unary.h" @@ -452,7 +453,7 @@ int16_t pred_dc; int16_t rec_intradc[6]; int16_t *dc_ptr[6]; - const int interleaved_stats = s->avctx->flags & CODEC_FLAG_PASS1; + const int interleaved_stats = s->avctx->flags & AV_CODEC_FLAG_PASS1; if (!s->mb_intra) { /* compute cbp */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/j2kenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/j2kenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/j2kenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/j2kenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -31,12 +31,16 @@ #include "bytestream.h" #include "jpeg2000.h" #include "libavutil/common.h" +#include "libavutil/opt.h" #define NMSEDEC_BITS 7 #define NMSEDEC_FRACBITS (NMSEDEC_BITS-1) #define WMSEDEC_SHIFT 13 ///< must be >= 13 #define LAMBDA_SCALE (100000000LL << (WMSEDEC_SHIFT - 13)) +#define CODEC_JP2 1 +#define CODEC_J2K 0 + static int lut_nmsedec_ref [1<buf, 0); // progression level bytestream_put_be16(&s->buf, 1); // num of layers if(s->avctx->pix_fmt == AV_PIX_FMT_YUV444P){ - bytestream_put_byte(&s->buf, 2); // ICT + bytestream_put_byte(&s->buf, 0); // unspecified }else{ bytestream_put_byte(&s->buf, 0); // unspecified } @@ -310,6 +317,25 @@ return 0; } +static int put_com(Jpeg2000EncoderContext *s, int compno) +{ + int size = 4 + strlen(LIBAVCODEC_IDENT); + + if (s->avctx->flags & AV_CODEC_FLAG_BITEXACT) + return 0; + + if (s->buf_end - s->buf < size + 2) + return -1; + + bytestream_put_be16(&s->buf, JPEG2000_COM); + bytestream_put_be16(&s->buf, size); + bytestream_put_be16(&s->buf, 1); // General use (ISO/IEC 8859-15 (Latin) values) + + bytestream_put_buffer(&s->buf, LIBAVCODEC_IDENT, strlen(LIBAVCODEC_IDENT)); + + return 0; +} + static uint8_t *put_sot(Jpeg2000EncoderContext *s, int tileno) { uint8_t *psotptr; @@ -486,18 +512,18 @@ for (y0 = 0; y0 < height; y0 += 4) for (x = 0; x < width; x++) for (y = y0; y < height && y < y0+4; y++){ - if (!(t1->flags[y+1][x+1] & JPEG2000_T1_SIG) && (t1->flags[y+1][x+1] & JPEG2000_T1_SIG_NB)){ - int ctxno = ff_jpeg2000_getsigctxno(t1->flags[y+1][x+1], bandno), - bit = t1->data[y][x] & mask ? 1 : 0; + if (!(t1->flags[(y+1) * t1->stride + x+1] & JPEG2000_T1_SIG) && (t1->flags[(y+1) * t1->stride + x+1] & JPEG2000_T1_SIG_NB)){ + int ctxno = ff_jpeg2000_getsigctxno(t1->flags[(y+1) * t1->stride + x+1], bandno), + bit = t1->data[(y) * t1->stride + x] & mask ? 1 : 0; ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, bit); if (bit){ int xorbit; - int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y+1][x+1], &xorbit); - ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->flags[y+1][x+1] >> 15) ^ xorbit); - *nmsedec += getnmsedec_sig(t1->data[y][x], bpno + NMSEDEC_FRACBITS); - ff_jpeg2000_set_significance(t1, x, y, t1->flags[y+1][x+1] >> 15); + int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[(y+1) * t1->stride + x+1], &xorbit); + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->flags[(y+1) * t1->stride + x+1] >> 15) ^ xorbit); + *nmsedec += getnmsedec_sig(t1->data[(y) * t1->stride + x], bpno + NMSEDEC_FRACBITS); + ff_jpeg2000_set_significance(t1, x, y, t1->flags[(y+1) * t1->stride + x+1] >> 15); } - t1->flags[y+1][x+1] |= JPEG2000_T1_VIS; + t1->flags[(y+1) * t1->stride + x+1] |= JPEG2000_T1_VIS; } } } @@ -508,11 +534,11 @@ for (y0 = 0; y0 < height; y0 += 4) for (x = 0; x < width; x++) for (y = y0; y < height && y < y0+4; y++) - if ((t1->flags[y+1][x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS)) == JPEG2000_T1_SIG){ - int ctxno = ff_jpeg2000_getrefctxno(t1->flags[y+1][x+1]); - *nmsedec += getnmsedec_ref(t1->data[y][x], bpno + NMSEDEC_FRACBITS); - ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, t1->data[y][x] & mask ? 1:0); - t1->flags[y+1][x+1] |= JPEG2000_T1_REF; + if ((t1->flags[(y+1) * t1->stride + x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS)) == JPEG2000_T1_SIG){ + int ctxno = ff_jpeg2000_getrefctxno(t1->flags[(y+1) * t1->stride + x+1]); + *nmsedec += getnmsedec_ref(t1->data[(y) * t1->stride + x], bpno + NMSEDEC_FRACBITS); + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, t1->data[(y) * t1->stride + x] & mask ? 1:0); + t1->flags[(y+1) * t1->stride + x+1] |= JPEG2000_T1_REF; } } @@ -522,15 +548,15 @@ for (y0 = 0; y0 < height; y0 += 4) for (x = 0; x < width; x++){ if (y0 + 3 < height && !( - (t1->flags[y0+1][x+1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) || - (t1->flags[y0+2][x+1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) || - (t1->flags[y0+3][x+1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) || - (t1->flags[y0+4][x+1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)))) + (t1->flags[(y0+1) * t1->stride + x+1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) || + (t1->flags[(y0+2) * t1->stride + x+1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) || + (t1->flags[(y0+3) * t1->stride + x+1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) || + (t1->flags[(y0+4) * t1->stride + x+1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)))) { // aggregation mode int rlen; for (rlen = 0; rlen < 4; rlen++) - if (t1->data[y0+rlen][x] & mask) + if (t1->data[(y0+rlen) * t1->stride + x] & mask) break; ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + MQC_CX_RL, rlen != 4); if (rlen == 4) @@ -538,34 +564,34 @@ ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI, rlen >> 1); ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI, rlen & 1); for (y = y0 + rlen; y < y0 + 4; y++){ - if (!(t1->flags[y+1][x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))){ - int ctxno = ff_jpeg2000_getsigctxno(t1->flags[y+1][x+1], bandno); + if (!(t1->flags[(y+1) * t1->stride + x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))){ + int ctxno = ff_jpeg2000_getsigctxno(t1->flags[(y+1) * t1->stride + x+1], bandno); if (y > y0 + rlen) - ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, t1->data[y][x] & mask ? 1:0); - if (t1->data[y][x] & mask){ // newly significant + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, t1->data[(y) * t1->stride + x] & mask ? 1:0); + if (t1->data[(y) * t1->stride + x] & mask){ // newly significant int xorbit; - int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y+1][x+1], &xorbit); - *nmsedec += getnmsedec_sig(t1->data[y][x], bpno + NMSEDEC_FRACBITS); - ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->flags[y+1][x+1] >> 15) ^ xorbit); - ff_jpeg2000_set_significance(t1, x, y, t1->flags[y+1][x+1] >> 15); + int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[(y+1) * t1->stride + x+1], &xorbit); + *nmsedec += getnmsedec_sig(t1->data[(y) * t1->stride + x], bpno + NMSEDEC_FRACBITS); + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->flags[(y+1) * t1->stride + x+1] >> 15) ^ xorbit); + ff_jpeg2000_set_significance(t1, x, y, t1->flags[(y+1) * t1->stride + x+1] >> 15); } } - t1->flags[y+1][x+1] &= ~JPEG2000_T1_VIS; + t1->flags[(y+1) * t1->stride + x+1] &= ~JPEG2000_T1_VIS; } } else{ for (y = y0; y < y0 + 4 && y < height; y++){ - if (!(t1->flags[y+1][x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))){ - int ctxno = ff_jpeg2000_getsigctxno(t1->flags[y+1][x+1], bandno); - ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, t1->data[y][x] & mask ? 1:0); - if (t1->data[y][x] & mask){ // newly significant + if (!(t1->flags[(y+1) * t1->stride + x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))){ + int ctxno = ff_jpeg2000_getsigctxno(t1->flags[(y+1) * t1->stride + x+1], bandno); + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, t1->data[(y) * t1->stride + x] & mask ? 1:0); + if (t1->data[(y) * t1->stride + x] & mask){ // newly significant int xorbit; - int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y+1][x+1], &xorbit); - *nmsedec += getnmsedec_sig(t1->data[y][x], bpno + NMSEDEC_FRACBITS); - ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->flags[y+1][x+1] >> 15) ^ xorbit); - ff_jpeg2000_set_significance(t1, x, y, t1->flags[y+1][x+1] >> 15); + int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[(y+1) * t1->stride + x+1], &xorbit); + *nmsedec += getnmsedec_sig(t1->data[(y) * t1->stride + x], bpno + NMSEDEC_FRACBITS); + ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->flags[(y+1) * t1->stride + x+1] >> 15) ^ xorbit); + ff_jpeg2000_set_significance(t1, x, y, t1->flags[(y+1) * t1->stride + x+1] >> 15); } } - t1->flags[y+1][x+1] &= ~JPEG2000_T1_VIS; + t1->flags[(y+1) * t1->stride + x+1] &= ~JPEG2000_T1_VIS; } } } @@ -577,16 +603,15 @@ int pass_t = 2, passno, x, y, max=0, nmsedec, bpno; int64_t wmsedec = 0; - for (y = 0; y < height+2; y++) - memset(t1->flags[y], 0, (width+2)*sizeof(int)); + memset(t1->flags, 0, t1->stride * (height + 2) * sizeof(*t1->flags)); for (y = 0; y < height; y++){ for (x = 0; x < width; x++){ - if (t1->data[y][x] < 0){ - t1->flags[y+1][x+1] |= JPEG2000_T1_SGN; - t1->data[y][x] = -t1->data[y][x]; + if (t1->data[(y) * t1->stride + x] < 0){ + t1->flags[(y+1) * t1->stride + x+1] |= JPEG2000_T1_SGN; + t1->data[(y) * t1->stride + x] = -t1->data[(y) * t1->stride + x]; } - max = FFMAX(max, t1->data[y][x]); + max = FFMAX(max, t1->data[(y) * t1->stride + x]); } } @@ -612,7 +637,7 @@ break; } - cblk->passes[passno].rate = 3 + ff_mqc_length(&t1->mqc); + cblk->passes[passno].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno].flushed, &cblk->passes[passno].flushed_len); wmsedec += (int64_t)nmsedec << (2*bpno); cblk->passes[passno].disto = wmsedec; @@ -624,8 +649,7 @@ cblk->npasses = passno; cblk->ninclpasses = passno; - // TODO: optional flush on each pass - cblk->passes[passno-1].rate = ff_mqc_flush(&t1->mqc); + cblk->passes[passno-1].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno-1].flushed, &cblk->passes[passno-1].flushed_len); } /* tier-2 routines: */ @@ -732,7 +756,10 @@ if (cblk->ninclpasses){ if (s->buf_end - s->buf < cblk->passes[cblk->ninclpasses-1].rate) return -1; - bytestream_put_buffer(&s->buf, cblk->data, cblk->passes[cblk->ninclpasses-1].rate); + bytestream_put_buffer(&s->buf, cblk->data, cblk->passes[cblk->ninclpasses-1].rate + - cblk->passes[cblk->ninclpasses-1].flushed_len); + bytestream_put_buffer(&s->buf, cblk->passes[cblk->ninclpasses-1].flushed, + cblk->passes[cblk->ninclpasses-1].flushed_len); } } } @@ -818,6 +845,8 @@ for (compno = 0; compno < s->ncomponents; compno++){ Jpeg2000Component *comp = s->tile[tileno].comp + compno; + t1.stride = (1<log2_cblk_width) + 2; + av_log(s->avctx, AV_LOG_DEBUG,"dwt\n"); if ((ret = ff_dwt_encode(&comp->dwt, comp->i_data)) < 0) return ret; @@ -853,14 +882,14 @@ int y, x; if (codsty->transform == FF_DWT53){ for (y = yy0; y < yy1; y++){ - int *ptr = t1.data[y-yy0]; + int *ptr = t1.data + (y-yy0)*t1.stride; for (x = xx0; x < xx1; x++){ *ptr++ = comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] << NMSEDEC_FRACBITS; } } } else{ for (y = yy0; y < yy1; y++){ - int *ptr = t1.data[y-yy0]; + int *ptr = t1.data + (y-yy0)*t1.stride; for (x = xx0; x < xx1; x++){ *ptr = (comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) * y + x]); *ptr = (int64_t)*ptr * (int64_t)(16384 * 65536 / band->i_stepsize) >> 15 - NMSEDEC_FRACBITS; @@ -914,13 +943,19 @@ } } +static void update_size(uint8_t *size, const uint8_t *end) +{ + AV_WB32(size, end-size); +} + static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { int tileno, ret; Jpeg2000EncoderContext *s = avctx->priv_data; + uint8_t *chunkstart, *jp2cstart, *jp2hstart; - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width*avctx->height*9 + FF_MIN_BUFFER_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width*avctx->height*9 + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return ret; // init: @@ -934,6 +969,58 @@ copy_frame(s); reinit(s); + if (s->format == CODEC_JP2) { + av_assert0(s->buf == pkt->data); + + bytestream_put_be32(&s->buf, 0x0000000C); + bytestream_put_be32(&s->buf, 0x6A502020); + bytestream_put_be32(&s->buf, 0x0D0A870A); + + chunkstart = s->buf; + bytestream_put_be32(&s->buf, 0); + bytestream_put_buffer(&s->buf, "ftyp", 4); + bytestream_put_buffer(&s->buf, "jp2\040\040", 4); + bytestream_put_be32(&s->buf, 0); + bytestream_put_buffer(&s->buf, "jp2\040", 4); + update_size(chunkstart, s->buf); + + jp2hstart = s->buf; + bytestream_put_be32(&s->buf, 0); + bytestream_put_buffer(&s->buf, "jp2h", 4); + + chunkstart = s->buf; + bytestream_put_be32(&s->buf, 0); + bytestream_put_buffer(&s->buf, "ihdr", 4); + bytestream_put_be32(&s->buf, avctx->height); + bytestream_put_be32(&s->buf, avctx->width); + bytestream_put_be16(&s->buf, s->ncomponents); + bytestream_put_byte(&s->buf, s->cbps[0]); + bytestream_put_byte(&s->buf, 7); + bytestream_put_byte(&s->buf, 0); + bytestream_put_byte(&s->buf, 0); + update_size(chunkstart, s->buf); + + chunkstart = s->buf; + bytestream_put_be32(&s->buf, 0); + bytestream_put_buffer(&s->buf, "colr", 4); + bytestream_put_byte(&s->buf, 1); + bytestream_put_byte(&s->buf, 0); + bytestream_put_byte(&s->buf, 0); + if (s->ncomponents == 1) { + bytestream_put_be32(&s->buf, 17); + } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) { + bytestream_put_be32(&s->buf, 16); + } else { + bytestream_put_be32(&s->buf, 18); + } + update_size(chunkstart, s->buf); + update_size(jp2hstart, s->buf); + + jp2cstart = s->buf; + bytestream_put_be32(&s->buf, 0); + bytestream_put_buffer(&s->buf, "jp2c", 4); + } + if (s->buf_end - s->buf < 2) return -1; bytestream_put_be16(&s->buf, JPEG2000_SOC); @@ -943,6 +1030,8 @@ return ret; if ((ret = put_qcd(s, 0)) < 0) return ret; + if ((ret = put_com(s, 0)) < 0) + return ret; for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ uint8_t *psotptr; @@ -959,6 +1048,9 @@ return -1; bytestream_put_be16(&s->buf, JPEG2000_EOC); + if (s->format == CODEC_JP2) + update_size(jp2cstart, s->buf); + av_log(s->avctx, AV_LOG_DEBUG, "end\n"); pkt->size = s->buf - s->buf_start; pkt->flags |= AV_PKT_FLAG_KEY; @@ -989,8 +1081,10 @@ qntsty->nguardbits = 1; - s->tile_width = 256; - s->tile_height = 256; + if ((s->tile_width & (s->tile_width -1)) || + (s->tile_height & (s->tile_height-1))) { + av_log(avctx, AV_LOG_WARNING, "Tile dimension not a power of 2\n"); + } if (codsty->transform == FF_DWT53) qntsty->quantsty = JPEG2000_QSTY_NONE; @@ -1035,6 +1129,27 @@ return 0; } +// taken from the libopenjpeg wraper so it matches + +#define OFFSET(x) offsetof(Jpeg2000EncoderContext, x) +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "format", "Codec Format", OFFSET(format), AV_OPT_TYPE_INT, { .i64 = CODEC_JP2 }, CODEC_J2K, CODEC_JP2, VE, "format" }, + { "j2k", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CODEC_J2K }, 0, 0, VE, "format" }, + { "jp2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CODEC_JP2 }, 0, 0, VE, "format" }, + { "tile_width", "Tile Width", OFFSET(tile_width), AV_OPT_TYPE_INT, { .i64 = 256 }, 1, 1<<30, VE, }, + { "tile_height", "Tile Height", OFFSET(tile_height), AV_OPT_TYPE_INT, { .i64 = 256 }, 1, 1<<30, VE, }, + + { NULL } +}; + +static const AVClass j2k_class = { + .class_name = "jpeg 2000 encoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_jpeg2000_encoder = { .name = "jpeg2000", .long_name = NULL_IF_CONFIG_SMALL("JPEG 2000"), @@ -1044,12 +1159,12 @@ .init = j2kenc_init, .encode2 = encode_frame, .close = j2kenc_destroy, - .capabilities = CODEC_CAP_EXPERIMENTAL, + .capabilities = AV_CODEC_CAP_EXPERIMENTAL, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_YUV444P, AV_PIX_FMT_GRAY8, -/* AV_PIX_FMT_YUV420P, - AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, - AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,*/ + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, + AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_NONE - } + }, + .priv_class = &j2k_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000.c 2015-07-28 17:20:07.000000000 +0000 @@ -171,22 +171,22 @@ { x++; y++; - t1->flags[y][x] |= JPEG2000_T1_SIG; + t1->flags[(y) * t1->stride + x] |= JPEG2000_T1_SIG; if (negative) { - t1->flags[y][x + 1] |= JPEG2000_T1_SIG_W | JPEG2000_T1_SGN_W; - t1->flags[y][x - 1] |= JPEG2000_T1_SIG_E | JPEG2000_T1_SGN_E; - t1->flags[y + 1][x] |= JPEG2000_T1_SIG_N | JPEG2000_T1_SGN_N; - t1->flags[y - 1][x] |= JPEG2000_T1_SIG_S | JPEG2000_T1_SGN_S; + t1->flags[(y) * t1->stride + x + 1] |= JPEG2000_T1_SIG_W | JPEG2000_T1_SGN_W; + t1->flags[(y) * t1->stride + x - 1] |= JPEG2000_T1_SIG_E | JPEG2000_T1_SGN_E; + t1->flags[(y + 1) * t1->stride + x] |= JPEG2000_T1_SIG_N | JPEG2000_T1_SGN_N; + t1->flags[(y - 1) * t1->stride + x] |= JPEG2000_T1_SIG_S | JPEG2000_T1_SGN_S; } else { - t1->flags[y][x + 1] |= JPEG2000_T1_SIG_W; - t1->flags[y][x - 1] |= JPEG2000_T1_SIG_E; - t1->flags[y + 1][x] |= JPEG2000_T1_SIG_N; - t1->flags[y - 1][x] |= JPEG2000_T1_SIG_S; + t1->flags[(y) * t1->stride + x + 1] |= JPEG2000_T1_SIG_W; + t1->flags[(y) * t1->stride + x - 1] |= JPEG2000_T1_SIG_E; + t1->flags[(y + 1) * t1->stride + x] |= JPEG2000_T1_SIG_N; + t1->flags[(y - 1) * t1->stride + x] |= JPEG2000_T1_SIG_S; } - t1->flags[y + 1][x + 1] |= JPEG2000_T1_SIG_NW; - t1->flags[y + 1][x - 1] |= JPEG2000_T1_SIG_NE; - t1->flags[y - 1][x + 1] |= JPEG2000_T1_SIG_SW; - t1->flags[y - 1][x - 1] |= JPEG2000_T1_SIG_SE; + t1->flags[(y + 1) * t1->stride + x + 1] |= JPEG2000_T1_SIG_NW; + t1->flags[(y + 1) * t1->stride + x - 1] |= JPEG2000_T1_SIG_NE; + t1->flags[(y - 1) * t1->stride + x + 1] |= JPEG2000_T1_SIG_SW; + t1->flags[(y - 1) * t1->stride + x - 1] |= JPEG2000_T1_SIG_SE; } static const uint8_t lut_gain[2][4] = { { 0, 0, 0, 0 }, { 0, 1, 1, 2 } }; @@ -215,11 +215,13 @@ (comp->coord[1][1] - comp->coord[1][0]); if (codsty->transform == FF_DWT97) { + csize += AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*comp->f_data); comp->i_data = NULL; comp->f_data = av_mallocz_array(csize, sizeof(*comp->f_data)); if (!comp->f_data) return AVERROR(ENOMEM); } else { + csize += AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*comp->i_data); comp->f_data = NULL; comp->i_data = av_mallocz_array(csize, sizeof(*comp->i_data)); if (!comp->i_data) @@ -303,9 +305,6 @@ * delta_b = 2 ^ (R_b - expn_b) * (1 + (mant_b / 2 ^ 11)) * R_b = R_I + log2 (gain_b ) * see ISO/IEC 15444-1:2002 E.1.1 eqn. E-3 and E-4 */ - /* TODO/WARN: value of log2 (gain_b ) not taken into account - * but it works (compared to OpenJPEG). Why? - * Further investigation needed. */ gain = cbps; band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]); band->f_stepsize *= qntsty->mant[gbandno] / 2048.0 + 1.0; @@ -315,13 +314,30 @@ av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n"); break; } + if (codsty->transform != FF_DWT53) { + int lband = 0; + switch (bandno + (reslevelno > 0)) { + case 1: + case 2: + band->f_stepsize *= F_LFTG_X * 2; + lband = 1; + break; + case 3: + band->f_stepsize *= F_LFTG_X * F_LFTG_X * 4; + break; + } + if (codsty->transform == FF_DWT97) { + band->f_stepsize *= pow(F_LFTG_K, 2*(codsty->nreslevels2decode - reslevelno) + lband - 2); + } + } + + band->i_stepsize = band->f_stepsize * (1 << 15); + /* FIXME: In openjepg code stespize = stepsize * 0.5. Why? * If not set output of entropic decoder is not correct. */ if (!av_codec_is_encoder(avctx->codec)) band->f_stepsize *= 0.5; - band->i_stepsize = band->f_stepsize * (1 << 15); - /* computation of tbx_0, tbx_1, tby_0, tby_1 * see ISO/IEC 15444-1:2002 B.5 eq. B-15 and tbl B.1 * codeblock width and height is computed for @@ -331,7 +347,7 @@ for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) band->coord[i][j] = - ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0], + ff_jpeg2000_ceildivpow2(comp->coord_o[i][j], declvl - 1); log2_band_prec_width = reslevel->log2_prec_width; log2_band_prec_height = reslevel->log2_prec_height; @@ -347,8 +363,8 @@ for (j = 0; j < 2; j++) /* Formula example for tbx_0 = ceildiv((tcx_0 - 2 ^ (declvl - 1) * x0_b) / declvl) */ band->coord[i][j] = - ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0] - - (((bandno + 1 >> i) & 1) << declvl - 1), + ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - + (((bandno + 1 >> i) & 1LL) << declvl - 1), declvl); /* TODO: Manage case of 3 band offsets here or * in coding/decoding function? */ @@ -376,37 +392,40 @@ Jpeg2000Prec *prec = band->prec + precno; int nb_codeblocks; + prec->decoded_layers = 0; + /* TODO: Explain formula for JPEG200 DCINEMA. */ /* TODO: Verify with previous count of codeblocks per band */ /* Compute P_x0 */ - prec->coord[0][0] = (precno % reslevel->num_precincts_x) * + prec->coord[0][0] = ((band->coord[0][0] >> log2_band_prec_width) + precno % reslevel->num_precincts_x) * (1 << log2_band_prec_width); - prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]); /* Compute P_y0 */ - prec->coord[1][0] = (precno / reslevel->num_precincts_x) * + prec->coord[1][0] = ((band->coord[1][0] >> log2_band_prec_height) + precno / reslevel->num_precincts_x) * (1 << log2_band_prec_height); - prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]); /* Compute P_x1 */ prec->coord[0][1] = prec->coord[0][0] + (1 << log2_band_prec_width); + prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]); prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]); /* Compute P_y1 */ prec->coord[1][1] = prec->coord[1][0] + (1 << log2_band_prec_height); + prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]); prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]); prec->nb_codeblocks_width = - ff_jpeg2000_ceildivpow2(prec->coord[0][1] - - prec->coord[0][0], - band->log2_cblk_width); + ff_jpeg2000_ceildivpow2(prec->coord[0][1], + band->log2_cblk_width) + - (prec->coord[0][0] >> band->log2_cblk_width); prec->nb_codeblocks_height = - ff_jpeg2000_ceildivpow2(prec->coord[1][1] - - prec->coord[1][0], - band->log2_cblk_height); + ff_jpeg2000_ceildivpow2(prec->coord[1][1], + band->log2_cblk_height) + - (prec->coord[1][0] >> band->log2_cblk_height); + /* Tag trees initialization */ prec->cblkincl = @@ -435,12 +454,12 @@ /* Compute coordinates of codeblocks */ /* Compute Cx0*/ - Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width; + Cx0 = ((prec->coord[0][0]) >> band->log2_cblk_width) << band->log2_cblk_width; Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width); cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]); /* Compute Cy0*/ - Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height; + Cy0 = ((prec->coord[1][0]) >> band->log2_cblk_height) << band->log2_cblk_height; Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height); cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]); @@ -468,7 +487,7 @@ cblk->zero = 0; cblk->lblock = 3; cblk->length = 0; - cblk->lengthinc = 0; + memset(cblk->lengthinc, 0, sizeof(cblk->lengthinc)); cblk->npasses = 0; } } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000dec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -47,6 +47,23 @@ #define HAD_COC 0x01 #define HAD_QCC 0x02 +#define MAX_POCS 32 + +typedef struct Jpeg2000POCEntry { + uint16_t LYEpoc; + uint16_t CSpoc; + uint16_t CEpoc; + uint8_t RSpoc; + uint8_t REpoc; + uint8_t Ppoc; +} Jpeg2000POCEntry; + +typedef struct Jpeg2000POC { + Jpeg2000POCEntry poc[MAX_POCS]; + int nb_poc; + int is_default; +} Jpeg2000POC; + typedef struct Jpeg2000TilePart { uint8_t tile_index; // Tile index who refers the tile-part const uint8_t *tp_end; @@ -60,8 +77,10 @@ uint8_t properties[4]; Jpeg2000CodingStyle codsty[4]; Jpeg2000QuantStyle qntsty[4]; - Jpeg2000TilePart tile_part[4]; + Jpeg2000POC poc; + Jpeg2000TilePart tile_part[256]; uint16_t tp_idx; // Tile-part index + int coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}} } Jpeg2000Tile; typedef struct Jpeg2000DecoderContext { @@ -88,6 +107,7 @@ Jpeg2000CodingStyle codsty[4]; Jpeg2000QuantStyle qntsty[4]; + Jpeg2000POC poc; int bit_index; @@ -133,8 +153,10 @@ Jpeg2000TgtNode *stack[30]; int sp = -1, curval = 0; - if (!node) + if (!node) { + av_log(s->avctx, AV_LOG_ERROR, "missing node\n"); return AVERROR_INVALIDDATA; + } while (node && !node->vis) { stack[++sp] = node; @@ -171,6 +193,8 @@ int match = 1; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); + av_assert2(desc); + if (desc->nb_components != components) { return 0; } @@ -218,7 +242,8 @@ static const enum AVPixelFormat rgb_pix_fmts[] = {RGB_PIXEL_FORMATS}; static const enum AVPixelFormat gray_pix_fmts[] = {GRAY_PIXEL_FORMATS}; static const enum AVPixelFormat yuv_pix_fmts[] = {YUV_PIXEL_FORMATS}; -static const enum AVPixelFormat xyz_pix_fmts[] = {XYZ_PIXEL_FORMATS}; +static const enum AVPixelFormat xyz_pix_fmts[] = {XYZ_PIXEL_FORMATS, + YUV_PIXEL_FORMATS}; static const enum AVPixelFormat all_pix_fmts[] = {RGB_PIXEL_FORMATS, GRAY_PIXEL_FORMATS, YUV_PIXEL_FORMATS, @@ -234,8 +259,10 @@ const enum AVPixelFormat *possible_fmts = NULL; int possible_fmts_nb = 0; - if (bytestream2_get_bytes_left(&s->g) < 36) + if (bytestream2_get_bytes_left(&s->g) < 36) { + av_log(s->avctx, AV_LOG_ERROR, "Insufficient space for SIZ\n"); return AVERROR_INVALIDDATA; + } s->avctx->profile = bytestream2_get_be16u(&s->g); // Rsiz s->width = bytestream2_get_be32u(&s->g); // Width @@ -261,7 +288,7 @@ if (ncomponents > 4) { avpriv_request_sample(s->avctx, "Support for %d components", - s->ncomponents); + ncomponents); return AVERROR_PATCHWELCOME; } @@ -273,8 +300,10 @@ return AVERROR_INVALIDDATA; } - if (bytestream2_get_bytes_left(&s->g) < 3 * s->ncomponents) + if (bytestream2_get_bytes_left(&s->g) < 3 * s->ncomponents) { + av_log(s->avctx, AV_LOG_ERROR, "Insufficient space for %d components in SIZ\n", s->ncomponents); return AVERROR_INVALIDDATA; + } for (i = 0; i < s->ncomponents; i++) { // Ssiz_i XRsiz_i, YRsiz_i uint8_t x = bytestream2_get_byteu(&s->g); @@ -349,16 +378,41 @@ break; } } + + if (i == possible_fmts_nb) { + if (ncomponents == 4 && + s->cdy[0] == 1 && s->cdx[0] == 1 && + s->cdy[1] == 1 && s->cdx[1] == 1 && + s->cdy[2] == s->cdy[3] && s->cdx[2] == s->cdx[3]) { + if (s->precision == 8 && s->cdy[2] == 2 && s->cdx[2] == 2 && !s->pal8) { + s->avctx->pix_fmt = AV_PIX_FMT_YUVA420P; + s->cdef[0] = 0; + s->cdef[1] = 1; + s->cdef[2] = 2; + s->cdef[3] = 3; + i = 0; + } + } + } + + if (i == possible_fmts_nb) { av_log(s->avctx, AV_LOG_ERROR, "Unknown pix_fmt, profile: %d, colour_space: %d, " - "components: %d, precision: %d, " - "cdx[1]: %d, cdy[1]: %d, cdx[2]: %d, cdy[2]: %d\n", + "components: %d, precision: %d\n" + "cdx[0]: %d, cdy[0]: %d\n" + "cdx[1]: %d, cdy[1]: %d\n" + "cdx[2]: %d, cdy[2]: %d\n" + "cdx[3]: %d, cdy[3]: %d\n", s->avctx->profile, s->colour_space, ncomponents, s->precision, - ncomponents > 2 ? s->cdx[1] : 0, - ncomponents > 2 ? s->cdy[1] : 0, + s->cdx[0], + s->cdy[0], + ncomponents > 1 ? s->cdx[1] : 0, + ncomponents > 1 ? s->cdy[1] : 0, ncomponents > 2 ? s->cdx[2] : 0, - ncomponents > 2 ? s->cdy[2] : 0); + ncomponents > 2 ? s->cdy[2] : 0, + ncomponents > 3 ? s->cdx[3] : 0, + ncomponents > 3 ? s->cdy[3] : 0); return AVERROR_PATCHWELCOME; } s->avctx->bits_per_raw_sample = s->precision; @@ -370,8 +424,10 @@ { uint8_t byte; - if (bytestream2_get_bytes_left(&s->g) < 5) + if (bytestream2_get_bytes_left(&s->g) < 5) { + av_log(s->avctx, AV_LOG_ERROR, "Insufficient space for COX\n"); return AVERROR_INVALIDDATA; + } /* nreslevels = number of resolution levels = number of decomposition level +1 */ @@ -403,19 +459,19 @@ return AVERROR_INVALIDDATA; } - if (c->log2_cblk_width > 6 || c->log2_cblk_height > 6) { - avpriv_request_sample(s->avctx, "cblk size > 64"); - return AVERROR_PATCHWELCOME; - } - c->cblk_style = bytestream2_get_byteu(&s->g); if (c->cblk_style != 0) { // cblk style av_log(s->avctx, AV_LOG_WARNING, "extra cblk styles %X\n", c->cblk_style); + if (c->cblk_style & JPEG2000_CBLK_BYPASS) + av_log(s->avctx, AV_LOG_WARNING, "Selective arithmetic coding bypass\n"); } c->transform = bytestream2_get_byteu(&s->g); // DWT transformation type /* set integer 9/7 DWT in case of BITEXACT flag */ - if ((s->avctx->flags & CODEC_FLAG_BITEXACT) && (c->transform == FF_DWT97)) + if ((s->avctx->flags & AV_CODEC_FLAG_BITEXACT) && (c->transform == FF_DWT97)) c->transform = FF_DWT97_INT; + else if (c->transform == FF_DWT53) { + s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS; + } if (c->csty & JPEG2000_CSTY_PREC) { int i; @@ -423,6 +479,13 @@ byte = bytestream2_get_byte(&s->g); c->log2_prec_widths[i] = byte & 0x0F; // precinct PPx c->log2_prec_heights[i] = (byte >> 4) & 0x0F; // precinct PPy + if (i) + if (c->log2_prec_widths[i] == 0 || c->log2_prec_heights[i] == 0) { + av_log(s->avctx, AV_LOG_ERROR, "PPx %d PPy %d invalid\n", + c->log2_prec_widths[i], c->log2_prec_heights[i]); + c->log2_prec_widths[i] = c->log2_prec_heights[i] = 1; + return AVERROR_INVALIDDATA; + } } } else { memset(c->log2_prec_widths , 15, sizeof(c->log2_prec_widths )); @@ -438,8 +501,10 @@ Jpeg2000CodingStyle tmp; int compno, ret; - if (bytestream2_get_bytes_left(&s->g) < 5) + if (bytestream2_get_bytes_left(&s->g) < 5) { + av_log(s->avctx, AV_LOG_ERROR, "Insufficient space for COD\n"); return AVERROR_INVALIDDATA; + } tmp.csty = bytestream2_get_byteu(&s->g); @@ -472,8 +537,10 @@ { int compno, ret; - if (bytestream2_get_bytes_left(&s->g) < 2) + if (bytestream2_get_bytes_left(&s->g) < 2) { + av_log(s->avctx, AV_LOG_ERROR, "Insufficient space for COC\n"); return AVERROR_INVALIDDATA; + } compno = bytestream2_get_byteu(&s->g); @@ -579,13 +646,74 @@ return get_qcx(s, n - 1, q + compno); } +static int get_poc(Jpeg2000DecoderContext *s, int size, Jpeg2000POC *p) +{ + int i; + int elem_size = s->ncomponents <= 257 ? 7 : 9; + Jpeg2000POC tmp = {{{0}}}; + + if (bytestream2_get_bytes_left(&s->g) < 5 || size < 2 + elem_size) { + av_log(s->avctx, AV_LOG_ERROR, "Insufficient space for POC\n"); + return AVERROR_INVALIDDATA; + } + + if (elem_size > 7) { + avpriv_request_sample(s->avctx, "Fat POC not supported\n"); + return AVERROR_PATCHWELCOME; + } + + tmp.nb_poc = (size - 2) / elem_size; + if (tmp.nb_poc > MAX_POCS) { + avpriv_request_sample(s->avctx, "Too many POCs (%d)\n", tmp.nb_poc); + return AVERROR_PATCHWELCOME; + } + + for (i = 0; iRSpoc = bytestream2_get_byteu(&s->g); + e->CSpoc = bytestream2_get_byteu(&s->g); + e->LYEpoc = bytestream2_get_be16u(&s->g); + e->REpoc = bytestream2_get_byteu(&s->g); + e->CEpoc = bytestream2_get_byteu(&s->g); + e->Ppoc = bytestream2_get_byteu(&s->g); + if (!e->CEpoc) + e->CEpoc = 256; + if (e->CEpoc > s->ncomponents) + e->CEpoc = s->ncomponents; + if ( e->RSpoc >= e->REpoc || e->REpoc > 33 + || e->CSpoc >= e->CEpoc || e->CEpoc > s->ncomponents + || !e->LYEpoc) { + av_log(s->avctx, AV_LOG_ERROR, "POC Entry %d is invalid (%d, %d, %d, %d, %d, %d)\n", i, + e->RSpoc, e->CSpoc, e->LYEpoc, e->REpoc, e->CEpoc, e->Ppoc + ); + return AVERROR_INVALIDDATA; + } + } + + if (!p->nb_poc || p->is_default) { + *p = tmp; + } else { + if (p->nb_poc + tmp.nb_poc > MAX_POCS) { + av_log(s->avctx, AV_LOG_ERROR, "Insufficient space for POC\n"); + return AVERROR_INVALIDDATA; + } + memcpy(p->poc + p->nb_poc, tmp.poc, tmp.nb_poc * sizeof(tmp.poc[0])); + p->nb_poc += tmp.nb_poc; + } + + p->is_default = 0; + + return 0; +} + + /* Get start of tile segment. */ static int get_sot(Jpeg2000DecoderContext *s, int n) { Jpeg2000TilePart *tp; uint16_t Isot; uint32_t Psot; - uint8_t TPsot; + unsigned TPsot; if (bytestream2_get_bytes_left(&s->g) < 8) return AVERROR_INVALIDDATA; @@ -610,10 +738,7 @@ return AVERROR_INVALIDDATA; } - if (TPsot >= FF_ARRAY_ELEMS(s->tile[Isot].tile_part)) { - avpriv_request_sample(s->avctx, "Support for %"PRIu8" components", TPsot); - return AVERROR_PATCHWELCOME; - } + av_assert0(TPsot < FF_ARRAY_ELEMS(s->tile[Isot].tile_part)); s->tile[Isot].tp_idx = TPsot; tp = s->tile[Isot].tile_part + TPsot; @@ -626,6 +751,8 @@ /* copy defaults */ memcpy(tile->codsty, s->codsty, s->ncomponents * sizeof(Jpeg2000CodingStyle)); memcpy(tile->qntsty, s->qntsty, s->ncomponents * sizeof(Jpeg2000QuantStyle)); + memcpy(&tile->poc , &s->poc , sizeof(tile->poc)); + tile->poc.is_default = 1; } return 0; @@ -677,7 +804,7 @@ { int i; - av_log(s->avctx, AV_LOG_ERROR, + av_log(s->avctx, AV_LOG_DEBUG, "PLT marker at pos 0x%X\n", bytestream2_tell(&s->g) - 4); /*Zplt =*/ bytestream2_get_byte(&s->g); @@ -699,16 +826,21 @@ if (!tile->comp) return AVERROR(ENOMEM); + tile->coord[0][0] = FFMAX(tilex * s->tile_width + s->tile_offset_x, s->image_offset_x); + tile->coord[0][1] = FFMIN((tilex + 1) * s->tile_width + s->tile_offset_x, s->width); + tile->coord[1][0] = FFMAX(tiley * s->tile_height + s->tile_offset_y, s->image_offset_y); + tile->coord[1][1] = FFMIN((tiley + 1) * s->tile_height + s->tile_offset_y, s->height); + for (compno = 0; compno < s->ncomponents; compno++) { Jpeg2000Component *comp = tile->comp + compno; Jpeg2000CodingStyle *codsty = tile->codsty + compno; Jpeg2000QuantStyle *qntsty = tile->qntsty + compno; int ret; // global bandno - comp->coord_o[0][0] = FFMAX(tilex * s->tile_width + s->tile_offset_x, s->image_offset_x); - comp->coord_o[0][1] = FFMIN((tilex + 1) * s->tile_width + s->tile_offset_x, s->width); - comp->coord_o[1][0] = FFMAX(tiley * s->tile_height + s->tile_offset_y, s->image_offset_y); - comp->coord_o[1][1] = FFMIN((tiley + 1) * s->tile_height + s->tile_offset_y, s->height); + comp->coord_o[0][0] = tile->coord[0][0]; + comp->coord_o[0][1] = tile->coord[0][1]; + comp->coord_o[1][0] = tile->coord[1][0]; + comp->coord_o[1][1] = tile->coord[1][1]; if (compno) { comp->coord_o[0][0] /= s->cdx[compno]; comp->coord_o[0][1] /= s->cdx[compno]; @@ -756,12 +888,26 @@ return res; } -static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, +static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, int *tp_index, Jpeg2000CodingStyle *codsty, Jpeg2000ResLevel *rlevel, int precno, int layno, uint8_t *expn, int numgbits) { int bandno, cblkno, ret, nb_code_blocks; + int cwsno; + + if (layno < rlevel->band[0].prec[precno].decoded_layers) + return 0; + rlevel->band[0].prec[precno].decoded_layers = layno + 1; + + if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) { + if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) { + s->g = tile->tile_part[++(*tp_index)].tpg; + } + } + + if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES) + bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH); if (!(ret = get_bits(s, 1))) { jpeg2000_flush(s); @@ -803,19 +949,46 @@ } if ((newpasses = getnpasses(s)) < 0) return newpasses; + av_assert2(newpasses > 0); + if (cblk->npasses + newpasses >= JPEG2000_MAX_PASSES) { + avpriv_request_sample(s->avctx, "Too many passes\n"); + return AVERROR_PATCHWELCOME; + } if ((llen = getlblockinc(s)) < 0) return llen; - cblk->lblock += llen; - if ((ret = get_bits(s, av_log2(newpasses) + cblk->lblock)) < 0) - return ret; - if (ret > sizeof(cblk->data)) { + if (cblk->lblock + llen + av_log2(newpasses) > 16) { avpriv_request_sample(s->avctx, - "Block with lengthinc greater than %"SIZE_SPECIFIER"", - sizeof(cblk->data)); + "Block with length beyond 16 bits\n"); return AVERROR_PATCHWELCOME; } - cblk->lengthinc = ret; - cblk->npasses += newpasses; + + cblk->lblock += llen; + + cblk->nb_lengthinc = 0; + cblk->nb_terminationsinc = 0; + do { + int newpasses1 = 0; + + while (newpasses1 < newpasses) { + newpasses1 ++; + if (needs_termination(codsty->cblk_style, cblk->npasses + newpasses1 - 1)) { + cblk->nb_terminationsinc ++; + break; + } + } + + if ((ret = get_bits(s, av_log2(newpasses1) + cblk->lblock)) < 0) + return ret; + if (ret > sizeof(cblk->data)) { + avpriv_request_sample(s->avctx, + "Block with lengthinc greater than %"SIZE_SPECIFIER"", + sizeof(cblk->data)); + return AVERROR_PATCHWELCOME; + } + cblk->lengthinc[cblk->nb_lengthinc++] = ret; + cblk->npasses += newpasses1; + newpasses -= newpasses1; + } while(newpasses); } } jpeg2000_flush(s); @@ -824,7 +997,7 @@ if (bytestream2_peek_be16(&s->g) == JPEG2000_EPH) bytestream2_skip(&s->g, 2); else - av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found.\n"); + av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found. instead %X\n", bytestream2_peek_be32(&s->g)); } for (bandno = 0; bandno < rlevel->nbands; bandno++) { @@ -834,40 +1007,76 @@ nb_code_blocks = prec->nb_codeblocks_height * prec->nb_codeblocks_width; for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) { Jpeg2000Cblk *cblk = prec->cblk + cblkno; - if ( bytestream2_get_bytes_left(&s->g) < cblk->lengthinc - || sizeof(cblk->data) < cblk->length + cblk->lengthinc + 2 - ) { - av_log(s->avctx, AV_LOG_ERROR, - "Block length %"PRIu16" or lengthinc %d is too large\n", - cblk->length, cblk->lengthinc); - return AVERROR_INVALIDDATA; - } + for (cwsno = 0; cwsno < cblk->nb_lengthinc; cwsno ++) { + if ( bytestream2_get_bytes_left(&s->g) < cblk->lengthinc[cwsno] + || sizeof(cblk->data) < cblk->length + cblk->lengthinc[cwsno] + 4 + ) { + av_log(s->avctx, AV_LOG_ERROR, + "Block length %"PRIu16" or lengthinc %d is too large, left %d\n", + cblk->length, cblk->lengthinc[cwsno], bytestream2_get_bytes_left(&s->g)); + return AVERROR_INVALIDDATA; + } - bytestream2_get_bufferu(&s->g, cblk->data + cblk->length, cblk->lengthinc); - cblk->length += cblk->lengthinc; - cblk->lengthinc = 0; + bytestream2_get_bufferu(&s->g, cblk->data + cblk->length, cblk->lengthinc[cwsno]); + cblk->length += cblk->lengthinc[cwsno]; + cblk->lengthinc[cwsno] = 0; + if (cblk->nb_terminationsinc) { + cblk->nb_terminationsinc--; + cblk->nb_terminations++; + cblk->data[cblk->length++] = 0xFF; + cblk->data[cblk->length++] = 0xFF; + cblk->data_start[cblk->nb_terminations] = cblk->length; + } + } } } return 0; } -static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile) +static int jpeg2000_decode_packets_po_iteration(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, + int RSpoc, int CSpoc, + int LYEpoc, int REpoc, int CEpoc, + int Ppoc, int *tp_index) { int ret = 0; int layno, reslevelno, compno, precno, ok_reslevel; int x, y; + int step_x, step_y; - s->bit_index = 8; - switch (tile->codsty[0].prog_order) { + switch (Ppoc) { case JPEG2000_PGOD_RLCP: - avpriv_request_sample(s->avctx, "Progression order RLCP"); + av_log(s->avctx, AV_LOG_DEBUG, "Progression order RLCP\n"); + ok_reslevel = 1; + for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) { + ok_reslevel = 0; + for (layno = 0; layno < LYEpoc; layno++) { + for (compno = CSpoc; compno < CEpoc; compno++) { + Jpeg2000CodingStyle *codsty = tile->codsty + compno; + Jpeg2000QuantStyle *qntsty = tile->qntsty + compno; + if (reslevelno < codsty->nreslevels) { + Jpeg2000ResLevel *rlevel = tile->comp[compno].reslevel + + reslevelno; + ok_reslevel = 1; + for (precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++) + if ((ret = jpeg2000_decode_packet(s, tile, tp_index, + codsty, rlevel, + precno, layno, + qntsty->expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0), + qntsty->nguardbits)) < 0) + return ret; + } + } + } + } + break; case JPEG2000_PGOD_LRCP: - for (layno = 0; layno < tile->codsty[0].nlayers; layno++) { + av_log(s->avctx, AV_LOG_DEBUG, "Progression order LRCP\n"); + for (layno = 0; layno < LYEpoc; layno++) { ok_reslevel = 1; - for (reslevelno = 0; ok_reslevel; reslevelno++) { + for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) { ok_reslevel = 0; - for (compno = 0; compno < s->ncomponents; compno++) { + for (compno = CSpoc; compno < CEpoc; compno++) { Jpeg2000CodingStyle *codsty = tile->codsty + compno; Jpeg2000QuantStyle *qntsty = tile->qntsty + compno; if (reslevelno < codsty->nreslevels) { @@ -875,7 +1084,7 @@ reslevelno; ok_reslevel = 1; for (precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++) - if ((ret = jpeg2000_decode_packet(s, + if ((ret = jpeg2000_decode_packet(s, tile, tp_index, codsty, rlevel, precno, layno, qntsty->expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0), @@ -888,46 +1097,54 @@ break; case JPEG2000_PGOD_CPRL: - for (compno = 0; compno < s->ncomponents; compno++) { + av_log(s->avctx, AV_LOG_DEBUG, "Progression order CPRL\n"); + for (compno = CSpoc; compno < CEpoc; compno++) { + Jpeg2000Component *comp = tile->comp + compno; Jpeg2000CodingStyle *codsty = tile->codsty + compno; Jpeg2000QuantStyle *qntsty = tile->qntsty + compno; + step_x = 32; + step_y = 32; - /* Set bit stream buffer address according to tile-part. - * For DCinema one tile-part per component, so can be - * indexed by component. */ - s->g = tile->tile_part[compno].tpg; - - /* Position loop (y axis) - * TODO: Automate computing of step 256. - * Fixed here, but to be computed before entering here. */ - for (y = 0; y < s->height; y += 256) { - /* Position loop (y axis) - * TODO: automate computing of step 256. - * Fixed here, but to be computed before entering here. */ - for (x = 0; x < s->width; x += 256) { - for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) { - uint16_t prcx, prcy; + for (reslevelno = RSpoc; reslevelno < FFMIN(codsty->nreslevels, REpoc); reslevelno++) { + uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; // ==> N_L - r + Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno; + step_x = FFMIN(step_x, rlevel->log2_prec_width + reducedresno); + step_y = FFMIN(step_y, rlevel->log2_prec_height + reducedresno); + } + step_x = 1<coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) { + for (x = tile->coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) { + for (reslevelno = RSpoc; reslevelno < FFMIN(codsty->nreslevels, REpoc); reslevelno++) { + unsigned prcx, prcy; uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; // ==> N_L - r - Jpeg2000ResLevel *rlevel = tile->comp[compno].reslevel + reslevelno; + Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno; + int xc = x / s->cdx[compno]; + int yc = y / s->cdy[compno]; - if (!((y % (1 << (rlevel->log2_prec_height + reducedresno)) == 0) || - (y == 0))) // TODO: 2nd condition simplified as try0 always =0 for dcinema + if (yc % (1 << (rlevel->log2_prec_height + reducedresno)) && y != tile->coord[1][0]) //FIXME this is a subset of the check continue; - if (!((x % (1 << (rlevel->log2_prec_width + reducedresno)) == 0) || - (x == 0))) // TODO: 2nd condition simplified as try0 always =0 for dcinema + if (xc % (1 << (rlevel->log2_prec_width + reducedresno)) && x != tile->coord[0][0]) //FIXME this is a subset of the check continue; // check if a precinct exists - prcx = ff_jpeg2000_ceildivpow2(x, reducedresno) >> rlevel->log2_prec_width; - prcy = ff_jpeg2000_ceildivpow2(y, reducedresno) >> rlevel->log2_prec_height; + prcx = ff_jpeg2000_ceildivpow2(xc, reducedresno) >> rlevel->log2_prec_width; + prcy = ff_jpeg2000_ceildivpow2(yc, reducedresno) >> rlevel->log2_prec_height; + prcx -= ff_jpeg2000_ceildivpow2(comp->coord_o[0][0], reducedresno) >> rlevel->log2_prec_width; + prcy -= ff_jpeg2000_ceildivpow2(comp->coord_o[1][0], reducedresno) >> rlevel->log2_prec_height; + precno = prcx + rlevel->num_precincts_x * prcy; - if (prcx >= rlevel->num_precincts_x || prcy >= rlevel->num_precincts_y) - return AVERROR_PATCHWELCOME; + if (prcx >= rlevel->num_precincts_x || prcy >= rlevel->num_precincts_y) { + av_log(s->avctx, AV_LOG_WARNING, "prc %d %d outside limits %d %d\n", + prcx, prcy, rlevel->num_precincts_x, rlevel->num_precincts_y); + continue; + } - for (layno = 0; layno < tile->codsty[0].nlayers; layno++) { - if ((ret = jpeg2000_decode_packet(s, codsty, rlevel, + for (layno = 0; layno < LYEpoc; layno++) { + if ((ret = jpeg2000_decode_packet(s, tile, tp_index, codsty, rlevel, precno, layno, qntsty->expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0), qntsty->nguardbits)) < 0) @@ -940,19 +1157,178 @@ break; case JPEG2000_PGOD_RPCL: - avpriv_request_sample(s->avctx, "Progression order RPCL"); - ret = AVERROR_PATCHWELCOME; + av_log(s->avctx, AV_LOG_WARNING, "Progression order RPCL\n"); + ok_reslevel = 1; + for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) { + ok_reslevel = 0; + step_x = 30; + step_y = 30; + for (compno = CSpoc; compno < CEpoc; compno++) { + Jpeg2000Component *comp = tile->comp + compno; + Jpeg2000CodingStyle *codsty = tile->codsty + compno; + + if (reslevelno < codsty->nreslevels) { + uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; // ==> N_L - r + Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno; + step_x = FFMIN(step_x, rlevel->log2_prec_width + reducedresno); + step_y = FFMIN(step_y, rlevel->log2_prec_height + reducedresno); + } + } + step_x = 1<coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) { + for (x = tile->coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) { + for (compno = CSpoc; compno < CEpoc; compno++) { + Jpeg2000Component *comp = tile->comp + compno; + Jpeg2000CodingStyle *codsty = tile->codsty + compno; + Jpeg2000QuantStyle *qntsty = tile->qntsty + compno; + uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; // ==> N_L - r + Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno; + unsigned prcx, prcy; + + int xc = x / s->cdx[compno]; + int yc = y / s->cdy[compno]; + + if (reslevelno >= codsty->nreslevels) + continue; + + if (yc % (1 << (rlevel->log2_prec_height + reducedresno)) && y != tile->coord[1][0]) //FIXME this is a subset of the check + continue; + + if (xc % (1 << (rlevel->log2_prec_width + reducedresno)) && x != tile->coord[0][0]) //FIXME this is a subset of the check + continue; + + // check if a precinct exists + prcx = ff_jpeg2000_ceildivpow2(xc, reducedresno) >> rlevel->log2_prec_width; + prcy = ff_jpeg2000_ceildivpow2(yc, reducedresno) >> rlevel->log2_prec_height; + prcx -= ff_jpeg2000_ceildivpow2(comp->coord_o[0][0], reducedresno) >> rlevel->log2_prec_width; + prcy -= ff_jpeg2000_ceildivpow2(comp->coord_o[1][0], reducedresno) >> rlevel->log2_prec_height; + + precno = prcx + rlevel->num_precincts_x * prcy; + + ok_reslevel = 1; + if (prcx >= rlevel->num_precincts_x || prcy >= rlevel->num_precincts_y) { + av_log(s->avctx, AV_LOG_WARNING, "prc %d %d outside limits %d %d\n", + prcx, prcy, rlevel->num_precincts_x, rlevel->num_precincts_y); + continue; + } + + for (layno = 0; layno < LYEpoc; layno++) { + if ((ret = jpeg2000_decode_packet(s, tile, tp_index, + codsty, rlevel, + precno, layno, + qntsty->expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0), + qntsty->nguardbits)) < 0) + return ret; + } + } + } + } + } break; case JPEG2000_PGOD_PCRL: - avpriv_request_sample(s->avctx, "Progression order PCRL"); - ret = AVERROR_PATCHWELCOME; + av_log(s->avctx, AV_LOG_WARNING, "Progression order PCRL\n"); + step_x = 32; + step_y = 32; + for (compno = CSpoc; compno < CEpoc; compno++) { + Jpeg2000Component *comp = tile->comp + compno; + Jpeg2000CodingStyle *codsty = tile->codsty + compno; + + for (reslevelno = RSpoc; reslevelno < FFMIN(codsty->nreslevels, REpoc); reslevelno++) { + uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; // ==> N_L - r + Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno; + step_x = FFMIN(step_x, rlevel->log2_prec_width + reducedresno); + step_y = FFMIN(step_y, rlevel->log2_prec_height + reducedresno); + } + } + step_x = 1<coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) { + for (x = tile->coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) { + for (compno = CSpoc; compno < CEpoc; compno++) { + Jpeg2000Component *comp = tile->comp + compno; + Jpeg2000CodingStyle *codsty = tile->codsty + compno; + Jpeg2000QuantStyle *qntsty = tile->qntsty + compno; + int xc = x / s->cdx[compno]; + int yc = y / s->cdy[compno]; + + for (reslevelno = RSpoc; reslevelno < FFMIN(codsty->nreslevels, REpoc); reslevelno++) { + unsigned prcx, prcy; + uint8_t reducedresno = codsty->nreslevels - 1 -reslevelno; // ==> N_L - r + Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno; + + if (yc % (1 << (rlevel->log2_prec_height + reducedresno)) && y != tile->coord[1][0]) //FIXME this is a subset of the check + continue; + + if (xc % (1 << (rlevel->log2_prec_width + reducedresno)) && x != tile->coord[0][0]) //FIXME this is a subset of the check + continue; + + // check if a precinct exists + prcx = ff_jpeg2000_ceildivpow2(xc, reducedresno) >> rlevel->log2_prec_width; + prcy = ff_jpeg2000_ceildivpow2(yc, reducedresno) >> rlevel->log2_prec_height; + prcx -= ff_jpeg2000_ceildivpow2(comp->coord_o[0][0], reducedresno) >> rlevel->log2_prec_width; + prcy -= ff_jpeg2000_ceildivpow2(comp->coord_o[1][0], reducedresno) >> rlevel->log2_prec_height; + + precno = prcx + rlevel->num_precincts_x * prcy; + + if (prcx >= rlevel->num_precincts_x || prcy >= rlevel->num_precincts_y) { + av_log(s->avctx, AV_LOG_WARNING, "prc %d %d outside limits %d %d\n", + prcx, prcy, rlevel->num_precincts_x, rlevel->num_precincts_y); + continue; + } + + for (layno = 0; layno < LYEpoc; layno++) { + if ((ret = jpeg2000_decode_packet(s, tile, tp_index, codsty, rlevel, + precno, layno, + qntsty->expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0), + qntsty->nguardbits)) < 0) + return ret; + } + } + } + } + } break; default: break; } + return ret; +} + +static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile) +{ + int ret, i; + int tp_index = 0; + + s->bit_index = 8; + if (tile->poc.nb_poc) { + for (i=0; ipoc.nb_poc; i++) { + Jpeg2000POCEntry *e = &tile->poc.poc[i]; + ret = jpeg2000_decode_packets_po_iteration(s, tile, + e->RSpoc, e->CSpoc, + FFMIN(e->LYEpoc, tile->codsty[0].nlayers), + e->REpoc, + FFMIN(e->CEpoc, s->ncomponents), + e->Ppoc, &tp_index + ); + if (ret < 0) + return ret; + } + } else { + ret = jpeg2000_decode_packets_po_iteration(s, tile, + 0, 0, + tile->codsty[0].nlayers, + 33, + s->ncomponents, + tile->codsty[0].prog_order, + &tp_index + ); + } /* EOC marker reached */ bytestream2_skip(&s->g, 2); @@ -961,7 +1337,7 @@ /* TIER-1 routines */ static void decode_sigpass(Jpeg2000T1Context *t1, int width, int height, - int bpno, int bandno, int bpass_csty_symbol, + int bpno, int bandno, int vert_causal_ctx_csty_symbol) { int mask = 3 << (bpno - 1), y0, x, y; @@ -969,29 +1345,29 @@ for (y0 = 0; y0 < height; y0 += 4) for (x = 0; x < width; x++) for (y = y0; y < height && y < y0 + 4; y++) { - if ((t1->flags[y+1][x+1] & JPEG2000_T1_SIG_NB) - && !(t1->flags[y+1][x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))) { - int flags_mask = -1; - if (vert_causal_ctx_csty_symbol && y == y0 + 3) - flags_mask &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE); - if (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_jpeg2000_getsigctxno(t1->flags[y+1][x+1] & flags_mask, bandno))) { - int xorbit, ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y+1][x+1], &xorbit); - if (bpass_csty_symbol) - t1->data[y][x] = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ? -mask : mask; + int flags_mask = -1; + if (vert_causal_ctx_csty_symbol && y == y0 + 3) + flags_mask &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S); + if ((t1->flags[(y+1) * t1->stride + x+1] & JPEG2000_T1_SIG_NB & flags_mask) + && !(t1->flags[(y+1) * t1->stride + x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))) { + if (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_jpeg2000_getsigctxno(t1->flags[(y+1) * t1->stride + x+1] & flags_mask, bandno))) { + int xorbit, ctxno = ff_jpeg2000_getsgnctxno(t1->flags[(y+1) * t1->stride + x+1] & flags_mask, &xorbit); + if (t1->mqc.raw) + t1->data[(y) * t1->stride + x] = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ? -mask : mask; else - t1->data[y][x] = (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) ? + t1->data[(y) * t1->stride + x] = (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) ? -mask : mask; ff_jpeg2000_set_significance(t1, x, y, - t1->data[y][x] < 0); + t1->data[(y) * t1->stride + x] < 0); } - t1->flags[y + 1][x + 1] |= JPEG2000_T1_VIS; + t1->flags[(y + 1) * t1->stride + x + 1] |= JPEG2000_T1_VIS; } } } static void decode_refpass(Jpeg2000T1Context *t1, int width, int height, - int bpno) + int bpno, int vert_causal_ctx_csty_symbol) { int phalf, nhalf; int y0, x, y; @@ -1002,13 +1378,15 @@ for (y0 = 0; y0 < height; y0 += 4) for (x = 0; x < width; x++) for (y = y0; y < height && y < y0 + 4; y++) - if ((t1->flags[y + 1][x + 1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS)) == JPEG2000_T1_SIG) { - int ctxno = ff_jpeg2000_getrefctxno(t1->flags[y + 1][x + 1]); + if ((t1->flags[(y + 1) * t1->stride + x + 1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS)) == JPEG2000_T1_SIG) { + int flags_mask = (vert_causal_ctx_csty_symbol && y == y0 + 3) ? + ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S) : -1; + int ctxno = ff_jpeg2000_getrefctxno(t1->flags[(y + 1) * t1->stride + x + 1] & flags_mask); int r = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ? phalf : nhalf; - t1->data[y][x] += t1->data[y][x] < 0 ? -r : r; - t1->flags[y + 1][x + 1] |= JPEG2000_T1_REF; + t1->data[(y) * t1->stride + x] += t1->data[(y) * t1->stride + x] < 0 ? -r : r; + t1->flags[(y + 1) * t1->stride + x + 1] |= JPEG2000_T1_REF; } } @@ -1020,11 +1398,14 @@ for (y0 = 0; y0 < height; y0 += 4) { for (x = 0; x < width; x++) { + int flags_mask = -1; + if (vert_causal_ctx_csty_symbol) + flags_mask &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S); if (y0 + 3 < height && - !((t1->flags[y0 + 1][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) || - (t1->flags[y0 + 2][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) || - (t1->flags[y0 + 3][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) || - (t1->flags[y0 + 4][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)))) { + !((t1->flags[(y0 + 1) * t1->stride + x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) || + (t1->flags[(y0 + 2) * t1->stride + x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) || + (t1->flags[(y0 + 3) * t1->stride + x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) || + (t1->flags[(y0 + 4) * t1->stride + x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG) & flags_mask))) { if (!ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_RL)) continue; runlen = ff_mqc_decode(&t1->mqc, @@ -1039,27 +1420,27 @@ } for (y = y0 + runlen; y < y0 + 4 && y < height; y++) { + int flags_mask = -1; + if (vert_causal_ctx_csty_symbol && y == y0 + 3) + flags_mask &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S); if (!dec) { - if (!(t1->flags[y+1][x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))) { - int flags_mask = -1; - if (vert_causal_ctx_csty_symbol && y == y0 + 3) - flags_mask &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE); - dec = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_jpeg2000_getsigctxno(t1->flags[y+1][x+1] & flags_mask, + if (!(t1->flags[(y+1) * t1->stride + x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))) { + dec = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_jpeg2000_getsigctxno(t1->flags[(y+1) * t1->stride + x+1] & flags_mask, bandno)); } } if (dec) { int xorbit; - int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y + 1][x + 1], + int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[(y + 1) * t1->stride + x + 1] & flags_mask, &xorbit); - t1->data[y][x] = (ff_mqc_decode(&t1->mqc, + t1->data[(y) * t1->stride + x] = (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) ? -mask : mask; - ff_jpeg2000_set_significance(t1, x, y, t1->data[y][x] < 0); + ff_jpeg2000_set_significance(t1, x, y, t1->data[(y) * t1->stride + x] < 0); } dec = 0; - t1->flags[y + 1][x + 1] &= ~JPEG2000_T1_VIS; + t1->flags[(y + 1) * t1->stride + x + 1] &= ~JPEG2000_T1_VIS; } } } @@ -1079,56 +1460,73 @@ Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk, int width, int height, int bandpos) { - int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1, y; - int clnpass_cnt = 0; - int bpass_csty_symbol = codsty->cblk_style & JPEG2000_CBLK_BYPASS; + int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1; + int pass_cnt = 0; int vert_causal_ctx_csty_symbol = codsty->cblk_style & JPEG2000_CBLK_VSC; + int term_cnt = 0; + int coder_type; - av_assert0(width <= JPEG2000_MAX_CBLKW); - av_assert0(height <= JPEG2000_MAX_CBLKH); + av_assert0(width <= 1024U && height <= 1024U); + av_assert0(width*height <= 4096); - for (y = 0; y < height; y++) - memset(t1->data[y], 0, width * sizeof(**t1->data)); + memset(t1->data, 0, t1->stride * height * sizeof(*t1->data)); /* If code-block contains no compressed data: nothing to do. */ if (!cblk->length) return 0; - for (y = 0; y < height + 2; y++) - memset(t1->flags[y], 0, (width + 2) * sizeof(**t1->flags)); + memset(t1->flags, 0, t1->stride * (height + 2) * sizeof(*t1->flags)); cblk->data[cblk->length] = 0xff; cblk->data[cblk->length+1] = 0xff; - ff_mqc_initdec(&t1->mqc, cblk->data); + ff_mqc_initdec(&t1->mqc, cblk->data, 0, 1); while (passno--) { switch(pass_t) { case 0: decode_sigpass(t1, width, height, bpno + 1, bandpos, - bpass_csty_symbol && (clnpass_cnt >= 4), vert_causal_ctx_csty_symbol); break; case 1: - decode_refpass(t1, width, height, bpno + 1); - if (bpass_csty_symbol && clnpass_cnt >= 4) - ff_mqc_initdec(&t1->mqc, cblk->data); + decode_refpass(t1, width, height, bpno + 1, vert_causal_ctx_csty_symbol); break; case 2: + av_assert2(!t1->mqc.raw); decode_clnpass(s, t1, width, height, bpno + 1, bandpos, codsty->cblk_style & JPEG2000_CBLK_SEGSYM, vert_causal_ctx_csty_symbol); - clnpass_cnt = clnpass_cnt + 1; - if (bpass_csty_symbol && clnpass_cnt >= 4) - ff_mqc_initdec(&t1->mqc, cblk->data); break; } + if (codsty->cblk_style & JPEG2000_CBLK_RESET) // XXX no testcase for just this + ff_mqc_init_contexts(&t1->mqc); + + if (passno && (coder_type = needs_termination(codsty->cblk_style, pass_cnt))) { + if (term_cnt >= cblk->nb_terminations) { + av_log(s->avctx, AV_LOG_ERROR, "Missing needed termination \n"); + return AVERROR_INVALIDDATA; + } + if (FFABS(cblk->data + cblk->data_start[term_cnt + 1] - 2 - t1->mqc.bp) > 0) { + av_log(s->avctx, AV_LOG_WARNING, "Mid mismatch %"PTRDIFF_SPECIFIER" in pass %d of %d\n", + cblk->data + cblk->data_start[term_cnt + 1] - 2 - t1->mqc.bp, + pass_cnt, cblk->npasses); + } + + ff_mqc_initdec(&t1->mqc, cblk->data + cblk->data_start[++term_cnt], coder_type == 2, 0); + } pass_t++; if (pass_t == 3) { bpno--; pass_t = 0; } + pass_cnt ++; + } + + if (cblk->data + cblk->length - 2*(term_cnt < cblk->nb_terminations) != t1->mqc.bp) { + av_log(s->avctx, AV_LOG_WARNING, "End mismatch %"PTRDIFF_SPECIFIER"\n", + cblk->data + cblk->length - 2*(term_cnt < cblk->nb_terminations) - t1->mqc.bp); } + return 0; } @@ -1147,7 +1545,7 @@ int w = cblk->coord[0][1] - cblk->coord[0][0]; for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j) { float *datap = &comp->f_data[(comp->coord[0][1] - comp->coord[0][0]) * (y + j) + x]; - int *src = t1->data[j]; + int *src = t1->data + j*t1->stride; for (i = 0; i < w; ++i) datap[i] = src[i] * band->f_stepsize; } @@ -1162,9 +1560,15 @@ int w = cblk->coord[0][1] - cblk->coord[0][0]; for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j) { int32_t *datap = &comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) * (y + j) + x]; - int *src = t1->data[j]; - for (i = 0; i < w; ++i) - datap[i] = (src[i] * band->i_stepsize) / 32768; + int *src = t1->data + j*t1->stride; + if (band->i_stepsize == 32768) { + for (i = 0; i < w; ++i) + datap[i] = src[i] / 2; + } else { + // This should be VERY uncommon + for (i = 0; i < w; ++i) + datap[i] = (src[i] * (int64_t)band->i_stepsize) / 65536; + } } } @@ -1176,9 +1580,9 @@ int w = cblk->coord[0][1] - cblk->coord[0][0]; for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j) { int32_t *datap = &comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) * (y + j) + x]; - int *src = t1->data[j]; + int *src = t1->data + j*t1->stride; for (i = 0; i < w; ++i) - datap[i] = (src[i] * band->i_stepsize + (1<<14)) >> 15; + datap[i] = (src[i] * (int64_t)band->i_stepsize + (1<<15)) >> 16; } } @@ -1227,6 +1631,8 @@ Jpeg2000Component *comp = tile->comp + compno; Jpeg2000CodingStyle *codsty = tile->codsty + compno; + t1.stride = (1<log2_cblk_width) + 2; + /* Loop on resolution levels */ for (reslevelno = 0; reslevelno < codsty->nreslevels2decode; reslevelno++) { Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno; @@ -1256,8 +1662,8 @@ cblk->coord[1][1] - cblk->coord[1][0], bandpos); - x = cblk->coord[0][0]; - y = cblk->coord[1][0]; + x = cblk->coord[0][0] - band->coord[0][0]; + y = cblk->coord[1][0] - band->coord[1][0]; if (codsty->transform == FF_DWT97) dequantization_float(x, y, cblk, comp, &t1, band); @@ -1299,13 +1705,13 @@ plane = s->cdef[compno] ? s->cdef[compno]-1 : (s->ncomponents-1); - y = tile->comp[compno].coord[1][0] - s->image_offset_y; - line = picture->data[plane] + y / s->cdy[compno] * picture->linesize[plane]; + y = tile->comp[compno].coord[1][0] - s->image_offset_y / s->cdy[compno]; + line = picture->data[plane] + y * picture->linesize[plane]; for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y ++) { uint8_t *dst; - x = tile->comp[compno].coord[0][0] - s->image_offset_x; - dst = line + x / s->cdx[compno] * pixelsize + compno*!planar; + x = tile->comp[compno].coord[0][0] - s->image_offset_x / s->cdx[compno]; + dst = line + x * pixelsize + compno*!planar; if (codsty->transform == FF_DWT97) { for (; x < w; x ++) { @@ -1331,6 +1737,8 @@ } } else { int precision = picture->format == AV_PIX_FMT_XYZ12 || + picture->format == AV_PIX_FMT_RGB48 || + picture->format == AV_PIX_FMT_RGBA64 || picture->format == AV_PIX_FMT_GRAY16 ? 16 : s->precision; for (compno = 0; compno < s->ncomponents; compno++) { @@ -1346,13 +1754,13 @@ if (planar) plane = s->cdef[compno] ? s->cdef[compno]-1 : (s->ncomponents-1); - y = tile->comp[compno].coord[1][0] - s->image_offset_y; - linel = (uint16_t *)picture->data[plane] + y / s->cdy[compno] * (picture->linesize[plane] >> 1); + y = tile->comp[compno].coord[1][0] - s->image_offset_y / s->cdy[compno]; + linel = (uint16_t *)picture->data[plane] + y * (picture->linesize[plane] >> 1); for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y ++) { uint16_t *dst; - x = tile->comp[compno].coord[0][0] - s->image_offset_x; - dst = linel + (x / s->cdx[compno] * pixelsize + compno*!planar); + x = tile->comp[compno].coord[0][0] - s->image_offset_x / s->cdx[compno]; + dst = linel + (x * pixelsize + compno*!planar); if (codsty->transform == FF_DWT97) { for (; x < w; x ++) { int val = lrintf(*datap) + (1 << (cbps - 1)); @@ -1399,6 +1807,7 @@ av_freep(&s->tile); memset(s->codsty, 0, sizeof(s->codsty)); memset(s->qntsty, 0, sizeof(s->qntsty)); + memset(&s->poc , 0, sizeof(s->poc)); s->numXtiles = s->numYtiles = 0; } @@ -1406,6 +1815,7 @@ { Jpeg2000CodingStyle *codsty = s->codsty; Jpeg2000QuantStyle *qntsty = s->qntsty; + Jpeg2000POC *poc = &s->poc; uint8_t *properties = s->properties; for (;;) { @@ -1449,8 +1859,10 @@ break; len = bytestream2_get_be16(&s->g); - if (len < 2 || bytestream2_get_bytes_left(&s->g) < len - 2) + if (len < 2 || bytestream2_get_bytes_left(&s->g) < len - 2) { + av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", len, bytestream2_get_bytes_left(&s->g)); return AVERROR_INVALIDDATA; + } switch (marker) { case JPEG2000_SIZ: @@ -1470,11 +1882,15 @@ case JPEG2000_QCD: ret = get_qcd(s, len, qntsty, properties); break; + case JPEG2000_POC: + ret = get_poc(s, len, poc); + break; case JPEG2000_SOT: if (!(ret = get_sot(s, len))) { av_assert1(s->curtileno >= 0); codsty = s->tile[s->curtileno].codsty; qntsty = s->tile[s->curtileno].qntsty; + poc = &s->tile[s->curtileno].poc; properties = s->tile[s->curtileno].properties; } break; @@ -1516,11 +1932,11 @@ for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++) { Jpeg2000Tile *tile = s->tile + tileno; - if (ret = init_tile(s, tileno)) + if ((ret = init_tile(s, tileno)) < 0) return ret; s->g = tile->tile_part[0].tpg; - if (ret = jpeg2000_decode_packets(s, tile)) + if ((ret = jpeg2000_decode_packets(s, tile)) < 0) return ret; } @@ -1743,7 +2159,7 @@ .long_name = NULL_IF_CONFIG_SMALL("JPEG 2000"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_JPEG2000, - .capabilities = CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_DR1, .priv_data_size = sizeof(Jpeg2000DecoderContext), .init_static_data = jpeg2000_init_static_data, .init = jpeg2000_decode_init, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000dsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000dsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000dsp.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000dsp.c 2015-06-14 17:20:02.000000000 +0000 @@ -95,4 +95,7 @@ c->mct_decode[FF_DWT97] = ict_float; c->mct_decode[FF_DWT53] = rct_int; c->mct_decode[FF_DWT97_INT] = ict_int; + + if (ARCH_X86) + ff_jpeg2000dsp_init_x86(c); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000dsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000dsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000dsp.h 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000dsp.h 2015-06-14 17:20:02.000000000 +0000 @@ -31,5 +31,6 @@ } Jpeg2000DSPContext; void ff_jpeg2000dsp_init(Jpeg2000DSPContext *c); +void ff_jpeg2000dsp_init_x86(Jpeg2000DSPContext *c); #endif /* AVCODEC_JPEG2000DSP_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000dwt.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000dwt.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000dwt.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000dwt.c 2015-06-24 17:20:02.000000000 +0000 @@ -25,6 +25,7 @@ * Discrete wavelet transform */ +#include "libavutil/avassert.h" #include "libavutil/common.h" #include "libavutil/mem.h" #include "jpeg2000dwt.h" @@ -36,20 +37,16 @@ #define F_LFTG_BETA 0.052980118572961f #define F_LFTG_GAMMA 0.882911075530934f #define F_LFTG_DELTA 0.443506852043971f -#define F_LFTG_K 1.230174104914001f -#define F_LFTG_X 1.625732422f -/* FIXME: Why use 1.625732422 instead of 1/F_LFTG_K? - * Incorrect value in JPEG2000 norm. - * see (ISO/IEC 15444:1 (version 2002) F.3.8.2 */ /* Lifting parameters in integer format. * Computed as param = (float param) * (1 << 16) */ -#define I_LFTG_ALPHA 103949 -#define I_LFTG_BETA 3472 -#define I_LFTG_GAMMA 57862 -#define I_LFTG_DELTA 29066 -#define I_LFTG_K 80621 -#define I_LFTG_X 106544 +#define I_LFTG_ALPHA 103949ll +#define I_LFTG_BETA 3472ll +#define I_LFTG_GAMMA 57862ll +#define I_LFTG_DELTA 29066ll +#define I_LFTG_K 80621ll +#define I_LFTG_X 53274ll +#define I_PRESHIFT 8 static inline void extend53(int *p, int i0, int i1) { @@ -83,14 +80,17 @@ { int i; - if (i1 == i0 + 1) + if (i1 <= i0 + 1) { + if (i0 == 1) + p[1] <<= 1; return; + } extend53(p, i0, i1); - for (i = (i0+1)/2 - 1; i < (i1+1)/2; i++) + for (i = ((i0+1)>>1) - 1; i < (i1+1)>>1; i++) p[2*i+1] -= (p[2*i] + p[2*i+2]) >> 1; - for (i = (i0+1)/2; i < (i1+1)/2; i++) + for (i = ((i0+1)>>1); i < (i1+1)>>1; i++) p[2*i] += (p[2*i-1] + p[2*i+1] + 2) >> 2; } @@ -109,23 +109,6 @@ lp; int *l; - // HOR_SD - l = line + mh; - for (lp = 0; lp < lv; lp++){ - int i, j = 0; - - for (i = 0; i < lh; i++) - l[i] = t[w*lp + i]; - - sd_1d53(line, mh, mh + lh); - - // copy back and deinterleave - for (i = mh; i < lh; i+=2, j++) - t[w*lp + j] = l[i]; - for (i = 1-mh; i < lh; i+=2, j++) - t[w*lp + j] = l[i]; - } - // VER_SD l = line + mv; for (lp = 0; lp < lh; lp++) { @@ -142,25 +125,47 @@ for (i = 1-mv; i < lv; i+=2, j++) t[w*j + lp] = l[i]; } + + // HOR_SD + l = line + mh; + for (lp = 0; lp < lv; lp++){ + int i, j = 0; + + for (i = 0; i < lh; i++) + l[i] = t[w*lp + i]; + + sd_1d53(line, mh, mh + lh); + + // copy back and deinterleave + for (i = mh; i < lh; i+=2, j++) + t[w*lp + j] = l[i]; + for (i = 1-mh; i < lh; i+=2, j++) + t[w*lp + j] = l[i]; + } } } static void sd_1d97_float(float *p, int i0, int i1) { int i; - if (i1 == i0 + 1) + if (i1 <= i0 + 1) { + if (i0 == 1) + p[1] *= F_LFTG_X * 2; + else + p[0] *= F_LFTG_K; return; + } extend97_float(p, i0, i1); i0++; i1++; - for (i = i0/2 - 2; i < i1/2 + 1; i++) + for (i = (i0>>1) - 2; i < (i1>>1) + 1; i++) p[2*i+1] -= 1.586134 * (p[2*i] + p[2*i+2]); - for (i = i0/2 - 1; i < i1/2 + 1; i++) + for (i = (i0>>1) - 1; i < (i1>>1) + 1; i++) p[2*i] -= 0.052980 * (p[2*i-1] + p[2*i+1]); - for (i = i0/2 - 1; i < i1/2; i++) + for (i = (i0>>1) - 1; i < (i1>>1); i++) p[2*i+1] += 0.882911 * (p[2*i] + p[2*i+2]); - for (i = i0/2; i < i1/2; i++) + for (i = (i0>>1); i < (i1>>1); i++) p[2*i] += 0.443506 * (p[2*i-1] + p[2*i+1]); } @@ -191,9 +196,9 @@ // copy back and deinterleave for (i = mh; i < lh; i+=2, j++) - t[w*lp + j] = F_LFTG_X * l[i] / 2; + t[w*lp + j] = l[i]; for (i = 1-mh; i < lh; i+=2, j++) - t[w*lp + j] = F_LFTG_K * l[i] / 2; + t[w*lp + j] = l[i]; } // VER_SD @@ -208,9 +213,9 @@ // copy back and deinterleave for (i = mv; i < lv; i+=2, j++) - t[w*j + lp] = F_LFTG_X * l[i] / 2; + t[w*j + lp] = l[i]; for (i = 1-mv; i < lv; i+=2, j++) - t[w*j + lp] = F_LFTG_K * l[i] / 2; + t[w*j + lp] = l[i]; } } } @@ -219,29 +224,39 @@ { int i; - if (i1 == i0 + 1) + if (i1 <= i0 + 1) { + if (i0 == 1) + p[1] = (p[1] * I_LFTG_X + (1<<14)) >> 15; + else + p[0] = (p[0] * I_LFTG_K + (1<<15)) >> 16; return; + } extend97_int(p, i0, i1); i0++; i1++; - for (i = i0/2 - 2; i < i1/2 + 1; i++) + for (i = (i0>>1) - 2; i < (i1>>1) + 1; i++) p[2 * i + 1] -= (I_LFTG_ALPHA * (p[2 * i] + p[2 * i + 2]) + (1 << 15)) >> 16; - for (i = i0/2 - 1; i < i1/2 + 1; i++) + for (i = (i0>>1) - 1; i < (i1>>1) + 1; i++) p[2 * i] -= (I_LFTG_BETA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16; - for (i = i0/2 - 1; i < i1/2; i++) + for (i = (i0>>1) - 1; i < (i1>>1); i++) p[2 * i + 1] += (I_LFTG_GAMMA * (p[2 * i] + p[2 * i + 2]) + (1 << 15)) >> 16; - for (i = i0/2; i < i1/2; i++) + for (i = (i0>>1); i < (i1>>1); i++) p[2 * i] += (I_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16; } static void dwt_encode97_int(DWTContext *s, int *t) { - int lev, - w = s->linelen[s->ndeclevels-1][0]; + int lev; + int w = s->linelen[s->ndeclevels-1][0]; + int h = s->linelen[s->ndeclevels-1][1]; + int i; int *line = s->i_linebuf; line += 5; + for (i = 0; i < w * h; i++) + t[i] <<= I_PRESHIFT; + for (lev = s->ndeclevels-1; lev >= 0; lev--){ int lh = s->linelen[lev][0], lv = s->linelen[lev][1], @@ -250,6 +265,23 @@ lp; int *l; + // VER_SD + l = line + mv; + for (lp = 0; lp < lh; lp++) { + int i, j = 0; + + for (i = 0; i < lv; i++) + l[i] = t[w*i + lp]; + + sd_1d97_int(line, mv, mv + lv); + + // copy back and deinterleave + for (i = mv; i < lv; i+=2, j++) + t[w*j + lp] = ((l[i] * I_LFTG_X) + (1 << 15)) >> 16; + for (i = 1-mv; i < lv; i+=2, j++) + t[w*j + lp] = l[i]; + } + // HOR_SD l = line + mh; for (lp = 0; lp < lv; lp++){ @@ -262,42 +294,32 @@ // copy back and deinterleave for (i = mh; i < lh; i+=2, j++) - t[w*lp + j] = ((l[i] * I_LFTG_X) + (1 << 16)) >> 17; + t[w*lp + j] = ((l[i] * I_LFTG_X) + (1 << 15)) >> 16; for (i = 1-mh; i < lh; i+=2, j++) - t[w*lp + j] = ((l[i] * I_LFTG_K) + (1 << 16)) >> 17; + t[w*lp + j] = l[i]; } - // VER_SD - l = line + mv; - for (lp = 0; lp < lh; lp++) { - int i, j = 0; - - for (i = 0; i < lv; i++) - l[i] = t[w*i + lp]; - - sd_1d97_int(line, mv, mv + lv); - - // copy back and deinterleave - for (i = mv; i < lv; i+=2, j++) - t[w*j + lp] = ((l[i] * I_LFTG_X) + (1 << 16)) >> 17; - for (i = 1-mv; i < lv; i+=2, j++) - t[w*j + lp] = ((l[i] * I_LFTG_K) + (1 << 16)) >> 17; - } } + + for (i = 0; i < w * h; i++) + t[i] = (t[i] + ((1<>1)) >> I_PRESHIFT; } static void sr_1d53(int *p, int i0, int i1) { int i; - if (i1 == i0 + 1) + if (i1 <= i0 + 1) { + if (i0 == 1) + p[1] >>= 1; return; + } extend53(p, i0, i1); - for (i = i0 / 2; i < i1 / 2 + 1; i++) + for (i = (i0 >> 1); i < (i1 >> 1) + 1; i++) p[2 * i] -= (p[2 * i - 1] + p[2 * i + 1] + 2) >> 2; - for (i = i0 / 2; i < i1 / 2; i++) + for (i = (i0 >> 1); i < (i1 >> 1); i++) p[2 * i + 1] += (p[2 * i] + p[2 * i + 2]) >> 1; } @@ -354,21 +376,26 @@ { int i; - if (i1 == i0 + 1) + if (i1 <= i0 + 1) { + if (i0 == 1) + p[1] *= F_LFTG_K/2; + else + p[0] *= F_LFTG_X; return; + } extend97_float(p, i0, i1); - for (i = i0 / 2 - 1; i < i1 / 2 + 2; i++) + for (i = (i0 >> 1) - 1; i < (i1 >> 1) + 2; i++) p[2 * i] -= F_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]); /* step 4 */ - for (i = i0 / 2 - 1; i < i1 / 2 + 1; i++) + for (i = (i0 >> 1) - 1; i < (i1 >> 1) + 1; i++) p[2 * i + 1] -= F_LFTG_GAMMA * (p[2 * i] + p[2 * i + 2]); /*step 5*/ - for (i = i0 / 2; i < i1 / 2 + 1; i++) + for (i = (i0 >> 1); i < (i1 >> 1) + 1; i++) p[2 * i] += F_LFTG_BETA * (p[2 * i - 1] + p[2 * i + 1]); /* step 6 */ - for (i = i0 / 2; i < i1 / 2; i++) + for (i = (i0 >> 1); i < (i1 >> 1); i++) p[2 * i + 1] += F_LFTG_ALPHA * (p[2 * i] + p[2 * i + 2]); } @@ -394,9 +421,9 @@ int i, j = 0; // copy with interleaving for (i = mh; i < lh; i += 2, j++) - l[i] = data[w * lp + j] * F_LFTG_K; + l[i] = data[w * lp + j]; for (i = 1 - mh; i < lh; i += 2, j++) - l[i] = data[w * lp + j] * F_LFTG_X; + l[i] = data[w * lp + j]; sr_1d97_float(line, mh, mh + lh); @@ -410,9 +437,9 @@ int i, j = 0; // copy with interleaving for (i = mv; i < lv; i += 2, j++) - l[i] = data[w * j + lp] * F_LFTG_K; + l[i] = data[w * j + lp]; for (i = 1 - mv; i < lv; i += 2, j++) - l[i] = data[w * j + lp] * F_LFTG_X; + l[i] = data[w * j + lp]; sr_1d97_float(line, mv, mv + lv); @@ -426,21 +453,26 @@ { int i; - if (i1 == i0 + 1) + if (i1 <= i0 + 1) { + if (i0 == 1) + p[1] = (p[1] * I_LFTG_K + (1<<16)) >> 17; + else + p[0] = (p[0] * I_LFTG_X + (1<<15)) >> 16; return; + } extend97_int(p, i0, i1); - for (i = i0 / 2 - 1; i < i1 / 2 + 2; i++) + for (i = (i0 >> 1) - 1; i < (i1 >> 1) + 2; i++) p[2 * i] -= (I_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16; /* step 4 */ - for (i = i0 / 2 - 1; i < i1 / 2 + 1; i++) + for (i = (i0 >> 1) - 1; i < (i1 >> 1) + 1; i++) p[2 * i + 1] -= (I_LFTG_GAMMA * (p[2 * i] + p[2 * i + 2]) + (1 << 15)) >> 16; /*step 5*/ - for (i = i0 / 2; i < i1 / 2 + 1; i++) + for (i = (i0 >> 1); i < (i1 >> 1) + 1; i++) p[2 * i] += (I_LFTG_BETA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16; /* step 6 */ - for (i = i0 / 2; i < i1 / 2; i++) + for (i = (i0 >> 1); i < (i1 >> 1); i++) p[2 * i + 1] += (I_LFTG_ALPHA * (p[2 * i] + p[2 * i + 2]) + (1 << 15)) >> 16; } @@ -448,11 +480,16 @@ { int lev; int w = s->linelen[s->ndeclevels - 1][0]; + int h = s->linelen[s->ndeclevels - 1][1]; + int i; int32_t *line = s->i_linebuf; int32_t *data = t; /* position at index O of line range [0-5,w+5] cf. extend function */ line += 5; + for (i = 0; i < w * h; i++) + data[i] <<= I_PRESHIFT; + for (lev = 0; lev < s->ndeclevels; lev++) { int lh = s->linelen[lev][0], lv = s->linelen[lev][1], @@ -468,7 +505,7 @@ for (i = mh; i < lh; i += 2, j++) l[i] = ((data[w * lp + j] * I_LFTG_K) + (1 << 15)) >> 16; for (i = 1 - mh; i < lh; i += 2, j++) - l[i] = ((data[w * lp + j] * I_LFTG_X) + (1 << 15)) >> 16; + l[i] = data[w * lp + j]; sr_1d97_int(line, mh, mh + lh); @@ -484,7 +521,7 @@ for (i = mv; i < lv; i += 2, j++) l[i] = ((data[w * j + lp] * I_LFTG_K) + (1 << 15)) >> 16; for (i = 1 - mv; i < lv; i += 2, j++) - l[i] = ((data[w * j + lp] * I_LFTG_X) + (1 << 15)) >> 16; + l[i] = data[w * j + lp]; sr_1d97_int(line, mv, mv + lv); @@ -492,6 +529,9 @@ data[w * i + lp] = l[i]; } } + + for (i = 0; i < w * h; i++) + data[i] = (data[i] + ((1<>1)) >> I_PRESHIFT; } int ff_jpeg2000_dwt_init(DWTContext *s, uint16_t border[2][2], @@ -576,3 +616,125 @@ av_freep(&s->f_linebuf); av_freep(&s->i_linebuf); } + +#ifdef TEST + +#include "libavutil/lfg.h" + +#define MAX_W 256 + +static int test_dwt(int *array, int *ref, uint16_t border[2][2], int decomp_levels, int type, int max_diff) { + int ret, j; + DWTContext s1={{{0}}}, *s= &s1; + int64_t err2 = 0; + + ret = ff_jpeg2000_dwt_init(s, border, decomp_levels, type); + if (ret < 0) { + fprintf(stderr, "ff_jpeg2000_dwt_init failed\n"); + return 1; + } + ret = ff_dwt_encode(s, array); + if (ret < 0) { + fprintf(stderr, "ff_dwt_encode failed\n"); + return 1; + } + ret = ff_dwt_decode(s, array); + if (ret < 0) { + fprintf(stderr, "ff_dwt_encode failed\n"); + return 1; + } + for (j = 0; j max_diff) { + fprintf(stderr, "missmatch at %d (%d != %d) decomp:%d border %d %d %d %d\n", + j, array[j], ref[j],decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1]); + return 2; + } + err2 += (array[j] - ref[j]) * (array[j] - ref[j]); + array[j] = ref[j]; + } + ff_dwt_destroy(s); + + printf("%s, decomp:%2d border %3d %3d %3d %3d milli-err2:%9"PRId64"\n", + type == FF_DWT53 ? "5/3i" : "9/7i", + decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1], + 1000*err2 / ((border[0][1] - border[0][0])*(border[1][1] - border[1][0]))); + + return 0; +} + +static int test_dwtf(float *array, float *ref, uint16_t border[2][2], int decomp_levels, float max_diff) { + int ret, j; + DWTContext s1={{{0}}}, *s= &s1; + double err2 = 0; + + ret = ff_jpeg2000_dwt_init(s, border, decomp_levels, FF_DWT97); + if (ret < 0) { + fprintf(stderr, "ff_jpeg2000_dwt_init failed\n"); + return 1; + } + ret = ff_dwt_encode(s, array); + if (ret < 0) { + fprintf(stderr, "ff_dwt_encode failed\n"); + return 1; + } + ret = ff_dwt_decode(s, array); + if (ret < 0) { + fprintf(stderr, "ff_dwt_encode failed\n"); + return 1; + } + for (j = 0; j max_diff) { + fprintf(stderr, "missmatch at %d (%f != %f) decomp:%d border %d %d %d %d\n", + j, array[j], ref[j],decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1]); + return 2; + } + err2 += (array[j] - ref[j]) * (array[j] - ref[j]); + array[j] = ref[j]; + } + ff_dwt_destroy(s); + + printf("9/7f, decomp:%2d border %3d %3d %3d %3d err2:%20.3f\n", + decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1], + err2 / ((border[0][1] - border[0][0])*(border[1][1] - border[1][0]))); + + return 0; +} + +static int array[MAX_W * MAX_W]; +static int ref [MAX_W * MAX_W]; +static float arrayf[MAX_W * MAX_W]; +static float reff [MAX_W * MAX_W]; + +int main(void) { + AVLFG prng; + int i,j; + uint16_t border[2][2]; + int ret, decomp_levels; + + av_lfg_init(&prng, 1); + + for (i = 0; i>1][j&1] = av_lfg_get(&prng) % MAX_W; + if (border[0][0] >= border[0][1] || border[1][0] >= border[1][1]) + continue; + decomp_levels = av_lfg_get(&prng) % FF_DWT_MAX_DECLVLS; + + ret = test_dwt(array, ref, border, decomp_levels, FF_DWT53, 0); + if (ret) + return ret; + ret = test_dwt(array, ref, border, decomp_levels, FF_DWT97_INT, FFMIN(7+5*decomp_levels, 15+3*decomp_levels)); + if (ret) + return ret; + ret = test_dwtf(arrayf, reff, border, decomp_levels, 0.05); + if (ret) + return ret; + } + + return 0; +} + +#endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000dwt.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000dwt.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000dwt.h 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000dwt.h 2015-06-22 17:20:02.000000000 +0000 @@ -30,6 +30,8 @@ #include #define FF_DWT_MAX_DECLVLS 32 ///< max number of decomposition levels +#define F_LFTG_K 1.230174104914001f +#define F_LFTG_X 0.812893066115961f enum DWTType { FF_DWT97, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeg2000.h 2015-03-15 02:45:59.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeg2000.h 2015-06-28 17:20:02.000000000 +0000 @@ -58,19 +58,20 @@ JPEG2000_EOC = 0xffd9, // end of codestream }; +#define JPEG2000_SOP_FIXED_BYTES 0xFF910004 +#define JPEG2000_SOP_BYTE_LENGTH 6 + enum Jpeg2000Quantsty { // quantization style JPEG2000_QSTY_NONE, // no quantization JPEG2000_QSTY_SI, // scalar derived JPEG2000_QSTY_SE // scalar expounded }; -#define JPEG2000_MAX_CBLKW 64 -#define JPEG2000_MAX_CBLKH 64 - - -#define JPEG2000_MAX_DECLEVELS 32 +#define JPEG2000_MAX_DECLEVELS 33 #define JPEG2000_MAX_RESLEVELS (JPEG2000_MAX_DECLEVELS + 1) +#define JPEG2000_MAX_PASSES 100 + // T1 flags // flags determining significance of neighbor coefficients #define JPEG2000_T1_SIG_N 0x0001 @@ -118,9 +119,10 @@ #define JPEG2000_PGOD_CPRL 0x04 // Component-position-resolution level-layer progression typedef struct Jpeg2000T1Context { - int data[JPEG2000_MAX_CBLKW][JPEG2000_MAX_CBLKH]; - int flags[JPEG2000_MAX_CBLKW + 2][JPEG2000_MAX_CBLKH + 2]; + int data[6144]; + uint16_t flags[6156]; MqcState mqc; + int stride; } Jpeg2000T1Context; typedef struct Jpeg2000TgtNode { @@ -154,6 +156,8 @@ typedef struct Jpeg2000Pass { uint16_t rate; int64_t disto; + uint8_t flushed[4]; + int flushed_len; } Jpeg2000Pass; typedef struct Jpeg2000Cblk { @@ -161,11 +165,15 @@ uint8_t ninclpasses; // number coding of passes included in codestream uint8_t nonzerobits; uint16_t length; - uint16_t lengthinc; + uint16_t lengthinc[JPEG2000_MAX_PASSES]; + uint8_t nb_lengthinc; uint8_t lblock; uint8_t zero; uint8_t data[8192]; - Jpeg2000Pass passes[100]; + int nb_terminations; + int nb_terminationsinc; + int data_start[JPEG2000_MAX_PASSES]; + Jpeg2000Pass passes[JPEG2000_MAX_PASSES]; uint16_t coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}} } Jpeg2000Cblk; // code block @@ -175,6 +183,7 @@ Jpeg2000TgtNode *zerobits; Jpeg2000TgtNode *cblkincl; Jpeg2000Cblk *cblk; + int decoded_layers; uint16_t coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}} } Jpeg2000Prec; // precinct @@ -206,7 +215,7 @@ /* misc tools */ static inline int ff_jpeg2000_ceildivpow2(int a, int b) { - return (a + (1 << b) - 1) >> b; + return -(((int64_t)(-a)) >> b); } static inline int ff_jpeg2000_ceildiv(int a, int b) @@ -262,4 +271,21 @@ void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty); +static inline int needs_termination(int style, int passno) { + if (style & JPEG2000_CBLK_BYPASS) { + int type = passno % 3; + passno /= 3; + if (type == 0 && passno > 2) + return 2; + if (type == 2 && passno > 2) + return 1; + if (style & JPEG2000_CBLK_TERMALL) { + return passno > 2 ? 2 : 1; + } + } + if (style & JPEG2000_CBLK_TERMALL) + return 1; + return 0; +} + #endif /* AVCODEC_JPEG2000_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeglsdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeglsdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeglsdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeglsdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -523,6 +523,6 @@ .init = ff_mjpeg_decode_init, .close = ff_mjpeg_decode_end, .decode = ff_mjpeg_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeglsenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeglsenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/jpeglsenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/jpeglsenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -269,7 +269,7 @@ comps = 3; if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width *avctx->height * comps * 4 + - FF_MIN_BUFFER_SIZE)) < 0) + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return ret; buf2 = av_malloc(pkt->size); @@ -412,20 +412,14 @@ return AVERROR(ENOMEM); } -static av_cold int encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - return 0; -} - static av_cold int encode_init_ls(AVCodecContext *ctx) { - ctx->coded_frame = av_frame_alloc(); - if (!ctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS ctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; ctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (ctx->pix_fmt != AV_PIX_FMT_GRAY8 && ctx->pix_fmt != AV_PIX_FMT_GRAY16 && @@ -444,8 +438,7 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_JPEGLS, .init = encode_init_ls, - .close = encode_close, - .capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY, + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .encode2 = encode_picture_ls, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/jvdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/jvdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/jvdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/jvdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -231,5 +231,5 @@ .init = decode_init, .close = decode_close, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/kgv1dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/kgv1dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/kgv1dec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/kgv1dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -183,5 +183,5 @@ .close = decode_end, .decode = decode_frame, .flush = decode_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/kmvc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/kmvc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/kmvc.c 2015-06-18 18:54:58.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/kmvc.c 2015-07-28 17:20:07.000000000 +0000 @@ -421,5 +421,5 @@ .priv_data_size = sizeof(KmvcContext), .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/lagarith.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/lagarith.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/lagarith.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/lagarith.c 2015-07-28 17:20:07.000000000 +0000 @@ -748,5 +748,5 @@ .init = lag_decode_init, .close = lag_decode_end, .decode = lag_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/lcldec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/lcldec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/lcldec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/lcldec.c 2015-07-28 17:20:07.000000000 +0000 @@ -660,7 +660,7 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif @@ -674,6 +674,6 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/lclenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/lclenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/lclenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/lclenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -79,7 +79,7 @@ int zret; // Zlib return code int max_size = deflateBound(&c->zstream, avctx->width * avctx->height * 3); - if ((ret = ff_alloc_packet2(avctx, pkt, max_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, max_size, 0)) < 0) return ret; if(avctx->pix_fmt != AV_PIX_FMT_BGR24){ @@ -131,16 +131,16 @@ av_assert0(avctx->width && avctx->height); - avctx->extradata = av_mallocz(8 + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_mallocz(8 + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) return AVERROR(ENOMEM); - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif c->compression = avctx->compression_level == FF_COMPRESSION_DEFAULT ? COMP_ZLIB_NORMAL : @@ -183,8 +183,6 @@ av_freep(&avctx->extradata); deflateEnd(&c->zstream); - av_frame_free(&avctx->coded_frame); - return 0; } @@ -197,7 +195,7 @@ .init = encode_init, .encode2 = encode_frame, .close = encode_end, - .capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY, + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_NONE }, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libaacplus.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libaacplus.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libaacplus.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libaacplus.c 2015-07-28 17:20:07.000000000 +0000 @@ -63,7 +63,7 @@ aacplus_cfg->bitRate = avctx->bit_rate; aacplus_cfg->bandWidth = avctx->cutoff; - aacplus_cfg->outputFormat = !(avctx->flags & CODEC_FLAG_GLOBAL_HEADER); + aacplus_cfg->outputFormat = !(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER); aacplus_cfg->inputFormat = avctx->sample_fmt == AV_SAMPLE_FMT_FLT ? AACPLUS_INPUT_FLOAT : AACPLUS_INPUT_16BIT; if (!aacplusEncSetConfiguration(s->aacplus_handle, aacplus_cfg)) { av_log(avctx, AV_LOG_ERROR, "libaacplus doesn't support this output format!\n"); @@ -74,14 +74,14 @@ /* Set decoder specific info */ avctx->extradata_size = 0; - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { unsigned char *buffer = NULL; unsigned long decoder_specific_info_size; if (aacplusEncGetDecoderSpecificInfo(s->aacplus_handle, &buffer, &decoder_specific_info_size) == 1) { - avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_malloc(decoder_specific_info_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { free(buffer); return AVERROR(ENOMEM); @@ -101,7 +101,7 @@ int32_t *input_buffer = (int32_t *)frame->data[0]; int ret; - if ((ret = ff_alloc_packet2(avctx, pkt, s->max_output_bytes)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, s->max_output_bytes, 0)) < 0) return ret; pkt->size = aacplusEncEncode(s->aacplus_handle, input_buffer, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libcelt_dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libcelt_dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libcelt_dec.c 2015-06-18 18:54:58.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libcelt_dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -136,5 +136,5 @@ .init = libcelt_dec_init, .close = libcelt_dec_close, .decode = libcelt_dec_decode, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libdcadec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libdcadec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libdcadec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libdcadec.c 2015-07-28 17:20:07.000000000 +0000 @@ -34,6 +34,7 @@ struct dcadec_context *ctx; uint8_t *buffer; int buffer_size; + int downmix_warned; } DCADecContext; static int dcadec_decode_frame(AVCodecContext *avctx, void *data, @@ -41,6 +42,7 @@ { DCADecContext *s = avctx->priv_data; AVFrame *frame = data; + av_unused struct dcadec_exss_info *exss; int ret, i, k; int **samples, nsamples, channel_mask, sample_rate, bits_per_sample, profile; uint32_t mrk; @@ -54,7 +56,7 @@ } mrk = AV_RB32(input); if (mrk != DCA_SYNCWORD_CORE_BE && mrk != DCA_SYNCWORD_SUBSTREAM) { - s->buffer = av_fast_realloc(s->buffer, &s->buffer_size, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE); + s->buffer = av_fast_realloc(s->buffer, &s->buffer_size, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE); if (!s->buffer) return AVERROR(ENOMEM); @@ -127,6 +129,37 @@ } else avctx->bit_rate = 0; +#if HAVE_STRUCT_DCADEC_EXSS_INFO_MATRIX_ENCODING + if (exss = dcadec_context_get_exss_info(s->ctx)) { + enum AVMatrixEncoding matrix_encoding = AV_MATRIX_ENCODING_NONE; + + if (!s->downmix_warned) { + uint64_t layout = avctx->request_channel_layout; + + if (((layout == AV_CH_LAYOUT_STEREO_DOWNMIX || layout == AV_CH_LAYOUT_STEREO) && !exss->embedded_stereo) || + ( layout == AV_CH_LAYOUT_5POINT1 && !exss->embedded_6ch)) + av_log(avctx, AV_LOG_WARNING, "%s downmix was requested but no custom coefficients are available, " + "this may result in clipping\n", + layout == AV_CH_LAYOUT_5POINT1 ? "5.1" : "Stereo"); + s->downmix_warned = 1; + } + + switch(exss->matrix_encoding) { + case DCADEC_MATRIX_ENCODING_SURROUND: + matrix_encoding = AV_MATRIX_ENCODING_DOLBY; + break; + case DCADEC_MATRIX_ENCODING_HEADPHONE: + matrix_encoding = AV_MATRIX_ENCODING_DOLBYHEADPHONE; + break; + } + dcadec_context_free_exss_info(exss); + + if (matrix_encoding != AV_MATRIX_ENCODING_NONE && + (ret = ff_side_data_update_matrix_encoding(frame, matrix_encoding)) < 0) + return ret; + } +#endif + frame->nb_samples = nsamples; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; @@ -173,9 +206,30 @@ int flags = 0; /* Affects only lossy DTS profiles. DTS-HD MA is always bitexact */ - if (avctx->flags & CODEC_FLAG_BITEXACT) + if (avctx->flags & AV_CODEC_FLAG_BITEXACT) flags |= DCADEC_FLAG_CORE_BIT_EXACT; + if (avctx->request_channel_layout > 0 && avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE) { + switch (avctx->request_channel_layout) { + case AV_CH_LAYOUT_STEREO: + case AV_CH_LAYOUT_STEREO_DOWNMIX: + /* libdcadec ignores the 2ch flag if used alone when no custom downmix coefficients + are available, silently outputting a 5.1 downmix if possible instead. + Using both the 2ch and 6ch flags together forces a 2ch downmix using default + coefficients in such cases. This matches the behavior of the 6ch flag when used + alone, where a 5.1 downmix is generated if possible, regardless of custom + coefficients being available or not. */ + flags |= DCADEC_FLAG_KEEP_DMIX_2CH | DCADEC_FLAG_KEEP_DMIX_6CH; + break; + case AV_CH_LAYOUT_5POINT1: + flags |= DCADEC_FLAG_KEEP_DMIX_6CH; + break; + default: + av_log(avctx, AV_LOG_WARNING, "Invalid request_channel_layout\n"); + break; + } + } + s->ctx = dcadec_context_create(flags); if (!s->ctx) return AVERROR(ENOMEM); @@ -206,7 +260,7 @@ .decode = dcadec_decode_frame, .close = dcadec_close, .flush = dcadec_flush, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_CHANNEL_CONF, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, .profiles = NULL_IF_CONFIG_SMALL(profiles), diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libfaac.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libfaac.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libfaac.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libfaac.c 2015-07-28 17:20:07.000000000 +0000 @@ -117,7 +117,7 @@ faac_cfg->allowMidside = 1; faac_cfg->bitRate = avctx->bit_rate / avctx->channels; faac_cfg->bandWidth = avctx->cutoff; - if(avctx->flags & CODEC_FLAG_QSCALE) { + if(avctx->flags & AV_CODEC_FLAG_QSCALE) { faac_cfg->bitRate = 0; faac_cfg->quantqual = avctx->global_quality / FF_QP2LAMBDA; } @@ -131,14 +131,14 @@ /* Set decoder specific info */ avctx->extradata_size = 0; - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { unsigned char *buffer = NULL; unsigned long decoder_specific_info_size; if (!faacEncGetDecoderSpecificInfo(s->faac_handle, &buffer, &decoder_specific_info_size)) { - avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_malloc(decoder_specific_info_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { ret = AVERROR(ENOMEM); goto error; @@ -184,7 +184,7 @@ int num_samples = frame ? frame->nb_samples : 0; void *samples = frame ? frame->data[0] : NULL; - if ((ret = ff_alloc_packet2(avctx, avpkt, (7 + 768) * avctx->channels)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, (7 + 768) * avctx->channels, 0)) < 0) return ret; bytes_written = faacEncEncode(s->faac_handle, samples, @@ -240,7 +240,7 @@ .init = Faac_encode_init, .encode2 = Faac_encode_frame, .close = Faac_encode_close, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .profiles = NULL_IF_CONFIG_SMALL(profiles), diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libfdk-aacdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libfdk-aacdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libfdk-aacdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libfdk-aacdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -415,6 +415,6 @@ .decode = fdk_aac_decode_frame, .close = fdk_aac_decode_close, .flush = fdk_aac_decode_flush, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_CHANNEL_CONF, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, .priv_class = &fdk_aac_dec_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libfdk-aacenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libfdk-aacenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libfdk-aacenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libfdk-aacenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -184,7 +184,7 @@ goto error; } - if (avctx->flags & CODEC_FLAG_QSCALE || s->vbr) { + if (avctx->flags & AV_CODEC_FLAG_QSCALE || s->vbr) { int mode = s->vbr ? s->vbr : avctx->global_quality; if (mode < 1 || mode > 5) { av_log(avctx, AV_LOG_WARNING, @@ -224,7 +224,7 @@ /* Choose bitstream format - if global header is requested, use * raw access units, otherwise use ADTS. */ if ((err = aacEncoder_SetParam(s->handle, AACENC_TRANSMUX, - avctx->flags & CODEC_FLAG_GLOBAL_HEADER ? 0 : s->latm ? 10 : 2)) != AACENC_OK) { + avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER ? 0 : s->latm ? 10 : 2)) != AACENC_OK) { av_log(avctx, AV_LOG_ERROR, "Unable to set the transmux format: %s\n", aac_get_error(err)); goto error; @@ -243,7 +243,7 @@ * if using mp4 mode (raw access units, with global header) and * implicit signaling if using ADTS. */ if (s->signaling < 0) - s->signaling = avctx->flags & CODEC_FLAG_GLOBAL_HEADER ? 2 : 0; + s->signaling = avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER ? 2 : 0; if ((err = aacEncoder_SetParam(s->handle, AACENC_SIGNALING_MODE, s->signaling)) != AACENC_OK) { @@ -289,10 +289,10 @@ avctx->initial_padding = info.encoderDelay; ff_af_queue_init(avctx, &s->afq); - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { avctx->extradata_size = info.confSize; avctx->extradata = av_mallocz(avctx->extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { ret = AVERROR(ENOMEM); goto error; @@ -342,7 +342,7 @@ } /* The maximum packet size is 6144 bits aka 768 bytes per channel. */ - if ((ret = ff_alloc_packet2(avctx, avpkt, FFMAX(8192, 768 * avctx->channels))) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, FFMAX(8192, 768 * avctx->channels), 0)) < 0) return ret; out_ptr = avpkt->data; @@ -417,7 +417,7 @@ .init = aac_encode_init, .encode2 = aac_encode_frame, .close = aac_encode_close, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .priv_class = &aac_enc_class, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libgsmdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libgsmdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libgsmdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libgsmdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -134,7 +134,7 @@ .close = libgsm_decode_close, .decode = libgsm_decode_frame, .flush = libgsm_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif #if CONFIG_LIBGSM_MS_DECODER @@ -148,6 +148,6 @@ .close = libgsm_decode_close, .decode = libgsm_decode_frame, .flush = libgsm_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libgsmenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libgsmenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libgsmenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libgsmenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -98,7 +98,7 @@ gsm_signal *samples = (gsm_signal *)frame->data[0]; struct gsm_state *state = avctx->priv_data; - if ((ret = ff_alloc_packet2(avctx, avpkt, avctx->block_align)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, avctx->block_align, 0)) < 0) return ret; switch(avctx->codec_id) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libilbc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libilbc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libilbc.c 2015-06-18 18:54:58.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libilbc.c 2015-07-28 17:20:07.000000000 +0000 @@ -111,7 +111,7 @@ .priv_data_size = sizeof(ILBCDecContext), .init = ilbc_decode_init, .decode = ilbc_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .priv_class = &ilbc_dec_class, }; @@ -166,7 +166,7 @@ ILBCEncContext *s = avctx->priv_data; int ret; - if ((ret = ff_alloc_packet2(avctx, avpkt, 50)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, 50, 0)) < 0) return ret; WebRtcIlbcfix_EncodeImpl((uint16_t *) avpkt->data, (const int16_t *) frame->data[0], &s->encoder); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libkvazaar.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libkvazaar.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libkvazaar.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libkvazaar.c 2015-07-28 17:20:07.000000000 +0000 @@ -0,0 +1,248 @@ +/* + * libkvazaar encoder + * + * Copyright (c) 2015 Tampere University of Technology + * + * 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 +#include + +#include "libavutil/avassert.h" +#include "libavutil/dict.h" +#include "libavutil/opt.h" +#include "avcodec.h" +#include "internal.h" + +typedef struct LibkvazaarContext { + const AVClass *class; + + const kvz_api *api; + kvz_encoder *encoder; + kvz_config *config; + + char *kvz_params; +} LibkvazaarContext; + +static av_cold int libkvazaar_init(AVCodecContext *avctx) +{ + int retval = 0; + kvz_config *cfg = NULL; + kvz_encoder *enc = NULL; + const kvz_api *const api = kvz_api_get(8); + + LibkvazaarContext *const ctx = avctx->priv_data; + + // Kvazaar requires width and height to be multiples of eight. + if (avctx->width % 8 || avctx->height % 8) { + av_log(avctx, AV_LOG_ERROR, "Video dimensions are not a multiple of 8.\n"); + retval = AVERROR_INVALIDDATA; + goto done; + } + + cfg = api->config_alloc(); + if (!cfg) { + av_log(avctx, AV_LOG_ERROR, "Could not allocate kvazaar config structure.\n"); + retval = AVERROR(ENOMEM); + goto done; + } + + if (!api->config_init(cfg)) { + av_log(avctx, AV_LOG_ERROR, "Could not initialize kvazaar config structure.\n"); + retval = AVERROR_EXTERNAL; + goto done; + } + + cfg->width = avctx->width; + cfg->height = avctx->height; + cfg->framerate = + (double)(avctx->time_base.num * avctx->ticks_per_frame) / avctx->time_base.den; + cfg->threads = avctx->thread_count; + cfg->target_bitrate = avctx->bit_rate; + cfg->vui.sar_width = avctx->sample_aspect_ratio.num; + cfg->vui.sar_height = avctx->sample_aspect_ratio.den; + + if (ctx->kvz_params) { + AVDictionary *dict = NULL; + if (!av_dict_parse_string(&dict, ctx->kvz_params, "=", ",", 0)) { + AVDictionaryEntry *entry = NULL; + while ((entry = av_dict_get(dict, "", entry, AV_DICT_IGNORE_SUFFIX))) { + if (!api->config_parse(cfg, entry->key, entry->value)) { + av_log(avctx, AV_LOG_WARNING, + "Invalid option: %s=%s.\n", + entry->key, entry->value); + } + } + av_dict_free(&dict); + } + } + + enc = api->encoder_open(cfg); + if (!enc) { + av_log(avctx, AV_LOG_ERROR, "Could not open kvazaar encoder.\n"); + retval = AVERROR_EXTERNAL; + goto done; + } + + ctx->api = api; + ctx->encoder = enc; + ctx->config = cfg; + enc = NULL; + cfg = NULL; + +done: + if (cfg) api->config_destroy(cfg); + if (enc) api->encoder_close(enc); + + return retval; +} + +static av_cold int libkvazaar_close(AVCodecContext *avctx) +{ + LibkvazaarContext *ctx = avctx->priv_data; + if (!ctx->api) return 0; + + if (ctx->encoder) { + ctx->api->encoder_close(ctx->encoder); + ctx->encoder = NULL; + } + + if (ctx->config) { + ctx->api->config_destroy(ctx->config); + ctx->config = NULL; + } + + return 0; +} + +static int libkvazaar_encode(AVCodecContext *avctx, + AVPacket *avpkt, + const AVFrame *frame, + int *got_packet_ptr) +{ + int retval = 0; + kvz_picture *img_in = NULL; + kvz_data_chunk *data_out = NULL; + uint32_t len_out = 0; + LibkvazaarContext *ctx = avctx->priv_data; + + *got_packet_ptr = 0; + + if (frame) { + int i = 0; + + av_assert0(frame->width == ctx->config->width); + av_assert0(frame->height == ctx->config->height); + av_assert0(frame->format == avctx->pix_fmt); + + // Allocate input picture for kvazaar. + img_in = ctx->api->picture_alloc(frame->width, frame->height); + if (!img_in) { + av_log(avctx, AV_LOG_ERROR, "Failed to allocate picture.\n"); + retval = AVERROR(ENOMEM); + goto done; + } + + // Copy pixels from frame to img_in. + for (i = 0; i < 3; ++i) { + uint8_t *dst = img_in->data[i]; + uint8_t *src = frame->data[i]; + int width = (i == 0) ? frame->width : (frame->width / 2); + int height = (i == 0) ? frame->height : (frame->height / 2); + int y = 0; + for (y = 0; y < height; ++y) { + memcpy(dst, src, width); + src += frame->linesize[i]; + dst += width; + } + } + } + + if (!ctx->api->encoder_encode(ctx->encoder, img_in, &data_out, &len_out, NULL)) { + av_log(avctx, AV_LOG_ERROR, "Failed to encode frame.\n"); + retval = AVERROR_EXTERNAL; + goto done; + } + + if (data_out) { + kvz_data_chunk *chunk = NULL; + uint64_t written = 0; + + retval = ff_alloc_packet(avpkt, len_out); + if (retval < 0) { + av_log(avctx, AV_LOG_ERROR, "Failed to allocate output packet.\n"); + goto done; + } + + for (chunk = data_out; chunk != NULL; chunk = chunk->next) { + av_assert0(written + chunk->len <= len_out); + memcpy(avpkt->data + written, chunk->data, chunk->len); + written += chunk->len; + } + *got_packet_ptr = 1; + + ctx->api->chunk_free(data_out); + data_out = NULL; + } + +done: + if (img_in) ctx->api->picture_free(img_in); + if (data_out) ctx->api->chunk_free(data_out); + return retval; +} + +static const enum AVPixelFormat pix_fmts[] = { + AV_PIX_FMT_YUV420P, + AV_PIX_FMT_NONE +}; + +static const AVOption options[] = { + { "kvazaar-params", "Set kvazaar parameters as a comma-separated list of name=value pairs.", + offsetof(LibkvazaarContext, kvz_params), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, + AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, + { NULL }, +}; + +static const AVClass class = { + .class_name = "libkvazaar", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const AVCodecDefault defaults[] = { + { "b", "0" }, + { NULL }, +}; + +AVCodec ff_libkvazaar_encoder = { + .name = "libkvazaar", + .long_name = NULL_IF_CONFIG_SMALL("libkvazaar H.265 / HEVC"), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_HEVC, + .capabilities = AV_CODEC_CAP_DELAY, + .pix_fmts = pix_fmts, + + .priv_class = &class, + .priv_data_size = sizeof(LibkvazaarContext), + .defaults = defaults, + + .init = libkvazaar_init, + .encode2 = libkvazaar_encode, + .close = libkvazaar_close, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libmp3lame.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libmp3lame.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libmp3lame.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libmp3lame.c 2015-07-28 17:20:07.000000000 +0000 @@ -111,7 +111,7 @@ lame_set_quality(s->gfp, avctx->compression_level); /* rate control */ - if (avctx->flags & CODEC_FLAG_QSCALE) { // VBR + if (avctx->flags & AV_CODEC_FLAG_QSCALE) { // VBR lame_set_VBR(s->gfp, vbr_default); lame_set_VBR_quality(s->gfp, avctx->global_quality / (float)FF_QP2LAMBDA); } else { @@ -159,7 +159,7 @@ if (ret < 0) goto error; - s->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!s->fdsp) { ret = AVERROR(ENOMEM); goto error; @@ -258,7 +258,7 @@ ff_dlog(avctx, "in:%d packet-len:%d index:%d\n", avctx->frame_size, len, s->buffer_index); if (len <= s->buffer_index) { - if ((ret = ff_alloc_packet2(avctx, avpkt, len)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, len, 0)) < 0) return ret; memcpy(avpkt->data, s->buffer, len); s->buffer_index -= len; @@ -308,7 +308,7 @@ .init = mp3lame_encode_init, .encode2 = mp3lame_encode_frame, .close = mp3lame_encode_close, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_SMALL_LAST_FRAME, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libopencore-amr.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libopencore-amr.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libopencore-amr.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libopencore-amr.c 2015-07-28 17:20:07.000000000 +0000 @@ -135,7 +135,7 @@ .init = amr_nb_decode_init, .close = amr_nb_decode_close, .decode = amr_nb_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif /* CONFIG_LIBOPENCORE_AMRNB_DECODER */ @@ -236,7 +236,7 @@ s->enc_bitrate = avctx->bit_rate; } - if ((ret = ff_alloc_packet2(avctx, avpkt, 32)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, 32, 0)) < 0) return ret; if (frame) { @@ -287,7 +287,7 @@ .init = amr_nb_encode_init, .encode2 = amr_nb_encode_frame, .close = amr_nb_encode_close, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_SMALL_LAST_FRAME, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .priv_class = &amrnb_class, @@ -372,7 +372,7 @@ .init = amr_wb_decode_init, .close = amr_wb_decode_close, .decode = amr_wb_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif /* CONFIG_LIBOPENCORE_AMRWB_DECODER */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libopenh264enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libopenh264enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libopenh264enc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libopenh264enc.c 2015-07-28 17:20:07.000000000 +0000 @@ -92,7 +92,7 @@ (*s->encoder)->GetDefaultParams(s->encoder, ¶m); - param.fMaxFrameRate = avctx->time_base.den / avctx->time_base.num; + param.fMaxFrameRate = 1/av_q2d(avctx->time_base); param.iPicWidth = avctx->width; param.iPicHeight = avctx->height; param.iTargetBitrate = avctx->bit_rate; @@ -137,13 +137,13 @@ goto fail; } - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { SFrameBSInfo fbi = { 0 }; int i, size = 0; (*s->encoder)->EncodeParameterSets(s->encoder, &fbi); for (i = 0; i < fbi.sLayerInfo[0].iNalCount; i++) size += fbi.sLayerInfo[0].pNalLengthInByte[i]; - avctx->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { err = AVERROR(ENOMEM); goto fail; @@ -192,7 +192,7 @@ // frames have two layers, where the first layer contains the SPS/PPS. // If using global headers, don't include the SPS/PPS in the returned // packet - thus, only return one layer. - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) first_layer = fbi.iLayerNum - 1; for (layer = first_layer; layer < fbi.iLayerNum; layer++) { @@ -227,7 +227,7 @@ .init = svc_encode_init, .encode2 = svc_encode_frame, .close = svc_encode_close, - .capabilities = CODEC_CAP_AUTO_THREADS, + .capabilities = AV_CODEC_CAP_AUTO_THREADS, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, .priv_class = &class, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libopenjpegdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libopenjpegdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libopenjpegdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libopenjpegdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -439,7 +439,7 @@ int major, minor; if (sscanf(version, "%d.%d", &major, &minor) == 2 && 1000*major + minor <= 1003) - codec->capabilities |= CODEC_CAP_EXPERIMENTAL; + codec->capabilities |= AV_CODEC_CAP_EXPERIMENTAL; } #define OFFSET(x) offsetof(LibOpenJPEGContext, x) @@ -466,7 +466,7 @@ .priv_data_size = sizeof(LibOpenJPEGContext), .init = libopenjpeg_decode_init, .decode = libopenjpeg_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .max_lowres = 31, .priv_class = &openjpeg_class, .init_static_data = libopenjpeg_static_init, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libopenjpegenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libopenjpegenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libopenjpegenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libopenjpegenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -242,18 +242,11 @@ goto fail; } - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) { - av_log(avctx, AV_LOG_ERROR, "Error allocating coded frame\n"); - goto fail; - } - return 0; fail: opj_image_destroy(ctx->image); ctx->image = NULL; - av_frame_free(&avctx->coded_frame); return err; } @@ -586,7 +579,7 @@ } len = cio_tell(stream); - if ((ret = ff_alloc_packet2(avctx, pkt, len)) < 0) { + if ((ret = ff_alloc_packet2(avctx, pkt, len, 0)) < 0) { return ret; } @@ -608,7 +601,6 @@ opj_image_destroy(ctx->image); ctx->image = NULL; - av_frame_free(&avctx->coded_frame); return 0; } @@ -657,7 +649,7 @@ .init = libopenjpeg_encode_init, .encode2 = libopenjpeg_encode_frame, .close = libopenjpeg_encode_close, - .capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY, + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64, AV_PIX_FMT_GBR24P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libopusdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libopusdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libopusdec.c 2015-06-18 18:54:58.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libopusdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -191,7 +191,7 @@ .close = libopus_decode_close, .decode = libopus_decode, .flush = libopus_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libopusenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libopusenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libopusenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libopusenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -269,7 +269,7 @@ } header_size = 19 + (avctx->channels > 2 ? 2 + avctx->channels : 0); - avctx->extradata = av_malloc(header_size + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_malloc(header_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate extradata.\n"); ret = AVERROR(ENOMEM); @@ -335,7 +335,7 @@ /* Maximum packet size taken from opusenc in opus-tools. 60ms packets * consist of 3 frames in one packet. The maximum frame size is 1275 * bytes along with the largest possible packet header of 7 bytes. */ - if ((ret = ff_alloc_packet2(avctx, avpkt, (1275 * 3 + 7) * opus->stream_count)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, (1275 * 3 + 7) * opus->stream_count, 0)) < 0) return ret; if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) @@ -438,7 +438,7 @@ .init = libopus_encode_init, .encode2 = libopus_encode, .close = libopus_encode_close, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_SMALL_LAST_FRAME, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libschroedingerdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libschroedingerdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libschroedingerdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libschroedingerdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -383,6 +383,6 @@ .init = libschroedinger_decode_init, .close = libschroedinger_decode_close, .decode = libschroedinger_decode_frame, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .flush = libschroedinger_flush, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libschroedingerenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libschroedingerenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libschroedingerenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libschroedingerenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -159,10 +159,6 @@ avctx->width, avctx->height); - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - if (!avctx->gop_size) { schro_encoder_setting_set_double(p_schro_params->encoder, "gop_structure", @@ -179,7 +175,7 @@ } /* FIXME - Need to handle SCHRO_ENCODER_RATE_CONTROL_LOW_DELAY. */ - if (avctx->flags & CODEC_FLAG_QSCALE) { + if (avctx->flags & AV_CODEC_FLAG_QSCALE) { if (!avctx->global_quality) { /* lossless coding */ schro_encoder_setting_set_double(p_schro_params->encoder, @@ -206,14 +202,14 @@ "bitrate", avctx->bit_rate); } - if (avctx->flags & CODEC_FLAG_INTERLACED_ME) + if (avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) /* All material can be coded as interlaced or progressive irrespective of the type of source material. */ schro_encoder_setting_set_double(p_schro_params->encoder, "interlaced_coding", 1); schro_encoder_setting_set_double(p_schro_params->encoder, "open_gop", - !(avctx->flags & CODEC_FLAG_CLOSED_GOP)); + !(avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)); /* FIXME: Signal range hardcoded to 8-bit data until both libschroedinger * and libdirac support other bit-depth data. */ @@ -383,16 +379,20 @@ pkt_size = p_frame_output->size; if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0) pkt_size += p_schro_params->enc_buf_size; - if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, 0)) < 0) goto error; memcpy(pkt->data, p_frame_output->p_encbuf, p_frame_output->size); +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->key_frame = p_frame_output->key_frame; + avctx->coded_frame->pts = p_frame_output->frame_num; +FF_ENABLE_DEPRECATION_WARNINGS +#endif /* Use the frame number of the encoded frame as the pts. It is OK to * do so since Dirac is a constant frame rate codec. It expects input * to be of constant frame rate. */ - pkt->pts = - avctx->coded_frame->pts = p_frame_output->frame_num; + pkt->pts = p_frame_output->frame_num; pkt->dts = p_schro_params->dts++; enc_size = p_frame_output->size; @@ -436,8 +436,6 @@ /* Free the video format structure. */ av_freep(&p_schro_params->format); - av_frame_free(&avctx->coded_frame); - return 0; } @@ -451,7 +449,7 @@ .init = libschroedinger_encode_init, .encode2 = libschroedinger_encode_frame, .close = libschroedinger_encode_close, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libshine.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libshine.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libshine.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libshine.c 2015-08-02 17:20:02.000000000 +0000 @@ -102,7 +102,7 @@ len = hdr.frame_size; if (len <= s->buffer_index) { - if ((ret = ff_alloc_packet2(avctx, avpkt, len))) + if ((ret = ff_alloc_packet2(avctx, avpkt, len, 0))) return ret; memcpy(avpkt->data, s->buffer, len); s->buffer_index -= len; @@ -139,7 +139,7 @@ .init = libshine_encode_init, .encode2 = libshine_encode_frame, .close = libshine_encode_close, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, .supported_samplerates = libshine_sample_rates, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libspeexdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libspeexdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libspeexdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libspeexdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -199,5 +199,5 @@ .close = libspeex_decode_close, .decode = libspeex_decode_frame, .flush = libspeex_decode_flush, - .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libspeexenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libspeexenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libspeexenc.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libspeexenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -40,7 +40,7 @@ * used to set the encoding mode. * * Rate Control - * VBR mode is turned on by setting CODEC_FLAG_QSCALE in avctx->flags. + * VBR mode is turned on by setting AV_CODEC_FLAG_QSCALE in avctx->flags. * avctx->global_quality is used to set the encoding quality. * For CBR mode, avctx->bit_rate can be used to set the constant bitrate. * Alternatively, the 'cbr_quality' option can be set from 0 to 10 to set @@ -177,7 +177,7 @@ speex_init_header(&s->header, avctx->sample_rate, avctx->channels, mode); /* rate control method and parameters */ - if (avctx->flags & CODEC_FLAG_QSCALE) { + if (avctx->flags & AV_CODEC_FLAG_QSCALE) { /* VBR */ s->header.vbr = 1; s->vad = 1; /* VAD is always implicitly activated for VBR */ @@ -244,8 +244,8 @@ below with speex_header_free() */ header_data = speex_header_to_packet(&s->header, &header_size); - /* allocate extradata and coded_frame */ - avctx->extradata = av_malloc(header_size + FF_INPUT_BUFFER_PADDING_SIZE); + /* allocate extradata */ + avctx->extradata = av_malloc(header_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { speex_header_free(header_data); speex_encoder_destroy(s->enc_state); @@ -294,7 +294,7 @@ /* write output if all frames for the packet have been encoded */ if (s->pkt_frame_count == s->frames_per_packet) { s->pkt_frame_count = 0; - if ((ret = ff_alloc_packet2(avctx, avpkt, speex_bits_nbytes(&s->bits))) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, speex_bits_nbytes(&s->bits), 0)) < 0) return ret; ret = speex_bits_write(&s->bits, avpkt->data, avpkt->size); speex_bits_reset(&s->bits); @@ -356,7 +356,7 @@ .init = encode_init, .encode2 = encode_frame, .close = encode_close, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .channel_layouts = (const uint64_t[]){ AV_CH_LAYOUT_MONO, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libstagefright.cpp ffmpeg-2.7.2~trusty~ppa1/libavcodec/libstagefright.cpp --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libstagefright.cpp 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libstagefright.cpp 2015-07-28 17:20:07.000000000 +0000 @@ -272,7 +272,7 @@ s->orig_extradata_size = avctx->extradata_size; s->orig_extradata = (uint8_t*) av_mallocz(avctx->extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!s->orig_extradata) { ret = AVERROR(ENOMEM); goto fail; @@ -568,7 +568,7 @@ NULL_IF_CONFIG_SMALL("libstagefright H.264"), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264, - CODEC_CAP_DELAY, + AV_CODEC_CAP_DELAY, NULL, //supported_framerates NULL, //pix_fmts NULL, //supported_samplerates diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libtheoraenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libtheoraenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libtheoraenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libtheoraenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -210,7 +210,7 @@ } avcodec_get_chroma_sub_sample(avc_context->pix_fmt, &h->uv_hshift, &h->uv_vshift); - if (avc_context->flags & CODEC_FLAG_QSCALE) { + if (avc_context->flags & AV_CODEC_FLAG_QSCALE) { /* Clip global_quality in QP units to the [0 - 10] range to be consistent with the libvorbis implementation. Theora accepts a quality parameter which is an int value in @@ -241,10 +241,10 @@ } // need to enable 2 pass (via TH_ENCCTL_2PASS_) before encoding headers - if (avc_context->flags & CODEC_FLAG_PASS1) { + if (avc_context->flags & AV_CODEC_FLAG_PASS1) { if ((ret = get_stats(avc_context, 0)) < 0) return ret; - } else if (avc_context->flags & CODEC_FLAG_PASS2) { + } else if (avc_context->flags & AV_CODEC_FLAG_PASS2) { if ((ret = submit_stats(avc_context)) < 0) return ret; } @@ -267,11 +267,6 @@ th_comment_clear(&t_comment); - /* Set up the output AVFrame */ - avc_context->coded_frame = av_frame_alloc(); - if (!avc_context->coded_frame) - return AVERROR(ENOMEM); - return 0; } @@ -286,7 +281,7 @@ // EOS, finish and get 1st pass stats if applicable if (!frame) { th_encode_packetout(h->t_state, 1, &o_packet); - if (avc_context->flags & CODEC_FLAG_PASS1) + if (avc_context->flags & AV_CODEC_FLAG_PASS1) if ((ret = get_stats(avc_context, 1)) < 0) return ret; return 0; @@ -300,7 +295,7 @@ t_yuv_buffer[i].data = frame->data[i]; } - if (avc_context->flags & CODEC_FLAG_PASS2) + if (avc_context->flags & AV_CODEC_FLAG_PASS2) if ((ret = submit_stats(avc_context)) < 0) return ret; @@ -323,7 +318,7 @@ return AVERROR_EXTERNAL; } - if (avc_context->flags & CODEC_FLAG_PASS1) + if (avc_context->flags & AV_CODEC_FLAG_PASS1) if ((ret = get_stats(avc_context, 0)) < 0) return ret; @@ -342,15 +337,19 @@ } /* Copy ogg_packet content out to buffer */ - if ((ret = ff_alloc_packet2(avc_context, pkt, o_packet.bytes)) < 0) + if ((ret = ff_alloc_packet2(avc_context, pkt, o_packet.bytes, 0)) < 0) return ret; memcpy(pkt->data, o_packet.packet, o_packet.bytes); // HACK: assumes no encoder delay, this is true until libtheora becomes // multithreaded (which will be disabled unless explicitly requested) pkt->pts = pkt->dts = frame->pts; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avc_context->coded_frame->key_frame = !(o_packet.granulepos & h->keyframe_mask); - if (avc_context->coded_frame->key_frame) +FF_ENABLE_DEPRECATION_WARNINGS +#endif + if (!(o_packet.granulepos & h->keyframe_mask)) pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; @@ -363,7 +362,6 @@ th_encode_free(h->t_state); av_freep(&h->stats); - av_frame_free(&avc_context->coded_frame); av_freep(&avc_context->stats_out); av_freep(&avc_context->extradata); avc_context->extradata_size = 0; @@ -381,7 +379,7 @@ .init = encode_init, .close = encode_close, .encode2 = encode_frame, - .capabilities = CODEC_CAP_DELAY, // needed to get the statsfile summary + .capabilities = AV_CODEC_CAP_DELAY, // needed to get the statsfile summary .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libtwolame.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libtwolame.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libtwolame.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libtwolame.c 2015-07-28 17:20:07.000000000 +0000 @@ -81,7 +81,7 @@ if (!avctx->bit_rate) avctx->bit_rate = avctx->sample_rate < 28000 ? 160000 : 384000; - if (avctx->flags & CODEC_FLAG_QSCALE || !avctx->bit_rate) { + if (avctx->flags & AV_CODEC_FLAG_QSCALE || !avctx->bit_rate) { twolame_set_VBR(s->glopts, TRUE); twolame_set_VBR_level(s->glopts, avctx->global_quality / (float) FF_QP2LAMBDA); @@ -106,7 +106,7 @@ TWOLAMEContext *s = avctx->priv_data; int ret; - if ((ret = ff_alloc_packet2(avctx, avpkt, MPA_MAX_CODED_FRAME_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, MPA_MAX_CODED_FRAME_SIZE, 0)) < 0) return ret; if (frame) { @@ -211,7 +211,7 @@ .init = twolame_encode_init, .encode2 = twolame_encode_frame, .close = twolame_encode_close, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .defaults = twolame_defaults, .priv_class = &twolame_class, .sample_fmts = (const enum AVSampleFormat[]) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libutvideoenc.cpp ffmpeg-2.7.2~trusty~ppa1/libavcodec/libutvideoenc.cpp --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libutvideoenc.cpp 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libutvideoenc.cpp 2015-08-02 17:20:02.000000000 +0000 @@ -81,7 +81,6 @@ flags = ((avctx->prediction_method + 1) << 8) | (avctx->thread_count - 1); avctx->priv_data = utv; - avctx->coded_frame = av_frame_alloc(); /* Alloc extradata buffer */ info = (UtVideoExtra *)av_malloc(sizeof(*info)); @@ -144,7 +143,7 @@ uint8_t *dst; /* Alloc buffer */ - if ((ret = ff_alloc_packet2(avctx, pkt, utv->buf_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, utv->buf_size, 0)) < 0) return ret; dst = pkt->data; @@ -199,8 +198,6 @@ * assert that this is true. */ av_assert2(keyframe == true); - avctx->coded_frame->key_frame = 1; - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; @@ -211,7 +208,6 @@ { UtVideoContext *utv = (UtVideoContext *)avctx->priv_data; - av_frame_free(&avctx->coded_frame); av_freep(&avctx->extradata); av_freep(&utv->buffer); @@ -226,7 +222,7 @@ NULL_IF_CONFIG_SMALL("Ut Video"), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_UTVIDEO, - CODEC_CAP_AUTO_THREADS | CODEC_CAP_LOSSLESS, + AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_LOSSLESS | AV_CODEC_CAP_INTRA_ONLY, NULL, /* supported_framerates */ (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUYV422, AV_PIX_FMT_BGR24, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvo-aacenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvo-aacenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvo-aacenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvo-aacenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -85,7 +85,7 @@ params.sampleRate = avctx->sample_rate; params.bitRate = avctx->bit_rate; params.nChannels = avctx->channels; - params.adtsUsed = !(avctx->flags & CODEC_FLAG_GLOBAL_HEADER); + params.adtsUsed = !(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER); if (s->codec_api.SetParam(s->handle, VO_PID_AAC_ENCPARAM, ¶ms) != VO_ERR_NONE) { av_log(avctx, AV_LOG_ERROR, "Unable to set encoding parameters\n"); @@ -102,10 +102,10 @@ ret = AVERROR(ENOSYS); goto error; } - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { avctx->extradata_size = 2; avctx->extradata = av_mallocz(avctx->extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { ret = AVERROR(ENOMEM); goto error; @@ -153,7 +153,7 @@ return ret; } - if ((ret = ff_alloc_packet2(avctx, avpkt, FFMAX(8192, 768 * avctx->channels))) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, FFMAX(8192, 768 * avctx->channels), 0)) < 0) return ret; input.Buffer = samples; @@ -194,7 +194,7 @@ .encode2 = aac_encode_frame, .close = aac_encode_close, .supported_samplerates = mpeg4audio_sample_rates, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvo-amrwbenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvo-amrwbenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvo-amrwbenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvo-amrwbenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -115,7 +115,7 @@ const int16_t *samples = (const int16_t *)frame->data[0]; int size, ret; - if ((ret = ff_alloc_packet2(avctx, avpkt, MAX_PACKET_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, MAX_PACKET_SIZE, 0)) < 0) return ret; if (s->last_bitrate != avctx->bit_rate) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvorbisdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvorbisdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvorbisdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvorbisdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -203,5 +203,5 @@ .init = oggvorbis_decode_init, .decode = oggvorbis_decode_frame, .close = oggvorbis_decode_close, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvorbisenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvorbisenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvorbisenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvorbisenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -86,14 +86,14 @@ double cfreq; int ret; - if (avctx->flags & CODEC_FLAG_QSCALE || !avctx->bit_rate) { + if (avctx->flags & AV_CODEC_FLAG_QSCALE || !avctx->bit_rate) { /* variable bitrate * NOTE: we use the oggenc range of -1 to 10 for global_quality for * user convenience, but libvorbis uses -0.1 to 1.0. */ float q = avctx->global_quality / (float)FF_QP2LAMBDA; /* default to 3 if the user did not set quality or bitrate */ - if (!(avctx->flags & CODEC_FLAG_QSCALE)) + if (!(avctx->flags & AV_CODEC_FLAG_QSCALE)) q = 3.0; if ((ret = vorbis_encode_setup_vbr(vi, avctx->channels, avctx->sample_rate, @@ -218,7 +218,7 @@ } vorbis_comment_init(&s->vc); - if (!(avctx->flags & CODEC_FLAG_BITEXACT)) + if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) vorbis_comment_add_tag(&s->vc, "encoder", LIBAVCODEC_IDENT); if ((ret = vorbis_analysis_headerout(&s->vd, &s->vc, &header, &header_comm, @@ -231,7 +231,7 @@ xiph_len(header_comm.bytes) + header_code.bytes; p = avctx->extradata = av_malloc(avctx->extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!p) { ret = AVERROR(ENOMEM); goto error; @@ -338,7 +338,7 @@ av_fifo_generic_read(s->pkt_fifo, &op, sizeof(ogg_packet), NULL); - if ((ret = ff_alloc_packet2(avctx, avpkt, op.bytes)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, op.bytes, 0)) < 0) return ret; av_fifo_generic_read(s->pkt_fifo, avpkt->data, op.bytes, NULL); @@ -372,7 +372,7 @@ .init = libvorbis_encode_init, .encode2 = libvorbis_encode_frame, .close = libvorbis_encode_close, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_SMALL_LAST_FRAME, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, .priv_class = &vorbis_class, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvpx.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvpx.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvpx.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvpx.c 2015-07-28 17:20:07.000000000 +0000 @@ -62,7 +62,7 @@ { if ( vpx_codec_version_major() < 1 || (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3)) - codec->capabilities |= CODEC_CAP_EXPERIMENTAL; + codec->capabilities |= AV_CODEC_CAP_EXPERIMENTAL; codec->pix_fmts = vp9_pix_fmts_def; #if CONFIG_LIBVPX_VP9_ENCODER if ( vpx_codec_version_major() > 1 @@ -77,3 +77,60 @@ } #endif } +#if 0 +enum AVPixelFormat ff_vpx_imgfmt_to_pixfmt(vpx_img_fmt_t img) +{ + switch (img) { + case VPX_IMG_FMT_RGB24: return AV_PIX_FMT_RGB24; + case VPX_IMG_FMT_RGB565: return AV_PIX_FMT_RGB565BE; + case VPX_IMG_FMT_RGB555: return AV_PIX_FMT_RGB555BE; + case VPX_IMG_FMT_UYVY: return AV_PIX_FMT_UYVY422; + case VPX_IMG_FMT_YUY2: return AV_PIX_FMT_YUYV422; + case VPX_IMG_FMT_YVYU: return AV_PIX_FMT_YVYU422; + case VPX_IMG_FMT_BGR24: return AV_PIX_FMT_BGR24; + case VPX_IMG_FMT_ARGB: return AV_PIX_FMT_ARGB; + case VPX_IMG_FMT_ARGB_LE: return AV_PIX_FMT_BGRA; + case VPX_IMG_FMT_RGB565_LE: return AV_PIX_FMT_RGB565LE; + case VPX_IMG_FMT_RGB555_LE: return AV_PIX_FMT_RGB555LE; + case VPX_IMG_FMT_I420: return AV_PIX_FMT_YUV420P; + case VPX_IMG_FMT_I422: return AV_PIX_FMT_YUV422P; + case VPX_IMG_FMT_I444: return AV_PIX_FMT_YUV444P; + case VPX_IMG_FMT_444A: return AV_PIX_FMT_YUVA444P; +#if VPX_IMAGE_ABI_VERSION >= 3 + case VPX_IMG_FMT_I440: return AV_PIX_FMT_YUV440P; + case VPX_IMG_FMT_I42016: return AV_PIX_FMT_YUV420P16BE; + case VPX_IMG_FMT_I42216: return AV_PIX_FMT_YUV422P16BE; + case VPX_IMG_FMT_I44416: return AV_PIX_FMT_YUV444P16BE; +#endif + default: return AV_PIX_FMT_NONE; + } +} + +vpx_img_fmt_t ff_vpx_pixfmt_to_imgfmt(enum AVPixelFormat pix) +{ + switch (pix) { + case AV_PIX_FMT_RGB24: return VPX_IMG_FMT_RGB24; + case AV_PIX_FMT_RGB565BE: return VPX_IMG_FMT_RGB565; + case AV_PIX_FMT_RGB555BE: return VPX_IMG_FMT_RGB555; + case AV_PIX_FMT_UYVY422: return VPX_IMG_FMT_UYVY; + case AV_PIX_FMT_YUYV422: return VPX_IMG_FMT_YUY2; + case AV_PIX_FMT_YVYU422: return VPX_IMG_FMT_YVYU; + case AV_PIX_FMT_BGR24: return VPX_IMG_FMT_BGR24; + case AV_PIX_FMT_ARGB: return VPX_IMG_FMT_ARGB; + case AV_PIX_FMT_BGRA: return VPX_IMG_FMT_ARGB_LE; + case AV_PIX_FMT_RGB565LE: return VPX_IMG_FMT_RGB565_LE; + case AV_PIX_FMT_RGB555LE: return VPX_IMG_FMT_RGB555_LE; + case AV_PIX_FMT_YUV420P: return VPX_IMG_FMT_I420; + case AV_PIX_FMT_YUV422P: return VPX_IMG_FMT_I422; + case AV_PIX_FMT_YUV444P: return VPX_IMG_FMT_I444; + case AV_PIX_FMT_YUVA444P: return VPX_IMG_FMT_444A; +#if VPX_IMAGE_ABI_VERSION >= 3 + case AV_PIX_FMT_YUV440P: return VPX_IMG_FMT_I440; + case AV_PIX_FMT_YUV420P16BE: return VPX_IMG_FMT_I42016; + case AV_PIX_FMT_YUV422P16BE: return VPX_IMG_FMT_I42216; + case AV_PIX_FMT_YUV444P16BE: return VPX_IMG_FMT_I44416; +#endif + default: return VPX_IMG_FMT_NONE; + } +} +#endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvpxdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvpxdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvpxdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvpxdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -62,26 +62,39 @@ // returns 0 on success, AVERROR_INVALIDDATA otherwise static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img) { +#if VPX_IMAGE_ABI_VERSION >= 3 + static const enum AVColorSpace colorspaces[8] = { + AVCOL_SPC_UNSPECIFIED, AVCOL_SPC_BT470BG, AVCOL_SPC_BT709, AVCOL_SPC_SMPTE170M, + AVCOL_SPC_SMPTE240M, AVCOL_SPC_BT2020_NCL, AVCOL_SPC_RESERVED, AVCOL_SPC_RGB, + }; + avctx->colorspace = colorspaces[img->cs]; +#endif if (avctx->codec_id == AV_CODEC_ID_VP8 && img->fmt != VPX_IMG_FMT_I420) return AVERROR_INVALIDDATA; switch (img->fmt) { case VPX_IMG_FMT_I420: + if (avctx->codec_id == AV_CODEC_ID_VP9) + avctx->profile = FF_PROFILE_VP9_0; avctx->pix_fmt = AV_PIX_FMT_YUV420P; return 0; #if CONFIG_LIBVPX_VP9_DECODER case VPX_IMG_FMT_I422: + avctx->profile = FF_PROFILE_VP9_1; avctx->pix_fmt = AV_PIX_FMT_YUV422P; return 0; #if VPX_IMAGE_ABI_VERSION >= 3 case VPX_IMG_FMT_I440: + avctx->profile = FF_PROFILE_VP9_1; avctx->pix_fmt = AV_PIX_FMT_YUV440P; return 0; #endif case VPX_IMG_FMT_I444: + avctx->profile = FF_PROFILE_VP9_1; avctx->pix_fmt = AV_PIX_FMT_YUV444P; return 0; #ifdef VPX_IMG_FMT_HIGHBITDEPTH case VPX_IMG_FMT_I42016: + avctx->profile = FF_PROFILE_VP9_2; if (img->bit_depth == 10) { avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE; return 0; @@ -92,6 +105,7 @@ return AVERROR_INVALIDDATA; } case VPX_IMG_FMT_I42216: + avctx->profile = FF_PROFILE_VP9_3; if (img->bit_depth == 10) { avctx->pix_fmt = AV_PIX_FMT_YUV422P10LE; return 0; @@ -103,6 +117,7 @@ } #if VPX_IMAGE_ABI_VERSION >= 3 case VPX_IMG_FMT_I44016: + avctx->profile = FF_PROFILE_VP9_3; if (img->bit_depth == 10) { avctx->pix_fmt = AV_PIX_FMT_YUV440P10LE; return 0; @@ -114,6 +129,7 @@ } #endif case VPX_IMG_FMT_I44416: + avctx->profile = FF_PROFILE_VP9_3; if (img->bit_depth == 10) { avctx->pix_fmt = AV_PIX_FMT_YUV444P10LE; return 0; @@ -201,7 +217,7 @@ .init = vp8_init, .close = vp8_free, .decode = vp8_decode, - .capabilities = CODEC_CAP_AUTO_THREADS | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_DR1, }; #endif /* CONFIG_LIBVPX_VP8_DECODER */ @@ -211,6 +227,14 @@ return vpx_init(avctx, &vpx_codec_vp9_dx_algo); } +static const AVProfile profiles[] = { + { FF_PROFILE_VP9_0, "Profile 0" }, + { FF_PROFILE_VP9_1, "Profile 1" }, + { FF_PROFILE_VP9_2, "Profile 2" }, + { FF_PROFILE_VP9_3, "Profile 3" }, + { FF_PROFILE_UNKNOWN }, +}; + AVCodec ff_libvpx_vp9_decoder = { .name = "libvpx-vp9", .long_name = NULL_IF_CONFIG_SMALL("libvpx VP9"), @@ -220,7 +244,8 @@ .init = vp9_init, .close = vp8_free, .decode = vp8_decode, - .capabilities = CODEC_CAP_AUTO_THREADS | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_DR1, .init_static_data = ff_vp9_init_static, + .profiles = NULL_IF_CONFIG_SMALL(profiles), }; #endif /* CONFIG_LIBVPX_VP9_DECODER */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvpxenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvpxenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvpxenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvpxenc.c 2015-07-30 17:20:02.000000000 +0000 @@ -91,6 +91,8 @@ int crf; int static_thresh; int max_intra_rate; + int rc_undershoot_pct; + int rc_overshoot_pct; // VP9-only int lossless; @@ -126,6 +128,9 @@ [VP9E_SET_TILE_ROWS] = "VP9E_SET_TILE_ROWS", [VP9E_SET_FRAME_PARALLEL_DECODING] = "VP9E_SET_FRAME_PARALLEL_DECODING", [VP9E_SET_AQ_MODE] = "VP9E_SET_AQ_MODE", +#if VPX_ENCODER_ABI_VERSION > 8 + [VP9E_SET_COLOR_SPACE] = "VP9E_SET_COLOR_SPACE", +#endif #endif }; @@ -260,7 +265,6 @@ if (ctx->is_alpha) vpx_codec_destroy(&ctx->encoder_alpha); av_freep(&ctx->twopass_stats.buf); - av_frame_free(&avctx->coded_frame); av_freep(&avctx->stats_out); free_frame_list(ctx->coded_frame_list); return 0; @@ -347,15 +351,38 @@ av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n"); return AVERROR_INVALIDDATA; } + +#if VPX_ENCODER_ABI_VERSION > 8 +static void set_colorspace(AVCodecContext *avctx) +{ + enum vpx_color_space vpx_cs; + + switch (avctx->colorspace) { + case AVCOL_SPC_RGB: vpx_cs = VPX_CS_SRGB; break; + case AVCOL_SPC_BT709: vpx_cs = VPX_CS_BT_709; break; + case AVCOL_SPC_UNSPECIFIED: vpx_cs = VPX_CS_UNKNOWN; break; + case AVCOL_SPC_RESERVED: vpx_cs = VPX_CS_RESERVED; break; + case AVCOL_SPC_BT470BG: vpx_cs = VPX_CS_BT_601; break; + case AVCOL_SPC_SMPTE170M: vpx_cs = VPX_CS_SMPTE_170; break; + case AVCOL_SPC_SMPTE240M: vpx_cs = VPX_CS_SMPTE_240; break; + case AVCOL_SPC_BT2020_NCL: vpx_cs = VPX_CS_BT_2020; break; + default: + av_log(avctx, AV_LOG_WARNING, "Unsupported colorspace (%d)\n", + avctx->colorspace); + return; + } + codecctl_int(avctx, VP9E_SET_COLOR_SPACE, vpx_cs); +} +#endif #endif static av_cold int vpx_init(AVCodecContext *avctx, const struct vpx_codec_iface *iface) { VP8Context *ctx = avctx->priv_data; - struct vpx_codec_enc_cfg enccfg; + struct vpx_codec_enc_cfg enccfg = { 0 }; struct vpx_codec_enc_cfg enccfg_alpha; - vpx_codec_flags_t flags = (avctx->flags & CODEC_FLAG_PSNR) ? VPX_CODEC_USE_PSNR : 0; + vpx_codec_flags_t flags = (avctx->flags & AV_CODEC_FLAG_PSNR) ? VPX_CODEC_USE_PSNR : 0; int res; vpx_img_fmt_t img_fmt = VPX_IMG_FMT_I420; #if CONFIG_LIBVPX_VP9_ENCODER @@ -396,9 +423,9 @@ enccfg.g_threads = avctx->thread_count; enccfg.g_lag_in_frames= ctx->lag_in_frames; - if (avctx->flags & CODEC_FLAG_PASS1) + if (avctx->flags & AV_CODEC_FLAG_PASS1) enccfg.g_pass = VPX_RC_FIRST_PASS; - else if (avctx->flags & CODEC_FLAG_PASS2) + else if (avctx->flags & AV_CODEC_FLAG_PASS2) enccfg.g_pass = VPX_RC_LAST_PASS; else enccfg.g_pass = VPX_RC_ONE_PASS; @@ -472,7 +499,19 @@ enccfg.rc_buf_initial_sz = avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate; enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6; - enccfg.rc_undershoot_pct = round(avctx->rc_buffer_aggressivity * 100); +#if FF_API_MPV_OPT + FF_DISABLE_DEPRECATION_WARNINGS + if (avctx->rc_buffer_aggressivity != 1.0) { + av_log(avctx, AV_LOG_WARNING, "The rc_buffer_aggressivity option is " + "deprecated, use the undershoot-pct private option instead.\n"); + enccfg.rc_undershoot_pct = round(avctx->rc_buffer_aggressivity * 100); + } + FF_ENABLE_DEPRECATION_WARNINGS +#endif + if (ctx->rc_undershoot_pct >= 0) + enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct; + if (ctx->rc_overshoot_pct >= 0) + enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct; //_enc_init() will balk if kf_min_dist differs from max w/VPX_KF_AUTO if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size) @@ -548,7 +587,8 @@ codecctl_int(avctx, VP8E_SET_ARNR_STRENGTH, ctx->arnr_strength); if (ctx->arnr_type >= 0) codecctl_int(avctx, VP8E_SET_ARNR_TYPE, ctx->arnr_type); - if (avctx->codec_id == AV_CODEC_ID_VP8) { + + if (CONFIG_LIBVPX_VP8_ENCODER && avctx->codec_id == AV_CODEC_ID_VP8) { codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction); codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices)); } @@ -579,6 +619,9 @@ codecctl_int(avctx, VP9E_SET_FRAME_PARALLEL_DECODING, ctx->frame_parallel); if (ctx->aq_mode >= 0) codecctl_int(avctx, VP9E_SET_AQ_MODE, ctx->aq_mode); +#if VPX_ENCODER_ABI_VERSION > 8 + set_colorspace(avctx); +#endif } #endif @@ -596,12 +639,6 @@ vpx_img_wrap(&ctx->rawimg_alpha, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1, (unsigned char*)1); - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) { - av_log(avctx, AV_LOG_ERROR, "Error allocating coded frame\n"); - vp8_free(avctx); - return AVERROR(ENOMEM); - } return 0; } @@ -648,31 +685,54 @@ * @return a negative AVERROR on error */ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, - AVPacket *pkt, AVFrame *coded_frame) + AVPacket *pkt) { - int ret = ff_alloc_packet2(avctx, pkt, cx_frame->sz); + int ret = ff_alloc_packet2(avctx, pkt, cx_frame->sz, 0); uint8_t *side_data; if (ret >= 0) { + int pict_type; memcpy(pkt->data, cx_frame->buf, pkt->size); - pkt->pts = pkt->dts = cx_frame->pts; - coded_frame->pts = cx_frame->pts; - coded_frame->key_frame = !!(cx_frame->flags & VPX_FRAME_IS_KEY); - - if (coded_frame->key_frame) { - coded_frame->pict_type = AV_PICTURE_TYPE_I; - pkt->flags |= AV_PKT_FLAG_KEY; - } else - coded_frame->pict_type = AV_PICTURE_TYPE_P; + pkt->pts = pkt->dts = cx_frame->pts; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->pts = cx_frame->pts; + avctx->coded_frame->key_frame = !!(cx_frame->flags & VPX_FRAME_IS_KEY); +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + if (!!(cx_frame->flags & VPX_FRAME_IS_KEY)) { + pict_type = AV_PICTURE_TYPE_I; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->pict_type = pict_type; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + pkt->flags |= AV_PKT_FLAG_KEY; + } else { + pict_type = AV_PICTURE_TYPE_P; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->pict_type = pict_type; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + } + + ff_side_data_set_encoder_stats(pkt, 0, cx_frame->sse + 1, + cx_frame->have_sse ? 3 : 0, pict_type); if (cx_frame->have_sse) { int i; /* Beware of the Y/U/V/all order! */ - coded_frame->error[0] = cx_frame->sse[1]; - coded_frame->error[1] = cx_frame->sse[2]; - coded_frame->error[2] = cx_frame->sse[3]; - coded_frame->error[3] = 0; // alpha - for (i = 0; i < 4; ++i) { - avctx->error[i] += coded_frame->error[i]; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->error[0] = cx_frame->sse[1]; + avctx->coded_frame->error[1] = cx_frame->sse[2]; + avctx->coded_frame->error[2] = cx_frame->sse[3]; + avctx->coded_frame->error[3] = 0; // alpha +FF_ENABLE_DEPRECATION_WARNINGS +#endif + for (i = 0; i < 3; ++i) { + avctx->error[i] += cx_frame->sse[i + 1]; } cx_frame->have_sse = 0; } @@ -702,8 +762,7 @@ * @return AVERROR(EINVAL) on output size error * @return AVERROR(ENOMEM) on coded frame queue data allocation error */ -static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out, - AVFrame *coded_frame) +static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out) { VP8Context *ctx = avctx->priv_data; const struct vpx_codec_cx_pkt *pkt; @@ -715,7 +774,7 @@ if (ctx->coded_frame_list) { struct FrameListData *cx_frame = ctx->coded_frame_list; /* return the leading frame if we've already begun queueing */ - size = storeframe(avctx, cx_frame, pkt_out, coded_frame); + size = storeframe(avctx, cx_frame, pkt_out); if (size < 0) return size; ctx->coded_frame_list = cx_frame->next; @@ -736,7 +795,7 @@ provided a frame for output */ av_assert0(!ctx->coded_frame_list); cx_pktcpy(&cx_frame, pkt, pkt_alpha, ctx); - size = storeframe(avctx, &cx_frame, pkt_out, coded_frame); + size = storeframe(avctx, &cx_frame, pkt_out); if (size < 0) return size; } else { @@ -863,9 +922,9 @@ } } - coded_size = queue_frames(avctx, pkt, avctx->coded_frame); + coded_size = queue_frames(avctx, pkt); - if (!frame && avctx->flags & CODEC_FLAG_PASS1) { + if (!frame && avctx->flags & AV_CODEC_FLAG_PASS1) { unsigned int b64_size = AV_BASE64_SIZE(ctx->twopass_stats.sz); avctx->stats_out = av_malloc(b64_size); @@ -920,6 +979,8 @@ " is still done over the partition boundary.", 0, AV_OPT_TYPE_CONST, {.i64 = VPX_ERROR_RESILIENT_PARTITIONS}, 0, 0, VE, "er"}, \ { "crf", "Select the quality for constant quality mode", offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE }, \ { "static-thresh", "A change threshold on blocks below which they will be skipped by the encoder", OFFSET(static_thresh), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, \ + { "undershoot-pct", "Datarate undershoot (min) target (%)", OFFSET(rc_undershoot_pct), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 100, VE }, \ + { "overshoot-pct", "Datarate overshoot (max) target (%)", OFFSET(rc_overshoot_pct), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1000, VE }, \ #define LEGACY_OPTIONS \ {"speed", "", offsetof(VP8Context, cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE}, \ @@ -948,10 +1009,10 @@ { "tile-rows", "Number of tile rows to use, log2", OFFSET(tile_rows), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE}, { "frame-parallel", "Enable frame parallel decodability features", OFFSET(frame_parallel), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE}, { "aq-mode", "adaptive quantization mode", OFFSET(aq_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 3, VE, "aq_mode"}, - { "none", "Aq not used", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, "aq_mode" }, \ - { "variance", "Variance based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "aq_mode" }, \ - { "complexity", "Complexity based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "aq_mode" }, \ - { "cyclic", "Cyclic Refresh Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, "aq_mode" }, \ + { "none", "Aq not used", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, "aq_mode" }, + { "variance", "Variance based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "aq_mode" }, + { "complexity", "Complexity based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "aq_mode" }, + { "cyclic", "Cyclic Refresh Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, "aq_mode" }, LEGACY_OPTIONS { NULL } }; @@ -990,7 +1051,7 @@ .init = vp8_init, .encode2 = vp8_encode, .close = vp8_free, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE }, .priv_class = &class_vp8, .defaults = defaults, @@ -1010,6 +1071,14 @@ .version = LIBAVUTIL_VERSION_INT, }; +static const AVProfile profiles[] = { + { FF_PROFILE_VP9_0, "Profile 0" }, + { FF_PROFILE_VP9_1, "Profile 1" }, + { FF_PROFILE_VP9_2, "Profile 2" }, + { FF_PROFILE_VP9_3, "Profile 3" }, + { FF_PROFILE_UNKNOWN }, +}; + AVCodec ff_libvpx_vp9_encoder = { .name = "libvpx-vp9", .long_name = NULL_IF_CONFIG_SMALL("libvpx VP9"), @@ -1019,7 +1088,8 @@ .init = vp9_init, .encode2 = vp8_encode, .close = vp8_free, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS, + .profiles = NULL_IF_CONFIG_SMALL(profiles), .priv_class = &class_vp9, .defaults = defaults, .init_static_data = ff_vp9_init_static, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvpx.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvpx.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libvpx.h 2015-06-18 18:54:58.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libvpx.h 2015-07-10 17:20:03.000000000 +0000 @@ -21,8 +21,14 @@ #ifndef AVCODEC_LIBVPX_H #define AVCODEC_LIBVPX_H +#include + #include "avcodec.h" void ff_vp9_init_static(AVCodec *codec); +#if 0 +enum AVPixelFormat ff_vpx_imgfmt_to_pixfmt(vpx_img_fmt_t img); +vpx_img_fmt_t ff_vpx_pixfmt_to_imgfmt(enum AVPixelFormat pix); +#endif #endif /* AVCODEC_LIBVPX_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libwavpackenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libwavpackenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libwavpackenc.c 2015-03-15 02:45:59.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libwavpackenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -188,7 +188,7 @@ .init = wavpack_encode_init, .encode2 = wavpack_encode_frame, .close = wavpack_encode_close, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_SMALL_LAST_FRAME, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libwebpenc_animencoder.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libwebpenc_animencoder.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libwebpenc_animencoder.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libwebpenc_animencoder.c 2015-08-03 17:20:02.000000000 +0000 @@ -66,7 +66,7 @@ WebPData assembled_data = { 0 }; ret = WebPAnimEncoderAssemble(s->enc, &assembled_data); if (ret) { - ret = ff_alloc_packet(pkt, assembled_data.size); + ret = ff_alloc_packet2(avctx, pkt, assembled_data.size, assembled_data.size); if (ret < 0) return ret; memcpy(pkt->data, assembled_data.bytes, assembled_data.size); @@ -139,7 +139,7 @@ .init = libwebp_anim_encode_init, .encode2 = libwebp_anim_encode_frame, .close = libwebp_anim_encode_close, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB32, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libwebpenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libwebpenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libwebpenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libwebpenc.c 2015-08-03 17:20:02.000000000 +0000 @@ -57,7 +57,7 @@ goto end; } - ret = ff_alloc_packet(pkt, mw.size); + ret = ff_alloc_packet2(avctx, pkt, mw.size, mw.size); if (ret < 0) goto end; memcpy(pkt->data, mw.mem, mw.size); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libx264.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libx264.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libx264.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libx264.c 2015-08-01 17:20:02.000000000 +0000 @@ -81,6 +81,7 @@ char *stats; int nal_hrd; int avcintra_class; + int motion_est; char *x264_params; } X264Context; @@ -113,7 +114,7 @@ for (i = 0; i < nnal; i++) size += nals[i].i_payload; - if ((ret = ff_alloc_packet2(ctx, pkt, size)) < 0) + if ((ret = ff_alloc_packet2(ctx, pkt, size, 0)) < 0) return ret; p = pkt->data; @@ -158,6 +159,94 @@ } } +static void reconfig_encoder(AVCodecContext *ctx, const AVFrame *frame) +{ + X264Context *x4 = ctx->priv_data; + AVFrameSideData *side_data; + + + if (x4->avcintra_class < 0) { + if (x4->params.b_interlaced && x4->params.b_tff != frame->top_field_first) { + + x4->params.b_tff = frame->top_field_first; + x264_encoder_reconfig(x4->enc, &x4->params); + } + if (x4->params.vui.i_sar_height*ctx->sample_aspect_ratio.num != ctx->sample_aspect_ratio.den * x4->params.vui.i_sar_width) { + x4->params.vui.i_sar_height = ctx->sample_aspect_ratio.den; + x4->params.vui.i_sar_width = ctx->sample_aspect_ratio.num; + x264_encoder_reconfig(x4->enc, &x4->params); + } + + if (x4->params.rc.i_vbv_buffer_size != ctx->rc_buffer_size / 1000 || + x4->params.rc.i_vbv_max_bitrate != ctx->rc_max_rate / 1000) { + x4->params.rc.i_vbv_buffer_size = ctx->rc_buffer_size / 1000; + x4->params.rc.i_vbv_max_bitrate = ctx->rc_max_rate / 1000; + x264_encoder_reconfig(x4->enc, &x4->params); + } + + if (x4->params.rc.i_rc_method == X264_RC_ABR && + x4->params.rc.i_bitrate != ctx->bit_rate / 1000) { + x4->params.rc.i_bitrate = ctx->bit_rate / 1000; + x264_encoder_reconfig(x4->enc, &x4->params); + } + + if (x4->crf >= 0 && + x4->params.rc.i_rc_method == X264_RC_CRF && + x4->params.rc.f_rf_constant != x4->crf) { + x4->params.rc.f_rf_constant = x4->crf; + x264_encoder_reconfig(x4->enc, &x4->params); + } + + if (x4->params.rc.i_rc_method == X264_RC_CQP && + x4->cqp >= 0 && + x4->params.rc.i_qp_constant != x4->cqp) { + x4->params.rc.i_qp_constant = x4->cqp; + x264_encoder_reconfig(x4->enc, &x4->params); + } + + if (x4->crf_max >= 0 && + x4->params.rc.f_rf_constant_max != x4->crf_max) { + x4->params.rc.f_rf_constant_max = x4->crf_max; + x264_encoder_reconfig(x4->enc, &x4->params); + } + } + + side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_STEREO3D); + if (side_data) { + AVStereo3D *stereo = (AVStereo3D *)side_data->data; + int fpa_type; + + switch (stereo->type) { + case AV_STEREO3D_CHECKERBOARD: + fpa_type = 0; + break; + case AV_STEREO3D_COLUMNS: + fpa_type = 1; + break; + case AV_STEREO3D_LINES: + fpa_type = 2; + break; + case AV_STEREO3D_SIDEBYSIDE: + fpa_type = 3; + break; + case AV_STEREO3D_TOPBOTTOM: + fpa_type = 4; + break; + case AV_STEREO3D_FRAMESEQUENCE: + fpa_type = 5; + break; + default: + fpa_type = -1; + break; + } + + if (fpa_type != x4->params.i_frame_packing) { + x4->params.i_frame_packing = fpa_type; + x264_encoder_reconfig(x4->enc, &x4->params); + } + } +} + static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { @@ -165,7 +254,7 @@ x264_nal_t *nal; int nnal, i, ret; x264_picture_t pic_out = {0}; - AVFrameSideData *side_data; + int pict_type; x264_picture_init( &x4->pic ); x4->pic.img.i_csp = x4->params.i_csp; @@ -186,85 +275,7 @@ frame->pict_type == AV_PICTURE_TYPE_B ? X264_TYPE_B : X264_TYPE_AUTO; - if (x4->avcintra_class < 0) { - if (x4->params.b_interlaced && x4->params.b_tff != frame->top_field_first) { - x4->params.b_tff = frame->top_field_first; - x264_encoder_reconfig(x4->enc, &x4->params); - } - if (x4->params.vui.i_sar_height*ctx->sample_aspect_ratio.num != ctx->sample_aspect_ratio.den * x4->params.vui.i_sar_width) { - x4->params.vui.i_sar_height = ctx->sample_aspect_ratio.den; - x4->params.vui.i_sar_width = ctx->sample_aspect_ratio.num; - x264_encoder_reconfig(x4->enc, &x4->params); - } - - if (x4->params.rc.i_vbv_buffer_size != ctx->rc_buffer_size / 1000 || - x4->params.rc.i_vbv_max_bitrate != ctx->rc_max_rate / 1000) { - x4->params.rc.i_vbv_buffer_size = ctx->rc_buffer_size / 1000; - x4->params.rc.i_vbv_max_bitrate = ctx->rc_max_rate / 1000; - x264_encoder_reconfig(x4->enc, &x4->params); - } - - if (x4->params.rc.i_rc_method == X264_RC_ABR && - x4->params.rc.i_bitrate != ctx->bit_rate / 1000) { - x4->params.rc.i_bitrate = ctx->bit_rate / 1000; - x264_encoder_reconfig(x4->enc, &x4->params); - } - - if (x4->crf >= 0 && - x4->params.rc.i_rc_method == X264_RC_CRF && - x4->params.rc.f_rf_constant != x4->crf) { - x4->params.rc.f_rf_constant = x4->crf; - x264_encoder_reconfig(x4->enc, &x4->params); - } - - if (x4->params.rc.i_rc_method == X264_RC_CQP && - x4->cqp >= 0 && - x4->params.rc.i_qp_constant != x4->cqp) { - x4->params.rc.i_qp_constant = x4->cqp; - x264_encoder_reconfig(x4->enc, &x4->params); - } - - if (x4->crf_max >= 0 && - x4->params.rc.f_rf_constant_max != x4->crf_max) { - x4->params.rc.f_rf_constant_max = x4->crf_max; - x264_encoder_reconfig(x4->enc, &x4->params); - } - } - - side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_STEREO3D); - if (side_data) { - AVStereo3D *stereo = (AVStereo3D *)side_data->data; - int fpa_type; - - switch (stereo->type) { - case AV_STEREO3D_CHECKERBOARD: - fpa_type = 0; - break; - case AV_STEREO3D_COLUMNS: - fpa_type = 1; - break; - case AV_STEREO3D_LINES: - fpa_type = 2; - break; - case AV_STEREO3D_SIDEBYSIDE: - fpa_type = 3; - break; - case AV_STEREO3D_TOPBOTTOM: - fpa_type = 4; - break; - case AV_STEREO3D_FRAMESEQUENCE: - fpa_type = 5; - break; - default: - fpa_type = -1; - break; - } - - if (fpa_type != x4->params.i_frame_packing) { - x4->params.i_frame_packing = fpa_type; - x264_encoder_reconfig(x4->enc, &x4->params); - } - } + reconfig_encoder(ctx, frame); } do { if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0) @@ -278,23 +289,38 @@ pkt->pts = pic_out.i_pts; pkt->dts = pic_out.i_dts; + switch (pic_out.i_type) { case X264_TYPE_IDR: case X264_TYPE_I: - ctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; + pict_type = AV_PICTURE_TYPE_I; break; case X264_TYPE_P: - ctx->coded_frame->pict_type = AV_PICTURE_TYPE_P; + pict_type = AV_PICTURE_TYPE_P; break; case X264_TYPE_B: case X264_TYPE_BREF: - ctx->coded_frame->pict_type = AV_PICTURE_TYPE_B; + pict_type = AV_PICTURE_TYPE_B; break; + default: + pict_type = AV_PICTURE_TYPE_NONE; } +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + ctx->coded_frame->pict_type = pict_type; +FF_ENABLE_DEPRECATION_WARNINGS +#endif pkt->flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe; - if (ret) + if (ret) { + ff_side_data_set_encoder_stats(pkt, (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA, NULL, 0, pict_type); + +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS ctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + } *got_packet = ret; return 0; @@ -312,8 +338,6 @@ x4->enc = NULL; } - av_frame_free(&avctx->coded_frame); - return 0; } @@ -357,6 +381,9 @@ case AV_PIX_FMT_NV12: return X264_CSP_NV12; case AV_PIX_FMT_NV16: case AV_PIX_FMT_NV20: return X264_CSP_NV16; +#ifdef X264_CSP_NV21 + case AV_PIX_FMT_NV21: return X264_CSP_NV21; +#endif }; return 0; } @@ -375,9 +402,15 @@ if (avctx->global_quality > 0) av_log(avctx, AV_LOG_WARNING, "-qscale is ignored, -crf is recommended.\n"); +#if CONFIG_LIBX262_ENCODER + if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO) { + x4->params.b_mpeg2 = 1; + x264_param_default_mpeg2(&x4->params); + } else +#endif x264_param_default(&x4->params); - x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER; + x4->params.b_deblocking_filter = avctx->flags & AV_CODEC_FLAG_LOOP_FILTER; if (x4->preset || x4->tune) if (x264_param_default_preset(&x4->params, x4->preset, x4->tune) < 0) { @@ -410,8 +443,8 @@ } x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000; x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000; - x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1; - if (avctx->flags & CODEC_FLAG_PASS2) { + x4->params.rc.b_stat_write = avctx->flags & AV_CODEC_FLAG_PASS1; + if (avctx->flags & AV_CODEC_FLAG_PASS2) { x4->params.rc.b_stat_read = 1; } else { if (x4->crf >= 0) { @@ -441,17 +474,6 @@ if (avctx->chromaoffset) x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset; - if (avctx->me_method == ME_EPZS) - x4->params.analyse.i_me_method = X264_ME_DIA; - else if (avctx->me_method == ME_HEX) - x4->params.analyse.i_me_method = X264_ME_HEX; - else if (avctx->me_method == ME_UMH) - x4->params.analyse.i_me_method = X264_ME_UMH; - else if (avctx->me_method == ME_FULL) - x4->params.analyse.i_me_method = X264_ME_ESA; - else if (avctx->me_method == ME_TESA) - x4->params.analyse.i_me_method = X264_ME_TESA; - if (avctx->gop_size >= 0) x4->params.i_keyint_max = avctx->gop_size; if (avctx->max_b_frames >= 0) @@ -604,6 +626,25 @@ if (x4->nal_hrd >= 0) x4->params.i_nal_hrd = x4->nal_hrd; + if (x4->motion_est >= 0) { + x4->params.analyse.i_me_method = x4->motion_est; +#if FF_API_MOTION_EST +FF_DISABLE_DEPRECATION_WARNINGS + } else { + if (avctx->me_method == ME_EPZS) + x4->params.analyse.i_me_method = X264_ME_DIA; + else if (avctx->me_method == ME_HEX) + x4->params.analyse.i_me_method = X264_ME_HEX; + else if (avctx->me_method == ME_UMH) + x4->params.analyse.i_me_method = X264_ME_UMH; + else if (avctx->me_method == ME_FULL) + x4->params.analyse.i_me_method = X264_ME_ESA; + else if (avctx->me_method == ME_TESA) + x4->params.analyse.i_me_method = X264_ME_TESA; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + } + if (x4->profile) if (x264_param_apply_profile(&x4->params, x4->profile) < 0) { int i; @@ -625,15 +666,15 @@ x4->params.i_fps_num = avctx->time_base.den; x4->params.i_fps_den = avctx->time_base.num * avctx->ticks_per_frame; - x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR; + x4->params.analyse.b_psnr = avctx->flags & AV_CODEC_FLAG_PSNR; x4->params.i_threads = avctx->thread_count; if (avctx->thread_type) x4->params.b_sliced_threads = avctx->thread_type == FF_THREAD_SLICE; - x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT; + x4->params.b_interlaced = avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT; - x4->params.b_open_gop = !(avctx->flags & CODEC_FLAG_CLOSED_GOP); + x4->params.b_open_gop = !(avctx->flags & AV_CODEC_FLAG_CLOSED_GOP); x4->params.i_slice_count = avctx->slices; @@ -649,7 +690,7 @@ if (avctx->color_trc != AVCOL_TRC_UNSPECIFIED) x4->params.vui.i_transfer = avctx->color_trc; - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) x4->params.b_repeat_headers = 0; if(x4->x264opts){ @@ -693,11 +734,7 @@ if (!x4->enc) return AVERROR_EXTERNAL; - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { x264_nal_t *nal; uint8_t *p; int nnal, s, i; @@ -736,6 +773,9 @@ AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_NV12, AV_PIX_FMT_NV16, +#ifdef X264_CSP_NV21 + AV_PIX_FMT_NV21, +#endif AV_PIX_FMT_NONE }; static const enum AVPixelFormat pix_fmts_9bit[] = { @@ -829,24 +869,16 @@ { "vbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_VBR}, INT_MIN, INT_MAX, VE, "nal-hrd" }, { "cbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_CBR}, INT_MIN, INT_MAX, VE, "nal-hrd" }, { "avcintra-class","AVC-Intra class 50/100/200", OFFSET(avcintra_class),AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 200 , VE}, + { "motion-est", "Set motion estimation method", OFFSET(motion_est), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, X264_ME_TESA, VE, "motion-est"}, + { "dia", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_DIA }, INT_MIN, INT_MAX, VE, "motion-est" }, + { "hex", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_HEX }, INT_MIN, INT_MAX, VE, "motion-est" }, + { "umh", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_UMH }, INT_MIN, INT_MAX, VE, "motion-est" }, + { "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" }, + { "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" }, { "x264-params", "Override the x264 configuration using a :-separated list of key=value parameters", OFFSET(x264_params), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE }, { NULL }, }; -static const AVClass x264_class = { - .class_name = "libx264", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; - -static const AVClass rgbclass = { - .class_name = "libx264rgb", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; - static const AVCodecDefault x264_defaults[] = { { "b", "0" }, { "bf", "-1" }, @@ -865,7 +897,9 @@ { "trellis", "-1" }, { "nr", "-1" }, { "me_range", "-1" }, +#if FF_API_MOTION_EST { "me_method", "-1" }, +#endif { "subq", "-1" }, { "b_strategy", "-1" }, { "keyint_min", "-1" }, @@ -878,6 +912,21 @@ { NULL }, }; +#if CONFIG_LIBX264_ENCODER +static const AVClass x264_class = { + .class_name = "libx264", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const AVClass rgbclass = { + .class_name = "libx264rgb", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_libx264_encoder = { .name = "libx264", .long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), @@ -887,7 +936,7 @@ .init = X264_init, .encode2 = X264_frame, .close = X264_close, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS, .priv_class = &x264_class, .defaults = x264_defaults, .init_static_data = X264_init_static, @@ -904,8 +953,35 @@ .init = X264_init, .encode2 = X264_frame, .close = X264_close, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS, .priv_class = &rgbclass, .defaults = x264_defaults, .pix_fmts = pix_fmts_8bit_rgb, }; +#endif + +#if CONFIG_LIBX262_ENCODER +static const AVClass X262_class = { + .class_name = "libx262", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +AVCodec ff_libx262_encoder = { + .name = "libx262", + .long_name = NULL_IF_CONFIG_SMALL("libx262 MPEG2VIDEO"), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_MPEG2VIDEO, + .priv_data_size = sizeof(X264Context), + .init = X264_init, + .encode2 = X264_frame, + .close = X264_close, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS, + .priv_class = &X262_class, + .defaults = x264_defaults, + .pix_fmts = pix_fmts_8bit, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_INIT_CLEANUP, +}; +#endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libx265.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libx265.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libx265.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libx265.c 2015-07-28 17:20:07.000000000 +0000 @@ -66,8 +66,6 @@ { libx265Context *ctx = avctx->priv_data; - av_frame_free(&avctx->coded_frame); - ctx->api->param_free(ctx->params); if (ctx->encoder) @@ -92,12 +90,6 @@ return AVERROR(ENOSYS); } - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) { - av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n"); - return AVERROR(ENOMEM); - } - ctx->params = ctx->api->param_alloc(); if (!ctx->params) { av_log(avctx, AV_LOG_ERROR, "Could not allocate x265 param structure.\n"); @@ -127,7 +119,7 @@ ctx->params->fpsDenom = avctx->time_base.num * avctx->ticks_per_frame; ctx->params->sourceWidth = avctx->width; ctx->params->sourceHeight = avctx->height; - ctx->params->bEnablePsnr = !!(avctx->flags & CODEC_FLAG_PSNR); + ctx->params->bEnablePsnr = !!(avctx->flags & AV_CODEC_FLAG_PSNR); if ((avctx->color_primaries <= AVCOL_PRI_BT2020 && avctx->color_primaries != AVCOL_PRI_UNSPECIFIED) || @@ -187,7 +179,7 @@ ctx->params->rc.rateControlMode = X265_RC_ABR; } - if (!(avctx->flags & CODEC_FLAG_GLOBAL_HEADER)) + if (!(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) ctx->params->bRepeatHeaders = 1; if (ctx->x265_opts) { @@ -222,7 +214,7 @@ return AVERROR_INVALIDDATA; } - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { x265_nal *nal; int nnal; @@ -233,7 +225,7 @@ return AVERROR_INVALIDDATA; } - avctx->extradata = av_malloc(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_malloc(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate HEVC header of size %d.\n", avctx->extradata_size); @@ -306,6 +298,8 @@ pkt->pts = x265pic_out.pts; pkt->dts = x265pic_out.dts; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS switch (x265pic_out.sliceType) { case X265_TYPE_IDR: case X265_TYPE_I: @@ -318,6 +312,8 @@ avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B; break; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif *got_packet = 1; return 0; @@ -382,5 +378,5 @@ .priv_data_size = sizeof(libx265Context), .priv_class = &class, .defaults = x265_defaults, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libxavs.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libxavs.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libxavs.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libxavs.c 2015-07-28 17:20:07.000000000 +0000 @@ -53,6 +53,7 @@ int direct_pred; int aud; int fast_pskip; + int motion_est; int mbtree; int mixed_refs; @@ -80,7 +81,7 @@ { XavsContext *x4 = ctx->priv_data; uint8_t *p; - int i, s, ret, size = x4->sei_size + FF_MIN_BUFFER_SIZE; + int i, s, ret, size = x4->sei_size + AV_INPUT_BUFFER_MIN_SIZE; if (!nnal) return 0; @@ -88,7 +89,7 @@ for (i = 0; i < nnal; i++) size += nals[i].i_payload; - if ((ret = ff_alloc_packet2(ctx, pkt, size)) < 0) + if ((ret = ff_alloc_packet2(ctx, pkt, size, 0)) < 0) return ret; p = pkt->data; @@ -117,6 +118,7 @@ xavs_nal_t *nal; int nnal, i, ret; xavs_picture_t pic_out; + int pict_type; x4->pic.img.i_csp = XAVS_CSP_I420; x4->pic.img.i_plane = 3; @@ -143,7 +145,7 @@ if (!ret) { if (!frame && !(x4->end_of_stream)) { - if ((ret = ff_alloc_packet2(avctx, pkt, 4)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, 4, 0)) < 0) return ret; pkt->data[0] = 0x0; @@ -158,7 +160,11 @@ return 0; } +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pts = pic_out.i_pts; +FF_ENABLE_DEPRECATION_WARNINGS +#endif pkt->pts = pic_out.i_pts; if (avctx->has_b_frames) { if (!x4->out_frame_count) @@ -171,25 +177,42 @@ switch (pic_out.i_type) { case XAVS_TYPE_IDR: case XAVS_TYPE_I: - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; + pict_type = AV_PICTURE_TYPE_I; break; case XAVS_TYPE_P: - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P; + pict_type = AV_PICTURE_TYPE_P; break; case XAVS_TYPE_B: case XAVS_TYPE_BREF: - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B; + pict_type = AV_PICTURE_TYPE_B; break; + default: + pict_type = AV_PICTURE_TYPE_NONE; } +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->pict_type = pict_type; +FF_ENABLE_DEPRECATION_WARNINGS +#endif /* There is no IDR frame in AVS JiZhun */ /* Sequence header is used as a flag */ if (pic_out.i_type == XAVS_TYPE_I) { +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif pkt->flags |= AV_PKT_FLAG_KEY; } +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + ff_side_data_set_encoder_stats(pkt, (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA, NULL, 0, pict_type); x4->out_frame_count++; *got_packet = ret; @@ -207,8 +230,6 @@ if (x4->enc) xavs_encoder_close(x4->enc); - av_frame_free(&avctx->coded_frame); - return 0; } @@ -228,8 +249,8 @@ } x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000; x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000; - x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1; - if (avctx->flags & CODEC_FLAG_PASS2) { + x4->params.rc.b_stat_write = avctx->flags & AV_CODEC_FLAG_PASS1; + if (avctx->flags & AV_CODEC_FLAG_PASS2) { x4->params.rc.b_stat_read = 1; } else { if (x4->crf >= 0) { @@ -249,6 +270,8 @@ x4->params.analyse.i_direct_mv_pred = x4->direct_pred; if (x4->fast_pskip >= 0) x4->params.analyse.b_fast_pskip = x4->fast_pskip; + if (x4->motion_est >= 0) + x4->params.analyse.i_me_method = x4->motion_est; if (x4->mixed_refs >= 0) x4->params.analyse.b_mixed_references = x4->mixed_refs; if (x4->b_bias != INT_MIN) @@ -256,6 +279,32 @@ if (x4->cplxblur >= 0) x4->params.rc.f_complexity_blur = x4->cplxblur; +#if FF_API_MOTION_EST +FF_DISABLE_DEPRECATION_WARNINGS + if (x4->motion_est < 0) { + switch (avctx->me_method) { + case ME_EPZS: + x4->params.analyse.i_me_method = XAVS_ME_DIA; + break; + case ME_HEX: + x4->params.analyse.i_me_method = XAVS_ME_HEX; + break; + case ME_UMH: + x4->params.analyse.i_me_method = XAVS_ME_UMH; + break; + case ME_FULL: + x4->params.analyse.i_me_method = XAVS_ME_ESA; + break; + case ME_TESA: + x4->params.analyse.i_me_method = XAVS_ME_TESA; + break; + default: + x4->params.analyse.i_me_method = XAVS_ME_HEX; + } + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + x4->params.i_bframe = avctx->max_b_frames; /* cabac is not included in AVS JiZhun Profile */ x4->params.b_cabac = 0; @@ -272,7 +321,7 @@ x4->params.i_scenecut_threshold = avctx->scenechange_threshold; - // x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER; + // x4->params.b_deblocking_filter = avctx->flags & AV_CODEC_FLAG_LOOP_FILTER; x4->params.rc.i_qp_min = avctx->qmin; x4->params.rc.i_qp_max = avctx->qmax; @@ -292,32 +341,12 @@ x4->params.i_fps_den = avctx->time_base.num; x4->params.analyse.inter = XAVS_ANALYSE_I8x8 |XAVS_ANALYSE_PSUB16x16| XAVS_ANALYSE_BSUB16x16; - switch (avctx->me_method) { - case ME_EPZS: - x4->params.analyse.i_me_method = XAVS_ME_DIA; - break; - case ME_HEX: - x4->params.analyse.i_me_method = XAVS_ME_HEX; - break; - case ME_UMH: - x4->params.analyse.i_me_method = XAVS_ME_UMH; - break; - case ME_FULL: - x4->params.analyse.i_me_method = XAVS_ME_ESA; - break; - case ME_TESA: - x4->params.analyse.i_me_method = XAVS_ME_TESA; - break; - default: - x4->params.analyse.i_me_method = XAVS_ME_HEX; - } - x4->params.analyse.i_me_range = avctx->me_range; x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA; /* AVS P2 only enables 8x8 transform */ - x4->params.analyse.b_transform_8x8 = 1; //avctx->flags2 & CODEC_FLAG2_8X8DCT; + x4->params.analyse.b_transform_8x8 = 1; //avctx->flags2 & AV_CODEC_FLAG2_8X8DCT; x4->params.analyse.i_trellis = avctx->trellis; x4->params.analyse.i_noise_reduction = avctx->noise_reduction; @@ -342,12 +371,12 @@ x4->params.rc.f_pb_factor = avctx->b_quant_factor; x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset; - x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR; + x4->params.analyse.b_psnr = avctx->flags & AV_CODEC_FLAG_PSNR; x4->params.i_log_level = XAVS_LOG_DEBUG; x4->params.i_threads = avctx->thread_count; - x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT; + x4->params.b_interlaced = avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT; - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) x4->params.b_repeat_headers = 0; x4->enc = xavs_encoder_open(&x4->params); @@ -357,13 +386,9 @@ if (!(x4->pts_buffer = av_mallocz_array((avctx->max_b_frames+1), sizeof(*x4->pts_buffer)))) return AVERROR(ENOMEM); - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - /* TAG: Do we have GLOBAL HEADER in AVS */ /* We Have PPS and SPS in AVS */ - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER && 0) { + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER && 0) { xavs_nal_t *nal; int nnal, s, i, size; uint8_t *p; @@ -406,6 +431,13 @@ { "mbtree", "Use macroblock tree ratecontrol.", OFFSET(mbtree), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 1, VE}, { "mixed-refs", "One reference per partition, as opposed to one reference per macroblock", OFFSET(mixed_refs), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE }, { "fast-pskip", NULL, OFFSET(fast_pskip), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 1, VE}, + { "motion-est", "Set motion estimation method", OFFSET(motion_est), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, XAVS_ME_TESA, VE, "motion-est"}, + { "dia", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_DIA }, INT_MIN, INT_MAX, VE, "motion-est" }, + { "hex", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_HEX }, INT_MIN, INT_MAX, VE, "motion-est" }, + { "umh", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_UMH }, INT_MIN, INT_MAX, VE, "motion-est" }, + { "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" }, + { "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" }, + { NULL }, }; @@ -430,7 +462,7 @@ .init = XAVS_init, .encode2 = XAVS_frame, .close = XAVS_close, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, .priv_class = &xavs_class, .defaults = xavs_defaults, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libxvid.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libxvid.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libxvid.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libxvid.c 2015-07-28 17:20:07.000000000 +0000 @@ -77,6 +77,7 @@ int ssim; /**< SSIM information display mode */ int ssim_acc; /**< SSIM accuracy. 0: accurate. 4: fast. */ int gmc; + int me_quality; /**< Motion estimation quality. 0: fast 6: best. */ }; /** @@ -381,37 +382,56 @@ /* Bring in VOP flags from ffmpeg command-line */ x->vop_flags = XVID_VOP_HALFPEL; /* Bare minimum quality */ - if (xvid_flags & CODEC_FLAG_4MV) + if (xvid_flags & AV_CODEC_FLAG_4MV) x->vop_flags |= XVID_VOP_INTER4V; /* Level 3 */ if (avctx->trellis) x->vop_flags |= XVID_VOP_TRELLISQUANT; /* Level 5 */ - if (xvid_flags & CODEC_FLAG_AC_PRED) + if (xvid_flags & AV_CODEC_FLAG_AC_PRED) x->vop_flags |= XVID_VOP_HQACPRED; /* Level 6 */ - if (xvid_flags & CODEC_FLAG_GRAY) + if (xvid_flags & AV_CODEC_FLAG_GRAY) x->vop_flags |= XVID_VOP_GREYSCALE; /* Decide which ME quality setting to use */ x->me_flags = 0; - switch (avctx->me_method) { - case ME_FULL: /* Quality 6 */ + switch (x->me_quality) { + case 6: + case 5: x->me_flags |= XVID_ME_EXTSEARCH16 | XVID_ME_EXTSEARCH8; - - case ME_EPZS: /* Quality 4 */ + case 4: + case 3: x->me_flags |= XVID_ME_ADVANCEDDIAMOND8 | XVID_ME_HALFPELREFINE8 | XVID_ME_CHROMA_PVOP | XVID_ME_CHROMA_BVOP; - - case ME_LOG: /* Quality 2 */ - case ME_PHODS: - case ME_X1: + case 2: + case 1: x->me_flags |= XVID_ME_ADVANCEDDIAMOND16 | XVID_ME_HALFPELREFINE16; - - case ME_ZERO: /* Quality 0 */ - default: +#if FF_API_MOTION_EST +FF_DISABLE_DEPRECATION_WARNINGS break; + default: + switch (avctx->me_method) { + case ME_FULL: /* Quality 6 */ + x->me_flags |= XVID_ME_EXTSEARCH16 | + XVID_ME_EXTSEARCH8; + case ME_EPZS: /* Quality 4 */ + x->me_flags |= XVID_ME_ADVANCEDDIAMOND8 | + XVID_ME_HALFPELREFINE8 | + XVID_ME_CHROMA_PVOP | + XVID_ME_CHROMA_BVOP; + case ME_LOG: /* Quality 2 */ + case ME_PHODS: + case ME_X1: + x->me_flags |= XVID_ME_ADVANCEDDIAMOND16 | + XVID_ME_HALFPELREFINE16; + case ME_ZERO: /* Quality 0 */ + default: + break; + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif } /* Decide how we should decide blocks */ @@ -442,7 +462,7 @@ x->vol_flags |= XVID_VOL_GMC; x->me_flags |= XVID_ME_GME_REFINE; } - if (xvid_flags & CODEC_FLAG_QPEL) { + if (xvid_flags & AV_CODEC_FLAG_QPEL) { x->vol_flags |= XVID_VOL_QUARTERPEL; x->me_flags |= XVID_ME_QUARTERPELREFINE16; if (x->vop_flags & XVID_VOP_INTER4V) @@ -494,7 +514,7 @@ x->old_twopassbuffer = NULL; x->twopassfile = NULL; - if (xvid_flags & CODEC_FLAG_PASS1) { + if (xvid_flags & AV_CODEC_FLAG_PASS1) { rc2pass1.version = XVID_VERSION; rc2pass1.context = x; x->twopassbuffer = av_malloc(BUFFER_SIZE); @@ -510,7 +530,7 @@ plugins[xvid_enc_create.num_plugins].func = xvid_ff_2pass; plugins[xvid_enc_create.num_plugins].param = &rc2pass1; xvid_enc_create.num_plugins++; - } else if (xvid_flags & CODEC_FLAG_PASS2) { + } else if (xvid_flags & AV_CODEC_FLAG_PASS2) { rc2pass2.version = XVID_VERSION; rc2pass2.bitrate = avctx->bit_rate; @@ -541,7 +561,7 @@ plugins[xvid_enc_create.num_plugins].func = xvid_plugin_2pass2; plugins[xvid_enc_create.num_plugins].param = &rc2pass2; xvid_enc_create.num_plugins++; - } else if (!(xvid_flags & CODEC_FLAG_QSCALE)) { + } else if (!(xvid_flags & AV_CODEC_FLAG_QSCALE)) { /* Single Pass Bitrate Control! */ single.version = XVID_VERSION; single.bitrate = avctx->bit_rate; @@ -600,7 +620,7 @@ xvid_enc_create.max_key_interval = 240; /* Xvid's best default */ /* Quants */ - if (xvid_flags & CODEC_FLAG_QSCALE) + if (xvid_flags & AV_CODEC_FLAG_QSCALE) x->qscale = 1; else x->qscale = 0; @@ -646,13 +666,13 @@ /* Misc Settings */ xvid_enc_create.frame_drop_ratio = 0; xvid_enc_create.global = 0; - if (xvid_flags & CODEC_FLAG_CLOSED_GOP) + if (xvid_flags & AV_CODEC_FLAG_CLOSED_GOP) xvid_enc_create.global |= XVID_GLOBAL_CLOSED_GOP; /* Determines which codec mode we are operating in */ avctx->extradata = NULL; avctx->extradata_size = 0; - if (xvid_flags & CODEC_FLAG_GLOBAL_HEADER) { + if (xvid_flags & AV_CODEC_FLAG_GLOBAL_HEADER) { /* In this case, we are claiming to be MPEG4 */ x->quicktime_format = 1; avctx->codec_id = AV_CODEC_ID_MPEG4; @@ -680,9 +700,6 @@ } x->encoder_handle = xvid_enc_create.handle; - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); return 0; } @@ -692,7 +709,6 @@ { int xerr, i, ret, user_packet = !!pkt->data; struct xvid_context *x = avctx->priv_data; - AVFrame *p = avctx->coded_frame; int mb_width = (avctx->width + 15) / 16; int mb_height = (avctx->height + 15) / 16; char *tmp; @@ -700,7 +716,7 @@ xvid_enc_frame_t xvid_enc_frame = { 0 }; xvid_enc_stats_t xvid_enc_stats = { 0 }; - if ((ret = ff_alloc_packet2(avctx, pkt, mb_width*(int64_t)mb_height*MAX_MB_BYTES + FF_MIN_BUFFER_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, mb_width*(int64_t)mb_height*MAX_MB_BYTES + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return ret; /* Start setting up the frame */ @@ -775,25 +791,45 @@ } if (xerr > 0) { + int pict_type; + *got_packet = 1; - p->quality = xvid_enc_stats.quant * FF_QP2LAMBDA; if (xvid_enc_stats.type == XVID_TYPE_PVOP) - p->pict_type = AV_PICTURE_TYPE_P; + pict_type = AV_PICTURE_TYPE_P; else if (xvid_enc_stats.type == XVID_TYPE_BVOP) - p->pict_type = AV_PICTURE_TYPE_B; + pict_type = AV_PICTURE_TYPE_B; else if (xvid_enc_stats.type == XVID_TYPE_SVOP) - p->pict_type = AV_PICTURE_TYPE_S; + pict_type = AV_PICTURE_TYPE_S; else - p->pict_type = AV_PICTURE_TYPE_I; + pict_type = AV_PICTURE_TYPE_I; + +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->pict_type = pict_type; + avctx->coded_frame->quality = xvid_enc_stats.quant * FF_QP2LAMBDA; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + ff_side_data_set_encoder_stats(pkt, xvid_enc_stats.quant * FF_QP2LAMBDA, NULL, 0, pict_type); + if (xvid_enc_frame.out_flags & XVID_KEYFRAME) { - p->key_frame = 1; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif pkt->flags |= AV_PKT_FLAG_KEY; if (x->quicktime_format) return xvid_strip_vol_header(avctx, pkt, xvid_enc_stats.hlength, xerr); - } else - p->key_frame = 0; + } else { +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->key_frame = 0; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + } pkt->size = xerr; @@ -818,7 +854,6 @@ x->encoder_handle = NULL; } - av_frame_free(&avctx->coded_frame); av_freep(&avctx->extradata); if (x->twopassbuffer) { av_freep(&x->twopassbuffer); @@ -848,6 +883,7 @@ { "frame", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "ssim" }, { "ssim_acc", "SSIM accuracy", OFFSET(ssim_acc), AV_OPT_TYPE_INT, { .i64 = 2 }, 0, 4, VE }, { "gmc", "use GMC", OFFSET(gmc), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, + { "me_quality", "Motion estimation quality", OFFSET(me_quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 6, VE }, { NULL }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/libzvbi-teletextdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/libzvbi-teletextdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/libzvbi-teletextdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/libzvbi-teletextdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -565,7 +565,7 @@ .init = teletext_init_decoder, .close = teletext_close_decoder, .decode = teletext_decode_frame, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .flush = teletext_flush, .priv_class= &teletext_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ljpegenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ljpegenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ljpegenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ljpegenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -217,7 +217,7 @@ const int height = avctx->height; const int mb_width = (width + s->hsample[0] - 1) / s->hsample[0]; const int mb_height = (height + s->vsample[0] - 1) / s->vsample[0]; - int max_pkt_size = FF_MIN_BUFFER_SIZE; + int max_pkt_size = AV_INPUT_BUFFER_MIN_SIZE; int ret, header_bits; if( avctx->pix_fmt == AV_PIX_FMT_BGR0 @@ -229,7 +229,7 @@ * s->hsample[0] * s->vsample[0]; } - if ((ret = ff_alloc_packet2(avctx, pkt, max_pkt_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, max_pkt_size, 0)) < 0) return ret; init_put_bits(&pb, pkt->data, pkt->size); @@ -265,7 +265,6 @@ { LJpegEncContext *s = avctx->priv_data; - av_frame_free(&avctx->coded_frame); av_freep(&s->scratch); return 0; @@ -286,12 +285,12 @@ return AVERROR(EINVAL); } - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch)); if (!s->scratch) @@ -327,7 +326,7 @@ .init = ljpeg_encode_init, .encode2 = ljpeg_encode_frame, .close = ljpeg_encode_close, - .capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY, + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24 , AV_PIX_FMT_BGRA , AV_PIX_FMT_BGR0, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/loco.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/loco.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/loco.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/loco.c 2015-07-28 17:20:07.000000000 +0000 @@ -330,5 +330,5 @@ .priv_data_size = sizeof(LOCOContext), .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/lpc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/lpc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/lpc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/lpc.c 2015-07-07 17:20:03.000000000 +0000 @@ -37,13 +37,19 @@ double w; double c; - /* The optimization in commit fa4ed8c does not support odd len. - * If someone wants odd len extend that change. */ - av_assert2(!(len & 1)); - n2 = (len >> 1); c = 2.0 / (len - 1.0); + if (len & 1) { + for(i=0; i #include "libavutil/avassert.h" #include "libavutil/lls.h" +#include "aac_defines.h" #define ORDER_METHOD_EST 0 #define ORDER_METHOD_2LEVEL 1 @@ -111,11 +112,15 @@ */ void ff_lpc_end(LPCContext *s); +#if USE_FIXED +#define LPC_TYPE int +#else #ifdef LPC_USE_DOUBLE #define LPC_TYPE double #else #define LPC_TYPE float #endif +#endif // USE_FIXED /** * Schur recursion. @@ -152,7 +157,7 @@ * Levinson-Durbin recursion. * Produce LPC coefficients from autocorrelation data. */ -static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order, +static inline int AAC_RENAME(compute_lpc_coefs)(const LPC_TYPE *autoc, int max_order, LPC_TYPE *lpc, int lpc_stride, int fail, int normalize) { @@ -169,14 +174,14 @@ return -1; for(i=0; i>1; j++) { LPC_TYPE f = lpc_last[ j]; LPC_TYPE b = lpc_last[i-1-j]; - lpc[ j] = f + r * b; - lpc[i-1-j] = b + r * f; + lpc[ j] = f + AAC_MUL26(r, b); + lpc[i-1-j] = b + AAC_MUL26(r, f); } if (fail && err < 0) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mace.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mace.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mace.c 2015-06-18 18:54:58.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mace.c 2015-07-28 17:20:07.000000000 +0000 @@ -292,7 +292,7 @@ .priv_data_size = sizeof(MACEContext), .init = mace_decode_init, .decode = mace_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, }; @@ -305,7 +305,7 @@ .priv_data_size = sizeof(MACEContext), .init = mace_decode_init, .decode = mace_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/Makefile ffmpeg-2.7.2~trusty~ppa1/libavcodec/Makefile --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/Makefile 2015-06-19 20:44:36.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/Makefile 2015-08-03 17:20:02.000000000 +0000 @@ -13,6 +13,7 @@ vda.h \ vdpau.h \ version.h \ + videotoolbox.h \ vorbis_parser.h \ xvmc.h \ @@ -56,6 +57,7 @@ OBJS-$(CONFIG_FFT) += avfft.o fft_fixed.o fft_float.o \ fft_fixed_32.o fft_init_table.o \ $(FFT-OBJS-yes) +OBJS-$(CONFIG_FLACDSP) += flacdsp.o OBJS-$(CONFIG_FMTCONVERT) += fmtconvert.o OBJS-$(CONFIG_GOLOMB) += golomb.o OBJS-$(CONFIG_H263DSP) += h263dsp.o @@ -71,6 +73,7 @@ OBJS-$(CONFIG_IIRFILTER) += iirfilter.o OBJS-$(CONFIG_IMDCT15) += imdct15.o OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o +OBJS-$(CONFIG_IVIDSP) += ivi_dsp.o OBJS-$(CONFIG_JPEGTABLES) += jpegtables.o OBJS-$(CONFIG_LIBXVID) += libxvid_rc.o OBJS-$(CONFIG_LLAUDDSP) += lossless_audiodsp.o @@ -88,10 +91,11 @@ mpegaudiodsp_float.o OBJS-$(CONFIG_MPEGVIDEO) += mpegvideo.o mpegvideodsp.o rl.o \ mpegvideo_motion.o mpegutils.o \ - mpegvideodata.o + mpegvideodata.o mpegpicture.o OBJS-$(CONFIG_MPEGVIDEOENC) += mpegvideo_enc.o mpeg12data.o \ motion_est.o ratecontrol.o \ mpegvideoencdsp.o +OBJS-$(CONFIG_MSS34DSP) += mss34dsp.o OBJS-$(CONFIG_NVENC) += nvenc.o OBJS-$(CONFIG_PIXBLOCKDSP) += pixblockdsp.o OBJS-$(CONFIG_QPELDSP) += qpeldsp.o @@ -101,21 +105,31 @@ OBJS-$(CONFIG_RANGECODER) += rangecoder.o RDFT-OBJS-$(CONFIG_HARDCODED_TABLES) += sin_tables.o OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes) +OBJS-$(CONFIG_RV34DSP) += rv34dsp.o OBJS-$(CONFIG_SHARED) += log2_tab.o -OBJS-$(CONFIG_SINEWIN) += sinewin.o +OBJS-$(CONFIG_SINEWIN) += sinewin.o sinewin_fixed.o +OBJS-$(CONFIG_SNAPPY) += snappy.o OBJS-$(CONFIG_STARTCODE) += startcode.o +OBJS-$(CONFIG_TEXTUREDSP) += texturedsp.o +OBJS-$(CONFIG_TEXTUREDSPENC) += texturedspenc.o OBJS-$(CONFIG_TPELDSP) += tpeldsp.o OBJS-$(CONFIG_VIDEODSP) += videodsp.o OBJS-$(CONFIG_VP3DSP) += vp3dsp.o +OBJS-$(CONFIG_VP56DSP) += vp56dsp.o +OBJS-$(CONFIG_VP8DSP) += vp8dsp.o OBJS-$(CONFIG_WMA_FREQS) += wma_freqs.o +OBJS-$(CONFIG_WMV2DSP) += wmv2dsp.o # decoders/encoders OBJS-$(CONFIG_ZERO12V_DECODER) += 012v.o OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o -OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \ +OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps_float.o \ aacadtsdec.o mpeg4audio.o kbdwin.o \ - sbrdsp.o aacpsdsp.o + sbrdsp.o aacpsdsp_float.o +OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o aacps_fixed.o \ + aacadtsdec.o mpeg4audio.o kbdwin.o \ + sbrdsp_fixed.o aacpsdsp_fixed.o OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \ aacpsy.o aactab.o \ psymodel.o mpeg4audio.o kbdwin.o @@ -202,6 +216,7 @@ dcadata.o dca_exss.o \ dca_xll.o synth_filter.o OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dca.o dcadata.o +OBJS-$(CONFIG_DDS_DECODER) += dds.o OBJS-$(CONFIG_DIRAC_DECODER) += diracdec.o dirac.o diracdsp.o \ dirac_arith.o mpeg12data.o dirac_dwt.o OBJS-$(CONFIG_DFA_DECODER) += dfa.o @@ -243,8 +258,8 @@ OBJS-$(CONFIG_FFV1_ENCODER) += ffv1enc.o ffv1.o OBJS-$(CONFIG_FFWAVESYNTH_DECODER) += ffwavesynth.o OBJS-$(CONFIG_FIC_DECODER) += fic.o -OBJS-$(CONFIG_FLAC_DECODER) += flacdec.o flacdata.o flac.o flacdsp.o -OBJS-$(CONFIG_FLAC_ENCODER) += flacenc.o flacdata.o flac.o flacdsp.o vorbis_data.o +OBJS-$(CONFIG_FLAC_DECODER) += flacdec.o flacdata.o flac.o +OBJS-$(CONFIG_FLAC_ENCODER) += flacenc.o flacdata.o flac.o vorbis_data.o OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o OBJS-$(CONFIG_FLASHSV2_ENCODER) += flashsv2enc.o @@ -253,7 +268,7 @@ OBJS-$(CONFIG_FOURXM_DECODER) += 4xm.o OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o OBJS-$(CONFIG_FRWU_DECODER) += frwu.o -OBJS-$(CONFIG_G2M_DECODER) += g2meet.o +OBJS-$(CONFIG_G2M_DECODER) += g2meet.o elsdec.o OBJS-$(CONFIG_G723_1_DECODER) += g723_1.o acelp_vectors.o \ celp_filters.o celp_math.o OBJS-$(CONFIG_G723_1_ENCODER) += g723_1.o acelp_vectors.o celp_math.o @@ -266,7 +281,7 @@ OBJS-$(CONFIG_H261_ENCODER) += h261enc.o h261data.o h261.o OBJS-$(CONFIG_H263_DECODER) += h263dec.o h263.o ituh263dec.o \ mpeg4video.o mpeg4videodec.o flvdec.o\ - intelh263dec.o + intelh263dec.o h263data.o OBJS-$(CONFIG_H263_ENCODER) += mpeg4videoenc.o mpeg4video.o \ h263.o ituh263enc.o flvenc.o OBJS-$(CONFIG_H264_DECODER) += h264.o h264_cabac.o h264_cavlc.o \ @@ -275,11 +290,15 @@ h264_refs.o h264_sei.o h264_slice.o OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o OBJS-$(CONFIG_H264_VDA_DECODER) += vda_h264_dec.o -OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec_h264.o +OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec_h2645.o OBJS-$(CONFIG_H264_QSV_ENCODER) += qsvenc_h264.o +OBJS-$(CONFIG_HAP_DECODER) += hapdec.o hap.o +OBJS-$(CONFIG_HAP_ENCODER) += hapenc.o hap.o OBJS-$(CONFIG_HEVC_DECODER) += hevc.o hevc_mvs.o hevc_ps.o hevc_sei.o \ hevc_cabac.o hevc_refs.o hevcpred.o \ - hevcdsp.o hevc_filter.o + hevcdsp.o hevc_filter.o hevc_parse.o hevc_data.o +OBJS-$(CONFIG_HEVC_QSV_DECODER) += qsvdec_h2645.o +OBJS-$(CONFIG_HEVC_QSV_ENCODER) += qsvenc_hevc.o hevc_ps_enc.o hevc_parse.o OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadata.o hq_hqadsp.o \ canopus.o @@ -293,8 +312,8 @@ OBJS-$(CONFIG_IMC_DECODER) += imc.o OBJS-$(CONFIG_INDEO2_DECODER) += indeo2.o OBJS-$(CONFIG_INDEO3_DECODER) += indeo3.o -OBJS-$(CONFIG_INDEO4_DECODER) += indeo4.o ivi.o ivi_dsp.o -OBJS-$(CONFIG_INDEO5_DECODER) += indeo5.o ivi.o ivi_dsp.o +OBJS-$(CONFIG_INDEO4_DECODER) += indeo4.o ivi.o +OBJS-$(CONFIG_INDEO5_DECODER) += indeo5.o ivi.o OBJS-$(CONFIG_INTERPLAY_DPCM_DECODER) += dpcm.o OBJS-$(CONFIG_INTERPLAY_VIDEO_DECODER) += interplayvideo.o OBJS-$(CONFIG_JACOSUB_DECODER) += jacosubdec.o ass.o @@ -346,6 +365,8 @@ OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o +OBJS-$(CONFIG_MPEG2_QSV_DECODER) += qsvdec_mpeg2.o +OBJS-$(CONFIG_MPEG2_QSV_ENCODER) += qsvenc_mpeg2.o OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o OBJS-$(CONFIG_MPL2_DECODER) += mpl2dec.o ass.o OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o @@ -354,13 +375,13 @@ OBJS-$(CONFIG_MSMPEG4V3_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o OBJS-$(CONFIG_MSMPEG4V3_ENCODER) += msmpeg4enc.o msmpeg4.o msmpeg4data.o OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o msrledec.o -OBJS-$(CONFIG_MSA1_DECODER) += mss3.o mss34dsp.o +OBJS-$(CONFIG_MSA1_DECODER) += mss3.o OBJS-$(CONFIG_MSS1_DECODER) += mss1.o mss12.o OBJS-$(CONFIG_MSS2_DECODER) += mss2.o mss12.o mss2dsp.o OBJS-$(CONFIG_MSVIDEO1_DECODER) += msvideo1.o OBJS-$(CONFIG_MSVIDEO1_ENCODER) += msvideo1enc.o elbg.o OBJS-$(CONFIG_MSZH_DECODER) += lcldec.o -OBJS-$(CONFIG_MTS2_DECODER) += mss4.o mss34dsp.o +OBJS-$(CONFIG_MTS2_DECODER) += mss4.o OBJS-$(CONFIG_MVC1_DECODER) += mvcdec.o OBJS-$(CONFIG_MVC2_DECODER) += mvcdec.o OBJS-$(CONFIG_MXPEG_DECODER) += mxpegdec.o @@ -424,8 +445,8 @@ OBJS-$(CONFIG_RV10_ENCODER) += rv10enc.o OBJS-$(CONFIG_RV20_DECODER) += rv10.o OBJS-$(CONFIG_RV20_ENCODER) += rv20enc.o -OBJS-$(CONFIG_RV30_DECODER) += rv30.o rv34.o rv30dsp.o rv34dsp.o -OBJS-$(CONFIG_RV40_DECODER) += rv40.o rv34.o rv34dsp.o rv40dsp.o +OBJS-$(CONFIG_RV30_DECODER) += rv30.o rv34.o rv30dsp.o +OBJS-$(CONFIG_RV40_DECODER) += rv40.o rv34.o rv40dsp.o OBJS-$(CONFIG_SAMI_DECODER) += samidec.o ass.o OBJS-$(CONFIG_S302M_DECODER) += s302m.o OBJS-$(CONFIG_S302M_ENCODER) += s302menc.o @@ -482,7 +503,7 @@ OBJS-$(CONFIG_TTA_DECODER) += tta.o ttadata.o ttadsp.o OBJS-$(CONFIG_TTA_ENCODER) += ttaenc.o ttadata.o OBJS-$(CONFIG_TWINVQ_DECODER) += twinvqdec.o twinvq.o -OBJS-$(CONFIG_TXD_DECODER) += txd.o s3tc.o +OBJS-$(CONFIG_TXD_DECODER) += txd.o OBJS-$(CONFIG_ULTI_DECODER) += ulti.o OBJS-$(CONFIG_UTVIDEO_DECODER) += utvideodec.o utvideo.o OBJS-$(CONFIG_UTVIDEO_ENCODER) += utvideoenc.o utvideo.o @@ -502,6 +523,7 @@ vc1dsp.o \ msmpeg4dec.o msmpeg4.o msmpeg4data.o \ wmv2dsp.o +OBJS-$(CONFIG_VC1_QSV_DECODER) += qsvdec_vc1.o OBJS-$(CONFIG_VCR1_DECODER) += vcr1.o OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdaudio.o OBJS-$(CONFIG_VMDVIDEO_DECODER) += vmdvideo.o @@ -511,12 +533,11 @@ OBJS-$(CONFIG_VORBIS_ENCODER) += vorbisenc.o vorbis.o \ vorbis_data.o OBJS-$(CONFIG_VP3_DECODER) += vp3.o -OBJS-$(CONFIG_VP5_DECODER) += vp5.o vp56.o vp56data.o vp56dsp.o \ - vp56rac.o -OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o vp56dsp.o \ +OBJS-$(CONFIG_VP5_DECODER) += vp5.o vp56.o vp56data.o vp56rac.o +OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o \ vp6dsp.o vp56rac.o -OBJS-$(CONFIG_VP7_DECODER) += vp8.o vp8dsp.o vp56rac.o -OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp8dsp.o vp56rac.o +OBJS-$(CONFIG_VP7_DECODER) += vp8.o vp56rac.o +OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp56rac.o OBJS-$(CONFIG_VP9_DECODER) += vp9.o vp9dsp.o vp56rac.o vp9dsp_8bpp.o \ vp9dsp_10bpp.o vp9dsp_12bpp.o OBJS-$(CONFIG_VPLAYER_DECODER) += textdec.o ass.o @@ -538,9 +559,9 @@ acelp_vectors.o acelp_filters.o OBJS-$(CONFIG_WMV1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o OBJS-$(CONFIG_WMV1_ENCODER) += msmpeg4enc.o -OBJS-$(CONFIG_WMV2_DECODER) += wmv2dec.o wmv2.o wmv2dsp.o \ +OBJS-$(CONFIG_WMV2_DECODER) += wmv2dec.o wmv2.o \ msmpeg4dec.o msmpeg4.o msmpeg4data.o -OBJS-$(CONFIG_WMV2_ENCODER) += wmv2enc.o wmv2.o wmv2dsp.o \ +OBJS-$(CONFIG_WMV2_ENCODER) += wmv2enc.o wmv2.o \ msmpeg4.o msmpeg4enc.o msmpeg4data.o OBJS-$(CONFIG_WNV1_DECODER) += wnv1.o OBJS-$(CONFIG_WS_SND1_DECODER) += ws-snd1.o @@ -676,27 +697,34 @@ OBJS-$(CONFIG_D3D11VA) += dxva2.o OBJS-$(CONFIG_DXVA2) += dxva2.o OBJS-$(CONFIG_VAAPI) += vaapi.o -OBJS-$(CONFIG_VDA) += vda.o +OBJS-$(CONFIG_VDA) += vda.o videotoolbox.o +OBJS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.o OBJS-$(CONFIG_VDPAU) += vdpau.o OBJS-$(CONFIG_H263_VAAPI_HWACCEL) += vaapi_mpeg4.o OBJS-$(CONFIG_H263_VDPAU_HWACCEL) += vdpau_mpeg4.o +OBJS-$(CONFIG_H263_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o OBJS-$(CONFIG_H264_D3D11VA_HWACCEL) += dxva2_h264.o OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o OBJS-$(CONFIG_H264_VDA_HWACCEL) += vda_h264.o OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o +OBJS-$(CONFIG_H264_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o +OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL) += vdpau_mpeg12.o +OBJS-$(CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o OBJS-$(CONFIG_MPEG1_XVMC_HWACCEL) += mpegvideo_xvmc.o OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL) += dxva2_mpeg2.o OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL) += vdpau_mpeg12.o +OBJS-$(CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o OBJS-$(CONFIG_MPEG2_XVMC_HWACCEL) += mpegvideo_xvmc.o OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL) += vaapi_mpeg4.o OBJS-$(CONFIG_MPEG4_VDPAU_HWACCEL) += vdpau_mpeg4.o +OBJS-$(CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o OBJS-$(CONFIG_VC1_D3D11VA_HWACCEL) += dxva2_vc1.o OBJS-$(CONFIG_VC1_DXVA2_HWACCEL) += dxva2_vc1.o OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o @@ -757,6 +785,7 @@ OBJS-$(CONFIG_LIBGSM_MS_ENCODER) += libgsmenc.o OBJS-$(CONFIG_LIBILBC_DECODER) += libilbc.o OBJS-$(CONFIG_LIBILBC_ENCODER) += libilbc.o +OBJS-$(CONFIG_LIBKVAZAAR_ENCODER) += libkvazaar.o OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o mpegaudiodecheader.o OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER) += libopencore-amr.o OBJS-$(CONFIG_LIBOPENCORE_AMRNB_ENCODER) += libopencore-amr.o @@ -792,6 +821,7 @@ OBJS-$(CONFIG_LIBWAVPACK_ENCODER) += libwavpackenc.o OBJS-$(CONFIG_LIBWEBP_ENCODER) += libwebpenc_common.o libwebpenc.o OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER) += libwebpenc_common.o libwebpenc_animencoder.o +OBJS-$(CONFIG_LIBX262_ENCODER) += libx264.o OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o OBJS-$(CONFIG_LIBX265_ENCODER) += libx265.o OBJS-$(CONFIG_LIBXAVS_ENCODER) += libxavs.o @@ -821,7 +851,7 @@ OBJS-$(CONFIG_H261_PARSER) += h261_parser.o OBJS-$(CONFIG_H263_PARSER) += h263_parser.o OBJS-$(CONFIG_H264_PARSER) += h264_parser.o -OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o +OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_parse.o hevc_ps.o hevc_data.o OBJS-$(CONFIG_MJPEG_PARSER) += mjpeg_parser.o OBJS-$(CONFIG_MLP_PARSER) += mlp_parser.o mlp.o OBJS-$(CONFIG_MPEG4VIDEO_PARSER) += mpeg4video_parser.o h263.o \ @@ -849,6 +879,7 @@ OBJS-$(CONFIG_CHOMP_BSF) += chomp_bsf.o OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF) += h264_mp4toannexb_bsf.o +OBJS-$(CONFIG_HEVC_MP4TOANNEXB_BSF) += hevc_mp4toannexb_bsf.o OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF) += imx_dump_header_bsf.o OBJS-$(CONFIG_MJPEG2JPEG_BSF) += mjpeg2jpeg_bsf.o OBJS-$(CONFIG_MJPEGA_DUMP_HEADER_BSF) += mjpega_dump_header_bsf.o @@ -888,16 +919,16 @@ SKIPHEADERS-$(CONFIG_QSVENC) += qsvenc.h SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h -SKIPHEADERS-$(CONFIG_VDA) += vda.h vda_internal.h +SKIPHEADERS-$(CONFIG_VDA) += vda.h vda_vt_internal.h SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h +SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vda_vt_internal.h TESTPROGS = imgconvert \ + jpeg2000dwt \ mathops \ options \ avfft \ -TESTPROGS += api-flac - TESTPROGS-$(CONFIG_CABAC) += cabac TESTPROGS-$(CONFIG_FFT) += fft fft-fixed fft-fixed32 TESTPROGS-$(CONFIG_IDCTDSP) += dct @@ -913,9 +944,12 @@ HOSTPROGS = aac_tablegen \ aacps_tablegen \ + aacps_fixed_tablegen \ aacsbr_tablegen \ + aacsbr_fixed_tablegen \ cabac_tablegen \ cbrt_tablegen \ + cbrt_fixed_tablegen \ cos_tablegen \ dsd_tablegen \ dv_tablegen \ @@ -924,6 +958,7 @@ pcm_tablegen \ qdm2_tablegen \ sinewin_tablegen \ + sinewin_fixed_tablegen \ CLEANFILES = *_tables.c *_tables.h *_tablegen$(HOSTEXESUF) @@ -942,8 +977,9 @@ $(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=0 endif -GEN_HEADERS = cabac_tables.h cbrt_tables.h aacps_tables.h aacsbr_tables.h aac_tables.h dsd_tables.h dv_tables.h \ - sinewin_tables.h mpegaudio_tables.h motionpixels_tables.h \ +GEN_HEADERS = cabac_tables.h cbrt_tables.h cbrt_fixed_tables.h aacps_tables.h aacps_fixed_tables.h aacsbr_tables.h \ + aacsbr_fixed_tables.h aac_tables.h dsd_tables.h dv_tables.h \ + sinewin_tables.h sinewin_fixed_tables.h mpegaudio_tables.h motionpixels_tables.h \ pcm_tables.h qdm2_tables.h GEN_HEADERS := $(addprefix $(SUBDIR), $(GEN_HEADERS)) @@ -952,13 +988,18 @@ ifdef CONFIG_HARDCODED_TABLES $(SUBDIR)aacdec.o: $(SUBDIR)cbrt_tables.h -$(SUBDIR)aacps.o: $(SUBDIR)aacps_tables.h +$(SUBDIR)aacdec_fixed.o: $(SUBDIR)cbrt_fixed_tables.h +$(SUBDIR)aacps_float.o: $(SUBDIR)aacps_tables.h +$(SUBDIR)aacps_fixed.o: $(SUBDIR)aacps_fixed_tables.h $(SUBDIR)aacsbr.o: $(SUBDIR)aacsbr_tables.h +$(SUBDIR)aacsbr_fixed.o: $(SUBDIR)aacsbr_fixed_tables.h $(SUBDIR)aactab.o: $(SUBDIR)aac_tables.h +$(SUBDIR)aactab_fixed.o: $(SUBDIR)aac_fixed_tables.h $(SUBDIR)cabac.o: $(SUBDIR)cabac_tables.h $(SUBDIR)dsddec.o: $(SUBDIR)dsd_tables.h $(SUBDIR)dvenc.o: $(SUBDIR)dv_tables.h $(SUBDIR)sinewin.o: $(SUBDIR)sinewin_tables.h +$(SUBDIR)sinewin_fixed.o: $(SUBDIR)sinewin_fixed_tables.h $(SUBDIR)mpegaudiodec_fixed.o: $(SUBDIR)mpegaudio_tables.h $(SUBDIR)mpegaudiodec_float.o: $(SUBDIR)mpegaudio_tables.h $(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mdct_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mdct_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mdct_template.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mdct_template.c 2015-07-09 17:20:03.000000000 +0000 @@ -81,8 +81,13 @@ scale = sqrt(fabs(scale)); for(i=0;itcos[i*tstep] = (FFTSample)floor(-cos(alpha) * 2147483648.0 + 0.5); + s->tsin[i*tstep] = (FFTSample)floor(-sin(alpha) * 2147483648.0 + 0.5); +#else s->tcos[i*tstep] = FIX15(-cos(alpha) * scale); s->tsin[i*tstep] = FIX15(-sin(alpha) * scale); +#endif } return 0; fail: diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -160,7 +160,7 @@ a->idsp.idct_put(dest_y + 8 * linesize, linesize, block[2]); a->idsp.idct_put(dest_y + 8 * linesize + 8, linesize, block[3]); - if (!(a->avctx->flags & CODEC_FLAG_GRAY)) { + if (!(a->avctx->flags & AV_CODEC_FLAG_GRAY)) { a->idsp.idct_put(dest_cb, frame->linesize[1], block[4]); a->idsp.idct_put(dest_cr, frame->linesize[2], block[5]); } @@ -262,6 +262,6 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy) }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/me_cmp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/me_cmp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/me_cmp.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/me_cmp.c 2015-07-06 17:20:03.000000000 +0000 @@ -991,4 +991,6 @@ ff_me_cmp_init_ppc(c, avctx); if (ARCH_X86) ff_me_cmp_init_x86(c, avctx); + if (ARCH_MIPS) + ff_me_cmp_init_mips(c, avctx); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/me_cmp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/me_cmp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/me_cmp.h 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/me_cmp.h 2015-07-06 17:20:03.000000000 +0000 @@ -87,6 +87,7 @@ void ff_me_cmp_init_arm(MECmpContext *c, AVCodecContext *avctx); void ff_me_cmp_init_ppc(MECmpContext *c, AVCodecContext *avctx); void ff_me_cmp_init_x86(MECmpContext *c, AVCodecContext *avctx); +void ff_me_cmp_init_mips(MECmpContext *c, AVCodecContext *avctx); void ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/metasound.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/metasound.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/metasound.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/metasound.c 2015-07-28 17:20:07.000000000 +0000 @@ -383,7 +383,7 @@ .init = metasound_decode_init, .close = ff_twinvq_decode_close, .decode = ff_twinvq_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mimic.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mimic.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mimic.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mimic.c 2015-07-28 17:20:07.000000000 +0000 @@ -479,7 +479,7 @@ .init = mimic_decode_init, .close = mimic_decode_end, .decode = mimic_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .update_thread_context = ONLY_IF_THREADS_ENABLED(mimic_decode_update_thread_context), .init_thread_copy = ONLY_IF_THREADS_ENABLED(mimic_init_thread_copy), }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/aacsbr_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/aacsbr_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/aacsbr_mips.h 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/aacsbr_mips.h 2015-07-07 17:20:03.000000000 +0000 @@ -149,7 +149,7 @@ } } -#if (HAVE_MIPSFPU && !HAVE_LOONGSON3) +#if HAVE_MIPSFPU static void sbr_qmf_synthesis_mips(FFTContext *mdct, SBRDSPContext *sbrdsp, AVFloatDSPContext *fdsp, float *out, float X[2][38][64], @@ -488,7 +488,7 @@ #define sbr_qmf_analysis sbr_qmf_analysis_mips #define sbr_qmf_synthesis sbr_qmf_synthesis_mips -#endif /* (HAVE_MIPSFPU && !HAVE_LOONGSON3) */ +#endif /* HAVE_MIPSFPU */ #endif /* HAVE_INLINE_ASM */ #endif /* AVCODEC_MIPS_AACSBR_FLOAT_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/blockdsp_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/blockdsp_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/blockdsp_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/blockdsp_init_mips.c 2015-07-21 17:20:03.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2015 Parag Salasakar (parag.salasakar@imgtec.com) + * Zhou Xiaoyong + * + * 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 "blockdsp_mips.h" + +#if HAVE_MSA +static av_cold void blockdsp_init_msa(BlockDSPContext *c, + unsigned high_bit_depth) +{ + c->clear_block = ff_clear_block_msa; + c->clear_blocks = ff_clear_blocks_msa; + + c->fill_block_tab[0] = ff_fill_block16_msa; + c->fill_block_tab[1] = ff_fill_block8_msa; +} +#endif // #if HAVE_MSA + +#if HAVE_MMI +static av_cold void blockdsp_init_mmi(BlockDSPContext *c, + unsigned high_bit_depth) +{ + c->clear_block = ff_clear_block_mmi; + c->clear_blocks = ff_clear_blocks_mmi; + + c->fill_block_tab[0] = ff_fill_block16_mmi; + c->fill_block_tab[1] = ff_fill_block8_mmi; +} +#endif /* HAVE_MMI */ + +void ff_blockdsp_init_mips(BlockDSPContext *c, unsigned high_bit_depth) +{ +#if HAVE_MSA + blockdsp_init_msa(c, high_bit_depth); +#endif // #if HAVE_MSA +#if HAVE_MMI + blockdsp_init_mmi(c, high_bit_depth); +#endif /* HAVE_MMI */ +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/blockdsp_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/blockdsp_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/blockdsp_mips.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/blockdsp_mips.h 2015-07-21 17:20:03.000000000 +0000 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015 Parag Salasakar (parag.salasakar@imgtec.com) + * Zhou Xiaoyong + * + * 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 + */ + +#ifndef AVCODEC_MIPS_BLOCKDSP_MIPS_H +#define AVCODEC_MIPS_BLOCKDSP_MIPS_H + +#include "../mpegvideo.h" + +void ff_fill_block16_msa(uint8_t *src, uint8_t val, int stride, int height); +void ff_fill_block8_msa(uint8_t *src, uint8_t val, int stride, int height); +void ff_clear_block_msa(int16_t *block); +void ff_clear_blocks_msa(int16_t *block); + +void ff_fill_block16_mmi(uint8_t *block, uint8_t value, int line_size, int h); +void ff_fill_block8_mmi(uint8_t *block, uint8_t value, int line_size, int h); +void ff_clear_block_mmi(int16_t *block); +void ff_clear_blocks_mmi(int16_t *block); + +#endif // #ifndef AVCODEC_MIPS_BLOCKDSP_MIPS_H diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/blockdsp_mmi.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/blockdsp_mmi.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/blockdsp_mmi.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/blockdsp_mmi.c 2015-07-21 17:20:03.000000000 +0000 @@ -0,0 +1,147 @@ +/* + * Loongson SIMD optimized blockdsp + * + * Copyright (c) 2015 Loongson Technology Corporation Limited + * Copyright (c) 2015 Zhou Xiaoyong + * + * 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 "blockdsp_mips.h" + +void ff_fill_block16_mmi(uint8_t *block, uint8_t value, int line_size, int h) +{ + __asm__ volatile ( + "move $8, %3 \r\n" + "move $9, %0 \r\n" + "dmtc1 %1, $f2 \r\n" + "punpcklbh $f2, $f2, $f2 \r\n" + "punpcklbh $f2, $f2, $f2 \r\n" + "punpcklbh $f2, $f2, $f2 \r\n" + "1: \r\n" + "gssdlc1 $f2, 7($9) \r\n" + "gssdrc1 $f2, 0($9) \r\n" + "gssdlc1 $f2, 15($9) \r\n" + "gssdrc1 $f2, 8($9) \r\n" + "daddi $8, $8, -1 \r\n" + "daddu $9, $9, %2 \r\n" + "bnez $8, 1b \r\n" + ::"r"(block),"r"(value),"r"(line_size),"r"(h) + : "$8","$9" + ); +} + +void ff_fill_block8_mmi(uint8_t *block, uint8_t value, int line_size, int h) +{ + __asm__ volatile ( + "move $8, %3 \r\n" + "move $9, %0 \r\n" + "dmtc1 %1, $f2 \r\n" + "punpcklbh $f2, $f2, $f2 \r\n" + "punpcklbh $f2, $f2, $f2 \r\n" + "punpcklbh $f2, $f2, $f2 \r\n" + "1: \r\n" + "gssdlc1 $f2, 7($9) \r\n" + "gssdrc1 $f2, 0($9) \r\n" + "daddi $8, $8, -1 \r\n" + "daddu $9, $9, %2 \r\n" + "bnez $8, 1b \r\n" + ::"r"(block),"r"(value),"r"(line_size),"r"(h) + : "$8","$9" + ); +} + +void ff_clear_block_mmi(int16_t *block) +{ + __asm__ volatile ( + "xor $f0, $f0, $f0 \r\n" + "xor $f2, $f2, $f2 \r\n" + "gssqc1 $f0, $f2, 0(%0) \r\n" + "gssqc1 $f0, $f2, 16(%0) \r\n" + "gssqc1 $f0, $f2, 32(%0) \r\n" + "gssqc1 $f0, $f2, 48(%0) \r\n" + "gssqc1 $f0, $f2, 64(%0) \r\n" + "gssqc1 $f0, $f2, 80(%0) \r\n" + "gssqc1 $f0, $f2, 96(%0) \r\n" + "gssqc1 $f0, $f2, 112(%0) \r\n" + ::"r"(block) + : "memory" + ); +} + +void ff_clear_blocks_mmi(int16_t *block) +{ + __asm__ volatile ( + "xor $f0, $f0, $f0 \r\n" + "xor $f2, $f2, $f2 \r\n" + "gssqc1 $f0, $f2, 0(%0) \r\n" + "gssqc1 $f0, $f2, 16(%0) \r\n" + "gssqc1 $f0, $f2, 32(%0) \r\n" + "gssqc1 $f0, $f2, 48(%0) \r\n" + "gssqc1 $f0, $f2, 64(%0) \r\n" + "gssqc1 $f0, $f2, 80(%0) \r\n" + "gssqc1 $f0, $f2, 96(%0) \r\n" + "gssqc1 $f0, $f2, 112(%0) \r\n" + + "gssqc1 $f0, $f2, 128(%0) \r\n" + "gssqc1 $f0, $f2, 144(%0) \r\n" + "gssqc1 $f0, $f2, 160(%0) \r\n" + "gssqc1 $f0, $f2, 176(%0) \r\n" + "gssqc1 $f0, $f2, 192(%0) \r\n" + "gssqc1 $f0, $f2, 208(%0) \r\n" + "gssqc1 $f0, $f2, 224(%0) \r\n" + "gssqc1 $f0, $f2, 240(%0) \r\n" + + "gssqc1 $f0, $f2, 256(%0) \r\n" + "gssqc1 $f0, $f2, 272(%0) \r\n" + "gssqc1 $f0, $f2, 288(%0) \r\n" + "gssqc1 $f0, $f2, 304(%0) \r\n" + "gssqc1 $f0, $f2, 320(%0) \r\n" + "gssqc1 $f0, $f2, 336(%0) \r\n" + "gssqc1 $f0, $f2, 352(%0) \r\n" + "gssqc1 $f0, $f2, 368(%0) \r\n" + + "gssqc1 $f0, $f2, 384(%0) \r\n" + "gssqc1 $f0, $f2, 400(%0) \r\n" + "gssqc1 $f0, $f2, 416(%0) \r\n" + "gssqc1 $f0, $f2, 432(%0) \r\n" + "gssqc1 $f0, $f2, 448(%0) \r\n" + "gssqc1 $f0, $f2, 464(%0) \r\n" + "gssqc1 $f0, $f2, 480(%0) \r\n" + "gssqc1 $f0, $f2, 496(%0) \r\n" + + "gssqc1 $f0, $f2, 512(%0) \r\n" + "gssqc1 $f0, $f2, 528(%0) \r\n" + "gssqc1 $f0, $f2, 544(%0) \r\n" + "gssqc1 $f0, $f2, 560(%0) \r\n" + "gssqc1 $f0, $f2, 576(%0) \r\n" + "gssqc1 $f0, $f2, 592(%0) \r\n" + "gssqc1 $f0, $f2, 608(%0) \r\n" + "gssqc1 $f0, $f2, 624(%0) \r\n" + + "gssqc1 $f0, $f2, 640(%0) \r\n" + "gssqc1 $f0, $f2, 656(%0) \r\n" + "gssqc1 $f0, $f2, 672(%0) \r\n" + "gssqc1 $f0, $f2, 688(%0) \r\n" + "gssqc1 $f0, $f2, 704(%0) \r\n" + "gssqc1 $f0, $f2, 720(%0) \r\n" + "gssqc1 $f0, $f2, 736(%0) \r\n" + "gssqc1 $f0, $f2, 752(%0) \r\n" + ::"r"(block) + : "memory" + ); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/blockdsp_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/blockdsp_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/blockdsp_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/blockdsp_msa.c 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2015 Parag Salasakar (parag.salasakar@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "blockdsp_mips.h" + +static void copy_8bit_value_width8_msa(uint8_t *src, uint8_t val, + int32_t src_stride, int32_t height) +{ + int32_t cnt; + uint64_t dst0; + v16u8 val0; + + val0 = (v16u8) __msa_fill_b(val); + dst0 = __msa_copy_u_d((v2i64) val0, 0); + + for (cnt = (height >> 2); cnt--;) { + SD4(dst0, dst0, dst0, dst0, src, src_stride); + src += (4 * src_stride); + } +} + +static void copy_8bit_value_width16_msa(uint8_t *src, uint8_t val, + int32_t src_stride, int32_t height) +{ + int32_t cnt; + v16u8 val0; + + val0 = (v16u8) __msa_fill_b(val); + + for (cnt = (height >> 3); cnt--;) { + ST_UB8(val0, val0, val0, val0, val0, val0, val0, val0, src, src_stride); + src += (8 * src_stride); + } +} + +static void memset_zero_16width_msa(uint8_t *src, int32_t stride, + int32_t height) +{ + int8_t cnt; + v16u8 zero = { 0 }; + + for (cnt = (height / 2); cnt--;) { + ST_UB(zero, src); + src += stride; + ST_UB(zero, src); + src += stride; + } +} + +void ff_fill_block16_msa(uint8_t *src, uint8_t val, int stride, int height) +{ + copy_8bit_value_width16_msa(src, val, stride, height); +} + +void ff_fill_block8_msa(uint8_t *src, uint8_t val, int stride, int height) +{ + copy_8bit_value_width8_msa(src, val, stride, height); +} + +void ff_clear_block_msa(int16_t *block) +{ + memset_zero_16width_msa((uint8_t *) block, 16, 8); +} + +void ff_clear_blocks_msa(int16_t *block) +{ + memset_zero_16width_msa((uint8_t *) block, 16, 8 * 6); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/constants.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/constants.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/constants.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/constants.c 2015-07-20 17:20:03.000000000 +0000 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015 Loongson Technology Corporation Limited + * Copyright (c) 2015 Zhou Xiaoyong + * + * 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 "config.h" +#include "libavutil/mem.h" +#include "constants.h" + +DECLARE_ALIGNED(8, const uint64_t, ff_pw_1) = {0x0001000100010001ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_4) = {0x0004000400040004ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_5) = {0x0005000500050005ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_3) = {0x0003000300030003ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_8) = {0x0008000800080008ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_9) = {0x0009000900090009ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_16) = {0x0010001000100010ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_18) = {0x0012001200120012ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_28) = {0x001C001C001C001CULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_32) = {0x0020002000200020ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_53) = {0x0035003500350035ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_64) = {0x0040004000400040ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_128) = {0x0080008000800080ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_m8tom5) = {0xFFFBFFFAFFF9FFF8ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_m4tom1) = {0xFFFFFFFEFFFDFFFCULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_1to4) = {0x0004000300020001ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_5to8) = {0x0008000700060005ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_0to3) = {0x0003000200010000ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_4to7) = {0x0007000600050004ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_8tob) = {0x000b000a00090008ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pw_ctof) = {0x000f000e000d000cULL}; + +DECLARE_ALIGNED(8, const uint64_t, ff_pb_1) = {0x0101010101010101ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pb_3) = {0x0303030303030303ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pb_80) = {0x8080808080808080ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_pb_A1) = {0xA1A1A1A1A1A1A1A1ULL}; + +DECLARE_ALIGNED(8, const uint64_t, ff_rnd) = {0x0004000400040004ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_rnd2) = {0x0040004000400040ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_rnd3) = {0x0020002000200020ULL}; + +DECLARE_ALIGNED(8, const uint64_t, ff_wm1010) = {0xFFFF0000FFFF0000ULL}; +DECLARE_ALIGNED(8, const uint64_t, ff_d40000) = {0x0000000000040000ULL}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/constants.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/constants.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/constants.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/constants.h 2015-07-20 17:20:03.000000000 +0000 @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2015 Loongson Technology Corporation Limited + * Copyright (c) 2015 Zhou Xiaoyong + * + * 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 + */ + +#ifndef AVCODEC_MIPS_CONSTANTS_H +#define AVCODEC_MIPS_CONSTANTS_H + +#include + +extern const uint64_t ff_pw_1; +extern const uint64_t ff_pw_3; +extern const uint64_t ff_pw_4; +extern const uint64_t ff_pw_5; +extern const uint64_t ff_pw_8; +extern const uint64_t ff_pw_9; +extern const uint64_t ff_pw_16; +extern const uint64_t ff_pw_18; +extern const uint64_t ff_pw_28; +extern const uint64_t ff_pw_32; +extern const uint64_t ff_pw_53; +extern const uint64_t ff_pw_64; +extern const uint64_t ff_pw_128; +extern const uint64_t ff_pw_m8tom5; +extern const uint64_t ff_pw_m4tom1; +extern const uint64_t ff_pw_1to4; +extern const uint64_t ff_pw_5to8; +extern const uint64_t ff_pw_0to3; +extern const uint64_t ff_pw_4to7; +extern const uint64_t ff_pw_8tob; +extern const uint64_t ff_pw_ctof; + +extern const uint64_t ff_pb_1; +extern const uint64_t ff_pb_3; +extern const uint64_t ff_pb_80; +extern const uint64_t ff_pb_A1; + +extern const uint64_t ff_rnd; +extern const uint64_t ff_rnd2; +extern const uint64_t ff_rnd3; + +extern const uint64_t ff_wm1010; +extern const uint64_t ff_d40000; + +#endif /* AVCODEC_MIPS_CONSTANTS_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h263dsp_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h263dsp_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h263dsp_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h263dsp_init_mips.c 2015-06-17 17:20:02.000000000 +0000 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * 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 "h263dsp_mips.h" + +#if HAVE_MSA +static av_cold void h263dsp_init_msa(H263DSPContext *c) +{ + c->h263_h_loop_filter = ff_h263_h_loop_filter_msa; + c->h263_v_loop_filter = ff_h263_v_loop_filter_msa; +} +#endif // #if HAVE_MSA + +av_cold void ff_h263dsp_init_mips(H263DSPContext *c) +{ +#if HAVE_MSA + h263dsp_init_msa(c); +#endif // #if HAVE_MSA +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h263dsp_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h263dsp_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h263dsp_mips.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h263dsp_mips.h 2015-06-17 17:20:02.000000000 +0000 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * 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 + */ + +#ifndef AVCODEC_MIPS_H263DSP_MIPS_H +#define AVCODEC_MIPS_H263DSP_MIPS_H + +#include "libavcodec/mpegvideo.h" + +void ff_h263_h_loop_filter_msa(uint8_t *src, int stride, int q_scale); +void ff_h263_v_loop_filter_msa(uint8_t *src, int stride, int q_scale); +void ff_dct_unquantize_mpeg2_inter_msa(MpegEncContext *s, int16_t *block, + int32_t index, int32_t q_scale); +void ff_dct_unquantize_h263_inter_msa(MpegEncContext *s, int16_t *block, + int32_t index, int32_t q_scale); +void ff_dct_unquantize_h263_intra_msa(MpegEncContext *s, int16_t *block, + int32_t index, int32_t q_scale); +int ff_pix_sum_msa(uint8_t *pix, int line_size); + +#endif // #ifndef AVCODEC_MIPS_H263DSP_MIPS_H diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h263dsp_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h263dsp_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h263dsp_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h263dsp_msa.c 2015-06-17 17:20:02.000000000 +0000 @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "h263dsp_mips.h" + +static const uint8_t h263_loop_filter_strength_msa[32] = { + 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, + 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12 +}; + +static void h263_h_loop_filter_msa(uint8_t *src, int32_t stride, int32_t qscale) +{ + int32_t strength = h263_loop_filter_strength_msa[qscale]; + v16u8 in0, in1, in2, in3, in4, in5, in6, in7; + v8i16 temp0, temp1, temp2; + v8i16 diff0, diff2, diff4, diff6, diff8; + v8i16 d0, a_d0, str_x2, str; + + src -= 2; + LD_UB8(src, stride, in0, in1, in2, in3, in4, in5, in6, in7); + TRANSPOSE8x4_UB_UB(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in3, in2, in1); + + temp0 = (v8i16) __msa_ilvr_b((v16i8) in0, (v16i8) in1); + a_d0 = __msa_hsub_u_h((v16u8) temp0, (v16u8) temp0); + temp2 = (v8i16) __msa_ilvr_b((v16i8) in2, (v16i8) in3); + temp2 = __msa_hsub_u_h((v16u8) temp2, (v16u8) temp2); + temp2 <<= 2; + diff0 = a_d0 + temp2; + diff2 = -(-diff0 >> 3); + str_x2 = __msa_fill_h(-(strength << 1)); + temp0 = (str_x2 <= diff2); + diff2 = (v8i16) __msa_bmz_v((v16u8) diff2, (v16u8) temp0, (v16u8) temp0); + temp2 = str_x2 - diff2; + str = __msa_fill_h(-strength); + temp0 = (diff2 < str); + diff2 = (v8i16) __msa_bmnz_v((v16u8) diff2, (v16u8) temp2, (v16u8) temp0); + diff4 = diff0 >> 3; + str_x2 = __msa_fill_h(strength << 1); + temp0 = (diff4 <= str_x2); + diff4 = (v8i16) __msa_bmz_v((v16u8) diff4, (v16u8) temp0, (v16u8) temp0); + temp2 = str_x2 - diff4; + str = __msa_fill_h(strength); + temp0 = (str < diff4); + diff4 = (v8i16) __msa_bmnz_v((v16u8) diff4, (v16u8) temp2, (v16u8) temp0); + temp0 = __msa_clti_s_h(diff0, 0); + d0 = (v8i16) __msa_bmnz_v((v16u8) diff4, (v16u8) diff2, (v16u8) temp0); + diff2 = -diff2 >> 1; + diff4 >>= 1; + diff8 = (v8i16) __msa_bmnz_v((v16u8) diff4, (v16u8) diff2, (v16u8) temp0); + diff6 = (-a_d0) >> 2; + diff6 = -(diff6); + temp2 = -diff8; + temp0 = (diff6 < temp2); + diff6 = (v8i16) __msa_bmnz_v((v16u8) diff6, (v16u8) temp2, (v16u8) temp0); + diff2 = a_d0 >> 2; + temp0 = (diff2 <= diff8); + diff2 = (v8i16) __msa_bmz_v((v16u8) diff2, (v16u8) diff8, (v16u8) temp0); + temp0 = __msa_clti_s_h(a_d0, 0); + diff6 = (v8i16) __msa_bmz_v((v16u8) diff6, (v16u8) diff2, (v16u8) temp0); + PCKEV_B2_SH(a_d0, diff6, a_d0, d0, diff6, d0); + in0 = (v16u8) ((v16i8) in0 - (v16i8) diff6); + in1 = (v16u8) ((v16i8) in1 + (v16i8) diff6); + in3 = __msa_xori_b(in3, 128); + in3 = (v16u8) __msa_adds_s_b((v16i8) in3, (v16i8) d0); + in3 = __msa_xori_b(in3, 128); + in2 = __msa_subsus_u_b(in2, (v16i8) d0); + ILVR_B2_SH(in3, in0, in1, in2, temp0, temp1); + in0 = (v16u8) __msa_ilvr_h(temp1, temp0); + in3 = (v16u8) __msa_ilvl_h(temp1, temp0); + ST4x4_UB(in0, in0, 0, 1, 2, 3, src, stride); + src += 4 * stride; + ST4x4_UB(in3, in3, 0, 1, 2, 3, src, stride); + src += 4 * stride; +} + +static void h263_v_loop_filter_msa(uint8_t *src, int32_t stride, int32_t qscale) +{ + int32_t strength = h263_loop_filter_strength_msa[qscale]; + uint64_t res0, res1, res2, res3; + v16u8 in0, in1, in2, in3; + v8i16 temp0, temp2, diff0, diff2, diff4, diff6, diff8; + v8i16 d0, a_d0, str_x2, str; + + src -= 2 * stride; + LD_UB4(src, stride, in0, in3, in2, in1); + temp0 = (v8i16) __msa_ilvr_b((v16i8) in0, (v16i8) in1); + a_d0 = __msa_hsub_u_h((v16u8) temp0, (v16u8) temp0); + temp2 = (v8i16) __msa_ilvr_b((v16i8) in2, (v16i8) in3); + temp2 = __msa_hsub_u_h((v16u8) temp2, (v16u8) temp2); + temp2 <<= 2; + diff0 = a_d0 + temp2; + diff2 = -(-diff0 >> 3); + str_x2 = __msa_fill_h(-(strength << 1)); + temp0 = (str_x2 <= diff2); + diff2 = (v8i16) __msa_bmz_v((v16u8) diff2, (v16u8) temp0, (v16u8) temp0); + temp2 = str_x2 - diff2; + str = __msa_fill_h(-strength); + temp0 = (diff2 < str); + diff2 = (v8i16) __msa_bmnz_v((v16u8) diff2, (v16u8) temp2, (v16u8) temp0); + diff4 = diff0 >> 3; + str_x2 = __msa_fill_h(strength << 1); + temp0 = (diff4 <= str_x2); + diff4 = (v8i16) __msa_bmz_v((v16u8) diff4, (v16u8) temp0, (v16u8) temp0); + temp2 = str_x2 - diff4; + str = __msa_fill_h(strength); + temp0 = (str < diff4); + diff4 = (v8i16) __msa_bmnz_v((v16u8) diff4, (v16u8) temp2, (v16u8) temp0); + temp0 = __msa_clti_s_h(diff0, 0); + d0 = (v8i16) __msa_bmnz_v((v16u8) diff4, (v16u8) diff2, (v16u8) temp0); + diff2 = -diff2 >> 1; + diff4 >>= 1; + diff8 = (v8i16) __msa_bmnz_v((v16u8) diff4, (v16u8) diff2, (v16u8) temp0); + diff6 = (-a_d0) >> 2; + diff6 = -(diff6); + temp2 = -diff8; + temp0 = (diff6 < temp2); + diff6 = (v8i16) __msa_bmnz_v((v16u8) diff6, (v16u8) temp2, (v16u8) temp0); + diff2 = a_d0 >> 2; + temp0 = (diff2 <= diff8); + diff2 = (v8i16) __msa_bmz_v((v16u8) diff2, (v16u8) diff8, (v16u8) temp0); + temp0 = __msa_clti_s_h(a_d0, 0); + diff6 = (v8i16) __msa_bmz_v((v16u8) diff6, (v16u8) diff2, (v16u8) temp0); + PCKEV_B2_SH(a_d0, diff6, a_d0, d0, diff6, d0); + in0 = (v16u8) ((v16i8) in0 - (v16i8) diff6); + in1 = (v16u8) ((v16i8) in1 + (v16i8) diff6); + in3 = __msa_xori_b(in3, 128); + in3 = (v16u8) __msa_adds_s_b((v16i8) in3, (v16i8) d0); + in3 = __msa_xori_b(in3, 128); + in2 = __msa_subsus_u_b(in2, (v16i8) d0); + res0 = __msa_copy_u_d((v2i64) in0, 0); + res1 = __msa_copy_u_d((v2i64) in3, 0); + res2 = __msa_copy_u_d((v2i64) in2, 0); + res3 = __msa_copy_u_d((v2i64) in1, 0); + SD4(res0, res1, res2, res3, src, stride); +} + +void ff_h263_h_loop_filter_msa(uint8_t *src, int32_t stride, int32_t q_scale) +{ + h263_h_loop_filter_msa(src, stride, q_scale); +} + +void ff_h263_v_loop_filter_msa(uint8_t *src, int32_t stride, int32_t q_scale) +{ + h263_v_loop_filter_msa(src, stride, q_scale); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264chroma_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264chroma_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264chroma_init_mips.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264chroma_init_mips.c 2015-07-07 17:20:03.000000000 +0000 @@ -1,5 +1,6 @@ /* * Copyright (c) 2015 Zhou Xiaoyong + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) * * This file is part of FFmpeg. * @@ -20,7 +21,24 @@ #include "h264chroma_mips.h" -#if HAVE_LOONGSON3 +#if HAVE_MSA +static av_cold void h264chroma_init_msa(H264ChromaContext *c, int bit_depth) +{ + const int high_bit_depth = bit_depth > 8; + + if (!high_bit_depth) { + c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_msa; + c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_msa; + c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_msa; + + c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_msa; + c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_msa; + c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_msa; + } +} +#endif // #if HAVE_MSA + +#if HAVE_MMI static av_cold void h264chroma_init_mmi(H264ChromaContext *c, int bit_depth) { int high_bit_depth = bit_depth > 8; @@ -32,11 +50,14 @@ c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_mmi; } } -#endif /* HAVE_LOONGSON3 */ +#endif /* HAVE_MMI */ av_cold void ff_h264chroma_init_mips(H264ChromaContext *c, int bit_depth) { -#if HAVE_LOONGSON3 +#if HAVE_MSA + h264chroma_init_msa(c, bit_depth); +#endif // #if HAVE_MSA +#if HAVE_MMI h264chroma_init_mmi(c, bit_depth); -#endif /* HAVE_LOONGSON3 */ +#endif /* HAVE_MMI */ } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264chroma_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264chroma_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264chroma_mips.h 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264chroma_mips.h 2015-06-11 17:20:04.000000000 +0000 @@ -22,6 +22,18 @@ #define H264_CHROMA_MIPS_H #include "libavcodec/h264.h" +void ff_put_h264_chroma_mc8_msa(uint8_t *dst, uint8_t *src, int stride, + int height, int x, int y); +void ff_put_h264_chroma_mc4_msa(uint8_t *dst, uint8_t *src, int stride, + int height, int x, int y); +void ff_put_h264_chroma_mc2_msa(uint8_t *dst, uint8_t *src, int stride, + int height, int x, int y); +void ff_avg_h264_chroma_mc8_msa(uint8_t *dst, uint8_t *src, int stride, + int height, int x, int y); +void ff_avg_h264_chroma_mc4_msa(uint8_t *dst, uint8_t *src, int stride, + int height, int x, int y); +void ff_avg_h264_chroma_mc2_msa(uint8_t *dst, uint8_t *src, int stride, + int height, int x, int y); void ff_put_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264chroma_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264chroma_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264chroma_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264chroma_msa.c 2015-06-11 17:20:04.000000000 +0000 @@ -0,0 +1,2003 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "h264chroma_mips.h" + +static const uint8_t chroma_mask_arr[16 * 5] = { + 0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20, + 0, 2, 2, 4, 4, 6, 6, 8, 16, 18, 18, 20, 20, 22, 22, 24, + 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, + 0, 1, 1, 2, 16, 17, 17, 18, 4, 5, 5, 6, 6, 7, 7, 8, + 0, 1, 1, 2, 16, 17, 17, 18, 16, 17, 17, 18, 18, 19, 19, 20 +}; + +static void avc_chroma_hz_2x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + uint16_t out0, out1; + v16i8 src0, src1; + v8u16 res_r; + v8i16 res; + v16i8 mask; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + mask = LD_SB(&chroma_mask_arr[0]); + + LD_SB2(src, src_stride, src0, src1); + + src0 = __msa_vshf_b(mask, src1, src0); + res_r = __msa_dotp_u_h((v16u8) src0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + res = (v8i16) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + + out0 = __msa_copy_u_h(res, 0); + out1 = __msa_copy_u_h(res, 2); + + SH(out0, dst); + dst += dst_stride; + SH(out1, dst); +} + +static void avc_chroma_hz_2x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + v16u8 src0, src1, src2, src3; + v8u16 res_r; + v8i16 res; + v16i8 mask; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + mask = LD_SB(&chroma_mask_arr[64]); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, src0, src2); + + src0 = (v16u8) __msa_ilvr_d((v2i64) src2, (v2i64) src0); + + res_r = __msa_dotp_u_h(src0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + res = (v8i16) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + + ST2x4_UB(res, 0, dst, dst_stride); +} + +static void avc_chroma_hz_2x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + v8u16 res_r; + v8i16 res; + v16i8 mask; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + mask = LD_SB(&chroma_mask_arr[64]); + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, src0, src2); + VSHF_B2_UB(src4, src5, src6, src7, mask, mask, src4, src6); + + ILVR_D2_UB(src2, src0, src6, src4, src0, src4); + + res_r = __msa_dotp_u_h(src0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + res = (v8i16) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + + ST2x4_UB(res, 0, dst, dst_stride); + dst += (4 * dst_stride); + + res_r = __msa_dotp_u_h(src4, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + res = (v8i16) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + + ST2x4_UB(res, 0, dst, dst_stride); +} + +static void avc_chroma_hz_2w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + if (2 == height) { + avc_chroma_hz_2x2_msa(src, src_stride, dst, dst_stride, coeff0, coeff1); + } else if (4 == height) { + avc_chroma_hz_2x4_msa(src, src_stride, dst, dst_stride, coeff0, coeff1); + } else if (8 == height) { + avc_chroma_hz_2x8_msa(src, src_stride, dst, dst_stride, coeff0, coeff1); + } +} + +static void avc_chroma_hz_4x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + v16i8 src0, src1; + v8u16 res_r; + v4i32 res; + v16i8 mask; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + mask = LD_SB(&chroma_mask_arr[0]); + + LD_SB2(src, src_stride, src0, src1); + + src0 = __msa_vshf_b(mask, src1, src0); + res_r = __msa_dotp_u_h((v16u8) src0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + res = (v4i32) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + + ST4x2_UB(res, dst, dst_stride); +} + +static void avc_chroma_hz_4x4multiple_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + uint32_t row; + v16u8 src0, src1, src2, src3; + v8u16 res0_r, res1_r; + v4i32 res0, res1; + v16i8 mask; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + mask = LD_SB(&chroma_mask_arr[0]); + + for (row = (height >> 2); row--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, src0, src2); + DOTP_UB2_UH(src0, src2, coeff_vec, coeff_vec, res0_r, res1_r); + + res0_r <<= 3; + res1_r <<= 3; + + SRARI_H2_UH(res0_r, res1_r, 6); + SAT_UH2_UH(res0_r, res1_r, 7); + PCKEV_B2_SW(res0_r, res0_r, res1_r, res1_r, res0, res1); + + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void avc_chroma_hz_4w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + if (2 == height) { + avc_chroma_hz_4x2_msa(src, src_stride, dst, dst_stride, coeff0, coeff1); + } else { + avc_chroma_hz_4x4multiple_msa(src, src_stride, dst, dst_stride, coeff0, + coeff1, height); + } +} + +static void avc_chroma_hz_8w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + uint32_t row; + v16u8 src0, src1, src2, src3, out0, out1; + v8u16 res0, res1, res2, res3; + v16i8 mask; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + mask = LD_SB(&chroma_mask_arr[32]); + + for (row = height >> 2; row--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + VSHF_B2_UB(src0, src0, src1, src1, mask, mask, src0, src1); + VSHF_B2_UB(src2, src2, src3, src3, mask, mask, src2, src3); + DOTP_UB4_UH(src0, src1, src2, src3, coeff_vec, coeff_vec, coeff_vec, + coeff_vec, res0, res1, res2, res3); + SLLI_4V(res0, res1, res2, res3, 3); + SRARI_H4_UH(res0, res1, res2, res3, 6); + SAT_UH4_UH(res0, res1, res2, res3, 7); + PCKEV_B2_UB(res1, res0, res3, res2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + } + + if (0 != (height % 4)) { + for (row = (height % 4); row--;) { + src0 = LD_UB(src); + src += src_stride; + + src0 = (v16u8) __msa_vshf_b(mask, (v16i8) src0, (v16i8) src0); + + res0 = __msa_dotp_u_h(src0, coeff_vec); + res0 <<= 3; + res0 = (v8u16) __msa_srari_h((v8i16) res0, 6); + res0 = __msa_sat_u_h(res0, 7); + res0 = (v8u16) __msa_pckev_b((v16i8) res0, (v16i8) res0); + + ST8x1_UB(res0, dst); + dst += dst_stride; + } + } +} + +static void avc_chroma_vt_2x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + uint16_t out0, out1; + v16i8 src0, src1, src2; + v16u8 tmp0, tmp1; + v8i16 res; + v8u16 res_r; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + LD_SB3(src, src_stride, src0, src1, src2); + + ILVR_B2_UB(src1, src0, src2, src1, tmp0, tmp1); + + tmp0 = (v16u8) __msa_ilvr_d((v2i64) tmp1, (v2i64) tmp0); + + res_r = __msa_dotp_u_h(tmp0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + res = (v8i16) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + + out0 = __msa_copy_u_h(res, 0); + out1 = __msa_copy_u_h(res, 2); + + SH(out0, dst); + dst += dst_stride; + SH(out1, dst); +} + +static void avc_chroma_vt_2x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + v16u8 src0, src1, src2, src3, src4; + v16u8 tmp0, tmp1, tmp2, tmp3; + v8i16 res; + v8u16 res_r; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + LD_UB5(src, src_stride, src0, src1, src2, src3, src4); + ILVR_B4_UB(src1, src0, src2, src1, src3, src2, src4, src3, + tmp0, tmp1, tmp2, tmp3); + ILVR_W2_UB(tmp1, tmp0, tmp3, tmp2, tmp0, tmp2); + + tmp0 = (v16u8) __msa_ilvr_d((v2i64) tmp2, (v2i64) tmp0); + + res_r = __msa_dotp_u_h(tmp0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + + res = (v8i16) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + + ST2x4_UB(res, 0, dst, dst_stride); +} + +static void avc_chroma_vt_2x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16u8 tmp0, tmp1, tmp2, tmp3; + v8i16 res; + v8u16 res_r; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + LD_UB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + LD_UB4(src, src_stride, src5, src6, src7, src8); + + ILVR_B4_UB(src1, src0, src2, src1, src3, src2, src4, src3, + tmp0, tmp1, tmp2, tmp3); + ILVR_W2_UB(tmp1, tmp0, tmp3, tmp2, tmp0, tmp2); + + tmp0 = (v16u8) __msa_ilvr_d((v2i64) tmp2, (v2i64) tmp0); + + res_r = __msa_dotp_u_h(tmp0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + + res = (v8i16) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + + ST2x4_UB(res, 0, dst, dst_stride); + dst += (4 * dst_stride); + + ILVR_B4_UB(src5, src4, src6, src5, src7, src6, src8, src7, + tmp0, tmp1, tmp2, tmp3); + ILVR_W2_UB(tmp1, tmp0, tmp3, tmp2, tmp0, tmp2); + + tmp0 = (v16u8) __msa_ilvr_d((v2i64) tmp2, (v2i64) tmp0); + + res_r = __msa_dotp_u_h(tmp0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + + res = (v8i16) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + + ST2x4_UB(res, 0, dst, dst_stride); + dst += (4 * dst_stride); +} + +static void avc_chroma_vt_2w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + if (2 == height) { + avc_chroma_vt_2x2_msa(src, src_stride, dst, dst_stride, coeff0, coeff1); + } else if (4 == height) { + avc_chroma_vt_2x4_msa(src, src_stride, dst, dst_stride, coeff0, coeff1); + } else if (8 == height) { + avc_chroma_vt_2x8_msa(src, src_stride, dst, dst_stride, coeff0, coeff1); + } +} + +static void avc_chroma_vt_4x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + v16u8 src0, src1, src2; + v16u8 tmp0, tmp1; + v4i32 res; + v8u16 res_r; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + LD_UB3(src, src_stride, src0, src1, src2); + ILVR_B2_UB(src1, src0, src2, src1, tmp0, tmp1); + + tmp0 = (v16u8) __msa_ilvr_d((v2i64) tmp1, (v2i64) tmp0); + res_r = __msa_dotp_u_h(tmp0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + res = (v4i32) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + + ST4x2_UB(res, dst, dst_stride); +} + +static void avc_chroma_vt_4x4multiple_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + uint32_t row; + v16u8 src0, src1, src2, src3, src4; + v16u8 tmp0, tmp1, tmp2, tmp3; + v8u16 res0_r, res1_r; + v4i32 res0, res1; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + src0 = LD_UB(src); + src += src_stride; + + for (row = (height >> 2); row--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + ILVR_B4_UB(src1, src0, src2, src1, src3, src2, src4, src3, + tmp0, tmp1, tmp2, tmp3); + ILVR_D2_UB(tmp1, tmp0, tmp3, tmp2, tmp0, tmp2); + DOTP_UB2_UH(tmp0, tmp2, coeff_vec, coeff_vec, res0_r, res1_r); + + res0_r <<= 3; + res1_r <<= 3; + + SRARI_H2_UH(res0_r, res1_r, 6); + SAT_UH2_UH(res0_r, res1_r, 7); + PCKEV_B2_SW(res0_r, res0_r, res1_r, res1_r, res0, res1); + + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + src0 = src4; + } +} + +static void avc_chroma_vt_4w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + if (2 == height) { + avc_chroma_vt_4x2_msa(src, src_stride, dst, dst_stride, coeff0, coeff1); + } else { + avc_chroma_vt_4x4multiple_msa(src, src_stride, dst, dst_stride, coeff0, + coeff1, height); + } +} + +static void avc_chroma_vt_8w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + uint32_t row; + v16u8 src0, src1, src2, src3, src4, out0, out1; + v8u16 res0, res1, res2, res3; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + src0 = LD_UB(src); + src += src_stride; + + for (row = height >> 2; row--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + ILVR_B4_UB(src1, src0, src2, src1, src3, src2, src4, src3, + src0, src1, src2, src3); + DOTP_UB4_UH(src0, src1, src2, src3, coeff_vec, coeff_vec, coeff_vec, + coeff_vec, res0, res1, res2, res3); + SLLI_4V(res0, res1, res2, res3, 3); + SRARI_H4_UH(res0, res1, res2, res3, 6); + SAT_UH4_UH(res0, res1, res2, res3, 7); + PCKEV_B2_UB(res1, res0, res3, res2, out0, out1); + + ST8x4_UB(out0, out1, dst, dst_stride); + + dst += (4 * dst_stride); + src0 = src4; + } +} + +static void avc_chroma_hv_2x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, uint32_t coef_hor1, + uint32_t coef_ver0, uint32_t coef_ver1) +{ + uint16_t out0, out1; + v16u8 src0, src1, src2; + v8u16 res_hz0, res_hz1, res_vt0, res_vt1; + v8i16 res_vert; + v16i8 mask; + v16i8 coeff_hz_vec0 = __msa_fill_b(coef_hor0); + v16i8 coeff_hz_vec1 = __msa_fill_b(coef_hor1); + v16u8 coeff_hz_vec = (v16u8) __msa_ilvr_b(coeff_hz_vec0, coeff_hz_vec1); + v8u16 coeff_vt_vec0 = (v8u16) __msa_fill_h(coef_ver0); + v8u16 coeff_vt_vec1 = (v8u16) __msa_fill_h(coef_ver1); + + mask = LD_SB(&chroma_mask_arr[48]); + + LD_UB3(src, src_stride, src0, src1, src2); + VSHF_B2_UB(src0, src1, src1, src2, mask, mask, src0, src1); + DOTP_UB2_UH(src0, src1, coeff_hz_vec, coeff_hz_vec, res_hz0, res_hz1); + MUL2(res_hz0, coeff_vt_vec1, res_hz1, coeff_vt_vec0, res_vt0, res_vt1); + + res_vt0 += res_vt1; + res_vt0 = (v8u16) __msa_srari_h((v8i16) res_vt0, 6); + res_vt0 = __msa_sat_u_h(res_vt0, 7); + res_vert = (v8i16) __msa_pckev_b((v16i8) res_vt0, (v16i8) res_vt0); + + out0 = __msa_copy_u_h(res_vert, 0); + out1 = __msa_copy_u_h(res_vert, 1); + + SH(out0, dst); + dst += dst_stride; + SH(out1, dst); +} + +static void avc_chroma_hv_2x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, uint32_t coef_hor1, + uint32_t coef_ver0, uint32_t coef_ver1) +{ + v16u8 src0, src1, src2, src3, src4; + v16u8 tmp0, tmp1, tmp2, tmp3; + v8u16 res_hz0, res_hz1, res_vt0, res_vt1; + v8i16 res; + v16i8 mask; + v16i8 coeff_hz_vec0 = __msa_fill_b(coef_hor0); + v16i8 coeff_hz_vec1 = __msa_fill_b(coef_hor1); + v16u8 coeff_hz_vec = (v16u8) __msa_ilvr_b(coeff_hz_vec0, coeff_hz_vec1); + v8u16 coeff_vt_vec0 = (v8u16) __msa_fill_h(coef_ver0); + v8u16 coeff_vt_vec1 = (v8u16) __msa_fill_h(coef_ver1); + + mask = LD_SB(&chroma_mask_arr[48]); + + LD_UB5(src, src_stride, src0, src1, src2, src3, src4); + + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, tmp0, tmp1); + VSHF_B2_UB(src1, src2, src3, src4, mask, mask, tmp2, tmp3); + ILVR_D2_UB(tmp1, tmp0, tmp3, tmp2, src0, src1); + DOTP_UB2_UH(src0, src1, coeff_hz_vec, coeff_hz_vec, res_hz0, res_hz1); + MUL2(res_hz0, coeff_vt_vec1, res_hz1, coeff_vt_vec0, res_vt0, res_vt1); + + res_vt0 += res_vt1; + res_vt0 = (v8u16) __msa_srari_h((v8i16) res_vt0, 6); + res_vt0 = __msa_sat_u_h(res_vt0, 7); + res = (v8i16) __msa_pckev_b((v16i8) res_vt0, (v16i8) res_vt0); + + ST2x4_UB(res, 0, dst, dst_stride); +} + +static void avc_chroma_hv_2x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, uint32_t coef_hor1, + uint32_t coef_ver0, uint32_t coef_ver1) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16u8 tmp0, tmp1, tmp2, tmp3; + v8u16 res_hz0, res_hz1, res_vt0, res_vt1; + v8i16 res; + v16i8 mask; + v16i8 coeff_hz_vec0 = __msa_fill_b(coef_hor0); + v16i8 coeff_hz_vec1 = __msa_fill_b(coef_hor1); + v16u8 coeff_hz_vec = (v16u8) __msa_ilvr_b(coeff_hz_vec0, coeff_hz_vec1); + v8u16 coeff_vt_vec0 = (v8u16) __msa_fill_h(coef_ver0); + v8u16 coeff_vt_vec1 = (v8u16) __msa_fill_h(coef_ver1); + + mask = LD_SB(&chroma_mask_arr[48]); + + LD_UB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + LD_UB4(src, src_stride, src5, src6, src7, src8); + + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, tmp0, tmp1); + VSHF_B2_UB(src1, src2, src3, src4, mask, mask, tmp2, tmp3); + ILVR_D2_UB(tmp1, tmp0, tmp3, tmp2, src0, src1); + VSHF_B2_UB(src4, src5, src6, src7, mask, mask, tmp0, tmp1); + VSHF_B2_UB(src5, src6, src7, src8, mask, mask, tmp2, tmp3); + ILVR_D2_UB(tmp1, tmp0, tmp3, tmp2, src4, src5); + DOTP_UB2_UH(src0, src1, coeff_hz_vec, coeff_hz_vec, res_hz0, res_hz1); + MUL2(res_hz0, coeff_vt_vec1, res_hz1, coeff_vt_vec0, res_vt0, res_vt1); + + res_vt0 += res_vt1; + res_vt0 = (v8u16) __msa_srari_h((v8i16) res_vt0, 6); + res_vt0 = __msa_sat_u_h(res_vt0, 7); + + res = (v8i16) __msa_pckev_b((v16i8) res_vt0, (v16i8) res_vt0); + + ST2x4_UB(res, 0, dst, dst_stride); + dst += (4 * dst_stride); + + DOTP_UB2_UH(src4, src5, coeff_hz_vec, coeff_hz_vec, res_hz0, res_hz1); + MUL2(res_hz0, coeff_vt_vec1, res_hz1, coeff_vt_vec0, res_vt0, res_vt1); + + res_vt0 += res_vt1; + res_vt0 = (v8u16) __msa_srari_h((v8i16) res_vt0, 6); + res_vt0 = __msa_sat_u_h(res_vt0, 7); + + res = (v8i16) __msa_pckev_b((v16i8) res_vt0, (v16i8) res_vt0); + + ST2x4_UB(res, 0, dst, dst_stride); +} + +static void avc_chroma_hv_2w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, uint32_t coef_hor1, + uint32_t coef_ver0, uint32_t coef_ver1, + int32_t height) +{ + if (2 == height) { + avc_chroma_hv_2x2_msa(src, src_stride, dst, dst_stride, coef_hor0, + coef_hor1, coef_ver0, coef_ver1); + } else if (4 == height) { + avc_chroma_hv_2x4_msa(src, src_stride, dst, dst_stride, coef_hor0, + coef_hor1, coef_ver0, coef_ver1); + } else if (8 == height) { + avc_chroma_hv_2x8_msa(src, src_stride, dst, dst_stride, coef_hor0, + coef_hor1, coef_ver0, coef_ver1); + } +} + +static void avc_chroma_hv_4x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, uint32_t coef_hor1, + uint32_t coef_ver0, uint32_t coef_ver1) +{ + v16u8 src0, src1, src2; + v8u16 res_hz0, res_hz1, res_vt0, res_vt1; + v16i8 mask; + v4i32 res; + v16i8 coeff_hz_vec0 = __msa_fill_b(coef_hor0); + v16i8 coeff_hz_vec1 = __msa_fill_b(coef_hor1); + v16u8 coeff_hz_vec = (v16u8) __msa_ilvr_b(coeff_hz_vec0, coeff_hz_vec1); + v8u16 coeff_vt_vec0 = (v8u16) __msa_fill_h(coef_ver0); + v8u16 coeff_vt_vec1 = (v8u16) __msa_fill_h(coef_ver1); + + mask = LD_SB(&chroma_mask_arr[0]); + LD_UB3(src, src_stride, src0, src1, src2); + VSHF_B2_UB(src0, src1, src1, src2, mask, mask, src0, src1); + DOTP_UB2_UH(src0, src1, coeff_hz_vec, coeff_hz_vec, res_hz0, res_hz1); + MUL2(res_hz0, coeff_vt_vec1, res_hz1, coeff_vt_vec0, res_vt0, res_vt1); + + res_vt0 += res_vt1; + res_vt0 = (v8u16) __msa_srari_h((v8i16) res_vt0, 6); + res_vt0 = __msa_sat_u_h(res_vt0, 7); + res = (v4i32) __msa_pckev_b((v16i8) res_vt0, (v16i8) res_vt0); + + ST4x2_UB(res, dst, dst_stride); +} + +static void avc_chroma_hv_4x4multiple_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, + uint32_t coef_hor1, + uint32_t coef_ver0, + uint32_t coef_ver1, + int32_t height) +{ + uint32_t row; + v16u8 src0, src1, src2, src3, src4; + v8u16 res_hz0, res_hz1, res_hz2, res_hz3; + v8u16 res_vt0, res_vt1, res_vt2, res_vt3; + v16i8 mask; + v16i8 coeff_hz_vec0 = __msa_fill_b(coef_hor0); + v16i8 coeff_hz_vec1 = __msa_fill_b(coef_hor1); + v16u8 coeff_hz_vec = (v16u8) __msa_ilvr_b(coeff_hz_vec0, coeff_hz_vec1); + v8u16 coeff_vt_vec0 = (v8u16) __msa_fill_h(coef_ver0); + v8u16 coeff_vt_vec1 = (v8u16) __msa_fill_h(coef_ver1); + v4i32 res0, res1; + + mask = LD_SB(&chroma_mask_arr[0]); + + src0 = LD_UB(src); + src += src_stride; + + for (row = (height >> 2); row--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + VSHF_B2_UB(src0, src1, src1, src2, mask, mask, src0, src1); + VSHF_B2_UB(src2, src3, src3, src4, mask, mask, src2, src3); + DOTP_UB4_UH(src0, src1, src2, src3, coeff_hz_vec, coeff_hz_vec, + coeff_hz_vec, coeff_hz_vec, res_hz0, res_hz1, res_hz2, + res_hz3); + MUL4(res_hz0, coeff_vt_vec1, res_hz1, coeff_vt_vec0, res_hz2, + coeff_vt_vec1, res_hz3, coeff_vt_vec0, res_vt0, res_vt1, res_vt2, + res_vt3); + ADD2(res_vt0, res_vt1, res_vt2, res_vt3, res_vt0, res_vt1); + SRARI_H2_UH(res_vt0, res_vt1, 6); + SAT_UH2_UH(res_vt0, res_vt1, 7); + PCKEV_B2_SW(res_vt0, res_vt0, res_vt1, res_vt1, res0, res1); + + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + src0 = src4; + } +} + +static void avc_chroma_hv_4w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, uint32_t coef_hor1, + uint32_t coef_ver0, uint32_t coef_ver1, + int32_t height) +{ + if (2 == height) { + avc_chroma_hv_4x2_msa(src, src_stride, dst, dst_stride, coef_hor0, + coef_hor1, coef_ver0, coef_ver1); + } else { + avc_chroma_hv_4x4multiple_msa(src, src_stride, dst, dst_stride, + coef_hor0, coef_hor1, coef_ver0, + coef_ver1, height); + } +} + +static void avc_chroma_hv_8w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, uint32_t coef_hor1, + uint32_t coef_ver0, uint32_t coef_ver1, + int32_t height) +{ + uint32_t row; + v16u8 src0, src1, src2, src3, src4, out0, out1; + v8u16 res_hz0, res_hz1, res_hz2, res_hz3, res_hz4; + v8u16 res_vt0, res_vt1, res_vt2, res_vt3; + v16i8 mask; + v16i8 coeff_hz_vec0 = __msa_fill_b(coef_hor0); + v16i8 coeff_hz_vec1 = __msa_fill_b(coef_hor1); + v16u8 coeff_hz_vec = (v16u8) __msa_ilvr_b(coeff_hz_vec0, coeff_hz_vec1); + v8u16 coeff_vt_vec0 = (v8u16) __msa_fill_h(coef_ver0); + v8u16 coeff_vt_vec1 = (v8u16) __msa_fill_h(coef_ver1); + + mask = LD_SB(&chroma_mask_arr[32]); + + src0 = LD_UB(src); + src += src_stride; + + src0 = (v16u8) __msa_vshf_b(mask, (v16i8) src0, (v16i8) src0); + res_hz0 = __msa_dotp_u_h(src0, coeff_hz_vec); + + for (row = (height >> 2); row--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + VSHF_B2_UB(src1, src1, src2, src2, mask, mask, src1, src2); + VSHF_B2_UB(src3, src3, src4, src4, mask, mask, src3, src4); + DOTP_UB4_UH(src1, src2, src3, src4, coeff_hz_vec, coeff_hz_vec, + coeff_hz_vec, coeff_hz_vec, res_hz1, res_hz2, res_hz3, + res_hz4); + MUL4(res_hz1, coeff_vt_vec0, res_hz2, coeff_vt_vec0, res_hz3, + coeff_vt_vec0, res_hz4, coeff_vt_vec0, res_vt0, res_vt1, res_vt2, + res_vt3); + + res_vt0 += (res_hz0 * coeff_vt_vec1); + res_vt1 += (res_hz1 * coeff_vt_vec1); + res_vt2 += (res_hz2 * coeff_vt_vec1); + res_vt3 += (res_hz3 * coeff_vt_vec1); + + SRARI_H4_UH(res_vt0, res_vt1, res_vt2, res_vt3, 6); + SAT_UH4_UH(res_vt0, res_vt1, res_vt2, res_vt3, 7); + PCKEV_B2_UB(res_vt1, res_vt0, res_vt3, res_vt2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + + dst += (4 * dst_stride); + + res_hz0 = res_hz4; + } +} + +static void avc_chroma_hz_and_aver_dst_2x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + uint16_t out0, out1; + uint32_t load0, load1; + v16i8 src0, src1; + v16u8 dst_data = { 0 }; + v8u16 res_r; + v16u8 res; + v16i8 mask; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + mask = LD_SB(&chroma_mask_arr[0]); + + LD_SB2(src, src_stride, src0, src1); + + load0 = LW(dst); + load1 = LW(dst + dst_stride); + + INSERT_W2_UB(load0, load1, dst_data); + + src0 = __msa_vshf_b(mask, src1, src0); + + res_r = __msa_dotp_u_h((v16u8) src0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + + res = (v16u8) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + dst_data = __msa_aver_u_b(res, dst_data); + + out0 = __msa_copy_u_h((v8i16) dst_data, 0); + out1 = __msa_copy_u_h((v8i16) dst_data, 2); + + SH(out0, dst); + dst += dst_stride; + SH(out1, dst); +} + +static void avc_chroma_hz_and_aver_dst_2x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + v16u8 src0, src1, src2, src3; + v16u8 dst0, dst1, dst2, dst3; + v8u16 res_r; + v16i8 res, mask; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + mask = LD_SB(&chroma_mask_arr[64]); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + dst0 = (v16u8) __msa_insve_h((v8i16) dst0, 1, (v8i16) dst1); + dst0 = (v16u8) __msa_insve_h((v8i16) dst0, 2, (v8i16) dst2); + dst0 = (v16u8) __msa_insve_h((v8i16) dst0, 3, (v8i16) dst3); + + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, src0, src2); + + src0 = (v16u8) __msa_ilvr_d((v2i64) src2, (v2i64) src0); + + res_r = __msa_dotp_u_h(src0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + + res = __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + dst0 = __msa_aver_u_b((v16u8) res, dst0); + + ST2x4_UB(dst0, 0, dst, dst_stride); +} + +static void avc_chroma_hz_and_aver_dst_2x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v8u16 res0_r, res1_r; + v16u8 res0, res1, mask; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + mask = LD_UB(&chroma_mask_arr[64]); + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + LD_UB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + dst0 = (v16u8) __msa_insve_h((v8i16) dst0, 1, (v8i16) dst1); + dst0 = (v16u8) __msa_insve_h((v8i16) dst0, 2, (v8i16) dst2); + dst0 = (v16u8) __msa_insve_h((v8i16) dst0, 3, (v8i16) dst3); + + dst4 = (v16u8) __msa_insve_h((v8i16) dst4, 1, (v8i16) dst5); + dst4 = (v16u8) __msa_insve_h((v8i16) dst4, 2, (v8i16) dst6); + dst4 = (v16u8) __msa_insve_h((v8i16) dst4, 3, (v8i16) dst7); + + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, src0, src2); + VSHF_B2_UB(src4, src5, src6, src7, mask, mask, src4, src6); + ILVR_D2_UB(src2, src0, src6, src4, src0, src4); + DOTP_UB2_UH(src0, src4, coeff_vec, coeff_vec, res0_r, res1_r); + + res0_r <<= 3; + res1_r <<= 3; + + SRARI_H2_UH(res0_r, res1_r, 6); + SAT_UH2_UH(res0_r, res1_r, 7); + PCKEV_B2_UB(res0_r, res0_r, res1_r, res1_r, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst4, dst0, dst4); + + ST2x4_UB(dst0, 0, dst, dst_stride); + dst += (4 * dst_stride); + ST2x4_UB(dst4, 0, dst, dst_stride); +} + +static void avc_chroma_hz_and_aver_dst_2w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + if (2 == height) { + avc_chroma_hz_and_aver_dst_2x2_msa(src, src_stride, dst, dst_stride, + coeff0, coeff1); + } else if (4 == height) { + avc_chroma_hz_and_aver_dst_2x4_msa(src, src_stride, dst, dst_stride, + coeff0, coeff1); + } else if (8 == height) { + avc_chroma_hz_and_aver_dst_2x8_msa(src, src_stride, dst, dst_stride, + coeff0, coeff1); + } +} + +static void avc_chroma_hz_and_aver_dst_4x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + uint32_t load0, load1; + v16i8 src0, src1; + v16u8 dst_data = { 0 }; + v8u16 res_r; + v16i8 res, mask; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + mask = LD_SB(&chroma_mask_arr[0]); + + LD_SB2(src, src_stride, src0, src1); + + load0 = LW(dst); + load1 = LW(dst + dst_stride); + + INSERT_W2_UB(load0, load1, dst_data); + + src0 = __msa_vshf_b(mask, src1, src0); + + res_r = __msa_dotp_u_h((v16u8) src0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + res = __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + dst_data = __msa_aver_u_b((v16u8) res, dst_data); + + ST4x2_UB(dst_data, dst, dst_stride); +} + +static void avc_chroma_hz_and_aver_dst_4x4multiple_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + uint32_t coeff0, + uint32_t coeff1, + int32_t height) +{ + uint32_t load0, load1; + uint32_t row; + v16u8 src0, src1, src2, src3; + v16u8 dst0 = { 0 }; + v16u8 dst1 = { 0 }; + v8u16 res0_r, res1_r; + v16u8 res0, res1, mask; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + mask = LD_UB(&chroma_mask_arr[0]); + + for (row = (height >> 2); row--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + load0 = LW(dst); + load1 = LW(dst + dst_stride); + + INSERT_W2_UB(load0, load1, dst0); + + load0 = LW(dst + 2 * dst_stride); + load1 = LW(dst + 3 * dst_stride); + + INSERT_W2_UB(load0, load1, dst1); + + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, src0, src2); + DOTP_UB2_UH(src0, src2, coeff_vec, coeff_vec, res0_r, res1_r); + + res0_r <<= 3; + res1_r <<= 3; + + SRARI_H2_UH(res0_r, res1_r, 6); + SAT_UH2_UH(res0_r, res1_r, 7); + PCKEV_B2_UB(res0_r, res0_r, res1_r, res1_r, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, dst0, dst1); + + ST4x4_UB(dst0, dst1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void avc_chroma_hz_and_aver_dst_4w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + if (2 == height) { + avc_chroma_hz_and_aver_dst_4x2_msa(src, src_stride, dst, dst_stride, + coeff0, coeff1); + } else { + avc_chroma_hz_and_aver_dst_4x4multiple_msa(src, src_stride, + dst, dst_stride, + coeff0, coeff1, height); + } +} + +static void avc_chroma_hz_and_aver_dst_8w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + uint32_t row; + v16u8 src0, src1, src2, src3, out0, out1; + v8u16 res0, res1, res2, res3; + v16u8 dst0, dst1, dst2, dst3; + v16i8 mask; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + mask = LD_SB(&chroma_mask_arr[32]); + + for (row = height >> 2; row--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + VSHF_B2_UB(src0, src0, src1, src1, mask, mask, src0, src1); + VSHF_B2_UB(src2, src2, src3, src3, mask, mask, src2, src3); + DOTP_UB4_UH(src0, src1, src2, src3, coeff_vec, coeff_vec, coeff_vec, + coeff_vec, res0, res1, res2, res3); + SLLI_4V(res0, res1, res2, res3, 3); + SRARI_H4_UH(res0, res1, res2, res3, 6); + SAT_UH4_UH(res0, res1, res2, res3, 7); + PCKEV_B2_UB(res1, res0, res3, res2, out0, out1); + PCKEV_D2_UB(dst1, dst0, dst3, dst2, dst0, dst1); + AVER_UB2_UB(out0, dst0, out1, dst1, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void avc_chroma_vt_and_aver_dst_2x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + uint16_t out0, out1; + uint32_t load0, load1; + v16i8 src0, src1, src2, tmp0, tmp1, res; + v16u8 dst_data = { 0 }; + v8u16 res_r; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + LD_SB3(src, src_stride, src0, src1, src2); + load0 = LW(dst); + load1 = LW(dst + dst_stride); + + INSERT_W2_UB(load0, load1, dst_data); + + ILVR_B2_SB(src1, src0, src2, src1, tmp0, tmp1); + + tmp0 = (v16i8) __msa_ilvr_d((v2i64) tmp1, (v2i64) tmp0); + res_r = __msa_dotp_u_h((v16u8) tmp0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + res = __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + dst_data = __msa_aver_u_b((v16u8) res, dst_data); + out0 = __msa_copy_u_h((v8i16) dst_data, 0); + out1 = __msa_copy_u_h((v8i16) dst_data, 2); + + SH(out0, dst); + dst += dst_stride; + SH(out1, dst); +} + +static void avc_chroma_vt_and_aver_dst_2x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + uint32_t load0, load1; + v16i8 src0, src1, src2, src3, src4; + v16u8 tmp0, tmp1, tmp2, tmp3; + v8u16 res_r; + v8i16 res; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + v16u8 dst_data = { 0 }; + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + + load0 = LW(dst); + load1 = LW(dst + dst_stride); + + dst_data = (v16u8) __msa_insert_h((v8i16) dst_data, 0, load0); + dst_data = (v16u8) __msa_insert_h((v8i16) dst_data, 1, load1); + + load0 = LW(dst + 2 * dst_stride); + load1 = LW(dst + 3 * dst_stride); + + dst_data = (v16u8) __msa_insert_h((v8i16) dst_data, 2, load0); + dst_data = (v16u8) __msa_insert_h((v8i16) dst_data, 3, load1); + + ILVR_B4_UB(src1, src0, src2, src1, src3, src2, src4, src3, + tmp0, tmp1, tmp2, tmp3); + ILVR_W2_UB(tmp1, tmp0, tmp3, tmp2, tmp0, tmp2); + + tmp0 = (v16u8) __msa_ilvr_d((v2i64) tmp2, (v2i64) tmp0); + + res_r = __msa_dotp_u_h(tmp0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + + res = (v8i16) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + res = (v8i16) __msa_aver_u_b((v16u8) res, dst_data); + + ST2x4_UB(res, 0, dst, dst_stride); + dst += (4 * dst_stride); +} + +static void avc_chroma_vt_and_aver_dst_2x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + uint32_t load0, load1, load2, load3; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16u8 tmp0, tmp1, tmp2, tmp3; + v8i16 res; + v8u16 res_r; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + v16u8 dst_data0 = { 0 }; + v16u8 dst_data1 = { 0 }; + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + LD_SB4(src, src_stride, src5, src6, src7, src8); + + LW4(dst, dst_stride, load0, load1, load2, load3); + + dst_data0 = (v16u8) __msa_insert_h((v8i16) dst_data0, 0, load0); + dst_data0 = (v16u8) __msa_insert_h((v8i16) dst_data0, 1, load1); + dst_data0 = (v16u8) __msa_insert_h((v8i16) dst_data0, 2, load2); + dst_data0 = (v16u8) __msa_insert_h((v8i16) dst_data0, 3, load3); + + LW4(dst + 4 * dst_stride, dst_stride, load0, load1, load2, load3); + + dst_data1 = (v16u8) __msa_insert_h((v8i16) dst_data1, 0, load0); + dst_data1 = (v16u8) __msa_insert_h((v8i16) dst_data1, 1, load1); + dst_data1 = (v16u8) __msa_insert_h((v8i16) dst_data1, 2, load2); + dst_data1 = (v16u8) __msa_insert_h((v8i16) dst_data1, 3, load3); + + ILVR_B4_UB(src1, src0, src2, src1, src3, src2, src4, src3, + tmp0, tmp1, tmp2, tmp3); + + ILVR_W2_UB(tmp1, tmp0, tmp3, tmp2, tmp0, tmp2); + + tmp0 = (v16u8) __msa_ilvr_d((v2i64) tmp2, (v2i64) tmp0); + + res_r = __msa_dotp_u_h(tmp0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + + res = (v8i16) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + res = (v8i16) __msa_aver_u_b((v16u8) res, dst_data0); + + ST2x4_UB(res, 0, dst, dst_stride); + dst += (4 * dst_stride); + + ILVR_B4_UB(src5, src4, src6, src5, src7, src6, src8, src7, + tmp0, tmp1, tmp2, tmp3); + + ILVR_W2_UB(tmp1, tmp0, tmp3, tmp2, tmp0, tmp2); + + tmp0 = (v16u8) __msa_ilvr_d((v2i64) tmp2, (v2i64) tmp0); + + res_r = __msa_dotp_u_h(tmp0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + + res = (v8i16) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + res = (v8i16) __msa_aver_u_b((v16u8) res, dst_data1); + + ST2x4_UB(res, 0, dst, dst_stride); +} + +static void avc_chroma_vt_and_aver_dst_2w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + if (2 == height) { + avc_chroma_vt_and_aver_dst_2x2_msa(src, src_stride, dst, dst_stride, + coeff0, coeff1); + } else if (4 == height) { + avc_chroma_vt_and_aver_dst_2x4_msa(src, src_stride, dst, dst_stride, + coeff0, coeff1); + } else if (8 == height) { + avc_chroma_vt_and_aver_dst_2x8_msa(src, src_stride, dst, dst_stride, + coeff0, coeff1); + } +} + +static void avc_chroma_vt_and_aver_dst_4x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1) +{ + uint32_t load0, load1; + v16i8 src0, src1, src2, tmp0, tmp1; + v16u8 dst_data = { 0 }; + v8u16 res_r; + v16u8 res; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + LD_SB3(src, src_stride, src0, src1, src2); + + load0 = LW(dst); + load1 = LW(dst + dst_stride); + + INSERT_W2_UB(load0, load1, dst_data); + ILVR_B2_SB(src1, src0, src2, src1, tmp0, tmp1); + + tmp0 = (v16i8) __msa_ilvr_d((v2i64) tmp1, (v2i64) tmp0); + + res_r = __msa_dotp_u_h((v16u8) tmp0, coeff_vec); + res_r <<= 3; + res_r = (v8u16) __msa_srari_h((v8i16) res_r, 6); + res_r = __msa_sat_u_h(res_r, 7); + res = (v16u8) __msa_pckev_b((v16i8) res_r, (v16i8) res_r); + res = __msa_aver_u_b(res, dst_data); + + ST4x2_UB(res, dst, dst_stride); +} + +static void avc_chroma_vt_and_aver_dst_4x4mul_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + uint32_t coeff0, + uint32_t coeff1, + int32_t height) +{ + uint32_t load0, load1, row; + v16i8 src0, src1, src2, src3, src4; + v16u8 tmp0, tmp1, tmp2, tmp3; + v16u8 dst0 = { 0 }; + v16u8 dst1 = { 0 }; + v8u16 res0_r, res1_r; + v16u8 res0, res1; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + src0 = LD_SB(src); + src += src_stride; + + for (row = (height >> 2); row--;) { + LD_SB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + load0 = LW(dst); + load1 = LW(dst + dst_stride); + + INSERT_W2_UB(load0, load1, dst0); + load0 = LW(dst + 2 * dst_stride); + load1 = LW(dst + 3 * dst_stride); + INSERT_W2_UB(load0, load1, dst1); + + ILVR_B4_UB(src1, src0, src2, src1, src3, src2, src4, src3, + tmp0, tmp1, tmp2, tmp3); + ILVR_D2_UB(tmp1, tmp0, tmp3, tmp2, tmp0, tmp2); + DOTP_UB2_UH(tmp0, tmp2, coeff_vec, coeff_vec, res0_r, res1_r); + + res0_r <<= 3; + res1_r <<= 3; + + SRARI_H2_UH(res0_r, res1_r, 6); + SAT_UH2_UH(res0_r, res1_r, 7); + PCKEV_B2_UB(res0_r, res0_r, res1_r, res1_r, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + src0 = src4; + } +} + +static void avc_chroma_vt_and_aver_dst_4w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + if (2 == height) { + avc_chroma_vt_and_aver_dst_4x2_msa(src, src_stride, dst, dst_stride, + coeff0, coeff1); + } else { + avc_chroma_vt_and_aver_dst_4x4mul_msa(src, src_stride, dst, dst_stride, + coeff0, coeff1, height); + } +} + +static void avc_chroma_vt_and_aver_dst_8w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coeff0, uint32_t coeff1, + int32_t height) +{ + uint32_t row; + v16u8 src0, src1, src2, src3, src4; + v16u8 out0, out1; + v8u16 res0, res1, res2, res3; + v16u8 dst0, dst1, dst2, dst3; + v16i8 coeff_vec0 = __msa_fill_b(coeff0); + v16i8 coeff_vec1 = __msa_fill_b(coeff1); + v16u8 coeff_vec = (v16u8) __msa_ilvr_b(coeff_vec0, coeff_vec1); + + src0 = LD_UB(src); + src += src_stride; + + for (row = height >> 2; row--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + ILVR_B4_UB(src1, src0, src2, src1, src3, src2, src4, src3, + src0, src1, src2, src3); + DOTP_UB4_UH(src0, src1, src2, src3, coeff_vec, coeff_vec, coeff_vec, + coeff_vec, res0, res1, res2, res3); + SLLI_4V(res0, res1, res2, res3, 3); + SRARI_H4_UH(res0, res1, res2, res3, 6); + SAT_UH4_UH(res0, res1, res2, res3, 7); + PCKEV_B2_UB(res1, res0, res3, res2, out0, out1); + PCKEV_D2_UB(dst1, dst0, dst3, dst2, dst0, dst1); + AVER_UB2_UB(out0, dst0, out1, dst1, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + + dst += (4 * dst_stride); + src0 = src4; + } +} + +static void avc_chroma_hv_and_aver_dst_2x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, + uint32_t coef_hor1, + uint32_t coef_ver0, + uint32_t coef_ver1) +{ + uint16_t out0, out1; + v16u8 dst0, dst1; + v16u8 src0, src1, src2; + v8u16 res_hz0, res_hz1, res_vt0, res_vt1; + v16i8 res, mask; + v16i8 coeff_hz_vec0 = __msa_fill_b(coef_hor0); + v16i8 coeff_hz_vec1 = __msa_fill_b(coef_hor1); + v16u8 coeff_hz_vec = (v16u8) __msa_ilvr_b(coeff_hz_vec0, coeff_hz_vec1); + v8u16 coeff_vt_vec0 = (v8u16) __msa_fill_h(coef_ver0); + v8u16 coeff_vt_vec1 = (v8u16) __msa_fill_h(coef_ver1); + + mask = LD_SB(&chroma_mask_arr[48]); + + LD_UB3(src, src_stride, src0, src1, src2); + LD_UB2(dst, dst_stride, dst0, dst1); + VSHF_B2_UB(src0, src1, src1, src2, mask, mask, src0, src1); + DOTP_UB2_UH(src0, src1, coeff_hz_vec, coeff_hz_vec, res_hz0, res_hz1); + MUL2(res_hz0, coeff_vt_vec1, res_hz1, coeff_vt_vec0, res_vt0, res_vt1); + + res_vt0 += res_vt1; + res_vt0 = (v8u16) __msa_srari_h((v8i16) res_vt0, 6); + res_vt0 = __msa_sat_u_h(res_vt0, 7); + res = __msa_pckev_b((v16i8) res_vt0, (v16i8) res_vt0); + dst0 = (v16u8) __msa_insve_h((v8i16) dst0, 1, (v8i16) dst1); + dst0 = __msa_aver_u_b((v16u8) res, dst0); + out0 = __msa_copy_u_h((v8i16) dst0, 0); + out1 = __msa_copy_u_h((v8i16) dst0, 1); + + SH(out0, dst); + dst += dst_stride; + SH(out1, dst); +} + +static void avc_chroma_hv_and_aver_dst_2x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, + uint32_t coef_hor1, + uint32_t coef_ver0, + uint32_t coef_ver1) +{ + v16u8 src0, src1, src2, src3, src4; + v16u8 tmp0, tmp1, tmp2, tmp3; + v16u8 dst0, dst1, dst2, dst3; + v8u16 res_hz0, res_hz1, res_vt0, res_vt1; + v16i8 res, mask; + v16i8 coeff_hz_vec0 = __msa_fill_b(coef_hor0); + v16i8 coeff_hz_vec1 = __msa_fill_b(coef_hor1); + v16u8 coeff_hz_vec = (v16u8) __msa_ilvr_b(coeff_hz_vec0, coeff_hz_vec1); + v8u16 coeff_vt_vec0 = (v8u16) __msa_fill_h(coef_ver0); + v8u16 coeff_vt_vec1 = (v8u16) __msa_fill_h(coef_ver1); + + mask = LD_SB(&chroma_mask_arr[48]); + + LD_UB5(src, src_stride, src0, src1, src2, src3, src4); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, tmp0, tmp1); + VSHF_B2_UB(src1, src2, src3, src4, mask, mask, tmp2, tmp3); + ILVR_D2_UB(tmp1, tmp0, tmp3, tmp2, src0, src1); + DOTP_UB2_UH(src0, src1, coeff_hz_vec, coeff_hz_vec, res_hz0, res_hz1); + MUL2(res_hz0, coeff_vt_vec1, res_hz1, coeff_vt_vec0, res_vt0, res_vt1); + + res_vt0 += res_vt1; + res_vt0 = (v8u16) __msa_srari_h((v8i16) res_vt0, 6); + res_vt0 = __msa_sat_u_h(res_vt0, 7); + res = __msa_pckev_b((v16i8) res_vt0, (v16i8) res_vt0); + + dst0 = (v16u8) __msa_insve_h((v8i16) dst0, 1, (v8i16) dst1); + dst0 = (v16u8) __msa_insve_h((v8i16) dst0, 2, (v8i16) dst2); + dst0 = (v16u8) __msa_insve_h((v8i16) dst0, 3, (v8i16) dst3); + dst0 = __msa_aver_u_b((v16u8) res, dst0); + + ST2x4_UB(dst0, 0, dst, dst_stride); +} + +static void avc_chroma_hv_and_aver_dst_2x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, + uint32_t coef_hor1, + uint32_t coef_ver0, + uint32_t coef_ver1) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v16u8 tmp0, tmp1, tmp2, tmp3; + v8u16 res_hz0, res_hz1, res_vt0, res_vt1; + v16i8 res, mask; + v16i8 coeff_hz_vec0 = __msa_fill_b(coef_hor0); + v16i8 coeff_hz_vec1 = __msa_fill_b(coef_hor1); + v16u8 coeff_hz_vec = (v16u8) __msa_ilvr_b(coeff_hz_vec0, coeff_hz_vec1); + v8u16 coeff_vt_vec0 = (v8u16) __msa_fill_h(coef_ver0); + v8u16 coeff_vt_vec1 = (v8u16) __msa_fill_h(coef_ver1); + + mask = LD_SB(&chroma_mask_arr[48]); + + LD_UB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + LD_UB4(src, src_stride, src5, src6, src7, src8); + + LD_UB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + dst0 = (v16u8) __msa_insve_h((v8i16) dst0, 1, (v8i16) dst1); + dst0 = (v16u8) __msa_insve_h((v8i16) dst0, 2, (v8i16) dst2); + dst0 = (v16u8) __msa_insve_h((v8i16) dst0, 3, (v8i16) dst3); + + dst4 = (v16u8) __msa_insve_h((v8i16) dst4, 1, (v8i16) dst5); + dst4 = (v16u8) __msa_insve_h((v8i16) dst4, 2, (v8i16) dst6); + dst4 = (v16u8) __msa_insve_h((v8i16) dst4, 3, (v8i16) dst7); + + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, tmp0, tmp1); + VSHF_B2_UB(src1, src2, src3, src4, mask, mask, tmp2, tmp3); + ILVR_D2_UB(tmp1, tmp0, tmp3, tmp2, src0, src1); + VSHF_B2_UB(src4, src5, src6, src7, mask, mask, tmp0, tmp1); + VSHF_B2_UB(src5, src6, src7, src8, mask, mask, tmp2, tmp3); + ILVR_D2_UB(tmp1, tmp0, tmp3, tmp2, src4, src5); + DOTP_UB2_UH(src0, src1, coeff_hz_vec, coeff_hz_vec, res_hz0, res_hz1); + MUL2(res_hz0, coeff_vt_vec1, res_hz1, coeff_vt_vec0, res_vt0, res_vt1); + + res_vt0 += res_vt1; + res_vt0 = (v8u16) __msa_srari_h((v8i16) res_vt0, 6); + res_vt0 = __msa_sat_u_h(res_vt0, 7); + res = __msa_pckev_b((v16i8) res_vt0, (v16i8) res_vt0); + dst0 = __msa_aver_u_b((v16u8) res, dst0); + + ST2x4_UB(dst0, 0, dst, dst_stride); + dst += (4 * dst_stride); + + DOTP_UB2_UH(src4, src5, coeff_hz_vec, coeff_hz_vec, res_hz0, res_hz1); + MUL2(res_hz0, coeff_vt_vec1, res_hz1, coeff_vt_vec0, res_vt0, res_vt1); + + res_vt0 += res_vt1; + res_vt0 = (v8u16) __msa_srari_h((v8i16) res_vt0, 6); + res_vt0 = __msa_sat_u_h(res_vt0, 7); + res = __msa_pckev_b((v16i8) res_vt0, (v16i8) res_vt0); + dst4 = __msa_aver_u_b((v16u8) res, dst4); + + ST2x4_UB(dst4, 0, dst, dst_stride); +} + +static void avc_chroma_hv_and_aver_dst_2w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, + uint32_t coef_hor1, + uint32_t coef_ver0, + uint32_t coef_ver1, + int32_t height) +{ + if (2 == height) { + avc_chroma_hv_and_aver_dst_2x2_msa(src, src_stride, dst, dst_stride, + coef_hor0, coef_hor1, + coef_ver0, coef_ver1); + } else if (4 == height) { + avc_chroma_hv_and_aver_dst_2x4_msa(src, src_stride, dst, dst_stride, + coef_hor0, coef_hor1, + coef_ver0, coef_ver1); + } else if (8 == height) { + avc_chroma_hv_and_aver_dst_2x8_msa(src, src_stride, dst, dst_stride, + coef_hor0, coef_hor1, + coef_ver0, coef_ver1); + } +} + +static void avc_chroma_hv_and_aver_dst_4x2_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, + uint32_t coef_hor1, + uint32_t coef_ver0, + uint32_t coef_ver1) +{ + v16u8 src0, src1, src2; + v16u8 dst0, dst1; + v8u16 res_hz0, res_hz1, res_vt0, res_vt1; + v16i8 res, mask; + v16i8 coeff_hz_vec0 = __msa_fill_b(coef_hor0); + v16i8 coeff_hz_vec1 = __msa_fill_b(coef_hor1); + v16u8 coeff_hz_vec = (v16u8) __msa_ilvr_b(coeff_hz_vec0, coeff_hz_vec1); + v8u16 coeff_vt_vec0 = (v8u16) __msa_fill_h(coef_ver0); + v8u16 coeff_vt_vec1 = (v8u16) __msa_fill_h(coef_ver1); + + mask = LD_SB(&chroma_mask_arr[0]); + + LD_UB3(src, src_stride, src0, src1, src2); + LD_UB2(dst, dst_stride, dst0, dst1); + VSHF_B2_UB(src0, src1, src1, src2, mask, mask, src0, src1); + DOTP_UB2_UH(src0, src1, coeff_hz_vec, coeff_hz_vec, res_hz0, res_hz1); + MUL2(res_hz0, coeff_vt_vec1, res_hz1, coeff_vt_vec0, res_vt0, res_vt1); + + res_vt0 += res_vt1; + res_vt0 = (v8u16) __msa_srari_h((v8i16) res_vt0, 6); + res_vt0 = __msa_sat_u_h(res_vt0, 7); + res = __msa_pckev_b((v16i8) res_vt0, (v16i8) res_vt0); + dst0 = (v16u8) __msa_insve_w((v4i32) dst0, 1, (v4i32) dst1); + dst0 = __msa_aver_u_b((v16u8) res, dst0); + + ST4x2_UB(dst0, dst, dst_stride); +} + +static void avc_chroma_hv_and_aver_dst_4x4mul_msa(uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + uint32_t coef_hor0, + uint32_t coef_hor1, + uint32_t coef_ver0, + uint32_t coef_ver1, + int32_t height) +{ + uint32_t row; + v16u8 src0, src1, src2, src3, src4; + v16u8 dst0, dst1, dst2, dst3; + v8u16 res_hz0, res_hz1, res_hz2, res_hz3; + v8u16 res_vt0, res_vt1, res_vt2, res_vt3; + v16i8 mask; + v16i8 coeff_hz_vec0 = __msa_fill_b(coef_hor0); + v16i8 coeff_hz_vec1 = __msa_fill_b(coef_hor1); + v16u8 coeff_hz_vec = (v16u8) __msa_ilvr_b(coeff_hz_vec0, coeff_hz_vec1); + v8u16 coeff_vt_vec0 = (v8u16) __msa_fill_h(coef_ver0); + v8u16 coeff_vt_vec1 = (v8u16) __msa_fill_h(coef_ver1); + v16u8 res0, res1; + + mask = LD_SB(&chroma_mask_arr[0]); + + src0 = LD_UB(src); + src += src_stride; + + for (row = (height >> 2); row--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + VSHF_B2_UB(src0, src1, src1, src2, mask, mask, src0, src1); + VSHF_B2_UB(src2, src3, src3, src4, mask, mask, src2, src3); + DOTP_UB4_UH(src0, src1, src2, src3, coeff_hz_vec, coeff_hz_vec, + coeff_hz_vec, coeff_hz_vec, res_hz0, res_hz1, res_hz2, + res_hz3); + MUL4(res_hz0, coeff_vt_vec1, res_hz1, coeff_vt_vec0, res_hz2, + coeff_vt_vec1, res_hz3, coeff_vt_vec0, res_vt0, res_vt1, res_vt2, + res_vt3); + ADD2(res_vt0, res_vt1, res_vt2, res_vt3, res_vt0, res_vt1); + SRARI_H2_UH(res_vt0, res_vt1, 6); + SAT_UH2_UH(res_vt0, res_vt1, 7); + PCKEV_B2_UB(res_vt0, res_vt0, res_vt1, res_vt1, res0, res1); + + dst0 = (v16u8) __msa_insve_w((v4i32) dst0, 1, (v4i32) dst1); + dst1 = (v16u8) __msa_insve_w((v4i32) dst2, 1, (v4i32) dst3); + + AVER_UB2_UB(res0, dst0, res1, dst1, dst0, dst1); + + ST4x4_UB(dst0, dst1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + src0 = src4; + } +} + +static void avc_chroma_hv_and_aver_dst_4w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, + uint32_t coef_hor1, + uint32_t coef_ver0, + uint32_t coef_ver1, + int32_t height) +{ + if (2 == height) { + avc_chroma_hv_and_aver_dst_4x2_msa(src, src_stride, dst, dst_stride, + coef_hor0, coef_hor1, + coef_ver0, coef_ver1); + } else { + avc_chroma_hv_and_aver_dst_4x4mul_msa(src, src_stride, dst, dst_stride, + coef_hor0, coef_hor1, + coef_ver0, coef_ver1, height); + } +} + +static void avc_chroma_hv_and_aver_dst_8w_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint32_t coef_hor0, + uint32_t coef_hor1, + uint32_t coef_ver0, + uint32_t coef_ver1, + int32_t height) +{ + uint32_t row; + v16u8 src0, src1, src2, src3, src4, out0, out1; + v8u16 res_hz0, res_hz1, res_hz2; + v8u16 res_hz3, res_hz4; + v8u16 res_vt0, res_vt1, res_vt2, res_vt3; + v16u8 dst0, dst1, dst2, dst3; + v16i8 mask; + v16i8 coeff_hz_vec0 = __msa_fill_b(coef_hor0); + v16i8 coeff_hz_vec1 = __msa_fill_b(coef_hor1); + v16u8 coeff_hz_vec = (v16u8) __msa_ilvr_b(coeff_hz_vec0, coeff_hz_vec1); + v8u16 coeff_vt_vec0 = (v8u16) __msa_fill_h(coef_ver0); + v8u16 coeff_vt_vec1 = (v8u16) __msa_fill_h(coef_ver1); + + mask = LD_SB(&chroma_mask_arr[32]); + + src0 = LD_UB(src); + src += src_stride; + + src0 = (v16u8) __msa_vshf_b(mask, (v16i8) src0, (v16i8) src0); + res_hz0 = __msa_dotp_u_h(src0, coeff_hz_vec); + + for (row = (height >> 2); row--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + VSHF_B2_UB(src1, src1, src2, src2, mask, mask, src1, src2); + VSHF_B2_UB(src3, src3, src4, src4, mask, mask, src3, src4); + DOTP_UB4_UH(src1, src2, src3, src4, coeff_hz_vec, coeff_hz_vec, + coeff_hz_vec, coeff_hz_vec, res_hz1, res_hz2, res_hz3, + res_hz4); + MUL4(res_hz1, coeff_vt_vec0, res_hz2, coeff_vt_vec0, res_hz3, + coeff_vt_vec0, res_hz4, coeff_vt_vec0, res_vt0, res_vt1, res_vt2, + res_vt3); + + res_vt0 += (res_hz0 * coeff_vt_vec1); + res_vt1 += (res_hz1 * coeff_vt_vec1); + res_vt2 += (res_hz2 * coeff_vt_vec1); + res_vt3 += (res_hz3 * coeff_vt_vec1); + + SRARI_H4_UH(res_vt0, res_vt1, res_vt2, res_vt3, 6); + SAT_UH4_UH(res_vt0, res_vt1, res_vt2, res_vt3, 7); + + PCKEV_B2_UB(res_vt1, res_vt0, res_vt3, res_vt2, out0, out1); + PCKEV_D2_UB(dst1, dst0, dst3, dst2, dst0, dst1); + AVER_UB2_UB(out0, dst0, out1, dst1, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + + res_hz0 = res_hz4; + } +} + +static void copy_width8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint64_t out0, out1, out2, out3, out4, out5, out6, out7; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + if (0 == height % 12) { + for (cnt = (height / 12); cnt--;) { + LD_UB8(src, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + out4 = __msa_copy_u_d((v2i64) src4, 0); + out5 = __msa_copy_u_d((v2i64) src5, 0); + out6 = __msa_copy_u_d((v2i64) src6, 0); + out7 = __msa_copy_u_d((v2i64) src7, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + SD4(out4, out5, out6, out7, dst, dst_stride); + dst += (4 * dst_stride); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 8) { + for (cnt = height >> 3; cnt--;) { + LD_UB8(src, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + out4 = __msa_copy_u_d((v2i64) src4, 0); + out5 = __msa_copy_u_d((v2i64) src5, 0); + out6 = __msa_copy_u_d((v2i64) src6, 0); + out7 = __msa_copy_u_d((v2i64) src7, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + SD4(out4, out5, out6, out7, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 4) { + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 2) { + for (cnt = (height / 2); cnt--;) { + LD_UB2(src, src_stride, src0, src1); + src += (2 * src_stride); + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + + SD(out0, dst); + dst += dst_stride; + SD(out1, dst); + dst += dst_stride; + } + } +} + +static void avg_width4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint32_t out0, out1, out2, out3; + v16u8 src0, src1, src2, src3; + v16u8 dst0, dst1, dst2, dst3; + + if (0 == (height % 4)) { + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + + out0 = __msa_copy_u_w((v4i32) dst0, 0); + out1 = __msa_copy_u_w((v4i32) dst1, 0); + out2 = __msa_copy_u_w((v4i32) dst2, 0); + out3 = __msa_copy_u_w((v4i32) dst3, 0); + SW4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == (height % 2)) { + for (cnt = (height / 2); cnt--;) { + LD_UB2(src, src_stride, src0, src1); + src += (2 * src_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + + AVER_UB2_UB(src0, dst0, src1, dst1, dst0, dst1); + + out0 = __msa_copy_u_w((v4i32) dst0, 0); + out1 = __msa_copy_u_w((v4i32) dst1, 0); + SW(out0, dst); + dst += dst_stride; + SW(out1, dst); + dst += dst_stride; + } + } +} + +static void avg_width8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint64_t out0, out1, out2, out3; + v16u8 src0, src1, src2, src3; + v16u8 dst0, dst1, dst2, dst3; + + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + + out0 = __msa_copy_u_d((v2i64) dst0, 0); + out1 = __msa_copy_u_d((v2i64) dst1, 0); + out2 = __msa_copy_u_d((v2i64) dst2, 0); + out3 = __msa_copy_u_d((v2i64) dst3, 0); + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +void ff_put_h264_chroma_mc8_msa(uint8_t *dst, uint8_t *src, + int stride, int height, int x, int y) +{ + av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0); + + if (x && y) { + avc_chroma_hv_8w_msa(src, stride, dst, + stride, x, (8 - x), y, (8 - y), height); + } else if (x) { + avc_chroma_hz_8w_msa(src, stride, dst, stride, x, (8 - x), height); + } else if (y) { + avc_chroma_vt_8w_msa(src, stride, dst, stride, y, (8 - y), height); + } else { + copy_width8_msa(src, stride, dst, stride, height); + } +} + +void ff_put_h264_chroma_mc4_msa(uint8_t *dst, uint8_t *src, + int stride, int height, int x, int y) +{ + int32_t cnt; + + av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0); + + if (x && y) { + avc_chroma_hv_4w_msa(src, stride, dst, + stride, x, (8 - x), y, (8 - y), height); + } else if (x) { + avc_chroma_hz_4w_msa(src, stride, dst, stride, x, (8 - x), height); + } else if (y) { + avc_chroma_vt_4w_msa(src, stride, dst, stride, y, (8 - y), height); + } else { + for (cnt = height; cnt--;) { + *((uint32_t *) dst) = *((uint32_t *) src); + + src += stride; + dst += stride; + } + } +} + +void ff_put_h264_chroma_mc2_msa(uint8_t *dst, uint8_t *src, + int stride, int height, int x, int y) +{ + int32_t cnt; + + av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0); + + if (x && y) { + avc_chroma_hv_2w_msa(src, stride, dst, + stride, x, (8 - x), y, (8 - y), height); + } else if (x) { + avc_chroma_hz_2w_msa(src, stride, dst, stride, x, (8 - x), height); + } else if (y) { + avc_chroma_vt_2w_msa(src, stride, dst, stride, y, (8 - y), height); + } else { + for (cnt = height; cnt--;) { + *((uint16_t *) dst) = *((uint16_t *) src); + + src += stride; + dst += stride; + } + } +} + +void ff_avg_h264_chroma_mc8_msa(uint8_t *dst, uint8_t *src, + int stride, int height, int x, int y) +{ + av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0); + + + if (x && y) { + avc_chroma_hv_and_aver_dst_8w_msa(src, stride, dst, + stride, x, (8 - x), y, + (8 - y), height); + } else if (x) { + avc_chroma_hz_and_aver_dst_8w_msa(src, stride, dst, + stride, x, (8 - x), height); + } else if (y) { + avc_chroma_vt_and_aver_dst_8w_msa(src, stride, dst, + stride, y, (8 - y), height); + } else { + avg_width8_msa(src, stride, dst, stride, height); + } +} + +void ff_avg_h264_chroma_mc4_msa(uint8_t *dst, uint8_t *src, + int stride, int height, int x, int y) +{ + av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0); + + if (x && y) { + avc_chroma_hv_and_aver_dst_4w_msa(src, stride, dst, + stride, x, (8 - x), y, + (8 - y), height); + } else if (x) { + avc_chroma_hz_and_aver_dst_4w_msa(src, stride, dst, + stride, x, (8 - x), height); + } else if (y) { + avc_chroma_vt_and_aver_dst_4w_msa(src, stride, dst, + stride, y, (8 - y), height); + } else { + avg_width4_msa(src, stride, dst, stride, height); + } +} + +void ff_avg_h264_chroma_mc2_msa(uint8_t *dst, uint8_t *src, + int stride, int height, int x, int y) +{ + int32_t cnt; + + av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0); + + if (x && y) { + avc_chroma_hv_and_aver_dst_2w_msa(src, stride, dst, + stride, x, (8 - x), y, + (8 - y), height); + } else if (x) { + avc_chroma_hz_and_aver_dst_2w_msa(src, stride, dst, + stride, x, (8 - x), height); + } else if (y) { + avc_chroma_vt_and_aver_dst_2w_msa(src, stride, dst, + stride, y, (8 - y), height); + } else { + for (cnt = height; cnt--;) { + dst[0] = (dst[0] + src[0] + 1) >> 1; + dst[1] = (dst[1] + src[1] + 1) >> 1; + + src += stride; + dst += stride; + } + } +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264dsp_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264dsp_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264dsp_init_mips.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264dsp_init_mips.c 2015-07-07 17:20:03.000000000 +0000 @@ -62,11 +62,26 @@ c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels16_8_msa; c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels8_8_msa; c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels4_8_msa; + + c->h264_idct_add = ff_h264_idct_add_msa; + c->h264_idct8_add = ff_h264_idct8_addblk_msa; + c->h264_idct_dc_add = ff_h264_idct4x4_addblk_dc_msa; + c->h264_idct8_dc_add = ff_h264_idct8_dc_addblk_msa; + c->h264_idct_add16 = ff_h264_idct_add16_msa; + c->h264_idct8_add4 = ff_h264_idct8_add4_msa; + + if (chroma_format_idc <= 1) + c->h264_idct_add8 = ff_h264_idct_add8_msa; + else + c->h264_idct_add8 = ff_h264_idct_add8_422_msa; + + c->h264_idct_add16intra = ff_h264_idct_add16_intra_msa; + c->h264_luma_dc_dequant_idct = ff_h264_deq_idct_luma_dc_msa; } // if (8 == bit_depth) } #endif // #if HAVE_MSA -#if HAVE_LOONGSON3 +#if HAVE_MMI static av_cold void h264dsp_init_mmi(H264DSPContext * c, const int bit_depth, const int chroma_format_idc) @@ -81,7 +96,7 @@ c->biweight_h264_pixels_tab[2] = ff_h264_biweight_pixels4_8_mmi; } } -#endif /* HAVE_LOONGSON3 */ +#endif /* HAVE_MMI */ av_cold void ff_h264dsp_init_mips(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) @@ -89,7 +104,7 @@ #if HAVE_MSA h264dsp_init_msa(c, bit_depth, chroma_format_idc); #endif // #if HAVE_MSA -#if HAVE_LOONGSON3 +#if HAVE_MMI h264dsp_init_mmi(c, bit_depth, chroma_format_idc); -#endif /* HAVE_LOONGSON3 */ +#endif /* HAVE_MMI */ } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264dsp_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264dsp_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264dsp_mips.h 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264dsp_mips.h 2015-06-13 17:20:02.000000000 +0000 @@ -41,6 +41,30 @@ int32_t alpha, int32_t beta, int8_t *tc0); +void ff_h264_idct_add_msa(uint8_t *dst, int16_t *src, int32_t dst_stride); +void ff_h264_idct4x4_addblk_dc_msa(uint8_t *dst, int16_t *src, + int32_t dst_stride); +void ff_h264_deq_idct_luma_dc_msa(int16_t *dst, int16_t *src, + int32_t de_q_val); +void ff_h264_idct_add16_msa(uint8_t *dst, const int32_t *blk_offset, + int16_t *block, int32_t stride, + const uint8_t nnzc[15 * 8]); +void ff_h264_idct_add16_intra_msa(uint8_t *dst, const int32_t *blk_offset, + int16_t *block, int32_t dst_stride, + const uint8_t nnzc[15 * 8]); +void ff_h264_idct_add8_msa(uint8_t **dst, const int32_t *blk_offset, + int16_t *block, int32_t dst_stride, + const uint8_t nnzc[15 * 8]); +void ff_h264_idct_add8_422_msa(uint8_t **dst, const int32_t *blk_offset, + int16_t *block, int32_t dst_stride, + const uint8_t nnzc[15 * 8]); +void ff_h264_idct8_addblk_msa(uint8_t *dst, int16_t *src, int32_t dst_stride); +void ff_h264_idct8_dc_addblk_msa(uint8_t *dst, int16_t *src, + int32_t dst_stride); +void ff_h264_idct8_add4_msa(uint8_t *dst, const int *blk_offset, + int16_t *blk, int dst_stride, + const uint8_t nnzc[15 * 8]); + void ff_h264_h_lpf_luma_intra_msa(uint8_t *src, int stride, int alpha, int beta); void ff_h264_v_lpf_luma_intra_msa(uint8_t *src, int stride, @@ -68,6 +92,231 @@ void ff_weight_h264_pixels4_8_msa(uint8_t *src, int stride, int height, int log2_denom, int weight, int offset); +void ff_put_h264_qpel16_mc00_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc10_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc20_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc30_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc01_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc11_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc21_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc31_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc02_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc12_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc22_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc32_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc03_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc13_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc23_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel16_mc33_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); + +void ff_put_h264_qpel8_mc00_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc10_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc20_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc30_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc01_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc11_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc21_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc31_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc02_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc12_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc22_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc32_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc03_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc13_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc23_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel8_mc33_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); + +void ff_put_h264_qpel4_mc00_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc10_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc20_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc30_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc01_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc11_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc21_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc31_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc02_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc12_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc22_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc32_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc03_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc13_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc23_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_put_h264_qpel4_mc33_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); + +void ff_avg_h264_qpel16_mc00_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc10_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc20_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc30_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc01_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc11_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc21_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc31_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc02_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc12_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc22_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc32_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc03_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc13_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc23_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel16_mc33_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); + +void ff_avg_h264_qpel8_mc00_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc10_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc20_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc30_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc01_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc11_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc21_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc31_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc02_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc12_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc22_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc32_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc03_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc13_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc23_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel8_mc33_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); + +void ff_avg_h264_qpel4_mc00_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc10_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc20_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc30_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc01_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc11_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc21_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc31_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc02_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc12_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc22_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc32_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc03_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc13_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc23_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); +void ff_avg_h264_qpel4_mc33_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t dst_stride); + +void ff_h264_intra_predict_plane_8x8_msa(uint8_t *src, ptrdiff_t stride); +void ff_h264_intra_predict_dc_4blk_8x8_msa(uint8_t *src, ptrdiff_t stride); +void ff_h264_intra_predict_hor_dc_8x8_msa(uint8_t *src, ptrdiff_t stride); +void ff_h264_intra_predict_vert_dc_8x8_msa(uint8_t *src, ptrdiff_t stride); +void ff_h264_intra_predict_mad_cow_dc_l0t_8x8_msa(uint8_t *src, + ptrdiff_t stride); +void ff_h264_intra_predict_mad_cow_dc_0lt_8x8_msa(uint8_t *src, + ptrdiff_t stride); +void ff_h264_intra_predict_mad_cow_dc_l00_8x8_msa(uint8_t *src, + ptrdiff_t stride); +void ff_h264_intra_predict_mad_cow_dc_0l0_8x8_msa(uint8_t *src, + ptrdiff_t stride); +void ff_h264_intra_predict_plane_16x16_msa(uint8_t *src, ptrdiff_t stride); +void ff_h264_intra_pred_vert_8x8_msa(uint8_t *src, ptrdiff_t stride); +void ff_h264_intra_pred_horiz_8x8_msa(uint8_t *src, ptrdiff_t stride); +void ff_h264_intra_pred_dc_16x16_msa(uint8_t *src, ptrdiff_t stride); +void ff_h264_intra_pred_vert_16x16_msa(uint8_t *src, ptrdiff_t stride); +void ff_h264_intra_pred_horiz_16x16_msa(uint8_t *src, ptrdiff_t stride); +void ff_h264_intra_pred_dc_left_16x16_msa(uint8_t *src, ptrdiff_t stride); +void ff_h264_intra_pred_dc_top_16x16_msa(uint8_t *src, ptrdiff_t stride); +void ff_h264_intra_pred_dc_128_8x8_msa(uint8_t *src, ptrdiff_t stride); +void ff_h264_intra_pred_dc_128_16x16_msa(uint8_t *src, ptrdiff_t stride); +void ff_vp8_pred8x8_127_dc_8_msa(uint8_t *src, ptrdiff_t stride); +void ff_vp8_pred8x8_129_dc_8_msa(uint8_t *src, ptrdiff_t stride); +void ff_vp8_pred16x16_127_dc_8_msa(uint8_t *src, ptrdiff_t stride); +void ff_vp8_pred16x16_129_dc_8_msa(uint8_t *src, ptrdiff_t stride); + void ff_h264_weight_pixels16_8_mmi(uint8_t *block, int stride, int height, int log2_denom, int weight, int offset); void ff_h264_biweight_pixels16_8_mmi(uint8_t *dst, uint8_t *src, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264idct_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264idct_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264idct_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264idct_msa.c 2015-06-11 17:20:04.000000000 +0000 @@ -0,0 +1,469 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "h264dsp_mips.h" +#include "libavcodec/bit_depth_template.c" + +#define AVC_ITRANS_H(in0, in1, in2, in3, out0, out1, out2, out3) \ +{ \ + v8i16 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + \ + tmp0_m = in0 + in2; \ + tmp1_m = in0 - in2; \ + tmp2_m = in1 >> 1; \ + tmp2_m = tmp2_m - in3; \ + tmp3_m = in3 >> 1; \ + tmp3_m = in1 + tmp3_m; \ + \ + BUTTERFLY_4(tmp0_m, tmp1_m, tmp2_m, tmp3_m, out0, out1, out2, out3); \ +} + +static void avc_idct4x4_addblk_msa(uint8_t *dst, int16_t *src, + int32_t dst_stride) +{ + v8i16 src0, src1, src2, src3; + v8i16 hres0, hres1, hres2, hres3; + v8i16 vres0, vres1, vres2, vres3; + v8i16 zeros = { 0 }; + + LD4x4_SH(src, src0, src1, src2, src3); + AVC_ITRANS_H(src0, src1, src2, src3, hres0, hres1, hres2, hres3); + TRANSPOSE4x4_SH_SH(hres0, hres1, hres2, hres3, hres0, hres1, hres2, hres3); + AVC_ITRANS_H(hres0, hres1, hres2, hres3, vres0, vres1, vres2, vres3); + SRARI_H4_SH(vres0, vres1, vres2, vres3, 6); + ADDBLK_ST4x4_UB(vres0, vres1, vres2, vres3, dst, dst_stride); + ST_SH2(zeros, zeros, src, 8); +} + +static void avc_idct4x4_addblk_dc_msa(uint8_t *dst, int16_t *src, + int32_t dst_stride) +{ + int16_t dc; + uint32_t src0, src1, src2, src3; + v16u8 pred = { 0 }; + v16i8 out; + v8i16 input_dc, pred_r, pred_l; + + dc = (src[0] + 32) >> 6; + input_dc = __msa_fill_h(dc); + src[0] = 0; + + LW4(dst, dst_stride, src0, src1, src2, src3); + INSERT_W4_UB(src0, src1, src2, src3, pred); + UNPCK_UB_SH(pred, pred_r, pred_l); + + pred_r += input_dc; + pred_l += input_dc; + + CLIP_SH2_0_255(pred_r, pred_l); + out = __msa_pckev_b((v16i8) pred_l, (v16i8) pred_r); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); +} + +static void avc_deq_idct_luma_dc_msa(int16_t *dst, int16_t *src, + int32_t de_q_val) +{ +#define DC_DEST_STRIDE 16 + int16_t out0, out1, out2, out3; + v8i16 src0, src1, src2, src3; + v8i16 vec0, vec1, vec2, vec3; + v8i16 hres0, hres1, hres2, hres3; + v8i16 vres0, vres1, vres2, vres3; + v4i32 vres0_r, vres1_r, vres2_r, vres3_r; + v4i32 de_q_vec = __msa_fill_w(de_q_val); + + LD4x4_SH(src, src0, src1, src2, src3); + TRANSPOSE4x4_SH_SH(src0, src1, src2, src3, src0, src1, src2, src3); + BUTTERFLY_4(src0, src2, src3, src1, vec0, vec3, vec2, vec1); + BUTTERFLY_4(vec0, vec1, vec2, vec3, hres0, hres3, hres2, hres1); + TRANSPOSE4x4_SH_SH(hres0, hres1, hres2, hres3, hres0, hres1, hres2, hres3); + BUTTERFLY_4(hres0, hres1, hres3, hres2, vec0, vec3, vec2, vec1); + BUTTERFLY_4(vec0, vec1, vec2, vec3, vres0, vres1, vres2, vres3); + UNPCK_R_SH_SW(vres0, vres0_r); + UNPCK_R_SH_SW(vres1, vres1_r); + UNPCK_R_SH_SW(vres2, vres2_r); + UNPCK_R_SH_SW(vres3, vres3_r); + + vres0_r *= de_q_vec; + vres1_r *= de_q_vec; + vres2_r *= de_q_vec; + vres3_r *= de_q_vec; + + SRARI_W4_SW(vres0_r, vres1_r, vres2_r, vres3_r, 8); + PCKEV_H2_SH(vres1_r, vres0_r, vres3_r, vres2_r, vec0, vec1); + + out0 = __msa_copy_s_h(vec0, 0); + out1 = __msa_copy_s_h(vec0, 1); + out2 = __msa_copy_s_h(vec0, 2); + out3 = __msa_copy_s_h(vec0, 3); + SH(out0, dst); + SH(out1, (dst + 2 * DC_DEST_STRIDE)); + SH(out2, (dst + 8 * DC_DEST_STRIDE)); + SH(out3, (dst + 10 * DC_DEST_STRIDE)); + dst += DC_DEST_STRIDE; + + out0 = __msa_copy_s_h(vec0, 4); + out1 = __msa_copy_s_h(vec0, 5); + out2 = __msa_copy_s_h(vec0, 6); + out3 = __msa_copy_s_h(vec0, 7); + SH(out0, dst); + SH(out1, (dst + 2 * DC_DEST_STRIDE)); + SH(out2, (dst + 8 * DC_DEST_STRIDE)); + SH(out3, (dst + 10 * DC_DEST_STRIDE)); + dst += (3 * DC_DEST_STRIDE); + + out0 = __msa_copy_s_h(vec1, 0); + out1 = __msa_copy_s_h(vec1, 1); + out2 = __msa_copy_s_h(vec1, 2); + out3 = __msa_copy_s_h(vec1, 3); + SH(out0, dst); + SH(out1, (dst + 2 * DC_DEST_STRIDE)); + SH(out2, (dst + 8 * DC_DEST_STRIDE)); + SH(out3, (dst + 10 * DC_DEST_STRIDE)); + dst += DC_DEST_STRIDE; + + out0 = __msa_copy_s_h(vec1, 4); + out1 = __msa_copy_s_h(vec1, 5); + out2 = __msa_copy_s_h(vec1, 6); + out3 = __msa_copy_s_h(vec1, 7); + SH(out0, dst); + SH(out1, (dst + 2 * DC_DEST_STRIDE)); + SH(out2, (dst + 8 * DC_DEST_STRIDE)); + SH(out3, (dst + 10 * DC_DEST_STRIDE)); + +#undef DC_DEST_STRIDE +} + +static void avc_idct8_addblk_msa(uint8_t *dst, int16_t *src, int32_t dst_stride) +{ + v8i16 src0, src1, src2, src3, src4, src5, src6, src7; + v8i16 vec0, vec1, vec2, vec3; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v8i16 res0, res1, res2, res3, res4, res5, res6, res7; + v4i32 tmp0_r, tmp1_r, tmp2_r, tmp3_r, tmp4_r, tmp5_r, tmp6_r, tmp7_r; + v4i32 tmp0_l, tmp1_l, tmp2_l, tmp3_l, tmp4_l, tmp5_l, tmp6_l, tmp7_l; + v4i32 vec0_r, vec1_r, vec2_r, vec3_r, vec0_l, vec1_l, vec2_l, vec3_l; + v4i32 res0_r, res1_r, res2_r, res3_r, res4_r, res5_r, res6_r, res7_r; + v4i32 res0_l, res1_l, res2_l, res3_l, res4_l, res5_l, res6_l, res7_l; + v16i8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v16i8 zeros = { 0 }; + + src[0] += 32; + + LD_SH8(src, 8, src0, src1, src2, src3, src4, src5, src6, src7); + + vec0 = src0 + src4; + vec1 = src0 - src4; + vec2 = src2 >> 1; + vec2 = vec2 - src6; + vec3 = src6 >> 1; + vec3 = src2 + vec3; + + BUTTERFLY_4(vec0, vec1, vec2, vec3, tmp0, tmp1, tmp2, tmp3); + + vec0 = src7 >> 1; + vec0 = src5 - vec0 - src3 - src7; + vec1 = src3 >> 1; + vec1 = src1 - vec1 + src7 - src3; + vec2 = src5 >> 1; + vec2 = vec2 - src1 + src7 + src5; + vec3 = src1 >> 1; + vec3 = vec3 + src3 + src5 + src1; + tmp4 = vec3 >> 2; + tmp4 += vec0; + tmp5 = vec2 >> 2; + tmp5 += vec1; + tmp6 = vec1 >> 2; + tmp6 -= vec2; + tmp7 = vec0 >> 2; + tmp7 = vec3 - tmp7; + + BUTTERFLY_8(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, + res0, res1, res2, res3, res4, res5, res6, res7); + TRANSPOSE8x8_SH_SH(res0, res1, res2, res3, res4, res5, res6, res7, + res0, res1, res2, res3, res4, res5, res6, res7); + UNPCK_SH_SW(res0, tmp0_r, tmp0_l); + UNPCK_SH_SW(res1, tmp1_r, tmp1_l); + UNPCK_SH_SW(res2, tmp2_r, tmp2_l); + UNPCK_SH_SW(res3, tmp3_r, tmp3_l); + UNPCK_SH_SW(res4, tmp4_r, tmp4_l); + UNPCK_SH_SW(res5, tmp5_r, tmp5_l); + UNPCK_SH_SW(res6, tmp6_r, tmp6_l); + UNPCK_SH_SW(res7, tmp7_r, tmp7_l); + BUTTERFLY_4(tmp0_r, tmp0_l, tmp4_l, tmp4_r, vec0_r, vec0_l, vec1_l, vec1_r); + + vec2_r = tmp2_r >> 1; + vec2_l = tmp2_l >> 1; + vec2_r -= tmp6_r; + vec2_l -= tmp6_l; + vec3_r = tmp6_r >> 1; + vec3_l = tmp6_l >> 1; + vec3_r += tmp2_r; + vec3_l += tmp2_l; + + BUTTERFLY_4(vec0_r, vec1_r, vec2_r, vec3_r, tmp0_r, tmp2_r, tmp4_r, tmp6_r); + BUTTERFLY_4(vec0_l, vec1_l, vec2_l, vec3_l, tmp0_l, tmp2_l, tmp4_l, tmp6_l); + + vec0_r = tmp7_r >> 1; + vec0_l = tmp7_l >> 1; + vec0_r = tmp5_r - vec0_r - tmp3_r - tmp7_r; + vec0_l = tmp5_l - vec0_l - tmp3_l - tmp7_l; + vec1_r = tmp3_r >> 1; + vec1_l = tmp3_l >> 1; + vec1_r = tmp1_r - vec1_r + tmp7_r - tmp3_r; + vec1_l = tmp1_l - vec1_l + tmp7_l - tmp3_l; + vec2_r = tmp5_r >> 1; + vec2_l = tmp5_l >> 1; + vec2_r = vec2_r - tmp1_r + tmp7_r + tmp5_r; + vec2_l = vec2_l - tmp1_l + tmp7_l + tmp5_l; + vec3_r = tmp1_r >> 1; + vec3_l = tmp1_l >> 1; + vec3_r = vec3_r + tmp3_r + tmp5_r + tmp1_r; + vec3_l = vec3_l + tmp3_l + tmp5_l + tmp1_l; + tmp1_r = vec3_r >> 2; + tmp1_l = vec3_l >> 2; + tmp1_r += vec0_r; + tmp1_l += vec0_l; + tmp3_r = vec2_r >> 2; + tmp3_l = vec2_l >> 2; + tmp3_r += vec1_r; + tmp3_l += vec1_l; + tmp5_r = vec1_r >> 2; + tmp5_l = vec1_l >> 2; + tmp5_r -= vec2_r; + tmp5_l -= vec2_l; + tmp7_r = vec0_r >> 2; + tmp7_l = vec0_l >> 2; + tmp7_r = vec3_r - tmp7_r; + tmp7_l = vec3_l - tmp7_l; + + BUTTERFLY_4(tmp0_r, tmp0_l, tmp7_l, tmp7_r, res0_r, res0_l, res7_l, res7_r); + BUTTERFLY_4(tmp2_r, tmp2_l, tmp5_l, tmp5_r, res1_r, res1_l, res6_l, res6_r); + BUTTERFLY_4(tmp4_r, tmp4_l, tmp3_l, tmp3_r, res2_r, res2_l, res5_l, res5_r); + BUTTERFLY_4(tmp6_r, tmp6_l, tmp1_l, tmp1_r, res3_r, res3_l, res4_l, res4_r); + SRA_4V(res0_r, res0_l, res1_r, res1_l, 6); + SRA_4V(res2_r, res2_l, res3_r, res3_l, 6); + SRA_4V(res4_r, res4_l, res5_r, res5_l, 6); + SRA_4V(res6_r, res6_l, res7_r, res7_l, 6); + PCKEV_H4_SH(res0_l, res0_r, res1_l, res1_r, res2_l, res2_r, res3_l, res3_r, + res0, res1, res2, res3); + PCKEV_H4_SH(res4_l, res4_r, res5_l, res5_r, res6_l, res6_r, res7_l, res7_r, + res4, res5, res6, res7); + LD_SB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + ILVR_B4_SH(zeros, dst0, zeros, dst1, zeros, dst2, zeros, dst3, + tmp0, tmp1, tmp2, tmp3); + ILVR_B4_SH(zeros, dst4, zeros, dst5, zeros, dst6, zeros, dst7, + tmp4, tmp5, tmp6, tmp7); + ADD4(res0, tmp0, res1, tmp1, res2, tmp2, res3, tmp3, + res0, res1, res2, res3); + ADD4(res4, tmp4, res5, tmp5, res6, tmp6, res7, tmp7, + res4, res5, res6, res7); + CLIP_SH4_0_255(res0, res1, res2, res3); + CLIP_SH4_0_255(res4, res5, res6, res7); + PCKEV_B4_SB(res1, res0, res3, res2, res5, res4, res7, res6, + dst0, dst1, dst2, dst3); + ST8x4_UB(dst0, dst1, dst, dst_stride); + dst += (4 * dst_stride); + ST8x4_UB(dst2, dst3, dst, dst_stride); +} + +static void avc_idct8_dc_addblk_msa(uint8_t *dst, int16_t *src, + int32_t dst_stride) +{ + int32_t dc_val; + v16i8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v8i16 dst0_r, dst1_r, dst2_r, dst3_r, dst4_r, dst5_r, dst6_r, dst7_r; + v8i16 dc; + v16i8 zeros = { 0 }; + + dc_val = (src[0] + 32) >> 6; + dc = __msa_fill_h(dc_val); + + src[0] = 0; + + LD_SB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + ILVR_B4_SH(zeros, dst0, zeros, dst1, zeros, dst2, zeros, dst3, + dst0_r, dst1_r, dst2_r, dst3_r); + ILVR_B4_SH(zeros, dst4, zeros, dst5, zeros, dst6, zeros, dst7, + dst4_r, dst5_r, dst6_r, dst7_r); + ADD4(dst0_r, dc, dst1_r, dc, dst2_r, dc, dst3_r, dc, + dst0_r, dst1_r, dst2_r, dst3_r); + ADD4(dst4_r, dc, dst5_r, dc, dst6_r, dc, dst7_r, dc, + dst4_r, dst5_r, dst6_r, dst7_r); + CLIP_SH4_0_255(dst0_r, dst1_r, dst2_r, dst3_r); + CLIP_SH4_0_255(dst4_r, dst5_r, dst6_r, dst7_r); + PCKEV_B4_SB(dst1_r, dst0_r, dst3_r, dst2_r, dst5_r, dst4_r, dst7_r, dst6_r, + dst0, dst1, dst2, dst3); + ST8x4_UB(dst0, dst1, dst, dst_stride); + dst += (4 * dst_stride); + ST8x4_UB(dst2, dst3, dst, dst_stride); +} + +void ff_h264_idct_add_msa(uint8_t *dst, int16_t *src, + int32_t dst_stride) +{ + avc_idct4x4_addblk_msa(dst, src, dst_stride); + memset(src, 0, 16 * sizeof(dctcoef)); +} + +void ff_h264_idct8_addblk_msa(uint8_t *dst, int16_t *src, + int32_t dst_stride) +{ + avc_idct8_addblk_msa(dst, src, dst_stride); + memset(src, 0, 64 * sizeof(dctcoef)); +} + +void ff_h264_idct4x4_addblk_dc_msa(uint8_t *dst, int16_t *src, + int32_t dst_stride) +{ + avc_idct4x4_addblk_dc_msa(dst, src, dst_stride); +} + +void ff_h264_idct8_dc_addblk_msa(uint8_t *dst, int16_t *src, + int32_t dst_stride) +{ + avc_idct8_dc_addblk_msa(dst, src, dst_stride); +} + +void ff_h264_idct_add16_msa(uint8_t *dst, + const int32_t *blk_offset, + int16_t *block, int32_t dst_stride, + const uint8_t nzc[15 * 8]) +{ + int32_t i; + + for (i = 0; i < 16; i++) { + int32_t nnz = nzc[scan8[i]]; + + if (nnz) { + if (nnz == 1 && ((dctcoef *) block)[i * 16]) + ff_h264_idct4x4_addblk_dc_msa(dst + blk_offset[i], + block + i * 16 * sizeof(pixel), + dst_stride); + else + ff_h264_idct_add_msa(dst + blk_offset[i], + block + i * 16 * sizeof(pixel), + dst_stride); + } + } +} + +void ff_h264_idct8_add4_msa(uint8_t *dst, const int32_t *blk_offset, + int16_t *block, int32_t dst_stride, + const uint8_t nzc[15 * 8]) +{ + int32_t cnt; + + for (cnt = 0; cnt < 16; cnt += 4) { + int32_t nnz = nzc[scan8[cnt]]; + + if (nnz) { + if (nnz == 1 && ((dctcoef *) block)[cnt * 16]) + ff_h264_idct8_dc_addblk_msa(dst + blk_offset[cnt], + block + cnt * 16 * sizeof(pixel), + dst_stride); + else + ff_h264_idct8_addblk_msa(dst + blk_offset[cnt], + block + cnt * 16 * sizeof(pixel), + dst_stride); + } + } +} + +void ff_h264_idct_add8_msa(uint8_t **dst, + const int32_t *blk_offset, + int16_t *block, int32_t dst_stride, + const uint8_t nzc[15 * 8]) +{ + int32_t i, j; + + for (j = 1; j < 3; j++) { + for (i = (j * 16); i < (j * 16 + 4); i++) { + if (nzc[scan8[i]]) + ff_h264_idct_add_msa(dst[j - 1] + blk_offset[i], + block + i * 16 * sizeof(pixel), + dst_stride); + else if (((dctcoef *) block)[i * 16]) + ff_h264_idct4x4_addblk_dc_msa(dst[j - 1] + blk_offset[i], + block + i * 16 * sizeof(pixel), + dst_stride); + } + } +} + +void ff_h264_idct_add8_422_msa(uint8_t **dst, + const int32_t *blk_offset, + int16_t *block, int32_t dst_stride, + const uint8_t nzc[15 * 8]) +{ + int32_t i, j; + + for (j = 1; j < 3; j++) { + for (i = (j * 16); i < (j * 16 + 4); i++) { + if (nzc[scan8[i]]) + ff_h264_idct_add_msa(dst[j - 1] + blk_offset[i], + block + i * 16 * sizeof(pixel), + dst_stride); + else if (((dctcoef *) block)[i * 16]) + ff_h264_idct4x4_addblk_dc_msa(dst[j - 1] + blk_offset[i], + block + i * 16 * sizeof(pixel), + dst_stride); + } + } + + for (j = 1; j < 3; j++) { + for (i = (j * 16 + 4); i < (j * 16 + 8); i++) { + if (nzc[scan8[i + 4]]) + ff_h264_idct_add_msa(dst[j - 1] + blk_offset[i + 4], + block + i * 16 * sizeof(pixel), + dst_stride); + else if (((dctcoef *) block)[i * 16]) + ff_h264_idct4x4_addblk_dc_msa(dst[j - 1] + blk_offset[i + 4], + block + i * 16 * sizeof(pixel), + dst_stride); + } + } +} + +void ff_h264_idct_add16_intra_msa(uint8_t *dst, + const int32_t *blk_offset, + int16_t *block, + int32_t dst_stride, + const uint8_t nzc[15 * 8]) +{ + int32_t i; + + for (i = 0; i < 16; i++) { + if (nzc[scan8[i]]) + ff_h264_idct_add_msa(dst + blk_offset[i], + block + i * 16 * sizeof(pixel), dst_stride); + else if (((dctcoef *) block)[i * 16]) + ff_h264_idct4x4_addblk_dc_msa(dst + blk_offset[i], + block + i * 16 * sizeof(pixel), + dst_stride); + } +} + +void ff_h264_deq_idct_luma_dc_msa(int16_t *dst, int16_t *src, + int32_t de_qval) +{ + avc_deq_idct_luma_dc_msa(dst, src, de_qval); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264pred_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264pred_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264pred_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264pred_init_mips.c 2015-07-15 17:20:03.000000000 +0000 @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * Zhou Xiaoyong + * + * 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 "config.h" +#include "h264dsp_mips.h" +#include "h264pred_mips.h" + +#if HAVE_MSA +static av_cold void h264_pred_init_msa(H264PredContext *h, int codec_id, + const int bit_depth, + const int chroma_format_idc) +{ + if (8 == bit_depth) { + if (chroma_format_idc == 1) { + h->pred8x8[VERT_PRED8x8] = ff_h264_intra_pred_vert_8x8_msa; + h->pred8x8[HOR_PRED8x8] = ff_h264_intra_pred_horiz_8x8_msa; + } + + if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) { + if (chroma_format_idc == 1) { + h->pred8x8[PLANE_PRED8x8] = ff_h264_intra_predict_plane_8x8_msa; + } + } + if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 + && codec_id != AV_CODEC_ID_VP8) { + if (chroma_format_idc == 1) { + h->pred8x8[DC_PRED8x8] = ff_h264_intra_predict_dc_4blk_8x8_msa; + h->pred8x8[LEFT_DC_PRED8x8] = + ff_h264_intra_predict_hor_dc_8x8_msa; + h->pred8x8[TOP_DC_PRED8x8] = + ff_h264_intra_predict_vert_dc_8x8_msa; + h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = + ff_h264_intra_predict_mad_cow_dc_l0t_8x8_msa; + h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = + ff_h264_intra_predict_mad_cow_dc_0lt_8x8_msa; + h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = + ff_h264_intra_predict_mad_cow_dc_l00_8x8_msa; + h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = + ff_h264_intra_predict_mad_cow_dc_0l0_8x8_msa; + } + } else { + if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) { + h->pred8x8[7] = ff_vp8_pred8x8_127_dc_8_msa; + h->pred8x8[8] = ff_vp8_pred8x8_129_dc_8_msa; + } + } + + if (chroma_format_idc == 1) { + h->pred8x8[DC_128_PRED8x8] = ff_h264_intra_pred_dc_128_8x8_msa; + } + + h->pred16x16[DC_PRED8x8] = ff_h264_intra_pred_dc_16x16_msa; + h->pred16x16[VERT_PRED8x8] = ff_h264_intra_pred_vert_16x16_msa; + h->pred16x16[HOR_PRED8x8] = ff_h264_intra_pred_horiz_16x16_msa; + + switch (codec_id) { + case AV_CODEC_ID_SVQ3: + ; + break; + case AV_CODEC_ID_RV40: + ; + break; + case AV_CODEC_ID_VP7: + case AV_CODEC_ID_VP8: + h->pred16x16[7] = ff_vp8_pred16x16_127_dc_8_msa; + h->pred16x16[8] = ff_vp8_pred16x16_129_dc_8_msa; + break; + default: + h->pred16x16[PLANE_PRED8x8] = + ff_h264_intra_predict_plane_16x16_msa; + break; + } + + h->pred16x16[LEFT_DC_PRED8x8] = ff_h264_intra_pred_dc_left_16x16_msa; + h->pred16x16[TOP_DC_PRED8x8] = ff_h264_intra_pred_dc_top_16x16_msa; + h->pred16x16[DC_128_PRED8x8] = ff_h264_intra_pred_dc_128_16x16_msa; + } +} +#endif // #if HAVE_MSA + +#if HAVE_MMI +static av_cold void h264_pred_init_mmi(H264PredContext *h, int codec_id, + const int bit_depth, const int chroma_format_idc) +{ + if (bit_depth == 8) { + if (chroma_format_idc == 1) { + h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_8_mmi; + h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_8_mmi; + } else { + h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x16_vertical_8_mmi; + h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x16_horizontal_8_mmi; + } + + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_mmi; + h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_8_mmi; + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_mmi; + h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_8_mmi; + h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_8_mmi; + h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_8_mmi; + + switch (codec_id) { + case AV_CODEC_ID_SVQ3: + h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_svq3_8_mmi; + ; + break; + case AV_CODEC_ID_RV40: + h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_rv40_8_mmi; + ; + break; + case AV_CODEC_ID_VP7: + case AV_CODEC_ID_VP8: + ; + break; + default: + h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_h264_8_mmi; + break; + } + + if (codec_id == AV_CODEC_ID_SVQ3 || codec_id == AV_CODEC_ID_H264) { + if (chroma_format_idc == 1) { + h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_8_mmi; + h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_8_mmi; + } + } + } +} +#endif /* HAVE_MMI */ + +av_cold void ff_h264_pred_init_mips(H264PredContext *h, int codec_id, + int bit_depth, + const int chroma_format_idc) +{ +#if HAVE_MSA + h264_pred_init_msa(h, codec_id, bit_depth, chroma_format_idc); +#endif // #if HAVE_MSA +#if HAVE_MMI + h264_pred_init_mmi(h, codec_id, bit_depth, chroma_format_idc); +#endif /* HAVE_MMI */ +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264pred_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264pred_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264pred_mips.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264pred_mips.h 2015-07-15 17:20:03.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015 Zhou Xiaoyong + * + * 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 + */ + +#ifndef H264_PRED_MIPS_H +#define H264_PRED_MIPS_H + +#include "libavutil/attributes.h" +#include "libavutil/avassert.h" +#include "libavcodec/avcodec.h" +#include "libavcodec/h264pred.h" +#include "libavcodec/bit_depth_template.c" + +void ff_pred16x16_vertical_8_mmi(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_horizontal_8_mmi(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_dc_8_mmi(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8l_top_dc_8_mmi(uint8_t *src, int has_topleft, int has_topright, + ptrdiff_t stride); +void ff_pred8x8l_dc_8_mmi(uint8_t *src, int has_topleft, int has_topright, + ptrdiff_t stride); +void ff_pred8x8l_horizontal_8_mmi(uint8_t *src, int has_topleft, + int has_topright, ptrdiff_t stride); +void ff_pred8x8l_vertical_8_mmi(uint8_t *src, int has_topleft, + int has_topright, ptrdiff_t stride); +void ff_pred4x4_dc_8_mmi(uint8_t *src, const uint8_t *topright, + ptrdiff_t stride); +void ff_pred8x8_vertical_8_mmi(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_horizontal_8_mmi(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_plane_svq3_8_mmi(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_plane_rv40_8_mmi(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_plane_h264_8_mmi(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_top_dc_8_mmi(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_dc_8_mmi(uint8_t *src, ptrdiff_t stride); +void ff_pred8x16_vertical_8_mmi(uint8_t *src, ptrdiff_t stride); +void ff_pred8x16_horizontal_8_mmi(uint8_t *src, ptrdiff_t stride); + +#endif /* H264_PRED_MIPS_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264pred_mmi.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264pred_mmi.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264pred_mmi.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264pred_mmi.c 2015-07-20 17:20:03.000000000 +0000 @@ -0,0 +1,789 @@ +/* + * Loongson SIMD optimized h264pred + * + * Copyright (c) 2015 Loongson Technology Corporation Limited + * Copyright (c) 2015 Zhou Xiaoyong + * Zhang Shuangshuang + * + * 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 "h264pred_mips.h" +#include "constants.h" + +void ff_pred16x16_vertical_8_mmi(uint8_t *src, ptrdiff_t stride) +{ + __asm__ volatile ( + "dsubu $2, %0, %1 \r\n" + "daddu $3, %0, $0 \r\n" + "ldl $4, 7($2) \r\n" + "ldr $4, 0($2) \r\n" + "ldl $5, 15($2) \r\n" + "ldr $5, 8($2) \r\n" + "dli $6, 0x10 \r\n" + "1: \r\n" + "sdl $4, 7($3) \r\n" + "sdr $4, 0($3) \r\n" + "sdl $5, 15($3) \r\n" + "sdr $5, 8($3) \r\n" + "daddu $3, %1 \r\n" + "daddiu $6, -1 \r\n" + "bnez $6, 1b \r\n" + ::"r"(src),"r"(stride) + : "$2","$3","$4","$5","$6","memory" + ); +} + +void ff_pred16x16_horizontal_8_mmi(uint8_t *src, ptrdiff_t stride) +{ + __asm__ volatile ( + "daddiu $2, %0, -1 \r\n" + "daddu $3, %0, $0 \r\n" + "dli $6, 0x10 \r\n" + "1: \r\n" + "lbu $4, 0($2) \r\n" + "dmul $5, $4, %2 \r\n" + "sdl $5, 7($3) \r\n" + "sdr $5, 0($3) \r\n" + "sdl $5, 15($3) \r\n" + "sdr $5, 8($3) \r\n" + "daddu $2, %1 \r\n" + "daddu $3, %1 \r\n" + "daddiu $6, -1 \r\n" + "bnez $6, 1b \r\n" + ::"r"(src),"r"(stride),"r"(ff_pb_1) + : "$2","$3","$4","$5","$6","memory" + ); +} + +void ff_pred16x16_dc_8_mmi(uint8_t *src, ptrdiff_t stride) +{ + __asm__ volatile ( + "daddiu $2, %0, -1 \r\n" + "dli $6, 0x10 \r\n" + "xor $8, $8, $8 \r\n" + "1: \r\n" + "lbu $4, 0($2) \r\n" + "daddu $8, $8, $4 \r\n" + "daddu $2, $2, %1 \r\n" + "daddiu $6, $6, -1 \r\n" + "bnez $6, 1b \r\n" + "dli $6, 0x10 \r\n" + "negu $3, %1 \r\n" + "daddu $2, %0, $3 \r\n" + "2: \r\n" + "lbu $4, 0($2) \r\n" + "daddu $8, $8, $4 \r\n" + "daddiu $2, $2, 1 \r\n" + "daddiu $6, $6, -1 \r\n" + "bnez $6, 2b \r\n" + "daddiu $8, $8, 0x10 \r\n" + "dsra $8, 5 \r\n" + "dmul $5, $8, %2 \r\n" + "daddu $2, %0, $0 \r\n" + "dli $6, 0x10 \r\n" + "3: \r\n" + "sdl $5, 7($2) \r\n" + "sdr $5, 0($2) \r\n" + "sdl $5, 15($2) \r\n" + "sdr $5, 8($2) \r\n" + "daddu $2, $2, %1 \r\n" + "daddiu $6, $6, -1 \r\n" + "bnez $6, 3b \r\n" + ::"r"(src),"r"(stride),"r"(ff_pb_1) + : "$2","$3","$4","$5","$6","$8","memory" + ); +} + +void ff_pred8x8l_top_dc_8_mmi(uint8_t *src, int has_topleft, + int has_topright, ptrdiff_t stride) +{ + int y; + uint32_t dc; + + __asm__ volatile ( + "ldl $8, 7(%1) \r\n" + "ldr $8, 0(%1) \r\n" + "ldl $9, 7(%2) \r\n" + "ldr $9, 0(%2) \r\n" + "ldl $10, 7(%3) \r\n" + "ldr $10, 0(%3) \r\n" + "dmtc1 $8, $f2 \r\n" + "dmtc1 $9, $f4 \r\n" + "dmtc1 $10, $f6 \r\n" + "dmtc1 $0, $f0 \r\n" + "punpcklbh $f8, $f2, $f0 \r\n" + "punpckhbh $f10, $f2, $f0 \r\n" + "punpcklbh $f12, $f4, $f0 \r\n" + "punpckhbh $f14, $f4, $f0 \r\n" + "punpcklbh $f16, $f6, $f0 \r\n" + "punpckhbh $f18, $f6, $f0 \r\n" + "bnez %4, 1f \r\n" + "pinsrh_0 $f8, $f8, $f12 \r\n" + "1: \r\n" + "bnez %5, 2f \r\n" + "pinsrh_3 $f18, $f18, $f14 \r\n" + "2: \r\n" + "daddiu $8, $0, 2 \r\n" + "dmtc1 $8, $f20 \r\n" + "pshufh $f22, $f20, $f0 \r\n" + "pmullh $f12, $f12, $f22 \r\n" + "pmullh $f14, $f14, $f22 \r\n" + "paddh $f8, $f8, $f12 \r\n" + "paddh $f10, $f10, $f14 \r\n" + "paddh $f8, $f8, $f16 \r\n" + "paddh $f10, $f10, $f18 \r\n" + "paddh $f8, $f8, $f22 \r\n" + "paddh $f10, $f10, $f22 \r\n" + "psrah $f8, $f8, $f20 \r\n" + "psrah $f10, $f10, $f20 \r\n" + "packushb $f4, $f8, $f10 \r\n" + "biadd $f2, $f4 \r\n" + "mfc1 $9, $f2 \r\n" + "addiu $9, $9, 4 \r\n" + "dsrl $9, $9, 3 \r\n" + "li $8, 0x01010101 \r\n" + "mul %0, $9, $8 \r\n" + : "=r"(dc) + : "r"(src-stride-1),"r"(src-stride),"r"(src-stride+1), + "r"(has_topleft),"r"(has_topright) + : "$8","$9","$10" + ); + + for (y=0; y<8; y++) { + AV_WN4PA(((uint32_t*)src)+0, dc); + AV_WN4PA(((uint32_t*)src)+1, dc); + src += stride; + } +} + +void ff_pred8x8l_dc_8_mmi(uint8_t *src, int has_topleft, + int has_topright, ptrdiff_t stride) +{ + int y; + uint32_t dc, dc1, dc2; + + const int l0 = ((has_topleft ? src[-1+-1*stride] : src[-1+0*stride]) + 2*src[-1+0*stride] + src[-1+1*stride] + 2) >> 2; + const int l1 = (src[-1+0*stride] + 2*src[-1+1*stride] + src[-1+2*stride] + 2) >> 2; + const int l2 = (src[-1+1*stride] + 2*src[-1+2*stride] + src[-1+3*stride] + 2) >> 2; + const int l3 = (src[-1+2*stride] + 2*src[-1+3*stride] + src[-1+4*stride] + 2) >> 2; + const int l4 = (src[-1+3*stride] + 2*src[-1+4*stride] + src[-1+5*stride] + 2) >> 2; + const int l5 = (src[-1+4*stride] + 2*src[-1+5*stride] + src[-1+6*stride] + 2) >> 2; + const int l6 = (src[-1+5*stride] + 2*src[-1+6*stride] + src[-1+7*stride] + 2) >> 2; + const int l7 = (src[-1+6*stride] + 2*src[-1+7*stride] + src[-1+7*stride] + 2) >> 2; + + __asm__ volatile ( + "ldl $8, 7(%1) \r\n" + "ldr $8, 0(%1) \r\n" + "ldl $9, 7(%2) \r\n" + "ldr $9, 0(%2) \r\n" + "ldl $10, 7(%3) \r\n" + "ldr $10, 0(%3) \r\n" + "dmtc1 $8, $f2 \r\n" + "dmtc1 $9, $f4 \r\n" + "dmtc1 $10, $f6 \r\n" + "dmtc1 $0, $f0 \r\n" + "punpcklbh $f8, $f2, $f0 \r\n" + "punpckhbh $f10, $f2, $f0 \r\n" + "punpcklbh $f12, $f4, $f0 \r\n" + "punpckhbh $f14, $f4, $f0 \r\n" + "punpcklbh $f16, $f6, $f0 \r\n" + "punpckhbh $f18, $f6, $f0 \r\n" + "daddiu $8, $0, 3 \r\n" + "dmtc1 $8, $f20 \r\n" + "pshufh $f28, $f10, $f20 \r\n" + "pshufh $f30, $f18, $f20 \r\n" + "pinsrh_3 $f10, $f10, $f30 \r\n" + "pinsrh_3 $f18, $f18, $f28 \r\n" + "bnez %4, 1f \r\n" + "pinsrh_0 $f8, $f8, $f12 \r\n" + "1: \r\n" + "bnez %5, 2f \r\n" + "pshufh $f30, $f14, $f20 \r\n" + "pinsrh_3 $f10, $f10, $f30 \r\n" + "2: \r\n" + "daddiu $8, $0, 2 \r\n" + "dmtc1 $8, $f20 \r\n" + "pshufh $f22, $f20, $f0 \r\n" + "pmullh $f12, $f12, $f22 \r\n" + "pmullh $f14, $f14, $f22 \r\n" + "paddh $f8, $f8, $f12 \r\n" + "paddh $f10, $f10, $f14 \r\n" + "paddh $f8, $f8, $f16 \r\n" + "paddh $f10, $f10, $f18 \r\n" + "paddh $f8, $f8, $f22 \r\n" + "paddh $f10, $f10, $f22 \r\n" + "psrah $f8, $f8, $f20 \r\n" + "psrah $f10, $f10, $f20 \r\n" + "packushb $f4, $f8, $f10 \r\n" + "biadd $f2, $f4 \r\n" + "mfc1 %0, $f2 \r\n" + : "=r"(dc2) + : "r"(src-stride-1),"r"(src-stride),"r"(src-stride+1), + "r"(has_topleft),"r"(has_topright) + : "$8","$9","$10" + ); + + dc1 = l0+l1+l2+l3+l4+l5+l6+l7; + dc = PIXEL_SPLAT_X4((dc1+dc2+8)>>4); + + for (y=0; y<8; y++) { + AV_WN4PA(((uint32_t*)src)+0, dc); + AV_WN4PA(((uint32_t*)src)+1, dc); + src += stride; + } +} + +void ff_pred8x8l_horizontal_8_mmi(uint8_t *src, int has_topleft, + int has_topright, ptrdiff_t stride) +{ + const int l0 = ((has_topleft ? src[-1+-1*stride] : src[-1+0*stride]) + 2*src[-1+0*stride] + src[-1+1*stride] + 2) >> 2; + const int l1 = (src[-1+0*stride] + 2*src[-1+1*stride] + src[-1+2*stride] + 2) >> 2; + const int l2 = (src[-1+1*stride] + 2*src[-1+2*stride] + src[-1+3*stride] + 2) >> 2; + const int l3 = (src[-1+2*stride] + 2*src[-1+3*stride] + src[-1+4*stride] + 2) >> 2; + const int l4 = (src[-1+3*stride] + 2*src[-1+4*stride] + src[-1+5*stride] + 2) >> 2; + const int l5 = (src[-1+4*stride] + 2*src[-1+5*stride] + src[-1+6*stride] + 2) >> 2; + const int l6 = (src[-1+5*stride] + 2*src[-1+6*stride] + src[-1+7*stride] + 2) >> 2; + const int l7 = (src[-1+6*stride] + 2*src[-1+7*stride] + src[-1+7*stride] + 2) >> 2; + + AV_WN4PA(src+0*stride, PIXEL_SPLAT_X4(l0)); + AV_WN4PA(src+0*stride+4, PIXEL_SPLAT_X4(l0)); + AV_WN4PA(src+1*stride, PIXEL_SPLAT_X4(l1)); + AV_WN4PA(src+1*stride+4, PIXEL_SPLAT_X4(l1)); + AV_WN4PA(src+2*stride, PIXEL_SPLAT_X4(l2)); + AV_WN4PA(src+2*stride+4, PIXEL_SPLAT_X4(l2)); + AV_WN4PA(src+3*stride, PIXEL_SPLAT_X4(l3)); + AV_WN4PA(src+3*stride+4, PIXEL_SPLAT_X4(l3)); + AV_WN4PA(src+4*stride, PIXEL_SPLAT_X4(l4)); + AV_WN4PA(src+4*stride+4, PIXEL_SPLAT_X4(l4)); + AV_WN4PA(src+5*stride, PIXEL_SPLAT_X4(l5)); + AV_WN4PA(src+5*stride+4, PIXEL_SPLAT_X4(l5)); + AV_WN4PA(src+6*stride, PIXEL_SPLAT_X4(l6)); + AV_WN4PA(src+6*stride+4, PIXEL_SPLAT_X4(l6)); + AV_WN4PA(src+7*stride, PIXEL_SPLAT_X4(l7)); + AV_WN4PA(src+7*stride+4, PIXEL_SPLAT_X4(l7)); +} + +void ff_pred8x8l_vertical_8_mmi(uint8_t *src, int has_topleft, + int has_topright, ptrdiff_t stride) +{ + int y; + uint32_t a, b; + + __asm__ volatile ( + "ldl $8, 7(%1) \r\n" + "ldr $8, 0(%1) \r\n" + "ldl $9, 7(%2) \r\n" + "ldr $9, 0(%2) \r\n" + "ldl $10, 7(%3) \r\n" + "ldr $10, 0(%3) \r\n" + "dmtc1 $8, $f2 \r\n" + "dmtc1 $9, $f4 \r\n" + "dmtc1 $10, $f6 \r\n" + "dmtc1 $0, $f0 \r\n" + "punpcklbh $f8, $f2, $f0 \r\n" + "punpckhbh $f10, $f2, $f0 \r\n" + "punpcklbh $f12, $f4, $f0 \r\n" + "punpckhbh $f14, $f4, $f0 \r\n" + "punpcklbh $f16, $f6, $f0 \r\n" + "punpckhbh $f18, $f6, $f0 \r\n" + "bnez %4, 1f \r\n" + "pinsrh_0 $f8, $f8, $f12 \r\n" + "1: \r\n" + "bnez %5, 2f \r\n" + "pinsrh_3 $f18, $f18, $f14 \r\n" + "2: \r\n" + "daddiu $8, $0, 2 \r\n" + "dmtc1 $8, $f20 \r\n" + "pshufh $f22, $f20, $f0 \r\n" + "pmullh $f12, $f12, $f22 \r\n" + "pmullh $f14, $f14, $f22 \r\n" + "paddh $f8, $f8, $f12 \r\n" + "paddh $f10, $f10, $f14 \r\n" + "paddh $f8, $f8, $f16 \r\n" + "paddh $f10, $f10, $f18 \r\n" + "paddh $f8, $f8, $f22 \r\n" + "paddh $f10, $f10, $f22 \r\n" + "psrah $f8, $f8, $f20 \r\n" + "psrah $f10, $f10, $f20 \r\n" + "packushb $f4, $f8, $f10 \r\n" + "sdc1 $f4, %0 \r\n" + : "=m"(*src) + : "r"(src-stride-1),"r"(src-stride),"r"(src-stride+1), + "r"(has_topleft),"r"(has_topright) + : "$8","$9","$10" + ); + + a = AV_RN4PA(((uint32_t*)src)+0); + b = AV_RN4PA(((uint32_t*)src)+1); + + for (y=1; y<8; y++) { + AV_WN4PA(((uint32_t*)(src+y*stride))+0, a); + AV_WN4PA(((uint32_t*)(src+y*stride))+1, b); + } +} + +void ff_pred4x4_dc_8_mmi(uint8_t *src, const uint8_t *topright, + ptrdiff_t stride) +{ + const int dc = (src[-stride] + src[1-stride] + src[2-stride] + + src[3-stride] + src[-1+0*stride] + src[-1+1*stride] + + src[-1+2*stride] + src[-1+3*stride] + 4) >>3; + + __asm__ volatile ( + "daddu $2, %2, $0 \r\n" + "dmul $3, $2, %3 \r\n" + "xor $4, $4, $4 \r\n" + "gsswx $3, 0(%0,$4) \r\n" + "daddu $4, %1 \r\n" + "gsswx $3, 0(%0,$4) \r\n" + "daddu $4, %1 \r\n" + "gsswx $3, 0(%0,$4) \r\n" + "daddu $4, %1 \r\n" + "gsswx $3, 0(%0,$4) \r\n" + ::"r"(src),"r"(stride),"r"(dc),"r"(ff_pb_1) + : "$2","$3","$4","memory" + ); +} + +void ff_pred8x8_vertical_8_mmi(uint8_t *src, ptrdiff_t stride) +{ + __asm__ volatile ( + "dsubu $2, %0, %1 \r\n" + "daddu $3, %0, $0 \r\n" + "ldl $4, 7($2) \r\n" + "ldr $4, 0($2) \r\n" + "dli $5, 0x8 \r\n" + "1: \r\n" + "sdl $4, 7($3) \r\n" + "sdr $4, 0($3) \r\n" + "daddu $3, %1 \r\n" + "daddiu $5, -1 \r\n" + "bnez $5, 1b \r\n" + ::"r"(src),"r"(stride) + : "$2","$3","$4","$5","memory" + ); +} + +void ff_pred8x8_horizontal_8_mmi(uint8_t *src, ptrdiff_t stride) +{ + __asm__ volatile ( + "daddiu $2, %0, -1 \r\n" + "daddu $3, %0, $0 \r\n" + "dli $6, 0x8 \r\n" + "1: \r\n" + "lbu $4, 0($2) \r\n" + "dmul $5, $4, %2 \r\n" + "sdl $5, 7($3) \r\n" + "sdr $5, 0($3) \r\n" + "daddu $2, %1 \r\n" + "daddu $3, %1 \r\n" + "daddiu $6, -1 \r\n" + "bnez $6, 1b \r\n" + ::"r"(src),"r"(stride),"r"(ff_pb_1) + : "$2","$3","$4","$5","$6","memory" + ); +} + +static void ff_pred16x16_plane_compat_8_mmi(uint8_t *src, ptrdiff_t stride, + const int svq3, const int rv40) +{ + __asm__ volatile ( + "negu $2, %1 \r\n" + "daddu $3, %0, $2 \r\n" + "xor $f8, $f8, $f8 \r\n" + "gslwlc1 $f0, 2($3) \r\n" + "gslwrc1 $f0, -1($3) \r\n" + "gslwlc1 $f2, 6($3) \r\n" + "gslwrc1 $f2, 3($3) \r\n" + "gslwlc1 $f4, 11($3) \r\n" + "gslwrc1 $f4, 8($3) \r\n" + "gslwlc1 $f6, 15($3) \r\n" + "gslwrc1 $f6, 12($3) \r\n" + "punpcklbh $f0, $f0, $f8 \r\n" + "punpcklbh $f2, $f2, $f8 \r\n" + "punpcklbh $f4, $f4, $f8 \r\n" + "punpcklbh $f6, $f6, $f8 \r\n" + "dmtc1 %4, $f20 \r\n" + "dmtc1 %5, $f22 \r\n" + "dmtc1 %6, $f24 \r\n" + "dmtc1 %7, $f26 \r\n" + "pmullh $f0, $f0, $f20 \r\n" + "pmullh $f2, $f2, $f22 \r\n" + "pmullh $f4, $f4, $f24 \r\n" + "pmullh $f6, $f6, $f26 \r\n" + "paddsh $f0, $f0, $f4 \r\n" + "paddsh $f2, $f2, $f6 \r\n" + "paddsh $f0, $f0, $f2 \r\n" + "dli $4, 0xE \r\n" + "dmtc1 $4, $f28 \r\n" + "pshufh $f2, $f0, $f28 \r\n" + "paddsh $f0, $f0, $f2 \r\n" + "dli $4, 0x1 \r\n" + "dmtc1 $4, $f30 \r\n" + "pshufh $f2, $f0, $f30 \r\n" + "paddsh $f10, $f0, $f2 \r\n" + "daddiu $3, %0, -1 \r\n" + "daddu $3, $2 \r\n" + "lbu $4, 0($3) \r\n" + "lbu $8, 16($3) \r\n" + "daddu $3, %1 \r\n" + "lbu $5, 0($3) \r\n" + "daddu $3, %1 \r\n" + "lbu $6, 0($3) \r\n" + "daddu $3, %1 \r\n" + "lbu $7, 0($3) \r\n" + "dsll $5, 16 \r\n" + "dsll $6, 32 \r\n" + "dsll $7, 48 \r\n" + "or $6, $7 \r\n" + "or $4, $5 \r\n" + "or $4, $6 \r\n" + "dmtc1 $4, $f0 \r\n" + "daddu $3, %1 \r\n" + "lbu $4, 0($3) \r\n" + "daddu $3, %1 \r\n" + "lbu $5, 0($3) \r\n" + "daddu $3, %1 \r\n" + "lbu $6, 0($3) \r\n" + "daddu $3, %1 \r\n" + "lbu $7, 0($3) \r\n" + "dsll $5, 16 \r\n" + "dsll $6, 32 \r\n" + "dsll $7, 48 \r\n" + "or $6, $7 \r\n" + "or $4, $5 \r\n" + "or $4, $6 \r\n" + "dmtc1 $4, $f2 \r\n" + "daddu $3, %1 \r\n" + "daddu $3, %1 \r\n" + "lbu $4, 0($3) \r\n" + "daddu $3, %1 \r\n" + "lbu $5, 0($3) \r\n" + "daddu $3, %1 \r\n" + "lbu $6, 0($3) \r\n" + "daddu $3, %1 \r\n" + "lbu $7, 0($3) \r\n" + "dsll $5, 16 \r\n" + "dsll $6, 32 \r\n" + "dsll $7, 48 \r\n" + "or $6, $7 \r\n" + "or $4, $5 \r\n" + "or $4, $6 \r\n" + "dmtc1 $4, $f4 \r\n" + "daddu $3, %1 \r\n" + "lbu $4, 0($3) \r\n" + "daddu $3, %1 \r\n" + "lbu $5, 0($3) \r\n" + "daddu $3, %1 \r\n" + "lbu $6, 0($3) \r\n" + "daddu $3, %1 \r\n" + "lbu $7, 0($3) \r\n" + "daddu $8, $7 \r\n" + "daddiu $8, 1 \r\n" + "dsll $8, 4 \r\n" + "dsll $5, 16 \r\n" + "dsll $6, 32 \r\n" + "dsll $7, 48 \r\n" + "or $6, $7 \r\n" + "or $4, $5 \r\n" + "or $4, $6 \r\n" + "dmtc1 $4, $f6 \r\n" + "pmullh $f0, $f0, $f20 \r\n" + "pmullh $f2, $f2, $f22 \r\n" + "pmullh $f4, $f4, $f24 \r\n" + "pmullh $f6, $f6, $f26 \r\n" + "paddsh $f0, $f0, $f4 \r\n" + "paddsh $f2, $f2, $f6 \r\n" + "paddsh $f0, $f0, $f2 \r\n" + "pshufh $f2, $f0, $f28 \r\n" + "paddsh $f0, $f0, $f2 \r\n" + "pshufh $f2, $f0, $f30 \r\n" + "paddsh $f12, $f0, $f2 \r\n" + "dmfc1 $2, $f10 \r\n" + "dsll $2, 48 \r\n" + "dsra $2, 48 \r\n" + "dmfc1 $3, $f12 \r\n" + "dsll $3, 48 \r\n" + "dsra $3, 48 \r\n" + "beqz %2, 1f \r\n" + "dli $4, 4 \r\n" + "ddiv $2, $4 \r\n" + "ddiv $3, $4 \r\n" + "dli $4, 5 \r\n" + "dmul $2, $4 \r\n" + "dmul $3, $4 \r\n" + "dli $4, 16 \r\n" + "ddiv $2, $4 \r\n" + "ddiv $3, $4 \r\n" + "daddu $4, $2, $0 \r\n" + "daddu $2, $3, $0 \r\n" + "daddu $3, $4, $0 \r\n" + "b 2f \r\n" + "1: \r\n" + "beqz %3, 1f \r\n" + "dsra $4, $2, 2 \r\n" + "daddu $2, $4 \r\n" + "dsra $4, $3, 2 \r\n" + "daddu $3, $4 \r\n" + "dsra $2, 4 \r\n" + "dsra $3, 4 \r\n" + "b 2f \r\n" + "1: \r\n" + "dli $4, 5 \r\n" + "dmul $2, $4 \r\n" + "dmul $3, $4 \r\n" + "daddiu $2, 32 \r\n" + "daddiu $3, 32 \r\n" + "dsra $2, 6 \r\n" + "dsra $3, 6 \r\n" + "2: \r\n" + "daddu $5, $2, $3 \r\n" + "dli $4, 7 \r\n" + "dmul $5, $4 \r\n" + "dsubu $8, $5 \r\n" + "dmtc1 $0, $f8 \r\n" + "dmtc1 $2, $f0 \r\n" + "pshufh $f0, $f0, $f8 \r\n" + "dmtc1 $3, $f10 \r\n" + "pshufh $f10, $f10, $f8 \r\n" + "dmtc1 $8, $f12 \r\n" + "pshufh $f12, $f12, $f8 \r\n" + "dli $4, 5 \r\n" + "dmtc1 $4, $f14 \r\n" + "dmtc1 %8, $f2 \r\n" + "pmullh $f2, $f2, $f0 \r\n" + "dmtc1 %9, $f4 \r\n" + "pmullh $f4, $f4, $f0 \r\n" + "dmtc1 %10, $f6 \r\n" + "pmullh $f6, $f6, $f0 \r\n" + "dmtc1 %11, $f8 \r\n" + "pmullh $f8, $f8, $f0 \r\n" + "daddu $3, %0, $0 \r\n" + "dli $2, 16 \r\n" + "1: \r\n" + "paddsh $f16, $f2, $f12 \r\n" + "psrah $f16, $f16, $f14 \r\n" + "paddsh $f18, $f4, $f12 \r\n" + "psrah $f18, $f18, $f14 \r\n" + "packushb $f20, $f16, $f18 \r\n" + "gssdlc1 $f20, 7($3) \r\n" + "gssdrc1 $f20, 0($3) \r\n" + "paddsh $f16, $f6, $f12 \r\n" + "psrah $f16, $f16, $f14 \r\n" + "paddsh $f18, $f8, $f12 \r\n" + "psrah $f18, $f18, $f14 \r\n" + "packushb $f20, $f16, $f18 \r\n" + "gssdlc1 $f20, 15($3) \r\n" + "gssdrc1 $f20, 8($3) \r\n" + "paddsh $f12, $f12, $f10 \r\n" + "daddu $3, %1 \r\n" + "daddiu $2, -1 \r\n" + "bnez $2, 1b \r\n" + ::"r"(src),"r"(stride),"r"(svq3),"r"(rv40), + "r"(ff_pw_m8tom5),"r"(ff_pw_m4tom1),"r"(ff_pw_1to4),"r"(ff_pw_5to8), + "r"(ff_pw_0to3),"r"(ff_pw_4to7),"r"(ff_pw_8tob),"r"(ff_pw_ctof) + : "$2","$3","$4","$5","$6","$7","$8","memory" + ); +} + +void ff_pred16x16_plane_svq3_8_mmi(uint8_t *src, ptrdiff_t stride) +{ + ff_pred16x16_plane_compat_8_mmi(src, stride, 1, 0); +} + +void ff_pred16x16_plane_rv40_8_mmi(uint8_t *src, ptrdiff_t stride) +{ + ff_pred16x16_plane_compat_8_mmi(src, stride, 0, 1); +} + +void ff_pred16x16_plane_h264_8_mmi(uint8_t *src, ptrdiff_t stride) +{ + ff_pred16x16_plane_compat_8_mmi(src, stride, 0, 0); +} + +void ff_pred8x8_top_dc_8_mmi(uint8_t *src, ptrdiff_t stride) +{ + __asm__ volatile ( + "dli $2, 2 \r\n" + "xor $f0, $f0, $f0 \r\n" + "xor $f2, $f2, $f2 \r\n" + "xor $f30, $f30, $f30 \r\n" + "negu $3, %1 \r\n" + "daddu $3, $3, %0 \r\n" + "gsldlc1 $f4, 7($3) \r\n" + "gsldrc1 $f4, 0($3) \r\n" + "punpcklbh $f0, $f4, $f30 \r\n" + "punpckhbh $f2, $f4, $f30 \r\n" + "biadd $f0, $f0 \r\n" + "biadd $f2, $f2 \r\n" + "pshufh $f0, $f0, $f30 \r\n" + "pshufh $f2, $f2, $f30 \r\n" + "dmtc1 $2, $f4 \r\n" + "pshufh $f4, $f4, $f30 \r\n" + "paddush $f0, $f0, $f4 \r\n" + "paddush $f2, $f2, $f4 \r\n" + "dmtc1 $2, $f4 \r\n" + "psrlh $f0, $f0, $f4 \r\n" + "psrlh $f2, $f2, $f4 \r\n" + "packushb $f4, $f0, $f2 \r\n" + "dli $2, 8 \r\n" + "1: \r\n" + "gssdlc1 $f4, 7(%0) \r\n" + "gssdrc1 $f4, 0(%0) \r\n" + "daddu %0, %0, %1 \r\n" + "daddiu $2, $2, -1 \r\n" + "bnez $2, 1b \r\n" + ::"r"(src),"r"(stride) + : "$2","$3","memory" + ); +} + +void ff_pred8x8_dc_8_mmi(uint8_t *src, ptrdiff_t stride) +{ + __asm__ volatile ( + "negu $2, %1 \r\n" + "daddu $2, $2, %0 \r\n" + "daddiu $5, $2, 4 \r\n" + "lbu $6, 0($2) \r\n" + "daddu $3, $0, $6 \r\n" + "daddiu $2, 1 \r\n" + "lbu $6, 0($5) \r\n" + "daddu $4, $0, $6 \r\n" + "daddiu $5, 1 \r\n" + "lbu $6, 0($2) \r\n" + "daddu $3, $3, $6 \r\n" + "daddiu $2, 1 \r\n" + "lbu $6, 0($5) \r\n" + "daddu $4, $4, $6 \r\n" + "daddiu $5, 1 \r\n" + "lbu $6, 0($2) \r\n" + "daddu $3, $3, $6 \r\n" + "daddiu $2, 1 \r\n" + "lbu $6, 0($5) \r\n" + "daddu $4, $4, $6 \r\n" + "daddiu $5, 1 \r\n" + "lbu $6, 0($2) \r\n" + "daddu $3, $3, $6 \r\n" + "daddiu $2, 1 \r\n" + "lbu $6, 0($5) \r\n" + "daddu $4, $4, $6 \r\n" + "daddiu $5, 1 \r\n" + "dli $6, -1 \r\n" + "daddu $6, $6, %0 \r\n" + "lbu $5, 0($6) \r\n" + "daddu $7, $0, $5 \r\n" + "daddu $6, $6, %1 \r\n" + "lbu $5, 0($6) \r\n" + "daddu $7, $7, $5 \r\n" + "daddu $6, $6, %1 \r\n" + "lbu $5, 0($6) \r\n" + "daddu $7, $7, $5 \r\n" + "daddu $6, $6, %1 \r\n" + "lbu $5, 0($6) \r\n" + "daddu $7, $7, $5 \r\n" + "daddu $6, $6, %1 \r\n" + "lbu $5, 0($6) \r\n" + "daddu $8, $0, $5 \r\n" + "daddu $6, $6, %1 \r\n" + "lbu $5, 0($6) \r\n" + "daddu $8, $8, $5 \r\n" + "daddu $6, $6, %1 \r\n" + "lbu $5, 0($6) \r\n" + "daddu $8, $8, $5 \r\n" + "daddu $6, $6, %1 \r\n" + "lbu $5, 0($6) \r\n" + "daddu $8, $8, $5 \r\n" + "daddu $3, $3, $7 \r\n" + "daddiu $3, $3, 4 \r\n" + "daddiu $4, $4, 2 \r\n" + "daddiu $5, $8, 2 \r\n" + "daddu $6, $4, $5 \r\n" + "dsrl $3, 3 \r\n" + "dsrl $4, 2 \r\n" + "dsrl $5, 2 \r\n" + "dsrl $6, 3 \r\n" + "xor $f30, $f30, $f30 \r\n" + "dmtc1 $3, $f0 \r\n" + "pshufh $f0, $f0, $f30 \r\n" + "dmtc1 $4, $f2 \r\n" + "pshufh $f2, $f2, $f30 \r\n" + "dmtc1 $5, $f4 \r\n" + "pshufh $f4, $f4, $f30 \r\n" + "dmtc1 $6, $f6 \r\n" + "pshufh $f6, $f6, $f30 \r\n" + "packushb $f0, $f0, $f2 \r\n" + "packushb $f2, $f4, $f6 \r\n" + "daddu $2, $0, %0 \r\n" + "sdc1 $f0, 0($2) \r\n" + "daddu $2, $2, %1 \r\n" + "sdc1 $f0, 0($2) \r\n" + "daddu $2, $2, %1 \r\n" + "sdc1 $f0, 0($2) \r\n" + "daddu $2, $2, %1 \r\n" + "sdc1 $f0, 0($2) \r\n" + "daddu $2, $2, %1 \r\n" + "sdc1 $f2, 0($2) \r\n" + "daddu $2, $2, %1 \r\n" + "sdc1 $f2, 0($2) \r\n" + "daddu $2, $2, %1 \r\n" + "sdc1 $f2, 0($2) \r\n" + "daddu $2, $2, %1 \r\n" + "sdc1 $f2, 0($2) \r\n" + ::"r"(src),"r"(stride) + :"$2","$3","$4","$5","$6","$7","$8","memory" + ); +} + +void ff_pred8x16_vertical_8_mmi(uint8_t *src, ptrdiff_t stride) +{ + __asm__ volatile ( + "dsubu $2, %0, %1 \r\n" + "daddu $3, %0, $0 \r\n" + "ldl $4, 7($2) \r\n" + "ldr $4, 0($2) \r\n" + "dli $5, 0x10 \r\n" + "1: \r\n" + "sdl $4, 7($3) \r\n" + "sdr $4, 0($3) \r\n" + "daddu $3, %1 \r\n" + "daddiu $5, -1 \r\n" + "bnez $5, 1b \r\n" + ::"r"(src),"r"(stride) + : "$2","$3","$4","$5","memory" + ); +} + +void ff_pred8x16_horizontal_8_mmi(uint8_t *src, ptrdiff_t stride) +{ + __asm__ volatile ( + "daddiu $2, %0, -1 \r\n" + "daddu $3, %0, $0 \r\n" + "dli $6, 0x10 \r\n" + "1: \r\n" + "lbu $4, 0($2) \r\n" + "dmul $5, $4, %2 \r\n" + "sdl $5, 7($3) \r\n" + "sdr $5, 0($3) \r\n" + "daddu $2, %1 \r\n" + "daddu $3, %1 \r\n" + "daddiu $6, -1 \r\n" + "bnez $6, 1b \r\n" + ::"r"(src),"r"(stride),"r"(ff_pb_1) + : "$2","$3","$4","$5","$6","memory" + ); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264pred_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264pred_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264pred_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264pred_msa.c 2015-06-11 17:20:04.000000000 +0000 @@ -0,0 +1,723 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "h264dsp_mips.h" + +static void intra_predict_vert_8x8_msa(uint8_t *src, uint8_t *dst, + int32_t dst_stride) +{ + uint32_t row; + uint32_t src_data1, src_data2; + + src_data1 = LW(src); + src_data2 = LW(src + 4); + + for (row = 8; row--;) { + SW(src_data1, dst); + SW(src_data2, (dst + 4)); + dst += dst_stride; + } +} + +static void intra_predict_vert_16x16_msa(uint8_t *src, uint8_t *dst, + int32_t dst_stride) +{ + uint32_t row; + v16u8 src0; + + src0 = LD_UB(src); + + for (row = 16; row--;) { + ST_UB(src0, dst); + dst += dst_stride; + } +} + +static void intra_predict_horiz_8x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + uint64_t out0, out1, out2, out3, out4, out5, out6, out7; + + out0 = src[0 * src_stride] * 0x0101010101010101; + out1 = src[1 * src_stride] * 0x0101010101010101; + out2 = src[2 * src_stride] * 0x0101010101010101; + out3 = src[3 * src_stride] * 0x0101010101010101; + out4 = src[4 * src_stride] * 0x0101010101010101; + out5 = src[5 * src_stride] * 0x0101010101010101; + out6 = src[6 * src_stride] * 0x0101010101010101; + out7 = src[7 * src_stride] * 0x0101010101010101; + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + SD4(out4, out5, out6, out7, dst, dst_stride); +} + +static void intra_predict_horiz_16x16_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + uint32_t row; + uint8_t inp0, inp1, inp2, inp3; + v16u8 src0, src1, src2, src3; + + for (row = 4; row--;) { + inp0 = src[0]; + src += src_stride; + inp1 = src[0]; + src += src_stride; + inp2 = src[0]; + src += src_stride; + inp3 = src[0]; + src += src_stride; + + src0 = (v16u8) __msa_fill_b(inp0); + src1 = (v16u8) __msa_fill_b(inp1); + src2 = (v16u8) __msa_fill_b(inp2); + src3 = (v16u8) __msa_fill_b(inp3); + + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void intra_predict_dc_8x8_msa(uint8_t *src_top, uint8_t *src_left, + int32_t src_stride_left, + uint8_t *dst, int32_t dst_stride, + uint8_t is_above, uint8_t is_left) +{ + uint32_t row; + uint32_t out, addition = 0; + v16u8 src_above, store; + v8u16 sum_above; + v4u32 sum_top; + v2u64 sum; + + if (is_left && is_above) { + src_above = LD_UB(src_top); + + sum_above = __msa_hadd_u_h(src_above, src_above); + sum_top = __msa_hadd_u_w(sum_above, sum_above); + sum = __msa_hadd_u_d(sum_top, sum_top); + addition = __msa_copy_u_w((v4i32) sum, 0); + + for (row = 0; row < 8; row++) { + addition += src_left[row * src_stride_left]; + } + + addition = (addition + 8) >> 4; + store = (v16u8) __msa_fill_b(addition); + } else if (is_left) { + for (row = 0; row < 8; row++) { + addition += src_left[row * src_stride_left]; + } + + addition = (addition + 4) >> 3; + store = (v16u8) __msa_fill_b(addition); + } else if (is_above) { + src_above = LD_UB(src_top); + + sum_above = __msa_hadd_u_h(src_above, src_above); + sum_top = __msa_hadd_u_w(sum_above, sum_above); + sum = __msa_hadd_u_d(sum_top, sum_top); + sum = (v2u64) __msa_srari_d((v2i64) sum, 3); + store = (v16u8) __msa_splati_b((v16i8) sum, 0); + } else { + store = (v16u8) __msa_ldi_b(128); + } + + out = __msa_copy_u_w((v4i32) store, 0); + + for (row = 8; row--;) { + SW(out, dst); + SW(out, (dst + 4)); + dst += dst_stride; + } +} + +static void intra_predict_dc_16x16_msa(uint8_t *src_top, uint8_t *src_left, + int32_t src_stride_left, + uint8_t *dst, int32_t dst_stride, + uint8_t is_above, uint8_t is_left) +{ + uint32_t row; + uint32_t addition = 0; + v16u8 src_above, store; + v8u16 sum_above; + v4u32 sum_top; + v2u64 sum; + + if (is_left && is_above) { + src_above = LD_UB(src_top); + + sum_above = __msa_hadd_u_h(src_above, src_above); + sum_top = __msa_hadd_u_w(sum_above, sum_above); + sum = __msa_hadd_u_d(sum_top, sum_top); + sum_top = (v4u32) __msa_pckev_w((v4i32) sum, (v4i32) sum); + sum = __msa_hadd_u_d(sum_top, sum_top); + addition = __msa_copy_u_w((v4i32) sum, 0); + + for (row = 0; row < 16; row++) { + addition += src_left[row * src_stride_left]; + } + + addition = (addition + 16) >> 5; + store = (v16u8) __msa_fill_b(addition); + } else if (is_left) { + for (row = 0; row < 16; row++) { + addition += src_left[row * src_stride_left]; + } + + addition = (addition + 8) >> 4; + store = (v16u8) __msa_fill_b(addition); + } else if (is_above) { + src_above = LD_UB(src_top); + + sum_above = __msa_hadd_u_h(src_above, src_above); + sum_top = __msa_hadd_u_w(sum_above, sum_above); + sum = __msa_hadd_u_d(sum_top, sum_top); + sum_top = (v4u32) __msa_pckev_w((v4i32) sum, (v4i32) sum); + sum = __msa_hadd_u_d(sum_top, sum_top); + sum = (v2u64) __msa_srari_d((v2i64) sum, 4); + store = (v16u8) __msa_splati_b((v16i8) sum, 0); + } else { + store = (v16u8) __msa_ldi_b(128); + } + + for (row = 16; row--;) { + ST_UB(store, dst); + dst += dst_stride; + } +} + +#define INTRA_PREDICT_VALDC_8X8_MSA(val) \ +static void intra_predict_##val##dc_8x8_msa(uint8_t *dst, \ + int32_t dst_stride) \ +{ \ + uint32_t row, out; \ + v16i8 store; \ + \ + store = __msa_ldi_b(val); \ + out = __msa_copy_u_w((v4i32) store, 0); \ + \ + for (row = 8; row--;) { \ + SW(out, dst); \ + SW(out, (dst + 4)); \ + dst += dst_stride; \ + } \ +} + +INTRA_PREDICT_VALDC_8X8_MSA(127); +INTRA_PREDICT_VALDC_8X8_MSA(129); + +#define INTRA_PREDICT_VALDC_16X16_MSA(val) \ +static void intra_predict_##val##dc_16x16_msa(uint8_t *dst, \ + int32_t dst_stride) \ +{ \ + uint32_t row; \ + v16u8 store; \ + \ + store = (v16u8) __msa_ldi_b(val); \ + \ + for (row = 16; row--;) { \ + ST_UB(store, dst); \ + dst += dst_stride; \ + } \ +} + +INTRA_PREDICT_VALDC_16X16_MSA(127); +INTRA_PREDICT_VALDC_16X16_MSA(129); + +static void intra_predict_plane_8x8_msa(uint8_t *src, int32_t stride) +{ + uint8_t lpcnt; + int32_t res, res0, res1, res2, res3; + uint64_t out0, out1; + v16i8 shf_mask = { 3, 5, 2, 6, 1, 7, 0, 8, 3, 5, 2, 6, 1, 7, 0, 8 }; + v8i16 short_multiplier = { 1, 2, 3, 4, 1, 2, 3, 4 }; + v4i32 int_multiplier = { 0, 1, 2, 3 }; + v16u8 src_top; + v8i16 vec9, vec10, vec11; + v4i32 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, vec8; + v2i64 sum; + + src_top = LD_UB(src - (stride + 1)); + src_top = (v16u8) __msa_vshf_b(shf_mask, (v16i8) src_top, (v16i8) src_top); + + vec9 = __msa_hsub_u_h(src_top, src_top); + vec9 *= short_multiplier; + vec8 = __msa_hadd_s_w(vec9, vec9); + sum = __msa_hadd_s_d(vec8, vec8); + + res0 = __msa_copy_s_w((v4i32) sum, 0); + + res1 = (src[4 * stride - 1] - src[2 * stride - 1]) + + 2 * (src[5 * stride - 1] - src[stride - 1]) + + 3 * (src[6 * stride - 1] - src[-1]) + + 4 * (src[7 * stride - 1] - src[-stride - 1]); + + res0 *= 17; + res1 *= 17; + res0 = (res0 + 16) >> 5; + res1 = (res1 + 16) >> 5; + + res3 = 3 * (res0 + res1); + res2 = 16 * (src[7 * stride - 1] + src[-stride + 7] + 1); + res = res2 - res3; + + vec8 = __msa_fill_w(res0); + vec4 = __msa_fill_w(res); + vec2 = __msa_fill_w(res1); + vec5 = vec8 * int_multiplier; + vec3 = vec8 * 4; + + for (lpcnt = 4; lpcnt--;) { + vec0 = vec5; + vec0 += vec4; + vec1 = vec0 + vec3; + vec6 = vec5; + vec4 += vec2; + vec6 += vec4; + vec7 = vec6 + vec3; + + SRA_4V(vec0, vec1, vec6, vec7, 5); + PCKEV_H2_SH(vec1, vec0, vec7, vec6, vec10, vec11); + CLIP_SH2_0_255(vec10, vec11); + PCKEV_B2_SH(vec10, vec10, vec11, vec11, vec10, vec11); + + out0 = __msa_copy_s_d((v2i64) vec10, 0); + out1 = __msa_copy_s_d((v2i64) vec11, 0); + SD(out0, src); + src += stride; + SD(out1, src); + src += stride; + + vec4 += vec2; + } +} + +static void intra_predict_plane_16x16_msa(uint8_t *src, int32_t stride) +{ + uint8_t lpcnt; + int32_t res0, res1, res2, res3; + uint64_t load0, load1; + v16i8 shf_mask = { 7, 8, 6, 9, 5, 10, 4, 11, 3, 12, 2, 13, 1, 14, 0, 15 }; + v8i16 short_multiplier = { 1, 2, 3, 4, 5, 6, 7, 8 }; + v4i32 int_multiplier = { 0, 1, 2, 3 }; + v16u8 src_top = { 0 }; + v8i16 vec9, vec10; + v4i32 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, vec8, res_add; + + load0 = LD(src - (stride + 1)); + load1 = LD(src - (stride + 1) + 9); + + INSERT_D2_UB(load0, load1, src_top); + + src_top = (v16u8) __msa_vshf_b(shf_mask, (v16i8) src_top, (v16i8) src_top); + + vec9 = __msa_hsub_u_h(src_top, src_top); + vec9 *= short_multiplier; + vec8 = __msa_hadd_s_w(vec9, vec9); + res_add = (v4i32) __msa_hadd_s_d(vec8, vec8); + + res0 = __msa_copy_s_w(res_add, 0) + __msa_copy_s_w(res_add, 2); + + res1 = (src[8 * stride - 1] - src[6 * stride - 1]) + + 2 * (src[9 * stride - 1] - src[5 * stride - 1]) + + 3 * (src[10 * stride - 1] - src[4 * stride - 1]) + + 4 * (src[11 * stride - 1] - src[3 * stride - 1]) + + 5 * (src[12 * stride - 1] - src[2 * stride - 1]) + + 6 * (src[13 * stride - 1] - src[stride - 1]) + + 7 * (src[14 * stride - 1] - src[-1]) + + 8 * (src[15 * stride - 1] - src[-1 * stride - 1]); + + res0 *= 5; + res1 *= 5; + res0 = (res0 + 32) >> 6; + res1 = (res1 + 32) >> 6; + + res3 = 7 * (res0 + res1); + res2 = 16 * (src[15 * stride - 1] + src[-stride + 15] + 1); + res2 -= res3; + + vec8 = __msa_fill_w(res0); + vec4 = __msa_fill_w(res2); + vec5 = __msa_fill_w(res1); + vec6 = vec8 * 4; + vec7 = vec8 * int_multiplier; + + for (lpcnt = 16; lpcnt--;) { + vec0 = vec7; + vec0 += vec4; + vec1 = vec0 + vec6; + vec2 = vec1 + vec6; + vec3 = vec2 + vec6; + + SRA_4V(vec0, vec1, vec2, vec3, 5); + PCKEV_H2_SH(vec1, vec0, vec3, vec2, vec9, vec10); + CLIP_SH2_0_255(vec9, vec10); + PCKEV_ST_SB(vec9, vec10, src); + src += stride; + + vec4 += vec5; + } +} + +static void intra_predict_dc_4blk_8x8_msa(uint8_t *src, int32_t stride) +{ + uint8_t lp_cnt; + uint32_t src0, src1, src3, src2 = 0; + uint32_t out0, out1, out2, out3; + v16u8 src_top; + v8u16 add; + v4u32 sum; + + src_top = LD_UB(src - stride); + add = __msa_hadd_u_h((v16u8) src_top, (v16u8) src_top); + sum = __msa_hadd_u_w(add, add); + src0 = __msa_copy_u_w((v4i32) sum, 0); + src1 = __msa_copy_u_w((v4i32) sum, 1); + + for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) { + src0 += src[lp_cnt * stride - 1]; + src2 += src[(4 + lp_cnt) * stride - 1]; + } + + src0 = (src0 + 4) >> 3; + src3 = (src1 + src2 + 4) >> 3; + src1 = (src1 + 2) >> 2; + src2 = (src2 + 2) >> 2; + out0 = src0 * 0x01010101; + out1 = src1 * 0x01010101; + out2 = src2 * 0x01010101; + out3 = src3 * 0x01010101; + + for (lp_cnt = 4; lp_cnt--;) { + SW(out0, src); + SW(out1, (src + 4)); + SW(out2, (src + 4 * stride)); + SW(out3, (src + 4 * stride + 4)); + src += stride; + } +} + +static void intra_predict_hor_dc_8x8_msa(uint8_t *src, int32_t stride) +{ + uint8_t lp_cnt; + uint32_t src0 = 0, src1 = 0; + uint64_t out0, out1; + + for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) { + src0 += src[lp_cnt * stride - 1]; + src1 += src[(4 + lp_cnt) * stride - 1]; + } + + src0 = (src0 + 2) >> 2; + src1 = (src1 + 2) >> 2; + out0 = src0 * 0x0101010101010101; + out1 = src1 * 0x0101010101010101; + + for (lp_cnt = 4; lp_cnt--;) { + SD(out0, src); + SD(out1, (src + 4 * stride)); + src += stride; + } +} + +static void intra_predict_vert_dc_8x8_msa(uint8_t *src, int32_t stride) +{ + uint8_t lp_cnt; + uint32_t out0 = 0, out1 = 0; + v16u8 src_top; + v8u16 add; + v4u32 sum; + v4i32 res0, res1; + + src_top = LD_UB(src - stride); + add = __msa_hadd_u_h(src_top, src_top); + sum = __msa_hadd_u_w(add, add); + sum = (v4u32) __msa_srari_w((v4i32) sum, 2); + res0 = (v4i32) __msa_splati_b((v16i8) sum, 0); + res1 = (v4i32) __msa_splati_b((v16i8) sum, 4); + out0 = __msa_copy_u_w(res0, 0); + out1 = __msa_copy_u_w(res1, 0); + + for (lp_cnt = 8; lp_cnt--;) { + SW(out0, src); + SW(out1, src + 4); + src += stride; + } +} + +static void intra_predict_mad_cow_dc_l0t_8x8_msa(uint8_t *src, int32_t stride) +{ + uint8_t lp_cnt; + uint32_t src0, src1, src2 = 0; + uint32_t out0, out1, out2; + v16u8 src_top; + v8u16 add; + v4u32 sum; + + src_top = LD_UB(src - stride); + add = __msa_hadd_u_h(src_top, src_top); + sum = __msa_hadd_u_w(add, add); + src0 = __msa_copy_u_w((v4i32) sum, 0); + src1 = __msa_copy_u_w((v4i32) sum, 1); + + for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) { + src2 += src[lp_cnt * stride - 1]; + } + src2 = (src0 + src2 + 4) >> 3; + src0 = (src0 + 2) >> 2; + src1 = (src1 + 2) >> 2; + out0 = src0 * 0x01010101; + out1 = src1 * 0x01010101; + out2 = src2 * 0x01010101; + + for (lp_cnt = 4; lp_cnt--;) { + SW(out2, src); + SW(out1, src + 4); + SW(out0, src + stride * 4); + SW(out1, src + stride * 4 + 4); + src += stride; + } +} + +static void intra_predict_mad_cow_dc_0lt_8x8_msa(uint8_t *src, int32_t stride) +{ + uint8_t lp_cnt; + uint32_t src0, src1, src2 = 0, src3; + uint32_t out0, out1, out2, out3; + v16u8 src_top; + v8u16 add; + v4u32 sum; + + src_top = LD_UB(src - stride); + add = __msa_hadd_u_h(src_top, src_top); + sum = __msa_hadd_u_w(add, add); + src0 = __msa_copy_u_w((v4i32) sum, 0); + src1 = __msa_copy_u_w((v4i32) sum, 1); + + for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) { + src2 += src[(4 + lp_cnt) * stride - 1]; + } + + src0 = (src0 + 2) >> 2; + src3 = (src1 + src2 + 4) >> 3; + src1 = (src1 + 2) >> 2; + src2 = (src2 + 2) >> 2; + + out0 = src0 * 0x01010101; + out1 = src1 * 0x01010101; + out2 = src2 * 0x01010101; + out3 = src3 * 0x01010101; + + for (lp_cnt = 4; lp_cnt--;) { + SW(out0, src); + SW(out1, src + 4); + SW(out2, src + stride * 4); + SW(out3, src + stride * 4 + 4); + src += stride; + } +} + +static void intra_predict_mad_cow_dc_l00_8x8_msa(uint8_t *src, int32_t stride) +{ + uint8_t lp_cnt; + uint32_t src0 = 0; + uint64_t out0, out1; + + for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) { + src0 += src[lp_cnt * stride - 1]; + } + + src0 = (src0 + 2) >> 2; + out0 = src0 * 0x0101010101010101; + out1 = 0x8080808080808080; + + for (lp_cnt = 4; lp_cnt--;) { + SD(out0, src); + SD(out1, src + stride * 4); + src += stride; + } +} + +static void intra_predict_mad_cow_dc_0l0_8x8_msa(uint8_t *src, int32_t stride) +{ + uint8_t lp_cnt; + uint32_t src0 = 0; + uint64_t out0, out1; + + for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) { + src0 += src[(4 + lp_cnt) * stride - 1]; + } + + src0 = (src0 + 2) >> 2; + + out0 = 0x8080808080808080; + out1 = src0 * 0x0101010101010101; + + for (lp_cnt = 4; lp_cnt--;) { + SD(out0, src); + SD(out1, src + stride * 4); + src += stride; + } +} + +void ff_h264_intra_predict_plane_8x8_msa(uint8_t *src, ptrdiff_t stride) +{ + intra_predict_plane_8x8_msa(src, stride); +} + +void ff_h264_intra_predict_dc_4blk_8x8_msa(uint8_t *src, ptrdiff_t stride) +{ + intra_predict_dc_4blk_8x8_msa(src, stride); +} + +void ff_h264_intra_predict_hor_dc_8x8_msa(uint8_t *src, ptrdiff_t stride) +{ + intra_predict_hor_dc_8x8_msa(src, stride); +} + +void ff_h264_intra_predict_vert_dc_8x8_msa(uint8_t *src, ptrdiff_t stride) +{ + intra_predict_vert_dc_8x8_msa(src, stride); +} + +void ff_h264_intra_predict_mad_cow_dc_l0t_8x8_msa(uint8_t *src, + ptrdiff_t stride) +{ + intra_predict_mad_cow_dc_l0t_8x8_msa(src, stride); +} + +void ff_h264_intra_predict_mad_cow_dc_0lt_8x8_msa(uint8_t *src, + ptrdiff_t stride) +{ + intra_predict_mad_cow_dc_0lt_8x8_msa(src, stride); +} + +void ff_h264_intra_predict_mad_cow_dc_l00_8x8_msa(uint8_t *src, + ptrdiff_t stride) +{ + intra_predict_mad_cow_dc_l00_8x8_msa(src, stride); +} + +void ff_h264_intra_predict_mad_cow_dc_0l0_8x8_msa(uint8_t *src, + ptrdiff_t stride) +{ + intra_predict_mad_cow_dc_0l0_8x8_msa(src, stride); +} + +void ff_h264_intra_predict_plane_16x16_msa(uint8_t *src, ptrdiff_t stride) +{ + intra_predict_plane_16x16_msa(src, stride); +} + +void ff_h264_intra_pred_vert_8x8_msa(uint8_t *src, ptrdiff_t stride) +{ + uint8_t *dst = src; + + intra_predict_vert_8x8_msa(src - stride, dst, stride); +} + +void ff_h264_intra_pred_horiz_8x8_msa(uint8_t *src, ptrdiff_t stride) +{ + uint8_t *dst = src; + + intra_predict_horiz_8x8_msa(src - 1, stride, dst, stride); +} + +void ff_h264_intra_pred_dc_16x16_msa(uint8_t *src, ptrdiff_t stride) +{ + uint8_t *src_top = src - stride; + uint8_t *src_left = src - 1; + uint8_t *dst = src; + + intra_predict_dc_16x16_msa(src_top, src_left, stride, dst, stride, 1, 1); +} + +void ff_h264_intra_pred_vert_16x16_msa(uint8_t *src, ptrdiff_t stride) +{ + uint8_t *dst = src; + + intra_predict_vert_16x16_msa(src - stride, dst, stride); +} + +void ff_h264_intra_pred_horiz_16x16_msa(uint8_t *src, ptrdiff_t stride) +{ + uint8_t *dst = src; + + intra_predict_horiz_16x16_msa(src - 1, stride, dst, stride); +} + +void ff_h264_intra_pred_dc_left_16x16_msa(uint8_t *src, ptrdiff_t stride) +{ + uint8_t *src_top = src - stride; + uint8_t *src_left = src - 1; + uint8_t *dst = src; + + intra_predict_dc_16x16_msa(src_top, src_left, stride, dst, stride, 0, 1); +} + +void ff_h264_intra_pred_dc_top_16x16_msa(uint8_t *src, ptrdiff_t stride) +{ + uint8_t *src_top = src - stride; + uint8_t *src_left = src - 1; + uint8_t *dst = src; + + intra_predict_dc_16x16_msa(src_top, src_left, stride, dst, stride, 1, 0); +} + +void ff_h264_intra_pred_dc_128_8x8_msa(uint8_t *src, ptrdiff_t stride) +{ + uint8_t *src_top = src - stride; + uint8_t *src_left = src - 1; + uint8_t *dst = src; + + intra_predict_dc_8x8_msa(src_top, src_left, stride, dst, stride, 0, 0); +} + +void ff_h264_intra_pred_dc_128_16x16_msa(uint8_t *src, ptrdiff_t stride) +{ + uint8_t *src_top = src - stride; + uint8_t *src_left = src - 1; + uint8_t *dst = src; + + intra_predict_dc_16x16_msa(src_top, src_left, stride, dst, stride, 0, 0); +} + +void ff_vp8_pred8x8_127_dc_8_msa(uint8_t *src, ptrdiff_t stride) +{ + intra_predict_127dc_8x8_msa(src, stride); +} + +void ff_vp8_pred8x8_129_dc_8_msa(uint8_t *src, ptrdiff_t stride) +{ + intra_predict_129dc_8x8_msa(src, stride); +} + +void ff_vp8_pred16x16_127_dc_8_msa(uint8_t *src, ptrdiff_t stride) +{ + intra_predict_127dc_16x16_msa(src, stride); +} + +void ff_vp8_pred16x16_129_dc_8_msa(uint8_t *src, ptrdiff_t stride) +{ + intra_predict_129dc_16x16_msa(src, stride); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264qpel_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264qpel_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264qpel_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264qpel_init_mips.c 2015-06-13 17:20:02.000000000 +0000 @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * + * 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 "h264dsp_mips.h" + +#if HAVE_MSA +static av_cold void h264qpel_init_msa(H264QpelContext *c, int bit_depth) +{ + if (8 == bit_depth) { + c->put_h264_qpel_pixels_tab[0][0] = ff_put_h264_qpel16_mc00_msa; + c->put_h264_qpel_pixels_tab[0][1] = ff_put_h264_qpel16_mc10_msa; + c->put_h264_qpel_pixels_tab[0][2] = ff_put_h264_qpel16_mc20_msa; + c->put_h264_qpel_pixels_tab[0][3] = ff_put_h264_qpel16_mc30_msa; + c->put_h264_qpel_pixels_tab[0][4] = ff_put_h264_qpel16_mc01_msa; + c->put_h264_qpel_pixels_tab[0][5] = ff_put_h264_qpel16_mc11_msa; + c->put_h264_qpel_pixels_tab[0][6] = ff_put_h264_qpel16_mc21_msa; + c->put_h264_qpel_pixels_tab[0][7] = ff_put_h264_qpel16_mc31_msa; + c->put_h264_qpel_pixels_tab[0][8] = ff_put_h264_qpel16_mc02_msa; + c->put_h264_qpel_pixels_tab[0][9] = ff_put_h264_qpel16_mc12_msa; + c->put_h264_qpel_pixels_tab[0][10] = ff_put_h264_qpel16_mc22_msa; + c->put_h264_qpel_pixels_tab[0][11] = ff_put_h264_qpel16_mc32_msa; + c->put_h264_qpel_pixels_tab[0][12] = ff_put_h264_qpel16_mc03_msa; + c->put_h264_qpel_pixels_tab[0][13] = ff_put_h264_qpel16_mc13_msa; + c->put_h264_qpel_pixels_tab[0][14] = ff_put_h264_qpel16_mc23_msa; + c->put_h264_qpel_pixels_tab[0][15] = ff_put_h264_qpel16_mc33_msa; + + c->put_h264_qpel_pixels_tab[1][0] = ff_put_h264_qpel8_mc00_msa; + c->put_h264_qpel_pixels_tab[1][1] = ff_put_h264_qpel8_mc10_msa; + c->put_h264_qpel_pixels_tab[1][2] = ff_put_h264_qpel8_mc20_msa; + c->put_h264_qpel_pixels_tab[1][3] = ff_put_h264_qpel8_mc30_msa; + c->put_h264_qpel_pixels_tab[1][4] = ff_put_h264_qpel8_mc01_msa; + c->put_h264_qpel_pixels_tab[1][5] = ff_put_h264_qpel8_mc11_msa; + c->put_h264_qpel_pixels_tab[1][6] = ff_put_h264_qpel8_mc21_msa; + c->put_h264_qpel_pixels_tab[1][7] = ff_put_h264_qpel8_mc31_msa; + c->put_h264_qpel_pixels_tab[1][8] = ff_put_h264_qpel8_mc02_msa; + c->put_h264_qpel_pixels_tab[1][9] = ff_put_h264_qpel8_mc12_msa; + c->put_h264_qpel_pixels_tab[1][10] = ff_put_h264_qpel8_mc22_msa; + c->put_h264_qpel_pixels_tab[1][11] = ff_put_h264_qpel8_mc32_msa; + c->put_h264_qpel_pixels_tab[1][12] = ff_put_h264_qpel8_mc03_msa; + c->put_h264_qpel_pixels_tab[1][13] = ff_put_h264_qpel8_mc13_msa; + c->put_h264_qpel_pixels_tab[1][14] = ff_put_h264_qpel8_mc23_msa; + c->put_h264_qpel_pixels_tab[1][15] = ff_put_h264_qpel8_mc33_msa; + + c->put_h264_qpel_pixels_tab[2][1] = ff_put_h264_qpel4_mc10_msa; + c->put_h264_qpel_pixels_tab[2][2] = ff_put_h264_qpel4_mc20_msa; + c->put_h264_qpel_pixels_tab[2][3] = ff_put_h264_qpel4_mc30_msa; + c->put_h264_qpel_pixels_tab[2][4] = ff_put_h264_qpel4_mc01_msa; + c->put_h264_qpel_pixels_tab[2][5] = ff_put_h264_qpel4_mc11_msa; + c->put_h264_qpel_pixels_tab[2][6] = ff_put_h264_qpel4_mc21_msa; + c->put_h264_qpel_pixels_tab[2][7] = ff_put_h264_qpel4_mc31_msa; + c->put_h264_qpel_pixels_tab[2][8] = ff_put_h264_qpel4_mc02_msa; + c->put_h264_qpel_pixels_tab[2][9] = ff_put_h264_qpel4_mc12_msa; + c->put_h264_qpel_pixels_tab[2][10] = ff_put_h264_qpel4_mc22_msa; + c->put_h264_qpel_pixels_tab[2][11] = ff_put_h264_qpel4_mc32_msa; + c->put_h264_qpel_pixels_tab[2][12] = ff_put_h264_qpel4_mc03_msa; + c->put_h264_qpel_pixels_tab[2][13] = ff_put_h264_qpel4_mc13_msa; + c->put_h264_qpel_pixels_tab[2][14] = ff_put_h264_qpel4_mc23_msa; + c->put_h264_qpel_pixels_tab[2][15] = ff_put_h264_qpel4_mc33_msa; + + c->avg_h264_qpel_pixels_tab[0][0] = ff_avg_h264_qpel16_mc00_msa; + c->avg_h264_qpel_pixels_tab[0][1] = ff_avg_h264_qpel16_mc10_msa; + c->avg_h264_qpel_pixels_tab[0][2] = ff_avg_h264_qpel16_mc20_msa; + c->avg_h264_qpel_pixels_tab[0][3] = ff_avg_h264_qpel16_mc30_msa; + c->avg_h264_qpel_pixels_tab[0][4] = ff_avg_h264_qpel16_mc01_msa; + c->avg_h264_qpel_pixels_tab[0][5] = ff_avg_h264_qpel16_mc11_msa; + c->avg_h264_qpel_pixels_tab[0][6] = ff_avg_h264_qpel16_mc21_msa; + c->avg_h264_qpel_pixels_tab[0][7] = ff_avg_h264_qpel16_mc31_msa; + c->avg_h264_qpel_pixels_tab[0][8] = ff_avg_h264_qpel16_mc02_msa; + c->avg_h264_qpel_pixels_tab[0][9] = ff_avg_h264_qpel16_mc12_msa; + c->avg_h264_qpel_pixels_tab[0][10] = ff_avg_h264_qpel16_mc22_msa; + c->avg_h264_qpel_pixels_tab[0][11] = ff_avg_h264_qpel16_mc32_msa; + c->avg_h264_qpel_pixels_tab[0][12] = ff_avg_h264_qpel16_mc03_msa; + c->avg_h264_qpel_pixels_tab[0][13] = ff_avg_h264_qpel16_mc13_msa; + c->avg_h264_qpel_pixels_tab[0][14] = ff_avg_h264_qpel16_mc23_msa; + c->avg_h264_qpel_pixels_tab[0][15] = ff_avg_h264_qpel16_mc33_msa; + + c->avg_h264_qpel_pixels_tab[1][0] = ff_avg_h264_qpel8_mc00_msa; + c->avg_h264_qpel_pixels_tab[1][1] = ff_avg_h264_qpel8_mc10_msa; + c->avg_h264_qpel_pixels_tab[1][2] = ff_avg_h264_qpel8_mc20_msa; + c->avg_h264_qpel_pixels_tab[1][3] = ff_avg_h264_qpel8_mc30_msa; + c->avg_h264_qpel_pixels_tab[1][4] = ff_avg_h264_qpel8_mc01_msa; + c->avg_h264_qpel_pixels_tab[1][5] = ff_avg_h264_qpel8_mc11_msa; + c->avg_h264_qpel_pixels_tab[1][6] = ff_avg_h264_qpel8_mc21_msa; + c->avg_h264_qpel_pixels_tab[1][7] = ff_avg_h264_qpel8_mc31_msa; + c->avg_h264_qpel_pixels_tab[1][8] = ff_avg_h264_qpel8_mc02_msa; + c->avg_h264_qpel_pixels_tab[1][9] = ff_avg_h264_qpel8_mc12_msa; + c->avg_h264_qpel_pixels_tab[1][10] = ff_avg_h264_qpel8_mc22_msa; + c->avg_h264_qpel_pixels_tab[1][11] = ff_avg_h264_qpel8_mc32_msa; + c->avg_h264_qpel_pixels_tab[1][12] = ff_avg_h264_qpel8_mc03_msa; + c->avg_h264_qpel_pixels_tab[1][13] = ff_avg_h264_qpel8_mc13_msa; + c->avg_h264_qpel_pixels_tab[1][14] = ff_avg_h264_qpel8_mc23_msa; + c->avg_h264_qpel_pixels_tab[1][15] = ff_avg_h264_qpel8_mc33_msa; + + c->avg_h264_qpel_pixels_tab[2][0] = ff_avg_h264_qpel4_mc00_msa; + c->avg_h264_qpel_pixels_tab[2][1] = ff_avg_h264_qpel4_mc10_msa; + c->avg_h264_qpel_pixels_tab[2][2] = ff_avg_h264_qpel4_mc20_msa; + c->avg_h264_qpel_pixels_tab[2][3] = ff_avg_h264_qpel4_mc30_msa; + c->avg_h264_qpel_pixels_tab[2][4] = ff_avg_h264_qpel4_mc01_msa; + c->avg_h264_qpel_pixels_tab[2][5] = ff_avg_h264_qpel4_mc11_msa; + c->avg_h264_qpel_pixels_tab[2][6] = ff_avg_h264_qpel4_mc21_msa; + c->avg_h264_qpel_pixels_tab[2][7] = ff_avg_h264_qpel4_mc31_msa; + c->avg_h264_qpel_pixels_tab[2][8] = ff_avg_h264_qpel4_mc02_msa; + c->avg_h264_qpel_pixels_tab[2][9] = ff_avg_h264_qpel4_mc12_msa; + c->avg_h264_qpel_pixels_tab[2][10] = ff_avg_h264_qpel4_mc22_msa; + c->avg_h264_qpel_pixels_tab[2][11] = ff_avg_h264_qpel4_mc32_msa; + c->avg_h264_qpel_pixels_tab[2][12] = ff_avg_h264_qpel4_mc03_msa; + c->avg_h264_qpel_pixels_tab[2][13] = ff_avg_h264_qpel4_mc13_msa; + c->avg_h264_qpel_pixels_tab[2][14] = ff_avg_h264_qpel4_mc23_msa; + c->avg_h264_qpel_pixels_tab[2][15] = ff_avg_h264_qpel4_mc33_msa; + } +} +#endif // #if HAVE_MSA + +av_cold void ff_h264qpel_init_mips(H264QpelContext *c, int bit_depth) +{ +#if HAVE_MSA + h264qpel_init_msa(c, bit_depth); +#endif // #if HAVE_MSA +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264qpel_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264qpel_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/h264qpel_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/h264qpel_msa.c 2015-06-13 17:20:02.000000000 +0000 @@ -0,0 +1,3600 @@ +/* + * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "h264dsp_mips.h" + +#define AVC_CALC_DPADD_H_6PIX_2COEFF_SH(in0, in1, in2, in3, in4, in5) \ +( { \ + v4i32 tmp0_m, tmp1_m; \ + v8i16 out0_m, out1_m, out2_m, out3_m; \ + v8i16 minus5h_m = __msa_ldi_h(-5); \ + v8i16 plus20h_m = __msa_ldi_h(20); \ + \ + ILVRL_H2_SW(in5, in0, tmp0_m, tmp1_m); \ + \ + tmp0_m = __msa_hadd_s_w((v8i16) tmp0_m, (v8i16) tmp0_m); \ + tmp1_m = __msa_hadd_s_w((v8i16) tmp1_m, (v8i16) tmp1_m); \ + \ + ILVRL_H2_SH(in1, in4, out0_m, out1_m); \ + DPADD_SH2_SW(out0_m, out1_m, minus5h_m, minus5h_m, tmp0_m, tmp1_m); \ + ILVRL_H2_SH(in2, in3, out2_m, out3_m); \ + DPADD_SH2_SW(out2_m, out3_m, plus20h_m, plus20h_m, tmp0_m, tmp1_m); \ + \ + SRARI_W2_SW(tmp0_m, tmp1_m, 10); \ + SAT_SW2_SW(tmp0_m, tmp1_m, 7); \ + out0_m = __msa_pckev_h((v8i16) tmp1_m, (v8i16) tmp0_m); \ + \ + out0_m; \ +} ) + +#define AVC_HORZ_FILTER_SH(in, mask0, mask1, mask2) \ +( { \ + v8i16 out0_m, out1_m; \ + v16i8 tmp0_m, tmp1_m; \ + v16i8 minus5b = __msa_ldi_b(-5); \ + v16i8 plus20b = __msa_ldi_b(20); \ + \ + tmp0_m = __msa_vshf_b((v16i8) mask0, in, in); \ + out0_m = __msa_hadd_s_h(tmp0_m, tmp0_m); \ + \ + tmp0_m = __msa_vshf_b((v16i8) mask1, in, in); \ + out0_m = __msa_dpadd_s_h(out0_m, minus5b, tmp0_m); \ + \ + tmp1_m = __msa_vshf_b((v16i8) (mask2), in, in); \ + out1_m = __msa_dpadd_s_h(out0_m, plus20b, tmp1_m); \ + \ + out1_m; \ +} ) + +static const uint8_t luma_mask_arr[16 * 8] = { + /* 8 width cases */ + 0, 5, 1, 6, 2, 7, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12, + 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 9, 7, 10, 8, 11, + 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, + + /* 4 width cases */ + 0, 5, 1, 6, 2, 7, 3, 8, 16, 21, 17, 22, 18, 23, 19, 24, + 1, 4, 2, 5, 3, 6, 4, 7, 17, 20, 18, 21, 19, 22, 20, 23, + 2, 3, 3, 4, 4, 5, 5, 6, 18, 19, 19, 20, 20, 21, 21, 22, + + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 24, 25, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 24, 25, 26 +}; + +#define AVC_CALC_DPADD_B_6PIX_2COEFF_SH(vec0, vec1, vec2, vec3, vec4, vec5, \ + out1, out2) \ +{ \ + v16i8 tmp0_m, tmp1_m; \ + v16i8 minus5b_m = __msa_ldi_b(-5); \ + v16i8 plus20b_m = __msa_ldi_b(20); \ + \ + ILVRL_B2_SB(vec5, vec0, tmp0_m, tmp1_m); \ + HADD_SB2_SH(tmp0_m, tmp1_m, out1, out2); \ + ILVRL_B2_SB(vec4, vec1, tmp0_m, tmp1_m); \ + DPADD_SB2_SH(tmp0_m, tmp1_m, minus5b_m, minus5b_m, out1, out2); \ + ILVRL_B2_SB(vec3, vec2, tmp0_m, tmp1_m); \ + DPADD_SB2_SH(tmp0_m, tmp1_m, plus20b_m, plus20b_m, out1, out2); \ +} + +#define AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(vec0, vec1, vec2, vec3, vec4, vec5) \ +( { \ + v8i16 tmp1_m; \ + v16i8 tmp0_m, tmp2_m; \ + v16i8 minus5b_m = __msa_ldi_b(-5); \ + v16i8 plus20b_m = __msa_ldi_b(20); \ + \ + tmp1_m = (v8i16) __msa_ilvr_b((v16i8) vec5, (v16i8) vec0); \ + tmp1_m = __msa_hadd_s_h((v16i8) tmp1_m, (v16i8) tmp1_m); \ + \ + ILVR_B2_SB(vec4, vec1, vec3, vec2, tmp0_m, tmp2_m); \ + DPADD_SB2_SH(tmp0_m, tmp2_m, minus5b_m, plus20b_m, tmp1_m, tmp1_m); \ + \ + tmp1_m; \ +} ) + +#define AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(vec0, vec1, vec2, vec3, vec4, vec5) \ +( { \ + v4i32 tmp1_m; \ + v8i16 tmp2_m, tmp3_m; \ + v8i16 minus5h_m = __msa_ldi_h(-5); \ + v8i16 plus20h_m = __msa_ldi_h(20); \ + \ + tmp1_m = (v4i32) __msa_ilvr_h((v8i16) vec5, (v8i16) vec0); \ + tmp1_m = __msa_hadd_s_w((v8i16) tmp1_m, (v8i16) tmp1_m); \ + \ + ILVR_H2_SH(vec1, vec4, vec2, vec3, tmp2_m, tmp3_m); \ + DPADD_SH2_SW(tmp2_m, tmp3_m, minus5h_m, plus20h_m, tmp1_m, tmp1_m); \ + \ + tmp1_m = __msa_srari_w(tmp1_m, 10); \ + tmp1_m = __msa_sat_s_w(tmp1_m, 7); \ + \ + tmp2_m = __msa_pckev_h((v8i16) tmp1_m, (v8i16) tmp1_m); \ + \ + tmp2_m; \ +} ) + +#define AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1, \ + mask0, mask1, mask2) \ +( { \ + v8i16 hz_out_m; \ + v16i8 vec0_m, vec1_m, vec2_m; \ + v16i8 minus5b_m = __msa_ldi_b(-5); \ + v16i8 plus20b_m = __msa_ldi_b(20); \ + \ + vec0_m = __msa_vshf_b((v16i8) mask0, (v16i8) src1, (v16i8) src0); \ + hz_out_m = __msa_hadd_s_h(vec0_m, vec0_m); \ + \ + VSHF_B2_SB(src0, src1, src0, src1, mask1, mask2, vec1_m, vec2_m); \ + DPADD_SB2_SH(vec1_m, vec2_m, minus5b_m, plus20b_m, hz_out_m, hz_out_m); \ + \ + hz_out_m; \ +} ) + +static void avc_luma_hz_4w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3; + v8i16 res0, res1; + v16u8 out; + v16i8 mask0, mask1, mask2; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v16i8 minus5b = __msa_ldi_b(-5); + v16i8 plus20b = __msa_ldi_b(20); + + LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2); + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B2_SB(src0, src1, src2, src3, mask0, mask0, vec0, vec1); + HADD_SB2_SH(vec0, vec1, res0, res1); + VSHF_B2_SB(src0, src1, src2, src3, mask1, mask1, vec2, vec3); + DPADD_SB2_SH(vec2, vec3, minus5b, minus5b, res0, res1); + VSHF_B2_SB(src0, src1, src2, src3, mask2, mask2, vec4, vec5); + DPADD_SB2_SH(vec4, vec5, plus20b, plus20b, res0, res1); + SRARI_H2_SH(res0, res1, 5); + SAT_SH2_SH(res0, res1, 7); + out = PCKEV_XORI128_UB(res0, res1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void avc_luma_hz_8w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3; + v8i16 res0, res1, res2, res3; + v16i8 mask0, mask1, mask2; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v16i8 vec6, vec7, vec8, vec9, vec10, vec11; + v16i8 minus5b = __msa_ldi_b(-5); + v16i8 plus20b = __msa_ldi_b(20); + v16u8 out0, out1; + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec0, vec1); + VSHF_B2_SB(src2, src2, src3, src3, mask0, mask0, vec2, vec3); + HADD_SB4_SH(vec0, vec1, vec2, vec3, res0, res1, res2, res3); + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec4, vec5); + VSHF_B2_SB(src2, src2, src3, src3, mask1, mask1, vec6, vec7); + DPADD_SB4_SH(vec4, vec5, vec6, vec7, minus5b, minus5b, minus5b, minus5b, + res0, res1, res2, res3); + VSHF_B2_SB(src0, src0, src1, src1, mask2, mask2, vec8, vec9); + VSHF_B2_SB(src2, src2, src3, src3, mask2, mask2, vec10, vec11); + DPADD_SB4_SH(vec8, vec9, vec10, vec11, plus20b, plus20b, plus20b, + plus20b, res0, res1, res2, res3); + SRARI_H4_SH(res0, res1, res2, res3, 5); + SAT_SH4_SH(res0, res1, res2, res3, 7); + out0 = PCKEV_XORI128_UB(res0, res1); + out1 = PCKEV_XORI128_UB(res2, res3); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void avc_luma_hz_16w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7; + v8i16 res0, res1, res2, res3, res4, res5, res6, res7; + v16i8 mask0, mask1, mask2; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v16i8 vec6, vec7, vec8, vec9, vec10, vec11; + v16i8 minus5b = __msa_ldi_b(-5); + v16i8 plus20b = __msa_ldi_b(20); + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB2(src, 8, src0, src1); + src += src_stride; + LD_SB2(src, 8, src2, src3); + src += src_stride; + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec0, vec3); + VSHF_B2_SB(src2, src2, src3, src3, mask0, mask0, vec6, vec9); + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec1, vec4); + VSHF_B2_SB(src2, src2, src3, src3, mask1, mask1, vec7, vec10); + VSHF_B2_SB(src0, src0, src1, src1, mask2, mask2, vec2, vec5); + VSHF_B2_SB(src2, src2, src3, src3, mask2, mask2, vec8, vec11); + HADD_SB4_SH(vec0, vec3, vec6, vec9, res0, res1, res2, res3); + DPADD_SB4_SH(vec1, vec4, vec7, vec10, minus5b, minus5b, minus5b, + minus5b, res0, res1, res2, res3); + DPADD_SB4_SH(vec2, vec5, vec8, vec11, plus20b, plus20b, plus20b, + plus20b, res0, res1, res2, res3); + + LD_SB2(src, 8, src4, src5); + src += src_stride; + LD_SB2(src, 8, src6, src7); + src += src_stride; + + XORI_B4_128_SB(src4, src5, src6, src7); + VSHF_B2_SB(src4, src4, src5, src5, mask0, mask0, vec0, vec3); + VSHF_B2_SB(src6, src6, src7, src7, mask0, mask0, vec6, vec9); + VSHF_B2_SB(src4, src4, src5, src5, mask1, mask1, vec1, vec4); + VSHF_B2_SB(src6, src6, src7, src7, mask1, mask1, vec7, vec10); + VSHF_B2_SB(src4, src4, src5, src5, mask2, mask2, vec2, vec5); + VSHF_B2_SB(src6, src6, src7, src7, mask2, mask2, vec8, vec11); + HADD_SB4_SH(vec0, vec3, vec6, vec9, res4, res5, res6, res7); + DPADD_SB4_SH(vec1, vec4, vec7, vec10, minus5b, minus5b, minus5b, + minus5b, res4, res5, res6, res7); + DPADD_SB4_SH(vec2, vec5, vec8, vec11, plus20b, plus20b, plus20b, + plus20b, res4, res5, res6, res7); + SRARI_H4_SH(res0, res1, res2, res3, 5); + SRARI_H4_SH(res4, res5, res6, res7, 5); + SAT_SH4_SH(res0, res1, res2, res3, 7); + SAT_SH4_SH(res4, res5, res6, res7, 7); + PCKEV_B4_SB(res1, res0, res3, res2, res5, res4, res7, res6, + vec0, vec1, vec2, vec3); + XORI_B4_128_SB(vec0, vec1, vec2, vec3); + + ST_SB4(vec0, vec1, vec2, vec3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void avc_luma_hz_qrt_4w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, uint8_t hor_offset) +{ + uint8_t slide; + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3; + v8i16 res0, res1; + v16i8 res, mask0, mask1, mask2; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v16i8 minus5b = __msa_ldi_b(-5); + v16i8 plus20b = __msa_ldi_b(20); + + LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2); + slide = 2 + hor_offset; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B2_SB(src0, src1, src2, src3, mask0, mask0, vec0, vec1); + HADD_SB2_SH(vec0, vec1, res0, res1); + VSHF_B2_SB(src0, src1, src2, src3, mask1, mask1, vec2, vec3); + DPADD_SB2_SH(vec2, vec3, minus5b, minus5b, res0, res1); + VSHF_B2_SB(src0, src1, src2, src3, mask2, mask2, vec4, vec5); + DPADD_SB2_SH(vec4, vec5, plus20b, plus20b, res0, res1); + SRARI_H2_SH(res0, res1, 5); + SAT_SH2_SH(res0, res1, 7); + + res = __msa_pckev_b((v16i8) res1, (v16i8) res0); + src0 = __msa_sld_b(src0, src0, slide); + src1 = __msa_sld_b(src1, src1, slide); + src2 = __msa_sld_b(src2, src2, slide); + src3 = __msa_sld_b(src3, src3, slide); + src0 = (v16i8) __msa_insve_w((v4i32) src0, 1, (v4i32) src1); + src1 = (v16i8) __msa_insve_w((v4i32) src2, 1, (v4i32) src3); + src0 = (v16i8) __msa_insve_d((v2i64) src0, 1, (v2i64) src1); + res = __msa_aver_s_b(res, src0); + res = (v16i8) __msa_xori_b((v16u8) res, 128); + + ST4x4_UB(res, res, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void avc_luma_hz_qrt_8w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, uint8_t hor_offset) +{ + uint8_t slide; + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3; + v16i8 tmp0, tmp1; + v8i16 res0, res1, res2, res3; + v16i8 mask0, mask1, mask2; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v16i8 vec6, vec7, vec8, vec9, vec10, vec11; + v16i8 minus5b = __msa_ldi_b(-5); + v16i8 plus20b = __msa_ldi_b(20); + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + slide = 2 + hor_offset; + + for (loop_cnt = height >> 2; loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec0, vec1); + VSHF_B2_SB(src2, src2, src3, src3, mask0, mask0, vec2, vec3); + HADD_SB4_SH(vec0, vec1, vec2, vec3, res0, res1, res2, res3); + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec4, vec5); + VSHF_B2_SB(src2, src2, src3, src3, mask1, mask1, vec6, vec7); + DPADD_SB4_SH(vec4, vec5, vec6, vec7, minus5b, minus5b, minus5b, minus5b, + res0, res1, res2, res3); + VSHF_B2_SB(src0, src0, src1, src1, mask2, mask2, vec8, vec9); + VSHF_B2_SB(src2, src2, src3, src3, mask2, mask2, vec10, vec11); + DPADD_SB4_SH(vec8, vec9, vec10, vec11, plus20b, plus20b, plus20b, + plus20b, res0, res1, res2, res3); + + src0 = __msa_sld_b(src0, src0, slide); + src1 = __msa_sld_b(src1, src1, slide); + src2 = __msa_sld_b(src2, src2, slide); + src3 = __msa_sld_b(src3, src3, slide); + + SRARI_H4_SH(res0, res1, res2, res3, 5); + SAT_SH4_SH(res0, res1, res2, res3, 7); + PCKEV_B2_SB(res1, res0, res3, res2, tmp0, tmp1); + PCKEV_D2_SB(src1, src0, src3, src2, src0, src1); + + tmp0 = __msa_aver_s_b(tmp0, src0); + tmp1 = __msa_aver_s_b(tmp1, src1); + + XORI_B2_128_SB(tmp0, tmp1); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); + + dst += (4 * dst_stride); + } +} + +static void avc_luma_hz_qrt_16w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, uint8_t hor_offset) +{ + uint32_t loop_cnt; + v16i8 dst0, dst1; + v16i8 src0, src1, src2, src3; + v16i8 mask0, mask1, mask2, vshf; + v8i16 res0, res1, res2, res3; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v16i8 vec6, vec7, vec8, vec9, vec10, vec11; + v16i8 minus5b = __msa_ldi_b(-5); + v16i8 plus20b = __msa_ldi_b(20); + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + + if (hor_offset) { + vshf = LD_SB(&luma_mask_arr[16 + 96]); + } else { + vshf = LD_SB(&luma_mask_arr[96]); + } + + for (loop_cnt = height >> 1; loop_cnt--;) { + LD_SB2(src, 8, src0, src1); + src += src_stride; + LD_SB2(src, 8, src2, src3); + src += src_stride; + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec0, vec3); + VSHF_B2_SB(src2, src2, src3, src3, mask0, mask0, vec6, vec9); + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec1, vec4); + VSHF_B2_SB(src2, src2, src3, src3, mask1, mask1, vec7, vec10); + VSHF_B2_SB(src0, src0, src1, src1, mask2, mask2, vec2, vec5); + VSHF_B2_SB(src2, src2, src3, src3, mask2, mask2, vec8, vec11); + HADD_SB4_SH(vec0, vec3, vec6, vec9, res0, res1, res2, res3); + DPADD_SB4_SH(vec1, vec4, vec7, vec10, minus5b, minus5b, minus5b, + minus5b, res0, res1, res2, res3); + DPADD_SB4_SH(vec2, vec5, vec8, vec11, plus20b, plus20b, plus20b, + plus20b, res0, res1, res2, res3); + VSHF_B2_SB(src0, src1, src2, src3, vshf, vshf, src0, src2); + SRARI_H4_SH(res0, res1, res2, res3, 5); + SAT_SH4_SH(res0, res1, res2, res3, 7); + PCKEV_B2_SB(res1, res0, res3, res2, dst0, dst1); + + dst0 = __msa_aver_s_b(dst0, src0); + dst1 = __msa_aver_s_b(dst1, src2); + + XORI_B2_128_SB(dst0, dst1); + + ST_SB2(dst0, dst1, dst, dst_stride); + dst += (2 * dst_stride); + } +} + +static void avc_luma_vt_4w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t loop_cnt; + int16_t filt_const0 = 0xfb01; + int16_t filt_const1 = 0x1414; + int16_t filt_const2 = 0x1fb; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r, src65_r; + v16i8 src87_r, src2110, src4332, src6554, src8776; + v16i8 filt0, filt1, filt2; + v8i16 out10, out32; + v16u8 out; + + filt0 = (v16i8) __msa_fill_h(filt_const0); + filt1 = (v16i8) __msa_fill_h(filt_const1); + filt2 = (v16i8) __msa_fill_h(filt_const2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + ILVR_D2_SB(src21_r, src10_r, src43_r, src32_r, src2110, src4332); + XORI_B2_128_SB(src2110, src4332); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src5, src6, src7, src8); + src += (4 * src_stride); + + ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, + src54_r, src65_r, src76_r, src87_r); + ILVR_D2_SB(src65_r, src54_r, src87_r, src76_r, src6554, src8776); + XORI_B2_128_SB(src6554, src8776); + out10 = DPADD_SH3_SH(src2110, src4332, src6554, filt0, filt1, filt2); + out32 = DPADD_SH3_SH(src4332, src6554, src8776, filt0, filt1, filt2); + SRARI_H2_SH(out10, out32, 5); + SAT_SH2_SH(out10, out32, 7); + out = PCKEV_XORI128_UB(out10, out32); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + + dst += (4 * dst_stride); + src2110 = src6554; + src4332 = src8776; + src4 = src8; + } +} + +static void avc_luma_vt_8w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t loop_cnt; + int16_t filt_const0 = 0xfb01; + int16_t filt_const1 = 0x1414; + int16_t filt_const2 = 0x1fb; + v16i8 src0, src1, src2, src3, src4, src7, src8, src9, src10; + v16i8 src10_r, src32_r, src76_r, src98_r; + v16i8 src21_r, src43_r, src87_r, src109_r; + v8i16 out0_r, out1_r, out2_r, out3_r; + v16i8 filt0, filt1, filt2; + v16u8 out0, out1; + + filt0 = (v16i8) __msa_fill_h(filt_const0); + filt1 = (v16i8) __msa_fill_h(filt_const1); + filt2 = (v16i8) __msa_fill_h(filt_const2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + src += (4 * src_stride); + + XORI_B4_128_SB(src7, src8, src9, src10); + ILVR_B4_SB(src7, src4, src8, src7, src9, src8, src10, src9, + src76_r, src87_r, src98_r, src109_r); + out0_r = DPADD_SH3_SH(src10_r, src32_r, src76_r, filt0, filt1, filt2); + out1_r = DPADD_SH3_SH(src21_r, src43_r, src87_r, filt0, filt1, filt2); + out2_r = DPADD_SH3_SH(src32_r, src76_r, src98_r, filt0, filt1, filt2); + out3_r = DPADD_SH3_SH(src43_r, src87_r, src109_r, filt0, filt1, filt2); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 5); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + out0 = PCKEV_XORI128_UB(out0_r, out1_r); + out1 = PCKEV_XORI128_UB(out2_r, out3_r); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src76_r; + src32_r = src98_r; + src21_r = src87_r; + src43_r = src109_r; + src4 = src10; + } +} + +static void avc_luma_vt_16w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t loop_cnt; + int16_t filt_const0 = 0xfb01; + int16_t filt_const1 = 0x1414; + int16_t filt_const2 = 0x1fb; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r, src65_r; + v16i8 src87_r, src10_l, src32_l, src54_l, src76_l, src21_l, src43_l; + v16i8 src65_l, src87_l; + v8i16 out0_r, out1_r, out2_r, out3_r, out0_l, out1_l, out2_l, out3_l; + v16u8 res0, res1, res2, res3; + v16i8 filt0, filt1, filt2; + + filt0 = (v16i8) __msa_fill_h(filt_const0); + filt1 = (v16i8) __msa_fill_h(filt_const1); + filt2 = (v16i8) __msa_fill_h(filt_const2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + ILVL_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_l, src21_l, src32_l, src43_l); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src5, src6, src7, src8); + src += (4 * src_stride); + + XORI_B4_128_SB(src5, src6, src7, src8); + ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, + src54_r, src65_r, src76_r, src87_r); + ILVL_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, + src54_l, src65_l, src76_l, src87_l); + out0_r = DPADD_SH3_SH(src10_r, src32_r, src54_r, filt0, filt1, filt2); + out1_r = DPADD_SH3_SH(src21_r, src43_r, src65_r, filt0, filt1, filt2); + out2_r = DPADD_SH3_SH(src32_r, src54_r, src76_r, filt0, filt1, filt2); + out3_r = DPADD_SH3_SH(src43_r, src65_r, src87_r, filt0, filt1, filt2); + out0_l = DPADD_SH3_SH(src10_l, src32_l, src54_l, filt0, filt1, filt2); + out1_l = DPADD_SH3_SH(src21_l, src43_l, src65_l, filt0, filt1, filt2); + out2_l = DPADD_SH3_SH(src32_l, src54_l, src76_l, filt0, filt1, filt2); + out3_l = DPADD_SH3_SH(src43_l, src65_l, src87_l, filt0, filt1, filt2); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 5); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SRARI_H4_SH(out0_l, out1_l, out2_l, out3_l, 5); + SAT_SH4_SH(out0_l, out1_l, out2_l, out3_l, 7); + PCKEV_B4_UB(out0_l, out0_r, out1_l, out1_r, out2_l, out2_r, out3_l, + out3_r, res0, res1, res2, res3); + XORI_B4_128_UB(res0, res1, res2, res3); + + ST_UB4(res0, res1, res2, res3, dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src54_r; + src32_r = src76_r; + src21_r = src65_r; + src43_r = src87_r; + src10_l = src54_l; + src32_l = src76_l; + src21_l = src65_l; + src43_l = src87_l; + src4 = src8; + } +} + +static void avc_luma_vt_qrt_4w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, uint8_t ver_offset) +{ + int32_t loop_cnt; + int16_t filt_const0 = 0xfb01; + int16_t filt_const1 = 0x1414; + int16_t filt_const2 = 0x1fb; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r, src65_r; + v16i8 src87_r, src2110, src4332, src6554, src8776; + v8i16 out10, out32; + v16i8 filt0, filt1, filt2; + v16u8 out; + + filt0 = (v16i8) __msa_fill_h(filt_const0); + filt1 = (v16i8) __msa_fill_h(filt_const1); + filt2 = (v16i8) __msa_fill_h(filt_const2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + ILVR_D2_SB(src21_r, src10_r, src43_r, src32_r, src2110, src4332); + XORI_B2_128_SB(src2110, src4332); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src5, src6, src7, src8); + src += (4 * src_stride); + + ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, + src54_r, src65_r, src76_r, src87_r); + ILVR_D2_SB(src65_r, src54_r, src87_r, src76_r, src6554, src8776); + XORI_B2_128_SB(src6554, src8776); + out10 = DPADD_SH3_SH(src2110, src4332, src6554, filt0, filt1, filt2); + out32 = DPADD_SH3_SH(src4332, src6554, src8776, filt0, filt1, filt2); + SRARI_H2_SH(out10, out32, 5); + SAT_SH2_SH(out10, out32, 7); + + out = PCKEV_XORI128_UB(out10, out32); + + if (ver_offset) { + src32_r = (v16i8) __msa_insve_w((v4i32) src3, 1, (v4i32) src4); + src54_r = (v16i8) __msa_insve_w((v4i32) src5, 1, (v4i32) src6); + } else { + src32_r = (v16i8) __msa_insve_w((v4i32) src2, 1, (v4i32) src3); + src54_r = (v16i8) __msa_insve_w((v4i32) src4, 1, (v4i32) src5); + } + + src32_r = (v16i8) __msa_insve_d((v2i64) src32_r, 1, (v2i64) src54_r); + out = __msa_aver_u_b(out, (v16u8) src32_r); + + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + src2110 = src6554; + src4332 = src8776; + src2 = src6; + src3 = src7; + src4 = src8; + } +} + +static void avc_luma_vt_qrt_8w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, uint8_t ver_offset) +{ + int32_t loop_cnt; + int16_t filt_const0 = 0xfb01; + int16_t filt_const1 = 0x1414; + int16_t filt_const2 = 0x1fb; + v16i8 src0, src1, src2, src3, src4, src7, src8, src9, src10; + v16i8 src10_r, src32_r, src76_r, src98_r; + v16i8 src21_r, src43_r, src87_r, src109_r; + v8i16 out0_r, out1_r, out2_r, out3_r; + v16i8 res0, res1; + v16i8 filt0, filt1, filt2; + + filt0 = (v16i8) __msa_fill_h(filt_const0); + filt1 = (v16i8) __msa_fill_h(filt_const1); + filt2 = (v16i8) __msa_fill_h(filt_const2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + src += (4 * src_stride); + + XORI_B4_128_SB(src7, src8, src9, src10); + ILVR_B4_SB(src7, src4, src8, src7, src9, src8, src10, src9, + src76_r, src87_r, src98_r, src109_r); + out0_r = DPADD_SH3_SH(src10_r, src32_r, src76_r, filt0, filt1, filt2); + out1_r = DPADD_SH3_SH(src21_r, src43_r, src87_r, filt0, filt1, filt2); + out2_r = DPADD_SH3_SH(src32_r, src76_r, src98_r, filt0, filt1, filt2); + out3_r = DPADD_SH3_SH(src43_r, src87_r, src109_r, filt0, filt1, filt2); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 5); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + PCKEV_B2_SB(out1_r, out0_r, out3_r, out2_r, res0, res1); + + if (ver_offset) { + PCKEV_D2_SB(src4, src3, src8, src7, src10_r, src32_r); + } else { + PCKEV_D2_SB(src3, src2, src7, src4, src10_r, src32_r); + } + + res0 = __msa_aver_s_b(res0, (v16i8) src10_r); + res1 = __msa_aver_s_b(res1, (v16i8) src32_r); + + XORI_B2_128_SB(res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + + dst += (4 * dst_stride); + src10_r = src76_r; + src32_r = src98_r; + src21_r = src87_r; + src43_r = src109_r; + src2 = src8; + src3 = src9; + src4 = src10; + } +} + +static void avc_luma_vt_qrt_16w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, uint8_t ver_offset) +{ + int32_t loop_cnt; + int16_t filt_const0 = 0xfb01; + int16_t filt_const1 = 0x1414; + int16_t filt_const2 = 0x1fb; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r, src65_r; + v16i8 src87_r, src10_l, src32_l, src54_l, src76_l, src21_l, src43_l; + v16i8 src65_l, src87_l; + v8i16 out0_r, out1_r, out2_r, out3_r, out0_l, out1_l, out2_l, out3_l; + v16u8 res0, res1, res2, res3; + v16i8 filt0, filt1, filt2; + + filt0 = (v16i8) __msa_fill_h(filt_const0); + filt1 = (v16i8) __msa_fill_h(filt_const1); + filt2 = (v16i8) __msa_fill_h(filt_const2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + ILVL_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_l, src21_l, src32_l, src43_l); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src5, src6, src7, src8); + src += (4 * src_stride); + + XORI_B4_128_SB(src5, src6, src7, src8); + ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, + src54_r, src65_r, src76_r, src87_r); + ILVL_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, + src54_l, src65_l, src76_l, src87_l); + out0_r = DPADD_SH3_SH(src10_r, src32_r, src54_r, filt0, filt1, filt2); + out1_r = DPADD_SH3_SH(src21_r, src43_r, src65_r, filt0, filt1, filt2); + out2_r = DPADD_SH3_SH(src32_r, src54_r, src76_r, filt0, filt1, filt2); + out3_r = DPADD_SH3_SH(src43_r, src65_r, src87_r, filt0, filt1, filt2); + out0_l = DPADD_SH3_SH(src10_l, src32_l, src54_l, filt0, filt1, filt2); + out1_l = DPADD_SH3_SH(src21_l, src43_l, src65_l, filt0, filt1, filt2); + out2_l = DPADD_SH3_SH(src32_l, src54_l, src76_l, filt0, filt1, filt2); + out3_l = DPADD_SH3_SH(src43_l, src65_l, src87_l, filt0, filt1, filt2); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 5); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SRARI_H4_SH(out0_l, out1_l, out2_l, out3_l, 5); + SAT_SH4_SH(out0_l, out1_l, out2_l, out3_l, 7); + PCKEV_B4_UB(out0_l, out0_r, out1_l, out1_r, out2_l, out2_r, out3_l, + out3_r, res0, res1, res2, res3); + + if (ver_offset) { + res0 = (v16u8) __msa_aver_s_b((v16i8) res0, src3); + res1 = (v16u8) __msa_aver_s_b((v16i8) res1, src4); + res2 = (v16u8) __msa_aver_s_b((v16i8) res2, src5); + res3 = (v16u8) __msa_aver_s_b((v16i8) res3, src6); + } else { + res0 = (v16u8) __msa_aver_s_b((v16i8) res0, src2); + res1 = (v16u8) __msa_aver_s_b((v16i8) res1, src3); + res2 = (v16u8) __msa_aver_s_b((v16i8) res2, src4); + res3 = (v16u8) __msa_aver_s_b((v16i8) res3, src5); + } + + XORI_B4_128_UB(res0, res1, res2, res3); + ST_UB4(res0, res1, res2, res3, dst, dst_stride); + + dst += (4 * dst_stride); + + src10_r = src54_r; + src32_r = src76_r; + src21_r = src65_r; + src43_r = src87_r; + src10_l = src54_l; + src32_l = src76_l; + src21_l = src65_l; + src43_l = src87_l; + src2 = src6; + src3 = src7; + src4 = src8; + } +} + +static void avc_luma_mid_4w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4; + v16i8 mask0, mask1, mask2; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8; + v8i16 dst0, dst1, dst2, dst3; + + LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2); + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + + hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1, + mask0, mask1, mask2); + hz_out2 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3, + mask0, mask1, mask2); + + PCKOD_D2_SH(hz_out0, hz_out0, hz_out2, hz_out2, hz_out1, hz_out3); + + hz_out4 = AVC_HORZ_FILTER_SH(src4, mask0, mask1, mask2); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + XORI_B4_128_SB(src0, src1, src2, src3); + + hz_out5 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1, + mask0, mask1, + mask2); + hz_out7 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3, + mask0, mask1, + mask2); + + PCKOD_D2_SH(hz_out5, hz_out5, hz_out7, hz_out7, hz_out6, hz_out8); + + dst0 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out0, hz_out1, hz_out2, + hz_out3, hz_out4, hz_out5); + dst1 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out1, hz_out2, hz_out3, + hz_out4, hz_out5, hz_out6); + dst2 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out2, hz_out3, hz_out4, + hz_out5, hz_out6, hz_out7); + dst3 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out3, hz_out4, hz_out5, + hz_out6, hz_out7, hz_out8); + + PCKEV_B2_SB(dst1, dst0, dst3, dst2, src0, src1); + XORI_B2_128_SB(src0, src1); + + ST4x4_UB(src0, src1, 0, 2, 0, 2, dst, dst_stride); + + dst += (4 * dst_stride); + + hz_out0 = hz_out4; + hz_out1 = hz_out5; + hz_out2 = hz_out6; + hz_out3 = hz_out7; + hz_out4 = hz_out8; + } +} + +static void avc_luma_mid_8w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4; + v16i8 mask0, mask1, mask2; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8; + v8i16 dst0, dst1, dst2, dst3; + v16u8 out0, out1; + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + XORI_B5_128_SB(src0, src1, src2, src3, src4); + src += (5 * src_stride); + + hz_out0 = AVC_HORZ_FILTER_SH(src0, mask0, mask1, mask2); + hz_out1 = AVC_HORZ_FILTER_SH(src1, mask0, mask1, mask2); + hz_out2 = AVC_HORZ_FILTER_SH(src2, mask0, mask1, mask2); + hz_out3 = AVC_HORZ_FILTER_SH(src3, mask0, mask1, mask2); + hz_out4 = AVC_HORZ_FILTER_SH(src4, mask0, mask1, mask2); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + + hz_out5 = AVC_HORZ_FILTER_SH(src0, mask0, mask1, mask2); + hz_out6 = AVC_HORZ_FILTER_SH(src1, mask0, mask1, mask2); + hz_out7 = AVC_HORZ_FILTER_SH(src2, mask0, mask1, mask2); + hz_out8 = AVC_HORZ_FILTER_SH(src3, mask0, mask1, mask2); + dst0 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out0, hz_out1, hz_out2, + hz_out3, hz_out4, hz_out5); + dst1 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out1, hz_out2, hz_out3, + hz_out4, hz_out5, hz_out6); + dst2 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out2, hz_out3, hz_out4, + hz_out5, hz_out6, hz_out7); + dst3 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out3, hz_out4, hz_out5, + hz_out6, hz_out7, hz_out8); + out0 = PCKEV_XORI128_UB(dst0, dst1); + out1 = PCKEV_XORI128_UB(dst2, dst3); + ST8x4_UB(out0, out1, dst, dst_stride); + + dst += (4 * dst_stride); + hz_out3 = hz_out7; + hz_out1 = hz_out5; + hz_out5 = hz_out4; + hz_out4 = hz_out8; + hz_out2 = hz_out6; + hz_out0 = hz_out5; + } +} + +static void avc_luma_mid_16w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + uint32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + avc_luma_mid_8w_msa(src, src_stride, dst, dst_stride, height); + src += 8; + dst += 8; + } +} + +static void avc_luma_midh_qrt_4w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, uint8_t horiz_offset) +{ + uint32_t row; + v16i8 src0, src1, src2, src3, src4, src5, src6; + v8i16 vt_res0, vt_res1, vt_res2, vt_res3; + v4i32 hz_res0, hz_res1; + v8i16 dst0, dst1; + v8i16 shf_vec0, shf_vec1, shf_vec2, shf_vec3, shf_vec4, shf_vec5; + v8i16 mask0 = { 0, 5, 1, 6, 2, 7, 3, 8 }; + v8i16 mask1 = { 1, 4, 2, 5, 3, 6, 4, 7 }; + v8i16 mask2 = { 2, 3, 3, 4, 4, 5, 5, 6 }; + v8i16 minus5h = __msa_ldi_h(-5); + v8i16 plus20h = __msa_ldi_h(20); + v8i16 zeros = { 0 }; + v16u8 out; + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + XORI_B5_128_SB(src0, src1, src2, src3, src4); + + for (row = (height >> 1); row--;) { + LD_SB2(src, src_stride, src5, src6); + src += (2 * src_stride); + + XORI_B2_128_SB(src5, src6); + AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src0, src1, src2, src3, src4, src5, + vt_res0, vt_res1); + AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src1, src2, src3, src4, src5, src6, + vt_res2, vt_res3); + VSHF_H3_SH(vt_res0, vt_res1, vt_res0, vt_res1, vt_res0, vt_res1, + mask0, mask1, mask2, shf_vec0, shf_vec1, shf_vec2); + VSHF_H3_SH(vt_res2, vt_res3, vt_res2, vt_res3, vt_res2, vt_res3, + mask0, mask1, mask2, shf_vec3, shf_vec4, shf_vec5); + hz_res0 = __msa_hadd_s_w(shf_vec0, shf_vec0); + DPADD_SH2_SW(shf_vec1, shf_vec2, minus5h, plus20h, hz_res0, hz_res0); + hz_res1 = __msa_hadd_s_w(shf_vec3, shf_vec3); + DPADD_SH2_SW(shf_vec4, shf_vec5, minus5h, plus20h, hz_res1, hz_res1); + + SRARI_W2_SW(hz_res0, hz_res1, 10); + SAT_SW2_SW(hz_res0, hz_res1, 7); + + dst0 = __msa_srari_h(shf_vec2, 5); + dst1 = __msa_srari_h(shf_vec5, 5); + + SAT_SH2_SH(dst0, dst1, 7); + + if (horiz_offset) { + dst0 = __msa_ilvod_h(zeros, dst0); + dst1 = __msa_ilvod_h(zeros, dst1); + } else { + ILVEV_H2_SH(dst0, zeros, dst1, zeros, dst0, dst1); + } + + hz_res0 = __msa_aver_s_w(hz_res0, (v4i32) dst0); + hz_res1 = __msa_aver_s_w(hz_res1, (v4i32) dst1); + dst0 = __msa_pckev_h((v8i16) hz_res1, (v8i16) hz_res0); + + out = PCKEV_XORI128_UB(dst0, dst0); + ST4x2_UB(out, dst, dst_stride); + + dst += (2 * dst_stride); + + src0 = src2; + src1 = src3; + src2 = src4; + src3 = src5; + src4 = src6; + } +} + +static void avc_luma_midh_qrt_8w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, uint8_t horiz_offset) +{ + uint32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + avc_luma_midh_qrt_4w_msa(src, src_stride, dst, dst_stride, height, + horiz_offset); + + src += 4; + dst += 4; + } +} + +static void avc_luma_midh_qrt_16w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, uint8_t horiz_offset) +{ + uint32_t multiple8_cnt; + + for (multiple8_cnt = 4; multiple8_cnt--;) { + avc_luma_midh_qrt_4w_msa(src, src_stride, dst, dst_stride, height, + horiz_offset); + + src += 4; + dst += 4; + } +} + +static void avc_luma_midv_qrt_4w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, uint8_t ver_offset) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4; + v16i8 mask0, mask1, mask2; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8; + v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + + LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2); + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + + hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1, + mask0, mask1, mask2); + hz_out2 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3, + mask0, mask1, mask2); + + PCKOD_D2_SH(hz_out0, hz_out0, hz_out2, hz_out2, hz_out1, hz_out3); + + hz_out4 = AVC_HORZ_FILTER_SH(src4, mask0, mask1, mask2); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + XORI_B4_128_SB(src0, src1, src2, src3); + + hz_out5 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1, + mask0, mask1, + mask2); + hz_out7 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3, + mask0, mask1, + mask2); + + PCKOD_D2_SH(hz_out5, hz_out5, hz_out7, hz_out7, hz_out6, hz_out8); + + dst0 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out0, hz_out1, hz_out2, + hz_out3, hz_out4, hz_out5); + dst2 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out1, hz_out2, hz_out3, + hz_out4, hz_out5, hz_out6); + dst4 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out2, hz_out3, hz_out4, + hz_out5, hz_out6, hz_out7); + dst6 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out3, hz_out4, hz_out5, + hz_out6, hz_out7, hz_out8); + + if (ver_offset) { + dst1 = __msa_srari_h(hz_out3, 5); + dst3 = __msa_srari_h(hz_out4, 5); + dst5 = __msa_srari_h(hz_out5, 5); + dst7 = __msa_srari_h(hz_out6, 5); + } else { + dst1 = __msa_srari_h(hz_out2, 5); + dst3 = __msa_srari_h(hz_out3, 5); + dst5 = __msa_srari_h(hz_out4, 5); + dst7 = __msa_srari_h(hz_out5, 5); + } + + SAT_SH4_SH(dst1, dst3, dst5, dst7, 7); + + dst0 = __msa_aver_s_h(dst0, dst1); + dst1 = __msa_aver_s_h(dst2, dst3); + dst2 = __msa_aver_s_h(dst4, dst5); + dst3 = __msa_aver_s_h(dst6, dst7); + + PCKEV_B2_SB(dst1, dst0, dst3, dst2, src0, src1); + XORI_B2_128_SB(src0, src1); + + ST4x4_UB(src0, src1, 0, 2, 0, 2, dst, dst_stride); + + dst += (4 * dst_stride); + hz_out0 = hz_out4; + hz_out1 = hz_out5; + hz_out2 = hz_out6; + hz_out3 = hz_out7; + hz_out4 = hz_out8; + } +} + +static void avc_luma_midv_qrt_8w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, uint8_t ver_offset) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4; + v16i8 mask0, mask1, mask2; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8; + v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v16u8 out; + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + XORI_B5_128_SB(src0, src1, src2, src3, src4); + src += (5 * src_stride); + + hz_out0 = AVC_HORZ_FILTER_SH(src0, mask0, mask1, mask2); + hz_out1 = AVC_HORZ_FILTER_SH(src1, mask0, mask1, mask2); + hz_out2 = AVC_HORZ_FILTER_SH(src2, mask0, mask1, mask2); + hz_out3 = AVC_HORZ_FILTER_SH(src3, mask0, mask1, mask2); + hz_out4 = AVC_HORZ_FILTER_SH(src4, mask0, mask1, mask2); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + + hz_out5 = AVC_HORZ_FILTER_SH(src0, mask0, mask1, mask2); + hz_out6 = AVC_HORZ_FILTER_SH(src1, mask0, mask1, mask2); + hz_out7 = AVC_HORZ_FILTER_SH(src2, mask0, mask1, mask2); + hz_out8 = AVC_HORZ_FILTER_SH(src3, mask0, mask1, mask2); + + dst0 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out0, hz_out1, hz_out2, + hz_out3, hz_out4, hz_out5); + dst2 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out1, hz_out2, hz_out3, + hz_out4, hz_out5, hz_out6); + dst4 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out2, hz_out3, hz_out4, + hz_out5, hz_out6, hz_out7); + dst6 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out3, hz_out4, hz_out5, + hz_out6, hz_out7, hz_out8); + + if (ver_offset) { + dst1 = __msa_srari_h(hz_out3, 5); + dst3 = __msa_srari_h(hz_out4, 5); + dst5 = __msa_srari_h(hz_out5, 5); + dst7 = __msa_srari_h(hz_out6, 5); + } else { + dst1 = __msa_srari_h(hz_out2, 5); + dst3 = __msa_srari_h(hz_out3, 5); + dst5 = __msa_srari_h(hz_out4, 5); + dst7 = __msa_srari_h(hz_out5, 5); + } + + SAT_SH4_SH(dst1, dst3, dst5, dst7, 7); + + dst0 = __msa_aver_s_h(dst0, dst1); + dst1 = __msa_aver_s_h(dst2, dst3); + dst2 = __msa_aver_s_h(dst4, dst5); + dst3 = __msa_aver_s_h(dst6, dst7); + + out = PCKEV_XORI128_UB(dst0, dst0); + ST8x1_UB(out, dst); + dst += dst_stride; + out = PCKEV_XORI128_UB(dst1, dst1); + ST8x1_UB(out, dst); + dst += dst_stride; + out = PCKEV_XORI128_UB(dst2, dst2); + ST8x1_UB(out, dst); + dst += dst_stride; + out = PCKEV_XORI128_UB(dst3, dst3); + ST8x1_UB(out, dst); + dst += dst_stride; + + hz_out0 = hz_out4; + hz_out1 = hz_out5; + hz_out2 = hz_out6; + hz_out3 = hz_out7; + hz_out4 = hz_out8; + } +} + +static void avc_luma_midv_qrt_16w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, uint8_t vert_offset) +{ + uint32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + avc_luma_midv_qrt_8w_msa(src, src_stride, dst, dst_stride, height, + vert_offset); + + src += 8; + dst += 8; + } +} + +static void avc_luma_hv_qrt_4w_msa(const uint8_t *src_x, const uint8_t *src_y, + int32_t src_stride, uint8_t *dst, + int32_t dst_stride, int32_t height) +{ + uint32_t loop_cnt; + v16i8 src_hz0, src_hz1, src_hz2, src_hz3; + v16i8 src_vt0, src_vt1, src_vt2, src_vt3, src_vt4; + v16i8 src_vt5, src_vt6, src_vt7, src_vt8; + v16i8 mask0, mask1, mask2; + v8i16 hz_out0, hz_out1, vert_out0, vert_out1; + v8i16 out0, out1; + v16u8 out; + + LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2); + + LD_SB5(src_y, src_stride, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4); + src_y += (5 * src_stride); + + src_vt0 = (v16i8) __msa_insve_w((v4i32) src_vt0, 1, (v4i32) src_vt1); + src_vt1 = (v16i8) __msa_insve_w((v4i32) src_vt1, 1, (v4i32) src_vt2); + src_vt2 = (v16i8) __msa_insve_w((v4i32) src_vt2, 1, (v4i32) src_vt3); + src_vt3 = (v16i8) __msa_insve_w((v4i32) src_vt3, 1, (v4i32) src_vt4); + + XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src_x, src_stride, src_hz0, src_hz1, src_hz2, src_hz3); + src_x += (4 * src_stride); + + XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3); + + hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz0, + src_hz1, mask0, + mask1, mask2); + hz_out1 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz2, + src_hz3, mask0, + mask1, mask2); + + SRARI_H2_SH(hz_out0, hz_out1, 5); + SAT_SH2_SH(hz_out0, hz_out1, 7); + + LD_SB4(src_y, src_stride, src_vt5, src_vt6, src_vt7, src_vt8); + src_y += (4 * src_stride); + + src_vt4 = (v16i8) __msa_insve_w((v4i32) src_vt4, 1, (v4i32) src_vt5); + src_vt5 = (v16i8) __msa_insve_w((v4i32) src_vt5, 1, (v4i32) src_vt6); + src_vt6 = (v16i8) __msa_insve_w((v4i32) src_vt6, 1, (v4i32) src_vt7); + src_vt7 = (v16i8) __msa_insve_w((v4i32) src_vt7, 1, (v4i32) src_vt8); + + XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7); + + /* filter calc */ + vert_out0 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt0, src_vt1, + src_vt2, src_vt3, + src_vt4, src_vt5); + vert_out1 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt2, src_vt3, + src_vt4, src_vt5, + src_vt6, src_vt7); + + SRARI_H2_SH(vert_out0, vert_out1, 5); + SAT_SH2_SH(vert_out0, vert_out1, 7); + + out0 = __msa_srari_h((hz_out0 + vert_out0), 1); + out1 = __msa_srari_h((hz_out1 + vert_out1), 1); + + SAT_SH2_SH(out0, out1, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + + src_vt3 = src_vt7; + src_vt1 = src_vt5; + src_vt0 = src_vt4; + src_vt4 = src_vt8; + src_vt2 = src_vt6; + } +} + +static void avc_luma_hv_qrt_8w_msa(const uint8_t *src_x, const uint8_t *src_y, + int32_t src_stride, uint8_t *dst, + int32_t dst_stride, int32_t height) +{ + uint32_t loop_cnt; + v16i8 src_hz0, src_hz1, src_hz2, src_hz3; + v16i8 src_vt0, src_vt1, src_vt2, src_vt3, src_vt4; + v16i8 src_vt5, src_vt6, src_vt7, src_vt8; + v16i8 mask0, mask1, mask2; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 vert_out0, vert_out1, vert_out2, vert_out3; + v8i16 out0, out1, out2, out3; + v16u8 tmp0, tmp1; + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + LD_SB5(src_y, src_stride, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4); + src_y += (5 * src_stride); + + src_vt0 = (v16i8) __msa_insve_d((v2i64) src_vt0, 1, (v2i64) src_vt1); + src_vt1 = (v16i8) __msa_insve_d((v2i64) src_vt1, 1, (v2i64) src_vt2); + src_vt2 = (v16i8) __msa_insve_d((v2i64) src_vt2, 1, (v2i64) src_vt3); + src_vt3 = (v16i8) __msa_insve_d((v2i64) src_vt3, 1, (v2i64) src_vt4); + + XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src_x, src_stride, src_hz0, src_hz1, src_hz2, src_hz3); + XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3); + src_x += (4 * src_stride); + + hz_out0 = AVC_HORZ_FILTER_SH(src_hz0, mask0, mask1, mask2); + hz_out1 = AVC_HORZ_FILTER_SH(src_hz1, mask0, mask1, mask2); + hz_out2 = AVC_HORZ_FILTER_SH(src_hz2, mask0, mask1, mask2); + hz_out3 = AVC_HORZ_FILTER_SH(src_hz3, mask0, mask1, mask2); + + SRARI_H4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 5); + SAT_SH4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 7); + + LD_SB4(src_y, src_stride, src_vt5, src_vt6, src_vt7, src_vt8); + src_y += (4 * src_stride); + + src_vt4 = (v16i8) __msa_insve_d((v2i64) src_vt4, 1, (v2i64) src_vt5); + src_vt5 = (v16i8) __msa_insve_d((v2i64) src_vt5, 1, (v2i64) src_vt6); + src_vt6 = (v16i8) __msa_insve_d((v2i64) src_vt6, 1, (v2i64) src_vt7); + src_vt7 = (v16i8) __msa_insve_d((v2i64) src_vt7, 1, (v2i64) src_vt8); + + XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7); + + /* filter calc */ + AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt0, src_vt1, src_vt2, src_vt3, + src_vt4, src_vt5, vert_out0, vert_out1); + AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt2, src_vt3, src_vt4, src_vt5, + src_vt6, src_vt7, vert_out2, vert_out3); + + SRARI_H4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 5); + SAT_SH4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 7); + + out0 = __msa_srari_h((hz_out0 + vert_out0), 1); + out1 = __msa_srari_h((hz_out1 + vert_out1), 1); + out2 = __msa_srari_h((hz_out2 + vert_out2), 1); + out3 = __msa_srari_h((hz_out3 + vert_out3), 1); + + SAT_SH4_SH(out0, out1, out2, out3, 7); + tmp0 = PCKEV_XORI128_UB(out0, out1); + tmp1 = PCKEV_XORI128_UB(out2, out3); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); + + dst += (4 * dst_stride); + src_vt3 = src_vt7; + src_vt1 = src_vt5; + src_vt5 = src_vt4; + src_vt4 = src_vt8; + src_vt2 = src_vt6; + src_vt0 = src_vt5; + } +} + +static void avc_luma_hv_qrt_16w_msa(const uint8_t *src_x, const uint8_t *src_y, + int32_t src_stride, uint8_t *dst, + int32_t dst_stride, int32_t height) +{ + uint32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + avc_luma_hv_qrt_8w_msa(src_x, src_y, src_stride, dst, dst_stride, + height); + + src_x += 8; + src_y += 8; + dst += 8; + } +} + +static void avc_luma_hz_and_aver_dst_4x4_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16i8 src0, src1, src2, src3; + v16u8 dst0, dst1, dst2, dst3, res; + v8i16 res0, res1; + v16i8 mask0, mask1, mask2; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v16i8 minus5b = __msa_ldi_b(-5); + v16i8 plus20b = __msa_ldi_b(20); + + LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2); + LD_SB4(src, src_stride, src0, src1, src2, src3); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B2_SB(src0, src1, src2, src3, mask0, mask0, vec0, vec1); + HADD_SB2_SH(vec0, vec1, res0, res1); + VSHF_B2_SB(src0, src1, src2, src3, mask1, mask1, vec2, vec3); + DPADD_SB2_SH(vec2, vec3, minus5b, minus5b, res0, res1); + VSHF_B2_SB(src0, src1, src2, src3, mask2, mask2, vec4, vec5); + DPADD_SB2_SH(vec4, vec5, plus20b, plus20b, res0, res1); + SRARI_H2_SH(res0, res1, 5); + SAT_SH2_SH(res0, res1, 7); + res = PCKEV_XORI128_UB(res0, res1); + ILVR_W2_UB(dst1, dst0, dst3, dst2, dst0, dst1); + + dst0 = (v16u8) __msa_pckev_d((v2i64) dst1, (v2i64) dst0); + res = __msa_aver_u_b(res, dst0); + + ST4x4_UB(res, res, 0, 1, 2, 3, dst, dst_stride); +} + +static void avc_luma_hz_and_aver_dst_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3; + v16u8 dst0, dst1, dst2, dst3; + v8i16 res0, res1, res2, res3; + v16i8 mask0, mask1, mask2; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v16i8 vec6, vec7, vec8, vec9, vec10, vec11; + v16i8 minus5b = __msa_ldi_b(-5); + v16i8 plus20b = __msa_ldi_b(20); + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + + for (loop_cnt = 2; loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec0, vec1); + VSHF_B2_SB(src2, src2, src3, src3, mask0, mask0, vec2, vec3); + HADD_SB4_SH(vec0, vec1, vec2, vec3, res0, res1, res2, res3); + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec4, vec5); + VSHF_B2_SB(src2, src2, src3, src3, mask1, mask1, vec6, vec7); + DPADD_SB4_SH(vec4, vec5, vec6, vec7, minus5b, minus5b, minus5b, minus5b, + res0, res1, res2, res3); + VSHF_B2_SB(src0, src0, src1, src1, mask2, mask2, vec8, vec9); + VSHF_B2_SB(src2, src2, src3, src3, mask2, mask2, vec10, vec11); + DPADD_SB4_SH(vec8, vec9, vec10, vec11, plus20b, plus20b, plus20b, + plus20b, res0, res1, res2, res3); + SRARI_H4_SH(res0, res1, res2, res3, 5); + SAT_SH4_SH(res0, res1, res2, res3, 7); + CONVERT_UB_AVG_ST8x4_UB(res0, res1, res2, res3, dst0, dst1, dst2, dst3, + dst, dst_stride); + + dst += (4 * dst_stride); + } +} + +static void avc_luma_hz_and_aver_dst_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7; + v16u8 dst0, dst1, dst2, dst3; + v16i8 mask0, mask1, mask2; + v8i16 res0, res1, res2, res3, res4, res5, res6, res7; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v16i8 vec6, vec7, vec8, vec9, vec10, vec11; + v16i8 minus5b = __msa_ldi_b(-5); + v16i8 plus20b = __msa_ldi_b(20); + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + + for (loop_cnt = 4; loop_cnt--;) { + LD_SB2(src, 8, src0, src1); + src += src_stride; + LD_SB2(src, 8, src2, src3); + src += src_stride; + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec0, vec3); + VSHF_B2_SB(src2, src2, src3, src3, mask0, mask0, vec6, vec9); + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec1, vec4); + VSHF_B2_SB(src2, src2, src3, src3, mask1, mask1, vec7, vec10); + VSHF_B2_SB(src0, src0, src1, src1, mask2, mask2, vec2, vec5); + VSHF_B2_SB(src2, src2, src3, src3, mask2, mask2, vec8, vec11); + HADD_SB4_SH(vec0, vec3, vec6, vec9, res0, res1, res2, res3); + DPADD_SB4_SH(vec1, vec4, vec7, vec10, minus5b, minus5b, minus5b, + minus5b, res0, res1, res2, res3); + DPADD_SB4_SH(vec2, vec5, vec8, vec11, plus20b, plus20b, plus20b, + plus20b, res0, res1, res2, res3); + LD_SB2(src, 8, src4, src5); + src += src_stride; + LD_SB2(src, 8, src6, src7); + src += src_stride; + XORI_B4_128_SB(src4, src5, src6, src7); + VSHF_B2_SB(src4, src4, src5, src5, mask0, mask0, vec0, vec3); + VSHF_B2_SB(src6, src6, src7, src7, mask0, mask0, vec6, vec9); + VSHF_B2_SB(src4, src4, src5, src5, mask1, mask1, vec1, vec4); + VSHF_B2_SB(src6, src6, src7, src7, mask1, mask1, vec7, vec10); + VSHF_B2_SB(src4, src4, src5, src5, mask2, mask2, vec2, vec5); + VSHF_B2_SB(src6, src6, src7, src7, mask2, mask2, vec8, vec11); + HADD_SB4_SH(vec0, vec3, vec6, vec9, res4, res5, res6, res7); + DPADD_SB4_SH(vec1, vec4, vec7, vec10, minus5b, minus5b, minus5b, + minus5b, res4, res5, res6, res7); + DPADD_SB4_SH(vec2, vec5, vec8, vec11, plus20b, plus20b, plus20b, + plus20b, res4, res5, res6, res7); + SRARI_H4_SH(res0, res1, res2, res3, 5); + SRARI_H4_SH(res4, res5, res6, res7, 5); + SAT_SH4_SH(res0, res1, res2, res3, 7); + SAT_SH4_SH(res4, res5, res6, res7, 7); + PCKEV_B4_SB(res1, res0, res3, res2, res5, res4, res7, res6, + vec0, vec1, vec2, vec3); + XORI_B4_128_SB(vec0, vec1, vec2, vec3); + AVER_UB4_UB(vec0, dst0, vec1, dst1, vec2, dst2, vec3, dst3, + dst0, dst1, dst2, dst3); + ST_UB4(dst0, dst1, dst2, dst3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void avc_luma_hz_qrt_and_aver_dst_4x4_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + uint8_t hor_offset) +{ + uint8_t slide; + v16i8 src0, src1, src2, src3; + v16u8 dst0, dst1, dst2, dst3; + v16i8 mask0, mask1, mask2; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v8i16 out0, out1; + v16i8 minus5b = __msa_ldi_b(-5); + v16i8 plus20b = __msa_ldi_b(20); + v16u8 res0, res1; + + LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2); + + if (hor_offset) { + slide = 3; + } else { + slide = 2; + } + + LD_SB4(src, src_stride, src0, src1, src2, src3); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B2_SB(src0, src1, src2, src3, mask0, mask0, vec0, vec1); + HADD_SB2_SH(vec0, vec1, out0, out1); + VSHF_B2_SB(src0, src1, src2, src3, mask1, mask1, vec2, vec3); + DPADD_SB2_SH(vec2, vec3, minus5b, minus5b, out0, out1); + VSHF_B2_SB(src0, src1, src2, src3, mask2, mask2, vec4, vec5); + DPADD_SB2_SH(vec4, vec5, plus20b, plus20b, out0, out1); + SRARI_H2_SH(out0, out1, 5); + SAT_SH2_SH(out0, out1, 7); + + PCKEV_B2_UB(out0, out0, out1, out1, res0, res1); + + src0 = __msa_sld_b(src0, src0, slide); + src1 = __msa_sld_b(src1, src1, slide); + src2 = __msa_sld_b(src2, src2, slide); + src3 = __msa_sld_b(src3, src3, slide); + src0 = (v16i8) __msa_insve_w((v4i32) src0, 1, (v4i32) src1); + src1 = (v16i8) __msa_insve_w((v4i32) src2, 1, (v4i32) src3); + res0 = (v16u8) __msa_aver_s_b((v16i8) res0, src0); + res1 = (v16u8) __msa_aver_s_b((v16i8) res1, src1); + + XORI_B2_128_UB(res0, res1); + + dst0 = (v16u8) __msa_insve_w((v4i32) dst0, 1, (v4i32) dst1); + dst1 = (v16u8) __msa_insve_w((v4i32) dst2, 1, (v4i32) dst3); + + AVER_UB2_UB(res0, dst0, res1, dst1, dst0, dst1); + + ST4x4_UB(dst0, dst1, 0, 1, 0, 1, dst, dst_stride); +} + +static void avc_luma_hz_qrt_and_aver_dst_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + uint8_t hor_offset) +{ + uint8_t slide; + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3; + v16i8 mask0, mask1, mask2; + v16u8 dst0, dst1, dst2, dst3; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v16i8 vec6, vec7, vec8, vec9, vec10, vec11; + v8i16 out0, out1, out2, out3; + v16i8 minus5b = __msa_ldi_b(-5); + v16i8 plus20b = __msa_ldi_b(20); + v16i8 res0, res1, res2, res3; + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + + if (hor_offset) { + slide = 3; + } else { + slide = 2; + } + + for (loop_cnt = 2; loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec0, vec1); + VSHF_B2_SB(src2, src2, src3, src3, mask0, mask0, vec2, vec3); + HADD_SB4_SH(vec0, vec1, vec2, vec3, out0, out1, out2, out3); + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec4, vec5); + VSHF_B2_SB(src2, src2, src3, src3, mask1, mask1, vec6, vec7); + DPADD_SB4_SH(vec4, vec5, vec6, vec7, minus5b, minus5b, minus5b, minus5b, + out0, out1, out2, out3); + VSHF_B2_SB(src0, src0, src1, src1, mask2, mask2, vec8, vec9); + VSHF_B2_SB(src2, src2, src3, src3, mask2, mask2, vec10, vec11); + DPADD_SB4_SH(vec8, vec9, vec10, vec11, plus20b, plus20b, plus20b, + plus20b, out0, out1, out2, out3); + + src0 = __msa_sld_b(src0, src0, slide); + src1 = __msa_sld_b(src1, src1, slide); + src2 = __msa_sld_b(src2, src2, slide); + src3 = __msa_sld_b(src3, src3, slide); + + SRARI_H4_SH(out0, out1, out2, out3, 5); + SAT_SH4_SH(out0, out1, out2, out3, 7); + + PCKEV_B4_SB(out0, out0, out1, out1, out2, out2, out3, out3, + res0, res1, res2, res3); + + res0 = __msa_aver_s_b(res0, src0); + res1 = __msa_aver_s_b(res1, src1); + res2 = __msa_aver_s_b(res2, src2); + res3 = __msa_aver_s_b(res3, src3); + + XORI_B4_128_SB(res0, res1, res2, res3); + AVER_ST8x4_UB(res0, dst0, res1, dst1, res2, dst2, res3, dst3, + dst, dst_stride); + + dst += (4 * dst_stride); + } +} + +static void avc_luma_hz_qrt_and_aver_dst_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + uint8_t hor_offset) +{ + uint32_t loop_cnt; + v16i8 out0, out1; + v16i8 src0, src1, src2, src3; + v16i8 mask0, mask1, mask2, vshf; + v16u8 dst0, dst1; + v8i16 res0, res1, res2, res3; + v16i8 vec0, vec1, vec2, vec3, vec4, vec5; + v16i8 vec6, vec7, vec8, vec9, vec10, vec11; + v16i8 minus5b = __msa_ldi_b(-5); + v16i8 plus20b = __msa_ldi_b(20); + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + + if (hor_offset) { + vshf = LD_SB(&luma_mask_arr[16 + 96]); + } else { + vshf = LD_SB(&luma_mask_arr[96]); + } + + for (loop_cnt = 8; loop_cnt--;) { + LD_SB2(src, 8, src0, src1); + src += src_stride; + LD_SB2(src, 8, src2, src3); + src += src_stride; + + LD_UB2(dst, dst_stride, dst0, dst1); + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec0, vec3); + VSHF_B2_SB(src2, src2, src3, src3, mask0, mask0, vec6, vec9); + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec1, vec4); + VSHF_B2_SB(src2, src2, src3, src3, mask1, mask1, vec7, vec10); + VSHF_B2_SB(src0, src0, src1, src1, mask2, mask2, vec2, vec5); + VSHF_B2_SB(src2, src2, src3, src3, mask2, mask2, vec8, vec11); + HADD_SB4_SH(vec0, vec3, vec6, vec9, res0, res1, res2, res3); + DPADD_SB4_SH(vec1, vec4, vec7, vec10, minus5b, minus5b, minus5b, + minus5b, res0, res1, res2, res3); + DPADD_SB4_SH(vec2, vec5, vec8, vec11, plus20b, plus20b, plus20b, + plus20b, res0, res1, res2, res3); + VSHF_B2_SB(src0, src1, src2, src3, vshf, vshf, src0, src2); + SRARI_H4_SH(res0, res1, res2, res3, 5); + SAT_SH4_SH(res0, res1, res2, res3, 7); + PCKEV_B2_SB(res1, res0, res3, res2, out0, out1); + + out0 = __msa_aver_s_b(out0, src0); + out1 = __msa_aver_s_b(out1, src2); + + XORI_B2_128_SB(out0, out1); + AVER_UB2_UB(out0, dst0, out1, dst1, dst0, dst1); + ST_UB2(dst0, dst1, dst, dst_stride); + dst += (2 * dst_stride); + } +} + +static void avc_luma_vt_and_aver_dst_4x4_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + int16_t filt_const0 = 0xfb01; + int16_t filt_const1 = 0x1414; + int16_t filt_const2 = 0x1fb; + v16u8 dst0, dst1, dst2, dst3; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r, src65_r; + v16i8 src87_r, src2110, src4332, src6554, src8776; + v8i16 out10, out32; + v16i8 filt0, filt1, filt2; + v16u8 res; + + filt0 = (v16i8) __msa_fill_h(filt_const0); + filt1 = (v16i8) __msa_fill_h(filt_const1); + filt2 = (v16i8) __msa_fill_h(filt_const2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + ILVR_D2_SB(src21_r, src10_r, src43_r, src32_r, src2110, src4332); + XORI_B2_128_SB(src2110, src4332); + LD_SB4(src, src_stride, src5, src6, src7, src8); + ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, + src54_r, src65_r, src76_r, src87_r); + ILVR_D2_SB(src65_r, src54_r, src87_r, src76_r, src6554, src8776); + XORI_B2_128_SB(src6554, src8776); + out10 = DPADD_SH3_SH(src2110, src4332, src6554, filt0, filt1, filt2); + out32 = DPADD_SH3_SH(src4332, src6554, src8776, filt0, filt1, filt2); + SRARI_H2_SH(out10, out32, 5); + SAT_SH2_SH(out10, out32, 7); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + res = PCKEV_XORI128_UB(out10, out32); + + ILVR_W2_UB(dst1, dst0, dst3, dst2, dst0, dst1); + + dst0 = (v16u8) __msa_pckev_d((v2i64) dst1, (v2i64) dst0); + dst0 = __msa_aver_u_b(res, dst0); + + ST4x4_UB(dst0, dst0, 0, 1, 2, 3, dst, dst_stride); +} + +static void avc_luma_vt_and_aver_dst_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + int32_t loop_cnt; + int16_t filt_const0 = 0xfb01; + int16_t filt_const1 = 0x1414; + int16_t filt_const2 = 0x1fb; + v16u8 dst0, dst1, dst2, dst3; + v16i8 src0, src1, src2, src3, src4, src7, src8, src9, src10; + v16i8 src10_r, src32_r, src76_r, src98_r; + v16i8 src21_r, src43_r, src87_r, src109_r; + v8i16 out0, out1, out2, out3; + v16i8 filt0, filt1, filt2; + + filt0 = (v16i8) __msa_fill_h(filt_const0); + filt1 = (v16i8) __msa_fill_h(filt_const1); + filt2 = (v16i8) __msa_fill_h(filt_const2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + + for (loop_cnt = 2; loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + src += (4 * src_stride); + + XORI_B4_128_SB(src7, src8, src9, src10); + ILVR_B4_SB(src7, src4, src8, src7, src9, src8, src10, src9, + src76_r, src87_r, src98_r, src109_r); + out0 = DPADD_SH3_SH(src10_r, src32_r, src76_r, filt0, filt1, filt2); + out1 = DPADD_SH3_SH(src21_r, src43_r, src87_r, filt0, filt1, filt2); + out2 = DPADD_SH3_SH(src32_r, src76_r, src98_r, filt0, filt1, filt2); + out3 = DPADD_SH3_SH(src43_r, src87_r, src109_r, filt0, filt1, filt2); + SRARI_H4_SH(out0, out1, out2, out3, 5); + SAT_SH4_SH(out0, out1, out2, out3, 7); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + CONVERT_UB_AVG_ST8x4_UB(out0, out1, out2, out3, dst0, dst1, dst2, dst3, + dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src76_r; + src32_r = src98_r; + src21_r = src87_r; + src43_r = src109_r; + src4 = src10; + } +} + +static void avc_luma_vt_and_aver_dst_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + int32_t loop_cnt; + int16_t filt_const0 = 0xfb01; + int16_t filt_const1 = 0x1414; + int16_t filt_const2 = 0x1fb; + v16u8 dst0, dst1, dst2, dst3; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r, src65_r; + v16i8 src87_r, src10_l, src32_l, src54_l, src76_l, src21_l, src43_l; + v16i8 src65_l, src87_l; + v8i16 out0_r, out1_r, out2_r, out3_r, out0_l, out1_l, out2_l, out3_l; + v16i8 filt0, filt1, filt2; + v16u8 res0, res1, res2, res3; + + filt0 = (v16i8) __msa_fill_h(filt_const0); + filt1 = (v16i8) __msa_fill_h(filt_const1); + filt2 = (v16i8) __msa_fill_h(filt_const2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + ILVL_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_l, src21_l, src32_l, src43_l); + + for (loop_cnt = 4; loop_cnt--;) { + LD_SB4(src, src_stride, src5, src6, src7, src8); + src += (4 * src_stride); + + XORI_B4_128_SB(src5, src6, src7, src8); + ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, + src54_r, src65_r, src76_r, src87_r); + ILVL_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, + src54_l, src65_l, src76_l, src87_l); + out0_r = DPADD_SH3_SH(src10_r, src32_r, src54_r, filt0, filt1, filt2); + out1_r = DPADD_SH3_SH(src21_r, src43_r, src65_r, filt0, filt1, filt2); + out2_r = DPADD_SH3_SH(src32_r, src54_r, src76_r, filt0, filt1, filt2); + out3_r = DPADD_SH3_SH(src43_r, src65_r, src87_r, filt0, filt1, filt2); + out0_l = DPADD_SH3_SH(src10_l, src32_l, src54_l, filt0, filt1, filt2); + out1_l = DPADD_SH3_SH(src21_l, src43_l, src65_l, filt0, filt1, filt2); + out2_l = DPADD_SH3_SH(src32_l, src54_l, src76_l, filt0, filt1, filt2); + out3_l = DPADD_SH3_SH(src43_l, src65_l, src87_l, filt0, filt1, filt2); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 5); + SRARI_H4_SH(out0_l, out1_l, out2_l, out3_l, 5); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SAT_SH4_SH(out0_l, out1_l, out2_l, out3_l, 7); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + PCKEV_B4_UB(out0_l, out0_r, out1_l, out1_r, out2_l, out2_r, out3_l, + out3_r, res0, res1, res2, res3); + XORI_B4_128_UB(res0, res1, res2, res3); + AVER_UB4_UB(res0, dst0, res1, dst1, res2, dst2, res3, dst3, + res0, res1, res2, res3); + ST_UB4(res0, res1, res2, res3, dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src54_r; + src32_r = src76_r; + src21_r = src65_r; + src43_r = src87_r; + src10_l = src54_l; + src32_l = src76_l; + src21_l = src65_l; + src43_l = src87_l; + src4 = src8; + } +} + +static void avc_luma_vt_qrt_and_aver_dst_4x4_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + uint8_t ver_offset) +{ + int16_t filt_const0 = 0xfb01; + int16_t filt_const1 = 0x1414; + int16_t filt_const2 = 0x1fb; + v16u8 dst0, dst1, dst2, dst3; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r, src65_r; + v16i8 src87_r, src2110, src4332, src6554, src8776; + v8i16 out10, out32; + v16i8 filt0, filt1, filt2; + v16u8 res; + + filt0 = (v16i8) __msa_fill_h(filt_const0); + filt1 = (v16i8) __msa_fill_h(filt_const1); + filt2 = (v16i8) __msa_fill_h(filt_const2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + ILVR_D2_SB(src21_r, src10_r, src43_r, src32_r, src2110, src4332); + XORI_B2_128_SB(src2110, src4332); + LD_SB4(src, src_stride, src5, src6, src7, src8); + ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, + src54_r, src65_r, src76_r, src87_r); + ILVR_D2_SB(src65_r, src54_r, src87_r, src76_r, src6554, src8776); + XORI_B2_128_SB(src6554, src8776); + out10 = DPADD_SH3_SH(src2110, src4332, src6554, filt0, filt1, filt2); + out32 = DPADD_SH3_SH(src4332, src6554, src8776, filt0, filt1, filt2); + SRARI_H2_SH(out10, out32, 5); + SAT_SH2_SH(out10, out32, 7); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + res = PCKEV_XORI128_UB(out10, out32); + + if (ver_offset) { + src32_r = (v16i8) __msa_insve_w((v4i32) src3, 1, (v4i32) src4); + src54_r = (v16i8) __msa_insve_w((v4i32) src5, 1, (v4i32) src6); + } else { + src32_r = (v16i8) __msa_insve_w((v4i32) src2, 1, (v4i32) src3); + src54_r = (v16i8) __msa_insve_w((v4i32) src4, 1, (v4i32) src5); + } + + src32_r = (v16i8) __msa_insve_d((v2i64) src32_r, 1, (v2i64) src54_r); + res = __msa_aver_u_b(res, (v16u8) src32_r); + + ILVR_W2_UB(dst1, dst0, dst3, dst2, dst0, dst1); + + dst0 = (v16u8) __msa_pckev_d((v2i64) dst1, (v2i64) dst0); + dst0 = __msa_aver_u_b(res, dst0); + + ST4x4_UB(dst0, dst0, 0, 1, 2, 3, dst, dst_stride); +} + +static void avc_luma_vt_qrt_and_aver_dst_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + uint8_t ver_offset) +{ + int32_t loop_cnt; + int16_t filt_const0 = 0xfb01; + int16_t filt_const1 = 0x1414; + int16_t filt_const2 = 0x1fb; + v16u8 dst0, dst1, dst2, dst3; + v16i8 src0, src1, src2, src3, src4, src7, src8, src9, src10; + v16i8 src10_r, src32_r, src76_r, src98_r; + v16i8 src21_r, src43_r, src87_r, src109_r; + v8i16 out0_r, out1_r, out2_r, out3_r; + v16i8 res0, res1; + v16u8 vec0, vec1; + v16i8 filt0, filt1, filt2; + + filt0 = (v16i8) __msa_fill_h(filt_const0); + filt1 = (v16i8) __msa_fill_h(filt_const1); + filt2 = (v16i8) __msa_fill_h(filt_const2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + + for (loop_cnt = 2; loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + src += (4 * src_stride); + + XORI_B4_128_SB(src7, src8, src9, src10); + ILVR_B4_SB(src7, src4, src8, src7, src9, src8, src10, src9, + src76_r, src87_r, src98_r, src109_r); + out0_r = DPADD_SH3_SH(src10_r, src32_r, src76_r, filt0, filt1, filt2); + out1_r = DPADD_SH3_SH(src21_r, src43_r, src87_r, filt0, filt1, filt2); + out2_r = DPADD_SH3_SH(src32_r, src76_r, src98_r, filt0, filt1, filt2); + out3_r = DPADD_SH3_SH(src43_r, src87_r, src109_r, filt0, filt1, filt2); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 5); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + PCKEV_B2_SB(out1_r, out0_r, out3_r, out2_r, res0, res1); + + if (ver_offset) { + PCKEV_D2_SB(src4, src3, src8, src7, src10_r, src32_r); + } else { + PCKEV_D2_SB(src3, src2, src7, src4, src10_r, src32_r); + } + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + ILVR_D2_UB(dst1, dst0, dst3, dst2, dst0, dst1); + + vec0 = (v16u8) __msa_aver_s_b(res0, src10_r); + vec1 = (v16u8) __msa_aver_s_b(res1, src32_r); + + XORI_B2_128_UB(vec0, vec1); + AVER_UB2_UB(vec0, dst0, vec1, dst1, vec0, vec1); + ST8x4_UB(vec0, vec1, dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src76_r; + src32_r = src98_r; + src21_r = src87_r; + src43_r = src109_r; + src2 = src8; + src3 = src9; + src4 = src10; + } +} + +static void avc_luma_vt_qrt_and_aver_dst_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + uint8_t ver_offset) +{ + int32_t loop_cnt; + int16_t filt_const0 = 0xfb01; + int16_t filt_const1 = 0x1414; + int16_t filt_const2 = 0x1fb; + v16u8 dst0, dst1, dst2, dst3; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r, src65_r; + v16i8 src87_r, src10_l, src32_l, src54_l, src76_l, src21_l, src43_l; + v16i8 src65_l, src87_l; + v8i16 out0_r, out1_r, out2_r, out3_r, out0_l, out1_l, out2_l, out3_l; + v16i8 out0, out1, out2, out3; + v16i8 filt0, filt1, filt2; + v16u8 res0, res1, res2, res3; + + filt0 = (v16i8) __msa_fill_h(filt_const0); + filt1 = (v16i8) __msa_fill_h(filt_const1); + filt2 = (v16i8) __msa_fill_h(filt_const2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + ILVL_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_l, src21_l, src32_l, src43_l); + + for (loop_cnt = 4; loop_cnt--;) { + LD_SB4(src, src_stride, src5, src6, src7, src8); + src += (4 * src_stride); + + XORI_B4_128_SB(src5, src6, src7, src8); + ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, + src54_r, src65_r, src76_r, src87_r); + ILVL_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, + src54_l, src65_l, src76_l, src87_l); + out0_r = DPADD_SH3_SH(src10_r, src32_r, src54_r, filt0, filt1, filt2); + out1_r = DPADD_SH3_SH(src21_r, src43_r, src65_r, filt0, filt1, filt2); + out2_r = DPADD_SH3_SH(src32_r, src54_r, src76_r, filt0, filt1, filt2); + out3_r = DPADD_SH3_SH(src43_r, src65_r, src87_r, filt0, filt1, filt2); + out0_l = DPADD_SH3_SH(src10_l, src32_l, src54_l, filt0, filt1, filt2); + out1_l = DPADD_SH3_SH(src21_l, src43_l, src65_l, filt0, filt1, filt2); + out2_l = DPADD_SH3_SH(src32_l, src54_l, src76_l, filt0, filt1, filt2); + out3_l = DPADD_SH3_SH(src43_l, src65_l, src87_l, filt0, filt1, filt2); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 5); + SRARI_H4_SH(out0_l, out1_l, out2_l, out3_l, 5); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SAT_SH4_SH(out0_l, out1_l, out2_l, out3_l, 7); + PCKEV_B4_SB(out0_l, out0_r, out1_l, out1_r, out2_l, out2_r, out3_l, + out3_r, out0, out1, out2, out3); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + if (ver_offset) { + res0 = (v16u8) __msa_aver_s_b(out0, src3); + res1 = (v16u8) __msa_aver_s_b(out1, src4); + res2 = (v16u8) __msa_aver_s_b(out2, src5); + res3 = (v16u8) __msa_aver_s_b(out3, src6); + } else { + res0 = (v16u8) __msa_aver_s_b(out0, src2); + res1 = (v16u8) __msa_aver_s_b(out1, src3); + res2 = (v16u8) __msa_aver_s_b(out2, src4); + res3 = (v16u8) __msa_aver_s_b(out3, src5); + } + + XORI_B4_128_UB(res0, res1, res2, res3); + AVER_UB4_UB(res0, dst0, res1, dst1, res2, dst2, res3, dst3, + dst0, dst1, dst2, dst3); + ST_UB4(dst0, dst1, dst2, dst3, dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src54_r; + src32_r = src76_r; + src21_r = src65_r; + src43_r = src87_r; + src10_l = src54_l; + src32_l = src76_l; + src21_l = src65_l; + src43_l = src87_l; + src2 = src6; + src3 = src7; + src4 = src8; + } +} + +static void avc_luma_mid_and_aver_dst_4x4_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16i8 src0, src1, src2, src3, src4; + v16i8 mask0, mask1, mask2; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8; + v8i16 res0, res1, res2, res3; + v16u8 dst0, dst1, dst2, dst3; + v16u8 tmp0, tmp1, tmp2, tmp3; + + LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2); + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + + hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1, + mask0, mask1, mask2); + hz_out2 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3, + mask0, mask1, mask2); + + PCKOD_D2_SH(hz_out0, hz_out0, hz_out2, hz_out2, hz_out1, hz_out3); + + hz_out4 = AVC_HORZ_FILTER_SH(src4, mask0, mask1, mask2); + + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + + hz_out5 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1, + mask0, mask1, mask2); + hz_out7 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3, + mask0, mask1, mask2); + + PCKOD_D2_SH(hz_out5, hz_out5, hz_out7, hz_out7, hz_out6, hz_out8); + + res0 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out0, hz_out1, hz_out2, + hz_out3, hz_out4, hz_out5); + res1 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out1, hz_out2, hz_out3, + hz_out4, hz_out5, hz_out6); + res2 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out2, hz_out3, hz_out4, + hz_out5, hz_out6, hz_out7); + res3 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out3, hz_out4, hz_out5, + hz_out6, hz_out7, hz_out8); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + tmp0 = PCKEV_XORI128_UB(res0, res1); + tmp1 = PCKEV_XORI128_UB(res2, res3); + PCKEV_D2_UB(dst1, dst0, dst3, dst2, tmp2, tmp3); + AVER_UB2_UB(tmp0, tmp2, tmp1, tmp3, tmp0, tmp1); + + ST4x4_UB(tmp0, tmp1, 0, 2, 0, 2, dst, dst_stride); +} + +static void avc_luma_mid_and_aver_dst_8w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4; + v16i8 mask0, mask1, mask2; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8; + v16u8 dst0, dst1, dst2, dst3; + v8i16 res0, res1, res2, res3; + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + XORI_B5_128_SB(src0, src1, src2, src3, src4); + src += (5 * src_stride); + + hz_out0 = AVC_HORZ_FILTER_SH(src0, mask0, mask1, mask2); + hz_out1 = AVC_HORZ_FILTER_SH(src1, mask0, mask1, mask2); + hz_out2 = AVC_HORZ_FILTER_SH(src2, mask0, mask1, mask2); + hz_out3 = AVC_HORZ_FILTER_SH(src3, mask0, mask1, mask2); + hz_out4 = AVC_HORZ_FILTER_SH(src4, mask0, mask1, mask2); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + + hz_out5 = AVC_HORZ_FILTER_SH(src0, mask0, mask1, mask2); + hz_out6 = AVC_HORZ_FILTER_SH(src1, mask0, mask1, mask2); + hz_out7 = AVC_HORZ_FILTER_SH(src2, mask0, mask1, mask2); + hz_out8 = AVC_HORZ_FILTER_SH(src3, mask0, mask1, mask2); + + res0 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out0, hz_out1, hz_out2, + hz_out3, hz_out4, hz_out5); + res1 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out1, hz_out2, hz_out3, + hz_out4, hz_out5, hz_out6); + res2 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out2, hz_out3, hz_out4, + hz_out5, hz_out6, hz_out7); + res3 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out3, hz_out4, hz_out5, + hz_out6, hz_out7, hz_out8); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + CONVERT_UB_AVG_ST8x4_UB(res0, res1, res2, res3, dst0, dst1, dst2, dst3, + dst, dst_stride); + + dst += (4 * dst_stride); + hz_out3 = hz_out7; + hz_out1 = hz_out5; + hz_out5 = hz_out4; + hz_out4 = hz_out8; + hz_out2 = hz_out6; + hz_out0 = hz_out5; + } +} + +static void avc_luma_mid_and_aver_dst_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + avc_luma_mid_and_aver_dst_8w_msa(src, src_stride, dst, dst_stride, 16); + avc_luma_mid_and_aver_dst_8w_msa(src + 8, src_stride, dst + 8, dst_stride, + 16); +} + +static void avc_luma_midh_qrt_and_aver_dst_4w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height, + uint8_t horiz_offset) +{ + uint32_t row; + v16i8 src0, src1, src2, src3, src4, src5, src6; + v16u8 dst0, dst1, res; + v8i16 vt_res0, vt_res1, vt_res2, vt_res3; + v4i32 hz_res0, hz_res1; + v8i16 res0, res1; + v8i16 shf_vec0, shf_vec1, shf_vec2, shf_vec3, shf_vec4, shf_vec5; + v8i16 mask0 = { 0, 5, 1, 6, 2, 7, 3, 8 }; + v8i16 mask1 = { 1, 4, 2, 5, 3, 6, 4, 7 }; + v8i16 mask2 = { 2, 3, 3, 4, 4, 5, 5, 6 }; + v8i16 minus5h = __msa_ldi_h(-5); + v8i16 plus20h = __msa_ldi_h(20); + v8i16 zeros = { 0 }; + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + + for (row = (height >> 1); row--;) { + LD_SB2(src, src_stride, src5, src6); + src += (2 * src_stride); + + XORI_B2_128_SB(src5, src6); + LD_UB2(dst, dst_stride, dst0, dst1); + + dst0 = (v16u8) __msa_ilvr_w((v4i32) dst1, (v4i32) dst0); + + AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src0, src1, src2, src3, src4, src5, + vt_res0, vt_res1); + AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src1, src2, src3, src4, src5, src6, + vt_res2, vt_res3); + VSHF_H3_SH(vt_res0, vt_res1, vt_res0, vt_res1, vt_res0, vt_res1, + mask0, mask1, mask2, shf_vec0, shf_vec1, shf_vec2); + VSHF_H3_SH(vt_res2, vt_res3, vt_res2, vt_res3, vt_res2, vt_res3, + mask0, mask1, mask2, shf_vec3, shf_vec4, shf_vec5); + + hz_res0 = __msa_hadd_s_w(shf_vec0, shf_vec0); + DPADD_SH2_SW(shf_vec1, shf_vec2, minus5h, plus20h, hz_res0, hz_res0); + + hz_res1 = __msa_hadd_s_w(shf_vec3, shf_vec3); + DPADD_SH2_SW(shf_vec4, shf_vec5, minus5h, plus20h, hz_res1, hz_res1); + + SRARI_W2_SW(hz_res0, hz_res1, 10); + SAT_SW2_SW(hz_res0, hz_res1, 7); + + res0 = __msa_srari_h(shf_vec2, 5); + res1 = __msa_srari_h(shf_vec5, 5); + + SAT_SH2_SH(res0, res1, 7); + + if (horiz_offset) { + res0 = __msa_ilvod_h(zeros, res0); + res1 = __msa_ilvod_h(zeros, res1); + } else { + ILVEV_H2_SH(res0, zeros, res1, zeros, res0, res1); + } + hz_res0 = __msa_aver_s_w(hz_res0, (v4i32) res0); + hz_res1 = __msa_aver_s_w(hz_res1, (v4i32) res1); + res0 = __msa_pckev_h((v8i16) hz_res1, (v8i16) hz_res0); + + res = PCKEV_XORI128_UB(res0, res0); + + dst0 = __msa_aver_u_b(res, dst0); + + ST4x2_UB(dst0, dst, dst_stride); + dst += (2 * dst_stride); + + src0 = src2; + src1 = src3; + src2 = src4; + src3 = src5; + src4 = src6; + } +} + +static void avc_luma_midh_qrt_and_aver_dst_8w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height, + uint8_t horiz_offset) +{ + uint32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + avc_luma_midh_qrt_and_aver_dst_4w_msa(src, src_stride, dst, dst_stride, + height, horiz_offset); + + src += 4; + dst += 4; + } +} + +static void avc_luma_midh_qrt_and_aver_dst_16w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height, + uint8_t horiz_offset) +{ + uint32_t multiple8_cnt; + + for (multiple8_cnt = 4; multiple8_cnt--;) { + avc_luma_midh_qrt_and_aver_dst_4w_msa(src, src_stride, dst, dst_stride, + height, horiz_offset); + + src += 4; + dst += 4; + } +} + +static void avc_luma_midv_qrt_and_aver_dst_4w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height, + uint8_t ver_offset) +{ + int32_t loop_cnt; + int32_t out0, out1; + v16i8 src0, src1, src2, src3, src4; + v16u8 dst0, dst1; + v16i8 mask0, mask1, mask2; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 hz_out4, hz_out5, hz_out6; + v8i16 res0, res1, res2, res3; + v16u8 vec0, vec1; + + LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2); + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + + hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1, + mask0, mask1, mask2); + hz_out2 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3, + mask0, mask1, mask2); + + PCKOD_D2_SH(hz_out0, hz_out0, hz_out2, hz_out2, hz_out1, hz_out3); + + hz_out4 = AVC_HORZ_FILTER_SH(src4, mask0, mask1, mask2); + + for (loop_cnt = (height >> 1); loop_cnt--;) { + LD_SB2(src, src_stride, src0, src1); + src += (2 * src_stride); + + XORI_B2_128_SB(src0, src1); + LD_UB2(dst, dst_stride, dst0, dst1); + hz_out5 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1, + mask0, mask1, + mask2); + hz_out6 = (v8i16) __msa_pckod_d((v2i64) hz_out5, (v2i64) hz_out5); + res0 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out0, hz_out1, hz_out2, + hz_out3, hz_out4, hz_out5); + res2 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out1, hz_out2, hz_out3, + hz_out4, hz_out5, hz_out6); + + if (ver_offset) { + res1 = __msa_srari_h(hz_out3, 5); + res3 = __msa_srari_h(hz_out4, 5); + } else { + res1 = __msa_srari_h(hz_out2, 5); + res3 = __msa_srari_h(hz_out3, 5); + } + + SAT_SH2_SH(res1, res3, 7); + + res0 = __msa_aver_s_h(res0, res1); + res1 = __msa_aver_s_h(res2, res3); + + vec0 = PCKEV_XORI128_UB(res0, res0); + vec1 = PCKEV_XORI128_UB(res1, res1); + + AVER_UB2_UB(vec0, dst0, vec1, dst1, dst0, dst1); + + out0 = __msa_copy_u_w((v4i32) dst0, 0); + out1 = __msa_copy_u_w((v4i32) dst1, 0); + SW(out0, dst); + dst += dst_stride; + SW(out1, dst); + dst += dst_stride; + + hz_out0 = hz_out2; + hz_out1 = hz_out3; + hz_out2 = hz_out4; + hz_out3 = hz_out5; + hz_out4 = hz_out6; + } +} + +static void avc_luma_midv_qrt_and_aver_dst_8w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height, + uint8_t vert_offset) +{ + int32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4; + v16u8 dst0, dst1, dst2, dst3; + v16i8 mask0, mask1, mask2; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8; + v8i16 res0, res1, res2, res3; + v8i16 res4, res5, res6, res7; + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + XORI_B5_128_SB(src0, src1, src2, src3, src4); + src += (5 * src_stride); + + hz_out0 = AVC_HORZ_FILTER_SH(src0, mask0, mask1, mask2); + hz_out1 = AVC_HORZ_FILTER_SH(src1, mask0, mask1, mask2); + hz_out2 = AVC_HORZ_FILTER_SH(src2, mask0, mask1, mask2); + hz_out3 = AVC_HORZ_FILTER_SH(src3, mask0, mask1, mask2); + hz_out4 = AVC_HORZ_FILTER_SH(src4, mask0, mask1, mask2); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + hz_out5 = AVC_HORZ_FILTER_SH(src0, mask0, mask1, mask2); + hz_out6 = AVC_HORZ_FILTER_SH(src1, mask0, mask1, mask2); + hz_out7 = AVC_HORZ_FILTER_SH(src2, mask0, mask1, mask2); + hz_out8 = AVC_HORZ_FILTER_SH(src3, mask0, mask1, mask2); + + res0 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out0, hz_out1, hz_out2, + hz_out3, hz_out4, hz_out5); + res2 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out1, hz_out2, hz_out3, + hz_out4, hz_out5, hz_out6); + res4 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out2, hz_out3, hz_out4, + hz_out5, hz_out6, hz_out7); + res6 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out3, hz_out4, hz_out5, + hz_out6, hz_out7, hz_out8); + + if (vert_offset) { + res1 = __msa_srari_h(hz_out3, 5); + res3 = __msa_srari_h(hz_out4, 5); + res5 = __msa_srari_h(hz_out5, 5); + res7 = __msa_srari_h(hz_out6, 5); + } else { + res1 = __msa_srari_h(hz_out2, 5); + res3 = __msa_srari_h(hz_out3, 5); + res5 = __msa_srari_h(hz_out4, 5); + res7 = __msa_srari_h(hz_out5, 5); + } + + SAT_SH4_SH(res1, res3, res5, res7, 7); + + res0 = __msa_aver_s_h(res0, res1); + res1 = __msa_aver_s_h(res2, res3); + res2 = __msa_aver_s_h(res4, res5); + res3 = __msa_aver_s_h(res6, res7); + + CONVERT_UB_AVG_ST8x4_UB(res0, res1, res2, res3, dst0, dst1, dst2, dst3, + dst, dst_stride); + dst += (4 * dst_stride); + + hz_out0 = hz_out4; + hz_out1 = hz_out5; + hz_out2 = hz_out6; + hz_out3 = hz_out7; + hz_out4 = hz_out8; + } +} + +static void avc_luma_midv_qrt_and_aver_dst_16w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height, + uint8_t vert_offset) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + avc_luma_midv_qrt_and_aver_dst_8w_msa(src, src_stride, dst, dst_stride, + height, vert_offset); + + src += 8; + dst += 8; + } +} + +static void avc_luma_hv_qrt_and_aver_dst_4x4_msa(const uint8_t *src_x, + const uint8_t *src_y, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16i8 src_hz0, src_hz1, src_hz2, src_hz3; + v16u8 dst0, dst1, dst2, dst3; + v16i8 src_vt0, src_vt1, src_vt2, src_vt3, src_vt4; + v16i8 src_vt5, src_vt6, src_vt7, src_vt8; + v16i8 mask0, mask1, mask2; + v8i16 hz_out0, hz_out1, vert_out0, vert_out1; + v8i16 res0, res1; + v16u8 res; + + LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2); + LD_SB5(src_y, src_stride, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4); + src_y += (5 * src_stride); + + src_vt0 = (v16i8) __msa_insve_w((v4i32) src_vt0, 1, (v4i32) src_vt1); + src_vt1 = (v16i8) __msa_insve_w((v4i32) src_vt1, 1, (v4i32) src_vt2); + src_vt2 = (v16i8) __msa_insve_w((v4i32) src_vt2, 1, (v4i32) src_vt3); + src_vt3 = (v16i8) __msa_insve_w((v4i32) src_vt3, 1, (v4i32) src_vt4); + + XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3); + LD_SB4(src_x, src_stride, src_hz0, src_hz1, src_hz2, src_hz3); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3); + hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz0, src_hz1, + mask0, mask1, mask2); + hz_out1 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz2, src_hz3, + mask0, mask1, mask2); + SRARI_H2_SH(hz_out0, hz_out1, 5); + SAT_SH2_SH(hz_out0, hz_out1, 7); + LD_SB4(src_y, src_stride, src_vt5, src_vt6, src_vt7, src_vt8); + + src_vt4 = (v16i8) __msa_insve_w((v4i32) src_vt4, 1, (v4i32) src_vt5); + src_vt5 = (v16i8) __msa_insve_w((v4i32) src_vt5, 1, (v4i32) src_vt6); + src_vt6 = (v16i8) __msa_insve_w((v4i32) src_vt6, 1, (v4i32) src_vt7); + src_vt7 = (v16i8) __msa_insve_w((v4i32) src_vt7, 1, (v4i32) src_vt8); + + XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7); + + /* filter calc */ + vert_out0 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt0, src_vt1, src_vt2, + src_vt3, src_vt4, src_vt5); + vert_out1 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt2, src_vt3, src_vt4, + src_vt5, src_vt6, src_vt7); + SRARI_H2_SH(vert_out0, vert_out1, 5); + SAT_SH2_SH(vert_out0, vert_out1, 7); + + res1 = __msa_srari_h((hz_out1 + vert_out1), 1); + res0 = __msa_srari_h((hz_out0 + vert_out0), 1); + + SAT_SH2_SH(res0, res1, 7); + res = PCKEV_XORI128_UB(res0, res1); + + dst0 = (v16u8) __msa_insve_w((v4i32) dst0, 1, (v4i32) dst1); + dst1 = (v16u8) __msa_insve_w((v4i32) dst2, 1, (v4i32) dst3); + dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1); + dst0 = __msa_aver_u_b(res, dst0); + + ST4x4_UB(dst0, dst0, 0, 1, 2, 3, dst, dst_stride); +} + +static void avc_luma_hv_qrt_and_aver_dst_8x8_msa(const uint8_t *src_x, + const uint8_t *src_y, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint32_t loop_cnt; + v16i8 src_hz0, src_hz1, src_hz2, src_hz3; + v16u8 dst0, dst1, dst2, dst3; + v16i8 src_vt0, src_vt1, src_vt2, src_vt3; + v16i8 src_vt4, src_vt5, src_vt6, src_vt7, src_vt8; + v16i8 mask0, mask1, mask2; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 vert_out0, vert_out1, vert_out2, vert_out3; + v8i16 out0, out1, out2, out3; + + LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); + + LD_SB5(src_y, src_stride, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4); + src_y += (5 * src_stride); + + src_vt0 = (v16i8) __msa_insve_d((v2i64) src_vt0, 1, (v2i64) src_vt1); + src_vt1 = (v16i8) __msa_insve_d((v2i64) src_vt1, 1, (v2i64) src_vt2); + src_vt2 = (v16i8) __msa_insve_d((v2i64) src_vt2, 1, (v2i64) src_vt3); + src_vt3 = (v16i8) __msa_insve_d((v2i64) src_vt3, 1, (v2i64) src_vt4); + + XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3); + + for (loop_cnt = 2; loop_cnt--;) { + LD_SB4(src_x, src_stride, src_hz0, src_hz1, src_hz2, src_hz3); + XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3); + src_x += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + hz_out0 = AVC_HORZ_FILTER_SH(src_hz0, mask0, mask1, mask2); + hz_out1 = AVC_HORZ_FILTER_SH(src_hz1, mask0, mask1, mask2); + hz_out2 = AVC_HORZ_FILTER_SH(src_hz2, mask0, mask1, mask2); + hz_out3 = AVC_HORZ_FILTER_SH(src_hz3, mask0, mask1, mask2); + SRARI_H4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 5); + SAT_SH4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 7); + LD_SB4(src_y, src_stride, src_vt5, src_vt6, src_vt7, src_vt8); + src_y += (4 * src_stride); + + src_vt4 = (v16i8) __msa_insve_d((v2i64) src_vt4, 1, (v2i64) src_vt5); + src_vt5 = (v16i8) __msa_insve_d((v2i64) src_vt5, 1, (v2i64) src_vt6); + src_vt6 = (v16i8) __msa_insve_d((v2i64) src_vt6, 1, (v2i64) src_vt7); + src_vt7 = (v16i8) __msa_insve_d((v2i64) src_vt7, 1, (v2i64) src_vt8); + + XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7); + AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt0, src_vt1, src_vt2, src_vt3, + src_vt4, src_vt5, vert_out0, vert_out1); + AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt2, src_vt3, src_vt4, src_vt5, + src_vt6, src_vt7, vert_out2, vert_out3); + SRARI_H4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 5); + SAT_SH4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 7); + + out0 = __msa_srari_h((hz_out0 + vert_out0), 1); + out1 = __msa_srari_h((hz_out1 + vert_out1), 1); + out2 = __msa_srari_h((hz_out2 + vert_out2), 1); + out3 = __msa_srari_h((hz_out3 + vert_out3), 1); + + SAT_SH4_SH(out0, out1, out2, out3, 7); + CONVERT_UB_AVG_ST8x4_UB(out0, out1, out2, out3, dst0, dst1, dst2, dst3, + dst, dst_stride); + dst += (4 * dst_stride); + + src_vt0 = src_vt4; + src_vt1 = src_vt5; + src_vt2 = src_vt6; + src_vt3 = src_vt7; + src_vt4 = src_vt8; + } +} + +static void avc_luma_hv_qrt_and_aver_dst_16x16_msa(const uint8_t *src_x, + const uint8_t *src_y, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + avc_luma_hv_qrt_and_aver_dst_8x8_msa(src_x, src_y, src_stride, + dst, dst_stride); + + src_x += 8; + src_y += 8; + dst += 8; + } + + src_x += (8 * src_stride) - 16; + src_y += (8 * src_stride) - 16; + dst += (8 * dst_stride) - 16; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + avc_luma_hv_qrt_and_aver_dst_8x8_msa(src_x, src_y, src_stride, + dst, dst_stride); + + src_x += 8; + src_y += 8; + dst += 8; + } +} + +static void copy_width8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint64_t out0, out1, out2, out3, out4, out5, out6, out7; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + if (0 == height % 12) { + for (cnt = (height / 12); cnt--;) { + LD_UB8(src, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + out4 = __msa_copy_u_d((v2i64) src4, 0); + out5 = __msa_copy_u_d((v2i64) src5, 0); + out6 = __msa_copy_u_d((v2i64) src6, 0); + out7 = __msa_copy_u_d((v2i64) src7, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + SD4(out4, out5, out6, out7, dst, dst_stride); + dst += (4 * dst_stride); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 8) { + for (cnt = height >> 3; cnt--;) { + LD_UB8(src, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + out4 = __msa_copy_u_d((v2i64) src4, 0); + out5 = __msa_copy_u_d((v2i64) src5, 0); + out6 = __msa_copy_u_d((v2i64) src6, 0); + out7 = __msa_copy_u_d((v2i64) src7, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + SD4(out4, out5, out6, out7, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 4) { + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 2) { + for (cnt = (height / 2); cnt--;) { + LD_UB2(src, src_stride, src0, src1); + src += (2 * src_stride); + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + + SD(out0, dst); + dst += dst_stride; + SD(out1, dst); + dst += dst_stride; + } + } +} + +static void copy_16multx8mult_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, int32_t width) +{ + int32_t cnt, loop_cnt; + const uint8_t *src_tmp; + uint8_t *dst_tmp; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + for (cnt = (width >> 4); cnt--;) { + src_tmp = src; + dst_tmp = dst; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src_tmp, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src_tmp += (8 * src_stride); + + ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, + dst_tmp, dst_stride); + dst_tmp += (8 * dst_stride); + } + + src += 16; + dst += 16; + } +} + +static void copy_width16_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + if (0 == height % 12) { + for (cnt = (height / 12); cnt--;) { + LD_UB8(src, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, + dst, dst_stride); + dst += (8 * dst_stride); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 8) { + copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 16); + } else if (0 == height % 4) { + for (cnt = (height >> 2); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + dst += (4 * dst_stride); + } + } +} + +static void avg_width4_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint32_t out0, out1, out2, out3; + v16u8 src0, src1, src2, src3; + v16u8 dst0, dst1, dst2, dst3; + + if (0 == (height % 4)) { + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + + out0 = __msa_copy_u_w((v4i32) dst0, 0); + out1 = __msa_copy_u_w((v4i32) dst1, 0); + out2 = __msa_copy_u_w((v4i32) dst2, 0); + out3 = __msa_copy_u_w((v4i32) dst3, 0); + SW4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == (height % 2)) { + for (cnt = (height / 2); cnt--;) { + LD_UB2(src, src_stride, src0, src1); + src += (2 * src_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + + AVER_UB2_UB(src0, dst0, src1, dst1, dst0, dst1); + + out0 = __msa_copy_u_w((v4i32) dst0, 0); + out1 = __msa_copy_u_w((v4i32) dst1, 0); + SW(out0, dst); + dst += dst_stride; + SW(out1, dst); + dst += dst_stride; + } + } +} + +static void avg_width8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint64_t out0, out1, out2, out3; + v16u8 src0, src1, src2, src3; + v16u8 dst0, dst1, dst2, dst3; + + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + + out0 = __msa_copy_u_d((v2i64) dst0, 0); + out1 = __msa_copy_u_d((v2i64) dst1, 0); + out2 = __msa_copy_u_d((v2i64) dst2, 0); + out3 = __msa_copy_u_d((v2i64) dst3, 0); + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void avg_width16_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + + for (cnt = (height / 8); cnt--;) { + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + LD_UB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + AVER_UB4_UB(src4, dst4, src5, dst5, src6, dst6, src7, dst7, + dst4, dst5, dst6, dst7); + ST_UB8(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst, dst_stride); + dst += (8 * dst_stride); + } +} + +void ff_put_h264_qpel16_mc00_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + copy_width16_msa(src, stride, dst, stride, 16); +} + +void ff_put_h264_qpel8_mc00_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + copy_width8_msa(src, stride, dst, stride, 8); +} + +void ff_avg_h264_qpel16_mc00_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avg_width16_msa(src, stride, dst, stride, 16); +} + +void ff_avg_h264_qpel8_mc00_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avg_width8_msa(src, stride, dst, stride, 8); +} + +void ff_avg_h264_qpel4_mc00_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avg_width4_msa(src, stride, dst, stride, 4); +} + +void ff_put_h264_qpel16_mc10_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_qrt_16w_msa(src - 2, stride, dst, stride, 16, 0); +} + +void ff_put_h264_qpel16_mc30_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_qrt_16w_msa(src - 2, stride, dst, stride, 16, 1); +} + +void ff_put_h264_qpel8_mc10_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_qrt_8w_msa(src - 2, stride, dst, stride, 8, 0); +} + +void ff_put_h264_qpel8_mc30_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_qrt_8w_msa(src - 2, stride, dst, stride, 8, 1); +} + +void ff_put_h264_qpel4_mc10_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_qrt_4w_msa(src - 2, stride, dst, stride, 4, 0); +} + +void ff_put_h264_qpel4_mc30_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_qrt_4w_msa(src - 2, stride, dst, stride, 4, 1); +} + +void ff_put_h264_qpel16_mc20_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_16w_msa(src - 2, stride, dst, stride, 16); +} + +void ff_put_h264_qpel8_mc20_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_8w_msa(src - 2, stride, dst, stride, 8); +} + +void ff_put_h264_qpel4_mc20_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_4w_msa(src - 2, stride, dst, stride, 4); +} + +void ff_put_h264_qpel16_mc01_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_qrt_16w_msa(src - (stride * 2), stride, dst, stride, 16, 0); +} + +void ff_put_h264_qpel16_mc03_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_qrt_16w_msa(src - (stride * 2), stride, dst, stride, 16, 1); +} + +void ff_put_h264_qpel8_mc01_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_qrt_8w_msa(src - (stride * 2), stride, dst, stride, 8, 0); +} + +void ff_put_h264_qpel8_mc03_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_qrt_8w_msa(src - (stride * 2), stride, dst, stride, 8, 1); +} + +void ff_put_h264_qpel4_mc01_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_qrt_4w_msa(src - (stride * 2), stride, dst, stride, 4, 0); +} + +void ff_put_h264_qpel4_mc03_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_qrt_4w_msa(src - (stride * 2), stride, dst, stride, 4, 1); +} + +void ff_put_h264_qpel16_mc11_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_16w_msa(src - 2, + src - (stride * 2), stride, dst, stride, 16); +} + +void ff_put_h264_qpel16_mc31_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_16w_msa(src - 2, + src - (stride * 2) + + sizeof(uint8_t), stride, dst, stride, 16); +} + +void ff_put_h264_qpel16_mc13_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_16w_msa(src + stride - 2, + src - (stride * 2), stride, dst, stride, 16); +} + +void ff_put_h264_qpel16_mc33_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_16w_msa(src + stride - 2, + src - (stride * 2) + + sizeof(uint8_t), stride, dst, stride, 16); +} + +void ff_put_h264_qpel8_mc11_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_8w_msa(src - 2, src - (stride * 2), stride, dst, stride, 8); +} + +void ff_put_h264_qpel8_mc31_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_8w_msa(src - 2, + src - (stride * 2) + + sizeof(uint8_t), stride, dst, stride, 8); +} + +void ff_put_h264_qpel8_mc13_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_8w_msa(src + stride - 2, + src - (stride * 2), stride, dst, stride, 8); +} + +void ff_put_h264_qpel8_mc33_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_8w_msa(src + stride - 2, + src - (stride * 2) + + sizeof(uint8_t), stride, dst, stride, 8); +} + + +void ff_put_h264_qpel4_mc11_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_4w_msa(src - 2, src - (stride * 2), stride, dst, stride, 4); +} + +void ff_put_h264_qpel4_mc31_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_4w_msa(src - 2, + src - (stride * 2) + + sizeof(uint8_t), stride, dst, stride, 4); +} + +void ff_put_h264_qpel4_mc13_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_4w_msa(src + stride - 2, + src - (stride * 2), stride, dst, stride, 4); +} + +void ff_put_h264_qpel4_mc33_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_4w_msa(src + stride - 2, + src - (stride * 2) + + sizeof(uint8_t), stride, dst, stride, 4); +} + +void ff_put_h264_qpel16_mc21_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midv_qrt_16w_msa(src - (2 * stride) - 2, + stride, dst, stride, 16, 0); +} + +void ff_put_h264_qpel16_mc23_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midv_qrt_16w_msa(src - (2 * stride) - 2, + stride, dst, stride, 16, 1); +} + +void ff_put_h264_qpel8_mc21_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midv_qrt_8w_msa(src - (2 * stride) - 2, stride, dst, stride, 8, 0); +} + +void ff_put_h264_qpel8_mc23_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midv_qrt_8w_msa(src - (2 * stride) - 2, stride, dst, stride, 8, 1); +} + +void ff_put_h264_qpel4_mc21_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midv_qrt_4w_msa(src - (2 * stride) - 2, stride, dst, stride, 4, 0); +} + +void ff_put_h264_qpel4_mc23_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midv_qrt_4w_msa(src - (2 * stride) - 2, stride, dst, stride, 4, 1); +} + +void ff_put_h264_qpel16_mc02_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_16w_msa(src - (stride * 2), stride, dst, stride, 16); +} + +void ff_put_h264_qpel8_mc02_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_8w_msa(src - (stride * 2), stride, dst, stride, 8); +} + +void ff_put_h264_qpel4_mc02_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_4w_msa(src - (stride * 2), stride, dst, stride, 4); +} + +void ff_put_h264_qpel16_mc12_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midh_qrt_16w_msa(src - (2 * stride) - 2, + stride, dst, stride, 16, 0); +} + +void ff_put_h264_qpel16_mc32_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midh_qrt_16w_msa(src - (2 * stride) - 2, + stride, dst, stride, 16, 1); +} + +void ff_put_h264_qpel8_mc12_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midh_qrt_8w_msa(src - (2 * stride) - 2, stride, dst, stride, 8, 0); +} + +void ff_put_h264_qpel8_mc32_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midh_qrt_8w_msa(src - (2 * stride) - 2, stride, dst, stride, 8, 1); +} + +void ff_put_h264_qpel4_mc12_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midh_qrt_4w_msa(src - (2 * stride) - 2, stride, dst, stride, 4, 0); +} + +void ff_put_h264_qpel4_mc32_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midh_qrt_4w_msa(src - (2 * stride) - 2, stride, dst, stride, 4, 1); +} + +void ff_put_h264_qpel16_mc22_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_mid_16w_msa(src - (2 * stride) - 2, stride, dst, stride, 16); +} + +void ff_put_h264_qpel8_mc22_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_mid_8w_msa(src - (2 * stride) - 2, stride, dst, stride, 8); +} + +void ff_put_h264_qpel4_mc22_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_mid_4w_msa(src - (2 * stride) - 2, stride, dst, stride, 4); +} + +void ff_avg_h264_qpel16_mc10_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_qrt_and_aver_dst_16x16_msa(src - 2, stride, dst, stride, 0); +} + +void ff_avg_h264_qpel16_mc30_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_qrt_and_aver_dst_16x16_msa(src - 2, stride, dst, stride, 1); +} + +void ff_avg_h264_qpel8_mc10_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_qrt_and_aver_dst_8x8_msa(src - 2, stride, dst, stride, 0); +} + +void ff_avg_h264_qpel8_mc30_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_qrt_and_aver_dst_8x8_msa(src - 2, stride, dst, stride, 1); +} + +void ff_avg_h264_qpel4_mc10_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_qrt_and_aver_dst_4x4_msa(src - 2, stride, dst, stride, 0); +} + +void ff_avg_h264_qpel4_mc30_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_qrt_and_aver_dst_4x4_msa(src - 2, stride, dst, stride, 1); +} + +void ff_avg_h264_qpel16_mc20_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_and_aver_dst_16x16_msa(src - 2, stride, dst, stride); +} + +void ff_avg_h264_qpel8_mc20_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_and_aver_dst_8x8_msa(src - 2, stride, dst, stride); +} + +void ff_avg_h264_qpel4_mc20_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hz_and_aver_dst_4x4_msa(src - 2, stride, dst, stride); +} + +void ff_avg_h264_qpel16_mc01_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_qrt_and_aver_dst_16x16_msa(src - (stride * 2), + stride, dst, stride, 0); +} + +void ff_avg_h264_qpel16_mc03_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_qrt_and_aver_dst_16x16_msa(src - (stride * 2), + stride, dst, stride, 1); +} + +void ff_avg_h264_qpel8_mc01_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_qrt_and_aver_dst_8x8_msa(src - (stride * 2), + stride, dst, stride, 0); +} + +void ff_avg_h264_qpel8_mc03_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_qrt_and_aver_dst_8x8_msa(src - (stride * 2), + stride, dst, stride, 1); +} + +void ff_avg_h264_qpel4_mc01_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_qrt_and_aver_dst_4x4_msa(src - (stride * 2), + stride, dst, stride, 0); +} + +void ff_avg_h264_qpel4_mc03_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_qrt_and_aver_dst_4x4_msa(src - (stride * 2), + stride, dst, stride, 1); +} + +void ff_avg_h264_qpel16_mc11_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_and_aver_dst_16x16_msa(src - 2, + src - (stride * 2), + stride, dst, stride); +} + +void ff_avg_h264_qpel16_mc31_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_and_aver_dst_16x16_msa(src - 2, + src - (stride * 2) + + sizeof(uint8_t), stride, + dst, stride); +} + +void ff_avg_h264_qpel16_mc13_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_and_aver_dst_16x16_msa(src + stride - 2, + src - (stride * 2), + stride, dst, stride); +} + +void ff_avg_h264_qpel16_mc33_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_and_aver_dst_16x16_msa(src + stride - 2, + src - (stride * 2) + + sizeof(uint8_t), stride, + dst, stride); +} + +void ff_avg_h264_qpel8_mc11_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_and_aver_dst_8x8_msa(src - 2, + src - (stride * 2), + stride, dst, stride); +} + +void ff_avg_h264_qpel8_mc31_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_and_aver_dst_8x8_msa(src - 2, + src - (stride * 2) + + sizeof(uint8_t), stride, dst, stride); +} + +void ff_avg_h264_qpel8_mc13_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_and_aver_dst_8x8_msa(src + stride - 2, + src - (stride * 2), + stride, dst, stride); +} + +void ff_avg_h264_qpel8_mc33_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_and_aver_dst_8x8_msa(src + stride - 2, + src - (stride * 2) + + sizeof(uint8_t), stride, dst, stride); +} + + +void ff_avg_h264_qpel4_mc11_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_and_aver_dst_4x4_msa(src - 2, + src - (stride * 2), + stride, dst, stride); +} + +void ff_avg_h264_qpel4_mc31_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_and_aver_dst_4x4_msa(src - 2, + src - (stride * 2) + + sizeof(uint8_t), stride, dst, stride); +} + +void ff_avg_h264_qpel4_mc13_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_and_aver_dst_4x4_msa(src + stride - 2, + src - (stride * 2), + stride, dst, stride); +} + +void ff_avg_h264_qpel4_mc33_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_hv_qrt_and_aver_dst_4x4_msa(src + stride - 2, + src - (stride * 2) + + sizeof(uint8_t), stride, dst, stride); +} + +void ff_avg_h264_qpel16_mc21_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midv_qrt_and_aver_dst_16w_msa(src - (2 * stride) - 2, + stride, dst, stride, 16, 0); +} + +void ff_avg_h264_qpel16_mc23_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midv_qrt_and_aver_dst_16w_msa(src - (2 * stride) - 2, + stride, dst, stride, 16, 1); +} + +void ff_avg_h264_qpel8_mc21_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midv_qrt_and_aver_dst_8w_msa(src - (2 * stride) - 2, + stride, dst, stride, 8, 0); +} + +void ff_avg_h264_qpel8_mc23_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midv_qrt_and_aver_dst_8w_msa(src - (2 * stride) - 2, + stride, dst, stride, 8, 1); +} + +void ff_avg_h264_qpel4_mc21_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midv_qrt_and_aver_dst_4w_msa(src - (2 * stride) - 2, + stride, dst, stride, 4, 0); +} + +void ff_avg_h264_qpel4_mc23_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midv_qrt_and_aver_dst_4w_msa(src - (2 * stride) - 2, + stride, dst, stride, 4, 1); +} + +void ff_avg_h264_qpel16_mc02_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_and_aver_dst_16x16_msa(src - (stride * 2), stride, dst, stride); +} + +void ff_avg_h264_qpel8_mc02_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_and_aver_dst_8x8_msa(src - (stride * 2), stride, dst, stride); +} + +void ff_avg_h264_qpel4_mc02_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_vt_and_aver_dst_4x4_msa(src - (stride * 2), stride, dst, stride); +} + +void ff_avg_h264_qpel16_mc12_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midh_qrt_and_aver_dst_16w_msa(src - (2 * stride) - 2, + stride, dst, stride, 16, 0); +} + +void ff_avg_h264_qpel16_mc32_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midh_qrt_and_aver_dst_16w_msa(src - (2 * stride) - 2, + stride, dst, stride, 16, 1); +} + +void ff_avg_h264_qpel8_mc12_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midh_qrt_and_aver_dst_8w_msa(src - (2 * stride) - 2, + stride, dst, stride, 8, 0); +} + +void ff_avg_h264_qpel8_mc32_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midh_qrt_and_aver_dst_8w_msa(src - (2 * stride) - 2, + stride, dst, stride, 8, 1); +} + +void ff_avg_h264_qpel4_mc12_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midh_qrt_and_aver_dst_4w_msa(src - (2 * stride) - 2, + stride, dst, stride, 4, 0); +} + +void ff_avg_h264_qpel4_mc32_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_midh_qrt_and_aver_dst_4w_msa(src - (2 * stride) - 2, + stride, dst, stride, 4, 1); +} + +void ff_avg_h264_qpel16_mc22_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_mid_and_aver_dst_16x16_msa(src - (2 * stride) - 2, + stride, dst, stride); +} + +void ff_avg_h264_qpel8_mc22_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_mid_and_aver_dst_8w_msa(src - (2 * stride) - 2, + stride, dst, stride, 8); +} + +void ff_avg_h264_qpel4_mc22_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride) +{ + avc_luma_mid_and_aver_dst_4x4_msa(src - (2 * stride) - 2, + stride, dst, stride); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevcdsp_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevcdsp_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevcdsp_init_mips.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevcdsp_init_mips.c 2015-06-10 17:20:04.000000000 +0000 @@ -403,6 +403,32 @@ c->put_hevc_epel_bi_w[6][1][1] = ff_hevc_put_hevc_bi_w_epel_hv24_8_msa; c->put_hevc_epel_bi_w[7][1][1] = ff_hevc_put_hevc_bi_w_epel_hv32_8_msa; + c->sao_band_filter[0] = + c->sao_band_filter[1] = + c->sao_band_filter[2] = + c->sao_band_filter[3] = + c->sao_band_filter[4] = ff_hevc_sao_band_filter_0_8_msa; + + c->sao_edge_filter[0] = + c->sao_edge_filter[1] = + c->sao_edge_filter[2] = + c->sao_edge_filter[3] = + c->sao_edge_filter[4] = ff_hevc_sao_edge_filter_8_msa; + + c->hevc_h_loop_filter_luma = ff_hevc_loop_filter_luma_h_8_msa; + c->hevc_v_loop_filter_luma = ff_hevc_loop_filter_luma_v_8_msa; + + c->hevc_h_loop_filter_chroma = ff_hevc_loop_filter_chroma_h_8_msa; + c->hevc_v_loop_filter_chroma = ff_hevc_loop_filter_chroma_v_8_msa; + + c->hevc_h_loop_filter_luma_c = ff_hevc_loop_filter_luma_h_8_msa; + c->hevc_v_loop_filter_luma_c = ff_hevc_loop_filter_luma_v_8_msa; + + c->hevc_h_loop_filter_chroma_c = + ff_hevc_loop_filter_chroma_h_8_msa; + c->hevc_v_loop_filter_chroma_c = + ff_hevc_loop_filter_chroma_v_8_msa; + c->idct[0] = ff_hevc_idct_4x4_msa; c->idct[1] = ff_hevc_idct_8x8_msa; c->idct[2] = ff_hevc_idct_16x16_msa; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevcdsp_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevcdsp_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevcdsp_mips.h 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevcdsp_mips.h 2015-07-31 17:20:05.000000000 +0000 @@ -24,7 +24,7 @@ #include "libavcodec/hevcdsp.h" #define MC(PEL, DIR, WIDTH) \ -void ff_hevc_put_hevc_##PEL##_##DIR####WIDTH##_8_msa(int16_t *dst, \ +void ff_hevc_put_hevc_##PEL##_##DIR##WIDTH##_8_msa(int16_t *dst, \ uint8_t *src, \ ptrdiff_t src_stride, \ int height, \ @@ -102,7 +102,7 @@ #undef MC #define UNI_MC(PEL, DIR, WIDTH) \ -void ff_hevc_put_hevc_uni_##PEL##_##DIR####WIDTH##_8_msa(uint8_t *dst, \ +void ff_hevc_put_hevc_uni_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst, \ ptrdiff_t dst_stride, \ uint8_t *src, \ ptrdiff_t src_stride, \ @@ -181,7 +181,7 @@ #undef UNI_MC #define UNI_W_MC(PEL, DIR, WIDTH) \ -void ff_hevc_put_hevc_uni_w_##PEL##_##DIR####WIDTH##_8_msa(uint8_t *dst, \ +void ff_hevc_put_hevc_uni_w_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst, \ ptrdiff_t \ dst_stride, \ uint8_t *src, \ @@ -265,7 +265,7 @@ #undef UNI_W_MC #define BI_MC(PEL, DIR, WIDTH) \ -void ff_hevc_put_hevc_bi_##PEL##_##DIR####WIDTH##_8_msa(uint8_t *dst, \ +void ff_hevc_put_hevc_bi_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst, \ ptrdiff_t dst_stride, \ uint8_t *src, \ ptrdiff_t src_stride, \ @@ -345,7 +345,7 @@ #undef BI_MC #define BI_W_MC(PEL, DIR, WIDTH) \ -void ff_hevc_put_hevc_bi_w_##PEL##_##DIR####WIDTH##_8_msa(uint8_t *dst, \ +void ff_hevc_put_hevc_bi_w_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst, \ ptrdiff_t \ dst_stride, \ uint8_t *src, \ @@ -431,6 +431,36 @@ #undef BI_W_MC +void ff_hevc_loop_filter_luma_h_8_msa(uint8_t *src, + ptrdiff_t src_stride, + int32_t beta, int32_t *tc, + uint8_t *no_p, uint8_t *no_q); + +void ff_hevc_loop_filter_luma_v_8_msa(uint8_t *src, + ptrdiff_t src_stride, + int32_t beta, int32_t *tc, + uint8_t *no_p, uint8_t *no_q); + +void ff_hevc_loop_filter_chroma_h_8_msa(uint8_t *src, + ptrdiff_t src_stride, + int32_t *tc, uint8_t *no_p, + uint8_t *no_q); + +void ff_hevc_loop_filter_chroma_v_8_msa(uint8_t *src, + ptrdiff_t src_stride, + int32_t *tc, uint8_t *no_p, + uint8_t *no_q); + +void ff_hevc_sao_band_filter_0_8_msa(uint8_t *dst, uint8_t *src, + ptrdiff_t stride_dst, ptrdiff_t stride_src, + int16_t *sao_offset_val, int sao_left_class, + int width, int height); + +void ff_hevc_sao_edge_filter_8_msa(uint8_t *dst, uint8_t *src, + ptrdiff_t stride_dst, + int16_t *sao_offset_val, + int eo, int width, int height); + void ff_hevc_idct_4x4_msa(int16_t *coeffs, int col_limit); void ff_hevc_idct_8x8_msa(int16_t *coeffs, int col_limit); void ff_hevc_idct_16x16_msa(int16_t *coeffs, int col_limit); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevcdsp_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevcdsp_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevcdsp_msa.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevcdsp_msa.c 2015-07-31 17:20:05.000000000 +0000 @@ -3792,7 +3792,7 @@ #undef MC_COPY #define MC(PEL, DIR, WIDTH, TAP, DIR1, FILT_DIR) \ -void ff_hevc_put_hevc_##PEL##_##DIR####WIDTH##_8_msa(int16_t *dst, \ +void ff_hevc_put_hevc_##PEL##_##DIR##WIDTH##_8_msa(int16_t *dst, \ uint8_t *src, \ ptrdiff_t src_stride, \ int height, \ @@ -3843,7 +3843,7 @@ #undef MC #define MC_HV(PEL, DIR, WIDTH, TAP, DIR1) \ -void ff_hevc_put_hevc_##PEL##_##DIR####WIDTH##_8_msa(int16_t *dst, \ +void ff_hevc_put_hevc_##PEL##_##DIR##WIDTH##_8_msa(int16_t *dst, \ uint8_t *src, \ ptrdiff_t src_stride, \ int height, \ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevc_idct_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevc_idct_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevc_idct_msa.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevc_idct_msa.c 2015-06-11 17:20:04.000000000 +0000 @@ -21,18 +21,18 @@ #include "libavutil/mips/generic_macros_msa.h" #include "libavcodec/mips/hevcdsp_mips.h" -static int16_t gt8x8_cnst[16] = { +static const int16_t gt8x8_cnst[16] = { 64, 64, 83, 36, 89, 50, 18, 75, 64, -64, 36, -83, 75, -89, -50, -18 }; -static int16_t gt16x16_cnst[64] = { +static const int16_t gt16x16_cnst[64] = { 64, 83, 64, 36, 89, 75, 50, 18, 90, 80, 57, 25, 70, 87, 9, 43, 64, 36, -64, -83, 75, -18, -89, -50, 87, 9, -80, -70, -43, 57, -25, -90, 64, -36, -64, 83, 50, -89, 18, 75, 80, -70, -25, 90, -87, 9, 43, 57, 64, -83, 64, -36, 18, -50, 75, -89, 70, -87, 90, -80, 9, -43, -57, 25 }; -static int16_t gt32x32_cnst0[256] = { +static const int16_t gt32x32_cnst0[256] = { 90, 90, 88, 85, 82, 78, 73, 67, 61, 54, 46, 38, 31, 22, 13, 4, 90, 82, 67, 46, 22, -4, -31, -54, -73, -85, -90, -88, -78, -61, -38, -13, 88, 67, 31, -13, -54, -82, -90, -78, -46, -4, 38, 73, 90, 85, 61, 22, @@ -51,18 +51,18 @@ 4, -13, 22, -31, 38, -46, 54, -61, 67, -73, 78, -82, 85, -88, 90, -90 }; -static int16_t gt32x32_cnst1[64] = { +static const int16_t gt32x32_cnst1[64] = { 90, 87, 80, 70, 57, 43, 25, 9, 87, 57, 9, -43, -80, -90, -70, -25, 80, 9, -70, -87, -25, 57, 90, 43, 70, -43, -87, 9, 90, 25, -80, -57, 57, -80, -25, 90, -9, -87, 43, 70, 43, -90, 57, 25, -87, 70, 9, -80, 25, -70, 90, -80, 43, 9, -57, 87, 9, -25, 43, -57, 70, -80, 87, -90 }; -static int16_t gt32x32_cnst2[16] = { +static const int16_t gt32x32_cnst2[16] = { 89, 75, 50, 18, 75, -18, -89, -50, 50, -89, 18, 75, 18, -50, 75, -89 }; -static int16_t gt32x32_cnst3[16] = { +static const int16_t gt32x32_cnst3[16] = { 64, 64, 64, 64, 83, 36, -36, -83, 64, -64, -64, 64, 36, -83, 83, -36 }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevc_lpf_sao_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevc_lpf_sao_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevc_lpf_sao_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevc_lpf_sao_msa.c 2015-06-10 17:20:04.000000000 +0000 @@ -0,0 +1,2088 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "libavcodec/mips/hevcdsp_mips.h" + +static void hevc_loopfilter_luma_hor_msa(uint8_t *src, int32_t stride, + int32_t beta, int32_t *tc, + uint8_t *p_is_pcm, uint8_t *q_is_pcm) +{ + uint8_t *p3 = src - (stride << 2); + uint8_t *p2 = src - ((stride << 1) + stride); + uint8_t *p1 = src - (stride << 1); + uint8_t *p0 = src - stride; + uint8_t *q0 = src; + uint8_t *q1 = src + stride; + uint8_t *q2 = src + (stride << 1); + uint8_t *q3 = src + (stride << 1) + stride; + uint8_t flag0, flag1; + int32_t dp00, dq00, dp30, dq30, d00, d30; + int32_t dp04, dq04, dp34, dq34, d04, d34; + int32_t tc0, p_is_pcm0, q_is_pcm0, beta30, beta20, tc250; + int32_t tc4, p_is_pcm4, q_is_pcm4, tc254, tmp; + uint64_t dst_val0, dst_val1; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5; + v2i64 cmp0, cmp1, cmp2, p_is_pcm_vec, q_is_pcm_vec; + v8u16 temp0, temp1; + v8i16 temp2; + v8i16 tc_pos, tc_neg; + v8i16 diff0, diff1, delta0, delta1, delta2, abs_delta0; + v16i8 zero = { 0 }; + v8u16 p3_src, p2_src, p1_src, p0_src, q0_src, q1_src, q2_src, q3_src; + + dp00 = abs(p2[0] - (p1[0] << 1) + p0[0]); + dq00 = abs(q2[0] - (q1[0] << 1) + q0[0]); + dp30 = abs(p2[3] - (p1[3] << 1) + p0[3]); + dq30 = abs(q2[3] - (q1[3] << 1) + q0[3]); + d00 = dp00 + dq00; + d30 = dp30 + dq30; + p_is_pcm0 = p_is_pcm[0]; + q_is_pcm0 = q_is_pcm[0]; + dp04 = abs(p2[4] - (p1[4] << 1) + p0[4]); + dq04 = abs(q2[4] - (q1[4] << 1) + q0[4]); + dp34 = abs(p2[7] - (p1[7] << 1) + p0[7]); + dq34 = abs(q2[7] - (q1[7] << 1) + q0[7]); + d04 = dp04 + dq04; + d34 = dp34 + dq34; + p_is_pcm4 = p_is_pcm[1]; + q_is_pcm4 = q_is_pcm[1]; + + if (!p_is_pcm0 || !p_is_pcm4 || !q_is_pcm0 || !q_is_pcm4) { + if (!(d00 + d30 >= beta) || !(d04 + d34 >= beta)) { + p3_src = LD_UH(p3); + p2_src = LD_UH(p2); + p1_src = LD_UH(p1); + p0_src = LD_UH(p0); + q0_src = LD_UH(q0); + q1_src = LD_UH(q1); + q2_src = LD_UH(q2); + q3_src = LD_UH(q3); + + tc0 = tc[0]; + beta30 = beta >> 3; + beta20 = beta >> 2; + tc250 = ((tc0 * 5 + 1) >> 1); + tc4 = tc[1]; + tc254 = ((tc4 * 5 + 1) >> 1); + + flag0 = (abs(p3[0] - p0[0]) + abs(q3[0] - q0[0]) < beta30 && + abs(p0[0] - q0[0]) < tc250 && + abs(p3[3] - p0[3]) + abs(q3[3] - q0[3]) < beta30 && + abs(p0[3] - q0[3]) < tc250 && + (d00 << 1) < beta20 && (d30 << 1) < beta20); + cmp0 = __msa_fill_d(flag0); + + flag1 = (abs(p3[4] - p0[4]) + abs(q3[4] - q0[4]) < beta30 && + abs(p0[4] - q0[4]) < tc254 && + abs(p3[7] - p0[7]) + abs(q3[7] - q0[7]) < beta30 && + abs(p0[7] - q0[7]) < tc254 && + (d04 << 1) < beta20 && (d34 << 1) < beta20); + cmp1 = __msa_fill_d(flag1); + cmp2 = __msa_ilvev_d(cmp1, cmp0); + cmp2 = __msa_ceqi_d(cmp2, 0); + + ILVR_B8_UH(zero, p3_src, zero, p2_src, zero, p1_src, zero, p0_src, + zero, q0_src, zero, q1_src, zero, q2_src, zero, q3_src, + p3_src, p2_src, p1_src, p0_src, q0_src, q1_src, q2_src, + q3_src); + + cmp0 = (v2i64) __msa_fill_h(tc0); + cmp1 = (v2i64) __msa_fill_h(tc4); + tc_pos = (v8i16) __msa_ilvev_d(cmp1, cmp0); + tc_pos <<= 1; + tc_neg = -tc_pos; + + temp0 = (p1_src + p0_src + q0_src); + temp1 = ((p3_src + p2_src) << 1) + p2_src + temp0; + temp1 = (v8u16) __msa_srari_h((v8i16) temp1, 3); + temp2 = (v8i16) (temp1 - p2_src); + temp2 = CLIP_SH(temp2, tc_neg, tc_pos); + dst0 = (v16u8) (temp2 + (v8i16) p2_src); + + temp1 = temp0 + p2_src; + temp1 = (v8u16) __msa_srari_h((v8i16) temp1, 2); + temp2 = (v8i16) (temp1 - p1_src); + temp2 = CLIP_SH(temp2, tc_neg, tc_pos); + dst1 = (v16u8) (temp2 + (v8i16) p1_src); + + temp1 = (temp0 << 1) + p2_src + q1_src; + temp1 = (v8u16) __msa_srari_h((v8i16) temp1, 3); + temp2 = (v8i16) (temp1 - p0_src); + temp2 = CLIP_SH(temp2, tc_neg, tc_pos); + dst2 = (v16u8) (temp2 + (v8i16) p0_src); + + cmp0 = __msa_fill_d(p_is_pcm0); + cmp1 = __msa_fill_d(p_is_pcm4); + p_is_pcm_vec = __msa_ilvev_d(cmp1, cmp0); + p_is_pcm_vec = __msa_ceqi_d(p_is_pcm_vec, 0); + + dst0 = __msa_bmz_v(dst0, (v16u8) p2_src, (v16u8) p_is_pcm_vec); + dst1 = __msa_bmz_v(dst1, (v16u8) p1_src, (v16u8) p_is_pcm_vec); + dst2 = __msa_bmz_v(dst2, (v16u8) p0_src, (v16u8) p_is_pcm_vec); + + temp0 = (q1_src + p0_src + q0_src); + + temp1 = ((q3_src + q2_src) << 1) + q2_src + temp0; + temp1 = (v8u16) __msa_srari_h((v8i16) temp1, 3); + temp2 = (v8i16) (temp1 - q2_src); + temp2 = CLIP_SH(temp2, tc_neg, tc_pos); + dst5 = (v16u8) (temp2 + (v8i16) q2_src); + + temp1 = temp0 + q2_src; + temp1 = (v8u16) __msa_srari_h((v8i16) temp1, 2); + temp2 = (v8i16) (temp1 - q1_src); + temp2 = CLIP_SH(temp2, tc_neg, tc_pos); + dst4 = (v16u8) (temp2 + (v8i16) q1_src); + + temp1 = (temp0 << 1) + p1_src + q2_src; + temp1 = (v8u16) __msa_srari_h((v8i16) temp1, 3); + temp2 = (v8i16) (temp1 - q0_src); + temp2 = CLIP_SH(temp2, tc_neg, tc_pos); + dst3 = (v16u8) (temp2 + (v8i16) q0_src); + + cmp0 = __msa_fill_d(q_is_pcm0); + cmp1 = __msa_fill_d(q_is_pcm4); + q_is_pcm_vec = __msa_ilvev_d(cmp1, cmp0); + q_is_pcm_vec = __msa_ceqi_d(q_is_pcm_vec, 0); + + dst3 = __msa_bmz_v(dst3, (v16u8) q0_src, (v16u8) q_is_pcm_vec); + dst4 = __msa_bmz_v(dst4, (v16u8) q1_src, (v16u8) q_is_pcm_vec); + dst5 = __msa_bmz_v(dst5, (v16u8) q2_src, (v16u8) q_is_pcm_vec); + + tc_pos >>= 1; + tc_neg = -tc_pos; + + diff0 = (v8i16) (q0_src - p0_src); + diff1 = (v8i16) (q1_src - p1_src); + diff0 = (diff0 << 3) + diff0; + diff1 = (diff1 << 1) + diff1; + delta0 = diff0 - diff1; + delta0 = __msa_srari_h(delta0, 4); + + temp1 = (v8u16) ((tc_pos << 3) + (tc_pos << 1)); + abs_delta0 = __msa_add_a_h(delta0, (v8i16) zero); + abs_delta0 = (v8u16) abs_delta0 < temp1; + + delta0 = CLIP_SH(delta0, tc_neg, tc_pos); + + temp0 = (v8u16) (delta0 + p0_src); + temp0 = (v8u16) CLIP_SH_0_255(temp0); + temp0 = (v8u16) __msa_bmz_v((v16u8) temp0, (v16u8) p0_src, + (v16u8) p_is_pcm_vec); + + temp2 = (v8i16) (q0_src - delta0); + temp2 = CLIP_SH_0_255(temp2); + temp2 = (v8i16) __msa_bmz_v((v16u8) temp2, (v16u8) q0_src, + (v16u8) q_is_pcm_vec); + + tmp = (beta + (beta >> 1)) >> 3; + cmp0 = __msa_fill_d(!p_is_pcm0 && ((dp00 + dp30) < tmp)); + cmp1 = __msa_fill_d(!p_is_pcm4 && ((dp04 + dp34) < tmp)); + p_is_pcm_vec = __msa_ilvev_d(cmp1, cmp0); + p_is_pcm_vec = __msa_ceqi_d(p_is_pcm_vec, 0); + + cmp0 = (v2i64) __msa_fill_h((!q_is_pcm0) && (dq00 + dq30 < tmp)); + cmp1 = (v2i64) __msa_fill_h((!q_is_pcm4) && (dq04 + dq34 < tmp)); + q_is_pcm_vec = __msa_ilvev_d(cmp1, cmp0); + q_is_pcm_vec = __msa_ceqi_d(q_is_pcm_vec, 0); + + tc_pos >>= 1; + tc_neg = -tc_pos; + + delta1 = (v8i16) __msa_aver_u_h(p2_src, p0_src); + delta1 -= (v8i16) p1_src; + delta1 += delta0; + delta1 >>= 1; + delta1 = CLIP_SH(delta1, tc_neg, tc_pos); + delta1 = (v8i16) p1_src + (v8i16) delta1; + delta1 = CLIP_SH_0_255(delta1); + delta1 = (v8i16) __msa_bmnz_v((v16u8) delta1, (v16u8) p1_src, + (v16u8) p_is_pcm_vec); + + delta2 = (v8i16) __msa_aver_u_h(q0_src, q2_src); + delta2 = delta2 - (v8i16) q1_src; + delta2 = delta2 - delta0; + delta2 = delta2 >> 1; + delta2 = CLIP_SH(delta2, tc_neg, tc_pos); + delta2 = (v8i16) q1_src + (v8i16) delta2; + delta2 = CLIP_SH_0_255(delta2); + delta2 = (v8i16) __msa_bmnz_v((v16u8) delta2, (v16u8) q1_src, + (v16u8) q_is_pcm_vec); + + delta1 = (v8i16) __msa_bmz_v((v16u8) delta1, (v16u8) p1_src, + (v16u8) abs_delta0); + temp0 = (v8u16) __msa_bmz_v((v16u8) temp0, (v16u8) p0_src, + (v16u8) abs_delta0); + temp2 = (v8i16) __msa_bmz_v((v16u8) temp2, (v16u8) q0_src, + (v16u8) abs_delta0); + delta2 = (v8i16) __msa_bmz_v((v16u8) delta2, (v16u8) q1_src, + (v16u8) abs_delta0); + + dst2 = __msa_bmnz_v(dst2, (v16u8) temp0, (v16u8) cmp2); + dst3 = __msa_bmnz_v(dst3, (v16u8) temp2, (v16u8) cmp2); + dst1 = __msa_bmnz_v(dst1, (v16u8) delta1, (v16u8) cmp2); + dst4 = __msa_bmnz_v(dst4, (v16u8) delta2, (v16u8) cmp2); + dst0 = __msa_bmnz_v(dst0, (v16u8) p2_src, (v16u8) cmp2); + dst5 = __msa_bmnz_v(dst5, (v16u8) q2_src, (v16u8) cmp2); + + cmp0 = __msa_fill_d(d00 + d30 >= beta); + cmp1 = __msa_fill_d(d04 + d34 >= beta); + cmp0 = __msa_ilvev_d(cmp1, cmp0); + cmp0 = __msa_ceqi_d(cmp0, 0); + + dst0 = __msa_bmz_v(dst0, (v16u8) p2_src, (v16u8) cmp0); + dst1 = __msa_bmz_v(dst1, (v16u8) p1_src, (v16u8) cmp0); + dst2 = __msa_bmz_v(dst2, (v16u8) p0_src, (v16u8) cmp0); + dst3 = __msa_bmz_v(dst3, (v16u8) q0_src, (v16u8) cmp0); + dst4 = __msa_bmz_v(dst4, (v16u8) q1_src, (v16u8) cmp0); + dst5 = __msa_bmz_v(dst5, (v16u8) q2_src, (v16u8) cmp0); + + PCKEV_B2_UB(dst1, dst0, dst3, dst2, dst0, dst1); + dst2 = (v16u8) __msa_pckev_b((v16i8) dst5, (v16i8) dst4); + + dst_val0 = __msa_copy_u_d((v2i64) dst2, 0); + dst_val1 = __msa_copy_u_d((v2i64) dst2, 1); + + ST8x4_UB(dst0, dst1, p2, stride); + p2 += (4 * stride); + SD(dst_val0, p2); + p2 += stride; + SD(dst_val1, p2); + } + } +} + +static void hevc_loopfilter_luma_ver_msa(uint8_t *src, int32_t stride, + int32_t beta, int32_t *tc, + uint8_t *p_is_pcm, uint8_t *q_is_pcm) +{ + uint8_t *p3 = src; + uint8_t *p2 = src + 3 * stride; + uint8_t *p1 = src + (stride << 2); + uint8_t *p0 = src + 7 * stride; + uint8_t flag0, flag1; + uint16_t tmp0, tmp1; + uint32_t tmp2, tmp3; + int32_t dp00, dq00, dp30, dq30, d00, d30; + int32_t dp04, dq04, dp34, dq34, d04, d34; + int32_t tc0, p_is_pcm0, q_is_pcm0, beta30, beta20, tc250; + int32_t tc4, p_is_pcm4, q_is_pcm4, tc254, tmp; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v2i64 cmp0, cmp1, cmp2, p_is_pcm_vec, q_is_pcm_vec; + v8u16 temp0, temp1; + v8i16 temp2; + v8i16 tc_pos, tc_neg; + v8i16 diff0, diff1, delta0, delta1, delta2, abs_delta0; + v16i8 zero = { 0 }; + v8u16 p3_src, p2_src, p1_src, p0_src, q0_src, q1_src, q2_src, q3_src; + + dp00 = abs(p3[-3] - (p3[-2] << 1) + p3[-1]); + dq00 = abs(p3[2] - (p3[1] << 1) + p3[0]); + dp30 = abs(p2[-3] - (p2[-2] << 1) + p2[-1]); + dq30 = abs(p2[2] - (p2[1] << 1) + p2[0]); + d00 = dp00 + dq00; + d30 = dp30 + dq30; + p_is_pcm0 = p_is_pcm[0]; + q_is_pcm0 = q_is_pcm[0]; + + dp04 = abs(p1[-3] - (p1[-2] << 1) + p1[-1]); + dq04 = abs(p1[2] - (p1[1] << 1) + p1[0]); + dp34 = abs(p0[-3] - (p0[-2] << 1) + p0[-1]); + dq34 = abs(p0[2] - (p0[1] << 1) + p0[0]); + d04 = dp04 + dq04; + d34 = dp34 + dq34; + p_is_pcm4 = p_is_pcm[1]; + q_is_pcm4 = q_is_pcm[1]; + + if (!p_is_pcm0 || !p_is_pcm4 || !q_is_pcm0 || !q_is_pcm4) { + if (!(d00 + d30 >= beta) || !(d04 + d34 >= beta)) { + src -= 4; + LD_UH8(src, stride, + p3_src, p2_src, p1_src, p0_src, q0_src, q1_src, q2_src, + q3_src); + + tc0 = tc[0]; + beta30 = beta >> 3; + beta20 = beta >> 2; + tc250 = ((tc0 * 5 + 1) >> 1); + + tc4 = tc[1]; + tc254 = ((tc4 * 5 + 1) >> 1); + + TRANSPOSE8x8_UB_UH(p3_src, p2_src, p1_src, p0_src, q0_src, q1_src, + q2_src, q3_src, p3_src, p2_src, p1_src, p0_src, + q0_src, q1_src, q2_src, q3_src); + + flag0 = (abs(p3[-4] - p3[-1]) + abs(p3[3] - p3[0]) < beta30 && + abs(p3[-1] - p3[0]) < tc250 && + abs(p2[-4] - p2[-1]) + abs(p2[3] - p2[0]) < beta30 && + abs(p2[-1] - p2[0]) < tc250 && + (d00 << 1) < beta20 && (d30 << 1) < beta20); + cmp0 = __msa_fill_d(flag0); + + flag1 = (abs(p1[-4] - p1[-1]) + abs(p1[3] - p1[0]) < beta30 && + abs(p1[-1] - p1[0]) < tc254 && + abs(p0[-4] - p0[-1]) + abs(p0[3] - p0[0]) < beta30 && + abs(p0[-1] - p0[0]) < tc254 && + (d04 << 1) < beta20 && (d34 << 1) < beta20); + cmp1 = __msa_fill_d(flag1); + cmp2 = __msa_ilvev_d(cmp1, cmp0); + cmp2 = __msa_ceqi_d(cmp2, 0); + + ILVR_B8_UH(zero, p3_src, zero, p2_src, zero, p1_src, zero, p0_src, + zero, q0_src, zero, q1_src, zero, q2_src, zero, q3_src, + p3_src, p2_src, p1_src, p0_src, q0_src, q1_src, q2_src, + q3_src); + + cmp0 = (v2i64) __msa_fill_h(tc0 << 1); + cmp1 = (v2i64) __msa_fill_h(tc4 << 1); + tc_pos = (v8i16) __msa_ilvev_d(cmp1, cmp0); + tc_neg = -tc_pos; + + temp0 = (p1_src + p0_src + q0_src); + + temp1 = ((p3_src + p2_src) << 1) + p2_src + temp0; + temp1 = (v8u16) __msa_srari_h((v8i16) temp1, 3); + temp2 = (v8i16) (temp1 - p2_src); + temp2 = CLIP_SH(temp2, tc_neg, tc_pos); + dst0 = (v16u8) (temp2 + (v8i16) p2_src); + + temp1 = temp0 + p2_src; + temp1 = (v8u16) __msa_srari_h((v8i16) temp1, 2); + temp2 = (v8i16) (temp1 - p1_src); + temp2 = CLIP_SH(temp2, tc_neg, tc_pos); + dst1 = (v16u8) (temp2 + (v8i16) p1_src); + + temp1 = (temp0 << 1) + p2_src + q1_src; + temp1 = (v8u16) __msa_srari_h((v8i16) temp1, 3); + temp2 = (v8i16) (temp1 - p0_src); + temp2 = CLIP_SH(temp2, tc_neg, tc_pos); + dst2 = (v16u8) (temp2 + (v8i16) p0_src); + + cmp0 = __msa_fill_d(p_is_pcm0); + cmp1 = __msa_fill_d(p_is_pcm4); + p_is_pcm_vec = __msa_ilvev_d(cmp1, cmp0); + p_is_pcm_vec = __msa_ceqi_d(p_is_pcm_vec, 0); + + dst0 = __msa_bmz_v(dst0, (v16u8) p2_src, (v16u8) p_is_pcm_vec); + dst1 = __msa_bmz_v(dst1, (v16u8) p1_src, (v16u8) p_is_pcm_vec); + dst2 = __msa_bmz_v(dst2, (v16u8) p0_src, (v16u8) p_is_pcm_vec); + + temp0 = (q1_src + p0_src + q0_src); + temp1 = ((q3_src + q2_src) << 1) + q2_src + temp0; + temp1 = (v8u16) __msa_srari_h((v8i16) temp1, 3); + temp2 = (v8i16) (temp1 - q2_src); + temp2 = CLIP_SH(temp2, tc_neg, tc_pos); + dst5 = (v16u8) (temp2 + (v8i16) q2_src); + + temp1 = temp0 + q2_src; + temp1 = (v8u16) __msa_srari_h((v8i16) temp1, 2); + temp2 = (v8i16) (temp1 - q1_src); + temp2 = CLIP_SH(temp2, tc_neg, tc_pos); + dst4 = (v16u8) (temp2 + (v8i16) q1_src); + + temp1 = (temp0 << 1) + p1_src + q2_src; + temp1 = (v8u16) __msa_srari_h((v8i16) temp1, 3); + temp2 = (v8i16) (temp1 - q0_src); + temp2 = CLIP_SH(temp2, tc_neg, tc_pos); + dst3 = (v16u8) (temp2 + (v8i16) q0_src); + + cmp0 = __msa_fill_d(q_is_pcm0); + cmp1 = __msa_fill_d(q_is_pcm4); + q_is_pcm_vec = __msa_ilvev_d(cmp1, cmp0); + q_is_pcm_vec = __msa_ceqi_d(q_is_pcm_vec, 0); + + dst3 = __msa_bmz_v(dst3, (v16u8) q0_src, (v16u8) q_is_pcm_vec); + dst4 = __msa_bmz_v(dst4, (v16u8) q1_src, (v16u8) q_is_pcm_vec); + dst5 = __msa_bmz_v(dst5, (v16u8) q2_src, (v16u8) q_is_pcm_vec); + + tc_pos >>= 1; + tc_neg = -tc_pos; + + diff0 = (v8i16) (q0_src - p0_src); + diff1 = (v8i16) (q1_src - p1_src); + diff0 = (v8i16) (diff0 << 3) + diff0; + diff1 = (v8i16) (diff1 << 1) + diff1; + delta0 = diff0 - diff1; + delta0 = __msa_srari_h(delta0, 4); + + temp1 = (v8u16) ((tc_pos << 3) + (tc_pos << 1)); + abs_delta0 = __msa_add_a_h(delta0, (v8i16) zero); + abs_delta0 = (v8u16) abs_delta0 < temp1; + + delta0 = CLIP_SH(delta0, tc_neg, tc_pos); + temp0 = (v8u16) delta0 + p0_src; + temp0 = (v8u16) CLIP_SH_0_255(temp0); + temp0 = (v8u16) __msa_bmz_v((v16u8) temp0, (v16u8) p0_src, + (v16u8) p_is_pcm_vec); + + temp2 = (v8i16) q0_src - delta0; + temp2 = CLIP_SH_0_255(temp2); + temp2 = (v8i16) __msa_bmz_v((v16u8) temp2, (v16u8) q0_src, + (v16u8) q_is_pcm_vec); + + tmp = ((beta + (beta >> 1)) >> 3); + cmp0 = __msa_fill_d(!p_is_pcm0 && (dp00 + dp30 < tmp)); + cmp1 = __msa_fill_d(!p_is_pcm4 && (dp04 + dp34 < tmp)); + p_is_pcm_vec = __msa_ilvev_d(cmp1, cmp0); + p_is_pcm_vec = __msa_ceqi_d(p_is_pcm_vec, 0); + + cmp0 = (v2i64) __msa_fill_h((!q_is_pcm0) && (dq00 + dq30 < tmp)); + cmp1 = (v2i64) __msa_fill_h((!q_is_pcm4) && (dq04 + dq34 < tmp)); + q_is_pcm_vec = __msa_ilvev_d(cmp1, cmp0); + q_is_pcm_vec = __msa_ceqi_d(q_is_pcm_vec, 0); + + tc_pos >>= 1; + tc_neg = -tc_pos; + + delta1 = (v8i16) __msa_aver_u_h(p2_src, p0_src); + delta1 -= (v8i16) p1_src; + delta1 += delta0; + delta1 >>= 1; + delta1 = CLIP_SH(delta1, tc_neg, tc_pos); + delta1 = (v8i16) p1_src + (v8i16) delta1; + delta1 = CLIP_SH_0_255(delta1); + delta1 = (v8i16) __msa_bmnz_v((v16u8) delta1, (v16u8) p1_src, + (v16u8) p_is_pcm_vec); + + delta2 = (v8i16) __msa_aver_u_h(q0_src, q2_src); + delta2 = delta2 - (v8i16) q1_src; + delta2 = delta2 - delta0; + delta2 = delta2 >> 1; + delta2 = CLIP_SH(delta2, tc_neg, tc_pos); + delta2 = (v8i16) q1_src + (v8i16) delta2; + delta2 = CLIP_SH_0_255(delta2); + delta2 = (v8i16) __msa_bmnz_v((v16u8) delta2, (v16u8) q1_src, + (v16u8) q_is_pcm_vec); + delta1 = (v8i16) __msa_bmz_v((v16u8) delta1, (v16u8) p1_src, + (v16u8) abs_delta0); + temp0 = (v8u16) __msa_bmz_v((v16u8) temp0, (v16u8) p0_src, + (v16u8) abs_delta0); + temp2 = (v8i16) __msa_bmz_v((v16u8) temp2, (v16u8) q0_src, + (v16u8) abs_delta0); + delta2 = (v8i16) __msa_bmz_v((v16u8) delta2, (v16u8) q1_src, + (v16u8) abs_delta0); + + dst2 = __msa_bmnz_v(dst2, (v16u8) temp0, (v16u8) cmp2); + dst3 = __msa_bmnz_v(dst3, (v16u8) temp2, (v16u8) cmp2); + dst1 = __msa_bmnz_v(dst1, (v16u8) delta1, (v16u8) cmp2); + dst4 = __msa_bmnz_v(dst4, (v16u8) delta2, (v16u8) cmp2); + dst0 = __msa_bmnz_v(dst0, (v16u8) p2_src, (v16u8) cmp2); + dst5 = __msa_bmnz_v(dst5, (v16u8) q2_src, (v16u8) cmp2); + + cmp0 = __msa_fill_d(d00 + d30 >= beta); + dst7 = (v16u8) __msa_fill_d(d04 + d34 >= beta); + cmp0 = __msa_ilvev_d((v2i64) dst7, cmp0); + dst6 = (v16u8) __msa_ceqi_d(cmp0, 0); + + dst0 = __msa_bmz_v(dst0, (v16u8) p2_src, dst6); + dst1 = __msa_bmz_v(dst1, (v16u8) p1_src, dst6); + dst2 = __msa_bmz_v(dst2, (v16u8) p0_src, dst6); + dst3 = __msa_bmz_v(dst3, (v16u8) q0_src, dst6); + dst4 = __msa_bmz_v(dst4, (v16u8) q1_src, dst6); + dst5 = __msa_bmz_v(dst5, (v16u8) q2_src, dst6); + + PCKEV_B4_UB(dst0, dst0, dst1, dst1, dst2, dst2, dst3, dst3, + dst0, dst1, dst2, dst3); + PCKEV_B2_UB(dst4, dst4, dst5, dst5, dst4, dst5); + + TRANSPOSE8x8_UB_UB(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, + dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + src += 1; + + tmp2 = __msa_copy_u_w((v4i32) dst0, 0); + tmp0 = __msa_copy_u_h((v8i16) dst0, 2); + tmp3 = __msa_copy_u_w((v4i32) dst1, 0); + tmp1 = __msa_copy_u_h((v8i16) dst1, 2); + SW(tmp2, src); + SH(tmp0, src + 4); + src += stride; + SW(tmp3, src); + SH(tmp1, src + 4); + src += stride; + + tmp2 = __msa_copy_u_w((v4i32) dst2, 0); + tmp0 = __msa_copy_u_h((v8i16) dst2, 2); + tmp3 = __msa_copy_u_w((v4i32) dst3, 0); + tmp1 = __msa_copy_u_h((v8i16) dst3, 2); + SW(tmp2, src); + SH(tmp0, src + 4); + src += stride; + SW(tmp3, src); + SH(tmp1, src + 4); + src += stride; + + tmp2 = __msa_copy_u_w((v4i32) dst4, 0); + tmp0 = __msa_copy_u_h((v8i16) dst4, 2); + tmp3 = __msa_copy_u_w((v4i32) dst5, 0); + tmp1 = __msa_copy_u_h((v8i16) dst5, 2); + SW(tmp2, src); + SH(tmp0, src + 4); + src += stride; + SW(tmp3, src); + SH(tmp1, src + 4); + src += stride; + + tmp2 = __msa_copy_u_w((v4i32) dst6, 0); + tmp0 = __msa_copy_u_h((v8i16) dst6, 2); + tmp3 = __msa_copy_u_w((v4i32) dst7, 0); + tmp1 = __msa_copy_u_h((v8i16) dst7, 2); + SW(tmp2, src); + SH(tmp0, src + 4); + src += stride; + SW(tmp3, src); + SH(tmp1, src + 4); + } + } +} + +static void hevc_loopfilter_chroma_hor_msa(uint8_t *src, int32_t stride, + int32_t *tc, uint8_t *p_is_pcm, + uint8_t *q_is_pcm) +{ + uint8_t *p1_ptr = src - (stride << 1); + uint8_t *p0_ptr = src - stride; + uint8_t *q0_ptr = src; + uint8_t *q1_ptr = src + stride; + v2i64 cmp0, cmp1, p_is_pcm_vec, q_is_pcm_vec; + v8u16 p1, p0, q0, q1; + v8i16 tc_pos, tc_neg; + v16i8 zero = { 0 }; + v8i16 temp0, temp1, delta; + + if (!(tc[0] <= 0) || !(tc[1] <= 0)) { + cmp0 = (v2i64) __msa_fill_h(tc[0]); + cmp1 = (v2i64) __msa_fill_h(tc[1]); + tc_pos = (v8i16) __msa_ilvev_d(cmp1, cmp0); + tc_neg = -tc_pos; + + cmp0 = __msa_fill_d(p_is_pcm[0]); + cmp1 = __msa_fill_d(p_is_pcm[1]); + p_is_pcm_vec = __msa_ilvev_d(cmp1, cmp0); + p_is_pcm_vec = __msa_ceqi_d(p_is_pcm_vec, 0); + + cmp0 = __msa_fill_d(q_is_pcm[0]); + cmp1 = __msa_fill_d(q_is_pcm[1]); + q_is_pcm_vec = __msa_ilvev_d(cmp1, cmp0); + q_is_pcm_vec = __msa_ceqi_d(q_is_pcm_vec, 0); + + p1 = LD_UH(p1_ptr); + p0 = LD_UH(p0_ptr); + q0 = LD_UH(q0_ptr); + q1 = LD_UH(q1_ptr); + + ILVR_B4_UH(zero, p1, zero, p0, zero, q0, zero, q1, p1, p0, q0, q1); + + temp0 = (v8i16) (q0 - p0); + temp1 = (v8i16) (p1 - q1); + temp0 <<= 2; + temp0 += temp1; + delta = __msa_srari_h((v8i16) temp0, 3); + delta = CLIP_SH(delta, tc_neg, tc_pos); + + temp0 = (v8i16) ((v8i16) p0 + delta); + temp0 = CLIP_SH_0_255(temp0); + temp0 = (v8i16) __msa_bmz_v((v16u8) temp0, (v16u8) p0, + (v16u8) p_is_pcm_vec); + + temp1 = (v8i16) ((v8i16) q0 - delta); + temp1 = CLIP_SH_0_255(temp1); + temp1 = (v8i16) __msa_bmz_v((v16u8) temp1, (v16u8) q0, + (v16u8) q_is_pcm_vec); + + tc_pos = (v8i16) __msa_clei_s_d((v2i64) tc_pos, 0); + temp0 = (v8i16) __msa_bmnz_v((v16u8) temp0, (v16u8) p0, (v16u8) tc_pos); + temp1 = (v8i16) __msa_bmnz_v((v16u8) temp1, (v16u8) q0, (v16u8) tc_pos); + + temp0 = (v8i16) __msa_pckev_b((v16i8) temp1, (v16i8) temp0); + ST8x2_UB(temp0, p0_ptr, stride); + } +} + +static void hevc_loopfilter_chroma_ver_msa(uint8_t *src, int32_t stride, + int32_t *tc, uint8_t *p_is_pcm, + uint8_t *q_is_pcm) +{ + v2i64 cmp0, cmp1, p_is_pcm_vec, q_is_pcm_vec; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + v8u16 p1, p0, q0, q1; + v8i16 tc_pos, tc_neg; + v16i8 zero = { 0 }; + v8i16 temp0, temp1, delta; + + if (!(tc[0] <= 0) || !(tc[1] <= 0)) { + cmp0 = (v2i64) __msa_fill_h(tc[0]); + cmp1 = (v2i64) __msa_fill_h(tc[1]); + tc_pos = (v8i16) __msa_ilvev_d(cmp1, cmp0); + tc_neg = -tc_pos; + + cmp0 = __msa_fill_d(p_is_pcm[0]); + cmp1 = __msa_fill_d(p_is_pcm[1]); + p_is_pcm_vec = __msa_ilvev_d(cmp1, cmp0); + p_is_pcm_vec = __msa_ceqi_d(p_is_pcm_vec, 0); + + cmp0 = __msa_fill_d(q_is_pcm[0]); + cmp1 = __msa_fill_d(q_is_pcm[1]); + q_is_pcm_vec = __msa_ilvev_d(cmp1, cmp0); + q_is_pcm_vec = __msa_ceqi_d(q_is_pcm_vec, 0); + + src -= 2; + LD_UB8(src, stride, src0, src1, src2, src3, src4, src5, src6, src7); + TRANSPOSE8x4_UB_UH(src0, src1, src2, src3, src4, src5, src6, src7, + p1, p0, q0, q1); + ILVR_B4_UH(zero, p1, zero, p0, zero, q0, zero, q1, p1, p0, q0, q1); + + temp0 = (v8i16) (q0 - p0); + temp1 = (v8i16) (p1 - q1); + temp0 <<= 2; + temp0 += temp1; + delta = __msa_srari_h((v8i16) temp0, 3); + delta = CLIP_SH(delta, tc_neg, tc_pos); + + temp0 = (v8i16) ((v8i16) p0 + delta); + temp0 = CLIP_SH_0_255(temp0); + temp0 = (v8i16) __msa_bmz_v((v16u8) temp0, (v16u8) p0, + (v16u8) p_is_pcm_vec); + + temp1 = (v8i16) ((v8i16) q0 - delta); + temp1 = CLIP_SH_0_255(temp1); + temp1 = (v8i16) __msa_bmz_v((v16u8) temp1, (v16u8) q0, + (v16u8) q_is_pcm_vec); + + tc_pos = (v8i16) __msa_clei_s_d((v2i64) tc_pos, 0); + temp0 = (v8i16) __msa_bmnz_v((v16u8) temp0, (v16u8) p0, (v16u8) tc_pos); + temp1 = (v8i16) __msa_bmnz_v((v16u8) temp1, (v16u8) q0, (v16u8) tc_pos); + + temp0 = (v8i16) __msa_ilvev_b((v16i8) temp1, (v16i8) temp0); + + src += 1; + ST2x4_UB(temp0, 0, src, stride); + src += (4 * stride); + ST2x4_UB(temp0, 4, src, stride); + } +} + +static void hevc_sao_band_filter_4width_msa(uint8_t *dst, int32_t dst_stride, + uint8_t *src, int32_t src_stride, + int32_t sao_left_class, + int16_t *sao_offset_val, + int32_t height) +{ + int32_t h_cnt; + v16u8 src0, src1, src2, src3; + v16i8 src0_r, src1_r; + v16i8 offset, offset_val, mask; + v16i8 offset0 = { 0 }; + v16i8 offset1 = { 0 }; + v16i8 zero = { 0 }; + v8i16 temp0, temp1, dst0, dst1; + + offset_val = LD_SB(sao_offset_val + 1); + offset_val = (v16i8) __msa_pckev_d((v2i64) offset_val, (v2i64) offset_val); + + offset_val = __msa_pckev_b(offset_val, offset_val); + offset1 = (v16i8) __msa_insve_w((v4i32) offset1, 3, (v4i32) offset_val); + offset0 = __msa_sld_b(offset1, offset0, 28 - ((sao_left_class) & 31)); + offset1 = __msa_sld_b(zero, offset1, 28 - ((sao_left_class) & 31)); + + if (!((sao_left_class > 12) & (sao_left_class < 29))) { + SWAP(offset0, offset1); + } + + for (h_cnt = height >> 2; h_cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + ILVEV_D2_SB(src0, src1, src2, src3, src0_r, src1_r); + + src0_r = (v16i8) __msa_pckev_w((v4i32) src1_r, (v4i32) src0_r); + mask = __msa_srli_b(src0_r, 3); + offset = __msa_vshf_b(mask, offset1, offset0); + + UNPCK_SB_SH(offset, temp0, temp1); + ILVRL_B2_SH(zero, src0_r, dst0, dst1); + ADD2(dst0, temp0, dst1, temp1, dst0, dst1); + CLIP_SH2_0_255(dst0, dst1); + dst0 = (v8i16) __msa_pckev_b((v16i8) dst1, (v16i8) dst0); + ST4x4_UB(dst0, dst0, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void hevc_sao_band_filter_8width_msa(uint8_t *dst, int32_t dst_stride, + uint8_t *src, int32_t src_stride, + int32_t sao_left_class, + int16_t *sao_offset_val, + int32_t height) +{ + int32_t h_cnt; + v16u8 src0, src1, src2, src3; + v16i8 src0_r, src1_r, mask0, mask1; + v16i8 offset, offset_val; + v16i8 offset0 = { 0 }; + v16i8 offset1 = { 0 }; + v16i8 zero = { 0 }; + v8i16 dst0, dst1, dst2, dst3; + v8i16 temp0, temp1, temp2, temp3; + + offset_val = LD_SB(sao_offset_val + 1); + offset_val = (v16i8) __msa_pckev_d((v2i64) offset_val, (v2i64) offset_val); + offset_val = __msa_pckev_b(offset_val, offset_val); + offset1 = (v16i8) __msa_insve_w((v4i32) offset1, 3, (v4i32) offset_val); + offset0 = __msa_sld_b(offset1, offset0, 28 - ((sao_left_class) & 31)); + offset1 = __msa_sld_b(zero, offset1, 28 - ((sao_left_class) & 31)); + + if (!((sao_left_class > 12) & (sao_left_class < 29))) { + SWAP(offset0, offset1); + } + + for (h_cnt = height >> 2; h_cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + ILVR_D2_SB(src1, src0, src3, src2, src0_r, src1_r); + + mask0 = __msa_srli_b(src0_r, 3); + mask1 = __msa_srli_b(src1_r, 3); + + offset = __msa_vshf_b(mask0, offset1, offset0); + UNPCK_SB_SH(offset, temp0, temp1); + + offset = __msa_vshf_b(mask1, offset1, offset0); + UNPCK_SB_SH(offset, temp2, temp3); + + UNPCK_UB_SH(src0_r, dst0, dst1); + UNPCK_UB_SH(src1_r, dst2, dst3); + ADD4(dst0, temp0, dst1, temp1, dst2, temp2, dst3, temp3, + dst0, dst1, dst2, dst3); + CLIP_SH4_0_255(dst0, dst1, dst2, dst3); + PCKEV_B2_SH(dst1, dst0, dst3, dst2, dst0, dst2); + ST8x4_UB(dst0, dst2, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void hevc_sao_band_filter_16multiple_msa(uint8_t *dst, + int32_t dst_stride, + uint8_t *src, + int32_t src_stride, + int32_t sao_left_class, + int16_t *sao_offset_val, + int32_t width, int32_t height) +{ + int32_t h_cnt, w_cnt; + v16u8 src0, src1, src2, src3; + v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v16i8 out0, out1, out2, out3; + v16i8 mask0, mask1, mask2, mask3; + v16i8 tmp0, tmp1, tmp2, tmp3, offset_val; + v16i8 offset0 = { 0 }; + v16i8 offset1 = { 0 }; + v16i8 zero = { 0 }; + v8i16 temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + + offset_val = LD_SB(sao_offset_val + 1); + offset_val = (v16i8) __msa_pckev_d((v2i64) offset_val, (v2i64) offset_val); + offset_val = __msa_pckev_b(offset_val, offset_val); + offset1 = (v16i8) __msa_insve_w((v4i32) offset1, 3, (v4i32) offset_val); + offset0 = __msa_sld_b(offset1, offset0, 28 - ((sao_left_class) & 31)); + offset1 = __msa_sld_b(zero, offset1, 28 - ((sao_left_class) & 31)); + + if (!((sao_left_class > 12) & (sao_left_class < 29))) { + SWAP(offset0, offset1); + } + + for (h_cnt = height >> 2; h_cnt--;) { + for (w_cnt = 0; w_cnt < (width >> 4); w_cnt++) { + LD_UB4(src + w_cnt * 16, src_stride, src0, src1, src2, src3); + + mask0 = __msa_srli_b((v16i8) src0, 3); + mask1 = __msa_srli_b((v16i8) src1, 3); + mask2 = __msa_srli_b((v16i8) src2, 3); + mask3 = __msa_srli_b((v16i8) src3, 3); + + VSHF_B2_SB(offset0, offset1, offset0, offset1, mask0, mask1, + tmp0, tmp1); + VSHF_B2_SB(offset0, offset1, offset0, offset1, mask2, mask3, + tmp2, tmp3); + UNPCK_SB_SH(tmp0, temp0, temp1); + UNPCK_SB_SH(tmp1, temp2, temp3); + UNPCK_SB_SH(tmp2, temp4, temp5); + UNPCK_SB_SH(tmp3, temp6, temp7); + ILVRL_B2_SH(zero, src0, dst0, dst1); + ILVRL_B2_SH(zero, src1, dst2, dst3); + ILVRL_B2_SH(zero, src2, dst4, dst5); + ILVRL_B2_SH(zero, src3, dst6, dst7); + ADD4(dst0, temp0, dst1, temp1, dst2, temp2, dst3, temp3, + dst0, dst1, dst2, dst3); + ADD4(dst4, temp4, dst5, temp5, dst6, temp6, dst7, temp7, + dst4, dst5, dst6, dst7); + CLIP_SH4_0_255(dst0, dst1, dst2, dst3); + CLIP_SH4_0_255(dst4, dst5, dst6, dst7); + PCKEV_B4_SB(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + out0, out1, out2, out3); + ST_SB4(out0, out1, out2, out3, dst + w_cnt * 16, dst_stride); + } + + src += src_stride << 2; + dst += dst_stride << 2; + } +} + +static void hevc_sao_edge_filter_0degree_4width_msa(uint8_t *dst, + int32_t dst_stride, + uint8_t *src, + int32_t src_stride, + int16_t *sao_offset_val, + int32_t height) +{ + int32_t h_cnt; + uint32_t dst_val0, dst_val1; + v8i16 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0 }; + v16u8 const1 = (v16u8) __msa_ldi_b(1); + v16u8 cmp_minus10, diff_minus10, cmp_minus11, diff_minus11; + v16u8 src_minus10, src_minus11; + v16i8 zero = { 0 }; + v16i8 src_zero0, src_zero1, src_plus10, src_plus11, dst0; + v8i16 offset_mask0, offset_mask1; + v8i16 sao_offset, src00, src01; + + sao_offset = LD_SH(sao_offset_val); + src -= 1; + + for (h_cnt = (height >> 1); h_cnt--;) { + LD_UB2(src, src_stride, src_minus10, src_minus11); + src += (2 * src_stride); + + SLDI_B2_0_SB(src_minus10, src_minus11, src_zero0, src_zero1, 1); + SLDI_B2_0_SB(src_minus10, src_minus11, src_plus10, src_plus11, 2); + ILVR_B2_UB(src_plus10, src_minus10, src_plus11, src_minus11, + src_minus10, src_minus11); + ILVR_B2_SB(src_zero0, src_zero0, src_zero1, src_zero1, src_zero0, + src_zero1); + + cmp_minus10 = ((v16u8) src_zero0 == src_minus10); + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + cmp_minus10 = (src_minus10 < (v16u8) src_zero0); + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + + cmp_minus11 = ((v16u8) src_zero1 == src_minus11); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + cmp_minus11 = (src_minus11 < (v16u8) src_zero1); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + + offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 2); + offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + 2); + + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask0, + offset_mask0, offset_mask0, offset_mask0); + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask1, + offset_mask1, offset_mask1, offset_mask1); + ILVEV_B2_SH(src_zero0, zero, src_zero1, zero, src00, src01); + ADD2(offset_mask0, src00, offset_mask1, src01, offset_mask0, + offset_mask1); + CLIP_SH2_0_255(offset_mask0, offset_mask1); + + dst0 = __msa_pckev_b((v16i8) offset_mask1, (v16i8) offset_mask0); + dst_val0 = __msa_copy_u_w((v4i32) dst0, 0); + dst_val1 = __msa_copy_u_w((v4i32) dst0, 2); + SW(dst_val0, dst); + dst += dst_stride; + SW(dst_val1, dst); + dst += dst_stride; + } +} + +static void hevc_sao_edge_filter_0degree_8width_msa(uint8_t *dst, + int32_t dst_stride, + uint8_t *src, + int32_t src_stride, + int16_t *sao_offset_val, + int32_t height) +{ + uint8_t *src_minus1; + int32_t h_cnt; + uint64_t dst_val0, dst_val1; + v8i16 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0 }; + v16u8 const1 = (v16u8) __msa_ldi_b(1); + v16i8 dst0, dst1; + v16i8 zero = { 0 }; + v16u8 cmp_minus10, diff_minus10, cmp_minus11, diff_minus11; + v16u8 src_minus10, src_minus11; + v16i8 src_zero0, src_plus10, src_zero1, src_plus11; + v8i16 sao_offset, src00, offset_mask0, src01, offset_mask1; + + sao_offset = LD_SH(sao_offset_val); + + for (h_cnt = (height >> 1); h_cnt--;) { + src_minus1 = src - 1; + LD_UB2(src_minus1, src_stride, src_minus10, src_minus11); + + SLDI_B2_0_SB(src_minus10, src_minus11, src_zero0, src_zero1, 1); + SLDI_B2_0_SB(src_minus10, src_minus11, src_plus10, src_plus11, 2); + ILVR_B2_UB(src_plus10, src_minus10, src_plus11, src_minus11, + src_minus10, src_minus11); + ILVR_B2_SB(src_zero0, src_zero0, src_zero1, src_zero1, + src_zero0, src_zero1); + + cmp_minus10 = ((v16u8) src_zero0 == src_minus10); + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + cmp_minus10 = (src_minus10 < (v16u8) src_zero0); + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + + cmp_minus11 = ((v16u8) src_zero1 == src_minus11); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + cmp_minus11 = (src_minus11 < (v16u8) src_zero1); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + + offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 2); + offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + 2); + + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask0, + offset_mask0, offset_mask0, offset_mask0); + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask1, + offset_mask1, offset_mask1, offset_mask1); + ILVEV_B2_SH(src_zero0, zero, src_zero1, zero, src00, src01); + + ADD2(offset_mask0, src00, offset_mask1, src01, offset_mask0, + offset_mask1); + CLIP_SH2_0_255(offset_mask0, offset_mask1); + PCKEV_B2_SB(offset_mask0, offset_mask0, offset_mask1, offset_mask1, + dst0, dst1); + + dst_val0 = __msa_copy_u_d((v2i64) dst0, 0); + dst_val1 = __msa_copy_u_d((v2i64) dst1, 0); + SD(dst_val0, dst); + dst += dst_stride; + SD(dst_val1, dst); + dst += dst_stride; + src += (src_stride << 1); + } +} + +static void hevc_sao_edge_filter_0degree_16multiple_msa(uint8_t *dst, + int32_t dst_stride, + uint8_t *src, + int32_t src_stride, + int16_t *sao_offset_val, + int32_t width, + int32_t height) +{ + uint8_t *dst_ptr, *src_minus1; + int32_t h_cnt, v_cnt; + v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + v16u8 const1 = (v16u8) __msa_ldi_b(1); + v16i8 sao_offset; + v16u8 cmp_minus10, cmp_plus10, diff_minus10, diff_plus10, cmp_minus11; + v16u8 cmp_plus11, diff_minus11, diff_plus11, cmp_minus12, cmp_plus12; + v16u8 diff_minus12, diff_plus12, cmp_minus13, cmp_plus13, diff_minus13; + v16u8 diff_plus13; + v16u8 src10, src11, src12, src13, dst0, dst1, dst2, dst3; + v16u8 src_minus10, src_minus11, src_minus12, src_minus13; + v16i8 offset_mask0, offset_mask1, offset_mask2, offset_mask3; + v16i8 src_zero0, src_zero1, src_zero2, src_zero3; + v16i8 src_plus10, src_plus11, src_plus12, src_plus13; + v8i16 src0, src1, src2, src3, src4, src5, src6, src7; + v8i16 temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + + sao_offset = LD_SB(sao_offset_val); + sao_offset = __msa_pckev_b(sao_offset, sao_offset); + + for (h_cnt = (height >> 2); h_cnt--;) { + src_minus1 = src - 1; + LD_UB4(src_minus1, src_stride, + src_minus10, src_minus11, src_minus12, src_minus13); + + for (v_cnt = 0; v_cnt < (width >> 4); v_cnt++) { + src_minus1 += 16; + dst_ptr = dst + (v_cnt << 4); + LD_UB4(src_minus1, src_stride, src10, src11, src12, src13); + + SLDI_B2_SB(src10, src11, src_minus10, src_minus11, src_zero0, + src_zero1, 1); + SLDI_B2_SB(src12, src13, src_minus12, src_minus13, src_zero2, + src_zero3, 1); + SLDI_B2_SB(src10, src11, src_minus10, src_minus11, src_plus10, + src_plus11, 2); + SLDI_B2_SB(src12, src13, src_minus12, src_minus13, src_plus12, + src_plus13, 2); + + cmp_minus10 = ((v16u8) src_zero0 == src_minus10); + cmp_plus10 = ((v16u8) src_zero0 == (v16u8) src_plus10); + cmp_minus11 = ((v16u8) src_zero1 == src_minus11); + cmp_plus11 = ((v16u8) src_zero1 == (v16u8) src_plus11); + cmp_minus12 = ((v16u8) src_zero2 == src_minus12); + cmp_plus12 = ((v16u8) src_zero2 == (v16u8) src_plus12); + cmp_minus13 = ((v16u8) src_zero3 == src_minus13); + cmp_plus13 = ((v16u8) src_zero3 == (v16u8) src_plus13); + + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + diff_plus10 = __msa_nor_v(cmp_plus10, cmp_plus10); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + diff_plus11 = __msa_nor_v(cmp_plus11, cmp_plus11); + diff_minus12 = __msa_nor_v(cmp_minus12, cmp_minus12); + diff_plus12 = __msa_nor_v(cmp_plus12, cmp_plus12); + diff_minus13 = __msa_nor_v(cmp_minus13, cmp_minus13); + diff_plus13 = __msa_nor_v(cmp_plus13, cmp_plus13); + + cmp_minus10 = (src_minus10 < (v16u8) src_zero0); + cmp_plus10 = ((v16u8) src_plus10 < (v16u8) src_zero0); + cmp_minus11 = (src_minus11 < (v16u8) src_zero1); + cmp_plus11 = ((v16u8) src_plus11 < (v16u8) src_zero1); + cmp_minus12 = (src_minus12 < (v16u8) src_zero2); + cmp_plus12 = ((v16u8) src_plus12 < (v16u8) src_zero2); + cmp_minus13 = (src_minus13 < (v16u8) src_zero3); + cmp_plus13 = ((v16u8) src_plus13 < (v16u8) src_zero3); + + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + diff_plus10 = __msa_bmnz_v(diff_plus10, const1, cmp_plus10); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + diff_plus11 = __msa_bmnz_v(diff_plus11, const1, cmp_plus11); + diff_minus12 = __msa_bmnz_v(diff_minus12, const1, cmp_minus12); + diff_plus12 = __msa_bmnz_v(diff_plus12, const1, cmp_plus12); + diff_minus13 = __msa_bmnz_v(diff_minus13, const1, cmp_minus13); + diff_plus13 = __msa_bmnz_v(diff_plus13, const1, cmp_plus13); + + offset_mask0 = 2 + (v16i8) diff_minus10 + (v16i8) diff_plus10; + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask0, + offset_mask0, offset_mask0, offset_mask0); + offset_mask1 = 2 + (v16i8) diff_minus11 + (v16i8) diff_plus11; + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask1, + offset_mask1, offset_mask1, offset_mask1); + offset_mask2 = 2 + (v16i8) diff_minus12 + (v16i8) diff_plus12; + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask2, + offset_mask2, offset_mask2, offset_mask2); + offset_mask3 = 2 + (v16i8) diff_minus13 + (v16i8) diff_plus13; + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask3, + offset_mask3, offset_mask3, offset_mask3); + + UNPCK_UB_SH(src_zero0, src0, src1); + UNPCK_SB_SH(offset_mask0, temp0, temp1); + UNPCK_UB_SH(src_zero1, src2, src3); + UNPCK_SB_SH(offset_mask1, temp2, temp3); + UNPCK_UB_SH(src_zero2, src4, src5); + UNPCK_SB_SH(offset_mask2, temp4, temp5); + UNPCK_UB_SH(src_zero3, src6, src7); + UNPCK_SB_SH(offset_mask3, temp6, temp7); + ADD4(temp0, src0, temp1, src1, temp2, src2, temp3, src3, temp0, + temp1, temp2, temp3); + ADD4(temp4, src4, temp5, src5, temp6, src6, temp7, src7, temp4, + temp5, temp6, temp7); + CLIP_SH4_0_255(temp0, temp1, temp2, temp3); + CLIP_SH4_0_255(temp4, temp5, temp6, temp7); + PCKEV_B4_UB(temp1, temp0, temp3, temp2, temp5, temp4, temp7, temp6, + dst0, dst1, dst2, dst3); + + src_minus10 = src10; + ST_UB(dst0, dst_ptr); + src_minus11 = src11; + ST_UB(dst1, dst_ptr + dst_stride); + src_minus12 = src12; + ST_UB(dst2, dst_ptr + (dst_stride << 1)); + src_minus13 = src13; + ST_UB(dst3, dst_ptr + (dst_stride * 3)); + } + + src += (src_stride << 2); + dst += (dst_stride << 2); + } +} + +static void hevc_sao_edge_filter_90degree_4width_msa(uint8_t *dst, + int32_t dst_stride, + uint8_t *src, + int32_t src_stride, + int16_t *sao_offset_val, + int32_t height) +{ + int32_t h_cnt; + uint32_t dst_val0, dst_val1; + v8i16 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0 }; + v16u8 const1 = (v16u8) __msa_ldi_b(1); + v16i8 dst0; + v16i8 zero = { 0 }; + v16u8 cmp_minus10, diff_minus10, cmp_minus11, diff_minus11; + v16u8 src_minus10, src_minus11, src10, src11; + v16i8 src_zero0, src_zero1; + v8i16 sao_offset, src00, src01, offset_mask0, offset_mask1; + + sao_offset = LD_SH(sao_offset_val); + + LD_UB2(src - src_stride, src_stride, src_minus10, src_minus11); + + for (h_cnt = (height >> 1); h_cnt--;) { + LD_UB2(src + src_stride, src_stride, src10, src11); + + src_minus10 = (v16u8) __msa_ilvr_b((v16i8) src10, (v16i8) src_minus10); + src_zero0 = __msa_ilvr_b((v16i8) src_minus11, (v16i8) src_minus11); + src_minus11 = (v16u8) __msa_ilvr_b((v16i8) src11, (v16i8) src_minus11); + src_zero1 = __msa_ilvr_b((v16i8) src10, (v16i8) src10); + + cmp_minus10 = ((v16u8) src_zero0 == src_minus10); + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + cmp_minus10 = (src_minus10 < (v16u8) src_zero0); + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + + cmp_minus11 = ((v16u8) src_zero1 == src_minus11); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + cmp_minus11 = (src_minus11 < (v16u8) src_zero1); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + + offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 2); + offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + 2); + + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask0, + offset_mask0, offset_mask0, offset_mask0); + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask1, + offset_mask1, offset_mask1, offset_mask1); + ILVEV_B2_SH(src_zero0, zero, src_zero1, zero, src00, src01); + ADD2(offset_mask0, src00, offset_mask1, src01, offset_mask0, + offset_mask1); + CLIP_SH2_0_255(offset_mask0, offset_mask1); + dst0 = __msa_pckev_b((v16i8) offset_mask1, (v16i8) offset_mask0); + + src_minus10 = src10; + src_minus11 = src11; + + dst_val0 = __msa_copy_u_w((v4i32) dst0, 0); + dst_val1 = __msa_copy_u_w((v4i32) dst0, 2); + SW(dst_val0, dst); + dst += dst_stride; + SW(dst_val1, dst); + + dst += dst_stride; + src += (src_stride << 1); + } +} + +static void hevc_sao_edge_filter_90degree_8width_msa(uint8_t *dst, + int32_t dst_stride, + uint8_t *src, + int32_t src_stride, + int16_t *sao_offset_val, + int32_t height) +{ + int32_t h_cnt; + uint64_t dst_val0, dst_val1; + v8i16 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0 }; + v16u8 const1 = (v16u8) __msa_ldi_b(1); + v16i8 zero = { 0 }; + v16i8 src_zero0, src_zero1, dst0, dst1; + v16u8 cmp_minus10, diff_minus10, cmp_minus11, diff_minus11; + v16u8 src_minus10, src_minus11, src10, src11; + v8i16 sao_offset, src00, offset_mask0, src01, offset_mask1; + + sao_offset = LD_SH(sao_offset_val); + + LD_UB2(src - src_stride, src_stride, src_minus10, src_minus11); + + for (h_cnt = (height >> 1); h_cnt--;) { + LD_UB2(src + src_stride, src_stride, src10, src11); + + src_minus10 = (v16u8) __msa_ilvr_b((v16i8) src10, (v16i8) src_minus10); + src_zero0 = __msa_ilvr_b((v16i8) src_minus11, (v16i8) src_minus11); + src_minus11 = (v16u8) __msa_ilvr_b((v16i8) src11, (v16i8) src_minus11); + src_zero1 = __msa_ilvr_b((v16i8) src10, (v16i8) src10); + + cmp_minus10 = ((v16u8) src_zero0 == src_minus10); + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + cmp_minus10 = (src_minus10 < (v16u8) src_zero0); + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + + cmp_minus11 = ((v16u8) src_zero1 == src_minus11); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + cmp_minus11 = (src_minus11 < (v16u8) src_zero1); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + + offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 2); + offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + 2); + + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask0, + offset_mask0, offset_mask0, offset_mask0); + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask1, + offset_mask1, offset_mask1, offset_mask1); + ILVEV_B2_SH(src_zero0, zero, src_zero1, zero, src00, src01); + ADD2(offset_mask0, src00, offset_mask1, src01, offset_mask0, + offset_mask1); + CLIP_SH2_0_255(offset_mask0, offset_mask1); + PCKEV_B2_SB(offset_mask0, offset_mask0, offset_mask1, offset_mask1, + dst0, dst1); + + src_minus10 = src10; + src_minus11 = src11; + + dst_val0 = __msa_copy_u_d((v2i64) dst0, 0); + dst_val1 = __msa_copy_u_d((v2i64) dst1, 0); + SD(dst_val0, dst); + dst += dst_stride; + SD(dst_val1, dst); + dst += dst_stride; + src += (src_stride << 1); + } +} + +static void hevc_sao_edge_filter_90degree_16multiple_msa(uint8_t *dst, + int32_t dst_stride, + uint8_t *src, + int32_t src_stride, + int16_t * + sao_offset_val, + int32_t width, + int32_t height) +{ + uint8_t *src_orig = src; + uint8_t *dst_orig = dst; + int32_t h_cnt, v_cnt; + v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + v16u8 const1 = (v16u8) __msa_ldi_b(1); + v16u8 cmp_minus10, cmp_plus10, diff_minus10, diff_plus10, cmp_minus11; + v16u8 cmp_plus11, diff_minus11, diff_plus11, cmp_minus12, cmp_plus12; + v16u8 diff_minus12, diff_plus12, cmp_minus13, cmp_plus13, diff_minus13; + v16u8 diff_plus13; + v16u8 src10, src_minus10, dst0, src11, src_minus11, dst1; + v16u8 src12, dst2, src13, dst3; + v16i8 offset_mask0, offset_mask1, offset_mask2, offset_mask3, sao_offset; + v8i16 src0, src1, src2, src3, src4, src5, src6, src7; + v8i16 temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + + sao_offset = LD_SB(sao_offset_val); + sao_offset = __msa_pckev_b(sao_offset, sao_offset); + + for (v_cnt = 0; v_cnt < (width >> 4); v_cnt++) { + src = src_orig + (v_cnt << 4); + dst = dst_orig + (v_cnt << 4); + + LD_UB2(src - src_stride, src_stride, src_minus10, src_minus11); + + for (h_cnt = (height >> 2); h_cnt--;) { + LD_UB4(src + src_stride, src_stride, src10, src11, src12, src13); + + cmp_minus10 = (src_minus11 == src_minus10); + cmp_plus10 = (src_minus11 == src10); + cmp_minus11 = (src10 == src_minus11); + cmp_plus11 = (src10 == src11); + cmp_minus12 = (src11 == src10); + cmp_plus12 = (src11 == src12); + cmp_minus13 = (src12 == src11); + cmp_plus13 = (src12 == src13); + + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + diff_plus10 = __msa_nor_v(cmp_plus10, cmp_plus10); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + diff_plus11 = __msa_nor_v(cmp_plus11, cmp_plus11); + diff_minus12 = __msa_nor_v(cmp_minus12, cmp_minus12); + diff_plus12 = __msa_nor_v(cmp_plus12, cmp_plus12); + diff_minus13 = __msa_nor_v(cmp_minus13, cmp_minus13); + diff_plus13 = __msa_nor_v(cmp_plus13, cmp_plus13); + + cmp_minus10 = (src_minus10 < src_minus11); + cmp_plus10 = (src10 < src_minus11); + cmp_minus11 = (src_minus11 < src10); + cmp_plus11 = (src11 < src10); + cmp_minus12 = (src10 < src11); + cmp_plus12 = (src12 < src11); + cmp_minus13 = (src11 < src12); + cmp_plus13 = (src13 < src12); + + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + diff_plus10 = __msa_bmnz_v(diff_plus10, const1, cmp_plus10); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + diff_plus11 = __msa_bmnz_v(diff_plus11, const1, cmp_plus11); + diff_minus12 = __msa_bmnz_v(diff_minus12, const1, cmp_minus12); + diff_plus12 = __msa_bmnz_v(diff_plus12, const1, cmp_plus12); + diff_minus13 = __msa_bmnz_v(diff_minus13, const1, cmp_minus13); + diff_plus13 = __msa_bmnz_v(diff_plus13, const1, cmp_plus13); + + offset_mask0 = 2 + (v16i8) diff_minus10 + (v16i8) diff_plus10; + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, + offset_mask0, offset_mask0, offset_mask0, offset_mask0); + offset_mask1 = 2 + (v16i8) diff_minus11 + (v16i8) diff_plus11; + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, + offset_mask1, offset_mask1, offset_mask1, offset_mask1); + offset_mask2 = 2 + (v16i8) diff_minus12 + (v16i8) diff_plus12; + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, + offset_mask2, offset_mask2, offset_mask2, offset_mask2); + offset_mask3 = 2 + (v16i8) diff_minus13 + (v16i8) diff_plus13; + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, + offset_mask3, offset_mask3, offset_mask3, offset_mask3); + + UNPCK_UB_SH(src_minus11, src0, src1); + UNPCK_SB_SH(offset_mask0, temp0, temp1); + UNPCK_UB_SH(src10, src2, src3); + UNPCK_SB_SH(offset_mask1, temp2, temp3); + UNPCK_UB_SH(src11, src4, src5); + UNPCK_SB_SH(offset_mask2, temp4, temp5); + UNPCK_UB_SH(src12, src6, src7); + UNPCK_SB_SH(offset_mask3, temp6, temp7); + ADD4(temp0, src0, temp1, src1, temp2, src2, temp3, src3, temp0, + temp1, temp2, temp3); + ADD4(temp4, src4, temp5, src5, temp6, src6, temp7, src7, temp4, + temp5, temp6, temp7); + CLIP_SH4_0_255(temp0, temp1, temp2, temp3); + CLIP_SH4_0_255(temp4, temp5, temp6, temp7); + PCKEV_B4_UB(temp1, temp0, temp3, temp2, temp5, temp4, temp7, temp6, + dst0, dst1, dst2, dst3); + + src_minus10 = src12; + src_minus11 = src13; + + ST_UB4(dst0, dst1, dst2, dst3, dst, dst_stride); + + src += (src_stride << 2); + dst += (dst_stride << 2); + } + } +} + +static void hevc_sao_edge_filter_45degree_4width_msa(uint8_t *dst, + int32_t dst_stride, + uint8_t *src, + int32_t src_stride, + int16_t *sao_offset_val, + int32_t height) +{ + uint8_t *src_orig; + int32_t h_cnt; + uint32_t dst_val0, dst_val1; + v8i16 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0 }; + v16u8 const1 = (v16u8) __msa_ldi_b(1); + v16i8 zero = { 0 }; + v16u8 cmp_minus10, diff_minus10, src_minus10, cmp_minus11, diff_minus11; + v16u8 src_minus11, src10, src11; + v16i8 src_plus0, src_zero0, src_plus1, src_zero1, dst0; + v8i16 sao_offset, src00, src01, offset_mask0, offset_mask1; + + sao_offset = LD_SH(sao_offset_val); + + src_orig = src - 1; + LD_UB2(src_orig - src_stride, src_stride, src_minus10, src_minus11); + + for (h_cnt = (height >> 1); h_cnt--;) { + LD_UB2(src_orig + src_stride, src_stride, src10, src11); + + SLDI_B2_0_SB(src_minus11, src10, src_zero0, src_zero1, 1); + SLDI_B2_0_SB(src10, src11, src_plus0, src_plus1, 2); + + ILVR_B2_UB(src_plus0, src_minus10, src_plus1, src_minus11, src_minus10, + src_minus11); + ILVR_B2_SB(src_zero0, src_zero0, src_zero1, src_zero1, src_zero0, + src_zero1); + + cmp_minus10 = ((v16u8) src_zero0 == src_minus10); + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + cmp_minus10 = (src_minus10 < (v16u8) src_zero0); + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + + cmp_minus11 = ((v16u8) src_zero1 == src_minus11); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + cmp_minus11 = (src_minus11 < (v16u8) src_zero1); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + + offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 2); + offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + 2); + + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask0, + offset_mask0, offset_mask0, offset_mask0); + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask1, + offset_mask1, offset_mask1, offset_mask1); + ILVEV_B2_SH(src_zero0, zero, src_zero1, zero, src00, src01); + ADD2(offset_mask0, src00, offset_mask1, src01, offset_mask0, + offset_mask1); + CLIP_SH2_0_255(offset_mask0, offset_mask1); + + dst0 = __msa_pckev_b((v16i8) offset_mask1, (v16i8) offset_mask0); + + src_minus10 = src10; + src_minus11 = src11; + + dst_val0 = __msa_copy_u_w((v4i32) dst0, 0); + dst_val1 = __msa_copy_u_w((v4i32) dst0, 2); + SW(dst_val0, dst); + dst += dst_stride; + SW(dst_val1, dst); + + dst += dst_stride; + src_orig += (src_stride << 1); + } +} + +static void hevc_sao_edge_filter_45degree_8width_msa(uint8_t *dst, + int32_t dst_stride, + uint8_t *src, + int32_t src_stride, + int16_t *sao_offset_val, + int32_t height) +{ + uint8_t *src_orig; + int32_t h_cnt; + uint64_t dst_val0, dst_val1; + v8i16 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0 }; + v16u8 const1 = (v16u8) __msa_ldi_b(1); + v16i8 zero = { 0 }; + v16u8 cmp_minus10, diff_minus10, cmp_minus11, diff_minus11; + v16u8 src_minus10, src10, src_minus11, src11; + v16i8 src_zero0, src_plus10, src_zero1, src_plus11, dst0, dst1; + v8i16 sao_offset, src00, offset_mask0, src01, offset_mask1; + + sao_offset = LD_SH(sao_offset_val); + src_orig = src - 1; + + LD_UB2(src_orig - src_stride, src_stride, src_minus10, src_minus11); + + for (h_cnt = (height >> 1); h_cnt--;) { + LD_UB2(src_orig + src_stride, src_stride, src10, src11); + + SLDI_B2_0_SB(src_minus11, src10, src_zero0, src_zero1, 1); + SLDI_B2_0_SB(src10, src11, src_plus10, src_plus11, 2); + + ILVR_B2_UB(src_plus10, src_minus10, src_plus11, src_minus11, + src_minus10, src_minus11); + ILVR_B2_SB(src_zero0, src_zero0, src_zero1, src_zero1, + src_zero0, src_zero1); + + cmp_minus10 = ((v16u8) src_zero0 == src_minus10); + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + cmp_minus10 = (src_minus10 < (v16u8) src_zero0); + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + + cmp_minus11 = ((v16u8) src_zero1 == src_minus11); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + cmp_minus11 = (src_minus11 < (v16u8) src_zero1); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + + offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 2); + offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + 2); + + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask0, + offset_mask0, offset_mask0, offset_mask0); + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask1, + offset_mask1, offset_mask1, offset_mask1); + ILVEV_B2_SH(src_zero0, zero, src_zero1, zero, src00, src01); + ADD2(offset_mask0, src00, offset_mask1, src01, offset_mask0, + offset_mask1); + CLIP_SH2_0_255(offset_mask0, offset_mask1); + PCKEV_B2_SB(offset_mask0, offset_mask0, offset_mask1, offset_mask1, + dst0, dst1); + + src_minus10 = src10; + src_minus11 = src11; + + dst_val0 = __msa_copy_u_d((v2i64) dst0, 0); + dst_val1 = __msa_copy_u_d((v2i64) dst1, 0); + SD(dst_val0, dst); + dst += dst_stride; + SD(dst_val1, dst); + + dst += dst_stride; + src_orig += (src_stride << 1); + } +} + +static void hevc_sao_edge_filter_45degree_16multiple_msa(uint8_t *dst, + int32_t dst_stride, + uint8_t *src, + int32_t src_stride, + int16_t * + sao_offset_val, + int32_t width, + int32_t height) +{ + uint8_t *src_orig = src; + uint8_t *dst_orig = dst; + int32_t h_cnt, v_cnt; + v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + v16u8 const1 = (v16u8) __msa_ldi_b(1); + v16u8 cmp_minus10, cmp_plus10, diff_minus10, diff_plus10, cmp_minus11; + v16u8 cmp_plus11, diff_minus11, diff_plus11, cmp_minus12, cmp_plus12; + v16u8 diff_minus12, diff_plus12, cmp_minus13, cmp_plus13, diff_minus13; + v16u8 diff_plus13, src_minus14, src_plus13; + v16i8 offset_mask0, offset_mask1, offset_mask2, offset_mask3; + v16u8 src10, src_minus10, dst0, src11, src_minus11, dst1; + v16u8 src12, src_minus12, dst2, src13, src_minus13, dst3; + v16i8 src_zero0, src_plus10, src_zero1, src_plus11, src_zero2, src_plus12; + v16i8 src_zero3, sao_offset; + v8i16 src0, src1, src2, src3, src4, src5, src6, src7; + v8i16 temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + + sao_offset = LD_SB(sao_offset_val); + sao_offset = __msa_pckev_b(sao_offset, sao_offset); + + for (h_cnt = (height >> 2); h_cnt--;) { + src_orig = src - 1; + dst_orig = dst; + LD_UB4(src_orig, src_stride, + src_minus11, src_minus12, src_minus13, src_minus14); + + for (v_cnt = 0; v_cnt < (width >> 4); v_cnt++) { + src_minus10 = LD_UB(src_orig - src_stride); + LD_UB4(src_orig + 16, src_stride, src10, src11, src12, src13); + src_plus13 = LD_UB(src + 1 + (v_cnt << 4) + (src_stride << 2)); + src_orig += 16; + + SLDI_B2_SB(src10, src11, src_minus11, src_minus12, src_zero0, + src_zero1, 1); + SLDI_B2_SB(src12, src13, src_minus13, src_minus14, src_zero2, + src_zero3, 1); + SLDI_B2_SB(src11, src12, src_minus12, src_minus13, src_plus10, + src_plus11, 2); + + src_plus12 = __msa_sldi_b((v16i8) src13, (v16i8) src_minus14, 2); + + cmp_minus10 = ((v16u8) src_zero0 == src_minus10); + cmp_plus10 = ((v16u8) src_zero0 == (v16u8) src_plus10); + cmp_minus11 = ((v16u8) src_zero1 == src_minus11); + cmp_plus11 = ((v16u8) src_zero1 == (v16u8) src_plus11); + cmp_minus12 = ((v16u8) src_zero2 == src_minus12); + cmp_plus12 = ((v16u8) src_zero2 == (v16u8) src_plus12); + cmp_minus13 = ((v16u8) src_zero3 == src_minus13); + cmp_plus13 = ((v16u8) src_zero3 == src_plus13); + + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + diff_plus10 = __msa_nor_v(cmp_plus10, cmp_plus10); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + diff_plus11 = __msa_nor_v(cmp_plus11, cmp_plus11); + diff_minus12 = __msa_nor_v(cmp_minus12, cmp_minus12); + diff_plus12 = __msa_nor_v(cmp_plus12, cmp_plus12); + diff_minus13 = __msa_nor_v(cmp_minus13, cmp_minus13); + diff_plus13 = __msa_nor_v(cmp_plus13, cmp_plus13); + + cmp_minus10 = (src_minus10 < (v16u8) src_zero0); + cmp_plus10 = ((v16u8) src_plus10 < (v16u8) src_zero0); + cmp_minus11 = (src_minus11 < (v16u8) src_zero1); + cmp_plus11 = ((v16u8) src_plus11 < (v16u8) src_zero1); + cmp_minus12 = (src_minus12 < (v16u8) src_zero2); + cmp_plus12 = ((v16u8) src_plus12 < (v16u8) src_zero2); + cmp_minus13 = (src_minus13 < (v16u8) src_zero3); + cmp_plus13 = (src_plus13 < (v16u8) src_zero3); + + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + diff_plus10 = __msa_bmnz_v(diff_plus10, const1, cmp_plus10); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + diff_plus11 = __msa_bmnz_v(diff_plus11, const1, cmp_plus11); + diff_minus12 = __msa_bmnz_v(diff_minus12, const1, cmp_minus12); + diff_plus12 = __msa_bmnz_v(diff_plus12, const1, cmp_plus12); + diff_minus13 = __msa_bmnz_v(diff_minus13, const1, cmp_minus13); + diff_plus13 = __msa_bmnz_v(diff_plus13, const1, cmp_plus13); + + offset_mask0 = 2 + (v16i8) diff_minus10 + (v16i8) diff_plus10; + offset_mask1 = 2 + (v16i8) diff_minus11 + (v16i8) diff_plus11; + offset_mask2 = 2 + (v16i8) diff_minus12 + (v16i8) diff_plus12; + offset_mask3 = 2 + (v16i8) diff_minus13 + (v16i8) diff_plus13; + + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, + offset_mask0, offset_mask0, offset_mask0, offset_mask0); + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, + offset_mask1, offset_mask1, offset_mask1, offset_mask1); + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, + offset_mask2, offset_mask2, offset_mask2, offset_mask2); + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, + offset_mask3, offset_mask3, offset_mask3, offset_mask3); + + UNPCK_UB_SH(src_zero0, src0, src1); + UNPCK_SB_SH(offset_mask0, temp0, temp1); + UNPCK_UB_SH(src_zero1, src2, src3); + UNPCK_SB_SH(offset_mask1, temp2, temp3); + UNPCK_UB_SH(src_zero2, src4, src5); + UNPCK_SB_SH(offset_mask2, temp4, temp5); + UNPCK_UB_SH(src_zero3, src6, src7); + UNPCK_SB_SH(offset_mask3, temp6, temp7); + ADD4(temp0, src0, temp1, src1, temp2, src2, temp3, src3, temp0, + temp1, temp2, temp3); + ADD4(temp4, src4, temp5, src5, temp6, src6, temp7, src7, temp4, + temp5, temp6, temp7); + CLIP_SH4_0_255(temp0, temp1, temp2, temp3); + CLIP_SH4_0_255(temp4, temp5, temp6, temp7); + PCKEV_B4_UB(temp1, temp0, temp3, temp2, temp5, temp4, + temp7, temp6, dst0, dst1, dst2, dst3); + + src_minus11 = src10; + src_minus12 = src11; + src_minus13 = src12; + src_minus14 = src13; + + ST_UB4(dst0, dst1, dst2, dst3, dst_orig, dst_stride); + dst_orig += 16; + } + + src += (src_stride << 2); + dst += (dst_stride << 2); + } +} + +static void hevc_sao_edge_filter_135degree_4width_msa(uint8_t *dst, + int32_t dst_stride, + uint8_t *src, + int32_t src_stride, + int16_t *sao_offset_val, + int32_t height) +{ + uint8_t *src_orig; + int32_t h_cnt; + uint32_t dst_val0, dst_val1; + v8i16 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0 }; + v16u8 const1 = (v16u8) __msa_ldi_b(1); + v16i8 zero = { 0 }; + v16i8 src_zero0, src_zero1, dst0; + v16u8 cmp_minus10, diff_minus10, cmp_minus11, diff_minus11; + v16u8 src_minus10, src10, src_minus11, src11; + v8i16 offset_mask0, offset_mask1, sao_offset, src00, src01; + + sao_offset = LD_SH(sao_offset_val); + src_orig = src - 1; + + LD_UB2(src_orig - src_stride, src_stride, src_minus10, src_minus11); + + for (h_cnt = (height >> 1); h_cnt--;) { + LD_UB2(src_orig + src_stride, src_stride, src10, src11); + + SLDI_B2_0_SB(src_minus11, src10, src_zero0, src_zero1, 1); + SLDI_B2_0_UB(src_minus10, src_minus11, src_minus10, src_minus11, 2); + + ILVR_B2_UB(src10, src_minus10, src11, src_minus11, src_minus10, + src_minus11); + ILVR_B2_SB(src_zero0, src_zero0, src_zero1, src_zero1, src_zero0, + src_zero1); + + cmp_minus10 = ((v16u8) src_zero0 == src_minus10); + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + cmp_minus10 = (src_minus10 < (v16u8) src_zero0); + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + + cmp_minus11 = ((v16u8) src_zero1 == src_minus11); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + cmp_minus11 = (src_minus11 < (v16u8) src_zero1); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + + offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 2); + offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + 2); + + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask0, + offset_mask0, offset_mask0, offset_mask0); + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask1, + offset_mask1, offset_mask1, offset_mask1); + ILVEV_B2_SH(src_zero0, zero, src_zero1, zero, src00, src01); + ADD2(offset_mask0, src00, offset_mask1, src01, offset_mask0, + offset_mask1); + CLIP_SH2_0_255(offset_mask0, offset_mask1); + dst0 = __msa_pckev_b((v16i8) offset_mask1, (v16i8) offset_mask0); + + src_minus10 = src10; + src_minus11 = src11; + + dst_val0 = __msa_copy_u_w((v4i32) dst0, 0); + dst_val1 = __msa_copy_u_w((v4i32) dst0, 2); + + SW(dst_val0, dst); + dst += dst_stride; + SW(dst_val1, dst); + + dst += dst_stride; + src_orig += (src_stride << 1); + } +} + +static void hevc_sao_edge_filter_135degree_8width_msa(uint8_t *dst, + int32_t dst_stride, + uint8_t *src, + int32_t src_stride, + int16_t *sao_offset_val, + int32_t height) +{ + uint8_t *src_orig; + int32_t h_cnt; + uint64_t dst_val0, dst_val1; + v8i16 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0 }; + v16u8 const1 = (v16u8) __msa_ldi_b(1); + v16i8 zero = { 0 }; + v16i8 src_zero0, src_zero1, dst0, dst1; + v16u8 cmp_minus10, diff_minus10, cmp_minus11, diff_minus11; + v16u8 src_minus10, src10, src_minus11, src11; + v8i16 sao_offset, src00, offset_mask0, src01, offset_mask1; + + sao_offset = LD_SH(sao_offset_val); + src_orig = src - 1; + + LD_UB2(src_orig - src_stride, src_stride, src_minus10, src_minus11); + + for (h_cnt = (height >> 1); h_cnt--;) { + LD_UB2(src_orig + src_stride, src_stride, src10, src11); + + SLDI_B2_0_SB(src_minus11, src10, src_zero0, src_zero1, 1); + SLDI_B2_0_UB(src_minus10, src_minus11, src_minus10, src_minus11, 2); + ILVR_B2_UB(src10, src_minus10, src11, src_minus11, src_minus10, + src_minus11); + ILVR_B2_SB(src_zero0, src_zero0, src_zero1, src_zero1, src_zero0, + src_zero1); + + cmp_minus10 = ((v16u8) src_zero0 == src_minus10); + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + cmp_minus10 = (src_minus10 < (v16u8) src_zero0); + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + + cmp_minus11 = ((v16u8) src_zero1 == src_minus11); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + cmp_minus11 = (src_minus11 < (v16u8) src_zero1); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + + offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 2); + offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + 2); + + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask0, + offset_mask0, offset_mask0, offset_mask0); + VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask1, + offset_mask1, offset_mask1, offset_mask1); + ILVEV_B2_SH(src_zero0, zero, src_zero1, zero, src00, src01); + ADD2(offset_mask0, src00, offset_mask1, src01, offset_mask0, + offset_mask1); + CLIP_SH2_0_255(offset_mask0, offset_mask1); + PCKEV_B2_SB(offset_mask0, offset_mask0, offset_mask1, offset_mask1, + dst0, dst1); + + src_minus10 = src10; + src_minus11 = src11; + + dst_val0 = __msa_copy_u_d((v2i64) dst0, 0); + dst_val1 = __msa_copy_u_d((v2i64) dst1, 0); + + SD(dst_val0, dst); + dst += dst_stride; + SD(dst_val1, dst); + dst += dst_stride; + + src_orig += (src_stride << 1); + } +} + +static void hevc_sao_edge_filter_135degree_16multiple_msa(uint8_t *dst, + int32_t dst_stride, + uint8_t *src, + int32_t src_stride, + int16_t * + sao_offset_val, + int32_t width, + int32_t height) +{ + uint8_t *src_orig, *dst_orig; + int32_t h_cnt, v_cnt; + v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + v16u8 const1 = (v16u8) __msa_ldi_b(1); + v16u8 dst0, dst1, dst2, dst3; + v16u8 cmp_minus10, cmp_minus11, cmp_minus12, cmp_minus13, cmp_plus10; + v16u8 cmp_plus11, cmp_plus12, cmp_plus13, diff_minus10, diff_minus11; + v16u8 diff_minus12, diff_minus13, diff_plus10, diff_plus11, diff_plus12; + v16u8 diff_plus13, src10, src11, src12, src13, src_minus10, src_minus11; + v16u8 src_plus10, src_plus11, src_plus12, src_plus13; + v16i8 src_minus12, src_minus13, src_zero0, src_zero1, src_zero2, src_zero3; + v16i8 offset_mask0, offset_mask1, offset_mask2, offset_mask3, sao_offset; + v8i16 src0, src1, src2, src3, src4, src5, src6, src7; + v8i16 temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + + sao_offset = LD_SB(sao_offset_val); + sao_offset = __msa_pckev_b(sao_offset, sao_offset); + + for (h_cnt = (height >> 2); h_cnt--;) { + src_orig = src - 1; + dst_orig = dst; + + LD_UB4(src_orig, src_stride, + src_minus11, src_plus10, src_plus11, src_plus12); + + for (v_cnt = 0; v_cnt < (width >> 4); v_cnt++) { + src_minus10 = LD_UB(src_orig + 2 - src_stride); + LD_UB4(src_orig + 16, src_stride, src10, src11, src12, src13); + src_plus13 = LD_UB(src_orig + (src_stride << 2)); + src_orig += 16; + + src_zero0 = __msa_sldi_b((v16i8) src10, (v16i8) src_minus11, 1); + cmp_minus10 = ((v16u8) src_zero0 == src_minus10); + cmp_plus10 = ((v16u8) src_zero0 == src_plus10); + + src_zero1 = __msa_sldi_b((v16i8) src11, (v16i8) src_plus10, 1); + src_minus11 = (v16u8) __msa_sldi_b((v16i8) src10, + (v16i8) src_minus11, 2); + cmp_minus11 = ((v16u8) src_zero1 == src_minus11); + cmp_plus11 = ((v16u8) src_zero1 == src_plus11); + + src_zero2 = __msa_sldi_b((v16i8) src12, (v16i8) src_plus11, 1); + src_minus12 = __msa_sldi_b((v16i8) src11, (v16i8) src_plus10, 2); + cmp_minus12 = ((v16u8) src_zero2 == (v16u8) src_minus12); + cmp_plus12 = ((v16u8) src_zero2 == src_plus12); + + src_zero3 = __msa_sldi_b((v16i8) src13, (v16i8) src_plus12, 1); + src_minus13 = __msa_sldi_b((v16i8) src12, (v16i8) src_plus11, 2); + cmp_minus13 = ((v16u8) src_zero3 == (v16u8) src_minus13); + cmp_plus13 = ((v16u8) src_zero3 == src_plus13); + + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + diff_plus10 = __msa_nor_v(cmp_plus10, cmp_plus10); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + diff_plus11 = __msa_nor_v(cmp_plus11, cmp_plus11); + diff_minus12 = __msa_nor_v(cmp_minus12, cmp_minus12); + diff_plus12 = __msa_nor_v(cmp_plus12, cmp_plus12); + diff_minus13 = __msa_nor_v(cmp_minus13, cmp_minus13); + diff_plus13 = __msa_nor_v(cmp_plus13, cmp_plus13); + + cmp_minus10 = (src_minus10 < (v16u8) src_zero0); + cmp_plus10 = (src_plus10 < (v16u8) src_zero0); + cmp_minus11 = (src_minus11 < (v16u8) src_zero1); + cmp_plus11 = (src_plus11 < (v16u8) src_zero1); + cmp_minus12 = ((v16u8) src_minus12 < (v16u8) src_zero2); + cmp_plus12 = (src_plus12 < (v16u8) src_zero2); + cmp_minus13 = ((v16u8) src_minus13 < (v16u8) src_zero3); + cmp_plus13 = (src_plus13 < (v16u8) src_zero3); + + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + diff_plus10 = __msa_bmnz_v(diff_plus10, const1, cmp_plus10); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + diff_plus11 = __msa_bmnz_v(diff_plus11, const1, cmp_plus11); + diff_minus12 = __msa_bmnz_v(diff_minus12, const1, cmp_minus12); + diff_plus12 = __msa_bmnz_v(diff_plus12, const1, cmp_plus12); + diff_minus13 = __msa_bmnz_v(diff_minus13, const1, cmp_minus13); + diff_plus13 = __msa_bmnz_v(diff_plus13, const1, cmp_plus13); + + offset_mask0 = 2 + (v16i8) diff_minus10 + (v16i8) diff_plus10; + offset_mask1 = 2 + (v16i8) diff_minus11 + (v16i8) diff_plus11; + offset_mask2 = 2 + (v16i8) diff_minus12 + (v16i8) diff_plus12; + offset_mask3 = 2 + (v16i8) diff_minus13 + (v16i8) diff_plus13; + + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, + offset_mask0, offset_mask0, offset_mask0, offset_mask0); + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, + offset_mask1, offset_mask1, offset_mask1, offset_mask1); + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, + offset_mask2, offset_mask2, offset_mask2, offset_mask2); + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, + offset_mask3, offset_mask3, offset_mask3, offset_mask3); + + UNPCK_UB_SH(src_zero0, src0, src1); + UNPCK_SB_SH(offset_mask0, temp0, temp1); + UNPCK_UB_SH(src_zero1, src2, src3); + UNPCK_SB_SH(offset_mask1, temp2, temp3); + UNPCK_UB_SH(src_zero2, src4, src5); + UNPCK_SB_SH(offset_mask2, temp4, temp5); + UNPCK_UB_SH(src_zero3, src6, src7); + UNPCK_SB_SH(offset_mask3, temp6, temp7); + + ADD4(temp0, src0, temp1, src1, temp2, src2, temp3, src3, temp0, + temp1, temp2, temp3); + ADD4(temp4, src4, temp5, src5, temp6, src6, temp7, src7, temp4, + temp5, temp6, temp7); + CLIP_SH4_0_255(temp0, temp1, temp2, temp3); + CLIP_SH4_0_255(temp4, temp5, temp6, temp7); + PCKEV_B4_UB(temp1, temp0, temp3, temp2, temp5, temp4, temp7, temp6, + dst0, dst1, dst2, dst3); + + src_minus11 = src10; + src_plus10 = src11; + src_plus11 = src12; + src_plus12 = src13; + + ST_UB4(dst0, dst1, dst2, dst3, dst_orig, dst_stride); + dst_orig += 16; + } + + src += (src_stride << 2); + dst += (dst_stride << 2); + } +} + +void ff_hevc_loop_filter_luma_h_8_msa(uint8_t *src, + ptrdiff_t src_stride, + int32_t beta, int32_t *tc, + uint8_t *no_p, uint8_t *no_q) +{ + hevc_loopfilter_luma_hor_msa(src, src_stride, beta, tc, no_p, no_q); +} + +void ff_hevc_loop_filter_luma_v_8_msa(uint8_t *src, + ptrdiff_t src_stride, + int32_t beta, int32_t *tc, + uint8_t *no_p, uint8_t *no_q) +{ + hevc_loopfilter_luma_ver_msa(src, src_stride, beta, tc, no_p, no_q); +} + +void ff_hevc_loop_filter_chroma_h_8_msa(uint8_t *src, + ptrdiff_t src_stride, + int32_t *tc, uint8_t *no_p, + uint8_t *no_q) +{ + hevc_loopfilter_chroma_hor_msa(src, src_stride, tc, no_p, no_q); +} + +void ff_hevc_loop_filter_chroma_v_8_msa(uint8_t *src, + ptrdiff_t src_stride, + int32_t *tc, uint8_t *no_p, + uint8_t *no_q) +{ + hevc_loopfilter_chroma_ver_msa(src, src_stride, tc, no_p, no_q); +} + +void ff_hevc_sao_band_filter_0_8_msa(uint8_t *dst, uint8_t *src, + ptrdiff_t stride_dst, ptrdiff_t stride_src, + int16_t *sao_offset_val, int sao_left_class, + int width, int height) +{ + if (width >> 4) { + hevc_sao_band_filter_16multiple_msa(dst, stride_dst, src, stride_src, + sao_left_class, sao_offset_val, + width - (width % 16), height); + dst += width - (width % 16); + src += width - (width % 16); + width %= 16; + } + + if (width >> 3) { + hevc_sao_band_filter_8width_msa(dst, stride_dst, src, stride_src, + sao_left_class, sao_offset_val, height); + dst += 8; + src += 8; + width %= 8; + } + + if (width) { + hevc_sao_band_filter_4width_msa(dst, stride_dst, src, stride_src, + sao_left_class, sao_offset_val, height); + } +} + +void ff_hevc_sao_edge_filter_8_msa(uint8_t *dst, uint8_t *src, + ptrdiff_t stride_dst, + int16_t *sao_offset_val, + int eo, int width, int height) +{ + ptrdiff_t stride_src = (2 * 64 + 32) / sizeof(uint8_t); + + switch (eo) { + case 0: + if (width >> 4) { + hevc_sao_edge_filter_0degree_16multiple_msa(dst, stride_dst, + src, stride_src, + sao_offset_val, + width - (width % 16), + height); + dst += width - (width % 16); + src += width - (width % 16); + width %= 16; + } + + if (width >> 3) { + hevc_sao_edge_filter_0degree_8width_msa(dst, stride_dst, + src, stride_src, + sao_offset_val, height); + dst += 8; + src += 8; + width %= 8; + } + + if (width) { + hevc_sao_edge_filter_0degree_4width_msa(dst, stride_dst, + src, stride_src, + sao_offset_val, height); + } + break; + + case 1: + if (width >> 4) { + hevc_sao_edge_filter_90degree_16multiple_msa(dst, stride_dst, + src, stride_src, + sao_offset_val, + width - (width % 16), + height); + dst += width - (width % 16); + src += width - (width % 16); + width %= 16; + } + + if (width >> 3) { + hevc_sao_edge_filter_90degree_8width_msa(dst, stride_dst, + src, stride_src, + sao_offset_val, height); + dst += 8; + src += 8; + width %= 8; + } + + if (width) { + hevc_sao_edge_filter_90degree_4width_msa(dst, stride_dst, + src, stride_src, + sao_offset_val, height); + } + break; + + case 2: + if (width >> 4) { + hevc_sao_edge_filter_45degree_16multiple_msa(dst, stride_dst, + src, stride_src, + sao_offset_val, + width - (width % 16), + height); + dst += width - (width % 16); + src += width - (width % 16); + width %= 16; + } + + if (width >> 3) { + hevc_sao_edge_filter_45degree_8width_msa(dst, stride_dst, + src, stride_src, + sao_offset_val, height); + dst += 8; + src += 8; + width %= 8; + } + + if (width) { + hevc_sao_edge_filter_45degree_4width_msa(dst, stride_dst, + src, stride_src, + sao_offset_val, height); + } + break; + + case 3: + if (width >> 4) { + hevc_sao_edge_filter_135degree_16multiple_msa(dst, stride_dst, + src, stride_src, + sao_offset_val, + width - (width % 16), + height); + dst += width - (width % 16); + src += width - (width % 16); + width %= 16; + } + + if (width >> 3) { + hevc_sao_edge_filter_135degree_8width_msa(dst, stride_dst, + src, stride_src, + sao_offset_val, height); + dst += 8; + src += 8; + width %= 8; + } + + if (width) { + hevc_sao_edge_filter_135degree_4width_msa(dst, stride_dst, + src, stride_src, + sao_offset_val, height); + } + break; + } +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevc_mc_bi_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevc_mc_bi_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevc_mc_bi_msa.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevc_mc_bi_msa.c 2015-07-31 17:20:05.000000000 +0000 @@ -4369,7 +4369,7 @@ #undef BI_MC_COPY #define BI_MC(PEL, DIR, WIDTH, TAP, DIR1, FILT_DIR) \ -void ff_hevc_put_hevc_bi_##PEL##_##DIR####WIDTH##_8_msa(uint8_t *dst, \ +void ff_hevc_put_hevc_bi_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst, \ ptrdiff_t dst_stride, \ uint8_t *src, \ ptrdiff_t src_stride, \ @@ -4423,7 +4423,7 @@ #undef BI_MC #define BI_MC_HV(PEL, DIR, WIDTH, TAP, DIR1) \ -void ff_hevc_put_hevc_bi_##PEL##_##DIR####WIDTH##_8_msa(uint8_t *dst, \ +void ff_hevc_put_hevc_bi_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst, \ ptrdiff_t dst_stride, \ uint8_t *src, \ ptrdiff_t src_stride, \ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevc_mc_biw_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevc_mc_biw_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevc_mc_biw_msa.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevc_mc_biw_msa.c 2015-07-31 17:20:05.000000000 +0000 @@ -5454,7 +5454,7 @@ #undef BI_W_MC_COPY #define BI_W_MC(PEL, DIR, WIDTH, TAP, DIR1, FILT_DIR) \ -void ff_hevc_put_hevc_bi_w_##PEL##_##DIR####WIDTH##_8_msa(uint8_t *dst, \ +void ff_hevc_put_hevc_bi_w_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst, \ ptrdiff_t \ dst_stride, \ uint8_t *src, \ @@ -5521,7 +5521,7 @@ #undef BI_W_MC #define BI_W_MC_HV(PEL, DIR, WIDTH, TAP, DIR1) \ -void ff_hevc_put_hevc_bi_w_##PEL##_##DIR####WIDTH##_8_msa(uint8_t *dst, \ +void ff_hevc_put_hevc_bi_w_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst, \ ptrdiff_t \ dst_stride, \ uint8_t *src, \ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevc_mc_uni_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevc_mc_uni_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevc_mc_uni_msa.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevc_mc_uni_msa.c 2015-07-31 17:20:05.000000000 +0000 @@ -249,7 +249,7 @@ copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 64); } -uint8_t mc_filt_mask_arr[16 * 3] = { +static const uint8_t mc_filt_mask_arr[16 * 3] = { /* 8 width cases */ 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, /* 4 width cases */ @@ -3871,7 +3871,7 @@ #undef UNI_MC_COPY #define UNI_MC(PEL, DIR, WIDTH, TAP, DIR1, FILT_DIR) \ -void ff_hevc_put_hevc_uni_##PEL##_##DIR####WIDTH##_8_msa(uint8_t *dst, \ +void ff_hevc_put_hevc_uni_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst, \ ptrdiff_t \ dst_stride, \ uint8_t *src, \ @@ -3925,7 +3925,7 @@ #undef UNI_MC #define UNI_MC_HV(PEL, DIR, WIDTH, TAP, DIR1) \ -void ff_hevc_put_hevc_uni_##PEL##_##DIR####WIDTH##_8_msa(uint8_t *dst, \ +void ff_hevc_put_hevc_uni_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst, \ ptrdiff_t \ dst_stride, \ uint8_t *src, \ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevc_mc_uniw_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevc_mc_uniw_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevc_mc_uniw_msa.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevc_mc_uniw_msa.c 2015-07-31 17:20:05.000000000 +0000 @@ -4687,7 +4687,7 @@ #undef UNIWGT_MC_COPY #define UNI_W_MC(PEL, DIR, WIDTH, TAP, DIR1, FILT_DIR) \ -void ff_hevc_put_hevc_uni_w_##PEL##_##DIR####WIDTH##_8_msa(uint8_t *dst, \ +void ff_hevc_put_hevc_uni_w_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst, \ ptrdiff_t \ dst_stride, \ uint8_t *src, \ @@ -4746,7 +4746,7 @@ #undef UNI_W_MC #define UNI_W_MC_HV(PEL, DIR, WIDTH, TAP, DIR1) \ -void ff_hevc_put_hevc_uni_w_##PEL##_##DIR####WIDTH##_8_msa(uint8_t *dst, \ +void ff_hevc_put_hevc_uni_w_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst, \ ptrdiff_t \ dst_stride, \ uint8_t *src, \ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevcpred_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevcpred_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevcpred_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevcpred_init_mips.c 2015-06-10 17:20:04.000000000 +0000 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/hevc.h" +#include "libavcodec/mips/hevcpred_mips.h" + +#if HAVE_MSA +static av_cold void hevc_pred_init_msa(HEVCPredContext *c, const int bit_depth) +{ + if (8 == bit_depth) { + c->intra_pred[2] = ff_intra_pred_8_16x16_msa; + c->intra_pred[3] = ff_intra_pred_8_32x32_msa; + c->pred_planar[0] = ff_hevc_intra_pred_planar_0_msa; + c->pred_planar[1] = ff_hevc_intra_pred_planar_1_msa; + c->pred_planar[2] = ff_hevc_intra_pred_planar_2_msa; + c->pred_planar[3] = ff_hevc_intra_pred_planar_3_msa; + c->pred_dc = ff_hevc_intra_pred_dc_msa; + c->pred_angular[0] = ff_pred_intra_pred_angular_0_msa; + c->pred_angular[1] = ff_pred_intra_pred_angular_1_msa; + c->pred_angular[2] = ff_pred_intra_pred_angular_2_msa; + c->pred_angular[3] = ff_pred_intra_pred_angular_3_msa; + } +} +#endif // #if HAVE_MSA + +void ff_hevc_pred_init_mips(HEVCPredContext *c, const int bit_depth) +{ +#if HAVE_MSA + hevc_pred_init_msa(c, bit_depth); +#endif // #if HAVE_MSA +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevcpred_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevcpred_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevcpred_mips.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevcpred_mips.h 2015-06-10 17:20:04.000000000 +0000 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * + * 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 + */ + +#ifndef AVCODEC_MIPS_HEVCPRED_MIPS_H +#define AVCODEC_MIPS_HEVCPRED_MIPS_H + +#include "libavcodec/hevcdsp.h" + +void ff_hevc_intra_pred_planar_0_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride); + +void ff_hevc_intra_pred_planar_1_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride); + +void ff_hevc_intra_pred_planar_2_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride); + +void ff_hevc_intra_pred_planar_3_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride); + +void ff_hevc_intra_pred_dc_msa(uint8_t *dst, const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride, int log2, int c_idx); + +void ff_pred_intra_pred_angular_0_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride, int c_idx, int mode); + +void ff_pred_intra_pred_angular_1_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride, int c_idx, int mode); + +void ff_pred_intra_pred_angular_2_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride, int c_idx, int mode); + +void ff_pred_intra_pred_angular_3_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride, int c_idx, int mode); + +void ff_intra_pred_8_16x16_msa(HEVCContext *s, int x0, int y0, int c_idx); +void ff_intra_pred_8_32x32_msa(HEVCContext *s, int x0, int y0, int c_idx); + +#endif // #ifndef AVCODEC_MIPS_HEVCPRED_MIPS_H diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevcpred_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevcpred_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hevcpred_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hevcpred_msa.c 2015-06-11 17:20:04.000000000 +0000 @@ -0,0 +1,3084 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/hevc.h" +#include "libavutil/mips/generic_macros_msa.h" +#include "hevcpred_mips.h" + +static const int8_t intra_pred_angle_up[17] = { + -32, -26, -21, -17, -13, -9, -5, -2, 0, 2, 5, 9, 13, 17, 21, 26, 32 +}; + +static const int8_t intra_pred_angle_low[16] = { + 32, 26, 21, 17, 13, 9, 5, 2, 0, -2, -5, -9, -13, -17, -21, -26 +}; + +#define HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, \ + mul_val_h0, mul_val_h1, mul_val_h2, mul_val_h3, \ + res0, res1, mul_val_b0, mul_val_b1, round) \ +{ \ + v8i16 res0_m, res1_m, res2_m, res3_m; \ + \ + MUL4(mul_val_h0, vec0, mul_val_h2, vec0, mul_val_h0, vec1, \ + mul_val_h2, vec1, res0_m, res1_m, res2_m, res3_m); \ + \ + res0_m += mul_val_h1 * tmp0; \ + res1_m += mul_val_h3 * tmp0; \ + res2_m += mul_val_h1 * tmp0; \ + res3_m += mul_val_h3 * tmp0; \ + \ + res0_m += mul_val_b0 * src0_r; \ + res1_m += mul_val_b0 * src0_l; \ + res2_m += (mul_val_b0 - 1) * src0_r; \ + res3_m += (mul_val_b0 - 1) * src0_l; \ + \ + res0_m += mul_val_b1 * tmp1; \ + res1_m += mul_val_b1 * tmp1; \ + res2_m += (mul_val_b1 + 1) * tmp1; \ + res3_m += (mul_val_b1 + 1) * tmp1; \ + \ + SRARI_H4_SH(res0_m, res1_m, res2_m, res3_m, round); \ + PCKEV_B2_SH(res1_m, res0_m, res3_m, res2_m, res0, res1); \ +} + +static void hevc_intra_pred_vert_4x4_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride, + int32_t flag) +{ + uint32_t col; + uint32_t src_data; + v8i16 vec0, vec1, vec2; + v16i8 zero = { 0 }; + + src_data = LW(src_top); + SW4(src_data, src_data, src_data, src_data, dst, stride); + + if (0 == flag) { + src_data = LW(src_left); + + vec2 = (v8i16) __msa_insert_w((v4i32) vec2, 0, src_data); + + vec0 = __msa_fill_h(src_left[-1]); + vec1 = __msa_fill_h(src_top[0]); + + vec2 = (v8i16) __msa_ilvr_b(zero, (v16i8) vec2); + vec2 -= vec0; + vec2 >>= 1; + vec2 += vec1; + vec2 = CLIP_SH_0_255(vec2); + + for (col = 0; col < 4; col++) { + dst[stride * col] = (uint8_t) vec2[col]; + } + } +} + +static void hevc_intra_pred_vert_8x8_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride, + int32_t flag) +{ + uint8_t *tmp_dst = dst; + uint32_t row; + uint16_t val0, val1, val2, val3; + uint64_t src_data1; + v8i16 vec0, vec1, vec2; + v16i8 zero = { 0 }; + + src_data1 = LD(src_top); + + for (row = 8; row--;) { + SD(src_data1, tmp_dst); + tmp_dst += stride; + } + + if (0 == flag) { + src_data1 = LD(src_left); + + vec2 = (v8i16) __msa_insert_d((v2i64) zero, 0, src_data1); + + vec0 = __msa_fill_h(src_left[-1]); + vec1 = __msa_fill_h(src_top[0]); + + vec2 = (v8i16) __msa_ilvr_b(zero, (v16i8) vec2); + vec2 -= vec0; + vec2 >>= 1; + vec2 += vec1; + vec2 = CLIP_SH_0_255(vec2); + + val0 = vec2[0]; + val1 = vec2[1]; + val2 = vec2[2]; + val3 = vec2[3]; + + dst[0] = val0; + dst[stride] = val1; + dst[2 * stride] = val2; + dst[3 * stride] = val3; + + val0 = vec2[4]; + val1 = vec2[5]; + val2 = vec2[6]; + val3 = vec2[7]; + + dst[4 * stride] = val0; + dst[5 * stride] = val1; + dst[6 * stride] = val2; + dst[7 * stride] = val3; + } +} + +static void hevc_intra_pred_vert_16x16_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride, + int32_t flag) +{ + int32_t col; + uint8_t *tmp_dst = dst; + uint32_t row; + v16u8 src; + v8i16 vec0, vec1, vec2, vec3; + + src = LD_UB(src_top); + + for (row = 16; row--;) { + ST_UB(src, tmp_dst); + tmp_dst += stride; + } + + if (0 == flag) { + src = LD_UB(src_left); + + vec0 = __msa_fill_h(src_left[-1]); + vec1 = __msa_fill_h(src_top[0]); + + UNPCK_UB_SH(src, vec2, vec3); + SUB2(vec2, vec0, vec3, vec0, vec2, vec3); + + vec2 >>= 1; + vec3 >>= 1; + + ADD2(vec2, vec1, vec3, vec1, vec2, vec3); + CLIP_SH2_0_255(vec2, vec3); + + src = (v16u8) __msa_pckev_b((v16i8) vec3, (v16i8) vec2); + + for (col = 0; col < 16; col++) { + dst[stride * col] = src[col]; + } + } +} + +static void hevc_intra_pred_horiz_4x4_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride, + int32_t flag) +{ + uint32_t val0, val1, val2, val3; + v16i8 src0; + v8i16 src0_r, src_top_val, src_left_val; + v16i8 zero = { 0 }; + + val0 = src_left[0] * 0x01010101; + val1 = src_left[1] * 0x01010101; + val2 = src_left[2] * 0x01010101; + val3 = src_left[3] * 0x01010101; + SW4(val0, val1, val2, val3, dst, stride); + + if (0 == flag) { + val0 = LW(src_top); + src0 = (v16i8) __msa_insert_w((v4i32) src0, 0, val0); + src_top_val = __msa_fill_h(src_top[-1]); + src_left_val = __msa_fill_h(src_left[0]); + + src0_r = (v8i16) __msa_ilvr_b(zero, src0); + + src0_r -= src_top_val; + src0_r >>= 1; + src0_r += src_left_val; + src0_r = CLIP_SH_0_255(src0_r); + src0 = __msa_pckev_b((v16i8) src0_r, (v16i8) src0_r); + val0 = __msa_copy_s_w((v4i32) src0, 0); + SW(val0, dst); + } +} + +static void hevc_intra_pred_horiz_8x8_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride, + int32_t flag) +{ + uint64_t val0, val1, val2, val3; + v16i8 src0; + v8i16 src0_r, src_top_val, src_left_val; + v16i8 zero = { 0 }; + + val0 = src_left[0] * 0x0101010101010101; + val1 = src_left[1] * 0x0101010101010101; + val2 = src_left[2] * 0x0101010101010101; + val3 = src_left[3] * 0x0101010101010101; + SD4(val0, val1, val2, val3, dst, stride); + + val0 = src_left[4] * 0x0101010101010101; + val1 = src_left[5] * 0x0101010101010101; + val2 = src_left[6] * 0x0101010101010101; + val3 = src_left[7] * 0x0101010101010101; + SD4(val0, val1, val2, val3, dst + 4 * stride, stride); + + if (0 == flag) { + val0 = LD(src_top); + src0 = (v16i8) __msa_insert_d((v2i64) src0, 0, val0); + src_top_val = __msa_fill_h(src_top[-1]); + src_left_val = __msa_fill_h(src_left[0]); + + src0_r = (v8i16) __msa_ilvr_b(zero, src0); + + src0_r -= src_top_val; + src0_r >>= 1; + src0_r += src_left_val; + src0_r = CLIP_SH_0_255(src0_r); + src0 = __msa_pckev_b((v16i8) src0_r, (v16i8) src0_r); + val0 = __msa_copy_s_d((v2i64) src0, 0); + SD(val0, dst); + } +} + +static void hevc_intra_pred_horiz_16x16_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride, + int32_t flag) +{ + uint8_t *tmp_dst = dst; + uint32_t row; + uint8_t inp0, inp1, inp2, inp3; + v16i8 src0, src1, src2, src3; + v8i16 src0_r, src0_l, src_left_val, src_top_val; + + src_left_val = __msa_fill_h(src_left[0]); + + for (row = 4; row--;) { + inp0 = src_left[0]; + inp1 = src_left[1]; + inp2 = src_left[2]; + inp3 = src_left[3]; + src_left += 4; + + src0 = __msa_fill_b(inp0); + src1 = __msa_fill_b(inp1); + src2 = __msa_fill_b(inp2); + src3 = __msa_fill_b(inp3); + + ST_SB4(src0, src1, src2, src3, tmp_dst, stride); + tmp_dst += (4 * stride); + } + + if (0 == flag) { + src0 = LD_SB(src_top); + src_top_val = __msa_fill_h(src_top[-1]); + + UNPCK_UB_SH(src0, src0_r, src0_l); + SUB2(src0_r, src_top_val, src0_l, src_top_val, src0_r, src0_l); + + src0_r >>= 1; + src0_l >>= 1; + + ADD2(src0_r, src_left_val, src0_l, src_left_val, src0_r, src0_l); + CLIP_SH2_0_255(src0_r, src0_l); + src0 = __msa_pckev_b((v16i8) src0_l, (v16i8) src0_r); + ST_SB(src0, dst); + } +} + +static void hevc_intra_pred_horiz_32x32_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride) +{ + uint32_t row; + uint8_t inp0, inp1, inp2, inp3; + v16i8 src0, src1, src2, src3; + + for (row = 0; row < 8; row++) { + inp0 = src_left[row * 4]; + inp1 = src_left[row * 4 + 1]; + inp2 = src_left[row * 4 + 2]; + inp3 = src_left[row * 4 + 3]; + + src0 = __msa_fill_b(inp0); + src1 = __msa_fill_b(inp1); + src2 = __msa_fill_b(inp2); + src3 = __msa_fill_b(inp3); + + ST_SB2(src0, src0, dst, 16); + dst += stride; + ST_SB2(src1, src1, dst, 16); + dst += stride; + ST_SB2(src2, src2, dst, 16); + dst += stride; + ST_SB2(src3, src3, dst, 16); + dst += stride; + } +} + +static void hevc_intra_pred_dc_4x4_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride, + int32_t flag) +{ + uint8_t *tmp_dst = dst; + uint32_t addition = 0; + uint32_t val0, val1, val2; + v16i8 src = { 0 }; + v16u8 store; + v16i8 zero = { 0 }; + v8u16 sum, vec0, vec1; + + val0 = LW(src_top); + val1 = LW(src_left); + INSERT_W2_SB(val0, val1, src); + sum = __msa_hadd_u_h((v16u8) src, (v16u8) src); + sum = (v8u16) __msa_hadd_u_w(sum, sum); + sum = (v8u16) __msa_hadd_u_d((v4u32) sum, (v4u32) sum); + sum = (v8u16) __msa_srari_w((v4i32) sum, 3); + addition = __msa_copy_u_w((v4i32) sum, 0); + store = (v16u8) __msa_fill_b(addition); + val0 = __msa_copy_u_w((v4i32) store, 0); + SW4(val0, val0, val0, val0, dst, stride) + + if (0 == flag) { + ILVR_B2_UH(zero, store, zero, src, vec0, vec1); + + vec1 += vec0; + vec0 += vec0; + vec1 += vec0; + + vec1 = (v8u16) __msa_srari_h((v8i16) vec1, 2); + store = (v16u8) __msa_pckev_b((v16i8) vec1, (v16i8) vec1); + val1 = (src_left[0] + 2 * addition + src_top[0] + 2) >> 2; + store = (v16u8) __msa_insert_b((v16i8) store, 0, val1); + val0 = __msa_copy_u_w((v4i32) store, 0); + SW(val0, tmp_dst); + + val0 = src_left[1]; + val1 = src_left[2]; + val2 = src_left[3]; + + addition *= 3; + + ADD2(val0, addition, val1, addition, val0, val1); + val2 += addition; + + val0 += 2; + val1 += 2; + val2 += 2; + val0 >>= 2; + val1 >>= 2; + val2 >>= 2; + + tmp_dst[stride * 1] = val0; + tmp_dst[stride * 2] = val1; + tmp_dst[stride * 3] = val2; + } +} + +static void hevc_intra_pred_dc_8x8_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride, + int32_t flag) +{ + uint8_t *tmp_dst = dst; + uint32_t row, col, val; + uint32_t addition = 0; + uint64_t val0, val1; + v16u8 src = { 0 }; + v16u8 store; + v8u16 sum, vec0, vec1; + v16i8 zero = { 0 }; + + val0 = LD(src_top); + val1 = LD(src_left); + INSERT_D2_UB(val0, val1, src); + sum = __msa_hadd_u_h((v16u8) src, (v16u8) src); + sum = (v8u16) __msa_hadd_u_w(sum, sum); + sum = (v8u16) __msa_hadd_u_d((v4u32) sum, (v4u32) sum); + sum = (v8u16) __msa_pckev_w((v4i32) sum, (v4i32) sum); + sum = (v8u16) __msa_hadd_u_d((v4u32) sum, (v4u32) sum); + sum = (v8u16) __msa_srari_w((v4i32) sum, 4); + addition = __msa_copy_u_w((v4i32) sum, 0); + store = (v16u8) __msa_fill_b(addition); + val0 = __msa_copy_u_d((v2i64) store, 0); + + for (row = 8; row--;) { + SD(val0, dst); + dst += stride; + } + + if (0 == flag) { + ILVR_B2_UH(zero, store, zero, src, vec0, vec1); + + vec1 += vec0; + vec0 += vec0; + vec1 += vec0; + vec1 = (v8u16) __msa_srari_h((v8i16) vec1, 2); + store = (v16u8) __msa_pckev_b((v16i8) vec1, (v16i8) vec1); + val = (src_left[0] + 2 * addition + src_top[0] + 2) >> 2; + store = (v16u8) __msa_insert_b((v16i8) store, 0, val); + val0 = __msa_copy_u_d((v2i64) store, 0); + SD(val0, tmp_dst); + + val0 = LD(src_left); + src = (v16u8) __msa_insert_d((v2i64) src, 0, val0); + vec1 = (v8u16) __msa_ilvr_b(zero, (v16i8) src); + vec0 = (v8u16) __msa_fill_h(addition); + vec0 *= 3; + vec1 += vec0; + vec1 = (v8u16) __msa_srari_h((v8i16) vec1, 2); + + for (col = 1; col < 8; col++) { + tmp_dst[stride * col] = vec1[col]; + } + } +} + +static void hevc_intra_pred_dc_16x16_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride, + int32_t flag) +{ + uint8_t *tmp_dst = dst; + uint32_t row, col, val; + uint32_t addition = 0; + v16u8 src_above1, store, src_left1; + v8u16 sum, sum_above, sum_left; + v8u16 vec0, vec1, vec2; + v16i8 zero = { 0 }; + + src_above1 = LD_UB(src_top); + src_left1 = LD_UB(src_left); + + HADD_UB2_UH(src_above1, src_left1, sum_above, sum_left); + sum = sum_above + sum_left; + sum = (v8u16) __msa_hadd_u_w(sum, sum); + sum = (v8u16) __msa_hadd_u_d((v4u32) sum, (v4u32) sum); + sum = (v8u16) __msa_pckev_w((v4i32) sum, (v4i32) sum); + sum = (v8u16) __msa_hadd_u_d((v4u32) sum, (v4u32) sum); + sum = (v8u16) __msa_srari_w((v4i32) sum, 5); + addition = __msa_copy_u_w((v4i32) sum, 0); + store = (v16u8) __msa_fill_b(addition); + + for (row = 16; row--;) { + ST_UB(store, dst); + dst += stride; + } + + if (0 == flag) { + vec0 = (v8u16) __msa_ilvr_b(zero, (v16i8) store); + ILVRL_B2_UH(zero, src_above1, vec1, vec2); + ADD2(vec1, vec0, vec2, vec0, vec1, vec2); + vec0 += vec0; + ADD2(vec1, vec0, vec2, vec0, vec1, vec2); + SRARI_H2_UH(vec1, vec2, 2); + store = (v16u8) __msa_pckev_b((v16i8) vec2, (v16i8) vec1); + val = (src_left[0] + 2 * addition + src_top[0] + 2) >> 2; + store = (v16u8) __msa_insert_b((v16i8) store, 0, val); + ST_UB(store, tmp_dst); + + ILVRL_B2_UH(zero, src_left1, vec1, vec2); + vec0 = (v8u16) __msa_fill_h(addition); + vec0 *= 3; + ADD2(vec1, vec0, vec2, vec0, vec1, vec2); + SRARI_H2_UH(vec1, vec2, 2); + store = (v16u8) __msa_pckev_b((v16i8) vec2, (v16i8) vec1); + + for (col = 1; col < 16; col++) { + tmp_dst[stride * col] = store[col]; + } + } +} + +static void hevc_intra_pred_dc_32x32_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride) +{ + uint32_t row; + v16u8 src_above1, src_above2, store, src_left1, src_left2; + v8u16 sum_above1, sum_above2; + v8u16 sum_left1, sum_left2; + v8u16 sum, sum_above, sum_left; + + LD_UB2(src_top, 16, src_above1, src_above2); + LD_UB2(src_left, 16, src_left1, src_left2); + HADD_UB2_UH(src_above1, src_above2, sum_above1, sum_above2); + HADD_UB2_UH(src_left1, src_left2, sum_left1, sum_left2); + sum_above = sum_above1 + sum_above2; + sum_left = sum_left1 + sum_left2; + sum = sum_above + sum_left; + sum = (v8u16) __msa_hadd_u_w(sum, sum); + sum = (v8u16) __msa_hadd_u_d((v4u32) sum, (v4u32) sum); + sum = (v8u16) __msa_pckev_w((v4i32) sum, (v4i32) sum); + sum = (v8u16) __msa_hadd_u_d((v4u32) sum, (v4u32) sum); + sum = (v8u16) __msa_srari_w((v4i32) sum, 6); + store = (v16u8) __msa_splati_b((v16i8) sum, 0); + + for (row = 16; row--;) { + ST_UB2(store, store, dst, 16); + dst += stride; + ST_UB2(store, store, dst, 16); + dst += stride; + } +} + +static void hevc_intra_pred_plane_4x4_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride) +{ + uint32_t src0, src1; + v16i8 src_vec0, src_vec1; + v8i16 src_vec0_r, src1_r, tmp0, tmp1, mul_val1; + v8i16 vec0, vec1, vec2, vec3, res0, res1, res2, res3; + v8i16 mul_val0 = { 3, 2, 1, 0, 1, 2, 3, 4 }; + v16i8 zero = { 0 }; + + src0 = LW(src_top); + src1 = LW(src_left); + + mul_val1 = (v8i16) __msa_pckod_d((v2i64) mul_val0, (v2i64) mul_val0); + + src_vec0 = (v16i8) __msa_insert_w((v4i32) zero, 0, src0); + src_vec1 = (v16i8) __msa_insert_w((v4i32) zero, 0, src1); + + ILVR_B2_SH(zero, src_vec0, zero, src_vec1, src_vec0_r, src1_r); + SPLATI_H4_SH(src1_r, 0, 1, 2, 3, vec0, vec1, vec2, vec3); + + tmp0 = __msa_fill_h(src_top[4]); + tmp1 = __msa_fill_h(src_left[4]); + + MUL4(mul_val0, vec0, mul_val0, vec1, mul_val0, vec2, mul_val0, vec3, + res0, res1, res2, res3); + + res0 += mul_val1 * tmp0; + res1 += mul_val1 * tmp0; + res2 += mul_val1 * tmp0; + res3 += mul_val1 * tmp0; + + res0 += 3 * src_vec0_r; + res1 += 2 * src_vec0_r; + res2 += src_vec0_r; + res0 += tmp1; + res1 += 2 * tmp1; + res2 += 3 * tmp1; + res3 += 4 * tmp1; + + PCKEV_D2_SH(res1, res0, res3, res2, res0, res1); + SRARI_H2_SH(res0, res1, 3); + src_vec0 = __msa_pckev_b((v16i8) res1, (v16i8) res0); + ST4x4_UB(src_vec0, src_vec0, 0, 1, 2, 3, dst, stride); +} + +static void hevc_intra_pred_plane_8x8_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride) +{ + uint64_t src0, src1; + v16i8 src_vec0, src_vec1, src_vec2, src_vec3; + v8i16 src_vec0_r, src_vec1_r; + v8i16 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8i16 res0, res1, res2, res3, res4, res5, res6, res7; + v8i16 tmp0, tmp1, tmp2; + v8i16 mul_val1 = { 1, 2, 3, 4, 5, 6, 7, 8 }; + v8i16 mul_val0 = { 7, 6, 5, 4, 3, 2, 1, 0 }; + v16i8 zero = { 0 }; + + src0 = LD(src_top); + src1 = LD(src_left); + + src_vec0 = (v16i8) __msa_insert_d((v2i64) zero, 0, src0); + src_vec1 = (v16i8) __msa_insert_d((v2i64) zero, 0, src1); + + ILVR_B2_SH(zero, src_vec0, zero, src_vec1, src_vec0_r, src_vec1_r); + SPLATI_H4_SH(src_vec1_r, 0, 1, 2, 3, vec0, vec1, vec2, vec3); + SPLATI_H4_SH(src_vec1_r, 4, 5, 6, 7, vec4, vec5, vec6, vec7); + + tmp0 = __msa_fill_h(src_top[8]); + tmp1 = __msa_fill_h(src_left[8]); + + MUL4(mul_val0, vec0, mul_val0, vec1, mul_val0, vec2, mul_val0, vec3, + res0, res1, res2, res3); + MUL4(mul_val0, vec4, mul_val0, vec5, mul_val0, vec6, mul_val0, vec7, + res4, res5, res6, res7); + + tmp2 = mul_val1 * tmp0; + res0 += tmp2; + res1 += tmp2; + res2 += tmp2; + res3 += tmp2; + res4 += tmp2; + res5 += tmp2; + res6 += tmp2; + res7 += tmp2; + + res0 += 7 * src_vec0_r; + res1 += 6 * src_vec0_r; + res2 += 5 * src_vec0_r; + res3 += 4 * src_vec0_r; + res4 += 3 * src_vec0_r; + res5 += 2 * src_vec0_r; + res6 += src_vec0_r; + + res0 += tmp1; + res1 += 2 * tmp1; + res2 += 3 * tmp1; + res3 += 4 * tmp1; + res4 += 5 * tmp1; + res5 += 6 * tmp1; + res6 += 7 * tmp1; + res7 += 8 * tmp1; + + SRARI_H4_SH(res0, res1, res2, res3, 4); + SRARI_H4_SH(res4, res5, res6, res7, 4); + PCKEV_B4_SB(res1, res0, res3, res2, res5, res4, res7, res6, + src_vec0, src_vec1, src_vec2, src_vec3); + + ST8x8_UB(src_vec0, src_vec1, src_vec2, src_vec3, dst, stride); +} + +static void hevc_intra_pred_plane_16x16_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride) +{ + v16u8 src0, src1; + v8i16 src0_r, src1_r, src0_l, src1_l; + v8i16 vec0, vec1; + v8i16 res0, res1, tmp0, tmp1; + v8i16 mul_val2, mul_val3; + v8i16 mul_val1 = { 1, 2, 3, 4, 5, 6, 7, 8 }; + v8i16 mul_val0 = { 15, 14, 13, 12, 11, 10, 9, 8 }; + + src0 = LD_UB(src_top); + src1 = LD_UB(src_left); + + UNPCK_UB_SH(src0, src0_r, src0_l); + UNPCK_UB_SH(src1, src1_r, src1_l); + + mul_val2 = mul_val0 - 8; + mul_val3 = mul_val1 + 8; + + tmp0 = __msa_fill_h(src_top[16]); + tmp1 = __msa_fill_h(src_left[16]); + + SPLATI_H2_SH(src1_r, 0, 1, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 15, 1, 5); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_r, 2, 3, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 13, 3, 5); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_r, 4, 5, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 11, 5, 5); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_r, 6, 7, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 9, 7, 5); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_l, 0, 1, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 7, 9, 5); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_l, 2, 3, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 5, 11, 5); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_l, 4, 5, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 3, 13, 5); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_l, 6, 7, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 1, 15, 5); + ST_SH2(res0, res1, dst, stride); +} + +static void process_intra_upper_16x16_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride, + uint8_t offset) +{ + v16i8 src0, src1; + v8i16 src0_r, src1_r, src0_l, src1_l; + v8i16 vec0, vec1, res0, res1; + v8i16 tmp0, tmp1; + v8i16 mul_val2, mul_val3; + v8i16 mul_val1 = { 1, 2, 3, 4, 5, 6, 7, 8 }; + v8i16 mul_val0 = { 31, 30, 29, 28, 27, 26, 25, 24 }; + + tmp0 = __msa_fill_h(src_top[32 - offset]); + tmp1 = __msa_fill_h(src_left[32]); + + src0 = LD_SB(src_top); + src1 = LD_SB(src_left); + + UNPCK_UB_SH(src0, src0_r, src0_l); + UNPCK_UB_SH(src1, src1_r, src1_l); + + mul_val1 += offset; + mul_val0 -= offset; + mul_val2 = mul_val0 - 8; + mul_val3 = mul_val1 + 8; + + SPLATI_H2_SH(src1_r, 0, 1, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 31, 1, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_r, 2, 3, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 29, 3, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_r, 4, 5, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 27, 5, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_r, 6, 7, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 25, 7, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_l, 0, 1, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 23, 9, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_l, 2, 3, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 21, 11, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_l, 4, 5, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 19, 13, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_l, 6, 7, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 17, 15, 6); + ST_SH2(res0, res1, dst, stride); +} + +static void process_intra_lower_16x16_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride, + uint8_t offset) +{ + v16i8 src0, src1; + v8i16 src0_r, src1_r, src0_l, src1_l; + v8i16 vec0, vec1, res0, res1, tmp0, tmp1; + v8i16 mul_val2, mul_val3; + v8i16 mul_val1 = { 1, 2, 3, 4, 5, 6, 7, 8 }; + v8i16 mul_val0 = { 31, 30, 29, 28, 27, 26, 25, 24 }; + + tmp0 = __msa_fill_h(src_top[32 - offset]); + tmp1 = __msa_fill_h(src_left[16]); + + src0 = LD_SB(src_top); + src1 = LD_SB(src_left); + + UNPCK_UB_SH(src0, src0_r, src0_l); + UNPCK_UB_SH(src1, src1_r, src1_l); + + mul_val1 += offset; + mul_val0 -= offset; + mul_val2 = mul_val0 - 8; + mul_val3 = mul_val1 + 8; + + SPLATI_H2_SH(src1_r, 0, 1, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 15, 17, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_r, 2, 3, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 13, 19, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_r, 4, 5, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 11, 21, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_r, 6, 7, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 9, 23, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_l, 0, 1, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 7, 25, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_l, 2, 3, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 5, 27, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_l, 4, 5, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 3, 29, 6); + ST_SH2(res0, res1, dst, stride); + dst += (2 * stride); + + SPLATI_H2_SH(src1_l, 6, 7, vec0, vec1); + HEVC_PRED_PLANAR_16x2(src0_r, src0_l, tmp0, tmp1, vec0, vec1, + mul_val0, mul_val1, mul_val2, mul_val3, + res0, res1, 1, 31, 6); + ST_SH2(res0, res1, dst, stride); +} + +static void hevc_intra_pred_plane_32x32_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, int32_t stride) +{ + process_intra_upper_16x16_msa(src_top, src_left, dst, stride, 0); + process_intra_upper_16x16_msa((src_top + 16), src_left, + (dst + 16), stride, 16); + dst += (16 * stride); + src_left += 16; + + process_intra_lower_16x16_msa(src_top, src_left, dst, stride, 0); + process_intra_lower_16x16_msa((src_top + 16), src_left, + (dst + 16), stride, 16); +} + +static void hevc_intra_pred_angular_upper_4width_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, + int32_t stride, + int32_t mode) +{ + int16_t inv_angle[] = { -256, -315, -390, -482, -630, -910, -1638, -4096 }; + uint8_t ref_array[3 * 32 + 4]; + uint8_t *ref_tmp = ref_array + 4; + const uint8_t *ref; + int32_t last; + int32_t h_cnt, idx0, fact_val0, idx1, fact_val1; + int32_t idx2, fact_val2, idx3, fact_val3; + int32_t angle, angle_loop; + int32_t inv_angle_val, offset; + uint64_t tmp0; + v16i8 top0, top1, top2, top3; + v16i8 dst_val0; + v16i8 zero = { 0 }; + v8i16 diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7; + v8i16 fact0, fact1, fact2, fact3, fact4, fact5, fact6, fact7; + + angle = intra_pred_angle_up[mode - 18]; + inv_angle_val = inv_angle[mode - 18]; + last = (angle) >> 3; + angle_loop = angle; + + ref = src_top - 1; + if (angle < 0 && last < -1) { + inv_angle_val = inv_angle[mode - 18]; + + tmp0 = LD(ref); + SD(tmp0, ref_tmp); + + for (h_cnt = last; h_cnt <= -1; h_cnt++) { + offset = -1 + ((h_cnt * inv_angle_val + 128) >> 8); + ref_tmp[h_cnt] = src_left[offset]; + } + + ref = ref_tmp; + } + + idx0 = angle_loop >> 5; + fact_val0 = angle_loop & 31; + angle_loop += angle; + + idx1 = angle_loop >> 5; + fact_val1 = angle_loop & 31; + angle_loop += angle; + + idx2 = angle_loop >> 5; + fact_val2 = angle_loop & 31; + angle_loop += angle; + + idx3 = angle_loop >> 5; + fact_val3 = angle_loop & 31; + + top0 = LD_SB(ref + idx0 + 1); + top1 = LD_SB(ref + idx1 + 1); + top2 = LD_SB(ref + idx2 + 1); + top3 = LD_SB(ref + idx3 + 1); + + fact0 = __msa_fill_h(fact_val0); + fact1 = __msa_fill_h(32 - fact_val0); + + fact2 = __msa_fill_h(fact_val1); + fact3 = __msa_fill_h(32 - fact_val1); + + fact4 = __msa_fill_h(fact_val2); + fact5 = __msa_fill_h(32 - fact_val2); + + fact6 = __msa_fill_h(fact_val3); + fact7 = __msa_fill_h(32 - fact_val3); + + ILVR_D2_SH(fact2, fact0, fact6, fact4, fact0, fact2); + ILVR_D2_SH(fact3, fact1, fact7, fact5, fact1, fact3); + ILVR_B4_SH(zero, top0, zero, top1, zero, top2, zero, top3, + diff0, diff2, diff4, diff6); + SLDI_B4_0_SH(diff0, diff2, diff4, diff6, diff1, diff3, diff5, diff7, 2); + ILVR_D2_SH(diff2, diff0, diff6, diff4, diff0, diff2); + ILVR_D2_SH(diff3, diff1, diff7, diff5, diff1, diff3); + MUL2(diff1, fact0, diff3, fact2, diff1, diff3); + + diff1 += diff0 * fact1; + diff3 += diff2 * fact3; + + SRARI_H2_SH(diff1, diff3, 5); + dst_val0 = __msa_pckev_b((v16i8) diff3, (v16i8) diff1); + ST4x4_UB(dst_val0, dst_val0, 0, 1, 2, 3, dst, stride); +} + +static void hevc_intra_pred_angular_upper_8width_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, + int32_t stride, + int32_t mode) +{ + int16_t inv_angle[] = { -256, -315, -390, -482, -630, -910, -1638, -4096 }; + uint8_t ref_array[3 * 32 + 4]; + uint8_t *ref_tmp = ref_array + 8; + const uint8_t *ref; + const uint8_t *src_left_tmp = src_left - 1; + int32_t last, offset; + int32_t h_cnt, v_cnt, idx0, fact_val0, idx1, fact_val1; + int32_t idx2, fact_val2, idx3, fact_val3; + int32_t angle, angle_loop; + int32_t inv_angle_val, inv_angle_val_loop; + int32_t tmp0, tmp1, tmp2; + v16i8 top0, top1, top2, top3; + v16u8 dst_val0, dst_val1; + v8i16 fact0, fact1, fact2, fact3, fact4, fact5, fact6, fact7; + v8i16 diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7; + + angle = intra_pred_angle_up[mode - 18]; + inv_angle_val = inv_angle[mode - 18]; + last = (angle) >> 2; + angle_loop = angle; + + ref = src_top - 1; + if (last < -1) { + inv_angle_val_loop = inv_angle_val * last; + + tmp0 = LW(ref); + tmp1 = LW(ref + 4); + tmp2 = LW(ref + 8); + SW(tmp0, ref_tmp); + SW(tmp1, ref_tmp + 4); + SW(tmp2, ref_tmp + 8); + + for (h_cnt = last; h_cnt <= -1; h_cnt++) { + offset = (inv_angle_val_loop + 128) >> 8; + ref_tmp[h_cnt] = src_left_tmp[offset]; + inv_angle_val_loop += inv_angle_val; + } + ref = ref_tmp; + } + + for (v_cnt = 0; v_cnt < 2; v_cnt++) { + idx0 = (angle_loop) >> 5; + fact_val0 = (angle_loop) & 31; + angle_loop += angle; + + idx1 = (angle_loop) >> 5; + fact_val1 = (angle_loop) & 31; + angle_loop += angle; + + idx2 = (angle_loop) >> 5; + fact_val2 = (angle_loop) & 31; + angle_loop += angle; + + idx3 = (angle_loop) >> 5; + fact_val3 = (angle_loop) & 31; + angle_loop += angle; + + top0 = LD_SB(ref + idx0 + 1); + top1 = LD_SB(ref + idx1 + 1); + top2 = LD_SB(ref + idx2 + 1); + top3 = LD_SB(ref + idx3 + 1); + + fact0 = __msa_fill_h(fact_val0); + fact1 = __msa_fill_h(32 - fact_val0); + fact2 = __msa_fill_h(fact_val1); + fact3 = __msa_fill_h(32 - fact_val1); + fact4 = __msa_fill_h(fact_val2); + fact5 = __msa_fill_h(32 - fact_val2); + fact6 = __msa_fill_h(fact_val3); + fact7 = __msa_fill_h(32 - fact_val3); + + UNPCK_UB_SH(top0, diff0, diff1); + UNPCK_UB_SH(top1, diff2, diff3); + UNPCK_UB_SH(top2, diff4, diff5); + UNPCK_UB_SH(top3, diff6, diff7); + + SLDI_B2_SH(diff1, diff3, diff0, diff2, diff1, diff3, 2); + SLDI_B2_SH(diff5, diff7, diff4, diff6, diff5, diff7, 2); + MUL4(diff1, fact0, diff3, fact2, diff5, fact4, diff7, fact6, + diff1, diff3, diff5, diff7); + + diff1 += diff0 * fact1; + diff3 += diff2 * fact3; + diff5 += diff4 * fact5; + diff7 += diff6 * fact7; + + SRARI_H4_SH(diff1, diff3, diff5, diff7, 5); + PCKEV_B2_UB(diff3, diff1, diff7, diff5, dst_val0, dst_val1); + ST8x4_UB(dst_val0, dst_val1, dst, stride); + dst += (4 * stride); + } +} + +static void hevc_intra_pred_angular_upper_16width_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, + int32_t stride, + int32_t mode) +{ + int16_t inv_angle[] = { -256, -315, -390, -482, -630, -910, -1638, -4096 }; + int32_t h_cnt, v_cnt, idx0, fact_val0, idx1, fact_val1; + int32_t idx2, fact_val2, idx3, fact_val3; + int32_t tmp0; + int32_t angle, angle_loop, offset; + int32_t inv_angle_val, inv_angle_val_loop; + uint8_t ref_array[3 * 32 + 4]; + uint8_t *ref_tmp = ref_array + 16; + const uint8_t *ref; + const uint8_t *src_left_tmp = src_left - 1; + int32_t last; + v16u8 top0, top1, top2, top3, top4, top5, top6, top7; + v16i8 dst0, dst1, dst2, dst3; + v8i16 fact0, fact1, fact2, fact3, fact4, fact5, fact6, fact7; + v8i16 diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7; + v8i16 diff8, diff9, diff10, diff11, diff12, diff13, diff14, diff15; + + angle = intra_pred_angle_up[mode - 18]; + inv_angle_val = inv_angle[mode - 18]; + last = angle >> 1; + angle_loop = angle; + + ref = src_top - 1; + if (last < -1) { + inv_angle_val_loop = inv_angle_val * last; + + top0 = LD_UB(ref); + tmp0 = LW(ref + 16); + ST_UB(top0, ref_tmp); + SW(tmp0, ref_tmp + 16); + + for (h_cnt = last; h_cnt <= -1; h_cnt++) { + offset = (inv_angle_val_loop + 128) >> 8; + ref_tmp[h_cnt] = src_left_tmp[offset]; + inv_angle_val_loop += inv_angle_val; + } + ref = ref_tmp; + } + + for (v_cnt = 4; v_cnt--;) { + idx0 = (angle_loop) >> 5; + fact_val0 = (angle_loop) & 31; + angle_loop += angle; + + idx1 = (angle_loop) >> 5; + fact_val1 = (angle_loop) & 31; + angle_loop += angle; + + idx2 = (angle_loop) >> 5; + fact_val2 = (angle_loop) & 31; + angle_loop += angle; + + idx3 = (angle_loop) >> 5; + fact_val3 = (angle_loop) & 31; + angle_loop += angle; + + LD_UB2(ref + idx0 + 1, 16, top0, top1); + LD_UB2(ref + idx1 + 1, 16, top2, top3); + LD_UB2(ref + idx2 + 1, 16, top4, top5); + LD_UB2(ref + idx3 + 1, 16, top6, top7); + + fact0 = __msa_fill_h(fact_val0); + fact1 = __msa_fill_h(32 - fact_val0); + fact2 = __msa_fill_h(fact_val1); + fact3 = __msa_fill_h(32 - fact_val1); + fact4 = __msa_fill_h(fact_val2); + fact5 = __msa_fill_h(32 - fact_val2); + fact6 = __msa_fill_h(fact_val3); + fact7 = __msa_fill_h(32 - fact_val3); + + SLDI_B2_UB(top1, top3, top0, top2, top1, top3, 1); + SLDI_B2_UB(top5, top7, top4, top6, top5, top7, 1); + UNPCK_UB_SH(top0, diff0, diff1); + UNPCK_UB_SH(top1, diff2, diff3); + UNPCK_UB_SH(top2, diff4, diff5); + UNPCK_UB_SH(top3, diff6, diff7); + UNPCK_UB_SH(top4, diff8, diff9); + UNPCK_UB_SH(top5, diff10, diff11); + UNPCK_UB_SH(top6, diff12, diff13); + UNPCK_UB_SH(top7, diff14, diff15); + + MUL4(diff2, fact0, diff3, fact0, diff6, fact2, diff7, fact2, + diff2, diff3, diff6, diff7); + MUL4(diff10, fact4, diff11, fact4, diff14, fact6, diff15, fact6, + diff10, diff11, diff14, diff15); + + diff2 += diff0 * fact1; + diff3 += diff1 * fact1; + diff6 += diff4 * fact3; + diff7 += diff5 * fact3; + diff10 += diff8 * fact5; + diff11 += diff9 * fact5; + diff14 += diff12 * fact7; + diff15 += diff13 * fact7; + + SRARI_H4_SH(diff2, diff3, diff6, diff7, 5); + SRARI_H4_SH(diff10, diff11, diff14, diff15, 5); + PCKEV_B4_SB(diff3, diff2, diff7, diff6, diff11, diff10, diff15, diff14, + dst0, dst1, dst2, dst3); + ST_SB4(dst0, dst1, dst2, dst3, dst, stride); + dst += (4 * stride); + } +} + +static void hevc_intra_pred_angular_upper_32width_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, + int32_t stride, + int32_t mode) +{ + int16_t inv_angle[] = { -256, -315, -390, -482, -630, -910, -1638, -4096 }; + uint8_t ref_array[3 * 32 + 4]; + uint8_t *ref_tmp; + const uint8_t *ref; + const uint8_t *src_left_tmp = src_left - 1; + int32_t h_cnt, v_cnt, idx0, fact_val0, idx1, fact_val1; + int32_t tmp0, tmp1, tmp2, tmp3; + int32_t angle, angle_loop; + int32_t inv_angle_val, inv_angle_val_loop; + int32_t last, offset; + v16u8 top0, top1, top2, top3, top4, top5, top6, top7; + v16i8 dst0, dst1, dst2, dst3; + v8i16 fact0, fact1, fact2, fact3; + v8i16 diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7; + v8i16 diff8, diff9, diff10, diff11, diff12, diff13, diff14, diff15; + + ref_tmp = ref_array + 32; + + angle = intra_pred_angle_up[mode - 18]; + inv_angle_val = inv_angle[mode - 18]; + last = angle; + angle_loop = angle; + + ref = src_top - 1; + if (last < -1) { + inv_angle_val_loop = inv_angle_val * last; + LD_UB2(ref, 16, top0, top1); + tmp0 = ref[32]; + tmp1 = ref[33]; + tmp2 = ref[34]; + tmp3 = ref[35]; + + ST_UB2(top0, top1, ref_tmp, 16); + ref_tmp[32] = tmp0; + ref_tmp[33] = tmp1; + ref_tmp[34] = tmp2; + ref_tmp[35] = tmp3; + + for (h_cnt = last; h_cnt <= -1; h_cnt++) { + offset = (inv_angle_val_loop + 128) >> 8; + ref_tmp[h_cnt] = src_left_tmp[offset]; + inv_angle_val_loop += inv_angle_val; + } + + ref = ref_tmp; + } + + for (v_cnt = 16; v_cnt--;) { + idx0 = (angle_loop) >> 5; + fact_val0 = (angle_loop) & 31; + angle_loop += angle; + + idx1 = (angle_loop) >> 5; + fact_val1 = (angle_loop) & 31; + angle_loop += angle; + + top0 = LD_UB(ref + idx0 + 1); + top4 = LD_UB(ref + idx1 + 1); + top1 = LD_UB(ref + idx0 + 17); + top5 = LD_UB(ref + idx1 + 17); + top3 = LD_UB(ref + idx0 + 33); + top7 = LD_UB(ref + idx1 + 33); + + fact0 = __msa_fill_h(fact_val0); + fact1 = __msa_fill_h(32 - fact_val0); + fact2 = __msa_fill_h(fact_val1); + fact3 = __msa_fill_h(32 - fact_val1); + + top2 = top1; + top6 = top5; + + SLDI_B2_UB(top1, top3, top0, top2, top1, top3, 1); + SLDI_B2_UB(top5, top7, top4, top6, top5, top7, 1); + UNPCK_UB_SH(top0, diff0, diff1); + UNPCK_UB_SH(top1, diff2, diff3); + UNPCK_UB_SH(top2, diff4, diff5); + UNPCK_UB_SH(top3, diff6, diff7); + UNPCK_UB_SH(top4, diff8, diff9); + UNPCK_UB_SH(top5, diff10, diff11); + UNPCK_UB_SH(top6, diff12, diff13); + UNPCK_UB_SH(top7, diff14, diff15); + + MUL4(diff2, fact0, diff3, fact0, diff6, fact0, diff7, fact0, + diff2, diff3, diff6, diff7); + MUL4(diff10, fact2, diff11, fact2, diff14, fact2, diff15, fact2, + diff10, diff11, diff14, diff15); + + diff2 += diff0 * fact1; + diff3 += diff1 * fact1; + diff6 += diff4 * fact1; + diff7 += diff5 * fact1; + diff10 += diff8 * fact3; + diff11 += diff9 * fact3; + diff14 += diff12 * fact3; + diff15 += diff13 * fact3; + + SRARI_H4_SH(diff2, diff3, diff6, diff7, 5); + SRARI_H4_SH(diff10, diff11, diff14, diff15, 5); + PCKEV_B4_SB(diff3, diff2, diff7, diff6, diff11, diff10, diff15, diff14, + dst0, dst1, dst2, dst3); + + ST_SB2(dst0, dst1, dst, 16); + dst += stride; + ST_SB2(dst2, dst3, dst, 16); + dst += stride; + } +} + +static void hevc_intra_pred_angular_lower_4width_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, + int32_t stride, + int32_t mode) +{ + int16_t inv_angle[] = { -4096, -1638, -910, -630, -482, -390, -315 }; + uint8_t ref_array[3 * 32 + 4]; + uint8_t *ref_tmp = ref_array + 4; + const uint8_t *ref; + int32_t last, offset; + int32_t h_cnt, idx0, fact_val0, idx1, fact_val1; + int32_t idx2, fact_val2, idx3, fact_val3; + int32_t angle, angle_loop, inv_angle_val; + uint64_t tmp0; + v16i8 dst_val0, dst_val1; + v16u8 top0, top1, top2, top3; + v16u8 zero = { 0 }; + v8i16 diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7; + v8i16 fact0, fact1, fact2, fact3, fact4, fact5, fact6, fact7; + + angle = intra_pred_angle_low[mode - 2]; + last = angle >> 3; + angle_loop = angle; + + ref = src_left - 1; + if (last < -1) { + inv_angle_val = inv_angle[mode - 11]; + + tmp0 = LD(ref); + SD(tmp0, ref_tmp); + + for (h_cnt = last; h_cnt <= -1; h_cnt++) { + offset = -1 + ((h_cnt * inv_angle_val + 128) >> 8); + ref_tmp[h_cnt] = src_top[offset]; + } + + ref = ref_tmp; + } + + idx0 = angle_loop >> 5; + fact_val0 = angle_loop & 31; + angle_loop += angle; + + idx1 = angle_loop >> 5; + fact_val1 = angle_loop & 31; + angle_loop += angle; + + idx2 = angle_loop >> 5; + fact_val2 = angle_loop & 31; + angle_loop += angle; + + idx3 = angle_loop >> 5; + fact_val3 = angle_loop & 31; + + top0 = LD_UB(ref + idx0 + 1); + top1 = LD_UB(ref + idx1 + 1); + top2 = LD_UB(ref + idx2 + 1); + top3 = LD_UB(ref + idx3 + 1); + + fact0 = __msa_fill_h(fact_val0); + fact1 = __msa_fill_h(32 - fact_val0); + fact2 = __msa_fill_h(fact_val1); + fact3 = __msa_fill_h(32 - fact_val1); + fact4 = __msa_fill_h(fact_val2); + fact5 = __msa_fill_h(32 - fact_val2); + fact6 = __msa_fill_h(fact_val3); + fact7 = __msa_fill_h(32 - fact_val3); + + ILVR_D2_SH(fact2, fact0, fact6, fact4, fact0, fact2); + ILVR_D2_SH(fact3, fact1, fact7, fact5, fact1, fact3); + ILVR_B4_SH(zero, top0, zero, top1, zero, top2, zero, top3, + diff0, diff2, diff4, diff6); + SLDI_B4_0_SH(diff0, diff2, diff4, diff6, diff1, diff3, diff5, diff7, 2); + ILVR_D2_SH(diff2, diff0, diff6, diff4, diff0, diff2); + ILVR_D2_SH(diff3, diff1, diff7, diff5, diff1, diff3); + MUL2(diff1, fact0, diff3, fact2, diff1, diff3); + + diff1 += diff0 * fact1; + diff3 += diff2 * fact3; + + SRARI_H2_SH(diff1, diff3, 5); + PCKEV_B2_SB(diff1, diff1, diff3, diff3, dst_val0, dst_val1); + + diff0 = (v8i16) __msa_pckev_b(dst_val1, dst_val0); + diff1 = (v8i16) __msa_pckod_b(dst_val1, dst_val0); + + diff2 = (v8i16) __msa_pckev_w((v4i32) diff1, (v4i32) diff0); + + dst_val0 = __msa_pckev_b((v16i8) diff2, (v16i8) diff2); + dst_val1 = __msa_pckod_b((v16i8) diff2, (v16i8) diff2); + + ST4x2_UB(dst_val0, dst, stride); + dst += (2 * stride); + ST4x2_UB(dst_val1, dst, stride); +} + +static void hevc_intra_pred_angular_lower_8width_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, + int32_t stride, + int32_t mode) +{ + int16_t inv_angle[] = { -4096, -1638, -910, -630, -482, -390, -315 }; + uint8_t ref_array[3 * 32 + 4]; + uint8_t *ref_tmp = ref_array + 8; + const uint8_t *ref; + const uint8_t *src_top_tmp = src_top - 1; + uint8_t *dst_org; + int32_t last, offset, tmp0, tmp1, tmp2; + int32_t h_cnt, v_cnt, idx0, fact_val0, idx1, fact_val1; + int32_t idx2, fact_val2, idx3, fact_val3; + int32_t angle, angle_loop, inv_angle_val; + v16i8 top0, top1, top2, top3; + v16i8 dst_val0, dst_val1, dst_val2, dst_val3; + v8i16 diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7; + v8i16 fact0, fact1, fact2, fact3, fact4, fact5, fact6, fact7; + + angle = intra_pred_angle_low[mode - 2]; + last = (angle) >> 2; + angle_loop = angle; + + ref = src_left - 1; + if (last < -1) { + inv_angle_val = inv_angle[mode - 11]; + + tmp0 = LW(ref); + tmp1 = LW(ref + 4); + tmp2 = LW(ref + 8); + SW(tmp0, ref_tmp); + SW(tmp1, ref_tmp + 4); + SW(tmp2, ref_tmp + 8); + + for (h_cnt = last; h_cnt <= -1; h_cnt++) { + offset = (h_cnt * inv_angle_val + 128) >> 8; + ref_tmp[h_cnt] = src_top_tmp[offset]; + } + + ref = ref_tmp; + } + + for (v_cnt = 0; v_cnt < 2; v_cnt++) { + dst_org = dst; + + idx0 = angle_loop >> 5; + fact_val0 = angle_loop & 31; + angle_loop += angle; + + idx1 = angle_loop >> 5; + fact_val1 = angle_loop & 31; + angle_loop += angle; + + idx2 = angle_loop >> 5; + fact_val2 = angle_loop & 31; + angle_loop += angle; + + idx3 = angle_loop >> 5; + fact_val3 = angle_loop & 31; + angle_loop += angle; + + top0 = LD_SB(ref + idx0 + 1); + top1 = LD_SB(ref + idx1 + 1); + top2 = LD_SB(ref + idx2 + 1); + top3 = LD_SB(ref + idx3 + 1); + + fact0 = __msa_fill_h(fact_val0); + fact1 = __msa_fill_h(32 - fact_val0); + fact2 = __msa_fill_h(fact_val1); + fact3 = __msa_fill_h(32 - fact_val1); + fact4 = __msa_fill_h(fact_val2); + fact5 = __msa_fill_h(32 - fact_val2); + fact6 = __msa_fill_h(fact_val3); + fact7 = __msa_fill_h(32 - fact_val3); + + UNPCK_UB_SH(top0, diff0, diff1); + UNPCK_UB_SH(top1, diff2, diff3); + UNPCK_UB_SH(top2, diff4, diff5); + UNPCK_UB_SH(top3, diff6, diff7); + SLDI_B2_SH(diff1, diff3, diff0, diff2, diff1, diff3, 2); + SLDI_B2_SH(diff5, diff7, diff4, diff6, diff5, diff7, 2); + MUL4(diff1, fact0, diff3, fact2, diff5, fact4, diff7, fact6, + diff1, diff3, diff5, diff7); + + diff1 += diff0 * fact1; + diff3 += diff2 * fact3; + diff5 += diff4 * fact5; + diff7 += diff6 * fact7; + + SRARI_H4_SH(diff1, diff3, diff5, diff7, 5); + PCKEV_B4_SB(diff1, diff1, diff3, diff3, diff5, diff5, diff7, diff7, + dst_val0, dst_val1, dst_val2, dst_val3); + ILVR_B2_SH(dst_val1, dst_val0, dst_val3, dst_val2, diff0, diff1); + ILVRL_H2_SH(diff1, diff0, diff3, diff4); + ST4x8_UB(diff3, diff4, dst_org, stride); + dst += 4; + } +} + +static void hevc_intra_pred_angular_lower_16width_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, + int32_t stride, + int32_t mode) +{ + int16_t inv_angle[] = { -4096, -1638, -910, -630, -482, -390, -315 }; + int32_t h_cnt, v_cnt, idx0, fact_val0, idx1, fact_val1; + int32_t idx2, fact_val2, idx3, fact_val3, tmp0; + v16i8 top0, top1, dst_val0, top2, top3, dst_val1; + v16i8 top4, top5, dst_val2, top6, top7, dst_val3; + v8i16 fact0, fact1, fact2, fact3, fact4, fact5, fact6, fact7; + v8i16 diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7; + v8i16 diff8, diff9, diff10, diff11, diff12, diff13, diff14, diff15; + int32_t angle, angle_loop, inv_angle_val, offset; + uint8_t ref_array[3 * 32 + 4]; + uint8_t *ref_tmp = ref_array + 16; + const uint8_t *ref, *src_top_tmp = src_top - 1; + uint8_t *dst_org; + int32_t last; + + angle = intra_pred_angle_low[mode - 2]; + last = (angle) >> 1; + angle_loop = angle; + + ref = src_left - 1; + if (last < -1) { + inv_angle_val = inv_angle[mode - 11]; + + top0 = LD_SB(ref); + tmp0 = LW(ref + 16); + ST_SB(top0, ref_tmp); + SW(tmp0, ref_tmp + 16); + + for (h_cnt = last; h_cnt <= -1; h_cnt++) { + offset = (h_cnt * inv_angle_val + 128) >> 8; + ref_tmp[h_cnt] = src_top_tmp[offset]; + } + + ref = ref_tmp; + } + + for (v_cnt = 0; v_cnt < 4; v_cnt++) { + dst_org = dst; + + idx0 = angle_loop >> 5; + fact_val0 = angle_loop & 31; + angle_loop += angle; + + idx1 = angle_loop >> 5; + fact_val1 = angle_loop & 31; + angle_loop += angle; + + idx2 = angle_loop >> 5; + fact_val2 = angle_loop & 31; + angle_loop += angle; + + idx3 = angle_loop >> 5; + fact_val3 = angle_loop & 31; + angle_loop += angle; + + LD_SB2(ref + idx0 + 1, 16, top0, top1); + LD_SB2(ref + idx1 + 1, 16, top2, top3); + LD_SB2(ref + idx2 + 1, 16, top4, top5); + LD_SB2(ref + idx3 + 1, 16, top6, top7); + + fact0 = __msa_fill_h(fact_val0); + fact1 = __msa_fill_h(32 - fact_val0); + fact2 = __msa_fill_h(fact_val1); + fact3 = __msa_fill_h(32 - fact_val1); + fact4 = __msa_fill_h(fact_val2); + fact5 = __msa_fill_h(32 - fact_val2); + fact6 = __msa_fill_h(fact_val3); + fact7 = __msa_fill_h(32 - fact_val3); + + SLDI_B2_SB(top1, top3, top0, top2, top1, top3, 1); + SLDI_B2_SB(top5, top7, top4, top6, top5, top7, 1); + + UNPCK_UB_SH(top0, diff0, diff1); + UNPCK_UB_SH(top1, diff2, diff3); + UNPCK_UB_SH(top2, diff4, diff5); + UNPCK_UB_SH(top3, diff6, diff7); + UNPCK_UB_SH(top4, diff8, diff9); + UNPCK_UB_SH(top5, diff10, diff11); + UNPCK_UB_SH(top6, diff12, diff13); + UNPCK_UB_SH(top7, diff14, diff15); + + MUL4(diff2, fact0, diff3, fact0, diff6, fact2, diff7, fact2, + diff2, diff3, diff6, diff7); + MUL4(diff10, fact4, diff11, fact4, diff14, fact6, diff15, fact6, + diff10, diff11, diff14, diff15); + + diff2 += diff0 * fact1; + diff3 += diff1 * fact1; + diff6 += diff4 * fact3; + diff7 += diff5 * fact3; + diff10 += diff8 * fact5; + diff11 += diff9 * fact5; + diff14 += diff12 * fact7; + diff15 += diff13 * fact7; + + SRARI_H4_SH(diff2, diff3, diff6, diff7, 5); + SRARI_H4_SH(diff10, diff11, diff14, diff15, 5); + PCKEV_B4_SB(diff3, diff2, diff7, diff6, diff11, diff10, diff15, diff14, + dst_val0, dst_val1, dst_val2, dst_val3); + ILVR_B2_SH(dst_val1, dst_val0, dst_val3, dst_val2, diff0, diff1); + ILVL_B2_SH(dst_val1, dst_val0, dst_val3, dst_val2, diff2, diff3); + ILVRL_H2_SH(diff1, diff0, diff4, diff5); + ILVRL_H2_SH(diff3, diff2, diff6, diff7); + ST4x8_UB(diff4, diff5, dst_org, stride); + dst_org += (8 * stride); + ST4x8_UB(diff6, diff7, dst_org, stride); + dst += 4; + } +} + +static void hevc_intra_pred_angular_lower_32width_msa(const uint8_t *src_top, + const uint8_t *src_left, + uint8_t *dst, + int32_t stride, + int32_t mode) +{ + int16_t inv_angle[] = { -4096, -1638, -910, -630, -482, -390, -315 }; + int32_t h_cnt, v_cnt, idx0, fact_val0, idx1, fact_val1, tmp0; + v16i8 top0, top1, dst_val0, top2, top3, dst_val1; + v16i8 top4, top5, dst_val2, top6, top7, dst_val3; + v8i16 fact0, fact1, fact2, fact3; + v8i16 diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7; + v8i16 diff8, diff9, diff10, diff11, diff12, diff13, diff14, diff15; + int32_t angle, angle_loop, inv_angle_val, offset; + uint8_t ref_array[3 * 32 + 4]; + uint8_t *ref_tmp = ref_array + 32; + const uint8_t *ref, *src_top_tmp = src_top - 1; + uint8_t *dst_org; + int32_t last; + + angle = intra_pred_angle_low[mode - 2]; + last = angle; + angle_loop = angle; + + ref = src_left - 1; + if (last < -1) { + inv_angle_val = inv_angle[mode - 11]; + + LD_SB2(ref, 16, top0, top1); + tmp0 = LW(ref + 32); + ST_SB2(top0, top1, ref_tmp, 16); + SW(tmp0, ref_tmp + 32); + + for (h_cnt = last; h_cnt <= -1; h_cnt++) { + offset = (h_cnt * inv_angle_val + 128) >> 8; + ref_tmp[h_cnt] = src_top_tmp[offset]; + } + + ref = ref_tmp; + } + + for (v_cnt = 0; v_cnt < 16; v_cnt++) { + dst_org = dst; + idx0 = angle_loop >> 5; + fact_val0 = angle_loop & 31; + angle_loop += angle; + + idx1 = angle_loop >> 5; + fact_val1 = angle_loop & 31; + angle_loop += angle; + + top0 = LD_SB(ref + idx0 + 1); + top4 = LD_SB(ref + idx1 + 1); + top1 = LD_SB(ref + idx0 + 17); + top5 = LD_SB(ref + idx1 + 17); + top3 = LD_SB(ref + idx0 + 33); + top7 = LD_SB(ref + idx1 + 33); + + fact0 = __msa_fill_h(fact_val0); + fact1 = __msa_fill_h(32 - fact_val0); + fact2 = __msa_fill_h(fact_val1); + fact3 = __msa_fill_h(32 - fact_val1); + + top2 = top1; + top6 = top5; + + SLDI_B2_SB(top1, top3, top0, top2, top1, top3, 1); + SLDI_B2_SB(top5, top7, top4, top6, top5, top7, 1); + + UNPCK_UB_SH(top0, diff0, diff1); + UNPCK_UB_SH(top1, diff2, diff3); + UNPCK_UB_SH(top2, diff4, diff5); + UNPCK_UB_SH(top3, diff6, diff7); + UNPCK_UB_SH(top4, diff8, diff9); + UNPCK_UB_SH(top5, diff10, diff11); + UNPCK_UB_SH(top6, diff12, diff13); + UNPCK_UB_SH(top7, diff14, diff15); + + MUL4(diff2, fact0, diff3, fact0, diff6, fact0, diff7, fact0, + diff2, diff3, diff6, diff7); + MUL4(diff10, fact2, diff11, fact2, diff14, fact2, diff15, fact2, + diff10, diff11, diff14, diff15); + + diff2 += diff0 * fact1; + diff3 += diff1 * fact1; + diff6 += diff4 * fact1; + diff7 += diff5 * fact1; + diff10 += diff8 * fact3; + diff11 += diff9 * fact3; + diff14 += diff12 * fact3; + diff15 += diff13 * fact3; + + SRARI_H4_SH(diff2, diff3, diff6, diff7, 5); + SRARI_H4_SH(diff10, diff11, diff14, diff15, 5); + PCKEV_B4_SB(diff3, diff2, diff7, diff6, diff11, diff10, diff15, diff14, + dst_val0, dst_val1, dst_val2, dst_val3); + ILVRL_B2_SH(dst_val2, dst_val0, diff0, diff1); + ILVRL_B2_SH(dst_val3, dst_val1, diff2, diff3); + + ST2x4_UB(diff0, 0, dst_org, stride); + dst_org += (4 * stride); + ST2x4_UB(diff0, 4, dst_org, stride); + dst_org += (4 * stride); + ST2x4_UB(diff1, 0, dst_org, stride); + dst_org += (4 * stride); + ST2x4_UB(diff1, 4, dst_org, stride); + dst_org += (4 * stride); + + ST2x4_UB(diff2, 0, dst_org, stride); + dst_org += (4 * stride); + ST2x4_UB(diff2, 4, dst_org, stride); + dst_org += (4 * stride); + ST2x4_UB(diff3, 0, dst_org, stride); + dst_org += (4 * stride); + ST2x4_UB(diff3, 4, dst_org, stride); + dst_org += (4 * stride); + + dst += 2; + } +} + +static void intra_predict_vert_32x32_msa(const uint8_t *src, uint8_t *dst, + int32_t dst_stride) +{ + uint32_t row; + v16u8 src1, src2; + + src1 = LD_UB(src); + src2 = LD_UB(src + 16); + + for (row = 32; row--;) { + ST_UB2(src1, src2, dst, 16); + dst += dst_stride; + } +} + +void ff_hevc_intra_pred_planar_0_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride) +{ + hevc_intra_pred_plane_4x4_msa(src_top, src_left, dst, stride); +} + +void ff_hevc_intra_pred_planar_1_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride) +{ + hevc_intra_pred_plane_8x8_msa(src_top, src_left, dst, stride); +} + +void ff_hevc_intra_pred_planar_2_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride) +{ + hevc_intra_pred_plane_16x16_msa(src_top, src_left, dst, stride); +} + +void ff_hevc_intra_pred_planar_3_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride) +{ + hevc_intra_pred_plane_32x32_msa(src_top, src_left, dst, stride); +} + +void ff_hevc_intra_pred_dc_msa(uint8_t *dst, const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride, int log2, int c_idx) +{ + switch (log2) { + case 2: + hevc_intra_pred_dc_4x4_msa(src_top, src_left, dst, stride, c_idx); + break; + + case 3: + hevc_intra_pred_dc_8x8_msa(src_top, src_left, dst, stride, c_idx); + break; + + case 4: + hevc_intra_pred_dc_16x16_msa(src_top, src_left, dst, stride, c_idx); + break; + + case 5: + hevc_intra_pred_dc_32x32_msa(src_top, src_left, dst, stride); + break; + } +} + +void ff_pred_intra_pred_angular_0_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride, int c_idx, int mode) +{ + if (mode == 10) { + hevc_intra_pred_horiz_4x4_msa(src_top, src_left, dst, stride, c_idx); + } else if (mode == 26) { + hevc_intra_pred_vert_4x4_msa(src_top, src_left, dst, stride, c_idx); + } else if (mode >= 18) { + hevc_intra_pred_angular_upper_4width_msa(src_top, src_left, + dst, stride, mode); + } else { + hevc_intra_pred_angular_lower_4width_msa(src_top, src_left, + dst, stride, mode); + } +} + +void ff_pred_intra_pred_angular_1_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride, int c_idx, int mode) +{ + if (mode == 10) { + hevc_intra_pred_horiz_8x8_msa(src_top, src_left, dst, stride, c_idx); + } else if (mode == 26) { + hevc_intra_pred_vert_8x8_msa(src_top, src_left, dst, stride, c_idx); + } else if (mode >= 18) { + hevc_intra_pred_angular_upper_8width_msa(src_top, src_left, + dst, stride, mode); + } else { + hevc_intra_pred_angular_lower_8width_msa(src_top, src_left, + dst, stride, mode); + } +} + +void ff_pred_intra_pred_angular_2_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride, int c_idx, int mode) +{ + if (mode == 10) { + hevc_intra_pred_horiz_16x16_msa(src_top, src_left, dst, stride, c_idx); + } else if (mode == 26) { + hevc_intra_pred_vert_16x16_msa(src_top, src_left, dst, stride, c_idx); + } else if (mode >= 18) { + hevc_intra_pred_angular_upper_16width_msa(src_top, src_left, + dst, stride, mode); + } else { + hevc_intra_pred_angular_lower_16width_msa(src_top, src_left, + dst, stride, mode); + } +} + +void ff_pred_intra_pred_angular_3_msa(uint8_t *dst, + const uint8_t *src_top, + const uint8_t *src_left, + ptrdiff_t stride, int c_idx, int mode) +{ + if (mode == 10) { + hevc_intra_pred_horiz_32x32_msa(src_top, src_left, dst, stride); + } else if (mode == 26) { + intra_predict_vert_32x32_msa(src_top, dst, stride); + } else if (mode >= 18) { + hevc_intra_pred_angular_upper_32width_msa(src_top, src_left, + dst, stride, mode); + } else { + hevc_intra_pred_angular_lower_32width_msa(src_top, src_left, + dst, stride, mode); + } +} + +void ff_intra_pred_8_16x16_msa(HEVCContext *s, int x0, int y0, int c_idx) +{ + v16u8 vec0; + HEVCLocalContext *lc = s->HEVClc; + int i; + int hshift = s->sps->hshift[c_idx]; + int vshift = s->sps->vshift[c_idx]; + int size_in_luma_h = 16 << hshift; + int size_in_tbs_h = size_in_luma_h >> s->sps->log2_min_tb_size; + int size_in_luma_v = 16 << vshift; + int size_in_tbs_v = size_in_luma_v >> s->sps->log2_min_tb_size; + int x = x0 >> hshift; + int y = y0 >> vshift; + int x_tb = (x0 >> s->sps->log2_min_tb_size) & s->sps->tb_mask; + int y_tb = (y0 >> s->sps->log2_min_tb_size) & s->sps->tb_mask; + + int cur_tb_addr = + s->pps->min_tb_addr_zs[(y_tb) * (s->sps->tb_mask + 2) + (x_tb)]; + + ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(uint8_t); + uint8_t *src = (uint8_t *) s->frame->data[c_idx] + x + y * stride; + + int min_pu_width = s->sps->min_pu_width; + + enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c : + lc->tu.intra_pred_mode; + uint32_t a; + uint8_t left_array[2 * 32 + 1]; + uint8_t filtered_left_array[2 * 32 + 1]; + uint8_t top_array[2 * 32 + 1]; + uint8_t filtered_top_array[2 * 32 + 1]; + + uint8_t *left = left_array + 1; + uint8_t *top = top_array + 1; + uint8_t *filtered_left = filtered_left_array + 1; + uint8_t *filtered_top = filtered_top_array + 1; + int cand_bottom_left = lc->na.cand_bottom_left + && cur_tb_addr > + s->pps->min_tb_addr_zs[((y_tb + size_in_tbs_v) & s->sps->tb_mask) * + (s->sps->tb_mask + 2) + (x_tb - 1)]; + int cand_left = lc->na.cand_left; + int cand_up_left = lc->na.cand_up_left; + int cand_up = lc->na.cand_up; + int cand_up_right = lc->na.cand_up_right + && cur_tb_addr > + s->pps->min_tb_addr_zs[(y_tb - 1) * (s->sps->tb_mask + 2) + + ((x_tb + size_in_tbs_h) & s->sps->tb_mask)]; + + int bottom_left_size = + (((y0 + 2 * size_in_luma_v) > + (s->sps->height) ? (s->sps->height) : (y0 + + 2 * size_in_luma_v)) - + (y0 + size_in_luma_v)) >> vshift; + int top_right_size = + (((x0 + 2 * size_in_luma_h) > + (s->sps->width) ? (s->sps->width) : (x0 + 2 * size_in_luma_h)) - + (x0 + size_in_luma_h)) >> hshift; + + if (s->pps->constrained_intra_pred_flag == 1) { + int size_in_luma_pu_v = ((size_in_luma_v) >> s->sps->log2_min_pu_size); + int size_in_luma_pu_h = ((size_in_luma_h) >> s->sps->log2_min_pu_size); + int on_pu_edge_x = !(x0 & ((1 << s->sps->log2_min_pu_size) - 1)); + int on_pu_edge_y = !(y0 & ((1 << s->sps->log2_min_pu_size) - 1)); + if (!size_in_luma_pu_h) + size_in_luma_pu_h++; + if (cand_bottom_left == 1 && on_pu_edge_x) { + int x_left_pu = ((x0 - 1) >> s->sps->log2_min_pu_size); + int y_bottom_pu = + ((y0 + size_in_luma_v) >> s->sps->log2_min_pu_size); + int max = + ((size_in_luma_pu_v) > + (s->sps->min_pu_height - + y_bottom_pu) ? (s->sps->min_pu_height - + y_bottom_pu) : (size_in_luma_pu_v)); + cand_bottom_left = 0; + for (i = 0; i < max; i += 2) + cand_bottom_left |= + ((s->ref->tab_mvf[(x_left_pu) + + (y_bottom_pu + + i) * min_pu_width]).pred_flag == + PF_INTRA); + } + if (cand_left == 1 && on_pu_edge_x) { + int x_left_pu = ((x0 - 1) >> s->sps->log2_min_pu_size); + int y_left_pu = ((y0) >> s->sps->log2_min_pu_size); + int max = + ((size_in_luma_pu_v) > + (s->sps->min_pu_height - + y_left_pu) ? (s->sps->min_pu_height - + y_left_pu) : (size_in_luma_pu_v)); + cand_left = 0; + for (i = 0; i < max; i += 2) + cand_left |= + ((s->ref->tab_mvf[(x_left_pu) + + (y_left_pu + + i) * min_pu_width]).pred_flag == + PF_INTRA); + } + if (cand_up_left == 1) { + int x_left_pu = ((x0 - 1) >> s->sps->log2_min_pu_size); + int y_top_pu = ((y0 - 1) >> s->sps->log2_min_pu_size); + cand_up_left = + (s->ref->tab_mvf[(x_left_pu) + + (y_top_pu) * min_pu_width]).pred_flag == + PF_INTRA; + } + if (cand_up == 1 && on_pu_edge_y) { + int x_top_pu = ((x0) >> s->sps->log2_min_pu_size); + int y_top_pu = ((y0 - 1) >> s->sps->log2_min_pu_size); + int max = + ((size_in_luma_pu_h) > + (s->sps->min_pu_width - + x_top_pu) ? (s->sps->min_pu_width - + x_top_pu) : (size_in_luma_pu_h)); + cand_up = 0; + for (i = 0; i < max; i += 2) + cand_up |= + ((s->ref->tab_mvf[(x_top_pu + i) + + (y_top_pu) * + min_pu_width]).pred_flag == PF_INTRA); + } + if (cand_up_right == 1 && on_pu_edge_y) { + int y_top_pu = ((y0 - 1) >> s->sps->log2_min_pu_size); + int x_right_pu = + ((x0 + size_in_luma_h) >> s->sps->log2_min_pu_size); + int max = + ((size_in_luma_pu_h) > + (s->sps->min_pu_width - + x_right_pu) ? (s->sps->min_pu_width - + x_right_pu) : (size_in_luma_pu_h)); + cand_up_right = 0; + for (i = 0; i < max; i += 2) + cand_up_right |= + ((s->ref->tab_mvf[(x_right_pu + i) + + (y_top_pu) * + min_pu_width]).pred_flag == PF_INTRA); + } + + vec0 = (v16u8) __msa_ldi_b(128); + + ST_UB4(vec0, vec0, vec0, vec0, left, 16); + + ST_UB4(vec0, vec0, vec0, vec0, top, 16); + + top[-1] = 128; + } + if (cand_up_left) { + left[-1] = src[(-1) + stride * (-1)]; + top[-1] = left[-1]; + } + if (cand_up) { + vec0 = LD_UB(src - stride); + ST_UB(vec0, top); + } + if (cand_up_right) { + vec0 = LD_UB(src - stride + 16); + ST_UB(vec0, (top + 16)); + + do { + uint32_t pix = + ((src[(16 + top_right_size - 1) + stride * (-1)]) * + 0x01010101U); + for (i = 0; i < (16 - top_right_size); i += 4) + ((((union unaligned_32 *) (top + 16 + top_right_size + + i))->l) = (pix)); + } while (0); + } + if (cand_left) + for (i = 0; i < 16; i++) + left[i] = src[(-1) + stride * (i)]; + if (cand_bottom_left) { + for (i = 16; i < 16 + bottom_left_size; i++) + left[i] = src[(-1) + stride * (i)]; + do { + uint32_t pix = + ((src[(-1) + stride * (16 + bottom_left_size - 1)]) * + 0x01010101U); + for (i = 0; i < (16 - bottom_left_size); i += 4) + ((((union unaligned_32 *) (left + 16 + bottom_left_size + + i))->l) = (pix)); + } while (0); + } + + if (s->pps->constrained_intra_pred_flag == 1) { + if (cand_bottom_left || cand_left || cand_up_left || cand_up + || cand_up_right) { + int size_max_x = + x0 + ((2 * 16) << hshift) < + s->sps->width ? 2 * 16 : (s->sps->width - x0) >> hshift; + int size_max_y = + y0 + ((2 * 16) << vshift) < + s->sps->height ? 2 * 16 : (s->sps->height - y0) >> vshift; + int j = 16 + (cand_bottom_left ? bottom_left_size : 0) - 1; + if (!cand_up_right) { + size_max_x = x0 + ((16) << hshift) < s->sps->width ? + 16 : (s->sps->width - x0) >> hshift; + } + if (!cand_bottom_left) { + size_max_y = y0 + ((16) << vshift) < s->sps->height ? + 16 : (s->sps->height - y0) >> vshift; + } + if (cand_bottom_left || cand_left || cand_up_left) { + while (j > -1 + && + !((s->ref->tab_mvf[(((x0 + + ((-1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + + ((j) << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + j--; + if (! + ((s->ref->tab_mvf[(((x0 + + ((-1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + ((j) + << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == PF_INTRA)) { + j = 0; + while (j < size_max_x + && + !((s->ref->tab_mvf[(((x0 + + ((j) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + + ((-1) << + vshift)) + >> s-> + sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + j++; + for (i = j; i > (j) - (j + 1); i--) + if (! + ((s->ref->tab_mvf[(((x0 + + ((i - + 1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + + ((-1) << + vshift)) + >> s-> + sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + top[i - 1] = top[i]; + left[-1] = top[-1]; + } + } else { + j = 0; + while (j < size_max_x + && + !((s->ref->tab_mvf[(((x0 + + ((j) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + ((-1) + << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + j++; + if (j > 0) + if (x0 > 0) { + for (i = j; i > (j) - (j + 1); i--) + if (! + ((s->ref->tab_mvf[(((x0 + + ((i - + 1) << hshift)) >> + s->sps->log2_min_pu_size)) + + (((y0 + ((-1) + << vshift)) + >> + s->sps->log2_min_pu_size)) + * + min_pu_width]).pred_flag == + PF_INTRA)) + top[i - 1] = top[i]; + } else { + for (i = j; i > (j) - (j); i--) + if (! + ((s->ref->tab_mvf[(((x0 + + ((i - + 1) << hshift)) >> + s->sps->log2_min_pu_size)) + + (((y0 + ((-1) + << vshift)) + >> + s->sps->log2_min_pu_size)) + * + min_pu_width]).pred_flag == + PF_INTRA)) + top[i - 1] = top[i]; + top[-1] = top[0]; + } + left[-1] = top[-1]; + } + left[-1] = top[-1]; + if (cand_bottom_left || cand_left) { + a = ((left[-1]) * 0x01010101U); + for (i = 0; i < (0) + (size_max_y); i += 4) + if (! + ((s->ref->tab_mvf[(((x0 + + ((-1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + + ((i) << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + ((((union unaligned_32 *) (&left[i]))->l) = (a)); + else + a = ((left[i + 3]) * 0x01010101U); + } + if (!cand_left) { + vec0 = (v16u8) __msa_fill_b(left[-1]); + + ST_UB(vec0, left); + } + if (!cand_bottom_left) { + + vec0 = (v16u8) __msa_fill_b(left[15]); + + ST_UB(vec0, (left + 16)); + } + if (x0 != 0 && y0 != 0) { + a = ((left[size_max_y - 1]) * 0x01010101U); + for (i = (size_max_y - 1); + i > (size_max_y - 1) - (size_max_y); i -= 4) + if (! + ((s->ref->tab_mvf[(((x0 + + ((-1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + + ((i - + 3) << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + ((((union unaligned_32 *) (&left[i - 3]))->l) = (a)); + else + a = ((left[i - 3]) * 0x01010101U); + if (! + ((s->ref->tab_mvf[(((x0 + + ((-1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + ((-1) + << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == PF_INTRA)) + left[-1] = left[0]; + } else if (x0 == 0) { + do { + uint32_t pix = ((0) * 0x01010101U); + for (i = 0; i < (size_max_y); i += 4) + ((((union unaligned_32 *) (left + i))->l) = (pix)); + } while (0); + } else { + a = ((left[size_max_y - 1]) * 0x01010101U); + for (i = (size_max_y - 1); + i > (size_max_y - 1) - (size_max_y); i -= 4) + if (! + ((s->ref->tab_mvf[(((x0 + + ((-1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + + ((i - + 3) << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + ((((union unaligned_32 *) (&left[i - 3]))->l) = (a)); + else + a = ((left[i - 3]) * 0x01010101U); + } + top[-1] = left[-1]; + if (y0 != 0) { + a = ((left[-1]) * 0x01010101U); + for (i = 0; i < (0) + (size_max_x); i += 4) + if (! + ((s->ref->tab_mvf[(((x0 + + ((i) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + ((-1) + << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + ((((union unaligned_32 *) (&top[i]))->l) = (a)); + else + a = ((top[i + 3]) * 0x01010101U); + } + } + } + + if (!cand_bottom_left) { + if (cand_left) { + vec0 = (v16u8) __msa_fill_b(left[15]); + + ST_UB(vec0, (left + 16)); + + } else if (cand_up_left) { + vec0 = (v16u8) __msa_fill_b(left[-1]); + + ST_UB2(vec0, vec0, left, 16); + + cand_left = 1; + } else if (cand_up) { + left[-1] = top[0]; + + vec0 = (v16u8) __msa_fill_b(left[-1]); + + ST_UB2(vec0, vec0, left, 16); + + cand_up_left = 1; + cand_left = 1; + } else if (cand_up_right) { + vec0 = (v16u8) __msa_fill_b(top[16]); + + ST_UB(vec0, top); + + left[-1] = top[16]; + + ST_UB2(vec0, vec0, left, 16); + + cand_up = 1; + cand_up_left = 1; + cand_left = 1; + } else { + left[-1] = 128; + vec0 = (v16u8) __msa_ldi_b(128); + + ST_UB2(vec0, vec0, top, 16); + ST_UB2(vec0, vec0, left, 16); + } + } + + if (!cand_left) { + vec0 = (v16u8) __msa_fill_b(left[16]); + ST_UB(vec0, left); + } + if (!cand_up_left) { + left[-1] = left[0]; + } + if (!cand_up) { + vec0 = (v16u8) __msa_fill_b(left[-1]); + ST_UB(vec0, top); + } + if (!cand_up_right) { + vec0 = (v16u8) __msa_fill_b(top[15]); + ST_UB(vec0, (top + 16)); + } + + top[-1] = left[-1]; + + + if (!s->sps->intra_smoothing_disabled_flag + && (c_idx == 0 || s->sps->chroma_format_idc == 3)) { + if (mode != INTRA_DC && 16 != 4) { + int intra_hor_ver_dist_thresh[] = { 7, 1, 0 }; + int min_dist_vert_hor = + (((((int) (mode - 26U)) >= + 0 ? ((int) (mode - 26U)) : (-((int) (mode - 26U))))) > + ((((int) (mode - 10U)) >= + 0 ? ((int) (mode - 10U)) : (-((int) (mode - 10U))))) + ? ((((int) (mode - 10U)) >= + 0 ? ((int) (mode - 10U)) : (-((int) (mode - 10U))))) + : ((((int) (mode - 26U)) >= + 0 ? ((int) (mode - 26U)) : (-((int) (mode - 26U)))))); + if (min_dist_vert_hor > intra_hor_ver_dist_thresh[4 - 3]) { + filtered_left[2 * 16 - 1] = left[2 * 16 - 1]; + filtered_top[2 * 16 - 1] = top[2 * 16 - 1]; + for (i = 2 * 16 - 2; i >= 0; i--) + filtered_left[i] = (left[i + 1] + 2 * left[i] + + left[i - 1] + 2) >> 2; + filtered_top[-1] = + filtered_left[-1] = + (left[0] + 2 * left[-1] + top[0] + 2) >> 2; + for (i = 2 * 16 - 2; i >= 0; i--) + filtered_top[i] = (top[i + 1] + 2 * top[i] + + top[i - 1] + 2) >> 2; + left = filtered_left; + top = filtered_top; + } + } + } + + switch (mode) { + case INTRA_PLANAR: + s->hpc.pred_planar[4 - 2] ((uint8_t *) src, (uint8_t *) top, + (uint8_t *) left, stride); + break; + case INTRA_DC: + s->hpc.pred_dc((uint8_t *) src, (uint8_t *) top, + (uint8_t *) left, stride, 4, c_idx); + break; + default: + s->hpc.pred_angular[4 - 2] ((uint8_t *) src, (uint8_t *) top, + (uint8_t *) left, stride, c_idx, mode); + break; + } +} + +void ff_intra_pred_8_32x32_msa(HEVCContext *s, int x0, int y0, int c_idx) +{ + v16u8 vec0, vec1; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v8i16 res0, res1, res2, res3; + v8i16 mul_val0 = { 63, 62, 61, 60, 59, 58, 57, 56 }; + v8i16 mul_val1 = { 1, 2, 3, 4, 5, 6, 7, 8 }; + HEVCLocalContext *lc = s->HEVClc; + int i; + int hshift = s->sps->hshift[c_idx]; + int vshift = s->sps->vshift[c_idx]; + int size_in_luma_h = 32 << hshift; + int size_in_tbs_h = size_in_luma_h >> s->sps->log2_min_tb_size; + int size_in_luma_v = 32 << vshift; + int size_in_tbs_v = size_in_luma_v >> s->sps->log2_min_tb_size; + int x = x0 >> hshift; + int y = y0 >> vshift; + int x_tb = (x0 >> s->sps->log2_min_tb_size) & s->sps->tb_mask; + int y_tb = (y0 >> s->sps->log2_min_tb_size) & s->sps->tb_mask; + + int cur_tb_addr = + s->pps->min_tb_addr_zs[(y_tb) * (s->sps->tb_mask + 2) + (x_tb)]; + + ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(uint8_t); + uint8_t *src = (uint8_t *) s->frame->data[c_idx] + x + y * stride; + + int min_pu_width = s->sps->min_pu_width; + + enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c : + lc->tu.intra_pred_mode; + uint32_t a; + uint8_t left_array[2 * 32 + 1]; + uint8_t filtered_left_array[2 * 32 + 1]; + uint8_t top_array[2 * 32 + 1]; + uint8_t filtered_top_array[2 * 32 + 1]; + + uint8_t *left = left_array + 1; + uint8_t *top = top_array + 1; + uint8_t *filtered_left = filtered_left_array + 1; + uint8_t *filtered_top = filtered_top_array + 1; + int cand_bottom_left = lc->na.cand_bottom_left + && cur_tb_addr > + s->pps->min_tb_addr_zs[((y_tb + size_in_tbs_v) & s->sps->tb_mask) * + (s->sps->tb_mask + 2) + (x_tb - 1)]; + int cand_left = lc->na.cand_left; + int cand_up_left = lc->na.cand_up_left; + int cand_up = lc->na.cand_up; + int cand_up_right = lc->na.cand_up_right + && cur_tb_addr > + s->pps->min_tb_addr_zs[(y_tb - 1) * (s->sps->tb_mask + 2) + + ((x_tb + size_in_tbs_h) & s->sps->tb_mask)]; + + int bottom_left_size = + (((y0 + 2 * size_in_luma_v) > + (s->sps->height) ? (s->sps->height) : (y0 + + 2 * size_in_luma_v)) - + (y0 + size_in_luma_v)) >> vshift; + int top_right_size = + (((x0 + 2 * size_in_luma_h) > + (s->sps->width) ? (s->sps->width) : (x0 + 2 * size_in_luma_h)) - + (x0 + size_in_luma_h)) >> hshift; + + if (s->pps->constrained_intra_pred_flag == 1) { + int size_in_luma_pu_v = ((size_in_luma_v) >> s->sps->log2_min_pu_size); + int size_in_luma_pu_h = ((size_in_luma_h) >> s->sps->log2_min_pu_size); + int on_pu_edge_x = !(x0 & ((1 << s->sps->log2_min_pu_size) - 1)); + int on_pu_edge_y = !(y0 & ((1 << s->sps->log2_min_pu_size) - 1)); + if (!size_in_luma_pu_h) + size_in_luma_pu_h++; + if (cand_bottom_left == 1 && on_pu_edge_x) { + int x_left_pu = ((x0 - 1) >> s->sps->log2_min_pu_size); + int y_bottom_pu = + ((y0 + size_in_luma_v) >> s->sps->log2_min_pu_size); + int max = + ((size_in_luma_pu_v) > + (s->sps->min_pu_height - + y_bottom_pu) ? (s->sps->min_pu_height - + y_bottom_pu) : (size_in_luma_pu_v)); + cand_bottom_left = 0; + for (i = 0; i < max; i += 2) + cand_bottom_left |= + ((s->ref->tab_mvf[(x_left_pu) + + (y_bottom_pu + + i) * min_pu_width]).pred_flag == + PF_INTRA); + } + if (cand_left == 1 && on_pu_edge_x) { + int x_left_pu = ((x0 - 1) >> s->sps->log2_min_pu_size); + int y_left_pu = ((y0) >> s->sps->log2_min_pu_size); + int max = + ((size_in_luma_pu_v) > + (s->sps->min_pu_height - + y_left_pu) ? (s->sps->min_pu_height - + y_left_pu) : (size_in_luma_pu_v)); + cand_left = 0; + for (i = 0; i < max; i += 2) + cand_left |= + ((s->ref->tab_mvf[(x_left_pu) + + (y_left_pu + + i) * min_pu_width]).pred_flag == + PF_INTRA); + } + if (cand_up_left == 1) { + int x_left_pu = ((x0 - 1) >> s->sps->log2_min_pu_size); + int y_top_pu = ((y0 - 1) >> s->sps->log2_min_pu_size); + cand_up_left = + (s->ref->tab_mvf[(x_left_pu) + + (y_top_pu) * min_pu_width]).pred_flag == + PF_INTRA; + } + if (cand_up == 1 && on_pu_edge_y) { + int x_top_pu = ((x0) >> s->sps->log2_min_pu_size); + int y_top_pu = ((y0 - 1) >> s->sps->log2_min_pu_size); + int max = + ((size_in_luma_pu_h) > + (s->sps->min_pu_width - + x_top_pu) ? (s->sps->min_pu_width - + x_top_pu) : (size_in_luma_pu_h)); + cand_up = 0; + for (i = 0; i < max; i += 2) + cand_up |= + ((s->ref->tab_mvf[(x_top_pu + i) + + (y_top_pu) * + min_pu_width]).pred_flag == PF_INTRA); + } + if (cand_up_right == 1 && on_pu_edge_y) { + int y_top_pu = ((y0 - 1) >> s->sps->log2_min_pu_size); + int x_right_pu = + ((x0 + size_in_luma_h) >> s->sps->log2_min_pu_size); + int max = + ((size_in_luma_pu_h) > + (s->sps->min_pu_width - + x_right_pu) ? (s->sps->min_pu_width - + x_right_pu) : (size_in_luma_pu_h)); + cand_up_right = 0; + for (i = 0; i < max; i += 2) + cand_up_right |= + ((s->ref->tab_mvf[(x_right_pu + i) + + (y_top_pu) * + min_pu_width]).pred_flag == PF_INTRA); + } + vec0 = (v16u8) __msa_ldi_b(128); + + ST_UB4(vec0, vec0, vec0, vec0, left, 16); + ST_UB4(vec0, vec0, vec0, vec0, top, 16); + + top[-1] = 128; + } + if (cand_up_left) { + left[-1] = src[(-1) + stride * (-1)]; + top[-1] = left[-1]; + } + if (cand_up) { + LD_UB2(src - stride, 16, vec0, vec1); + ST_UB2(vec0, vec1, top, 16); + } + + if (cand_up_right) { + LD_UB2(src - stride + 32, 16, vec0, vec1); + ST_UB2(vec0, vec1, (top + 32), 16); + do { + uint32_t pix = + ((src[(32 + top_right_size - 1) + stride * (-1)]) * + 0x01010101U); + for (i = 0; i < (32 - top_right_size); i += 4) + ((((union unaligned_32 *) (top + 32 + top_right_size + + i))->l) = (pix)); + } while (0); + } + if (cand_left) + for (i = 0; i < 32; i++) + left[i] = src[(-1) + stride * (i)]; + if (cand_bottom_left) { + for (i = 32; i < 32 + bottom_left_size; i++) + left[i] = src[(-1) + stride * (i)]; + do { + uint32_t pix = + ((src[(-1) + stride * (32 + bottom_left_size - 1)]) * + 0x01010101U); + for (i = 0; i < (32 - bottom_left_size); i += 4) + ((((union unaligned_32 *) (left + 32 + bottom_left_size + + i))->l) = (pix)); + } while (0); + } + + if (s->pps->constrained_intra_pred_flag == 1) { + if (cand_bottom_left || cand_left || cand_up_left || cand_up + || cand_up_right) { + int size_max_x = + x0 + ((2 * 32) << hshift) < + s->sps->width ? 2 * 32 : (s->sps->width - x0) >> hshift; + int size_max_y = + y0 + ((2 * 32) << vshift) < + s->sps->height ? 2 * 32 : (s->sps->height - y0) >> vshift; + int j = 32 + (cand_bottom_left ? bottom_left_size : 0) - 1; + if (!cand_up_right) { + size_max_x = x0 + ((32) << hshift) < s->sps->width ? + 32 : (s->sps->width - x0) >> hshift; + } + if (!cand_bottom_left) { + size_max_y = y0 + ((32) << vshift) < s->sps->height ? + 32 : (s->sps->height - y0) >> vshift; + } + if (cand_bottom_left || cand_left || cand_up_left) { + while (j > -1 + && + !((s->ref->tab_mvf[(((x0 + + ((-1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + + ((j) << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + j--; + if (! + ((s->ref->tab_mvf[(((x0 + + ((-1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + ((j) + << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == PF_INTRA)) { + j = 0; + while (j < size_max_x + && + !((s->ref->tab_mvf[(((x0 + + ((j) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + + ((-1) << + vshift)) + >> s-> + sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + j++; + for (i = j; i > (j) - (j + 1); i--) + if (! + ((s->ref->tab_mvf[(((x0 + + ((i - + 1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + + ((-1) << + vshift)) + >> s-> + sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + top[i - 1] = top[i]; + left[-1] = top[-1]; + } + } else { + j = 0; + while (j < size_max_x + && + !((s->ref->tab_mvf[(((x0 + + ((j) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + ((-1) + << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + j++; + if (j > 0) + if (x0 > 0) { + for (i = j; i > (j) - (j + 1); i--) + if (! + ((s->ref->tab_mvf[(((x0 + + ((i - + 1) << hshift)) >> + s->sps->log2_min_pu_size)) + + (((y0 + ((-1) + << vshift)) + >> + s->sps->log2_min_pu_size)) + * + min_pu_width]).pred_flag == + PF_INTRA)) + top[i - 1] = top[i]; + } else { + for (i = j; i > (j) - (j); i--) + if (! + ((s->ref->tab_mvf[(((x0 + + ((i - + 1) << hshift)) >> + s->sps->log2_min_pu_size)) + + (((y0 + ((-1) + << vshift)) + >> + s->sps->log2_min_pu_size)) + * + min_pu_width]).pred_flag == + PF_INTRA)) + top[i - 1] = top[i]; + top[-1] = top[0]; + } + left[-1] = top[-1]; + } + left[-1] = top[-1]; + if (cand_bottom_left || cand_left) { + a = ((left[-1]) * 0x01010101U); + for (i = 0; i < (0) + (size_max_y); i += 4) + if (! + ((s->ref->tab_mvf[(((x0 + + ((-1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + + ((i) << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + ((((union unaligned_32 *) (&left[i]))->l) = (a)); + else + a = ((left[i + 3]) * 0x01010101U); + } + if (!cand_left) { + vec0 = (v16u8) __msa_fill_b(left[-1]); + + ST_UB2(vec0, vec0, left, 16); + } + if (!cand_bottom_left) { + vec0 = (v16u8) __msa_fill_b(left[31]); + + ST_UB2(vec0, vec0, (left + 32), 16); + } + if (x0 != 0 && y0 != 0) { + a = ((left[size_max_y - 1]) * 0x01010101U); + for (i = (size_max_y - 1); + i > (size_max_y - 1) - (size_max_y); i -= 4) + if (! + ((s->ref->tab_mvf[(((x0 + + ((-1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + + ((i - + 3) << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + ((((union unaligned_32 *) (&left[i - 3]))->l) = (a)); + else + a = ((left[i - 3]) * 0x01010101U); + if (! + ((s->ref->tab_mvf[(((x0 + + ((-1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + ((-1) + << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == PF_INTRA)) + left[-1] = left[0]; + } else if (x0 == 0) { + do { + uint32_t pix = ((0) * 0x01010101U); + for (i = 0; i < (size_max_y); i += 4) + ((((union unaligned_32 *) (left + i))->l) = (pix)); + } while (0); + } else { + a = ((left[size_max_y - 1]) * 0x01010101U); + for (i = (size_max_y - 1); + i > (size_max_y - 1) - (size_max_y); i -= 4) + if (! + ((s->ref->tab_mvf[(((x0 + + ((-1) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + + ((i - + 3) << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + ((((union unaligned_32 *) (&left[i - 3]))->l) = (a)); + else + a = ((left[i - 3]) * 0x01010101U); + } + top[-1] = left[-1]; + if (y0 != 0) { + a = ((left[-1]) * 0x01010101U); + for (i = 0; i < (0) + (size_max_x); i += 4) + if (! + ((s->ref->tab_mvf[(((x0 + + ((i) << hshift)) >> s->sps-> + log2_min_pu_size)) + (((y0 + ((-1) + << + vshift)) + >> s->sps-> + log2_min_pu_size)) + * min_pu_width]).pred_flag == + PF_INTRA)) + ((((union unaligned_32 *) (&top[i]))->l) = (a)); + else + a = ((top[i + 3]) * 0x01010101U); + } + } + } + + if (!cand_bottom_left) { + if (cand_left) { + vec0 = (v16u8) __msa_fill_b(left[31]); + + ST_UB2(vec0, vec0, (left + 32), 16); + } else if (cand_up_left) { + vec0 = (v16u8) __msa_fill_b(left[-1]); + + ST_UB4(vec0, vec0, vec0, vec0, left, 16); + + cand_left = 1; + } else if (cand_up) { + left[-1] = top[0]; + + vec0 = (v16u8) __msa_fill_b(left[-1]); + + ST_UB4(vec0, vec0, vec0, vec0, left, 16); + + cand_up_left = 1; + cand_left = 1; + } else if (cand_up_right) { + vec0 = (v16u8) __msa_fill_b(top[32]); + + ST_UB2(vec0, vec0, top, 16); + + left[-1] = top[32]; + + ST_UB4(vec0, vec0, vec0, vec0, left, 16); + + cand_up = 1; + cand_up_left = 1; + cand_left = 1; + } else { + left[-1] = 128; + + vec0 = (v16u8) __msa_ldi_b(128); + + ST_UB4(vec0, vec0, vec0, vec0, top, 16); + ST_UB4(vec0, vec0, vec0, vec0, left, 16); + } + } + + if (!cand_left) { + vec0 = (v16u8) __msa_fill_b(left[32]); + + ST_UB2(vec0, vec0, left, 16); + } + if (!cand_up_left) { + left[-1] = left[0]; + } + if (!cand_up) { + vec0 = (v16u8) __msa_fill_b(left[-1]); + + ST_UB2(vec0, vec0, top, 16); + } + if (!cand_up_right) { + vec0 = (v16u8) __msa_fill_b(top[31]); + + ST_UB2(vec0, vec0, (top + 32), 16); + } + + top[-1] = left[-1]; + + + if (!s->sps->intra_smoothing_disabled_flag + && (c_idx == 0 || s->sps->chroma_format_idc == 3)) { + if (mode != INTRA_DC && 32 != 4) { + int intra_hor_ver_dist_thresh[] = { 7, 1, 0 }; + int min_dist_vert_hor = + (((((int) (mode - 26U)) >= + 0 ? ((int) (mode - 26U)) : (-((int) (mode - 26U))))) > + ((((int) (mode - 10U)) >= + 0 ? ((int) (mode - 10U)) : (-((int) (mode - 10U))))) + ? ((((int) (mode - 10U)) >= + 0 ? ((int) (mode - 10U)) : (-((int) (mode - 10U))))) + : ((((int) (mode - 26U)) >= + 0 ? ((int) (mode - 26U)) : (-((int) (mode - 26U)))))); + if (min_dist_vert_hor > intra_hor_ver_dist_thresh[5 - 3]) { + int threshold = 1 << (8 - 5); + if (s->sps->sps_strong_intra_smoothing_enable_flag + && c_idx == 0 + && ((top[-1] + top[63] - 2 * top[31]) >= + 0 ? (top[-1] + top[63] - + 2 * top[31]) : (-(top[-1] + top[63] - + 2 * top[31]))) < threshold + && ((left[-1] + left[63] - 2 * left[31]) >= + 0 ? (left[-1] + left[63] - + 2 * left[31]) : (-(left[-1] + left[63] - + 2 * left[31]))) < threshold) { + + + filtered_top[-1] = top[-1]; + filtered_top[63] = top[63]; + + + for (i = 0; i < 63; i++) { + filtered_top[i] = + ((63 - i) * top[-1] + (i + 1) * top[63] + 32) >> 6; + } + + tmp0 = __msa_fill_h(top[-1]); + tmp1 = __msa_fill_h(top[63]); + + tmp2 = mul_val0 - 8; + tmp3 = mul_val0 - 16; + tmp4 = mul_val0 - 24; + tmp5 = mul_val1 + 8; + tmp6 = mul_val1 + 16; + tmp7 = mul_val1 + 24; + + res0 = mul_val0 * tmp0; + res1 = tmp2 * tmp0; + res2 = tmp3 * tmp0; + res3 = tmp4 * tmp0; + res0 += mul_val1 * tmp1; + res1 += tmp5 * tmp1; + res2 += tmp6 * tmp1; + res3 += tmp7 * tmp1; + + res0 = __msa_srari_h(res0, 6); + res1 = __msa_srari_h(res1, 6); + res2 = __msa_srari_h(res2, 6); + res3 = __msa_srari_h(res3, 6); + + vec0 = (v16u8) __msa_pckev_b((v16i8) res1, (v16i8) res0); + vec1 = (v16u8) __msa_pckev_b((v16i8) res3, (v16i8) res2); + + ST_UB2(vec0, vec1, filtered_top, 16); + + res0 = mul_val0 - 32; + tmp2 = mul_val0 - 40; + tmp3 = mul_val0 - 48; + tmp4 = mul_val0 - 56; + res3 = mul_val1 + 32; + tmp5 = mul_val1 + 40; + tmp6 = mul_val1 + 48; + tmp7 = mul_val1 + 56; + + res0 = res0 * tmp0; + res1 = tmp2 * tmp0; + res2 = tmp3 * tmp0; + res0 += res3 * tmp1; + res3 = tmp4 * tmp0; + res1 += tmp5 * tmp1; + res2 += tmp6 * tmp1; + res3 += tmp7 * tmp1; + + res0 = __msa_srari_h(res0, 6); + res1 = __msa_srari_h(res1, 6); + res2 = __msa_srari_h(res2, 6); + res3 = __msa_srari_h(res3, 6); + + vec0 = (v16u8) __msa_pckev_b((v16i8) res1, (v16i8) res0); + vec1 = (v16u8) __msa_pckev_b((v16i8) res3, (v16i8) res2); + + ST_UB2(vec0, vec1, (filtered_top + 32), 16); + + filtered_top[63] = top[63]; + + tmp0 = __msa_fill_h(left[-1]); + tmp1 = __msa_fill_h(left[63]); + + tmp2 = mul_val0 - 8; + tmp3 = mul_val0 - 16; + tmp4 = mul_val0 - 24; + tmp5 = mul_val1 + 8; + tmp6 = mul_val1 + 16; + tmp7 = mul_val1 + 24; + + res0 = mul_val0 * tmp0; + res1 = tmp2 * tmp0; + res2 = tmp3 * tmp0; + res3 = tmp4 * tmp0; + res0 += mul_val1 * tmp1; + res1 += tmp5 * tmp1; + res2 += tmp6 * tmp1; + res3 += tmp7 * tmp1; + + res0 = __msa_srari_h(res0, 6); + res1 = __msa_srari_h(res1, 6); + res2 = __msa_srari_h(res2, 6); + res3 = __msa_srari_h(res3, 6); + + vec0 = (v16u8) __msa_pckev_b((v16i8) res1, (v16i8) res0); + vec1 = (v16u8) __msa_pckev_b((v16i8) res3, (v16i8) res2); + + ST_UB2(vec0, vec1, left, 16); + + res0 = mul_val0 - 32; + tmp2 = mul_val0 - 40; + tmp3 = mul_val0 - 48; + tmp4 = mul_val0 - 56; + res3 = mul_val1 + 32; + tmp5 = mul_val1 + 40; + tmp6 = mul_val1 + 48; + tmp7 = mul_val1 + 56; + + res0 = res0 * tmp0; + res1 = tmp2 * tmp0; + res2 = tmp3 * tmp0; + res0 += res3 * tmp1; + res3 = tmp4 * tmp0; + res1 += tmp5 * tmp1; + res2 += tmp6 * tmp1; + res3 += tmp7 * tmp1; + + res0 = __msa_srari_h(res0, 6); + res1 = __msa_srari_h(res1, 6); + res2 = __msa_srari_h(res2, 6); + res3 = __msa_srari_h(res3, 6); + + vec0 = (v16u8) __msa_pckev_b((v16i8) res1, (v16i8) res0); + vec1 = (v16u8) __msa_pckev_b((v16i8) res3, (v16i8) res2); + + ST_UB2(vec0, vec1, (left + 32), 16); + + left[63] = tmp1[0]; + + top = filtered_top; + } else { + filtered_left[2 * 32 - 1] = left[2 * 32 - 1]; + filtered_top[2 * 32 - 1] = top[2 * 32 - 1]; + for (i = 2 * 32 - 2; i >= 0; i--) + filtered_left[i] = (left[i + 1] + 2 * left[i] + + left[i - 1] + 2) >> 2; + filtered_top[-1] = + filtered_left[-1] = + (left[0] + 2 * left[-1] + top[0] + 2) >> 2; + for (i = 2 * 32 - 2; i >= 0; i--) + filtered_top[i] = (top[i + 1] + 2 * top[i] + + top[i - 1] + 2) >> 2; + left = filtered_left; + top = filtered_top; + } + } + } + } + + switch (mode) { + case INTRA_PLANAR: + s->hpc.pred_planar[3] ((uint8_t *) src, (uint8_t *) top, + (uint8_t *) left, stride); + break; + case INTRA_DC: + s->hpc.pred_dc((uint8_t *) src, (uint8_t *) top, + (uint8_t *) left, stride, 5, c_idx); + break; + default: + s->hpc.pred_angular[3] ((uint8_t *) src, (uint8_t *) top, + (uint8_t *) left, stride, c_idx, mode); + break; + } +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hpeldsp_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hpeldsp_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hpeldsp_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hpeldsp_init_mips.c 2015-06-19 17:20:03.000000000 +0000 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * + * 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 "../hpeldsp.h" +#include "libavcodec/mips/hpeldsp_mips.h" + +#if HAVE_MSA +static void ff_hpeldsp_init_msa(HpelDSPContext *c, int flags) +{ + c->put_pixels_tab[0][0] = ff_put_pixels16_msa; + c->put_pixels_tab[0][1] = ff_put_pixels16_x2_msa; + c->put_pixels_tab[0][2] = ff_put_pixels16_y2_msa; + c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_msa; + + c->put_pixels_tab[1][0] = ff_put_pixels8_msa; + c->put_pixels_tab[1][1] = ff_put_pixels8_x2_msa; + c->put_pixels_tab[1][2] = ff_put_pixels8_y2_msa; + c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_msa; + + c->put_pixels_tab[2][1] = ff_put_pixels4_x2_msa; + c->put_pixels_tab[2][2] = ff_put_pixels4_y2_msa; + c->put_pixels_tab[2][3] = ff_put_pixels4_xy2_msa; + + c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_msa; + c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_msa; + c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_msa; + c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_msa; + + c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_msa; + c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_msa; + c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_msa; + c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_msa; + + c->avg_pixels_tab[0][0] = ff_avg_pixels16_msa; + c->avg_pixels_tab[0][1] = ff_avg_pixels16_x2_msa; + c->avg_pixels_tab[0][2] = ff_avg_pixels16_y2_msa; + c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_msa; + + c->avg_pixels_tab[1][0] = ff_avg_pixels8_msa; + c->avg_pixels_tab[1][1] = ff_avg_pixels8_x2_msa; + c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_msa; + c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_msa; + + c->avg_pixels_tab[2][0] = ff_avg_pixels4_msa; + c->avg_pixels_tab[2][1] = ff_avg_pixels4_x2_msa; + c->avg_pixels_tab[2][2] = ff_avg_pixels4_y2_msa; + c->avg_pixels_tab[2][3] = ff_avg_pixels4_xy2_msa; +} +#endif // #if HAVE_MSA + +void ff_hpeldsp_init_mips(HpelDSPContext *c, int flags) +{ +#if HAVE_MSA + ff_hpeldsp_init_msa(c, flags); +#endif // #if HAVE_MSA +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hpeldsp_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hpeldsp_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hpeldsp_mips.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hpeldsp_mips.h 2015-06-19 17:20:03.000000000 +0000 @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * + * 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 + */ + +#ifndef AVCODEC_MIPS_HPELDSP_MIPS_H +#define AVCODEC_MIPS_HPELDSP_MIPS_H + +#include "libavcodec/bit_depth_template.c" + +void ff_put_pixels16_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_pixels16_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_pixels16_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_pixels16_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_pixels8_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_pixels8_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_pixels8_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_pixels8_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_pixels4_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_pixels4_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_pixels4_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_pixels4_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_no_rnd_pixels16_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_no_rnd_pixels16_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_no_rnd_pixels16_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_no_rnd_pixels8_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_no_rnd_pixels8_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_put_no_rnd_pixels8_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_avg_pixels16_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_avg_pixels16_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_avg_pixels16_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_avg_pixels16_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_avg_pixels8_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_avg_pixels8_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_avg_pixels8_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_avg_pixels8_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_avg_pixels4_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_avg_pixels4_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_avg_pixels4_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); +void ff_avg_pixels4_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int32_t h); + +#endif // #ifndef AVCODEC_MIPS_HPELDSP_MIPS_H diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hpeldsp_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hpeldsp_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/hpeldsp_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/hpeldsp_msa.c 2015-06-19 17:20:03.000000000 +0000 @@ -0,0 +1,1498 @@ +/* + * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "libavcodec/mips/hpeldsp_mips.h" + +#define PCKEV_AVG_ST_UB(in0, in1, dst, pdst) \ +{ \ + v16u8 tmp_m; \ + \ + tmp_m = (v16u8) __msa_pckev_b((v16i8) in0, (v16i8) in1); \ + tmp_m = __msa_aver_u_b(tmp_m, (v16u8) dst); \ + ST_UB(tmp_m, (pdst)); \ +} + +#define PCKEV_ST_SB4(in0, in1, in2, in3, in4, in5, in6, in7, pdst, stride) \ +{ \ + v16i8 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + uint8_t *pdst_m = (uint8_t *) (pdst); \ + \ + PCKEV_B4_SB(in0, in1, in2, in3, in4, in5, in6, in7, \ + tmp0_m, tmp1_m, tmp2_m, tmp3_m); \ + ST_SB4(tmp0_m, tmp1_m, tmp2_m, tmp3_m, pdst_m, stride); \ +} + +#define PCKEV_AVG_ST8x4_UB(in1, dst0, in2, dst1, in3, dst2, in4, dst3, \ + pdst, stride) \ +{ \ + v16u8 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + uint8_t *pdst_m = (uint8_t *) (pdst); \ + \ + PCKEV_B2_UB(in2, in1, in4, in3, tmp0_m, tmp1_m); \ + PCKEV_D2_UB(dst1, dst0, dst3, dst2, tmp2_m, tmp3_m); \ + AVER_UB2_UB(tmp0_m, tmp2_m, tmp1_m, tmp3_m, tmp0_m, tmp1_m); \ + ST8x4_UB(tmp0_m, tmp1_m, pdst_m, stride); \ +} + +static void common_hz_bil_4w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + uint32_t out0, out1; + v16u8 src0, src1, src0_sld1, src1_sld1, res0, res1; + + for (loop_cnt = (height >> 1); loop_cnt--;) { + LD_UB2(src, src_stride, src0, src1); + src += (2 * src_stride); + + SLDI_B2_0_UB(src0, src1, src0_sld1, src1_sld1, 1); + AVER_UB2_UB(src0_sld1, src0, src1_sld1, src1, res0, res1); + + out0 = __msa_copy_u_w((v4i32) res0, 0); + out1 = __msa_copy_u_w((v4i32) res1, 0); + SW(out0, dst); + dst += dst_stride; + SW(out1, dst); + dst += dst_stride; + } +} + +static void common_hz_bil_8w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + v16i8 src0, src1, src2, src3, src0_sld1, src1_sld1, src2_sld1, src3_sld1; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + SLDI_B4_0_SB(src0, src1, src2, src3, + src0_sld1, src1_sld1, src2_sld1, src3_sld1, 1); + AVER_ST8x4_UB(src0, src0_sld1, src1, src1_sld1, + src2, src2_sld1, src3, src3_sld1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void common_hz_bil_16w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + v16u8 src8, src9, src10, src11, src12, src13, src14, src15; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + LD_UB8((src + 1), src_stride, + src8, src9, src10, src11, src12, src13, src14, src15); + src += (8 * src_stride); + + AVER_ST16x4_UB(src0, src8, src1, src9, src2, src10, src3, src11, + dst, dst_stride); + dst += (4 * dst_stride); + + AVER_ST16x4_UB(src4, src12, src5, src13, src6, src14, src7, src15, + dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void common_hz_bil_no_rnd_8x8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16i8 src0, src1, src2, src3, src4, src5, src6, src7; + v16i8 src0_sld1, src1_sld1, src2_sld1, src3_sld1; + v16i8 src4_sld1, src5_sld1, src6_sld1, src7_sld1; + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + + SLDI_B4_0_SB(src0, src1, src2, src3, + src0_sld1, src1_sld1, src2_sld1, src3_sld1, 1); + SLDI_B4_0_SB(src4, src5, src6, src7, + src4_sld1, src5_sld1, src6_sld1, src7_sld1, 1); + + AVE_ST8x4_UB(src0, src0_sld1, src1, src1_sld1, + src2, src2_sld1, src3, src3_sld1, dst, dst_stride); + dst += (4 * dst_stride); + AVE_ST8x4_UB(src4, src4_sld1, src5, src5_sld1, + src6, src6_sld1, src7, src7_sld1, dst, dst_stride); +} + +static void common_hz_bil_no_rnd_4x8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16i8 src0, src1, src2, src3, src0_sld1, src1_sld1, src2_sld1, src3_sld1; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + SLDI_B4_0_SB(src0, src1, src2, src3, + src0_sld1, src1_sld1, src2_sld1, src3_sld1, 1); + AVE_ST8x4_UB(src0, src0_sld1, src1, src1_sld1, + src2, src2_sld1, src3, src3_sld1, dst, dst_stride); +} + +static void common_hz_bil_no_rnd_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16u8 src9, src10, src11, src12, src13, src14, src15; + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + LD_UB8((src + 1), src_stride, + src8, src9, src10, src11, src12, src13, src14, src15); + src += (8 * src_stride); + + AVE_ST16x4_UB(src0, src8, src1, src9, src2, src10, src3, src11, + dst, dst_stride); + dst += (4 * dst_stride); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + LD_UB4((src + 1), src_stride, src8, src9, src10, src11); + src += (4 * src_stride); + + AVE_ST16x4_UB(src4, src12, src5, src13, src6, src14, src7, src15, + dst, dst_stride); + dst += (4 * dst_stride); + + LD_UB4(src, src_stride, src4, src5, src6, src7); + LD_UB4((src + 1), src_stride, src12, src13, src14, src15); + src += (4 * src_stride); + + AVE_ST16x4_UB(src0, src8, src1, src9, src2, src10, src3, src11, + dst, dst_stride); + dst += (4 * dst_stride); + AVE_ST16x4_UB(src4, src12, src5, src13, src6, src14, src7, src15, + dst, dst_stride); +} + +static void common_hz_bil_no_rnd_8x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16u8 src9, src10, src11, src12, src13, src14, src15; + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + LD_UB8((src + 1), src_stride, + src8, src9, src10, src11, src12, src13, src14, src15); + + AVE_ST16x4_UB(src0, src8, src1, src9, src2, src10, src3, src11, + dst, dst_stride); + dst += (4 * dst_stride); + AVE_ST16x4_UB(src4, src12, src5, src13, src6, src14, src7, src15, + dst, dst_stride); +} + +static void common_hz_bil_and_aver_dst_4w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + uint32_t dst0, dst1, out0, out1; + v16u8 src0, src1, src0_sld1, src1_sld1, res0, res1; + v16u8 tmp0 = { 0 }; + v16u8 tmp1 = { 0 }; + + for (loop_cnt = (height >> 1); loop_cnt--;) { + LD_UB2(src, src_stride, src0, src1); + src += (2 * src_stride); + + SLDI_B2_0_UB(src0, src1, src0_sld1, src1_sld1, 1); + + dst0 = LW(dst); + dst1 = LW(dst + dst_stride); + tmp0 = (v16u8) __msa_insert_w((v4i32) tmp0, 0, dst0); + tmp1 = (v16u8) __msa_insert_w((v4i32) tmp1, 0, dst1); + + AVER_UB2_UB(src0_sld1, src0, src1_sld1, src1, res0, res1); + AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1); + + out0 = __msa_copy_u_w((v4i32) res0, 0); + out1 = __msa_copy_u_w((v4i32) res1, 0); + SW(out0, dst); + dst += dst_stride; + SW(out1, dst); + dst += dst_stride; + } +} + +static void common_hz_bil_and_aver_dst_8w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + v16i8 src0, src1, src2, src3, src0_sld1, src1_sld1, src2_sld1, src3_sld1; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + SLDI_B4_0_SB(src0, src1, src2, src3, + src0_sld1, src1_sld1, src2_sld1, src3_sld1, 1); + + AVER_DST_ST8x4_UB(src0, src0_sld1, src1, src1_sld1, src2, src2_sld1, + src3, src3_sld1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void common_hz_bil_and_aver_dst_16w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16u8 src9, src10, src11, src12, src13, src14, src15; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + LD_UB8((src + 1), src_stride, + src8, src9, src10, src11, src12, src13, src14, src15); + src += (8 * src_stride); + + AVER_DST_ST16x4_UB(src0, src8, src1, src9, src2, src10, src3, src11, + dst, dst_stride); + dst += (4 * dst_stride); + AVER_DST_ST16x4_UB(src4, src12, src5, src13, src6, src14, src7, src15, + dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void common_vt_bil_4w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + uint32_t out0, out1; + v16u8 src0, src1, src2, res0, res1; + + src0 = LD_UB(src); + src += src_stride; + + for (loop_cnt = (height >> 1); loop_cnt--;) { + LD_UB2(src, src_stride, src1, src2); + src += (2 * src_stride); + + AVER_UB2_UB(src0, src1, src1, src2, res0, res1); + + out0 = __msa_copy_u_w((v4i32) res0, 0); + out1 = __msa_copy_u_w((v4i32) res1, 0); + SW(out0, dst); + dst += dst_stride; + SW(out1, dst); + dst += dst_stride; + + src0 = src2; + } +} + +static void common_vt_bil_8w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + v16u8 src0, src1, src2, src3, src4; + + src0 = LD_UB(src); + src += src_stride; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + AVER_ST8x4_UB(src0, src1, src1, src2, src2, src3, src3, src4, + dst, dst_stride); + dst += (4 * dst_stride); + + src0 = src4; + } +} + +static void common_vt_bil_16w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + + src0 = LD_UB(src); + src += src_stride; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src, src_stride, src1, src2, src3, src4, src5, src6, src7, src8); + src += (8 * src_stride); + + AVER_ST16x4_UB(src0, src1, src1, src2, src2, src3, src3, src4, + dst, dst_stride); + dst += (4 * dst_stride); + AVER_ST16x4_UB(src4, src5, src5, src6, src6, src7, src7, src8, + dst, dst_stride); + dst += (4 * dst_stride); + + src0 = src8; + } +} + +static void common_vt_bil_no_rnd_8x8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + src8 = LD_UB(src); + + AVE_ST8x4_UB(src0, src1, src1, src2, src2, src3, src3, src4, + dst, dst_stride); + dst += (4 * dst_stride); + + AVE_ST8x4_UB(src4, src5, src5, src6, src6, src7, src7, src8, + dst, dst_stride); +} + +static void common_vt_bil_no_rnd_4x8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16u8 src0, src1, src2, src3, src4; + + LD_UB5(src, src_stride, src0, src1, src2, src3, src4); + AVE_ST8x4_UB(src0, src1, src1, src2, src2, src3, src3, src4, + dst, dst_stride); +} + +static void common_vt_bil_no_rnd_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16u8 src9, src10, src11, src12, src13, src14, src15, src16; + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + LD_UB8(src, src_stride, + src8, src9, src10, src11, src12, src13, src14, src15); + src += (8 * src_stride); + src16 = LD_UB(src); + + AVE_ST16x4_UB(src0, src1, src1, src2, src2, src3, src3, src4, + dst, dst_stride); + dst += (4 * dst_stride); + AVE_ST16x4_UB(src4, src5, src5, src6, src6, src7, src7, src8, + dst, dst_stride); + dst += (4 * dst_stride); + AVE_ST16x4_UB(src8, src9, src9, src10, src10, src11, src11, src12, + dst, dst_stride); + dst += (4 * dst_stride); + AVE_ST16x4_UB(src12, src13, src13, src14, + src14, src15, src15, src16, dst, dst_stride); +} + +static void common_vt_bil_no_rnd_8x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + src8 = LD_UB(src); + + AVE_ST16x4_UB(src0, src1, src1, src2, src2, src3, src3, src4, + dst, dst_stride); + dst += (4 * dst_stride); + AVE_ST16x4_UB(src4, src5, src5, src6, src6, src7, src7, src8, + dst, dst_stride); +} + +static void common_vt_bil_and_aver_dst_4w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + uint32_t out0, out1, dst0, dst1; + v16u8 src0, src1, src2; + v16u8 tmp0 = { 0 }; + v16u8 tmp1 = { 0 }; + v16u8 res0, res1; + + src0 = LD_UB(src); + src += src_stride; + + for (loop_cnt = (height >> 1); loop_cnt--;) { + LD_UB2(src, src_stride, src1, src2); + src += (2 * src_stride); + dst0 = LW(dst); + dst1 = LW(dst + dst_stride); + tmp0 = (v16u8) __msa_insert_w((v4i32) tmp0, 0, dst0); + tmp1 = (v16u8) __msa_insert_w((v4i32) tmp1, 0, dst1); + AVER_UB2_UB(src0, src1, src1, src2, res0, res1); + AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1); + out0 = __msa_copy_u_w((v4i32) res0, 0); + out1 = __msa_copy_u_w((v4i32) res1, 0); + SW(out0, dst); + dst += dst_stride; + SW(out1, dst); + dst += dst_stride; + src0 = src2; + } +} + +static void common_vt_bil_and_aver_dst_8w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + v16u8 src0, src1, src2, src3, src4; + + src0 = LD_UB(src); + src += src_stride; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + AVER_DST_ST8x4_UB(src0, src1, src1, src2, src2, src3, src3, src4, + dst, dst_stride); + dst += (4 * dst_stride); + src0 = src4; + } +} + +static void common_vt_bil_and_aver_dst_16w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16u8 res0, res1, res2, res3, res4, res5, res6, res7; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + + src0 = LD_UB(src); + src += src_stride; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src, src_stride, src1, src2, src3, src4, src5, src6, src7, src8); + src += (8 * src_stride); + AVER_UB4_UB(src0, src1, src1, src2, src2, src3, src3, src4, + res0, res1, res2, res3); + AVER_UB4_UB(src4, src5, src5, src6, src6, src7, src7, src8, + res4, res5, res6, res7); + + LD_UB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + AVER_UB4_UB(dst0, res0, dst1, res1, dst2, res2, dst3, res3, + res0, res1, res2, res3); + AVER_UB4_UB(dst4, res4, dst5, res5, dst6, res6, dst7, res7, + res4, res5, res6, res7); + ST_UB8(res0, res1, res2, res3, res4, res5, res6, res7, dst, dst_stride); + dst += (8 * dst_stride); + + src0 = src8; + } +} + +static void common_hv_bil_4w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + uint32_t res0, res1; + v16i8 src0, src1, src2, src0_sld1, src1_sld1, src2_sld1; + v16u8 src0_r, src1_r, src2_r, res; + v8u16 add0, add1, add2, sum0, sum1; + + src0 = LD_SB(src); + src += src_stride; + + for (loop_cnt = (height >> 1); loop_cnt--;) { + LD_SB2(src, src_stride, src1, src2); + src += (2 * src_stride); + + SLDI_B3_0_SB(src0, src1, src2, src0_sld1, src1_sld1, src2_sld1, 1); + ILVR_B3_UB(src0_sld1, src0, src1_sld1, src1, src2_sld1, src2, + src0_r, src1_r, src2_r); + HADD_UB3_UH(src0_r, src1_r, src2_r, add0, add1, add2); + ADD2(add0, add1, add1, add2, sum0, sum1); + SRARI_H2_UH(sum0, sum1, 2); + res = (v16u8) __msa_pckev_b((v16i8) sum1, (v16i8) sum0); + res0 = __msa_copy_u_w((v4i32) res, 0); + res1 = __msa_copy_u_w((v4i32) res, 2); + SW(res0, dst); + dst += dst_stride; + SW(res1, dst); + dst += dst_stride; + + src0 = src2; + } +} + +static void common_hv_bil_8w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + v16i8 src0, src1, src2, src3, src4; + v16i8 src0_sld1, src1_sld1, src2_sld1, src3_sld1, src4_sld1; + v16u8 src0_r, src1_r, src2_r, src3_r, src4_r; + v8u16 add0, add1, add2, add3, add4; + v8u16 sum0, sum1, sum2, sum3; + + src0 = LD_SB(src); + src += src_stride; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + SLDI_B3_0_SB(src0, src1, src2, src0_sld1, src1_sld1, src2_sld1, 1); + SLDI_B2_0_SB(src3, src4, src3_sld1, src4_sld1, 1); + ILVR_B3_UB(src0_sld1, src0, src1_sld1, src1, src2_sld1, src2, src0_r, + src1_r, src2_r); + ILVR_B2_UB(src3_sld1, src3, src4_sld1, src4, src3_r, src4_r); + HADD_UB3_UH(src0_r, src1_r, src2_r, add0, add1, add2); + HADD_UB2_UH(src3_r, src4_r, add3, add4); + ADD4(add0, add1, add1, add2, add2, add3, add3, add4, + sum0, sum1, sum2, sum3); + SRARI_H4_UH(sum0, sum1, sum2, sum3, 2); + PCKEV_B2_SB(sum1, sum0, sum3, sum2, src0, src1); + ST8x4_UB(src0, src1, dst, dst_stride); + dst += (4 * dst_stride); + src0 = src4; + } +} + +static void common_hv_bil_16w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9; + v16u8 src10, src11, src12, src13, src14, src15, src16, src17; + v8u16 src0_r, src1_r, src2_r, src3_r, src4_r, src5_r, src6_r, src7_r; + v8u16 src8_r, src0_l, src1_l, src2_l, src3_l, src4_l, src5_l, src6_l; + v8u16 src7_l, src8_l; + v8u16 sum0_r, sum1_r, sum2_r, sum3_r, sum4_r, sum5_r, sum6_r, sum7_r; + v8u16 sum0_l, sum1_l, sum2_l, sum3_l, sum4_l, sum5_l, sum6_l, sum7_l; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + LD_UB8((src + 1), src_stride, + src9, src10, src11, src12, src13, src14, src15, src16); + src += (8 * src_stride); + + src8 = LD_UB(src); + src17 = LD_UB(src + 1); + + ILVRL_B2_UH(src9, src0, src0_r, src0_l); + ILVRL_B2_UH(src10, src1, src1_r, src1_l); + ILVRL_B2_UH(src11, src2, src2_r, src2_l); + ILVRL_B2_UH(src12, src3, src3_r, src3_l); + ILVRL_B2_UH(src13, src4, src4_r, src4_l); + ILVRL_B2_UH(src14, src5, src5_r, src5_l); + ILVRL_B2_UH(src15, src6, src6_r, src6_l); + ILVRL_B2_UH(src16, src7, src7_r, src7_l); + ILVRL_B2_UH(src17, src8, src8_r, src8_l); + HADD_UB3_UH(src0_r, src1_r, src2_r, src0_r, src1_r, src2_r); + HADD_UB3_UH(src3_r, src4_r, src5_r, src3_r, src4_r, src5_r); + HADD_UB3_UH(src6_r, src7_r, src8_r, src6_r, src7_r, src8_r); + HADD_UB3_UH(src0_l, src1_l, src2_l, src0_l, src1_l, src2_l); + HADD_UB3_UH(src3_l, src4_l, src5_l, src3_l, src4_l, src5_l); + HADD_UB3_UH(src6_l, src7_l, src8_l, src6_l, src7_l, src8_l); + ADD4(src0_r, src1_r, src1_r, src2_r, src2_r, src3_r, src3_r, src4_r, + sum0_r, sum1_r, sum2_r, sum3_r); + ADD4(src4_r, src5_r, src5_r, src6_r, src6_r, src7_r, src7_r, src8_r, + sum4_r, sum5_r, sum6_r, sum7_r); + ADD4(src0_l, src1_l, src1_l, src2_l, src2_l, src3_l, src3_l, src4_l, + sum0_l, sum1_l, sum2_l, sum3_l); + ADD4(src4_l, src5_l, src5_l, src6_l, src6_l, src7_l, src7_l, src8_l, + sum4_l, sum5_l, sum6_l, sum7_l); + SRARI_H4_UH(sum0_r, sum1_r, sum2_r, sum3_r, 2); + SRARI_H4_UH(sum4_r, sum5_r, sum6_r, sum7_r, 2); + SRARI_H4_UH(sum0_l, sum1_l, sum2_l, sum3_l, 2); + SRARI_H4_UH(sum4_l, sum5_l, sum6_l, sum7_l, 2); + PCKEV_ST_SB4(sum0_l, sum0_r, sum1_l, sum1_r, sum2_l, sum2_r, + sum3_l, sum3_r, dst, dst_stride); + dst += (4 * dst_stride); + PCKEV_ST_SB4(sum4_l, sum4_r, sum5_l, sum5_r, sum6_l, sum6_r, + sum7_l, sum7_r, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void common_hv_bil_no_rnd_8x8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16u8 src0_sld1, src1_sld1, src2_sld1, src3_sld1; + v16u8 src4_sld1, src5_sld1, src6_sld1, src7_sld1, src8_sld1; + v8u16 src0_r, src1_r, src2_r, src3_r; + v8u16 src4_r, src5_r, src6_r, src7_r, src8_r; + v8u16 add0, add1, add2, add3, add4, add5, add6, add7, add8; + v8u16 sum0, sum1, sum2, sum3, sum4, sum5, sum6, sum7; + v16i8 out0, out1; + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + src8 = LD_UB(src); + + SLDI_B4_0_UB(src0, src1, src2, src3, src0_sld1, src1_sld1, src2_sld1, + src3_sld1, 1); + SLDI_B3_0_UB(src4, src5, src6, src4_sld1, src5_sld1, src6_sld1, 1); + SLDI_B2_0_UB(src7, src8, src7_sld1, src8_sld1, 1); + ILVR_B4_UH(src0_sld1, src0, src1_sld1, src1, src2_sld1, src2, src3_sld1, + src3, src0_r, src1_r, src2_r, src3_r); + ILVR_B3_UH(src4_sld1, src4, src5_sld1, src5, src6_sld1, src6, src4_r, + src5_r, src6_r); + ILVR_B2_UH(src7_sld1, src7, src8_sld1, src8, src7_r, src8_r); + HADD_UB3_UH(src0_r, src1_r, src2_r, add0, add1, add2); + HADD_UB3_UH(src3_r, src4_r, src5_r, add3, add4, add5); + HADD_UB3_UH(src6_r, src7_r, src8_r, add6, add7, add8); + + sum0 = add0 + add1 + 1; + sum1 = add1 + add2 + 1; + sum2 = add2 + add3 + 1; + sum3 = add3 + add4 + 1; + sum4 = add4 + add5 + 1; + sum5 = add5 + add6 + 1; + sum6 = add6 + add7 + 1; + sum7 = add7 + add8 + 1; + + SRA_4V(sum0, sum1, sum2, sum3, 2); + SRA_4V(sum4, sum5, sum6, sum7, 2); + PCKEV_B2_SB(sum1, sum0, sum3, sum2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + PCKEV_B2_SB(sum5, sum4, sum7, sum6, out0, out1); + ST8x4_UB(out0, out1, dst + 4 * dst_stride, dst_stride); +} + +static void common_hv_bil_no_rnd_4x8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16i8 src0, src1, src2, src3, src4; + v16i8 src0_sld1, src1_sld1, src2_sld1, src3_sld1, src4_sld1; + v8u16 src0_r, src1_r, src2_r, src3_r, src4_r; + v8u16 add0, add1, add2, add3, add4; + v8u16 sum0, sum1, sum2, sum3; + v16i8 out0, out1; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + src4 = LD_SB(src); + + SLDI_B3_0_SB(src0, src1, src2, src0_sld1, src1_sld1, src2_sld1, 1); + SLDI_B2_0_SB(src3, src4, src3_sld1, src4_sld1, 1); + ILVR_B3_UH(src0_sld1, src0, src1_sld1, src1, src2_sld1, src2, src0_r, + src1_r, src2_r); + ILVR_B2_UH(src3_sld1, src3, src4_sld1, src4, src3_r, src4_r); + HADD_UB3_UH(src0_r, src1_r, src2_r, add0, add1, add2); + HADD_UB2_UH(src3_r, src4_r, add3, add4); + + sum0 = add0 + add1 + 1; + sum1 = add1 + add2 + 1; + sum2 = add2 + add3 + 1; + sum3 = add3 + add4 + 1; + + SRA_4V(sum0, sum1, sum2, sum3, 2); + PCKEV_B2_SB(sum1, sum0, sum3, sum2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); +} + +static void common_hv_bil_no_rnd_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9; + v16u8 src10, src11, src12, src13, src14, src15, src16, src17; + v8u16 src0_r, src1_r, src2_r, src3_r, src4_r, src5_r, src6_r, src7_r; + v8u16 src8_r, src0_l, src1_l, src2_l, src3_l, src4_l, src5_l, src6_l; + v8u16 src7_l, src8_l; + v8u16 sum0_r, sum1_r, sum2_r, sum3_r, sum4_r, sum5_r, sum6_r, sum7_r; + v8u16 sum0_l, sum1_l, sum2_l, sum3_l, sum4_l, sum5_l, sum6_l, sum7_l; + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + LD_UB8((src + 1), src_stride, + src9, src10, src11, src12, src13, src14, src15, src16); + src += (8 * src_stride); + src8 = LD_UB(src); + src17 = LD_UB(src + 1); + + ILVRL_B2_UH(src9, src0, src0_r, src0_l); + ILVRL_B2_UH(src10, src1, src1_r, src1_l); + ILVRL_B2_UH(src11, src2, src2_r, src2_l); + ILVRL_B2_UH(src12, src3, src3_r, src3_l); + ILVRL_B2_UH(src13, src4, src4_r, src4_l); + ILVRL_B2_UH(src14, src5, src5_r, src5_l); + ILVRL_B2_UH(src15, src6, src6_r, src6_l); + ILVRL_B2_UH(src16, src7, src7_r, src7_l); + ILVRL_B2_UH(src17, src8, src8_r, src8_l); + + HADD_UB3_UH(src0_r, src1_r, src2_r, src0_r, src1_r, src2_r); + HADD_UB3_UH(src3_r, src4_r, src5_r, src3_r, src4_r, src5_r); + HADD_UB3_UH(src6_r, src7_r, src8_r, src6_r, src7_r, src8_r); + HADD_UB3_UH(src0_l, src1_l, src2_l, src0_l, src1_l, src2_l); + HADD_UB3_UH(src3_l, src4_l, src5_l, src3_l, src4_l, src5_l); + HADD_UB3_UH(src6_l, src7_l, src8_l, src6_l, src7_l, src8_l); + + sum0_r = src0_r + src1_r + 1; + sum1_r = src1_r + src2_r + 1; + sum2_r = src2_r + src3_r + 1; + sum3_r = src3_r + src4_r + 1; + sum4_r = src4_r + src5_r + 1; + sum5_r = src5_r + src6_r + 1; + sum6_r = src6_r + src7_r + 1; + sum7_r = src7_r + src8_r + 1; + sum0_l = src0_l + src1_l + 1; + sum1_l = src1_l + src2_l + 1; + sum2_l = src2_l + src3_l + 1; + sum3_l = src3_l + src4_l + 1; + sum4_l = src4_l + src5_l + 1; + sum5_l = src5_l + src6_l + 1; + sum6_l = src6_l + src7_l + 1; + sum7_l = src7_l + src8_l + 1; + + SRA_4V(sum0_r, sum1_r, sum2_r, sum3_r, 2); + SRA_4V(sum4_r, sum5_r, sum6_r, sum7_r, 2); + SRA_4V(sum0_l, sum1_l, sum2_l, sum3_l, 2); + SRA_4V(sum4_l, sum5_l, sum6_l, sum7_l, 2); + PCKEV_ST_SB4(sum0_l, sum0_r, sum1_l, sum1_r, + sum2_l, sum2_r, sum3_l, sum3_r, dst, dst_stride); + dst += (4 * dst_stride); + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + LD_UB8((src + 1), src_stride, + src9, src10, src11, src12, src13, src14, src15, src16); + src += (8 * src_stride); + src8 = LD_UB(src); + src17 = LD_UB(src + 1); + + PCKEV_ST_SB4(sum4_l, sum4_r, sum5_l, sum5_r, + sum6_l, sum6_r, sum7_l, sum7_r, dst, dst_stride); + dst += (4 * dst_stride); + + ILVRL_B2_UH(src9, src0, src0_r, src0_l); + ILVRL_B2_UH(src10, src1, src1_r, src1_l); + ILVRL_B2_UH(src11, src2, src2_r, src2_l); + ILVRL_B2_UH(src12, src3, src3_r, src3_l); + ILVRL_B2_UH(src13, src4, src4_r, src4_l); + ILVRL_B2_UH(src14, src5, src5_r, src5_l); + ILVRL_B2_UH(src15, src6, src6_r, src6_l); + ILVRL_B2_UH(src16, src7, src7_r, src7_l); + ILVRL_B2_UH(src17, src8, src8_r, src8_l); + + HADD_UB3_UH(src0_r, src1_r, src2_r, src0_r, src1_r, src2_r); + HADD_UB3_UH(src3_r, src4_r, src5_r, src3_r, src4_r, src5_r); + HADD_UB3_UH(src6_r, src7_r, src8_r, src6_r, src7_r, src8_r); + HADD_UB3_UH(src0_l, src1_l, src2_l, src0_l, src1_l, src2_l); + HADD_UB3_UH(src3_l, src4_l, src5_l, src3_l, src4_l, src5_l); + HADD_UB3_UH(src6_l, src7_l, src8_l, src6_l, src7_l, src8_l); + + sum0_r = src0_r + src1_r + 1; + sum1_r = src1_r + src2_r + 1; + sum2_r = src2_r + src3_r + 1; + sum3_r = src3_r + src4_r + 1; + sum4_r = src4_r + src5_r + 1; + sum5_r = src5_r + src6_r + 1; + sum6_r = src6_r + src7_r + 1; + sum7_r = src7_r + src8_r + 1; + sum0_l = src0_l + src1_l + 1; + sum1_l = src1_l + src2_l + 1; + sum2_l = src2_l + src3_l + 1; + sum3_l = src3_l + src4_l + 1; + sum4_l = src4_l + src5_l + 1; + sum5_l = src5_l + src6_l + 1; + sum6_l = src6_l + src7_l + 1; + sum7_l = src7_l + src8_l + 1; + + SRA_4V(sum0_r, sum1_r, sum2_r, sum3_r, 2); + SRA_4V(sum4_r, sum5_r, sum6_r, sum7_r, 2); + SRA_4V(sum0_l, sum1_l, sum2_l, sum3_l, 2); + SRA_4V(sum4_l, sum5_l, sum6_l, sum7_l, 2); + PCKEV_ST_SB4(sum0_l, sum0_r, sum1_l, sum1_r, + sum2_l, sum2_r, sum3_l, sum3_r, dst, dst_stride); + dst += (4 * dst_stride); + PCKEV_ST_SB4(sum4_l, sum4_r, sum5_l, sum5_r, + sum6_l, sum6_r, sum7_l, sum7_r, dst, dst_stride); +} + +static void common_hv_bil_no_rnd_8x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9; + v16u8 src10, src11, src12, src13, src14, src15, src16, src17; + v8u16 src0_r, src1_r, src2_r, src3_r, src4_r, src5_r, src6_r, src7_r; + v8u16 src8_r, src0_l, src1_l, src2_l, src3_l, src4_l, src5_l, src6_l; + v8u16 src7_l, src8_l; + v8u16 sum0_r, sum1_r, sum2_r, sum3_r, sum4_r, sum5_r, sum6_r, sum7_r; + v8u16 sum0_l, sum1_l, sum2_l, sum3_l, sum4_l, sum5_l, sum6_l, sum7_l; + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + LD_UB8((src + 1), src_stride, + src9, src10, src11, src12, src13, src14, src15, src16); + src += (8 * src_stride); + src8 = LD_UB(src); + src17 = LD_UB(src + 1); + + ILVRL_B2_UH(src9, src0, src0_r, src0_l); + ILVRL_B2_UH(src10, src1, src1_r, src1_l); + ILVRL_B2_UH(src11, src2, src2_r, src2_l); + ILVRL_B2_UH(src12, src3, src3_r, src3_l); + ILVRL_B2_UH(src13, src4, src4_r, src4_l); + ILVRL_B2_UH(src14, src5, src5_r, src5_l); + ILVRL_B2_UH(src15, src6, src6_r, src6_l); + ILVRL_B2_UH(src16, src7, src7_r, src7_l); + ILVRL_B2_UH(src17, src8, src8_r, src8_l); + + HADD_UB3_UH(src0_r, src1_r, src2_r, src0_r, src1_r, src2_r); + HADD_UB3_UH(src3_r, src4_r, src5_r, src3_r, src4_r, src5_r); + HADD_UB3_UH(src6_r, src7_r, src8_r, src6_r, src7_r, src8_r); + HADD_UB3_UH(src0_l, src1_l, src2_l, src0_l, src1_l, src2_l); + HADD_UB3_UH(src3_l, src4_l, src5_l, src3_l, src4_l, src5_l); + HADD_UB3_UH(src6_l, src7_l, src8_l, src6_l, src7_l, src8_l); + + sum0_r = src0_r + src1_r + 1; + sum1_r = src1_r + src2_r + 1; + sum2_r = src2_r + src3_r + 1; + sum3_r = src3_r + src4_r + 1; + sum4_r = src4_r + src5_r + 1; + sum5_r = src5_r + src6_r + 1; + sum6_r = src6_r + src7_r + 1; + sum7_r = src7_r + src8_r + 1; + sum0_l = src0_l + src1_l + 1; + sum1_l = src1_l + src2_l + 1; + sum2_l = src2_l + src3_l + 1; + sum3_l = src3_l + src4_l + 1; + sum4_l = src4_l + src5_l + 1; + sum5_l = src5_l + src6_l + 1; + sum6_l = src6_l + src7_l + 1; + sum7_l = src7_l + src8_l + 1; + + SRA_4V(sum0_r, sum1_r, sum2_r, sum3_r, 2); + SRA_4V(sum4_r, sum5_r, sum6_r, sum7_r, 2); + SRA_4V(sum0_l, sum1_l, sum2_l, sum3_l, 2); + SRA_4V(sum4_l, sum5_l, sum6_l, sum7_l, 2); + PCKEV_ST_SB4(sum0_l, sum0_r, sum1_l, sum1_r, + sum2_l, sum2_r, sum3_l, sum3_r, dst, dst_stride); + dst += (4 * dst_stride); + PCKEV_ST_SB4(sum4_l, sum4_r, sum5_l, sum5_r, + sum6_l, sum6_r, sum7_l, sum7_r, dst, dst_stride); +} + +static void common_hv_bil_and_aver_dst_4w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + uint32_t out0, out1; + v16i8 src0, src1, src2, src0_sld1, src1_sld1, src2_sld1; + v16u8 src0_r, src1_r, src2_r; + v8u16 add0, add1, add2, sum0, sum1; + v16u8 dst0, dst1, res0, res1; + + src0 = LD_SB(src); + src += src_stride; + + for (loop_cnt = (height >> 1); loop_cnt--;) { + LD_SB2(src, src_stride, src1, src2); + src += (2 * src_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + SLDI_B3_0_SB(src0, src1, src2, src0_sld1, src1_sld1, src2_sld1, 1); + ILVR_B3_UB(src0_sld1, src0, src1_sld1, src1, src2_sld1, src2, src0_r, + src1_r, src2_r); + HADD_UB3_UH(src0_r, src1_r, src2_r, add0, add1, add2); + ADD2(add0, add1, add1, add2, sum0, sum1); + SRARI_H2_UH(sum0, sum1, 2); + PCKEV_B2_UB(sum0, sum0, sum1, sum1, res0, res1); + AVER_UB2_UB(dst0, res0, dst1, res1, res0, res1); + + out0 = __msa_copy_u_w((v4i32) res0, 0); + out1 = __msa_copy_u_w((v4i32) res1, 0); + SW(out0, dst); + dst += dst_stride; + SW(out1, dst); + dst += dst_stride; + + src0 = src2; + } +} + +static void common_hv_bil_and_aver_dst_8w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + v16i8 src0, src1, src2, src3, src4; + v16i8 src0_sld1, src1_sld1, src2_sld1, src3_sld1, src4_sld1; + v16u8 dst0, dst1, dst2, dst3; + v16u8 src0_r, src1_r, src2_r, src3_r, src4_r; + v8u16 add0, add1, add2, add3, add4; + v8u16 sum0, sum1, sum2, sum3; + + src0 = LD_SB(src); + src += src_stride; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + SLDI_B3_0_SB(src0, src1, src2, src0_sld1, src1_sld1, src2_sld1, 1); + SLDI_B2_0_SB(src3, src4, src3_sld1, src4_sld1, 1); + ILVR_B3_UB(src0_sld1, src0, src1_sld1, src1, src2_sld1, src2, src0_r, + src1_r, src2_r); + ILVR_B2_UB(src3_sld1, src3, src4_sld1, src4, src3_r, src4_r); + HADD_UB3_UH(src0_r, src1_r, src2_r, add0, add1, add2); + HADD_UB2_UH(src3_r, src4_r, add3, add4); + ADD4(add0, add1, add1, add2, add2, add3, add3, add4, + sum0, sum1, sum2, sum3); + SRARI_H4_UH(sum0, sum1, sum2, sum3, 2); + PCKEV_AVG_ST8x4_UB(sum0, dst0, sum1, dst1, + sum2, dst2, sum3, dst3, dst, dst_stride); + dst += (4 * dst_stride); + src0 = src4; + } +} + +static void common_hv_bil_and_aver_dst_16w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + uint8_t height) +{ + uint8_t loop_cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16u8 src11, src12, src13, src14, src15, src16, src17; + v16u8 src0_r, src1_r, src2_r, src3_r, src4_r, src5_r, src6_r, src7_r; + v16u8 src8_r, src0_l, src1_l, src2_l, src3_l, src4_l, src5_l, src6_l; + v16u8 src7_l, src8_l; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v8u16 sum0_r, sum1_r, sum2_r, sum3_r, sum4_r, sum5_r, sum6_r, sum7_r; + v8u16 sum0_l, sum1_l, sum2_l, sum3_l, sum4_l, sum5_l, sum6_l, sum7_l; + v8u16 add0, add1, add2, add3, add4, add5, add6, add7, add8; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + LD_UB8((src + 1), src_stride, + src9, src10, src11, src12, src13, src14, src15, src16); + src += (8 * src_stride); + + src8 = LD_UB(src); + src17 = LD_UB(src + 1); + + ILVRL_B2_UB(src9, src0, src0_r, src0_l); + ILVRL_B2_UB(src10, src1, src1_r, src1_l); + ILVRL_B2_UB(src11, src2, src2_r, src2_l); + ILVRL_B2_UB(src12, src3, src3_r, src3_l); + ILVRL_B2_UB(src13, src4, src4_r, src4_l); + ILVRL_B2_UB(src14, src5, src5_r, src5_l); + ILVRL_B2_UB(src15, src6, src6_r, src6_l); + ILVRL_B2_UB(src16, src7, src7_r, src7_l); + ILVRL_B2_UB(src17, src8, src8_r, src8_l); + HADD_UB3_UH(src0_r, src1_r, src2_r, add0, add1, add2); + HADD_UB3_UH(src3_r, src4_r, src5_r, add3, add4, add5); + HADD_UB3_UH(src6_r, src7_r, src8_r, add6, add7, add8); + ADD4(add0, add1, add1, add2, add2, add3, add3, add4, sum0_r, sum1_r, + sum2_r, sum3_r); + ADD4(add4, add5, add5, add6, add6, add7, add7, add8, sum4_r, sum5_r, + sum6_r, sum7_r); + HADD_UB3_UH(src0_l, src1_l, src2_l, add0, add1, add2); + HADD_UB3_UH(src3_l, src4_l, src5_l, add3, add4, add5); + HADD_UB3_UH(src6_l, src7_l, src8_l, add6, add7, add8); + ADD4(add0, add1, add1, add2, add2, add3, add3, add4, sum0_l, sum1_l, + sum2_l, sum3_l); + ADD4(add4, add5, add5, add6, add6, add7, add7, add8, sum4_l, sum5_l, + sum6_l, sum7_l); + SRARI_H4_UH(sum0_r, sum1_r, sum2_r, sum3_r, 2); + SRARI_H4_UH(sum4_r, sum5_r, sum6_r, sum7_r, 2); + SRARI_H4_UH(sum0_l, sum1_l, sum2_l, sum3_l, 2); + SRARI_H4_UH(sum4_l, sum5_l, sum6_l, sum7_l, 2); + LD_UB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + PCKEV_AVG_ST_UB(sum0_l, sum0_r, dst0, dst); + dst += dst_stride; + PCKEV_AVG_ST_UB(sum1_l, sum1_r, dst1, dst); + dst += dst_stride; + PCKEV_AVG_ST_UB(sum2_l, sum2_r, dst2, dst); + dst += dst_stride; + PCKEV_AVG_ST_UB(sum3_l, sum3_r, dst3, dst); + dst += dst_stride; + PCKEV_AVG_ST_UB(sum4_l, sum4_r, dst4, dst); + dst += dst_stride; + PCKEV_AVG_ST_UB(sum5_l, sum5_r, dst5, dst); + dst += dst_stride; + PCKEV_AVG_ST_UB(sum6_l, sum6_r, dst6, dst); + dst += dst_stride; + PCKEV_AVG_ST_UB(sum7_l, sum7_r, dst7, dst); + dst += dst_stride; + } +} + +static void copy_width8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint64_t out0, out1, out2, out3, out4, out5, out6, out7; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + if (0 == height % 12) { + for (cnt = (height / 12); cnt--;) { + LD_UB8(src, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + out4 = __msa_copy_u_d((v2i64) src4, 0); + out5 = __msa_copy_u_d((v2i64) src5, 0); + out6 = __msa_copy_u_d((v2i64) src6, 0); + out7 = __msa_copy_u_d((v2i64) src7, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + SD4(out4, out5, out6, out7, dst, dst_stride); + dst += (4 * dst_stride); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 8) { + for (cnt = height >> 3; cnt--;) { + LD_UB8(src, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + out4 = __msa_copy_u_d((v2i64) src4, 0); + out5 = __msa_copy_u_d((v2i64) src5, 0); + out6 = __msa_copy_u_d((v2i64) src6, 0); + out7 = __msa_copy_u_d((v2i64) src7, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + SD4(out4, out5, out6, out7, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 4) { + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 2) { + for (cnt = (height / 2); cnt--;) { + LD_UB2(src, src_stride, src0, src1); + src += (2 * src_stride); + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + + SD(out0, dst); + dst += dst_stride; + SD(out1, dst); + dst += dst_stride; + } + } +} + +static void copy_16multx8mult_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, int32_t width) +{ + int32_t cnt, loop_cnt; + const uint8_t *src_tmp; + uint8_t *dst_tmp; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + for (cnt = (width >> 4); cnt--;) { + src_tmp = src; + dst_tmp = dst; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src_tmp, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src_tmp += (8 * src_stride); + + ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, + dst_tmp, dst_stride); + dst_tmp += (8 * dst_stride); + } + + src += 16; + dst += 16; + } +} + +static void copy_width16_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + if (0 == height % 12) { + for (cnt = (height / 12); cnt--;) { + LD_UB8(src, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, + dst, dst_stride); + dst += (8 * dst_stride); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 8) { + copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 16); + } else if (0 == height % 4) { + for (cnt = (height >> 2); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + dst += (4 * dst_stride); + } + } +} + +static void avg_width4_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint32_t out0, out1, out2, out3; + v16u8 src0, src1, src2, src3; + v16u8 dst0, dst1, dst2, dst3; + + if (0 == (height % 4)) { + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + + out0 = __msa_copy_u_w((v4i32) dst0, 0); + out1 = __msa_copy_u_w((v4i32) dst1, 0); + out2 = __msa_copy_u_w((v4i32) dst2, 0); + out3 = __msa_copy_u_w((v4i32) dst3, 0); + SW4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == (height % 2)) { + for (cnt = (height / 2); cnt--;) { + LD_UB2(src, src_stride, src0, src1); + src += (2 * src_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + + AVER_UB2_UB(src0, dst0, src1, dst1, dst0, dst1); + + out0 = __msa_copy_u_w((v4i32) dst0, 0); + out1 = __msa_copy_u_w((v4i32) dst1, 0); + SW(out0, dst); + dst += dst_stride; + SW(out1, dst); + dst += dst_stride; + } + } +} + +static void avg_width8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint64_t out0, out1, out2, out3; + v16u8 src0, src1, src2, src3; + v16u8 dst0, dst1, dst2, dst3; + + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + + out0 = __msa_copy_u_d((v2i64) dst0, 0); + out1 = __msa_copy_u_d((v2i64) dst1, 0); + out2 = __msa_copy_u_d((v2i64) dst2, 0); + out3 = __msa_copy_u_d((v2i64) dst3, 0); + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void avg_width16_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + + for (cnt = (height / 8); cnt--;) { + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + LD_UB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + AVER_UB4_UB(src4, dst4, src5, dst5, src6, dst6, src7, dst7, + dst4, dst5, dst6, dst7); + ST_UB8(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst, dst_stride); + dst += (8 * dst_stride); + } +} + +void ff_put_pixels16_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + copy_width16_msa(pixels, line_size, block, line_size, h); +} + +void ff_put_pixels16_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_hz_bil_16w_msa(pixels, line_size, block, line_size, h); +} + +void ff_put_pixels16_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_vt_bil_16w_msa(pixels, line_size, block, line_size, h); +} + +void ff_put_pixels16_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_hv_bil_16w_msa(pixels, line_size, block, line_size, h); +} + +void ff_put_pixels8_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + copy_width8_msa(pixels, line_size, block, line_size, h); +} + +void ff_put_pixels8_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_hz_bil_8w_msa(pixels, line_size, block, line_size, h); +} + +void ff_put_pixels8_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_vt_bil_8w_msa(pixels, line_size, block, line_size, h); +} + +void ff_put_pixels8_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_hv_bil_8w_msa(pixels, line_size, block, line_size, h); +} + +void ff_put_pixels4_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_hz_bil_4w_msa(pixels, line_size, block, line_size, h); +} + +void ff_put_pixels4_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_vt_bil_4w_msa(pixels, line_size, block, line_size, h); +} + +void ff_put_pixels4_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_hv_bil_4w_msa(pixels, line_size, block, line_size, h); +} + +void ff_put_no_rnd_pixels16_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + if (h == 16) { + common_hz_bil_no_rnd_16x16_msa(pixels, line_size, block, line_size); + } else if (h == 8) { + common_hz_bil_no_rnd_8x16_msa(pixels, line_size, block, line_size); + } +} + +void ff_put_no_rnd_pixels16_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + if (h == 16) { + common_vt_bil_no_rnd_16x16_msa(pixels, line_size, block, line_size); + } else if (h == 8) { + common_vt_bil_no_rnd_8x16_msa(pixels, line_size, block, line_size); + } +} + +void ff_put_no_rnd_pixels16_xy2_msa(uint8_t *block, + const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + if (h == 16) { + common_hv_bil_no_rnd_16x16_msa(pixels, line_size, block, line_size); + } else if (h == 8) { + common_hv_bil_no_rnd_8x16_msa(pixels, line_size, block, line_size); + } +} + +void ff_put_no_rnd_pixels8_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + if (h == 8) { + common_hz_bil_no_rnd_8x8_msa(pixels, line_size, block, line_size); + } else if (h == 4) { + common_hz_bil_no_rnd_4x8_msa(pixels, line_size, block, line_size); + } +} + +void ff_put_no_rnd_pixels8_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + if (h == 8) { + common_vt_bil_no_rnd_8x8_msa(pixels, line_size, block, line_size); + } else if (h == 4) { + common_vt_bil_no_rnd_4x8_msa(pixels, line_size, block, line_size); + } +} + +void ff_put_no_rnd_pixels8_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + if (h == 8) { + common_hv_bil_no_rnd_8x8_msa(pixels, line_size, block, line_size); + } else if (h == 4) { + common_hv_bil_no_rnd_4x8_msa(pixels, line_size, block, line_size); + } +} + +void ff_avg_pixels16_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + avg_width16_msa(pixels, line_size, block, line_size, h); +} + +void ff_avg_pixels16_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_hz_bil_and_aver_dst_16w_msa(pixels, line_size, block, line_size, h); +} + +void ff_avg_pixels16_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_vt_bil_and_aver_dst_16w_msa(pixels, line_size, block, line_size, h); +} + +void ff_avg_pixels16_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_hv_bil_and_aver_dst_16w_msa(pixels, line_size, block, line_size, h); +} + +void ff_avg_pixels8_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + avg_width8_msa(pixels, line_size, block, line_size, h); +} + +void ff_avg_pixels8_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_hz_bil_and_aver_dst_8w_msa(pixels, line_size, block, line_size, h); +} + +void ff_avg_pixels8_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_vt_bil_and_aver_dst_8w_msa(pixels, line_size, block, line_size, h); +} + +void ff_avg_pixels8_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_hv_bil_and_aver_dst_8w_msa(pixels, line_size, block, line_size, h); +} + +void ff_avg_pixels4_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + avg_width4_msa(pixels, line_size, block, line_size, h); +} + +void ff_avg_pixels4_x2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_hz_bil_and_aver_dst_4w_msa(pixels, line_size, block, line_size, h); +} + +void ff_avg_pixels4_y2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_vt_bil_and_aver_dst_4w_msa(pixels, line_size, block, line_size, h); +} + +void ff_avg_pixels4_xy2_msa(uint8_t *block, const uint8_t *pixels, + ptrdiff_t line_size, int h) +{ + common_hv_bil_and_aver_dst_4w_msa(pixels, line_size, block, line_size, h); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/idctdsp_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/idctdsp_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/idctdsp_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/idctdsp_init_mips.c 2015-07-21 17:20:03.000000000 +0000 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * Zhou Xiaoyong + * + * 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 "idctdsp_mips.h" + +#if HAVE_MSA +static av_cold void idctdsp_init_msa(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth) +{ + if ((avctx->lowres != 1) && (avctx->lowres != 2) && (avctx->lowres != 3) && + (avctx->bits_per_raw_sample != 10) && + (avctx->bits_per_raw_sample != 12) && + (avctx->idct_algo == FF_IDCT_AUTO)) { + c->idct_put = ff_simple_idct_put_msa; + c->idct_add = ff_simple_idct_add_msa; + c->idct = ff_simple_idct_msa; + c->perm_type = FF_IDCT_PERM_NONE; + } + + c->put_pixels_clamped = ff_put_pixels_clamped_msa; + c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_msa; + c->add_pixels_clamped = ff_add_pixels_clamped_msa; +} +#endif // #if HAVE_MSA + +#if HAVE_MMI +static av_cold void idctdsp_init_mmi(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth) +{ + if ((avctx->lowres != 1) && (avctx->lowres != 2) && (avctx->lowres != 3) && + (avctx->bits_per_raw_sample != 10) && + (avctx->bits_per_raw_sample != 12) && + (avctx->idct_algo == FF_IDCT_AUTO)) { + c->idct_put = ff_simple_idct_put_mmi; + c->idct_add = ff_simple_idct_add_mmi; + c->idct = ff_simple_idct_mmi; + c->perm_type = FF_IDCT_PERM_NONE; + } + + c->put_pixels_clamped = ff_put_pixels_clamped_mmi; + c->add_pixels_clamped = ff_add_pixels_clamped_mmi; + c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmi; +} +#endif /* HAVE_MMI */ + +av_cold void ff_idctdsp_init_mips(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth) +{ +#if HAVE_MSA + idctdsp_init_msa(c, avctx, high_bit_depth); +#endif // #if HAVE_MSA +#if HAVE_MMI + idctdsp_init_mmi(c, avctx, high_bit_depth); +#endif /* HAVE_MMI */ +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/idctdsp_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/idctdsp_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/idctdsp_mips.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/idctdsp_mips.h 2015-07-16 17:20:02.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * Zhou Xiaoyong + * + * 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 + */ + +#ifndef AVCODEC_MIPS_IDCTDSP_MIPS_H +#define AVCODEC_MIPS_IDCTDSP_MIPS_H + +#include "../mpegvideo.h" + +void ff_put_pixels_clamped_msa(const int16_t *block, + uint8_t *av_restrict pixels, + ptrdiff_t line_size); +void ff_put_signed_pixels_clamped_msa(const int16_t *block, + uint8_t *av_restrict pixels, + ptrdiff_t line_size); +void ff_add_pixels_clamped_msa(const int16_t *block, + uint8_t *av_restrict pixels, + ptrdiff_t line_size); +void ff_j_rev_dct_msa(int16_t *data); +void ff_jref_idct_put_msa(uint8_t *dest, int32_t stride, int16_t *block); +void ff_jref_idct_add_msa(uint8_t *dest, int32_t stride, int16_t *block); +void ff_simple_idct_msa(int16_t *block); +void ff_simple_idct_put_msa(uint8_t *dest, int32_t stride_dst, int16_t *block); +void ff_simple_idct_add_msa(uint8_t *dest, int32_t stride_dst, int16_t *block); + +void ff_put_pixels_clamped_mmi(const int16_t *block, + uint8_t *av_restrict pixels, ptrdiff_t line_size); +void ff_put_signed_pixels_clamped_mmi(const int16_t *block, + uint8_t *av_restrict pixels, ptrdiff_t line_size); +void ff_add_pixels_clamped_mmi(const int16_t *block, + uint8_t *av_restrict pixels, ptrdiff_t line_size); +void ff_simple_idct_mmi(int16_t *block); +void ff_simple_idct_put_mmi(uint8_t *dest, int32_t line_size, int16_t *block); +void ff_simple_idct_add_mmi(uint8_t *dest, int32_t line_size, int16_t *block); + +#endif // #ifndef AVCODEC_MIPS_IDCTDSP_MIPS_H diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/idctdsp_mmi.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/idctdsp_mmi.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/idctdsp_mmi.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/idctdsp_mmi.c 2015-07-21 17:20:03.000000000 +0000 @@ -0,0 +1,190 @@ +/* + * Loongson SIMD optimized idctdsp + * + * Copyright (c) 2015 Loongson Technology Corporation Limited + * Copyright (c) 2015 Zhou Xiaoyong + * + * 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 "idctdsp_mips.h" +#include "constants.h" + +void ff_put_pixels_clamped_mmi(const int16_t *block, + uint8_t *av_restrict pixels, ptrdiff_t line_size) +{ + const int16_t *p; + uint8_t *pix; + + p = block; + pix = pixels; + + __asm__ volatile ( + "ldc1 $f0, 0+%3 \r\n" + "ldc1 $f2, 8+%3 \r\n" + "ldc1 $f4, 16+%3 \r\n" + "ldc1 $f6, 24+%3 \r\n" + "ldc1 $f8, 32+%3 \r\n" + "ldc1 $f10, 40+%3 \r\n" + "ldc1 $f12, 48+%3 \r\n" + "ldc1 $f14, 56+%3 \r\n" + "dadd $10, %0, %1 \r\n" + "packushb $f0, $f0, $f2 \r\n" + "packushb $f4, $f4, $f6 \r\n" + "packushb $f8, $f8, $f10 \r\n" + "packushb $f12, $f12, $f14 \r\n" + "sdc1 $f0, 0(%0) \r\n" + "sdc1 $f4, 0($10) \r\n" + "gssdxc1 $f8, 0($10, %1) \r\n" + "gssdxc1 $f12, 0(%0, %2) \r\n" + ::"r"(pix),"r"((int)line_size), + "r"((int)line_size*3),"m"(*p) + : "$10","memory" + ); + + pix += line_size*4; + p += 32; + + __asm__ volatile ( + "ldc1 $f0, 0+%3 \r\n" + "ldc1 $f2, 8+%3 \r\n" + "ldc1 $f4, 16+%3 \r\n" + "ldc1 $f6, 24+%3 \r\n" + "ldc1 $f8, 32+%3 \r\n" + "ldc1 $f10, 40+%3 \r\n" + "ldc1 $f12, 48+%3 \r\n" + "ldc1 $f14, 56+%3 \r\n" + "dadd $10, %0, %1 \r\n" + "packushb $f0, $f0, $f2 \r\n" + "packushb $f4, $f4, $f6 \r\n" + "packushb $f8, $f8, $f10 \r\n" + "packushb $f12, $f12, $f14 \r\n" + "sdc1 $f0, 0(%0) \r\n" + "sdc1 $f4, 0($10) \r\n" + "gssdxc1 $f8, 0($10, %1) \r\n" + "gssdxc1 $f12, 0(%0, %2) \r\n" + ::"r"(pix),"r"((int)line_size), + "r"((int)line_size*3),"m"(*p) + : "$10","memory" + ); +} + +void ff_put_signed_pixels_clamped_mmi(const int16_t *block, + uint8_t *av_restrict pixels, ptrdiff_t line_size) +{ + int64_t line_skip = line_size; + int64_t line_skip3; + + __asm__ volatile ( + "dmtc1 %4, $f0 \n\t" + "daddu %1, %3, %3 \n\t" + "ldc1 $f2, 0(%2) \n\t" + "ldc1 $f10, 8(%2) \n\t" + "packsshb $f2, $f2, $f10 \n\t" + "ldc1 $f4, 16(%2) \n\t" + "ldc1 $f10, 24(%2) \n\t" + "packsshb $f4, $f4, $f10 \n\t" + "ldc1 $f6, 32(%2) \n\t" + "ldc1 $f10, 40(%2) \n\t" + "packsshb $f6, $f6, $f10 \n\t" + "ldc1 $f8, 48(%2) \n\t" + "ldc1 $f10, 56(%2) \n\t" + "packsshb $f8, $f8, $f10 \n\t" + "paddb $f2, $f2, $f0 \n\t" + "paddb $f4, $f4, $f0 \n\t" + "paddb $f6, $f6, $f0 \n\t" + "paddb $f8, $f8, $f0 \n\t" + "sdc1 $f2, 0(%0) \n\t" + "gssdxc1 $f4, 0(%0, %3) \n\t" + "gssdxc1 $f6, 0(%0, %1) \n\t" + "daddu %1, %1, %3 \n\t" + "gssdxc1 $f8, 0(%0, %1) \n\t" + "daddu $10, %1, %3 \n\t" + "daddu %0, %0, $10 \n\t" + "ldc1 $f2, 64(%2) \n\t" + "ldc1 $f10, 8+64(%2) \n\t" + "packsshb $f2, $f2, $f10 \n\t" + "ldc1 $f4, 16+64(%2) \n\t" + "ldc1 $f10, 24+64(%2) \n\t" + "packsshb $f4, $f4, $f10 \n\t" + "ldc1 $f6, 32+64(%2) \n\t" + "ldc1 $f10, 40+64(%2) \n\t" + "packsshb $f6, $f6, $f10 \n\t" + "ldc1 $f8, 48+64(%2) \n\t" + "ldc1 $f10, 56+64(%2) \n\t" + "packsshb $f8, $f8, $f10 \n\t" + "paddb $f2, $f2, $f0 \n\t" + "paddb $f4, $f4, $f0 \n\t" + "paddb $f6, $f6, $f0 \n\t" + "paddb $f8, $f8, $f0 \n\t" + "sdc1 $f2, 0(%0) \n\t" + "gssdxc1 $f4, 0(%0, %3) \n\t" + "daddu $10, %3, %3 \n\t" + "gssdxc1 $f6, 0(%0, $10) \n\t" + "gssdxc1 $f8, 0(%0, %1) \n\t" + : "+&r"(pixels),"=&r"(line_skip3) + : "r"(block),"r"(line_skip),"r"(ff_pb_80) + : "$10","memory" + ); +} + +void ff_add_pixels_clamped_mmi(const int16_t *block, + uint8_t *av_restrict pixels, ptrdiff_t line_size) +{ + const int16_t *p; + uint8_t *pix; + int i = 4; + + p = block; + pix = pixels; + + __asm__ volatile ( + "xor $f14, $f14, $f14 \r\n" + :: + ); + + do { + __asm__ volatile ( + "ldc1 $f0, 0+%2 \r\n" + "ldc1 $f2, 8+%2 \r\n" + "ldc1 $f4, 16+%2 \r\n" + "ldc1 $f6, 24+%2 \r\n" + "ldc1 $f8, %0 \r\n" + "ldc1 $f12, %1 \r\n" + "mov.d $f10, $f8 \r\n" + "punpcklbh $f8, $f8, $f14 \r\n" + "punpckhbh $f10, $f10, $f14 \r\n" + "paddsh $f0, $f0, $f8 \r\n" + "paddsh $f2, $f2, $f10 \r\n" + "mov.d $f10, $f12 \r\n" + "punpcklbh $f12, $f12, $f14 \r\n" + "punpckhbh $f10, $f10, $f14 \r\n" + "paddsh $f4, $f4, $f12 \r\n" + "paddsh $f6, $f6, $f10 \r\n" + "packushb $f0, $f0, $f2 \r\n" + "packushb $f4, $f4, $f6 \r\n" + "sdc1 $f0, %0 \r\n" + "sdc1 $f4, %1 \r\n" + : "+m"(*pix),"+m"(*(pix+line_size)) + : "m"(*p) + : "memory" + ); + + pix += line_size*2; + p += 16; + } while (--i); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/idctdsp_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/idctdsp_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/idctdsp_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/idctdsp_msa.c 2015-07-07 17:20:03.000000000 +0000 @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "idctdsp_mips.h" + +static void put_pixels_clamped_msa(const int16_t *block, uint8_t *pixels, + int32_t stride) +{ + uint64_t in0_d, in1_d, in2_d, in3_d, in4_d, in5_d, in6_d, in7_d; + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + + LD_SH8(block, 8, in0, in1, in2, in3, in4, in5, in6, in7); + CLIP_SH4_0_255(in0, in1, in2, in3); + CLIP_SH4_0_255(in4, in5, in6, in7); + PCKEV_B4_SH(in0, in0, in1, in1, in2, in2, in3, in3, in0, in1, in2, in3); + PCKEV_B4_SH(in4, in4, in5, in5, in6, in6, in7, in7, in4, in5, in6, in7); + + in0_d = __msa_copy_u_d((v2i64) in0, 0); + in1_d = __msa_copy_u_d((v2i64) in1, 0); + in2_d = __msa_copy_u_d((v2i64) in2, 0); + in3_d = __msa_copy_u_d((v2i64) in3, 0); + in4_d = __msa_copy_u_d((v2i64) in4, 0); + in5_d = __msa_copy_u_d((v2i64) in5, 0); + in6_d = __msa_copy_u_d((v2i64) in6, 0); + in7_d = __msa_copy_u_d((v2i64) in7, 0); + SD4(in0_d, in1_d, in2_d, in3_d, pixels, stride); + pixels += 4 * stride; + SD4(in4_d, in5_d, in6_d, in7_d, pixels, stride); +} + +static void put_signed_pixels_clamped_msa(const int16_t *block, uint8_t *pixels, + int32_t stride) +{ + uint64_t in0_d, in1_d, in2_d, in3_d, in4_d, in5_d, in6_d, in7_d; + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + + LD_SH8(block, 8, in0, in1, in2, in3, in4, in5, in6, in7); + + in0 += 128; + in1 += 128; + in2 += 128; + in3 += 128; + in4 += 128; + in5 += 128; + in6 += 128; + in7 += 128; + + CLIP_SH4_0_255(in0, in1, in2, in3); + CLIP_SH4_0_255(in4, in5, in6, in7); + PCKEV_B4_SH(in0, in0, in1, in1, in2, in2, in3, in3, in0, in1, in2, in3); + PCKEV_B4_SH(in4, in4, in5, in5, in6, in6, in7, in7, in4, in5, in6, in7); + + in0_d = __msa_copy_u_d((v2i64) in0, 0); + in1_d = __msa_copy_u_d((v2i64) in1, 0); + in2_d = __msa_copy_u_d((v2i64) in2, 0); + in3_d = __msa_copy_u_d((v2i64) in3, 0); + in4_d = __msa_copy_u_d((v2i64) in4, 0); + in5_d = __msa_copy_u_d((v2i64) in5, 0); + in6_d = __msa_copy_u_d((v2i64) in6, 0); + in7_d = __msa_copy_u_d((v2i64) in7, 0); + SD4(in0_d, in1_d, in2_d, in3_d, pixels, stride); + pixels += 4 * stride; + SD4(in4_d, in5_d, in6_d, in7_d, pixels, stride); +} + +static void add_pixels_clamped_msa(const int16_t *block, uint8_t *pixels, + int32_t stride) +{ + uint64_t in0_d, in1_d, in2_d, in3_d, in4_d, in5_d, in6_d, in7_d; + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + v16u8 pix_in0, pix_in1, pix_in2, pix_in3; + v16u8 pix_in4, pix_in5, pix_in6, pix_in7; + v8u16 pix0, pix1, pix2, pix3, pix4, pix5, pix6, pix7; + v8i16 zero = { 0 }; + + LD_SH8(block, 8, in0, in1, in2, in3, in4, in5, in6, in7); + LD_UB8(pixels, stride, pix_in0, pix_in1, pix_in2, + pix_in3, pix_in4, pix_in5, pix_in6, pix_in7); + + ILVR_B4_UH(zero, pix_in0, zero, pix_in1, zero, pix_in2, zero, pix_in3, + pix0, pix1, pix2, pix3); + ILVR_B4_UH(zero, pix_in4, zero, pix_in5, zero, pix_in6, zero, pix_in7, + pix4, pix5, pix6, pix7); + + in0 += (v8i16) pix0; + in1 += (v8i16) pix1; + in2 += (v8i16) pix2; + in3 += (v8i16) pix3; + in4 += (v8i16) pix4; + in5 += (v8i16) pix5; + in6 += (v8i16) pix6; + in7 += (v8i16) pix7; + + CLIP_SH4_0_255(in0, in1, in2, in3); + CLIP_SH4_0_255(in4, in5, in6, in7); + PCKEV_B4_SH(in0, in0, in1, in1, in2, in2, in3, in3, in0, in1, in2, in3); + PCKEV_B4_SH(in4, in4, in5, in5, in6, in6, in7, in7, in4, in5, in6, in7); + + in0_d = __msa_copy_u_d((v2i64) in0, 0); + in1_d = __msa_copy_u_d((v2i64) in1, 0); + in2_d = __msa_copy_u_d((v2i64) in2, 0); + in3_d = __msa_copy_u_d((v2i64) in3, 0); + in4_d = __msa_copy_u_d((v2i64) in4, 0); + in5_d = __msa_copy_u_d((v2i64) in5, 0); + in6_d = __msa_copy_u_d((v2i64) in6, 0); + in7_d = __msa_copy_u_d((v2i64) in7, 0); + SD4(in0_d, in1_d, in2_d, in3_d, pixels, stride); + pixels += 4 * stride; + SD4(in4_d, in5_d, in6_d, in7_d, pixels, stride); +} + +void ff_put_pixels_clamped_msa(const int16_t *block, + uint8_t *av_restrict pixels, + ptrdiff_t line_size) +{ + put_pixels_clamped_msa(block, pixels, line_size); +} + +void ff_put_signed_pixels_clamped_msa(const int16_t *block, + uint8_t *av_restrict pixels, + ptrdiff_t line_size) +{ + put_signed_pixels_clamped_msa(block, pixels, line_size); +} + +void ff_add_pixels_clamped_msa(const int16_t *block, + uint8_t *av_restrict pixels, + ptrdiff_t line_size) +{ + add_pixels_clamped_msa(block, pixels, line_size); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/iirfilter_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/iirfilter_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/iirfilter_mips.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/iirfilter_mips.c 2015-07-07 17:20:03.000000000 +0000 @@ -55,7 +55,6 @@ #include "libavcodec/iirfilter.h" #if HAVE_INLINE_ASM -#if !HAVE_LOONGSON3 typedef struct FFIIRFilterCoeffs { int order; float gain; @@ -196,13 +195,10 @@ } } } -#endif /* !HAVE_LOONGSON3 */ #endif /* HAVE_INLINE_ASM */ void ff_iir_filter_init_mips(FFIIRFilterContext *f) { #if HAVE_INLINE_ASM -#if !HAVE_LOONGSON3 f->filter_flt = ff_iir_filter_flt_mips; -#endif /* !HAVE_LOONGSON3 */ #endif /* HAVE_INLINE_ASM */ } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/Makefile ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/Makefile --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/Makefile 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/Makefile 2015-08-04 17:20:03.000000000 +0000 @@ -18,15 +18,61 @@ mips/aacpsdsp_mips.o MIPSDSPR1-OBJS-$(CONFIG_AAC_ENCODER) += mips/aaccoder_mips.o MIPSFPU-OBJS-$(CONFIG_AAC_ENCODER) += mips/iirfilter_mips.o -OBJS-$(CONFIG_HEVC_DECODER) += mips/hevcdsp_init_mips.o +OBJS-$(CONFIG_HEVC_DECODER) += mips/hevcdsp_init_mips.o \ + mips/hevcpred_init_mips.o +OBJS-$(CONFIG_VP9_DECODER) += mips/vp9dsp_init_mips.o +OBJS-$(CONFIG_VP8_DECODER) += mips/vp8dsp_init_mips.o OBJS-$(CONFIG_H264DSP) += mips/h264dsp_init_mips.o +OBJS-$(CONFIG_H264QPEL) += mips/h264qpel_init_mips.o OBJS-$(CONFIG_H264CHROMA) += mips/h264chroma_init_mips.o +OBJS-$(CONFIG_H264PRED) += mips/h264pred_init_mips.o +OBJS-$(CONFIG_H263DSP) += mips/h263dsp_init_mips.o +OBJS-$(CONFIG_QPELDSP) += mips/qpeldsp_init_mips.o +OBJS-$(CONFIG_HPELDSP) += mips/hpeldsp_init_mips.o +OBJS-$(CONFIG_BLOCKDSP) += mips/blockdsp_init_mips.o +OBJS-$(CONFIG_PIXBLOCKDSP) += mips/pixblockdsp_init_mips.o +OBJS-$(CONFIG_IDCTDSP) += mips/idctdsp_init_mips.o +OBJS-$(CONFIG_MPEGVIDEO) += mips/mpegvideo_init_mips.o +OBJS-$(CONFIG_MPEGVIDEOENC) += mips/mpegvideoencdsp_init_mips.o +OBJS-$(CONFIG_ME_CMP) += mips/me_cmp_init_mips.o +OBJS-$(CONFIG_MPEG4_DECODER) += mips/xvididct_init_mips.o MSA-OBJS-$(CONFIG_HEVC_DECODER) += mips/hevcdsp_msa.o \ mips/hevc_mc_uni_msa.o \ mips/hevc_mc_uniw_msa.o \ mips/hevc_mc_bi_msa.o \ mips/hevc_mc_biw_msa.o \ - mips/hevc_idct_msa.o -MSA-OBJS-$(CONFIG_H264DSP) += mips/h264dsp_msa.o -LOONGSON3-OBJS-$(CONFIG_H264DSP) += mips/h264dsp_mmi.o -LOONGSON3-OBJS-$(CONFIG_H264CHROMA) += mips/h264chroma_mmi.o + mips/hevc_idct_msa.o \ + mips/hevc_lpf_sao_msa.o \ + mips/hevcpred_msa.o +MSA-OBJS-$(CONFIG_VP9_DECODER) += mips/vp9_mc_msa.o \ + mips/vp9_lpf_msa.o \ + mips/vp9_idct_msa.o \ + mips/vp9_intra_msa.o +MSA-OBJS-$(CONFIG_VP8_DECODER) += mips/vp8_mc_msa.o \ + mips/vp8_idct_msa.o \ + mips/vp8_lpf_msa.o +MSA-OBJS-$(CONFIG_H264DSP) += mips/h264dsp_msa.o \ + mips/h264idct_msa.o +MSA-OBJS-$(CONFIG_H264QPEL) += mips/h264qpel_msa.o +MSA-OBJS-$(CONFIG_H264CHROMA) += mips/h264chroma_msa.o +MSA-OBJS-$(CONFIG_H264PRED) += mips/h264pred_msa.o +MSA-OBJS-$(CONFIG_H263DSP) += mips/h263dsp_msa.o +MSA-OBJS-$(CONFIG_QPELDSP) += mips/qpeldsp_msa.o +MSA-OBJS-$(CONFIG_HPELDSP) += mips/hpeldsp_msa.o +MSA-OBJS-$(CONFIG_BLOCKDSP) += mips/blockdsp_msa.o +MSA-OBJS-$(CONFIG_PIXBLOCKDSP) += mips/pixblockdsp_msa.o +MSA-OBJS-$(CONFIG_IDCTDSP) += mips/idctdsp_msa.o \ + mips/simple_idct_msa.o +MSA-OBJS-$(CONFIG_MPEGVIDEO) += mips/mpegvideo_msa.o +MSA-OBJS-$(CONFIG_MPEGVIDEOENC) += mips/mpegvideoencdsp_msa.o +MSA-OBJS-$(CONFIG_ME_CMP) += mips/me_cmp_msa.o +MMI-OBJS += mips/constants.o +MMI-OBJS-$(CONFIG_H264DSP) += mips/h264dsp_mmi.o +MMI-OBJS-$(CONFIG_H264CHROMA) += mips/h264chroma_mmi.o +MMI-OBJS-$(CONFIG_H264PRED) += mips/h264pred_mmi.o +MMI-OBJS-$(CONFIG_MPEGVIDEO) += mips/mpegvideo_mmi.o +MMI-OBJS-$(CONFIG_IDCTDSP) += mips/idctdsp_mmi.o \ + mips/simple_idct_mmi.o +MMI-OBJS-$(CONFIG_MPEG4_DECODER) += mips/xvid_idct_mmi.o +MMI-OBJS-$(CONFIG_BLOCKDSP) += mips/blockdsp_mmi.o +MMI-OBJS-$(CONFIG_PIXBLOCKDSP) += mips/pixblockdsp_mmi.o diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/me_cmp_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/me_cmp_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/me_cmp_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/me_cmp_init_mips.c 2015-07-06 17:20:03.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * + * 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 "me_cmp_mips.h" + +#if HAVE_MSA +static av_cold void me_cmp_msa(MECmpContext *c, AVCodecContext *avctx) +{ +#if BIT_DEPTH == 8 + c->pix_abs[0][0] = ff_pix_abs16_msa; + c->pix_abs[0][1] = ff_pix_abs16_x2_msa; + c->pix_abs[0][2] = ff_pix_abs16_y2_msa; + c->pix_abs[0][3] = ff_pix_abs16_xy2_msa; + c->pix_abs[1][0] = ff_pix_abs8_msa; + c->pix_abs[1][1] = ff_pix_abs8_x2_msa; + c->pix_abs[1][2] = ff_pix_abs8_y2_msa; + c->pix_abs[1][3] = ff_pix_abs8_xy2_msa; + + c->hadamard8_diff[0] = ff_hadamard8_diff16_msa; + c->hadamard8_diff[1] = ff_hadamard8_diff8x8_msa; + + c->hadamard8_diff[4] = ff_hadamard8_intra16_msa; + c->hadamard8_diff[5] = ff_hadamard8_intra8x8_msa; + + c->sad[0] = ff_pix_abs16_msa; + c->sad[1] = ff_pix_abs8_msa; + c->sse[0] = ff_sse16_msa; + c->sse[1] = ff_sse8_msa; + c->sse[2] = ff_sse4_msa; +#endif +} +#endif // #if HAVE_MSA + +av_cold void ff_me_cmp_init_mips(MECmpContext *c, AVCodecContext *avctx) +{ +#if HAVE_MSA + me_cmp_msa(c, avctx); +#endif // #if HAVE_MSA +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/me_cmp_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/me_cmp_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/me_cmp_mips.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/me_cmp_mips.h 2015-07-06 17:20:03.000000000 +0000 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * + * 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 + */ + +#ifndef AVCODEC_MIPS_ME_CMP_MIPS_H +#define AVCODEC_MIPS_ME_CMP_MIPS_H + +#include "../mpegvideo.h" +#include "libavcodec/bit_depth_template.c" + +int ff_hadamard8_diff8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src, + ptrdiff_t stride, int h); +int ff_hadamard8_intra8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src, + ptrdiff_t stride, int h); +int ff_hadamard8_diff16_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src, + ptrdiff_t stride, int h); +int ff_hadamard8_intra16_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src, + ptrdiff_t stride, int h); +int ff_pix_abs16_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h); +int ff_pix_abs16_x2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h); +int ff_pix_abs16_y2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h); +int ff_pix_abs16_xy2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h); +int ff_pix_abs8_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h); +int ff_pix_abs8_x2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h); +int ff_pix_abs8_y2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h); +int ff_pix_abs8_xy2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h); +int ff_sse16_msa(MpegEncContext *v, uint8_t *pu8Src, uint8_t *pu8Ref, + ptrdiff_t stride, int i32Height); +int ff_sse8_msa(MpegEncContext *v, uint8_t *pu8Src, uint8_t *pu8Ref, + ptrdiff_t stride, int i32Height); +int ff_sse4_msa(MpegEncContext *v, uint8_t *pu8Src, uint8_t *pu8Ref, + ptrdiff_t stride, int i32Height); +void ff_add_pixels8_msa(uint8_t *av_restrict pixels, int16_t *block, + ptrdiff_t stride); + +#endif // #ifndef AVCODEC_MIPS_ME_CMP_MIPS_H diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/me_cmp_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/me_cmp_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/me_cmp_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/me_cmp_msa.c 2015-07-06 17:20:03.000000000 +0000 @@ -0,0 +1,686 @@ +/* + * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "me_cmp_mips.h" + +static uint32_t sad_8width_msa(uint8_t *src, int32_t src_stride, + uint8_t *ref, int32_t ref_stride, + int32_t height) +{ + int32_t ht_cnt; + v16u8 src0, src1, src2, src3, ref0, ref1, ref2, ref3; + v8u16 sad = { 0 }; + + for (ht_cnt = (height >> 2); ht_cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB4(ref, ref_stride, ref0, ref1, ref2, ref3); + ref += (4 * ref_stride); + + PCKEV_D4_UB(src1, src0, src3, src2, ref1, ref0, ref3, ref2, + src0, src1, ref0, ref1); + sad += SAD_UB2_UH(src0, src1, ref0, ref1); + } + + return (HADD_UH_U32(sad)); +} + +static uint32_t sad_16width_msa(uint8_t *src, int32_t src_stride, + uint8_t *ref, int32_t ref_stride, + int32_t height) +{ + int32_t ht_cnt; + v16u8 src0, src1, ref0, ref1; + v8u16 sad = { 0 }; + + for (ht_cnt = (height >> 2); ht_cnt--;) { + LD_UB2(src, src_stride, src0, src1); + src += (2 * src_stride); + LD_UB2(ref, ref_stride, ref0, ref1); + ref += (2 * ref_stride); + sad += SAD_UB2_UH(src0, src1, ref0, ref1); + + LD_UB2(src, src_stride, src0, src1); + src += (2 * src_stride); + LD_UB2(ref, ref_stride, ref0, ref1); + ref += (2 * ref_stride); + sad += SAD_UB2_UH(src0, src1, ref0, ref1); + } + + return (HADD_UH_U32(sad)); +} + +static uint32_t sad_horiz_bilinear_filter_8width_msa(uint8_t *src, + int32_t src_stride, + uint8_t *ref, + int32_t ref_stride, + int32_t height) +{ + int32_t ht_cnt; + v16u8 src0, src1, src2, src3, comp0, comp1; + v16u8 ref0, ref1, ref2, ref3, ref4, ref5; + v8u16 sad = { 0 }; + + for (ht_cnt = (height >> 3); ht_cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB4(ref, ref_stride, ref0, ref1, ref2, ref3); + ref += (4 * ref_stride); + + PCKEV_D2_UB(src1, src0, src3, src2, src0, src1); + PCKEV_D2_UB(ref1, ref0, ref3, ref2, ref4, ref5); + SLDI_B2_UB(ref0, ref1, ref0, ref1, ref0, ref1, 1); + SLDI_B2_UB(ref2, ref3, ref2, ref3, ref2, ref3, 1); + PCKEV_D2_UB(ref1, ref0, ref3, ref2, ref0, ref1); + AVER_UB2_UB(ref4, ref0, ref5, ref1, comp0, comp1); + sad += SAD_UB2_UH(src0, src1, comp0, comp1); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB4(ref, ref_stride, ref0, ref1, ref2, ref3); + ref += (4 * ref_stride); + + PCKEV_D2_UB(src1, src0, src3, src2, src0, src1); + PCKEV_D2_UB(ref1, ref0, ref3, ref2, ref4, ref5); + SLDI_B2_UB(ref0, ref1, ref0, ref1, ref0, ref1, 1); + SLDI_B2_UB(ref2, ref3, ref2, ref3, ref2, ref3, 1); + PCKEV_D2_UB(ref1, ref0, ref3, ref2, ref0, ref1); + AVER_UB2_UB(ref4, ref0, ref5, ref1, comp0, comp1); + sad += SAD_UB2_UH(src0, src1, comp0, comp1); + } + + return (HADD_UH_U32(sad)); +} + +static uint32_t sad_horiz_bilinear_filter_16width_msa(uint8_t *src, + int32_t src_stride, + uint8_t *ref, + int32_t ref_stride, + int32_t height) +{ + int32_t ht_cnt; + v16u8 src0, src1, src2, src3, comp0, comp1; + v16u8 ref00, ref10, ref20, ref30, ref01, ref11, ref21, ref31; + v8u16 sad = { 0 }; + + for (ht_cnt = (height >> 3); ht_cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB4(ref, ref_stride, ref00, ref10, ref20, ref30); + LD_UB4(ref + 1, ref_stride, ref01, ref11, ref21, ref31); + ref += (4 * ref_stride); + + AVER_UB2_UB(ref01, ref00, ref11, ref10, comp0, comp1); + sad += SAD_UB2_UH(src0, src1, comp0, comp1); + AVER_UB2_UB(ref21, ref20, ref31, ref30, comp0, comp1); + sad += SAD_UB2_UH(src2, src3, comp0, comp1); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB4(ref, ref_stride, ref00, ref10, ref20, ref30); + LD_UB4(ref + 1, ref_stride, ref01, ref11, ref21, ref31); + ref += (4 * ref_stride); + + AVER_UB2_UB(ref01, ref00, ref11, ref10, comp0, comp1); + sad += SAD_UB2_UH(src0, src1, comp0, comp1); + AVER_UB2_UB(ref21, ref20, ref31, ref30, comp0, comp1); + sad += SAD_UB2_UH(src2, src3, comp0, comp1); + } + + return (HADD_UH_U32(sad)); +} + +static uint32_t sad_vert_bilinear_filter_8width_msa(uint8_t *src, + int32_t src_stride, + uint8_t *ref, + int32_t ref_stride, + int32_t height) +{ + int32_t ht_cnt; + v16u8 src0, src1, src2, src3, comp0, comp1; + v16u8 ref0, ref1, ref2, ref3, ref4; + v8u16 sad = { 0 }; + + for (ht_cnt = (height >> 3); ht_cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB5(ref, ref_stride, ref0, ref1, ref2, ref3, ref4); + ref += (4 * ref_stride); + + PCKEV_D2_UB(src1, src0, src3, src2, src0, src1); + PCKEV_D2_UB(ref1, ref0, ref2, ref1, ref0, ref1); + PCKEV_D2_UB(ref3, ref2, ref4, ref3, ref2, ref3); + AVER_UB2_UB(ref1, ref0, ref3, ref2, comp0, comp1); + sad += SAD_UB2_UH(src0, src1, comp0, comp1); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB5(ref, ref_stride, ref0, ref1, ref2, ref3, ref4); + ref += (4 * ref_stride); + + PCKEV_D2_UB(src1, src0, src3, src2, src0, src1); + PCKEV_D2_UB(ref1, ref0, ref2, ref1, ref0, ref1); + PCKEV_D2_UB(ref3, ref2, ref4, ref3, ref2, ref3); + AVER_UB2_UB(ref1, ref0, ref3, ref2, comp0, comp1); + sad += SAD_UB2_UH(src0, src1, comp0, comp1); + } + + return (HADD_UH_U32(sad)); +} + +static uint32_t sad_vert_bilinear_filter_16width_msa(uint8_t *src, + int32_t src_stride, + uint8_t *ref, + int32_t ref_stride, + int32_t height) +{ + int32_t ht_cnt; + v16u8 src0, src1, src2, src3, comp0, comp1; + v16u8 ref0, ref1, ref2, ref3, ref4; + v8u16 sad = { 0 }; + + for (ht_cnt = (height >> 3); ht_cnt--;) { + LD_UB5(ref, ref_stride, ref4, ref0, ref1, ref2, ref3); + ref += (5 * ref_stride); + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + AVER_UB2_UB(ref0, ref4, ref1, ref0, comp0, comp1); + sad += SAD_UB2_UH(src0, src1, comp0, comp1); + AVER_UB2_UB(ref2, ref1, ref3, ref2, comp0, comp1); + sad += SAD_UB2_UH(src2, src3, comp0, comp1); + + ref4 = ref3; + + LD_UB4(ref, ref_stride, ref0, ref1, ref2, ref3); + ref += (3 * ref_stride); + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + AVER_UB2_UB(ref0, ref4, ref1, ref0, comp0, comp1); + sad += SAD_UB2_UH(src0, src1, comp0, comp1); + AVER_UB2_UB(ref2, ref1, ref3, ref2, comp0, comp1); + sad += SAD_UB2_UH(src2, src3, comp0, comp1); + } + + return (HADD_UH_U32(sad)); +} + +static uint32_t sad_hv_bilinear_filter_8width_msa(uint8_t *src, + int32_t src_stride, + uint8_t *ref, + int32_t ref_stride, + int32_t height) +{ + int32_t ht_cnt; + v16u8 src0, src1, src2, src3, temp0, temp1, diff; + v16u8 ref0, ref1, ref2, ref3, ref4; + v16i8 mask = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v8u16 comp0, comp1, comp2, comp3; + v8u16 sad = { 0 }; + + for (ht_cnt = (height >> 2); ht_cnt--;) { + LD_UB5(ref, ref_stride, ref4, ref0, ref1, ref2, ref3); + ref += (4 * ref_stride); + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + PCKEV_D2_UB(src1, src0, src3, src2, src0, src1); + + VSHF_B2_UB(ref4, ref4, ref0, ref0, mask, mask, temp0, temp1); + comp0 = __msa_hadd_u_h(temp0, temp0); + comp1 = __msa_hadd_u_h(temp1, temp1); + comp0 += comp1; + comp0 = (v8u16) __msa_srari_h((v8i16) comp0, 2); + comp0 = (v8u16) __msa_pckev_b((v16i8) comp0, (v16i8) comp0); + + temp0 = (v16u8) __msa_vshf_b(mask, (v16i8) ref1, (v16i8) ref1); + comp2 = __msa_hadd_u_h(temp0, temp0); + comp1 += comp2; + comp1 = (v8u16) __msa_srari_h((v8i16) comp1, 2); + comp1 = (v8u16) __msa_pckev_b((v16i8) comp1, (v16i8) comp1); + comp1 = (v8u16) __msa_pckev_d((v2i64) comp1, (v2i64) comp0); + diff = (v16u8) __msa_asub_u_b(src0, (v16u8) comp1); + sad += __msa_hadd_u_h(diff, diff); + + temp1 = (v16u8) __msa_vshf_b(mask, (v16i8) ref2, (v16i8) ref2); + comp3 = __msa_hadd_u_h(temp1, temp1); + comp2 += comp3; + comp2 = (v8u16) __msa_srari_h((v8i16) comp2, 2); + comp2 = (v8u16) __msa_pckev_b((v16i8) comp2, (v16i8) comp2); + + temp0 = (v16u8) __msa_vshf_b(mask, (v16i8) ref3, (v16i8) ref3); + comp0 = __msa_hadd_u_h(temp0, temp0); + comp3 += comp0; + comp3 = (v8u16) __msa_srari_h((v8i16) comp3, 2); + comp3 = (v8u16) __msa_pckev_b((v16i8) comp3, (v16i8) comp3); + comp3 = (v8u16) __msa_pckev_d((v2i64) comp3, (v2i64) comp2); + diff = (v16u8) __msa_asub_u_b(src1, (v16u8) comp3); + sad += __msa_hadd_u_h(diff, diff); + } + + return (HADD_UH_U32(sad)); +} + +static uint32_t sad_hv_bilinear_filter_16width_msa(uint8_t *src, + int32_t src_stride, + uint8_t *ref, + int32_t ref_stride, + int32_t height) +{ + int32_t ht_cnt; + v16u8 src0, src1, src2, src3, comp, diff; + v16u8 temp0, temp1, temp2, temp3; + v16u8 ref00, ref01, ref02, ref03, ref04, ref10, ref11, ref12, ref13, ref14; + v8u16 comp0, comp1, comp2, comp3; + v8u16 sad = { 0 }; + + for (ht_cnt = (height >> 3); ht_cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB5(ref, ref_stride, ref04, ref00, ref01, ref02, ref03); + LD_UB5(ref + 1, ref_stride, ref14, ref10, ref11, ref12, ref13); + ref += (5 * ref_stride); + + ILVRL_B2_UB(ref14, ref04, temp0, temp1); + comp0 = __msa_hadd_u_h(temp0, temp0); + comp1 = __msa_hadd_u_h(temp1, temp1); + ILVRL_B2_UB(ref10, ref00, temp2, temp3); + comp2 = __msa_hadd_u_h(temp2, temp2); + comp3 = __msa_hadd_u_h(temp3, temp3); + comp0 += comp2; + comp1 += comp3; + SRARI_H2_UH(comp0, comp1, 2); + comp = (v16u8) __msa_pckev_b((v16i8) comp1, (v16i8) comp0); + diff = __msa_asub_u_b(src0, comp); + sad += __msa_hadd_u_h(diff, diff); + + ILVRL_B2_UB(ref11, ref01, temp0, temp1); + comp0 = __msa_hadd_u_h(temp0, temp0); + comp1 = __msa_hadd_u_h(temp1, temp1); + comp2 += comp0; + comp3 += comp1; + SRARI_H2_UH(comp2, comp3, 2); + comp = (v16u8) __msa_pckev_b((v16i8) comp3, (v16i8) comp2); + diff = __msa_asub_u_b(src1, comp); + sad += __msa_hadd_u_h(diff, diff); + + ILVRL_B2_UB(ref12, ref02, temp2, temp3); + comp2 = __msa_hadd_u_h(temp2, temp2); + comp3 = __msa_hadd_u_h(temp3, temp3); + comp0 += comp2; + comp1 += comp3; + SRARI_H2_UH(comp0, comp1, 2); + comp = (v16u8) __msa_pckev_b((v16i8) comp1, (v16i8) comp0); + diff = __msa_asub_u_b(src2, comp); + sad += __msa_hadd_u_h(diff, diff); + + ILVRL_B2_UB(ref13, ref03, temp0, temp1); + comp0 = __msa_hadd_u_h(temp0, temp0); + comp1 = __msa_hadd_u_h(temp1, temp1); + comp2 += comp0; + comp3 += comp1; + SRARI_H2_UH(comp2, comp3, 2); + comp = (v16u8) __msa_pckev_b((v16i8) comp3, (v16i8) comp2); + diff = __msa_asub_u_b(src3, comp); + sad += __msa_hadd_u_h(diff, diff); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB4(ref, ref_stride, ref00, ref01, ref02, ref03); + LD_UB4(ref + 1, ref_stride, ref10, ref11, ref12, ref13); + ref += (3 * ref_stride); + + ILVRL_B2_UB(ref10, ref00, temp2, temp3); + comp2 = __msa_hadd_u_h(temp2, temp2); + comp3 = __msa_hadd_u_h(temp3, temp3); + comp0 += comp2; + comp1 += comp3; + SRARI_H2_UH(comp0, comp1, 2); + comp = (v16u8) __msa_pckev_b((v16i8) comp1, (v16i8) comp0); + diff = __msa_asub_u_b(src0, comp); + sad += __msa_hadd_u_h(diff, diff); + + ILVRL_B2_UB(ref11, ref01, temp0, temp1); + comp0 = __msa_hadd_u_h(temp0, temp0); + comp1 = __msa_hadd_u_h(temp1, temp1); + comp2 += comp0; + comp3 += comp1; + SRARI_H2_UH(comp2, comp3, 2); + comp = (v16u8) __msa_pckev_b((v16i8) comp3, (v16i8) comp2); + diff = __msa_asub_u_b(src1, comp); + sad += __msa_hadd_u_h(diff, diff); + + ILVRL_B2_UB(ref12, ref02, temp2, temp3); + comp2 = __msa_hadd_u_h(temp2, temp2); + comp3 = __msa_hadd_u_h(temp3, temp3); + comp0 += comp2; + comp1 += comp3; + SRARI_H2_UH(comp0, comp1, 2); + comp = (v16u8) __msa_pckev_b((v16i8) comp1, (v16i8) comp0); + diff = __msa_asub_u_b(src2, comp); + sad += __msa_hadd_u_h(diff, diff); + + ILVRL_B2_UB(ref13, ref03, temp0, temp1); + comp0 = __msa_hadd_u_h(temp0, temp0); + comp1 = __msa_hadd_u_h(temp1, temp1); + comp2 += comp0; + comp3 += comp1; + SRARI_H2_UH(comp2, comp3, 2); + comp = (v16u8) __msa_pckev_b((v16i8) comp3, (v16i8) comp2); + diff = __msa_asub_u_b(src3, comp); + sad += __msa_hadd_u_h(diff, diff); + } + + return (HADD_UH_U32(sad)); +} + +#define CALC_MSE_B(src, ref, var) \ +{ \ + v16u8 src_l0_m, src_l1_m; \ + v8i16 res_l0_m, res_l1_m; \ + \ + ILVRL_B2_UB(src, ref, src_l0_m, src_l1_m); \ + HSUB_UB2_SH(src_l0_m, src_l1_m, res_l0_m, res_l1_m); \ + DPADD_SH2_SW(res_l0_m, res_l1_m, res_l0_m, res_l1_m, var, var); \ +} + +static uint32_t sse_4width_msa(uint8_t *src_ptr, int32_t src_stride, + uint8_t *ref_ptr, int32_t ref_stride, + int32_t height) +{ + int32_t ht_cnt; + uint32_t sse; + uint32_t src0, src1, src2, src3; + uint32_t ref0, ref1, ref2, ref3; + v16u8 src = { 0 }; + v16u8 ref = { 0 }; + v4i32 var = { 0 }; + + for (ht_cnt = (height >> 2); ht_cnt--;) { + LW4(src_ptr, src_stride, src0, src1, src2, src3); + src_ptr += (4 * src_stride); + LW4(ref_ptr, ref_stride, ref0, ref1, ref2, ref3); + ref_ptr += (4 * ref_stride); + + INSERT_W4_UB(src0, src1, src2, src3, src); + INSERT_W4_UB(ref0, ref1, ref2, ref3, ref); + CALC_MSE_B(src, ref, var); + } + + sse = HADD_SW_S32(var); + + return sse; +} + +static uint32_t sse_8width_msa(uint8_t *src_ptr, int32_t src_stride, + uint8_t *ref_ptr, int32_t ref_stride, + int32_t height) +{ + int32_t ht_cnt; + uint32_t sse; + v16u8 src0, src1, src2, src3; + v16u8 ref0, ref1, ref2, ref3; + v4i32 var = { 0 }; + + for (ht_cnt = (height >> 2); ht_cnt--;) { + LD_UB4(src_ptr, src_stride, src0, src1, src2, src3); + src_ptr += (4 * src_stride); + LD_UB4(ref_ptr, ref_stride, ref0, ref1, ref2, ref3); + ref_ptr += (4 * ref_stride); + + PCKEV_D4_UB(src1, src0, src3, src2, ref1, ref0, ref3, ref2, + src0, src1, ref0, ref1); + CALC_MSE_B(src0, ref0, var); + CALC_MSE_B(src1, ref1, var); + } + + sse = HADD_SW_S32(var); + + return sse; +} + +static uint32_t sse_16width_msa(uint8_t *src_ptr, int32_t src_stride, + uint8_t *ref_ptr, int32_t ref_stride, + int32_t height) +{ + int32_t ht_cnt; + uint32_t sse; + v16u8 src, ref; + v4i32 var = { 0 }; + + for (ht_cnt = (height >> 2); ht_cnt--;) { + src = LD_UB(src_ptr); + src_ptr += src_stride; + ref = LD_UB(ref_ptr); + ref_ptr += ref_stride; + CALC_MSE_B(src, ref, var); + + src = LD_UB(src_ptr); + src_ptr += src_stride; + ref = LD_UB(ref_ptr); + ref_ptr += ref_stride; + CALC_MSE_B(src, ref, var); + + src = LD_UB(src_ptr); + src_ptr += src_stride; + ref = LD_UB(ref_ptr); + ref_ptr += ref_stride; + CALC_MSE_B(src, ref, var); + + src = LD_UB(src_ptr); + src_ptr += src_stride; + ref = LD_UB(ref_ptr); + ref_ptr += ref_stride; + CALC_MSE_B(src, ref, var); + } + + sse = HADD_SW_S32(var); + + return sse; +} + +static int32_t hadamard_diff_8x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *ref, int32_t ref_stride) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + v16u8 ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7; + v8u16 diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7; + v8u16 temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + v8i16 sum = { 0 }; + v8i16 zero = { 0 }; + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + LD_UB8(ref, ref_stride, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7); + ILVR_B8_UH(src0, ref0, src1, ref1, src2, ref2, src3, ref3, + src4, ref4, src5, ref5, src6, ref6, src7, ref7, + diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7); + HSUB_UB4_UH(diff0, diff1, diff2, diff3, diff0, diff1, diff2, diff3); + HSUB_UB4_UH(diff4, diff5, diff6, diff7, diff4, diff5, diff6, diff7); + TRANSPOSE8x8_UH_UH(diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7, + diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7); + BUTTERFLY_8(diff0, diff2, diff4, diff6, diff7, diff5, diff3, diff1, + temp0, temp2, temp4, temp6, temp7, temp5, temp3, temp1); + BUTTERFLY_8(temp0, temp1, temp4, temp5, temp7, temp6, temp3, temp2, + diff0, diff1, diff4, diff5, diff7, diff6, diff3, diff2); + BUTTERFLY_8(diff0, diff1, diff2, diff3, diff7, diff6, diff5, diff4, + temp0, temp1, temp2, temp3, temp7, temp6, temp5, temp4); + TRANSPOSE8x8_UH_UH(temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, + temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7); + BUTTERFLY_8(temp0, temp2, temp4, temp6, temp7, temp5, temp3, temp1, + diff0, diff2, diff4, diff6, diff7, diff5, diff3, diff1); + BUTTERFLY_8(diff0, diff1, diff4, diff5, diff7, diff6, diff3, diff2, + temp0, temp1, temp4, temp5, temp7, temp6, temp3, temp2); + ADD4(temp0, temp4, temp1, temp5, temp2, temp6, temp3, temp7, + diff0, diff1, diff2, diff3); + sum = __msa_asub_s_h((v8i16) temp3, (v8i16) temp7); + sum += __msa_asub_s_h((v8i16) temp2, (v8i16) temp6); + sum += __msa_asub_s_h((v8i16) temp1, (v8i16) temp5); + sum += __msa_asub_s_h((v8i16) temp0, (v8i16) temp4); + sum += __msa_add_a_h((v8i16) diff0, zero); + sum += __msa_add_a_h((v8i16) diff1, zero); + sum += __msa_add_a_h((v8i16) diff2, zero); + sum += __msa_add_a_h((v8i16) diff3, zero); + + return (HADD_UH_U32(sum)); +} + +static int32_t hadamard_intra_8x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *ref, int32_t ref_stride) +{ + int32_t sum_res = 0; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + v8u16 diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7; + v8u16 temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + v8i16 sum = { 0 }; + v16i8 zero = { 0 }; + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + TRANSPOSE8x8_UB_UB(src0, src1, src2, src3, src4, src5, src6, src7, + src0, src1, src2, src3, src4, src5, src6, src7); + ILVR_B8_UH(zero, src0, zero, src1, zero, src2, zero, src3, + zero, src4, zero, src5, zero, src6, zero, src7, + diff0, diff1, diff2, diff3, diff4, diff5, diff6, diff7); + BUTTERFLY_8(diff0, diff2, diff4, diff6, diff7, diff5, diff3, diff1, + temp0, temp2, temp4, temp6, temp7, temp5, temp3, temp1); + BUTTERFLY_8(temp0, temp1, temp4, temp5, temp7, temp6, temp3, temp2, + diff0, diff1, diff4, diff5, diff7, diff6, diff3, diff2); + BUTTERFLY_8(diff0, diff1, diff2, diff3, diff7, diff6, diff5, diff4, + temp0, temp1, temp2, temp3, temp7, temp6, temp5, temp4); + TRANSPOSE8x8_UH_UH(temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, + temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7); + BUTTERFLY_8(temp0, temp2, temp4, temp6, temp7, temp5, temp3, temp1, + diff0, diff2, diff4, diff6, diff7, diff5, diff3, diff1); + BUTTERFLY_8(diff0, diff1, diff4, diff5, diff7, diff6, diff3, diff2, + temp0, temp1, temp4, temp5, temp7, temp6, temp3, temp2); + ADD4(temp0, temp4, temp1, temp5, temp2, temp6, temp3, temp7, + diff0, diff1, diff2, diff3); + sum = __msa_asub_s_h((v8i16) temp3, (v8i16) temp7); + sum += __msa_asub_s_h((v8i16) temp2, (v8i16) temp6); + sum += __msa_asub_s_h((v8i16) temp1, (v8i16) temp5); + sum += __msa_asub_s_h((v8i16) temp0, (v8i16) temp4); + sum += __msa_add_a_h((v8i16) diff0, (v8i16) zero); + sum += __msa_add_a_h((v8i16) diff1, (v8i16) zero); + sum += __msa_add_a_h((v8i16) diff2, (v8i16) zero); + sum += __msa_add_a_h((v8i16) diff3, (v8i16) zero); + sum_res = (HADD_UH_U32(sum)); + sum_res -= abs(temp0[0] + temp4[0]); + + return sum_res; +} + +int ff_pix_abs16_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref, + ptrdiff_t stride, int height) +{ + return sad_16width_msa(src, stride, ref, stride, height); +} + +int ff_pix_abs8_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref, + ptrdiff_t stride, int height) +{ + return sad_8width_msa(src, stride, ref, stride, height); +} + +int ff_pix_abs16_x2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h) +{ + return sad_horiz_bilinear_filter_16width_msa(pix1, stride, pix2, stride, h); +} + +int ff_pix_abs16_y2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h) +{ + return sad_vert_bilinear_filter_16width_msa(pix1, stride, pix2, stride, h); +} + +int ff_pix_abs16_xy2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h) +{ + return sad_hv_bilinear_filter_16width_msa(pix1, stride, pix2, stride, h); +} + +int ff_pix_abs8_x2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h) +{ + return sad_horiz_bilinear_filter_8width_msa(pix1, stride, pix2, stride, h); +} + +int ff_pix_abs8_y2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h) +{ + return sad_vert_bilinear_filter_8width_msa(pix1, stride, pix2, stride, h); +} + +int ff_pix_abs8_xy2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h) +{ + return sad_hv_bilinear_filter_8width_msa(pix1, stride, pix2, stride, h); +} + +int ff_sse16_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref, + ptrdiff_t stride, int height) +{ + return sse_16width_msa(src, stride, ref, stride, height); +} + +int ff_sse8_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref, + ptrdiff_t stride, int height) +{ + return sse_8width_msa(src, stride, ref, stride, height); +} + +int ff_sse4_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref, + ptrdiff_t stride, int height) +{ + return sse_4width_msa(src, stride, ref, stride, height); +} + +int ff_hadamard8_diff8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src, + ptrdiff_t stride, int h) +{ + return hadamard_diff_8x8_msa(src, stride, dst, stride); +} + +int ff_hadamard8_intra8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src, + ptrdiff_t stride, int h) +{ + return hadamard_intra_8x8_msa(src, stride, dst, stride); +} + +/* Hadamard Transform functions */ +#define WRAPPER8_16_SQ(name8, name16) \ +int name16(MpegEncContext *s, uint8_t *dst, uint8_t *src, \ + ptrdiff_t stride, int h) \ +{ \ + int score = 0; \ + score += name8(s, dst, src, stride, 8); \ + score += name8(s, dst + 8, src + 8, stride, 8); \ + if(h == 16) { \ + dst += 8 * stride; \ + src += 8 * stride; \ + score +=name8(s, dst, src, stride, 8); \ + score +=name8(s, dst + 8, src + 8, stride, 8); \ + } \ + return score; \ +} + +WRAPPER8_16_SQ(ff_hadamard8_diff8x8_msa, ff_hadamard8_diff16_msa); +WRAPPER8_16_SQ(ff_hadamard8_intra8x8_msa, ff_hadamard8_intra16_msa); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegaudiodsp_mips_float.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegaudiodsp_mips_float.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegaudiodsp_mips_float.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegaudiodsp_mips_float.c 2015-07-07 17:20:03.000000000 +0000 @@ -278,7 +278,6 @@ ); } -#if !HAVE_LOONGSON3 static void ff_dct32_mips_float(float *out, const float *tab) { float val0 , val1 , val2 , val3 , val4 , val5 , val6 , val7, @@ -787,7 +786,6 @@ out[15] = val30 + val17; out[31] = val31; } -#endif /* !HAVE_LOONGSON3 */ static void imdct36_mips_float(float *out, float *buf, float *in, float *win) { @@ -1226,7 +1224,6 @@ ); } -#if !HAVE_LOONGSON3 static void ff_imdct36_blocks_mips_float(float *out, float *buf, float *in, int count, int switch_point, int block_type) { @@ -1245,13 +1242,10 @@ out++; } } -#endif /* !HAVE_LOONGSON3 */ void ff_mpadsp_init_mipsfpu(MPADSPContext *s) { s->apply_window_float = ff_mpadsp_apply_window_mips_float; -#if !HAVE_LOONGSON3 s->imdct36_blocks_float = ff_imdct36_blocks_mips_float; s->dct32_float = ff_dct32_mips_float; -#endif /* !HAVE_LOONGSON3 */ } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegvideoencdsp_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegvideoencdsp_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegvideoencdsp_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegvideoencdsp_init_mips.c 2015-07-06 17:20:03.000000000 +0000 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/bit_depth_template.c" +#include "h263dsp_mips.h" + +#if HAVE_MSA +static av_cold void mpegvideoencdsp_init_msa(MpegvideoEncDSPContext *c, + AVCodecContext *avctx) +{ +#if BIT_DEPTH == 8 + c->pix_sum = ff_pix_sum_msa; +#endif +} +#endif // #if HAVE_MSA + +av_cold void ff_mpegvideoencdsp_init_mips(MpegvideoEncDSPContext *c, + AVCodecContext *avctx) +{ +#if HAVE_MSA + mpegvideoencdsp_init_msa(c, avctx); +#endif // #if HAVE_MSA +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegvideoencdsp_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegvideoencdsp_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegvideoencdsp_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegvideoencdsp_msa.c 2015-07-06 17:20:03.000000000 +0000 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * 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 "h263dsp_mips.h" +#include "libavutil/mips/generic_macros_msa.h" + +static int32_t sum_u8src_16width_msa(uint8_t *src, int32_t stride) +{ + uint32_t sum = 0; + v16u8 in0, in1, in2, in3, in4, in5, in6, in7; + v16u8 in8, in9, in10, in11, in12, in13, in14, in15; + + LD_UB8(src, stride, in0, in1, in2, in3, in4, in5, in6, in7); + src += (8 * stride); + LD_UB8(src, stride, in8, in9, in10, in11, in12, in13, in14, in15); + + HADD_UB4_UB(in0, in1, in2, in3, in0, in1, in2, in3); + HADD_UB4_UB(in4, in5, in6, in7, in4, in5, in6, in7); + HADD_UB4_UB(in8, in9, in10, in11, in8, in9, in10, in11); + HADD_UB4_UB(in12, in13, in14, in15, in12, in13, in14, in15); + + sum = HADD_UH_U32(in0); + sum += HADD_UH_U32(in1); + sum += HADD_UH_U32(in2); + sum += HADD_UH_U32(in3); + sum += HADD_UH_U32(in4); + sum += HADD_UH_U32(in5); + sum += HADD_UH_U32(in6); + sum += HADD_UH_U32(in7); + sum += HADD_UH_U32(in8); + sum += HADD_UH_U32(in9); + sum += HADD_UH_U32(in10); + sum += HADD_UH_U32(in11); + sum += HADD_UH_U32(in12); + sum += HADD_UH_U32(in13); + sum += HADD_UH_U32(in14); + sum += HADD_UH_U32(in15); + + return sum; +} + +int ff_pix_sum_msa(uint8_t *pix, int line_size) +{ + return sum_u8src_16width_msa(pix, line_size); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegvideo_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegvideo_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegvideo_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegvideo_init_mips.c 2015-07-15 17:20:03.000000000 +0000 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * 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 "h263dsp_mips.h" +#include "mpegvideo_mips.h" + +#if HAVE_MSA +static av_cold void dct_unquantize_init_msa(MpegEncContext *s) +{ + s->dct_unquantize_h263_intra = ff_dct_unquantize_h263_intra_msa; + s->dct_unquantize_h263_inter = ff_dct_unquantize_h263_inter_msa; + s->dct_unquantize_mpeg2_inter = ff_dct_unquantize_mpeg2_inter_msa; +} +#endif // #if HAVE_MSA + +#if HAVE_MMI +static av_cold void dct_unquantize_init_mmi(MpegEncContext *s) +{ + s->dct_unquantize_h263_intra = ff_dct_unquantize_h263_intra_mmi; + s->dct_unquantize_h263_inter = ff_dct_unquantize_h263_inter_mmi; + s->dct_unquantize_mpeg1_intra = ff_dct_unquantize_mpeg1_intra_mmi; + s->dct_unquantize_mpeg1_inter = ff_dct_unquantize_mpeg1_inter_mmi; +} +#endif /* HAVE_MMI */ + +av_cold void ff_mpv_common_init_mips(MpegEncContext *s) +{ +#if HAVE_MSA + dct_unquantize_init_msa(s); +#endif // #if HAVE_MSA +#if HAVE_MMI + dct_unquantize_init_mmi(s); +#endif /* HAVE_MMI */ +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegvideo_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegvideo_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegvideo_mips.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegvideo_mips.h 2015-07-15 17:20:03.000000000 +0000 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015 Zhou Xiaoyong + * + * 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 + */ + +#ifndef MPEGVIDEO_MIPS_H +#define MPEGVIDEO_MIPS_H + +#include "libavcodec/mpegvideo.h" + +void ff_dct_unquantize_h263_intra_mmi(MpegEncContext *s, int16_t *block, + int n, int qscale); +void ff_dct_unquantize_h263_inter_mmi(MpegEncContext *s, int16_t *block, + int n, int qscale); +void ff_dct_unquantize_mpeg1_intra_mmi(MpegEncContext *s, int16_t *block, + int n, int qscale); +void ff_dct_unquantize_mpeg1_inter_mmi(MpegEncContext *s, int16_t *block, + int n, int qscale); + +#endif /* MPEGVIDEO_MIPS_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegvideo_mmi.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegvideo_mmi.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegvideo_mmi.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegvideo_mmi.c 2015-07-15 17:20:03.000000000 +0000 @@ -0,0 +1,303 @@ +/* + * Loongson SIMD optimized mpegvideo + * + * Copyright (c) 2015 Loongson Technology Corporation Limited + * Copyright (c) 2015 Zhou Xiaoyong + * Zhang Shuangshuang + * + * 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 "mpegvideo_mips.h" + +void ff_dct_unquantize_h263_intra_mmi(MpegEncContext *s, int16_t *block, + int n, int qscale) +{ + int64_t level, qmul, qadd, nCoeffs; + + qmul = qscale << 1; + av_assert2(s->block_last_index[n]>=0 || s->h263_aic); + + if (!s->h263_aic) { + if (n<4) + level = block[0] * s->y_dc_scale; + else + level = block[0] * s->c_dc_scale; + qadd = (qscale-1) | 1; + } else { + qadd = 0; + level = block[0]; + } + + if(s->ac_pred) + nCoeffs = 63; + else + nCoeffs = s->inter_scantable.raster_end[s->block_last_index[n]]; + + __asm__ volatile ( + "xor $f12, $f12, $f12 \r\n" + "lwc1 $f12, %1 \n\r" + "xor $f10, $f10, $f10 \r\n" + "lwc1 $f10, %2 \r\n" + "xor $f14, $f14, $f14 \r\n" + "packsswh $f12, $f12, $f12 \r\n" + "packsswh $f12, $f12, $f12 \r\n" + "packsswh $f10, $f10, $f10 \r\n" + "packsswh $f10, $f10, $f10 \r\n" + "psubh $f14, $f14, $f10 \r\n" + "xor $f8, $f8, $f8 \r\n" + ".p2align 4 \r\n" + "1: \r\n" + "daddu $8, %0, %3 \r\n" + "gsldlc1 $f0, 7($8) \r\n" + "gsldrc1 $f0, 0($8) \r\n" + "gsldlc1 $f2, 15($8) \r\n" + "gsldrc1 $f2, 8($8) \r\n" + "mov.d $f4, $f0 \r\n" + "mov.d $f6, $f2 \r\n" + "pmullh $f0, $f0, $f12 \r\n" + "pmullh $f2, $f2, $f12 \r\n" + "pcmpgth $f4, $f4, $f8 \r\n" + "pcmpgth $f6, $f6, $f8 \r\n" + "xor $f0, $f0, $f4 \r\n" + "xor $f2, $f2, $f6 \r\n" + "paddh $f0, $f0, $f14 \r\n" + "paddh $f2, $f2, $f14 \r\n" + "xor $f4, $f4, $f0 \r\n" + "xor $f6, $f6, $f2 \r\n" + "pcmpeqh $f0, $f0, $f14 \r\n" + "pcmpeqh $f2, $f2, $f14 \r\n" + "pandn $f0, $f0, $f4 \r\n" + "pandn $f2, $f2, $f6 \r\n" + "gssdlc1 $f0, 7($8) \r\n" + "gssdrc1 $f0, 0($8) \r\n" + "gssdlc1 $f2, 15($8) \r\n" + "gssdrc1 $f2, 8($8) \r\n" + "addi %3, %3, 16 \r\n" + "blez %3, 1b \r\n" + ::"r"(block+nCoeffs),"m"(qmul),"m"(qadd),"r"(2*(-nCoeffs)) + :"$8","memory" + ); + + block[0] = level; +} + +void ff_dct_unquantize_h263_inter_mmi(MpegEncContext *s, int16_t *block, + int n, int qscale) +{ + int64_t qmul, qadd, nCoeffs; + + qmul = qscale << 1; + qadd = (qscale - 1) | 1; + av_assert2(s->block_last_index[n]>=0 || s->h263_aic); + nCoeffs = s->inter_scantable.raster_end[s->block_last_index[n]]; + + __asm__ volatile ( + "xor $f12, $f12, $f12 \r\n" + "lwc1 $f12, %1 \r\n" + "xor $f10, $f10, $f10 \r\n" + "lwc1 $f10, %2 \r\n" + "packsswh $f12, $f12, $f12 \r\n" + "packsswh $f12, $f12, $f12 \r\n" + "xor $f14, $f14, $f14 \r\n" + "packsswh $f10, $f10, $f10 \r\n" + "packsswh $f10, $f10, $f10 \r\n" + "psubh $f14, $f14, $f10 \r\n" + "xor $f8, $f8, $f8 \r\n" + ".p2align 4 \r\n" + "1: \r\n" + "daddu $8, %0, %3 \r\n" + "gsldlc1 $f0, 7($8) \r\n" + "gsldrc1 $f0, 0($8) \r\n" + "gsldlc1 $f2, 15($8) \r\n" + "gsldrc1 $f2, 8($8) \r\n" + "mov.d $f4, $f0 \r\n" + "mov.d $f6, $f2 \r\n" + "pmullh $f0, $f0, $f12 \r\n" + "pmullh $f2, $f2, $f12 \r\n" + "pcmpgth $f4, $f4, $f8 \r\n" + "pcmpgth $f6, $f6, $f8 \r\n" + "xor $f0, $f0, $f4 \r\n" + "xor $f2, $f2, $f6 \r\n" + "paddh $f0, $f0, $f14 \r\n" + "paddh $f2, $f2, $f14 \r\n" + "xor $f4, $f4, $f0 \r\n" + "xor $f6, $f6, $f2 \r\n" + "pcmpeqh $f0, $f0, $f14 \r\n" + "pcmpeqh $f2, $f2, $f14 \r\n" + "pandn $f0, $f0, $f4 \r\n" + "pandn $f2, $f2, $f6 \r\n" + "gssdlc1 $f0, 7($8) \r\n" + "gssdrc1 $f0, 0($8) \r\n" + "gssdlc1 $f2, 15($8) \r\n" + "gssdrc1 $f2, 8($8) \r\n" + "addi %3, %3, 16 \r\n" + "blez %3, 1b \r\n" + ::"r"(block+nCoeffs),"m"(qmul),"m"(qadd),"r"(2*(-nCoeffs)) + : "$8","memory" + ); +} + +void ff_dct_unquantize_mpeg1_intra_mmi(MpegEncContext *s, int16_t *block, + int n, int qscale) +{ + int64_t nCoeffs; + const uint16_t *quant_matrix; + int block0; + + av_assert2(s->block_last_index[n]>=0); + nCoeffs = s->intra_scantable.raster_end[s->block_last_index[n]] + 1; + + if (n<4) + block0 = block[0] * s->y_dc_scale; + else + block0 = block[0] * s->c_dc_scale; + + /* XXX: only mpeg1 */ + quant_matrix = s->intra_matrix; + + __asm__ volatile ( + "pcmpeqh $f14, $f14, $f14 \r\n" + "dli $10, 15 \r\n" + "dmtc1 $10, $f16 \r\n" + "xor $f12, $f12, $f12 \r\n" + "lwc1 $f12, %2 \r\n" + "psrlh $f14, $f14, $f16 \r\n" + "packsswh $f12, $f12, $f12 \r\n" + "packsswh $f12, $f12, $f12 \r\n" + "or $8, %3, $0 \r\n" + ".p2align 4 \r\n" + "1: \r\n" + "gsldxc1 $f0, 0($8, %0) \r\n" + "gsldxc1 $f2, 8($8, %0) \r\n" + "mov.d $f16, $f0 \r\n" + "mov.d $f18, $f2 \r\n" + "gsldxc1 $f8, 0($8, %1) \r\n" + "gsldxc1 $f10, 8($8, %1) \r\n" + "pmullh $f8, $f8, $f12 \r\n" + "pmullh $f10, $f10, $f12 \r\n" + "xor $f4, $f4, $f4 \r\n" + "xor $f6, $f6, $f6 \r\n" + "pcmpgth $f4, $f4, $f0 \r\n" + "pcmpgth $f6, $f6, $f2 \r\n" + "xor $f0, $f0, $f4 \r\n" + "xor $f2, $f2, $f6 \r\n" + "psubh $f0, $f0, $f4 \r\n" + "psubh $f2, $f2, $f6 \r\n" + "pmullh $f0, $f0, $f8 \r\n" + "pmullh $f2, $f2, $f10 \r\n" + "xor $f8, $f8, $f8 \r\n" + "xor $f10, $f10, $f10 \r\n" + "pcmpeqh $f8, $f8, $f16 \r\n" + "pcmpeqh $f10, $f10, $f18 \r\n" + "dli $10, 3 \r\n" + "dmtc1 $10, $f16 \r\n" + "psrah $f0, $f0, $f16 \r\n" + "psrah $f2, $f2, $f16 \r\n" + "psubh $f0, $f0, $f14 \r\n" + "psubh $f2, $f2, $f14 \r\n" + "or $f0, $f0, $f14 \r\n" + "or $f2, $f2, $f14 \r\n" + "xor $f0, $f0, $f4 \r\n" + "xor $f2, $f2, $f6 \r\n" + "psubh $f0, $f0, $f4 \r\n" + "psubh $f2, $f2, $f6 \r\n" + "pandn $f8, $f8, $f0 \r\n" + "pandn $f10, $f10, $f2 \r\n" + "gssdxc1 $f8, 0($8, %0) \r\n" + "gssdxc1 $f10, 8($8, %0) \r\n" + "addi $8, $8, 16 \r\n" + "bltz $8, 1b \r\n" + ::"r"(block+nCoeffs),"r"(quant_matrix+nCoeffs),"m"(qscale), + "g"(-2*nCoeffs) + : "$8","$10","memory" + ); + + block[0] = block0; +} + +void ff_dct_unquantize_mpeg1_inter_mmi(MpegEncContext *s, int16_t *block, + int n, int qscale) +{ + int64_t nCoeffs; + const uint16_t *quant_matrix; + + av_assert2(s->block_last_index[n] >= 0); + nCoeffs = s->intra_scantable.raster_end[s->block_last_index[n]] + 1; + quant_matrix = s->inter_matrix; + + __asm__ volatile ( + "pcmpeqh $f14, $f14, $f14 \r\n" + "dli $10, 15 \r\n" + "dmtc1 $10, $f16 \r\n" + "xor $f12, $f12, $f12 \r\n" + "lwc1 $f12, %2 \r\n" + "psrlh $f14, $f14, $f16 \r\n" + "packsswh $f12, $f12, $f12 \r\n" + "packsswh $f12, $f12, $f12 \r\n" + "or $8, %3, $0 \r\n" + ".p2align 4 \r\n" + "1: \r\n" + "gsldxc1 $f0, 0($8, %0) \r\n" + "gsldxc1 $f2, 8($8, %0) \r\n" + "mov.d $f16, $f0 \r\n" + "mov.d $f18, $f2 \r\n" + "gsldxc1 $f8, 0($8, %1) \r\n" + "gsldxc1 $f10, 8($8, %1) \r\n" + "pmullh $f8, $f8, $f12 \r\n" + "pmullh $f10, $f10, $f12 \r\n" + "xor $f4, $f4, $f4 \r\n" + "xor $f6, $f6, $f6 \r\n" + "pcmpgth $f4, $f4, $f0 \r\n" + "pcmpgth $f6, $f6, $f2 \r\n" + "xor $f0, $f0, $f4 \r\n" + "xor $f2, $f2, $f6 \r\n" + "psubh $f0, $f0, $f4 \r\n" + "psubh $f2, $f2, $f6 \r\n" + "paddh $f0, $f0, $f0 \r\n" + "paddh $f2, $f2, $f2 \r\n" + "paddh $f0, $f0, $f14 \r\n" + "paddh $f2, $f2, $f14 \r\n" + "pmullh $f0, $f0, $f8 \r\n" + "pmullh $f2, $f2, $f10 \r\n" + "xor $f8, $f8, $f8 \r\n" + "xor $f10, $f10, $f10 \r\n" + "pcmpeqh $f8, $f8, $f16 \r\n" + "pcmpeqh $f10, $f10, $f18 \r\n" + "dli $10, 4 \r\n" + "dmtc1 $10, $f16 \r\n" + "psrah $f0, $f0, $f16 \r\n" + "psrah $f2, $f2, $f16 \r\n" + "psubh $f0, $f0, $f14 \r\n" + "psubh $f2, $f2, $f14 \r\n" + "or $f0, $f0, $f14 \r\n" + "or $f2, $f2, $f14 \r\n" + "xor $f0, $f0, $f4 \r\n" + "xor $f2, $f2, $f6 \r\n" + "psubh $f0, $f0, $f4 \r\n" + "psubh $f2, $f2, $f6 \r\n" + "pandn $f8, $f8, $f0 \r\n" + "pandn $f10, $f10, $f2 \r\n" + "gssdxc1 $f8, 0($8, %0) \r\n" + "gssdxc1 $f10, 8($8, %0) \r\n" + "addi $8, $8, 16 \r\n" + "bltz $8, 1b \r\n" + ::"r"(block+nCoeffs),"r"(quant_matrix+nCoeffs),"m"(qscale), + "g"(-2*nCoeffs) + :"$8","$10","memory" + ); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegvideo_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegvideo_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/mpegvideo_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/mpegvideo_msa.c 2015-07-01 17:20:03.000000000 +0000 @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "h263dsp_mips.h" + +static void h263_dct_unquantize_msa(int16_t *block, int16_t qmul, + int16_t qadd, int8_t n_coeffs, + uint8_t loop_start) +{ + int16_t *block_dup = block; + int32_t level, cnt; + v8i16 block_vec, qmul_vec, qadd_vec, sub; + v8i16 add, mask, mul, zero_mask; + + qmul_vec = __msa_fill_h(qmul); + qadd_vec = __msa_fill_h(qadd); + for (cnt = 0; cnt < (n_coeffs >> 3); cnt++) { + block_vec = LD_SH(block_dup + loop_start); + mask = __msa_clti_s_h(block_vec, 0); + zero_mask = __msa_ceqi_h(block_vec, 0); + mul = block_vec * qmul_vec; + sub = mul - qadd_vec; + add = mul + qadd_vec; + add = (v8i16) __msa_bmnz_v((v16u8) add, (v16u8) sub, (v16u8) mask); + block_vec = (v8i16) __msa_bmnz_v((v16u8) add, (v16u8) block_vec, + (v16u8) zero_mask); + ST_SH(block_vec, block_dup + loop_start); + block_dup += 8; + } + + cnt = ((n_coeffs >> 3) * 8) + loop_start; + + for (; cnt <= n_coeffs; cnt++) { + level = block[cnt]; + if (level) { + if (level < 0) { + level = level * qmul - qadd; + } else { + level = level * qmul + qadd; + } + block[cnt] = level; + } + } +} + +static int32_t mpeg2_dct_unquantize_inter_msa(int16_t *block, + int32_t qscale, + const int16_t *quant_matrix) +{ + int32_t cnt, sum_res = -1; + v8i16 block_vec, block_neg, qscale_vec, mask; + v8i16 block_org0, block_org1, block_org2, block_org3; + v8i16 quant_m0, quant_m1, quant_m2, quant_m3; + v8i16 sum, mul, zero_mask; + v4i32 mul_vec, qscale_l, qscale_r, quant_m_r, quant_m_l; + v4i32 block_l, block_r, sad; + + qscale_vec = __msa_fill_h(qscale); + for (cnt = 0; cnt < 2; cnt++) { + LD_SH4(block, 8, block_org0, block_org1, block_org2, block_org3); + LD_SH4(quant_matrix, 8, quant_m0, quant_m1, quant_m2, quant_m3); + mask = __msa_clti_s_h(block_org0, 0); + zero_mask = __msa_ceqi_h(block_org0, 0); + block_neg = -block_org0; + block_vec = (v8i16) __msa_bmnz_v((v16u8) block_org0, (v16u8) block_neg, + (v16u8) mask); + block_vec <<= 1; + block_vec += 1; + UNPCK_SH_SW(block_vec, block_r, block_l); + UNPCK_SH_SW(qscale_vec, qscale_r, qscale_l); + UNPCK_SH_SW(quant_m0, quant_m_r, quant_m_l); + mul_vec = block_l * qscale_l; + mul_vec *= quant_m_l; + block_l = mul_vec >> 4; + mul_vec = block_r * qscale_r; + mul_vec *= quant_m_r; + block_r = mul_vec >> 4; + mul = (v8i16) __msa_pckev_h((v8i16) block_l, (v8i16) block_r); + block_neg = - mul; + sum = (v8i16) __msa_bmnz_v((v16u8) mul, (v16u8) block_neg, + (v16u8) mask); + sum = (v8i16) __msa_bmnz_v((v16u8) sum, (v16u8) block_org0, + (v16u8) zero_mask); + ST_SH(sum, block); + block += 8; + quant_matrix += 8; + sad = __msa_hadd_s_w(sum, sum); + sum_res += HADD_SW_S32(sad); + mask = __msa_clti_s_h(block_org1, 0); + zero_mask = __msa_ceqi_h(block_org1, 0); + block_neg = - block_org1; + block_vec = (v8i16) __msa_bmnz_v((v16u8) block_org1, (v16u8) block_neg, + (v16u8) mask); + block_vec <<= 1; + block_vec += 1; + UNPCK_SH_SW(block_vec, block_r, block_l); + UNPCK_SH_SW(qscale_vec, qscale_r, qscale_l); + UNPCK_SH_SW(quant_m1, quant_m_r, quant_m_l); + mul_vec = block_l * qscale_l; + mul_vec *= quant_m_l; + block_l = mul_vec >> 4; + mul_vec = block_r * qscale_r; + mul_vec *= quant_m_r; + block_r = mul_vec >> 4; + mul = __msa_pckev_h((v8i16) block_l, (v8i16) block_r); + block_neg = - mul; + sum = (v8i16) __msa_bmnz_v((v16u8) mul, (v16u8) block_neg, + (v16u8) mask); + sum = (v8i16) __msa_bmnz_v((v16u8) sum, (v16u8) block_org1, + (v16u8) zero_mask); + ST_SH(sum, block); + + block += 8; + quant_matrix += 8; + sad = __msa_hadd_s_w(sum, sum); + sum_res += HADD_SW_S32(sad); + mask = __msa_clti_s_h(block_org2, 0); + zero_mask = __msa_ceqi_h(block_org2, 0); + block_neg = - block_org2; + block_vec = (v8i16) __msa_bmnz_v((v16u8) block_org2, (v16u8) block_neg, + (v16u8) mask); + block_vec <<= 1; + block_vec += 1; + UNPCK_SH_SW(block_vec, block_r, block_l); + UNPCK_SH_SW(qscale_vec, qscale_r, qscale_l); + UNPCK_SH_SW(quant_m2, quant_m_r, quant_m_l); + mul_vec = block_l * qscale_l; + mul_vec *= quant_m_l; + block_l = mul_vec >> 4; + mul_vec = block_r * qscale_r; + mul_vec *= quant_m_r; + block_r = mul_vec >> 4; + mul = __msa_pckev_h((v8i16) block_l, (v8i16) block_r); + block_neg = - mul; + sum = (v8i16) __msa_bmnz_v((v16u8) mul, (v16u8) block_neg, + (v16u8) mask); + sum = (v8i16) __msa_bmnz_v((v16u8) sum, (v16u8) block_org2, + (v16u8) zero_mask); + ST_SH(sum, block); + + block += 8; + quant_matrix += 8; + sad = __msa_hadd_s_w(sum, sum); + sum_res += HADD_SW_S32(sad); + mask = __msa_clti_s_h(block_org3, 0); + zero_mask = __msa_ceqi_h(block_org3, 0); + block_neg = - block_org3; + block_vec = (v8i16) __msa_bmnz_v((v16u8) block_org3, (v16u8) block_neg, + (v16u8) mask); + block_vec <<= 1; + block_vec += 1; + UNPCK_SH_SW(block_vec, block_r, block_l); + UNPCK_SH_SW(qscale_vec, qscale_r, qscale_l); + UNPCK_SH_SW(quant_m3, quant_m_r, quant_m_l); + mul_vec = block_l * qscale_l; + mul_vec *= quant_m_l; + block_l = mul_vec >> 4; + mul_vec = block_r * qscale_r; + mul_vec *= quant_m_r; + block_r = mul_vec >> 4; + mul = __msa_pckev_h((v8i16) block_l, (v8i16) block_r); + block_neg = - mul; + sum = (v8i16) __msa_bmnz_v((v16u8) mul, (v16u8) block_neg, + (v16u8) mask); + sum = (v8i16) __msa_bmnz_v((v16u8) sum, (v16u8) block_org3, + (v16u8) zero_mask); + ST_SH(sum, block); + + block += 8; + quant_matrix += 8; + sad = __msa_hadd_s_w(sum, sum); + sum_res += HADD_SW_S32(sad); + } + + return sum_res; +} + +void ff_dct_unquantize_h263_intra_msa(MpegEncContext *s, + int16_t *block, int32_t index, + int32_t qscale) +{ + int32_t qmul, qadd; + int32_t nCoeffs; + + av_assert2(s->block_last_index[index] >= 0 || s->h263_aic); + + qmul = qscale << 1; + + if (!s->h263_aic) { + block[0] *= index < 4 ? s->y_dc_scale : s->c_dc_scale; + qadd = (qscale - 1) | 1; + } else { + qadd = 0; + } + if (s->ac_pred) + nCoeffs = 63; + else + nCoeffs = s->inter_scantable.raster_end[s->block_last_index[index]]; + + h263_dct_unquantize_msa(block, qmul, qadd, nCoeffs, 1); +} + +void ff_dct_unquantize_h263_inter_msa(MpegEncContext *s, + int16_t *block, int32_t index, + int32_t qscale) +{ + int32_t qmul, qadd; + int32_t nCoeffs; + + av_assert2(s->block_last_index[index] >= 0); + + qadd = (qscale - 1) | 1; + qmul = qscale << 1; + + nCoeffs = s->inter_scantable.raster_end[s->block_last_index[index]]; + + h263_dct_unquantize_msa(block, qmul, qadd, nCoeffs, 0); +} + +void ff_dct_unquantize_mpeg2_inter_msa(MpegEncContext *s, + int16_t *block, int32_t index, + int32_t qscale) +{ + const uint16_t *quant_matrix; + int32_t sum = -1; + + quant_matrix = s->inter_matrix; + + sum = mpeg2_dct_unquantize_inter_msa(block, qscale, quant_matrix); + + block[63] ^= sum & 1; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/pixblockdsp_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/pixblockdsp_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/pixblockdsp_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/pixblockdsp_init_mips.c 2015-07-22 17:20:04.000000000 +0000 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * Zhou Xiaoyong + * + * 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 "pixblockdsp_mips.h" + +#if HAVE_MSA +static av_cold void pixblockdsp_init_msa(PixblockDSPContext *c, + AVCodecContext *avctx, + unsigned high_bit_depth) +{ + c->diff_pixels = ff_diff_pixels_msa; + + switch (avctx->bits_per_raw_sample) { + case 9: + case 10: + case 12: + case 14: + c->get_pixels = ff_get_pixels_16_msa; + break; + default: + if (avctx->bits_per_raw_sample <= 8 || avctx->codec_type != + AVMEDIA_TYPE_VIDEO) { + c->get_pixels = ff_get_pixels_8_msa; + } + break; + } +} +#endif // #if HAVE_MSA + +#if HAVE_MMI +static av_cold void pixblockdsp_init_mmi(PixblockDSPContext *c, + AVCodecContext *avctx, unsigned high_bit_depth) +{ + c->diff_pixels = ff_diff_pixels_mmi; + + if (!high_bit_depth || avctx->codec_type != AVMEDIA_TYPE_VIDEO) { + c->get_pixels = ff_get_pixels_8_mmi; + } +} +#endif /* HAVE_MMI */ + +void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth) +{ +#if HAVE_MSA + pixblockdsp_init_msa(c, avctx, high_bit_depth); +#endif // #if HAVE_MSA +#if HAVE_MMI + pixblockdsp_init_mmi(c, avctx, high_bit_depth); +#endif /* HAVE_MMI */ +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/pixblockdsp_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/pixblockdsp_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/pixblockdsp_mips.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/pixblockdsp_mips.h 2015-07-22 17:20:04.000000000 +0000 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * Zhou Xiaoyong + * + * 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 + */ + +#ifndef AVCODEC_MIPS_PIXBLOCKDSP_MIPS_H +#define AVCODEC_MIPS_PIXBLOCKDSP_MIPS_H + +#include "../mpegvideo.h" + +void ff_diff_pixels_msa(int16_t *av_restrict block, const uint8_t *src1, + const uint8_t *src2, int stride); +void ff_get_pixels_16_msa(int16_t *restrict dst, const uint8_t *src, + ptrdiff_t stride); +void ff_get_pixels_8_msa(int16_t *restrict dst, const uint8_t *src, + ptrdiff_t stride); + +void ff_get_pixels_8_mmi(int16_t *av_restrict block, const uint8_t *pixels, + ptrdiff_t line_size); +void ff_diff_pixels_mmi(int16_t *av_restrict block, const uint8_t *src1, + const uint8_t *src2, int stride); + +#endif // #ifndef AVCODEC_MIPS_PIXBLOCKDSP_MIPS_H diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/pixblockdsp_mmi.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/pixblockdsp_mmi.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/pixblockdsp_mmi.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/pixblockdsp_mmi.c 2015-07-22 17:20:04.000000000 +0000 @@ -0,0 +1,79 @@ +/* + * Loongson SIMD optimized pixblockdsp + * + * Copyright (c) 2015 Loongson Technology Corporation Limited + * Copyright (c) 2015 Zhou Xiaoyong + * + * 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 "pixblockdsp_mips.h" + +void ff_get_pixels_8_mmi(int16_t *av_restrict block, const uint8_t *pixels, + ptrdiff_t line_size) +{ + __asm__ volatile ( + "move $8, $0 \n\t" + "xor $f0, $f0, $f0 \n\t" + "1: \n\t" + "gsldlc1 $f2, 7(%1) \n\t" + "gsldrc1 $f2, 0(%1) \n\t" + "punpcklbh $f4, $f2, $f0 \n\t" + "punpckhbh $f6, $f2, $f0 \n\t" + "gssdxc1 $f4, 0(%0, $8) \n\t" + "gssdxc1 $f6, 8(%0, $8) \n\t" + "daddiu $8, $8, 16 \n\t" + "daddu %1, %1, %2 \n\t" + "daddi %3, %3, -1 \n\t" + "bnez %3, 1b \n\t" + ::"r"((uint8_t *)block),"r"(pixels),"r"(line_size),"r"(8) + : "$8","memory" + ); +} + +void ff_diff_pixels_mmi(int16_t *av_restrict block, const uint8_t *src1, + const uint8_t *src2, int stride) +{ + __asm__ volatile ( + "dli $2, 8 \n\t" + "xor $f14, $f14, $f14 \n\t" + "1: \n\t" + "gsldlc1 $f0, 7(%1) \n\t" + "gsldrc1 $f0, 0(%1) \n\t" + "or $f2, $f0, $f0 \n\t" + "gsldlc1 $f4, 7(%2) \n\t" + "gsldrc1 $f4, 0(%2) \n\t" + "or $f6, $f4, $f4 \n\t" + "punpcklbh $f0, $f0, $f14 \n\t" + "punpckhbh $f2, $f2, $f14 \n\t" + "punpcklbh $f4, $f4, $f14 \n\t" + "punpckhbh $f6, $f6, $f14 \n\t" + "psubh $f0, $f0, $f4 \n\t" + "psubh $f2, $f2, $f6 \n\t" + "gssdlc1 $f0, 7(%0) \n\t" + "gssdrc1 $f0, 0(%0) \n\t" + "gssdlc1 $f2, 15(%0) \n\t" + "gssdrc1 $f2, 8(%0) \n\t" + "daddi %0, %0, 16 \n\t" + "daddu %1, %1, %3 \n\t" + "daddu %2, %2, %3 \n\t" + "daddi $2, $2, -1 \n\t" + "bgtz $2, 1b \n\t" + ::"r"(block),"r"(src1),"r"(src2),"r"(stride) + : "$2","memory" + ); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/pixblockdsp_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/pixblockdsp_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/pixblockdsp_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/pixblockdsp_msa.c 2015-06-29 17:20:04.000000000 +0000 @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "pixblockdsp_mips.h" + +static void diff_pixels_msa(int16_t *block, const uint8_t *src1, + const uint8_t *src2, int32_t stride) +{ + v16u8 in10, in11, in12, in13, in14, in15, in16, in17; + v16u8 in20, in21, in22, in23, in24, in25, in26, in27; + v8i16 out0, out1, out2, out3, out4, out5, out6, out7; + + LD_UB8(src1, stride, in10, in11, in12, in13, in14, in15, in16, in17); + LD_UB8(src2, stride, in20, in21, in22, in23, in24, in25, in26, in27); + ILVR_B4_SH(in10, in20, in11, in21, in12, in22, in13, in23, + out0, out1, out2, out3); + ILVR_B4_SH(in14, in24, in15, in25, in16, in26, in17, in27, + out4, out5, out6, out7); + HSUB_UB4_SH(out0, out1, out2, out3, out0, out1, out2, out3); + HSUB_UB4_SH(out4, out5, out6, out7, out4, out5, out6, out7); + ST_SH8(out0, out1, out2, out3, out4, out5, out6, out7, block, 8); +} + +static void copy_8bit_to_16bit_width8_msa(const uint8_t *src, int32_t src_stride, + int16_t *dst, int32_t dst_stride, + int32_t height) +{ + uint8_t *dst_ptr; + int32_t cnt; + v16u8 src0, src1, src2, src3; + v16i8 zero = { 0 }; + + dst_ptr = (uint8_t *) dst; + + for (cnt = (height >> 2); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + ILVR_B4_UB(zero, src0, zero, src1, zero, src2, zero, src3, + src0, src1, src2, src3); + + ST_UB4(src0, src1, src2, src3, dst_ptr, (dst_stride * 2)); + dst_ptr += (4 * 2 * dst_stride); + } +} + +static void copy_16multx8mult_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, int32_t width) +{ + int32_t cnt, loop_cnt; + const uint8_t *src_tmp; + uint8_t *dst_tmp; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + for (cnt = (width >> 4); cnt--;) { + src_tmp = src; + dst_tmp = dst; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src_tmp, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src_tmp += (8 * src_stride); + + ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, + dst_tmp, dst_stride); + dst_tmp += (8 * dst_stride); + } + + src += 16; + dst += 16; + } +} + +static void copy_width16_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + if (0 == height % 12) { + for (cnt = (height / 12); cnt--;) { + LD_UB8(src, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, + dst, dst_stride); + dst += (8 * dst_stride); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 8) { + copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 16); + } else if (0 == height % 4) { + for (cnt = (height >> 2); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + dst += (4 * dst_stride); + } + } +} + +void ff_get_pixels_16_msa(int16_t *av_restrict dest, const uint8_t *src, + ptrdiff_t stride) +{ + copy_width16_msa(src, stride, (uint8_t *) dest, 16, 8); +} + +void ff_get_pixels_8_msa(int16_t *av_restrict dest, const uint8_t *src, + ptrdiff_t stride) +{ + copy_8bit_to_16bit_width8_msa(src, stride, dest, 8, 8); +} + +void ff_diff_pixels_msa(int16_t *av_restrict block, const uint8_t *src1, + const uint8_t *src2, int stride) +{ + diff_pixels_msa(block, src1, src2, stride); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/qpeldsp_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/qpeldsp_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/qpeldsp_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/qpeldsp_init_mips.c 2015-06-18 17:20:02.000000000 +0000 @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * + * 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 "qpeldsp_mips.h" + +#if HAVE_MSA +static av_cold void qpeldsp_init_msa(QpelDSPContext *c) +{ + c->put_qpel_pixels_tab[0][0] = ff_copy_16x16_msa; + c->put_qpel_pixels_tab[0][1] = ff_horiz_mc_qpel_aver_src0_16width_msa; + c->put_qpel_pixels_tab[0][2] = ff_horiz_mc_qpel_16width_msa; + c->put_qpel_pixels_tab[0][3] = ff_horiz_mc_qpel_aver_src1_16width_msa; + c->put_qpel_pixels_tab[0][4] = ff_vert_mc_qpel_aver_src0_16x16_msa; + c->put_qpel_pixels_tab[0][5] = ff_hv_mc_qpel_aver_hv_src00_16x16_msa; + c->put_qpel_pixels_tab[0][6] = ff_hv_mc_qpel_aver_v_src0_16x16_msa; + c->put_qpel_pixels_tab[0][7] = ff_hv_mc_qpel_aver_hv_src10_16x16_msa; + c->put_qpel_pixels_tab[0][8] = ff_vert_mc_qpel_16x16_msa; + c->put_qpel_pixels_tab[0][9] = ff_hv_mc_qpel_aver_h_src0_16x16_msa; + c->put_qpel_pixels_tab[0][10] = ff_hv_mc_qpel_16x16_msa; + c->put_qpel_pixels_tab[0][11] = ff_hv_mc_qpel_aver_h_src1_16x16_msa; + c->put_qpel_pixels_tab[0][12] = ff_vert_mc_qpel_aver_src1_16x16_msa; + c->put_qpel_pixels_tab[0][13] = ff_hv_mc_qpel_aver_hv_src01_16x16_msa; + c->put_qpel_pixels_tab[0][14] = ff_hv_mc_qpel_aver_v_src1_16x16_msa; + c->put_qpel_pixels_tab[0][15] = ff_hv_mc_qpel_aver_hv_src11_16x16_msa; + + c->put_qpel_pixels_tab[1][0] = ff_copy_8x8_msa; + c->put_qpel_pixels_tab[1][1] = ff_horiz_mc_qpel_aver_src0_8width_msa; + c->put_qpel_pixels_tab[1][2] = ff_horiz_mc_qpel_8width_msa; + c->put_qpel_pixels_tab[1][3] = ff_horiz_mc_qpel_aver_src1_8width_msa; + c->put_qpel_pixels_tab[1][4] = ff_vert_mc_qpel_aver_src0_8x8_msa; + c->put_qpel_pixels_tab[1][5] = ff_hv_mc_qpel_aver_hv_src00_8x8_msa; + c->put_qpel_pixels_tab[1][6] = ff_hv_mc_qpel_aver_v_src0_8x8_msa; + c->put_qpel_pixels_tab[1][7] = ff_hv_mc_qpel_aver_hv_src10_8x8_msa; + c->put_qpel_pixels_tab[1][8] = ff_vert_mc_qpel_8x8_msa; + c->put_qpel_pixels_tab[1][9] = ff_hv_mc_qpel_aver_h_src0_8x8_msa; + c->put_qpel_pixels_tab[1][10] = ff_hv_mc_qpel_8x8_msa; + c->put_qpel_pixels_tab[1][11] = ff_hv_mc_qpel_aver_h_src1_8x8_msa; + c->put_qpel_pixels_tab[1][12] = ff_vert_mc_qpel_aver_src1_8x8_msa; + c->put_qpel_pixels_tab[1][13] = ff_hv_mc_qpel_aver_hv_src01_8x8_msa; + c->put_qpel_pixels_tab[1][14] = ff_hv_mc_qpel_aver_v_src1_8x8_msa; + c->put_qpel_pixels_tab[1][15] = ff_hv_mc_qpel_aver_hv_src11_8x8_msa; + + c->put_no_rnd_qpel_pixels_tab[0][0] = ff_copy_16x16_msa; + c->put_no_rnd_qpel_pixels_tab[0][1] = + ff_horiz_mc_qpel_no_rnd_aver_src0_16width_msa; + c->put_no_rnd_qpel_pixels_tab[0][2] = ff_horiz_mc_qpel_no_rnd_16width_msa; + c->put_no_rnd_qpel_pixels_tab[0][3] = + ff_horiz_mc_qpel_no_rnd_aver_src1_16width_msa; + c->put_no_rnd_qpel_pixels_tab[0][4] = + ff_vert_mc_qpel_no_rnd_aver_src0_16x16_msa; + c->put_no_rnd_qpel_pixels_tab[0][5] = + ff_hv_mc_qpel_no_rnd_aver_hv_src00_16x16_msa; + c->put_no_rnd_qpel_pixels_tab[0][6] = + ff_hv_mc_qpel_no_rnd_aver_v_src0_16x16_msa; + c->put_no_rnd_qpel_pixels_tab[0][7] = + ff_hv_mc_qpel_no_rnd_aver_hv_src10_16x16_msa; + c->put_no_rnd_qpel_pixels_tab[0][8] = ff_vert_mc_qpel_no_rnd_16x16_msa; + c->put_no_rnd_qpel_pixels_tab[0][9] = + ff_hv_mc_qpel_no_rnd_aver_h_src0_16x16_msa; + c->put_no_rnd_qpel_pixels_tab[0][10] = ff_hv_mc_qpel_no_rnd_16x16_msa; + c->put_no_rnd_qpel_pixels_tab[0][11] = + ff_hv_mc_qpel_no_rnd_aver_h_src1_16x16_msa; + c->put_no_rnd_qpel_pixels_tab[0][12] = + ff_vert_mc_qpel_no_rnd_aver_src1_16x16_msa; + c->put_no_rnd_qpel_pixels_tab[0][13] = + ff_hv_mc_qpel_no_rnd_aver_hv_src01_16x16_msa; + c->put_no_rnd_qpel_pixels_tab[0][14] = + ff_hv_mc_qpel_no_rnd_aver_v_src1_16x16_msa; + c->put_no_rnd_qpel_pixels_tab[0][15] = + ff_hv_mc_qpel_no_rnd_aver_hv_src11_16x16_msa; + + c->put_no_rnd_qpel_pixels_tab[1][0] = ff_copy_8x8_msa; + c->put_no_rnd_qpel_pixels_tab[1][1] = + ff_horiz_mc_qpel_no_rnd_aver_src0_8width_msa; + c->put_no_rnd_qpel_pixels_tab[1][2] = ff_horiz_mc_qpel_no_rnd_8width_msa; + c->put_no_rnd_qpel_pixels_tab[1][3] = + ff_horiz_mc_qpel_no_rnd_aver_src1_8width_msa; + c->put_no_rnd_qpel_pixels_tab[1][4] = + ff_vert_mc_qpel_no_rnd_aver_src0_8x8_msa; + c->put_no_rnd_qpel_pixels_tab[1][5] = + ff_hv_mc_qpel_no_rnd_aver_hv_src00_8x8_msa; + c->put_no_rnd_qpel_pixels_tab[1][6] = + ff_hv_mc_qpel_no_rnd_aver_v_src0_8x8_msa; + c->put_no_rnd_qpel_pixels_tab[1][7] = + ff_hv_mc_qpel_no_rnd_aver_hv_src10_8x8_msa; + c->put_no_rnd_qpel_pixels_tab[1][8] = ff_vert_mc_qpel_no_rnd_8x8_msa; + c->put_no_rnd_qpel_pixels_tab[1][9] = + ff_hv_mc_qpel_no_rnd_aver_h_src0_8x8_msa; + c->put_no_rnd_qpel_pixels_tab[1][10] = ff_hv_mc_qpel_no_rnd_8x8_msa; + c->put_no_rnd_qpel_pixels_tab[1][11] = + ff_hv_mc_qpel_no_rnd_aver_h_src1_8x8_msa; + c->put_no_rnd_qpel_pixels_tab[1][12] = + ff_vert_mc_qpel_no_rnd_aver_src1_8x8_msa; + c->put_no_rnd_qpel_pixels_tab[1][13] = + ff_hv_mc_qpel_no_rnd_aver_hv_src01_8x8_msa; + c->put_no_rnd_qpel_pixels_tab[1][14] = + ff_hv_mc_qpel_no_rnd_aver_v_src1_8x8_msa; + c->put_no_rnd_qpel_pixels_tab[1][15] = + ff_hv_mc_qpel_no_rnd_aver_hv_src11_8x8_msa; + + c->avg_qpel_pixels_tab[0][0] = ff_avg_width16_msa; + c->avg_qpel_pixels_tab[0][1] = + ff_horiz_mc_qpel_avg_dst_aver_src0_16width_msa; + c->avg_qpel_pixels_tab[0][2] = ff_horiz_mc_qpel_avg_dst_16width_msa; + c->avg_qpel_pixels_tab[0][3] = + ff_horiz_mc_qpel_avg_dst_aver_src1_16width_msa; + c->avg_qpel_pixels_tab[0][4] = ff_vert_mc_qpel_avg_dst_aver_src0_16x16_msa; + c->avg_qpel_pixels_tab[0][5] = + ff_hv_mc_qpel_avg_dst_aver_hv_src00_16x16_msa; + c->avg_qpel_pixels_tab[0][6] = ff_hv_mc_qpel_avg_dst_aver_v_src0_16x16_msa; + c->avg_qpel_pixels_tab[0][7] = + ff_hv_mc_qpel_avg_dst_aver_hv_src10_16x16_msa; + c->avg_qpel_pixels_tab[0][8] = ff_vert_mc_qpel_avg_dst_16x16_msa; + c->avg_qpel_pixels_tab[0][9] = ff_hv_mc_qpel_avg_dst_aver_h_src0_16x16_msa; + c->avg_qpel_pixels_tab[0][10] = ff_hv_mc_qpel_avg_dst_16x16_msa; + c->avg_qpel_pixels_tab[0][11] = ff_hv_mc_qpel_avg_dst_aver_h_src1_16x16_msa; + c->avg_qpel_pixels_tab[0][12] = ff_vert_mc_qpel_avg_dst_aver_src1_16x16_msa; + c->avg_qpel_pixels_tab[0][13] = + ff_hv_mc_qpel_avg_dst_aver_hv_src01_16x16_msa; + c->avg_qpel_pixels_tab[0][14] = ff_hv_mc_qpel_avg_dst_aver_v_src1_16x16_msa; + c->avg_qpel_pixels_tab[0][15] = + ff_hv_mc_qpel_avg_dst_aver_hv_src11_16x16_msa; + + c->avg_qpel_pixels_tab[1][0] = ff_avg_width8_msa; + c->avg_qpel_pixels_tab[1][1] = + ff_horiz_mc_qpel_avg_dst_aver_src0_8width_msa; + c->avg_qpel_pixels_tab[1][2] = ff_horiz_mc_qpel_avg_dst_8width_msa; + c->avg_qpel_pixels_tab[1][3] = + ff_horiz_mc_qpel_avg_dst_aver_src1_8width_msa; + c->avg_qpel_pixels_tab[1][4] = ff_vert_mc_qpel_avg_dst_aver_src0_8x8_msa; + c->avg_qpel_pixels_tab[1][5] = ff_hv_mc_qpel_avg_dst_aver_hv_src00_8x8_msa; + c->avg_qpel_pixels_tab[1][6] = ff_hv_mc_qpel_avg_dst_aver_v_src0_8x8_msa; + c->avg_qpel_pixels_tab[1][7] = ff_hv_mc_qpel_avg_dst_aver_hv_src10_8x8_msa; + c->avg_qpel_pixels_tab[1][8] = ff_vert_mc_qpel_avg_dst_8x8_msa; + c->avg_qpel_pixels_tab[1][9] = ff_hv_mc_qpel_avg_dst_aver_h_src0_8x8_msa; + c->avg_qpel_pixels_tab[1][10] = ff_hv_mc_qpel_avg_dst_8x8_msa; + c->avg_qpel_pixels_tab[1][11] = ff_hv_mc_qpel_avg_dst_aver_h_src1_8x8_msa; + c->avg_qpel_pixels_tab[1][12] = ff_vert_mc_qpel_avg_dst_aver_src1_8x8_msa; + c->avg_qpel_pixels_tab[1][13] = ff_hv_mc_qpel_avg_dst_aver_hv_src01_8x8_msa; + c->avg_qpel_pixels_tab[1][14] = ff_hv_mc_qpel_avg_dst_aver_v_src1_8x8_msa; + c->avg_qpel_pixels_tab[1][15] = ff_hv_mc_qpel_avg_dst_aver_hv_src11_8x8_msa; +} +#endif // #if HAVE_MSA + +void ff_qpeldsp_init_mips(QpelDSPContext *c) +{ +#if HAVE_MSA + qpeldsp_init_msa(c); +#endif // #if HAVE_MSA +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/qpeldsp_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/qpeldsp_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/qpeldsp_mips.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/qpeldsp_mips.h 2015-06-18 17:20:02.000000000 +0000 @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * + * 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 + */ + +#ifndef AVCODEC_MIPS_QPELDSP_MIPS_H +#define AVCODEC_MIPS_QPELDSP_MIPS_H + +#include "../mpegvideo.h" + +void ff_copy_8x8_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); +void ff_copy_16x16_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); +void ff_avg_width8_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); +void ff_avg_width16_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); + +void ff_horiz_mc_qpel_aver_src0_8width_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_aver_src0_16width_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_8width_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_16width_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_aver_src1_8width_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_aver_src1_16width_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_no_rnd_aver_src0_8width_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_no_rnd_aver_src0_16width_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_no_rnd_8width_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_no_rnd_16width_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_no_rnd_aver_src1_8width_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_no_rnd_aver_src1_16width_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_avg_dst_aver_src0_8width_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_avg_dst_aver_src0_16width_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_avg_dst_8width_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_avg_dst_16width_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_avg_dst_aver_src1_8width_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_horiz_mc_qpel_avg_dst_aver_src1_16width_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); + +void ff_vert_mc_qpel_aver_src0_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_aver_src0_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_aver_src1_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_aver_src1_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_no_rnd_aver_src0_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_no_rnd_aver_src0_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_no_rnd_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_no_rnd_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_no_rnd_aver_src1_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_no_rnd_aver_src1_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_avg_dst_aver_src0_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_avg_dst_aver_src0_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_avg_dst_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_avg_dst_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_avg_dst_aver_src1_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_vert_mc_qpel_avg_dst_aver_src1_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); + +void ff_hv_mc_qpel_aver_hv_src00_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_hv_src00_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_v_src0_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_v_src0_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_hv_src10_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_hv_src10_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_h_src0_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_h_src0_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_8x8_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); +void ff_hv_mc_qpel_aver_h_src1_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_h_src1_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_hv_src01_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_hv_src01_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_v_src1_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_v_src1_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_hv_src11_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_aver_hv_src11_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_hv_src00_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_hv_src00_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_v_src0_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_v_src0_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_hv_src10_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_hv_src10_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_h_src0_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_h_src0_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_h_src1_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_h_src1_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_hv_src01_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_hv_src01_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_v_src1_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_v_src1_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_hv_src11_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_avg_dst_aver_hv_src11_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_hv_src00_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_hv_src00_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_v_src0_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_v_src0_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_hv_src10_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_hv_src10_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_h_src0_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_h_src0_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_16x16_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_8x8_msa(uint8_t *dst, const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_h_src1_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_h_src1_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_hv_src01_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_hv_src01_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_v_src1_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_v_src1_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_hv_src11_16x16_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); +void ff_hv_mc_qpel_no_rnd_aver_hv_src11_8x8_msa(uint8_t *dst, + const uint8_t *src, + ptrdiff_t stride); + +#endif // #ifndef AVCODEC_MIPS_QPELDSP_MIPS_H diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/qpeldsp_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/qpeldsp_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/qpeldsp_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/qpeldsp_msa.c 2015-06-18 17:20:02.000000000 +0000 @@ -0,0 +1,6518 @@ +/* + * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "qpeldsp_mips.h" + +#define APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, coef0, coef1, coef2) \ +( { \ + v16u8 out, tmp0, tmp1; \ + v16u8 data0, data1, data2, data3, data4, data5; \ + v8i16 res_r, res_l; \ + v8u16 sum0_r, sum1_r, sum2_r, sum3_r; \ + v8u16 sum0_l, sum1_l, sum2_l, sum3_l; \ + \ + VSHF_B2_UB(inp0, inp0, inp1, inp1, mask, mask, tmp0, tmp1); \ + ILVRL_B2_UH(inp1, inp0, sum0_r, sum0_l); \ + data0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) tmp0, 15); \ + data3 = (v16u8) __msa_sldi_b((v16i8) tmp1, (v16i8) inp1, 1); \ + HADD_UB2_UH(sum0_r, sum0_l, sum0_r, sum0_l); \ + ILVRL_B2_UH(data3, data0, sum1_r, sum1_l); \ + data1 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) tmp0, 14); \ + data4 = (v16u8) __msa_sldi_b((v16i8) tmp1, (v16i8) inp1, 2); \ + sum0_r *= (v8u16) (coef0); \ + sum0_l *= (v8u16) (coef0); \ + ILVRL_B2_UH(data4, data1, sum2_r, sum2_l); \ + data2 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) tmp0, 13); \ + data5 = (v16u8) __msa_sldi_b((v16i8) tmp1, (v16i8) inp1, 3); \ + DPADD_UB2_UH(sum2_r, sum2_l, coef2, coef2, sum0_r, sum0_l); \ + ILVRL_B2_UH(data5, data2, sum3_r, sum3_l); \ + HADD_UB2_UH(sum3_r, sum3_l, sum3_r, sum3_l); \ + DPADD_UB2_UH(sum1_r, sum1_l, coef1, coef1, sum3_r, sum3_l); \ + res_r = (v8i16) (sum0_r - sum3_r); \ + res_l = (v8i16) (sum0_l - sum3_l); \ + SRARI_H2_SH(res_r, res_l, 5); \ + CLIP_SH2_0_255(res_r, res_l); \ + out = (v16u8) __msa_pckev_b((v16i8) res_l, (v16i8) res_r); \ + \ + out; \ +} ) + +#define APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, \ + mask0, mask1, mask2, mask3, \ + coef0, coef1, coef2) \ +( { \ + v16u8 out; \ + v8u16 sum0_r, sum1_r, sum2_r, sum3_r; \ + v8u16 sum4_r, sum5_r, sum6_r, sum7_r; \ + v8i16 res0_r, res1_r; \ + \ + VSHF_B2_UH(inp0, inp0, inp1, inp1, mask0, mask0, sum0_r, sum4_r); \ + VSHF_B2_UH(inp0, inp0, inp1, inp1, mask3, mask3, sum3_r, sum7_r); \ + HADD_UB2_UH(sum3_r, sum7_r, sum3_r, sum7_r); \ + DOTP_UB2_UH(sum0_r, sum4_r, coef0, coef0, sum0_r, sum4_r); \ + VSHF_B2_UH(inp0, inp0, inp1, inp1, mask2, mask2, sum2_r, sum6_r); \ + VSHF_B2_UH(inp0, inp0, inp1, inp1, mask1, mask1, sum1_r, sum5_r); \ + DPADD_UB2_UH(sum2_r, sum6_r, coef2, coef2, sum0_r, sum4_r); \ + DPADD_UB2_UH(sum1_r, sum5_r, coef1, coef1, sum3_r, sum7_r); \ + res0_r = (v8i16) (sum0_r - sum3_r); \ + res1_r = (v8i16) (sum4_r - sum7_r); \ + SRARI_H2_SH(res0_r, res1_r, 5); \ + CLIP_SH2_0_255(res0_r, res1_r); \ + out = (v16u8) __msa_pckev_b((v16i8) res1_r, (v16i8) res0_r); \ + \ + out; \ +} ) + +#define APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, \ + mask0, mask1, mask2, mask3, \ + coef0, coef1, coef2) \ +( { \ + v16u8 out; \ + v8i16 res0_r; \ + v8u16 sum0_r, sum1_r, sum2_r, sum3_r; \ + \ + VSHF_B2_UH(inp0, inp0, inp0, inp0, mask0, mask3, sum0_r, sum3_r); \ + sum3_r = __msa_hadd_u_h((v16u8) sum3_r, (v16u8) sum3_r); \ + sum0_r = __msa_dotp_u_h((v16u8) sum0_r, (v16u8) coef0); \ + VSHF_B2_UH(inp0, inp0, inp0, inp0, mask2, mask1, sum2_r, sum1_r); \ + DPADD_UB2_UH(sum2_r, sum1_r, coef2, coef1, sum0_r, sum3_r); \ + res0_r = (v8i16) (sum0_r - sum3_r); \ + res0_r = __msa_srari_h(res0_r, 5); \ + res0_r = CLIP_SH_0_255(res0_r); \ + out = (v16u8) __msa_pckev_b((v16i8) res0_r, (v16i8) res0_r); \ + \ + out; \ +} ) + +#define APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1, \ + mask2, mask3, coef0, \ + coef1, coef2) \ +( { \ + v16u8 out; \ + v8i16 res0_r; \ + v8u16 sum0_r, sum1_r, sum2_r, sum3_r; \ + \ + VSHF_B2_UH(inp0, inp0, inp0, inp0, mask0, mask3, sum0_r, sum3_r); \ + sum3_r = __msa_hadd_u_h((v16u8) sum3_r, (v16u8) sum3_r); \ + sum0_r = __msa_dotp_u_h((v16u8) sum0_r, (v16u8) coef0); \ + VSHF_B2_UH(inp0, inp0, inp0, inp0, mask2, mask1, sum2_r, sum1_r); \ + DPADD_UB2_UH(sum2_r, sum1_r, coef2, coef1, sum0_r, sum3_r); \ + res0_r = (v8i16) (sum0_r - sum3_r); \ + res0_r += 15; \ + res0_r >>= 5; \ + res0_r = CLIP_SH_0_255(res0_r); \ + out = (v16u8) __msa_pckev_b((v16i8) res0_r, (v16i8) res0_r); \ + \ + out; \ +} ) + +#define APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask, \ + coef0, coef1, coef2) \ +( { \ + v16u8 out, tmp0, tmp1; \ + v16u8 data0, data1, data2, data3, data4, data5; \ + v8i16 res_r, res_l; \ + v8u16 sum0_r, sum1_r, sum2_r, sum3_r; \ + v8u16 sum0_l, sum1_l, sum2_l, sum3_l; \ + \ + VSHF_B2_UB(inp0, inp0, inp1, inp1, mask, mask, tmp0, tmp1); \ + ILVRL_B2_UH(inp1, inp0, sum0_r, sum0_l); \ + data0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) tmp0, 15); \ + data3 = (v16u8) __msa_sldi_b((v16i8) tmp1, (v16i8) inp1, 1); \ + HADD_UB2_UH(sum0_r, sum0_l, sum0_r, sum0_l); \ + ILVRL_B2_UH(data3, data0, sum1_r, sum1_l); \ + data1 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) tmp0, 14); \ + data4 = (v16u8) __msa_sldi_b((v16i8) tmp1, (v16i8) inp1, 2); \ + sum0_r *= (v8u16) (coef0); \ + sum0_l *= (v8u16) (coef0); \ + ILVRL_B2_UH(data4, data1, sum2_r, sum2_l); \ + data2 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) tmp0, 13); \ + data5 = (v16u8) __msa_sldi_b((v16i8) tmp1, (v16i8) inp1, 3); \ + DPADD_UB2_UH(sum2_r, sum2_l, coef2, coef2, sum0_r, sum0_l); \ + ILVRL_B2_UH(data5, data2, sum3_r, sum3_l); \ + HADD_UB2_UH(sum3_r, sum3_l, sum3_r, sum3_l); \ + DPADD_UB2_UH(sum1_r, sum1_l, coef1, coef1, sum3_r, sum3_l); \ + res_r = (v8i16) (sum0_r - sum3_r); \ + res_l = (v8i16) (sum0_l - sum3_l); \ + res_r += 15; \ + res_l += 15; \ + res_r >>= 5; \ + res_l >>= 5; \ + CLIP_SH2_0_255(res_r, res_l); \ + out = (v16u8) __msa_pckev_b((v16i8) res_l, (v16i8) res_r); \ + \ + out; \ +} ) + +#define APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, \ + mask0, mask1, mask2, mask3, \ + coef0, coef1, coef2) \ +( { \ + v16u8 out; \ + v8i16 res0_r, res1_r; \ + v8u16 sum0_r, sum1_r, sum2_r, sum3_r; \ + v8u16 sum4_r, sum5_r, sum6_r, sum7_r; \ + \ + VSHF_B2_UH(inp0, inp0, inp1, inp1, mask0, mask0, sum0_r, sum4_r); \ + VSHF_B2_UH(inp0, inp0, inp1, inp1, mask3, mask3, sum3_r, sum7_r); \ + HADD_UB2_UH(sum3_r, sum7_r, sum3_r, sum7_r); \ + DOTP_UB2_UH(sum0_r, sum4_r, coef0, coef0, sum0_r, sum4_r); \ + VSHF_B2_UH(inp0, inp0, inp1, inp1, mask2, mask2, sum2_r, sum6_r); \ + VSHF_B2_UH(inp0, inp0, inp1, inp1, mask1, mask1, sum1_r, sum5_r); \ + DPADD_UB2_UH(sum2_r, sum6_r, coef2, coef2, sum0_r, sum4_r); \ + DPADD_UB2_UH(sum1_r, sum5_r, coef1, coef1, sum3_r, sum7_r); \ + res0_r = (v8i16) (sum0_r - sum3_r); \ + res1_r = (v8i16) (sum4_r - sum7_r); \ + res0_r += 15; \ + res1_r += 15; \ + res0_r >>= 5; \ + res1_r >>= 5; \ + CLIP_SH2_0_255(res0_r, res1_r); \ + out = (v16u8) __msa_pckev_b((v16i8) res1_r, (v16i8) res0_r); \ + \ + out; \ +} ) + +#define APPLY_VERT_QPEL_FILTER(inp0, inp1, inp2, inp3, \ + inp4, inp5, inp6, inp7, \ + coef0, coef1, coef2) \ +( { \ + v16u8 res; \ + v8i16 res_r, res_l; \ + v8u16 sum0_r, sum1_r, sum2_r, sum3_r; \ + v8u16 sum0_l, sum1_l, sum2_l, sum3_l; \ + \ + ILVRL_B2_UH(inp4, inp0, sum0_r, sum0_l); \ + ILVRL_B2_UH(inp7, inp3, sum3_r, sum3_l); \ + DOTP_UB2_UH(sum0_r, sum0_l, coef0, coef0, sum0_r, sum0_l); \ + HADD_UB2_UH(sum3_r, sum3_l, sum3_r, sum3_l); \ + ILVRL_B2_UH(inp6, inp2, sum2_r, sum2_l); \ + ILVRL_B2_UH(inp5, inp1, sum1_r, sum1_l); \ + DPADD_UB2_UH(sum2_r, sum2_l, coef2, coef2, sum0_r, sum0_l); \ + DPADD_UB2_UH(sum1_r, sum1_l, coef1, coef1, sum3_r, sum3_l); \ + res_r = (v8i16) (sum0_r - sum3_r); \ + res_l = (v8i16) (sum0_l - sum3_l); \ + SRARI_H2_SH(res_r, res_l, 5); \ + CLIP_SH2_0_255(res_r, res_l); \ + res = (v16u8) __msa_pckev_b((v16i8) res_l, (v16i8) res_r); \ + \ + res; \ +} ) + +#define APPLY_VERT_QPEL_FILTER_8BYTE(inp00, inp01, inp02, inp03, \ + inp04, inp05, inp06, inp07, \ + inp10, inp11, inp12, inp13, \ + inp14, inp15, inp16, inp17, \ + coef0, coef1, coef2) \ +( { \ + v16u8 res; \ + v8i16 val0, val1; \ + v8u16 sum00, sum01, sum02, sum03; \ + v8u16 sum10, sum11, sum12, sum13; \ + \ + ILVR_B4_UH(inp04, inp00, inp14, inp10, inp07, inp03, inp17, inp13, \ + sum00, sum10, sum03, sum13); \ + DOTP_UB2_UH(sum00, sum10, coef0, coef0, sum00, sum10); \ + HADD_UB2_UH(sum03, sum13, sum03, sum13); \ + ILVR_B4_UH(inp06, inp02, inp16, inp12, inp05, inp01, inp15, inp11, \ + sum02, sum12, sum01, sum11); \ + DPADD_UB2_UH(sum02, sum12, coef2, coef2, sum00, sum10); \ + DPADD_UB2_UH(sum01, sum11, coef1, coef1, sum03, sum13); \ + val0 = (v8i16) (sum00 - sum03); \ + val1 = (v8i16) (sum10 - sum13); \ + SRARI_H2_SH(val0, val1, 5); \ + CLIP_SH2_0_255(val0, val1); \ + res = (v16u8) __msa_pckev_b((v16i8) val1, (v16i8) val0); \ + \ + res; \ +} ) + +#define APPLY_VERT_QPEL_NO_ROUND_FILTER(inp0, inp1, inp2, inp3, \ + inp4, inp5, inp6, inp7, \ + coef0, coef1, coef2) \ +( { \ + v16u8 res; \ + v8i16 res_r, res_l; \ + v8u16 sum0_r, sum1_r, sum2_r, sum3_r; \ + v8u16 sum0_l, sum1_l, sum2_l, sum3_l; \ + \ + ILVRL_B2_UH(inp4, inp0, sum0_r, sum0_l); \ + ILVRL_B2_UH(inp7, inp3, sum3_r, sum3_l); \ + DOTP_UB2_UH(sum0_r, sum0_l, coef0, coef0, sum0_r, sum0_l); \ + HADD_UB2_UH(sum3_r, sum3_l, sum3_r, sum3_l); \ + ILVRL_B2_UH(inp6, inp2, sum2_r, sum2_l); \ + ILVRL_B2_UH(inp5, inp1, sum1_r, sum1_l); \ + DPADD_UB2_UH(sum2_r, sum2_l, coef2, coef2, sum0_r, sum0_l); \ + DPADD_UB2_UH(sum1_r, sum1_l, coef1, coef1, sum3_r, sum3_l); \ + res_r = (v8i16) (sum0_r - sum3_r); \ + res_l = (v8i16) (sum0_l - sum3_l); \ + res_r += 15; \ + res_l += 15; \ + res_r >>= 5; \ + res_l >>= 5; \ + CLIP_SH2_0_255(res_r, res_l); \ + res = (v16u8) __msa_pckev_b((v16i8) res_l, (v16i8) res_r); \ + \ + res; \ +} ) + +#define APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp00, inp01, inp02, inp03, \ + inp04, inp05, inp06, inp07, \ + inp10, inp11, inp12, inp13, \ + inp14, inp15, inp16, inp17, \ + coef0, coef1, coef2) \ +( { \ + v16u8 res; \ + v8i16 val0, val1; \ + v8u16 sum00, sum01, sum02, sum03; \ + v8u16 sum10, sum11, sum12, sum13; \ + \ + ILVR_B4_UH(inp04, inp00, inp14, inp10, inp07, inp03, inp17, inp13, \ + sum00, sum10, sum03, sum13); \ + DOTP_UB2_UH(sum00, sum10, coef0, coef0, sum00, sum10); \ + HADD_UB2_UH(sum03, sum13, sum03, sum13); \ + ILVR_B4_UH(inp06, inp02, inp16, inp12, inp05, inp01, inp15, inp11, \ + sum02, sum12, sum01, sum11); \ + DPADD_UB2_UH(sum02, sum12, coef2, coef2, sum00, sum10); \ + DPADD_UB2_UH(sum01, sum11, coef1, coef1, sum03, sum13); \ + val0 = (v8i16) (sum00 - sum03); \ + val1 = (v8i16) (sum10 - sum13); \ + val0 += 15; \ + val1 += 15; \ + val0 >>= 5; \ + val1 >>= 5; \ + CLIP_SH2_0_255(val0, val1); \ + res = (v16u8) __msa_pckev_b((v16i8) val1, (v16i8) val0); \ + \ + res; \ +} ) + +static void horiz_mc_qpel_aver_src0_8width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + AVER_UB2_UB(inp0, res0, inp2, res1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void horiz_mc_qpel_aver_src0_16width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + v8u16 const20 = (v8u16) __msa_ldi_h(20); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, + const20, const6, const3); + res = __msa_aver_u_b(inp0, res); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask, + const20, const6, const3); + res = __msa_aver_u_b(inp2, res); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask, + const20, const6, const3); + res = __msa_aver_u_b(inp4, res); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask, + const20, const6, const3); + res = __msa_aver_u_b(inp6, res); + ST_UB(res, dst); + dst += dst_stride; + } +} + +static void horiz_mc_qpel_8width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void horiz_mc_qpel_16width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v8u16 const20 = (v8u16) __msa_ldi_h(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + } +} + +static void horiz_mc_qpel_aver_src1_8width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + AVER_UB2_UB(inp0, res0, inp2, res1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void horiz_mc_qpel_aver_src1_16width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v8u16 const20 = (v8u16) __msa_ldi_h(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, + const20, const6, const3); + res = __msa_aver_u_b(res, inp1); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask, + const20, const6, const3); + res = __msa_aver_u_b(res, inp3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask, + const20, const6, const3); + res = __msa_aver_u_b(res, inp5); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask, + const20, const6, const3); + res = __msa_aver_u_b(res, inp7); + ST_UB(res, dst); + dst += dst_stride; + } +} + +static void horiz_mc_qpel_no_rnd_aver_src0_8width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + res0 = __msa_ave_u_b(inp0, res0); + res1 = __msa_ave_u_b(inp2, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void horiz_mc_qpel_no_rnd_aver_src0_16width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v8u16 const20 = (v8u16) __msa_ldi_h(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask, + const20, const6, const3); + res = __msa_ave_u_b(inp0, res); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp2, inp3, mask, + const20, const6, const3); + res = __msa_ave_u_b(inp2, res); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp4, inp5, mask, + const20, const6, const3); + res = __msa_ave_u_b(inp4, res); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp6, inp7, mask, + const20, const6, const3); + res = __msa_ave_u_b(inp6, res); + ST_UB(res, dst); + dst += dst_stride; + } +} + +static void horiz_mc_qpel_no_rnd_8width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void horiz_mc_qpel_no_rnd_16width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + v8u16 const20 = (v8u16) __msa_ldi_h(20); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp2, inp3, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp4, inp5, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp6, inp7, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + } +} + +static void horiz_mc_qpel_no_rnd_aver_src1_8width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + res0 = __msa_ave_u_b(inp0, res0); + res1 = __msa_ave_u_b(inp2, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void horiz_mc_qpel_no_rnd_aver_src1_16width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + v8u16 const20 = (v8u16) __msa_ldi_h(20); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask, + const20, const6, const3); + res = __msa_ave_u_b(res, inp1); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp2, inp3, mask, + const20, const6, const3); + res = __msa_ave_u_b(res, inp3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp4, inp5, mask, + const20, const6, const3); + res = __msa_ave_u_b(res, inp5); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp6, inp7, mask, + const20, const6, const3); + res = __msa_ave_u_b(res, inp7); + ST_UB(res, dst); + dst += dst_stride; + } +} + +static void horiz_mc_qpel_avg_dst_aver_src0_8width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3; + v16u8 dst0, dst1, dst2, dst3; + v16u8 res0, res1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1); + dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3); + AVER_UB2_UB(inp0, res0, inp2, res1, res0, res1); + AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void horiz_mc_qpel_avg_dst_aver_src0_16width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res0, res1; + v16u8 dst0, dst1; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + v8u16 const20 = (v8u16) __msa_ldi_h(20); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(inp0, res0, inp2, res1, res0, res1); + AVER_UB2_UB(dst0, res0, dst1, res1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + res0 = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(inp4, res0, inp6, res1, res0, res1); + AVER_UB2_UB(dst0, res0, dst1, res1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + } +} + +static void horiz_mc_qpel_avg_dst_8width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3; + v16u8 dst0, dst1, dst2, dst3; + v16u8 res0, res1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1); + dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3); + AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void horiz_mc_qpel_avg_dst_16width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res0, res1; + v16u8 dst0, dst1; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + v8u16 const20 = (v8u16) __msa_ldi_h(20); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(dst0, res0, dst1, res1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + res0 = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(dst0, res0, dst1, res1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + } +} + +static void horiz_mc_qpel_avg_dst_aver_src1_8width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3; + v16u8 dst0, dst1, dst2, dst3; + v16u8 res0, res1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1); + dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3); + AVER_UB2_UB(inp0, res0, inp2, res1, res0, res1); + AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void horiz_mc_qpel_avg_dst_aver_src1_16width_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res0, res1, dst0, dst1; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + v8u16 const20 = (v8u16) __msa_ldi_h(20); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp1, res1, inp3, res0, res1); + AVER_UB2_UB(dst0, res0, dst1, res1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + res0 = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp5, res1, inp7, res0, res1); + AVER_UB2_UB(dst0, res0, dst1, res1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + } +} + + +static void vert_mc_qpel_aver_src0_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 tmp0, tmp1, res0, res1; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + LD_UB2(src, src_stride, inp4, inp5); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + LD_UB2(src, src_stride, inp6, inp7); + src += (2 * src_stride); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + tmp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + tmp1 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + + inp8 = LD_UB(src); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp8, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp6, inp5, inp4, inp3, + inp7, inp8, inp8, inp7, + inp7, inp6, inp5, inp4, + inp8, inp8, inp7, inp6, + const20, const6, const3); + tmp0 = (v16u8) __msa_insve_d((v2i64) inp4, 1, (v2i64) inp5); + tmp1 = (v16u8) __msa_insve_d((v2i64) inp6, 1, (v2i64) inp7); + AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); +} + +static void vert_mc_qpel_aver_src0_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16; + v16u8 res0; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4); + src += (5 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp0); + ST_UB(res0, dst); + dst += dst_stride; + + inp5 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp1); + ST_UB(res0, dst); + dst += dst_stride; + + inp6 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp2); + ST_UB(res0, dst); + dst += dst_stride; + + inp7 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp3); + ST_UB(res0, dst); + dst += dst_stride; + + LD_UB2(src, src_stride, inp8, inp9); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp4); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER(inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp9, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp5); + ST_UB(res0, dst); + dst += dst_stride; + + LD_UB2(src, src_stride, inp10, inp11); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER(inp6, inp5, inp4, inp3, + inp7, inp8, inp9, inp10, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp6); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER(inp7, inp6, inp5, inp4, + inp8, inp9, inp10, inp11, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp7); + ST_UB(res0, dst); + dst += dst_stride; + + LD_UB2(src, src_stride, inp12, inp13); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER(inp8, inp7, inp6, inp5, + inp9, inp10, inp11, inp12, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp8); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER(inp9, inp8, inp7, inp6, + inp10, inp11, inp12, inp13, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp9); + ST_UB(res0, dst); + dst += dst_stride; + + LD_UB2(src, src_stride, inp14, inp15); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER(inp10, inp9, inp8, inp7, + inp11, inp12, inp13, inp14, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp10); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER(inp11, inp10, inp9, inp8, + inp12, inp13, inp14, inp15, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp11); + ST_UB(res0, dst); + dst += dst_stride; + + inp16 = LD_UB(src); + res0 = APPLY_VERT_QPEL_FILTER(inp12, inp11, inp10, inp9, + inp13, inp14, inp15, inp16, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp12); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER(inp13, inp12, inp11, inp10, + inp14, inp15, inp16, inp16, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp13); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER(inp14, inp13, inp12, inp11, + inp15, inp16, inp16, inp15, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp14); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER(inp15, inp14, inp13, inp12, + inp16, inp16, inp15, inp14, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp15); + ST_UB(res0, dst); +} + +static void vert_mc_qpel_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 res0, res1; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + LD_UB2(src, src_stride, inp4, inp5); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + LD_UB2(src, src_stride, inp6, inp7); + src += (2 * src_stride); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + + inp8 = LD_UB(src); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp8, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp6, inp5, inp4, inp3, + inp7, inp8, inp8, inp7, + inp7, inp6, inp5, inp4, + inp8, inp8, inp7, inp6, + const20, const6, const3); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); +} + +static void vert_mc_qpel_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16; + v16u8 res0; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + inp4 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp5 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp6 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp7 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp8 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp9 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp9, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp10 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp6, inp5, inp4, inp3, + inp7, inp8, inp9, inp10, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp11 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp7, inp6, inp5, inp4, + inp8, inp9, inp10, inp11, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp12 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp8, inp7, inp6, inp5, + inp9, inp10, inp11, inp12, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp13 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp9, inp8, inp7, inp6, + inp10, inp11, inp12, inp13, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp14 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp10, inp9, inp8, inp7, + inp11, inp12, inp13, inp14, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp15 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp11, inp10, inp9, inp8, + inp12, inp13, inp14, inp15, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp16 = LD_UB(src); + res0 = APPLY_VERT_QPEL_FILTER(inp12, inp11, inp10, inp9, + inp13, inp14, inp15, inp16, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER(inp13, inp12, inp11, inp10, + inp14, inp15, inp16, inp16, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER(inp14, inp13, inp12, inp11, + inp15, inp16, inp16, inp15, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER(inp15, inp14, inp13, inp12, + inp16, inp16, inp15, inp14, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; +} + +static void vert_mc_qpel_aver_src1_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 tmp0, tmp1, res0, res1; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + LD_UB2(src, src_stride, inp4, inp5); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + + LD_UB2(src, src_stride, inp6, inp7); + src += (2 * src_stride); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + tmp0 = (v16u8) __msa_insve_d((v2i64) inp1, 1, (v2i64) inp2); + tmp1 = (v16u8) __msa_insve_d((v2i64) inp3, 1, (v2i64) inp4); + AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + + inp8 = LD_UB(src); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp8, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp6, inp5, inp4, inp3, + inp7, inp8, inp8, inp7, + inp7, inp6, inp5, inp4, + inp8, inp8, inp7, inp6, + const20, const6, const3); + tmp0 = (v16u8) __msa_insve_d((v2i64) inp5, 1, (v2i64) inp6); + tmp1 = (v16u8) __msa_insve_d((v2i64) inp7, 1, (v2i64) inp8); + AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); +} + +static void vert_mc_qpel_aver_src1_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16; + v16u8 res0; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + inp4 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp1); + ST_UB(res0, dst); + dst += dst_stride; + + inp5 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp2); + ST_UB(res0, dst); + dst += dst_stride; + + inp6 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp3); + ST_UB(res0, dst); + dst += dst_stride; + + inp7 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp4); + ST_UB(res0, dst); + dst += dst_stride; + + inp8 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp5); + ST_UB(res0, dst); + dst += dst_stride; + + inp9 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp9, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp6); + ST_UB(res0, dst); + dst += dst_stride; + + inp10 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp6, inp5, inp4, inp3, + inp7, inp8, inp9, inp10, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp7); + ST_UB(res0, dst); + dst += dst_stride; + + inp11 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp7, inp6, inp5, inp4, + inp8, inp9, inp10, inp11, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp8); + ST_UB(res0, dst); + dst += dst_stride; + + inp12 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp8, inp7, inp6, inp5, + inp9, inp10, inp11, inp12, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp9); + ST_UB(res0, dst); + dst += dst_stride; + + inp13 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp9, inp8, inp7, inp6, + inp10, inp11, inp12, inp13, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp10); + ST_UB(res0, dst); + dst += dst_stride; + + inp14 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp10, inp9, inp8, inp7, + inp11, inp12, inp13, inp14, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp11); + ST_UB(res0, dst); + dst += dst_stride; + + inp15 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp11, inp10, inp9, inp8, + inp12, inp13, inp14, inp15, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp12); + ST_UB(res0, dst); + dst += dst_stride; + + inp16 = LD_UB(src); + res0 = APPLY_VERT_QPEL_FILTER(inp12, inp11, inp10, inp9, + inp13, inp14, inp15, inp16, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp13); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER(inp13, inp12, inp11, inp10, + inp14, inp15, inp16, inp16, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp14); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER(inp14, inp13, inp12, inp11, + inp15, inp16, inp16, inp15, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp15); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER(inp15, inp14, inp13, inp12, + inp16, inp16, inp15, inp14, + const20, const6, const3); + res0 = __msa_aver_u_b(res0, inp16); + ST_UB(res0, dst); +} + +static void vert_mc_qpel_no_rnd_aver_src0_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 tmp0, tmp1, res0, res1; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + LD_UB2(src, src_stride, inp4, inp5); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + LD_UB2(src, src_stride, inp6, inp7); + src += (2 * src_stride); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + tmp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + tmp1 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + res0 = __msa_ave_u_b(res0, tmp0); + res1 = __msa_ave_u_b(res1, tmp1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + + inp8 = LD_UB(src); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp8, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp6, inp5, inp4, inp3, + inp7, inp8, inp8, inp7, + inp7, inp6, inp5, inp4, + inp8, inp8, inp7, inp6, + const20, const6, const3); + tmp0 = (v16u8) __msa_insve_d((v2i64) inp4, 1, (v2i64) inp5); + tmp1 = (v16u8) __msa_insve_d((v2i64) inp6, 1, (v2i64) inp7); + res0 = __msa_ave_u_b(res0, tmp0); + res1 = __msa_ave_u_b(res1, tmp1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); +} + +static void vert_mc_qpel_no_rnd_aver_src0_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16; + v16u8 res0; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4); + src += (5 * src_stride); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp0); + ST_UB(res0, dst); + dst += dst_stride; + + inp5 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp1); + ST_UB(res0, dst); + dst += dst_stride; + + inp6 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp2); + ST_UB(res0, dst); + dst += dst_stride; + + inp7 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp3); + ST_UB(res0, dst); + dst += dst_stride; + + inp8 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp4); + ST_UB(res0, dst); + dst += dst_stride; + + inp9 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp9, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp5); + ST_UB(res0, dst); + dst += dst_stride; + + inp10 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp6, inp5, inp4, inp3, + inp7, inp8, inp9, inp10, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp6); + ST_UB(res0, dst); + dst += dst_stride; + + inp11 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp7, inp6, inp5, inp4, + inp8, inp9, inp10, inp11, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp7); + ST_UB(res0, dst); + dst += dst_stride; + + inp12 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp8, inp7, inp6, inp5, + inp9, inp10, inp11, inp12, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp8); + ST_UB(res0, dst); + dst += dst_stride; + + inp13 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp9, inp8, inp7, inp6, + inp10, inp11, inp12, inp13, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp9); + ST_UB(res0, dst); + dst += dst_stride; + + inp14 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp10, inp9, inp8, inp7, + inp11, inp12, inp13, inp14, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp10); + ST_UB(res0, dst); + dst += dst_stride; + + inp15 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp11, inp10, inp9, inp8, + inp12, inp13, inp14, inp15, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp11); + ST_UB(res0, dst); + dst += dst_stride; + + inp16 = LD_UB(src); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp12, inp11, inp10, inp9, + inp13, inp14, inp15, inp16, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp12); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp13, inp12, inp11, inp10, + inp14, inp15, inp16, inp16, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp13); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp14, inp13, inp12, inp11, + inp15, inp16, inp16, inp15, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp14); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp15, inp14, inp13, inp12, + inp16, inp16, inp15, inp14, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp15); + ST_UB(res0, dst); + dst += dst_stride; +} + +static void vert_mc_qpel_no_rnd_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 res0, res1; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + LD_UB2(src, src_stride, inp4, inp5); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + LD_UB2(src, src_stride, inp6, inp7); + src += (2 * src_stride); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + + inp8 = LD_UB(src); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp8, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp6, inp5, inp4, inp3, + inp7, inp8, inp8, inp7, + inp7, inp6, inp5, inp4, + inp8, inp8, inp7, inp6, + const20, const6, const3); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); +} + +static void vert_mc_qpel_no_rnd_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16; + v16u8 res0; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4); + src += (5 * src_stride); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp5 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp6 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp7 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp8 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp9 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp9, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp10 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp6, inp5, inp4, inp3, + inp7, inp8, inp9, inp10, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp11 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp7, inp6, inp5, inp4, + inp8, inp9, inp10, inp11, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp12 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp8, inp7, inp6, inp5, + inp9, inp10, inp11, inp12, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp13 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp9, inp8, inp7, inp6, + inp10, inp11, inp12, inp13, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp14 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp10, inp9, inp8, inp7, + inp11, inp12, inp13, inp14, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp15 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp11, inp10, inp9, inp8, + inp12, inp13, inp14, inp15, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + inp16 = LD_UB(src); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp12, inp11, inp10, inp9, + inp13, inp14, inp15, inp16, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp13, inp12, inp11, inp10, + inp14, inp15, inp16, inp16, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp14, inp13, inp12, inp11, + inp15, inp16, inp16, inp15, + const20, const6, const3); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp15, inp14, inp13, inp12, + inp16, inp16, inp15, inp14, + const20, const6, const3); + ST_UB(res0, dst); +} + +static void vert_mc_qpel_no_rnd_aver_src1_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 tmp0, tmp1, res0, res1; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + LD_UB2(src, src_stride, inp4, inp5); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + LD_UB2(src, src_stride, inp6, inp7); + src += (2 * src_stride); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + tmp0 = (v16u8) __msa_insve_d((v2i64) inp1, 1, (v2i64) inp2); + tmp1 = (v16u8) __msa_insve_d((v2i64) inp3, 1, (v2i64) inp4); + res0 = __msa_ave_u_b(res0, tmp0); + res1 = __msa_ave_u_b(res1, tmp1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + + inp8 = LD_UB(src); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp8, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp6, inp5, inp4, inp3, + inp7, inp8, inp8, inp7, + inp7, inp6, inp5, inp4, + inp8, inp8, inp7, inp6, + const20, const6, const3); + tmp0 = (v16u8) __msa_insve_d((v2i64) inp5, 1, (v2i64) inp6); + tmp1 = (v16u8) __msa_insve_d((v2i64) inp7, 1, (v2i64) inp8); + res0 = __msa_ave_u_b(res0, tmp0); + res1 = __msa_ave_u_b(res1, tmp1); + ST8x4_UB(res0, res1, dst, dst_stride); +} + +static void vert_mc_qpel_no_rnd_aver_src1_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16; + v16u8 res0; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4); + src += (5 * src_stride); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp1); + ST_UB(res0, dst); + dst += dst_stride; + + inp5 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp2); + ST_UB(res0, dst); + dst += dst_stride; + + inp6 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp3); + ST_UB(res0, dst); + dst += dst_stride; + + inp7 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp4); + ST_UB(res0, dst); + dst += dst_stride; + + inp8 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp5); + ST_UB(res0, dst); + dst += dst_stride; + + inp9 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp9, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp6); + ST_UB(res0, dst); + dst += dst_stride; + + inp10 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp6, inp5, inp4, inp3, + inp7, inp8, inp9, inp10, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp7); + ST_UB(res0, dst); + dst += dst_stride; + + inp11 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp7, inp6, inp5, inp4, + inp8, inp9, inp10, inp11, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp8); + ST_UB(res0, dst); + dst += dst_stride; + + inp12 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp8, inp7, inp6, inp5, + inp9, inp10, inp11, inp12, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp9); + ST_UB(res0, dst); + dst += dst_stride; + + inp13 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp9, inp8, inp7, inp6, + inp10, inp11, inp12, inp13, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp10); + ST_UB(res0, dst); + dst += dst_stride; + + inp14 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp10, inp9, inp8, inp7, + inp11, inp12, inp13, inp14, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp11); + ST_UB(res0, dst); + dst += dst_stride; + + inp15 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp11, inp10, inp9, inp8, + inp12, inp13, inp14, inp15, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp12); + ST_UB(res0, dst); + dst += dst_stride; + + inp16 = LD_UB(src); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp12, inp11, inp10, inp9, + inp13, inp14, inp15, inp16, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp13); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp13, inp12, inp11, inp10, + inp14, inp15, inp16, inp16, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp14); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp14, inp13, inp12, inp11, + inp15, inp16, inp16, inp15, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp15); + ST_UB(res0, dst); + dst += dst_stride; + + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp15, inp14, inp13, inp12, + inp16, inp16, inp15, inp14, + const20, const6, const3); + res0 = __msa_ave_u_b(res0, inp16); + ST_UB(res0, dst); +} + +static void vert_mc_qpel_avg_dst_aver_src0_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 dst0, dst1, dst2, dst3; + v16u8 tmp0, tmp1, res0, res1; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + LD_UB2(src, src_stride, inp4, inp5); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + + LD_UB2(src, src_stride, inp6, inp7); + src += (2 * src_stride); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + tmp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + tmp1 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1); + dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3); + AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1); + AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + + inp8 = LD_UB(src); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp8, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp6, inp5, inp4, inp3, + inp7, inp8, inp8, inp7, + inp7, inp6, inp5, inp4, + inp8, inp8, inp7, inp6, + const20, const6, const3); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + tmp0 = (v16u8) __msa_insve_d((v2i64) inp4, 1, (v2i64) inp5); + tmp1 = (v16u8) __msa_insve_d((v2i64) inp6, 1, (v2i64) inp7); + dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1); + dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3); + AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1); + AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); +} + +static void vert_mc_qpel_avg_dst_aver_src0_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16; + v16u8 res0, res1, dst0, dst1; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4); + src += (5 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + const20, const6, const3); + + inp5 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp0, res1, inp1, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp6 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + const20, const6, const3); + + inp7 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp2, res1, inp3, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp8, inp9); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER(inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp9, + const20, const6, const3); + + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp4, res1, inp5, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp10, inp11); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER(inp6, inp5, inp4, inp3, + inp7, inp8, inp9, inp10, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER(inp7, inp6, inp5, inp4, + inp8, inp9, inp10, inp11, + const20, const6, const3); + + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp6, res1, inp7, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp12, inp13); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER(inp8, inp7, inp6, inp5, + inp9, inp10, inp11, inp12, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER(inp9, inp8, inp7, inp6, + inp10, inp11, inp12, inp13, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp8, res1, inp9, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp14, inp15); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER(inp10, inp9, inp8, inp7, + inp11, inp12, inp13, inp14, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER(inp11, inp10, inp9, inp8, + inp12, inp13, inp14, inp15, + const20, const6, const3); + + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp10, res1, inp11, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp16 = LD_UB(src); + res0 = APPLY_VERT_QPEL_FILTER(inp12, inp11, inp10, inp9, + inp13, inp14, inp15, inp16, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER(inp13, inp12, inp11, inp10, + inp14, inp15, inp16, inp16, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp12, res1, inp13, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + res0 = APPLY_VERT_QPEL_FILTER(inp14, inp13, inp12, inp11, + inp15, inp16, inp16, inp15, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER(inp15, inp14, inp13, inp12, + inp16, inp16, inp15, inp14, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp14, res1, inp15, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); +} + +static void vert_mc_qpel_avg_dst_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 dst0, dst1, dst2, dst3; + v16u8 res0, res1; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + LD_UB2(src, src_stride, inp4, inp5); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + LD_UB2(src, src_stride, inp6, inp7); + src += (2 * src_stride); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1); + dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3); + AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + + inp8 = LD_UB(src); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp8, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp6, inp5, inp4, inp3, + inp7, inp8, inp8, inp7, + inp7, inp6, inp5, inp4, + inp8, inp8, inp7, inp6, + const20, const6, const3); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1); + dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3); + AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); +} + +static void vert_mc_qpel_avg_dst_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16; + v16u8 res0, res1, dst0, dst1; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4); + src += (5 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + const20, const6, const3); + inp5 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp6 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + const20, const6, const3); + inp7 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp8 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + const20, const6, const3); + inp9 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp9, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp10 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp6, inp5, inp4, inp3, + inp7, inp8, inp9, inp10, + const20, const6, const3); + inp11 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp7, inp6, inp5, inp4, + inp8, inp9, inp10, inp11, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp12 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp8, inp7, inp6, inp5, + inp9, inp10, inp11, inp12, + const20, const6, const3); + inp13 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp9, inp8, inp7, inp6, + inp10, inp11, inp12, inp13, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp14 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp10, inp9, inp8, inp7, + inp11, inp12, inp13, inp14, + const20, const6, const3); + inp15 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp11, inp10, inp9, inp8, + inp12, inp13, inp14, inp15, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp16 = LD_UB(src); + res0 = APPLY_VERT_QPEL_FILTER(inp12, inp11, inp10, inp9, + inp13, inp14, inp15, inp16, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER(inp13, inp12, inp11, inp10, + inp14, inp15, inp16, inp16, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + res0 = APPLY_VERT_QPEL_FILTER(inp14, inp13, inp12, inp11, + inp15, inp16, inp16, inp15, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER(inp15, inp14, inp13, inp12, + inp16, inp16, inp15, inp14, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); +} + +static void vert_mc_qpel_avg_dst_aver_src1_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 dst0, dst1, dst2, dst3; + v16u8 tmp0, tmp1, res0, res1; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + LD_UB2(src, src_stride, inp4, inp5); + src += (2 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + LD_UB2(src, src_stride, inp6, inp7); + src += (2 * src_stride); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + tmp0 = (v16u8) __msa_insve_d((v2i64) inp1, 1, (v2i64) inp2); + tmp1 = (v16u8) __msa_insve_d((v2i64) inp3, 1, (v2i64) inp4); + dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1); + dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3); + AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1); + AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); + dst += (4 * dst_stride); + + inp8 = LD_UB(src); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp8, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp6, inp5, inp4, inp3, + inp7, inp8, inp8, inp7, + inp7, inp6, inp5, inp4, + inp8, inp8, inp7, inp6, + const20, const6, const3); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + tmp0 = (v16u8) __msa_insve_d((v2i64) inp5, 1, (v2i64) inp6); + tmp1 = (v16u8) __msa_insve_d((v2i64) inp7, 1, (v2i64) inp8); + dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1); + dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3); + AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1); + AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1); + ST8x4_UB(res0, res1, dst, dst_stride); +} + +static void vert_mc_qpel_avg_dst_aver_src1_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8; + v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16; + v16u8 res0, res1, dst0, dst1; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4); + src += (5 * src_stride); + res0 = APPLY_VERT_QPEL_FILTER(inp0, inp0, inp1, inp2, + inp1, inp2, inp3, inp4, + const20, const6, const3); + inp5 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp1, inp0, inp0, inp1, + inp2, inp3, inp4, inp5, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp1, res1, inp2, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp6 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp2, inp1, inp0, inp0, + inp3, inp4, inp5, inp6, + const20, const6, const3); + inp7 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp3, inp2, inp1, inp0, + inp4, inp5, inp6, inp7, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp3, res1, inp4, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp8 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp4, inp3, inp2, inp1, + inp5, inp6, inp7, inp8, + const20, const6, const3); + inp9 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp5, inp4, inp3, inp2, + inp6, inp7, inp8, inp9, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp5, res1, inp6, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp10 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp6, inp5, inp4, inp3, + inp7, inp8, inp9, inp10, + const20, const6, const3); + inp11 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp7, inp6, inp5, inp4, + inp8, inp9, inp10, inp11, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp7, res1, inp8, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp12 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp8, inp7, inp6, inp5, + inp9, inp10, inp11, inp12, + const20, const6, const3); + inp13 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp9, inp8, inp7, inp6, + inp10, inp11, inp12, inp13, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp9, res1, inp10, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp14 = LD_UB(src); + src += src_stride; + res0 = APPLY_VERT_QPEL_FILTER(inp10, inp9, inp8, inp7, + inp11, inp12, inp13, inp14, + const20, const6, const3); + inp15 = LD_UB(src); + src += src_stride; + res1 = APPLY_VERT_QPEL_FILTER(inp11, inp10, inp9, inp8, + inp12, inp13, inp14, inp15, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp11, res1, inp12, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp16 = LD_UB(src); + res0 = APPLY_VERT_QPEL_FILTER(inp12, inp11, inp10, inp9, + inp13, inp14, inp15, inp16, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER(inp13, inp12, inp11, inp10, + inp14, inp15, inp16, inp16, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp13, res1, inp14, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); + dst += (2 * dst_stride); + + res0 = APPLY_VERT_QPEL_FILTER(inp14, inp13, inp12, inp11, + inp15, inp16, inp16, inp15, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER(inp15, inp14, inp13, inp12, + inp16, inp16, inp15, inp14, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + AVER_UB2_UB(res0, inp15, res1, inp16, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1); + ST_UB2(res0, res1, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_horiz_src0_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + v8u16 const20 = (v8u16) __msa_ldi_h(20); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask, + const20, const6, const3); + res = __msa_ave_u_b(inp0, res); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp2, inp3, mask, + const20, const6, const3); + res = __msa_ave_u_b(inp2, res); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp4, inp5, mask, + const20, const6, const3); + res = __msa_ave_u_b(inp4, res); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp6, inp7, mask, + const20, const6, const3); + res = __msa_ave_u_b(inp6, res); + ST_UB(res, dst); + dst += dst_stride; + } + + LD_UB2(src, 1, inp0, inp1); + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask, + const20, const6, const3); + res = __msa_ave_u_b(inp0, res); + ST_UB(res, dst); +} + +static void hv_mc_qpel_no_rnd_aver_hv_src00_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_no_rnd_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_no_rnd_aver_src0_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_aver_hv_src00_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz0 = __msa_ave_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz2 = __msa_ave_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz4 = __msa_ave_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0); + res0 = __msa_ave_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz6 = __msa_ave_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz8 = __msa_ave_u_b(inp0, res0); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2); + res1 = __msa_ave_u_b(avg1, res1); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4); + res0 = __msa_ave_u_b(avg0, res0); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6); + res1 = __msa_ave_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_horiz_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + v8u16 const20 = (v8u16) __msa_ldi_h(20); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp2, inp3, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp4, inp5, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp6, inp7, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + } + + LD_UB2(src, 1, inp0, inp1); + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask, + const20, const6, const3); + ST_UB(res, dst); +} + +static void hv_mc_qpel_no_rnd_aver_v_src0_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_no_rnd_horiz_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_no_rnd_aver_src0_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_aver_v_src0_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz2 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz4 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0); + res0 = __msa_ave_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz6 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + inp0 = LD_UB(src); + horiz8 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1, + mask2, mask3, const20, + const6, const3); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2); + res1 = __msa_ave_u_b(avg1, res1); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0); + res0 = __msa_ave_u_b(avg0, res0); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); + + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4); + res0 = __msa_ave_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6); + res1 = __msa_ave_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_horiz_src1_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + v8u16 const20 = (v8u16) __msa_ldi_h(20); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask, + const20, const6, const3); + res = __msa_ave_u_b(res, inp1); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp2, inp3, mask, + const20, const6, const3); + res = __msa_ave_u_b(res, inp3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp4, inp5, mask, + const20, const6, const3); + res = __msa_ave_u_b(res, inp5); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp6, inp7, mask, + const20, const6, const3); + res = __msa_ave_u_b(res, inp7); + ST_UB(res, dst); + dst += dst_stride; + } + + LD_UB2(src, 1, inp0, inp1); + res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask, + const20, const6, const3); + res = __msa_ave_u_b(inp1, res); + ST_UB(res, dst); +} + +static void hv_mc_qpel_no_rnd_aver_hv_src10_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_no_rnd_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_no_rnd_aver_src0_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_aver_hv_src10_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + horiz0 = __msa_ave_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + horiz2 = __msa_ave_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + horiz4 = __msa_ave_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0); + res0 = __msa_ave_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + horiz6 = __msa_ave_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1); + horiz8 = __msa_ave_u_b(inp0, res0); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2); + res1 = __msa_ave_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); + + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4); + res0 = __msa_ave_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6); + res1 = __msa_ave_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_aver_h_src0_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_no_rnd_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_no_rnd_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_aver_h_src0_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz0 = __msa_ave_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz2 = __msa_ave_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz4 = __msa_ave_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz6 = __msa_ave_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz8 = __msa_ave_u_b(inp0, res0); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_no_rnd_horiz_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_no_rnd_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz2 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz4 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + + horiz6 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + inp0 = LD_UB(src); + horiz8 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1, + mask2, mask3, const20, + const6, const3); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + + + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_aver_h_src1_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_no_rnd_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_no_rnd_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_aver_h_src1_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + horiz0 = __msa_ave_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + horiz2 = __msa_ave_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + horiz4 = __msa_ave_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + horiz6 = __msa_ave_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1); + horiz8 = __msa_ave_u_b(inp0, res0); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_aver_hv_src01_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_no_rnd_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_no_rnd_aver_src1_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_aver_hv_src01_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz0 = __msa_ave_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz2 = __msa_ave_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz4 = __msa_ave_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1); + res0 = __msa_ave_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz6 = __msa_ave_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz8 = __msa_ave_u_b(inp0, res0); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3); + res1 = __msa_ave_u_b(avg1, res1); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5); + res0 = __msa_ave_u_b(avg0, res0); + + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7); + res1 = __msa_ave_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_aver_v_src1_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_no_rnd_horiz_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_no_rnd_aver_src1_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_aver_v_src1_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz2 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz4 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1); + res0 = __msa_ave_u_b(avg0, res0); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + + horiz6 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3); + res1 = __msa_ave_u_b(avg1, res1); + inp0 = LD_UB(src); + horiz8 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1, + mask2, mask3, const20, + const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5); + res0 = __msa_ave_u_b(avg0, res0); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7); + res1 = __msa_ave_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_aver_hv_src11_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_no_rnd_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_no_rnd_aver_src1_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_no_rnd_aver_hv_src11_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + horiz0 = __msa_ave_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + horiz2 = __msa_ave_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1, + mask2, mask3, const20, + const6, const3); + + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + horiz4 = __msa_ave_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1); + res0 = __msa_ave_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1, + mask2, mask3, const20, + const6, const3); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + horiz6 = __msa_ave_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3); + res1 = __msa_ave_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1, + mask2, mask3, const20, + const6, const3); + inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1); + horiz8 = __msa_ave_u_b(inp0, res0); + res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5); + res0 = __msa_ave_u_b(avg0, res0); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7); + res1 = __msa_ave_u_b(avg1, res1); + ST8x4_UB(res0, res1, dst, dst_stride); +} + +static void hv_mc_qpel_aver_horiz_src0_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + v8u16 const20 = (v8u16) __msa_ldi_h(20); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, + const20, const6, const3); + res = __msa_aver_u_b(inp0, res); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask, + const20, const6, const3); + res = __msa_aver_u_b(inp2, res); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask, + const20, const6, const3); + res = __msa_aver_u_b(inp4, res); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask, + const20, const6, const3); + res = __msa_aver_u_b(inp6, res); + ST_UB(res, dst); + dst += dst_stride; + } + + LD_UB2(src, 1, inp0, inp1); + res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, const20, const6, const3); + res = __msa_aver_u_b(inp0, res); + ST_UB(res, dst); +} + +static void hv_mc_qpel_aver_hv_src00_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_aver_src0_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_aver_hv_src00_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz0 = __msa_aver_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz2 = __msa_aver_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz4 = __msa_aver_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz6 = __msa_aver_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2); + res1 = __msa_aver_u_b(avg1, res1); + + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz8 = __msa_aver_u_b(inp0, res0); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4); + res0 = __msa_aver_u_b(avg0, res0); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_aver_horiz_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + v8u16 const20 = (v8u16) __msa_ldi_h(20); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask, + const20, const6, const3); + ST_UB(res, dst); + dst += dst_stride; + } + + LD_UB2(src, 1, inp0, inp1); + res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, const20, const6, const3); + ST_UB(res, dst); +} + +static void hv_mc_qpel_aver_v_src0_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_aver_src0_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_aver_v_src0_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz2 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz4 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz6 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + inp0 = LD_UB(src); + horiz8 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, + mask0, mask1, mask2, mask3, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2); + res1 = __msa_aver_u_b(avg1, res1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4); + res0 = __msa_aver_u_b(avg0, res0); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_aver_horiz_src1_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + int32_t height) +{ + uint8_t loop_count; + v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7; + v16u8 res; + v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + v8u16 const20 = (v8u16) __msa_ldi_h(20); + + for (loop_count = (height >> 2); loop_count--;) { + LD_UB4(src, src_stride, inp0, inp2, inp4, inp6); + LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7); + src += (4 * src_stride); + res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, + const20, const6, const3); + res = __msa_aver_u_b(res, inp1); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask, + const20, const6, const3); + res = __msa_aver_u_b(res, inp3); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask, + const20, const6, const3); + res = __msa_aver_u_b(res, inp5); + ST_UB(res, dst); + dst += dst_stride; + + res = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask, + const20, const6, const3); + res = __msa_aver_u_b(res, inp7); + ST_UB(res, dst); + dst += dst_stride; + } + + LD_UB2(src, 1, inp0, inp1); + res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, const20, const6, const3); + res = __msa_aver_u_b(inp1, res); + ST_UB(res, dst); +} + +static void hv_mc_qpel_aver_hv_src10_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_aver_src0_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_aver_hv_src10_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + horiz0 = __msa_aver_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + horiz2 = __msa_aver_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + horiz4 = __msa_aver_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + horiz6 = __msa_aver_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0); + res0 = __msa_aver_u_b(avg0, res0); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2); + res1 = __msa_aver_u_b(avg1, res1); + inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1); + horiz8 = __msa_aver_u_b(inp0, res0); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4); + res0 = __msa_aver_u_b(avg0, res0); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_aver_h_src0_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_aver_h_src0_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz0 = __msa_aver_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz2 = __msa_aver_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz4 = __msa_aver_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz6 = __msa_aver_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz8 = __msa_aver_u_b(inp0, res0); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_8x8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz2 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz4 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz6 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + inp0 = LD_UB(src); + horiz8 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, + mask0, mask1, mask2, mask3, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_aver_h_src1_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_aver_h_src1_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + horiz0 = __msa_aver_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + horiz2 = __msa_aver_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + horiz4 = __msa_aver_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + horiz6 = __msa_aver_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1); + horiz8 = __msa_aver_u_b(inp0, res0); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); + + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_aver_hv_src01_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_aver_src1_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_aver_hv_src01_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz0 = __msa_aver_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz2 = __msa_aver_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz4 = __msa_aver_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_insve_d((v2i64) horiz1, 1, (v2i64) horiz2); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz6 = __msa_aver_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz8 = __msa_aver_u_b(inp0, res0); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_insve_d((v2i64) horiz3, 1, (v2i64) horiz4); + res1 = __msa_aver_u_b(avg1, res1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + + avg0 = (v16u8) __msa_insve_d((v2i64) horiz5, 1, (v2i64) horiz6); + res0 = __msa_aver_u_b(avg0, res0); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + + avg1 = (v16u8) __msa_insve_d((v2i64) horiz7, 1, (v2i64) horiz8); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); +} + +static void hv_mc_qpel_aver_v_src1_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_aver_src1_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_aver_v_src1_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz2 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz4 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_insve_d((v2i64) horiz1, 1, (v2i64) horiz2); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz6 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + inp0 = LD_UB(src); + horiz8 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, + mask0, mask1, mask2, mask3, + const20, const6, const3); + avg1 = (v16u8) __msa_insve_d((v2i64) horiz3, 1, (v2i64) horiz4); + res1 = __msa_aver_u_b(avg1, res1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + avg0 = (v16u8) __msa_insve_d((v2i64) horiz5, 1, (v2i64) horiz6); + res0 = __msa_aver_u_b(avg0, res0); + + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + avg1 = (v16u8) __msa_insve_d((v2i64) horiz7, 1, (v2i64) horiz8); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_aver_hv_src11_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_aver_src1_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_aver_hv_src11_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB4(src, src_stride, inp0, inp1, inp2, inp3); + src += (4 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + horiz0 = __msa_aver_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + horiz2 = __msa_aver_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1); + horiz4 = __msa_aver_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1); + res0 = __msa_aver_u_b(avg0, res0); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3); + horiz6 = __msa_aver_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3); + res1 = __msa_aver_u_b(avg1, res1); + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1); + horiz8 = __msa_aver_u_b(inp0, res0); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + ST8x2_UB(res1, dst, dst_stride); + dst += 2 * dst_stride; + + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5); + res0 = __msa_aver_u_b(avg0, res0); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + ST8x2_UB(res0, dst, dst_stride); + dst += 2 * dst_stride; + + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_hv_src00_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_avg_dst_aver_src0_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_hv_src00_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 dst0, dst1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz0 = __msa_aver_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz2 = __msa_aver_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz4 = __msa_aver_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + res0 = __msa_aver_u_b(avg0, res0); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz6 = __msa_aver_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + res1 = __msa_aver_u_b(avg1, res1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz8 = __msa_aver_u_b(inp0, res0); + LD_UB2(dst, dst_stride, dst0, dst1); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + res0 = __msa_aver_u_b(avg0, res0); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + res1 = __msa_aver_u_b(avg1, res1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_v_src0_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_avg_dst_aver_src0_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_v_src0_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 dst0, dst1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + horiz2 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + horiz4 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + res0 = __msa_aver_u_b(avg0, res0); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz6 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + res1 = __msa_aver_u_b(avg1, res1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp0 = LD_UB(src); + horiz8 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, + mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + res0 = __msa_aver_u_b(avg0, res0); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + res1 = __msa_aver_u_b(avg1, res1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_hv_src10_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_avg_dst_aver_src0_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_hv_src10_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 dst0, dst1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz0 = __msa_aver_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz2 = __msa_aver_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz4 = __msa_aver_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + res0 = __msa_aver_u_b(avg0, res0); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz6 = __msa_aver_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + res1 = __msa_aver_u_b(avg1, res1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1); + horiz8 = __msa_aver_u_b(inp0, res0); + LD_UB2(dst, dst_stride, dst0, dst1); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + res0 = __msa_aver_u_b(avg0, res0); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + res1 = __msa_aver_u_b(avg1, res1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_h_src0_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_avg_dst_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_h_src0_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 dst0, dst1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz0 = __msa_aver_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz2 = __msa_aver_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz4 = __msa_aver_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz6 = __msa_aver_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz8 = __msa_aver_u_b(inp0, res0); + LD_UB2(dst, dst_stride, dst0, dst1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); +} + +static void hv_mc_qpel_avg_dst_16x16_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_avg_dst_16x16_msa(buff, 16, dst, dst_stride); + +} + +static void hv_mc_qpel_avg_dst_8x8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 dst0, dst1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + horiz2 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + horiz4 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz6 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + inp0 = LD_UB(src); + horiz8 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, + mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(dst, dst_stride, dst0, dst1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_h_src1_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_avg_dst_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_h_src1_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 dst0, dst1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz0 = __msa_aver_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz2 = __msa_aver_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz4 = __msa_aver_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz6 = __msa_aver_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1); + horiz8 = __msa_aver_u_b(inp0, res0); + LD_UB2(dst, dst_stride, dst0, dst1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_hv_src01_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_avg_dst_aver_src1_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_hv_src01_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 dst0, dst1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz0 = __msa_aver_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz2 = __msa_aver_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz4 = __msa_aver_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1); + res0 = __msa_aver_u_b(avg0, res0); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz6 = __msa_aver_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3); + res1 = __msa_aver_u_b(avg1, res1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz8 = __msa_aver_u_b(inp0, res0); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, + horiz5, horiz6, horiz7, horiz8, + horiz5, horiz4, horiz3, horiz2, + horiz6, horiz7, horiz8, horiz8, + const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, + horiz7, horiz8, horiz8, horiz7, + horiz7, horiz6, horiz5, horiz4, + horiz8, horiz8, horiz7, horiz6, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5); + res0 = __msa_aver_u_b(avg0, res0); + LD_UB2(dst, dst_stride, dst0, dst1); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7); + res1 = __msa_aver_u_b(avg1, res1); + LD_UB2(dst, dst_stride, dst0, dst1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_v_src1_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_avg_dst_aver_src1_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_v_src1_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 dst0, dst1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz2 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + horiz4 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, + horiz1, horiz2, horiz3, horiz4, + horiz1, horiz0, horiz0, horiz1, + horiz2, horiz3, horiz4, horiz5, + const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1); + res0 = __msa_aver_u_b(avg0, res0); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + horiz6 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, + mask0, mask1, mask2, mask3, + const20, const6, const3); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, + horiz3, horiz4, horiz5, horiz6, + horiz3, horiz2, horiz1, horiz0, + horiz4, horiz5, horiz6, horiz7, + const20, const6, const3); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3); + res1 = __msa_aver_u_b(avg1, res1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp0 = LD_UB(src); + horiz8 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, + mask0, mask1, mask2, mask3, + const20, const6, const3); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, horiz5, + horiz6, horiz7, horiz8, horiz5, horiz4, + horiz3, horiz2, horiz6, horiz7, horiz8, + horiz8, const20, const6, const3); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, horiz7, + horiz8, horiz8, horiz7, horiz7, horiz6, + horiz5, horiz4, horiz8, horiz8, horiz7, + horiz6, const20, const6, const3); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5); + res0 = __msa_aver_u_b(avg0, res0); + LD_UB2(dst, dst_stride, dst0, dst1); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7); + res1 = __msa_aver_u_b(avg1, res1); + LD_UB2(dst, dst_stride, dst0, dst1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_hv_src11_16x16_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + uint8_t buff[272]; + + hv_mc_qpel_aver_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16); + vert_mc_qpel_avg_dst_aver_src1_16x16_msa(buff, 16, dst, dst_stride); +} + +static void hv_mc_qpel_avg_dst_aver_hv_src11_8x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride) +{ + v16u8 inp0, inp1, inp2, inp3; + v16u8 res0, res1, avg0, avg1; + v16u8 horiz0, horiz1, horiz2, horiz3; + v16u8 horiz4, horiz5, horiz6, horiz7, horiz8; + v16u8 dst0, dst1; + v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; + v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 }; + v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 }; + v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 }; + v16u8 const20 = (v16u8) __msa_ldi_b(20); + v16u8 const6 = (v16u8) __msa_ldi_b(6); + v16u8 const3 = (v16u8) __msa_ldi_b(3); + + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz0 = __msa_aver_u_b(inp0, res0); + horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + LD_UB2(src, src_stride, inp0, inp1); + src += (2 * src_stride); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz2 = __msa_aver_u_b(inp2, res1); + horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3, + const20, const6, const3); + SLDI_B2_UB(inp0, inp1, inp0, inp1, inp0, inp1, 1); + + inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0); + horiz4 = __msa_aver_u_b(inp0, res0); + horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, horiz1, + horiz2, horiz3, horiz4, horiz1, horiz0, + horiz0, horiz1, horiz2, horiz3, horiz4, + horiz5, const20, const6, const3); + res0 = __msa_aver_u_b(avg0, res0); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(src, src_stride, inp2, inp3); + src += (2 * src_stride); + res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3, + const20, const6, const3); + SLDI_B2_UB(inp2, inp3, inp2, inp3, inp2, inp3, 1); + + inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2); + horiz6 = __msa_aver_u_b(inp2, res1); + horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1); + LD_UB2(dst, dst_stride, dst0, dst1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, horiz3, + horiz4, horiz5, horiz6, horiz3, horiz2, + horiz1, horiz0, horiz4, horiz5, horiz6, + horiz7, const20, const6, const3); + res1 = __msa_aver_u_b(avg1, res1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); + dst += (2 * dst_stride); + + inp0 = LD_UB(src); + res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3, + const20, const6, const3); + inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1); + horiz8 = __msa_aver_u_b(inp0, res0); + LD_UB2(dst, dst_stride, dst0, dst1); + avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5); + res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, horiz5, + horiz6, horiz7, horiz8, horiz5, horiz4, + horiz3, horiz2, horiz6, horiz7, horiz8, + horiz8, const20, const6, const3); + res0 = __msa_aver_u_b(avg0, res0); + avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res0 = __msa_aver_u_b(avg0, res0); + ST8x2_UB(res0, dst, dst_stride); + dst += (2 * dst_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7); + res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, horiz7, + horiz8, horiz8, horiz7, horiz7, horiz6, + horiz5, horiz4, horiz8, horiz8, horiz7, + horiz6, const20, const6, const3); + res1 = __msa_aver_u_b(avg1, res1); + avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + res1 = __msa_aver_u_b(avg1, res1); + ST8x2_UB(res1, dst, dst_stride); +} + +static void copy_8x8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + uint64_t src0, src1; + int32_t loop_cnt; + + for (loop_cnt = 4; loop_cnt--;) { + src0 = LD(src); + src += src_stride; + src1 = LD(src); + src += src_stride; + + SD(src0, dst); + dst += dst_stride; + SD(src1, dst); + dst += dst_stride; + } +} + +static void copy_16x16_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride) +{ + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + v16u8 src8, src9, src10, src11, src12, src13, src14, src15; + + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + LD_UB8(src, src_stride, + src8, src9, src10, src11, src12, src13, src14, src15); + + ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, dst, dst_stride); + dst += (8 * dst_stride); + ST_UB8(src8, src9, src10, src11, src12, src13, src14, src15, + dst, dst_stride); +} + +static void avg_width8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint64_t out0, out1, out2, out3; + v16u8 src0, src1, src2, src3; + v16u8 dst0, dst1, dst2, dst3; + + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + + out0 = __msa_copy_u_d((v2i64) dst0, 0); + out1 = __msa_copy_u_d((v2i64) dst1, 0); + out2 = __msa_copy_u_d((v2i64) dst2, 0); + out3 = __msa_copy_u_d((v2i64) dst3, 0); + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void avg_width16_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + + for (cnt = (height / 8); cnt--;) { + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + LD_UB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + AVER_UB4_UB(src4, dst4, src5, dst5, src6, dst6, src7, dst7, + dst4, dst5, dst6, dst7); + ST_UB8(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst, dst_stride); + dst += (8 * dst_stride); + } +} + +void ff_copy_16x16_msa(uint8_t *dest, const uint8_t *src, ptrdiff_t stride) +{ + copy_16x16_msa(src, stride, dest, stride); +} + +void ff_copy_8x8_msa(uint8_t *dest, const uint8_t *src, ptrdiff_t stride) +{ + copy_8x8_msa(src, stride, dest, stride); +} + +void ff_horiz_mc_qpel_aver_src0_8width_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + horiz_mc_qpel_aver_src0_8width_msa(src, stride, dest, stride, 8); +} + +void ff_horiz_mc_qpel_aver_src0_16width_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + horiz_mc_qpel_aver_src0_16width_msa(src, stride, dest, stride, 16); +} + +void ff_horiz_mc_qpel_8width_msa(uint8_t *dest, const uint8_t *src, + ptrdiff_t stride) +{ + horiz_mc_qpel_8width_msa(src, stride, dest, stride, 8); +} + +void ff_horiz_mc_qpel_16width_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + horiz_mc_qpel_16width_msa(src, stride, dest, stride, 16); +} + +void ff_horiz_mc_qpel_aver_src1_8width_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + horiz_mc_qpel_aver_src1_8width_msa(src, stride, dest, stride, 8); +} + +void ff_horiz_mc_qpel_aver_src1_16width_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + horiz_mc_qpel_aver_src1_16width_msa(src, stride, dest, stride, 16); +} + +void ff_horiz_mc_qpel_no_rnd_aver_src0_8width_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + horiz_mc_qpel_no_rnd_aver_src0_8width_msa(src, stride, dest, stride, 8); +} + +void ff_horiz_mc_qpel_no_rnd_aver_src0_16width_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + horiz_mc_qpel_no_rnd_aver_src0_16width_msa(src, stride, dest, stride, 16); +} + +void ff_horiz_mc_qpel_no_rnd_8width_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + horiz_mc_qpel_no_rnd_8width_msa(src, stride, dest, stride, 8); +} + +void ff_horiz_mc_qpel_no_rnd_16width_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + horiz_mc_qpel_no_rnd_16width_msa(src, stride, dest, stride, 16); +} + +void ff_horiz_mc_qpel_no_rnd_aver_src1_8width_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + horiz_mc_qpel_no_rnd_aver_src1_8width_msa(src, stride, dest, stride, 8); +} + +void ff_horiz_mc_qpel_no_rnd_aver_src1_16width_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + horiz_mc_qpel_no_rnd_aver_src1_16width_msa(src, stride, dest, stride, 16); +} + +void ff_avg_width8_msa(uint8_t *dest, const uint8_t *src, ptrdiff_t stride) +{ + avg_width8_msa(src, stride, dest, stride, 8); +} + +void ff_avg_width16_msa(uint8_t *dest, const uint8_t *src, ptrdiff_t stride) +{ + avg_width16_msa(src, stride, dest, stride, 16); +} + +void ff_horiz_mc_qpel_avg_dst_aver_src0_8width_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + horiz_mc_qpel_avg_dst_aver_src0_8width_msa(src, stride, dest, stride, 8); +} + +void ff_horiz_mc_qpel_avg_dst_aver_src0_16width_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + horiz_mc_qpel_avg_dst_aver_src0_16width_msa(src, stride, dest, stride, 16); +} + +void ff_horiz_mc_qpel_avg_dst_8width_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + horiz_mc_qpel_avg_dst_8width_msa(src, stride, dest, stride, 8); +} + +void ff_horiz_mc_qpel_avg_dst_16width_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + horiz_mc_qpel_avg_dst_16width_msa(src, stride, dest, stride, 16); +} + +void ff_horiz_mc_qpel_avg_dst_aver_src1_8width_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + horiz_mc_qpel_avg_dst_aver_src1_8width_msa(src, stride, dest, stride, 8); +} + +void ff_horiz_mc_qpel_avg_dst_aver_src1_16width_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + horiz_mc_qpel_avg_dst_aver_src1_16width_msa(src, stride, dest, stride, 16); +} + + +void ff_vert_mc_qpel_aver_src0_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + vert_mc_qpel_aver_src0_8x8_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_aver_src0_16x16_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + vert_mc_qpel_aver_src0_16x16_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_8x8_msa(uint8_t *dest, const uint8_t *src, + ptrdiff_t stride) +{ + vert_mc_qpel_8x8_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_16x16_msa(uint8_t *dest, const uint8_t *src, + ptrdiff_t stride) +{ + vert_mc_qpel_16x16_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_aver_src1_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + vert_mc_qpel_aver_src1_8x8_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_aver_src1_16x16_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + vert_mc_qpel_aver_src1_16x16_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_no_rnd_aver_src0_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + vert_mc_qpel_no_rnd_aver_src0_8x8_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_no_rnd_aver_src0_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + vert_mc_qpel_no_rnd_aver_src0_16x16_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_no_rnd_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + vert_mc_qpel_no_rnd_8x8_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_no_rnd_16x16_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + vert_mc_qpel_no_rnd_16x16_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_no_rnd_aver_src1_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + vert_mc_qpel_no_rnd_aver_src1_8x8_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_no_rnd_aver_src1_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + vert_mc_qpel_no_rnd_aver_src1_16x16_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_avg_dst_aver_src0_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + vert_mc_qpel_avg_dst_aver_src0_8x8_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_avg_dst_aver_src0_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + vert_mc_qpel_avg_dst_aver_src0_16x16_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_avg_dst_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + vert_mc_qpel_avg_dst_8x8_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_avg_dst_16x16_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + vert_mc_qpel_avg_dst_16x16_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_avg_dst_aver_src1_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + vert_mc_qpel_avg_dst_aver_src1_8x8_msa(src, stride, dest, stride); +} + +void ff_vert_mc_qpel_avg_dst_aver_src1_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + vert_mc_qpel_avg_dst_aver_src1_16x16_msa(src, stride, dest, stride); +} + +/* HV cases */ +void ff_hv_mc_qpel_aver_hv_src00_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_aver_hv_src00_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_hv_src00_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_aver_hv_src00_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_v_src0_16x16_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_aver_v_src0_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_v_src0_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_aver_v_src0_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_hv_src10_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_aver_hv_src10_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_hv_src10_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_aver_hv_src10_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_h_src0_16x16_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_aver_h_src0_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_h_src0_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_aver_h_src0_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_16x16_msa(uint8_t *dest, const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_8x8_msa(uint8_t *dest, const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_h_src1_16x16_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_aver_h_src1_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_h_src1_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_aver_h_src1_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_hv_src01_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_aver_hv_src01_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_hv_src01_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_aver_hv_src01_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_v_src1_16x16_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_aver_v_src1_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_v_src1_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_aver_v_src1_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_hv_src11_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_aver_hv_src11_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_aver_hv_src11_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_aver_hv_src11_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_hv_src00_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_hv_src00_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_hv_src00_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_hv_src00_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_v_src0_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_v_src0_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_v_src0_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_v_src0_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_hv_src10_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_hv_src10_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_hv_src10_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_hv_src10_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_h_src0_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_h_src0_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_h_src0_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_h_src0_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_16x16_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_h_src1_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_h_src1_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_h_src1_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_h_src1_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_hv_src01_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_hv_src01_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_hv_src01_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_hv_src01_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_v_src1_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_v_src1_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_v_src1_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_v_src1_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_hv_src11_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_hv_src11_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_avg_dst_aver_hv_src11_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_avg_dst_aver_hv_src11_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_hv_src00_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_hv_src00_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_hv_src00_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_hv_src00_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_v_src0_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_v_src0_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_v_src0_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_v_src0_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_hv_src10_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_hv_src10_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_hv_src10_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_hv_src10_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_h_src0_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_h_src0_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_h_src0_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_h_src0_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_16x16_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_8x8_msa(uint8_t *dest, + const uint8_t *src, ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_h_src1_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_h_src1_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_h_src1_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_h_src1_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_hv_src01_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_hv_src01_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_hv_src01_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_hv_src01_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_v_src1_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_v_src1_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_v_src1_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_v_src1_8x8_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_hv_src11_16x16_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_hv_src11_16x16_msa(src, stride, dest, stride); +} + +void ff_hv_mc_qpel_no_rnd_aver_hv_src11_8x8_msa(uint8_t *dest, + const uint8_t *src, + ptrdiff_t stride) +{ + hv_mc_qpel_no_rnd_aver_hv_src11_8x8_msa(src, stride, dest, stride); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/sbrdsp_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/sbrdsp_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/sbrdsp_mips.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/sbrdsp_mips.c 2015-07-07 17:20:03.000000000 +0000 @@ -438,7 +438,6 @@ } } -#if !HAVE_LOONGSON3 static void sbr_autocorrelate_mips(const float x[40][2], float phi[3][2][2]) { int i; @@ -607,7 +606,6 @@ : "memory" ); } -#endif /* !HAVE_LOONGSON3 */ static void sbr_hf_gen_mips(float (*X_high)[2], const float (*X_low)[2], const float alpha0[2], const float alpha1[2], @@ -896,9 +894,7 @@ s->sum64x5 = sbr_sum64x5_mips; s->sum_square = sbr_sum_square_mips; s->qmf_deint_bfly = sbr_qmf_deint_bfly_mips; -#if !HAVE_LOONGSON3 s->autocorrelate = sbr_autocorrelate_mips; -#endif /* !HAVE_LOONGSON3 */ s->hf_gen = sbr_hf_gen_mips; s->hf_g_filt = sbr_hf_g_filt_mips; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/simple_idct_mmi.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/simple_idct_mmi.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/simple_idct_mmi.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/simple_idct_mmi.c 2015-07-21 17:20:03.000000000 +0000 @@ -0,0 +1,833 @@ +/* + * Loongson SIMD optimized simple idct + * + * Copyright (c) 2015 Loongson Technology Corporation Limited + * Copyright (c) 2015 Zhou Xiaoyong + * Zhang Shuangshuang + * + * 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 "idctdsp_mips.h" +#include "constants.h" + +#define C0 23170 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 +#define C1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 +#define C2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 +#define C3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 +#define C4 16383 //cos(i*M_PI/16)*sqrt(2)*(1<<14) - 0.5 +#define C5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 +#define C6 8867 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 +#define C7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 + +#define ROW_SHIFT 11 +#define COL_SHIFT 20 + +DECLARE_ALIGNED(8, static const int16_t, coeffs)[]= { + 1<<(ROW_SHIFT-1), 0, 1<<(ROW_SHIFT-1), 0, + 1<<(ROW_SHIFT-1), 1, 1<<(ROW_SHIFT-1), 0, + C4, C4, C4, C4, + C4, -C4, C4, -C4, + C2, C6, C2, C6, + C6, -C2, C6, -C2, + C1, C3, C1, C3, + C5, C7, C5, C7, + C3, -C7, C3, -C7, + -C1, -C5, -C1, -C5, + C5, -C1, C5, -C1, + C7, C3, C7, C3, + C7, -C5, C7, -C5, + C3, -C1, C3, -C1 +}; + +static void simple_idct_mmi(int16_t *block) +{ + DECLARE_ALIGNED(8, int64_t, align_tmp)[16]; + int16_t * const temp= (int16_t*)align_tmp; + + __asm__ volatile ( +#undef DC_COND_IDCT +#define DC_COND_IDCT(src0, src4, src1, src5, dst, rounder, rarg, shift) \ + "ldc1 $f0, " #src0 " \n\t" /* R4 R0 r4 r0 */\ + "ldc1 $f2, " #src4 " \n\t" /* R6 R2 r6 r2 */\ + "ldc1 $f4, " #src1 " \n\t" /* R3 R1 r3 r1 */\ + "ldc1 $f6, " #src5 " \n\t" /* R7 R5 r7 r5 */\ + "ldc1 $f8, %3 \n\t" \ + "and $f8, $f8, $f0 \n\t" \ + "or $f8, $f8, $f2 \n\t" \ + "or $f8, $f8, $f4 \n\t" \ + "or $f8, $f8, $f6 \n\t" \ + "packsswh $f8, $f8, $f8 \n\t" \ + "li $11, " #shift " \n\t" \ + "mfc1 $10, $f8 \n\t" \ + "mtc1 $11, $f18 \n\t" \ + "beqz $10, 1f \n\t" \ + "ldc1 $f8, 16(%2) \n\t" /* C4 C4 C4 C4 */\ + "pmaddhw $f8, $f8, $f0 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f10, 24(%2) \n\t" /* -C4 C4 -C4 C4 */\ + "pmaddhw $f0, $f0, $f10 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "ldc1 $f10, 32(%2) \n\t" /* C6 C2 C6 C2 */\ + "pmaddhw $f10, $f10, $f2 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\ + "ldc1 $f12, 40(%2) \n\t" /* -C2 C6 -C2 C6 */\ + "pmaddhw $f2, $f2, $f12 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\ + "ldc1 $f14, 48(%2) \n\t" /* C3 C1 C3 C1 */\ + "ldc1 $f16, " #rarg " \n\t" \ + "pmaddhw $f14, $f14, $f4 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\ + #rounder " $f8, $f8, $f16 \n\t" \ + "mov.d $f12, $f8 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "paddw $f8, $f8, $f10 \n\t" /* A0 a0 */\ + "psubw $f12, $f12, $f10 \n\t" /* A3 a3 */\ + "ldc1 $f10, 56(%2) \n\t" /* C7 C5 C7 C5 */\ + "ldc1 $f16, " #rarg " \n\t" \ + "pmaddhw $f10, $f10, $f6 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\ + #rounder " $f0, $f0, $f16 \n\t" \ + "paddw $f2, $f2, $f0 \n\t" /* A1 a1 */\ + "ldc1 $f16, 64(%2) \n\t" \ + "paddw $f0, $f0, $f0 \n\t" \ + "psubw $f0, $f0, $f2 \n\t" /* A2 a2 */\ + "pmaddhw $f4, $f4, $f16 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\ + "paddw $f14, $f14, $f10 \n\t" /* B0 b0 */\ + "ldc1 $f10, 72(%2) \n\t" /* -C5 -C1 -C5 -C1 */\ + "pmaddhw $f10, $f10, $f6 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\ + "paddw $f14, $f14, $f8 \n\t" /* A0+B0 a0+b0 */\ + "paddw $f8, $f8, $f8 \n\t" /* 2A0 2a0 */\ + "psubw $f8, $f8, $f14 \n\t" /* A0-B0 a0-b0 */\ + "paddw $f10, $f10, $f4 \n\t" /* B1 b1 */\ + "psraw $f14, $f14, $f18 \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "mov.d $f4, $f2 \n\t" /* A1 a1 */\ + "paddw $f2, $f2, $f10 \n\t" /* A1+B1 a1+b1 */\ + "psubw $f4, $f4, $f10 \n\t" /* A1-B1 a1-b1 */\ + "psraw $f2, $f2, $f18 \n\t" \ + "psraw $f4, $f4, $f18 \n\t" \ + "packsswh $f14, $f14, $f2 \n\t" /* A1+B1 a1+b1 A0+B0 a0+b0 */\ + "packsswh $f4, $f4, $f8 \n\t" /* A0-B0 a0-b0 A1-B1 a1-b1 */\ + "sdc1 $f14, " #dst " \n\t" \ + "ldc1 $f2, " #src1 " \n\t" /* R3 R1 r3 r1 */\ + "ldc1 $f8, 80(%2) \n\t" /* -C1 C5 -C1 C5 */\ + "sdc1 $f4, 24+" #dst " \n\t" \ + "pmaddhw $f8, $f8, $f2 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\ + "ldc1 $f16, 96(%2) \n\t" \ + "ldc1 $f14, 88(%2) \n\t" /* C3 C7 C3 C7 */\ + "pmaddhw $f2, $f2, $f16 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\ + "pmaddhw $f14, $f14, $f6 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\ + "ldc1 $f16, 104(%2) \n\t" \ + "mov.d $f4, $f0 \n\t" /* A2 a2 */\ + "pmaddhw $f6, $f6, $f16 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\ + "paddw $f8, $f8, $f14 \n\t" /* B2 b2 */\ + "paddw $f4, $f4, $f8 \n\t" /* A2+B2 a2+b2 */\ + "psubw $f0, $f0, $f8 \n\t" /* a2-B2 a2-b2 */\ + "psraw $f4, $f4, $f18 \n\t" \ + "psraw $f0, $f0, $f18 \n\t" \ + "mov.d $f8, $f12 \n\t" /* A3 a3 */\ + "paddw $f6, $f6, $f2 \n\t" /* B3 b3 */\ + "paddw $f12, $f12, $f6 \n\t" /* A3+B3 a3+b3 */\ + "psubw $f8, $f8, $f6 \n\t" /* a3-B3 a3-b3 */\ + "psraw $f12, $f12, $f18 \n\t" \ + "packsswh $f4, $f4, $f12 \n\t" /* A3+B3 a3+b3 A2+B2 a2+b2 */\ + "sdc1 $f4, 8+" #dst " \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "packsswh $f8, $f8, $f0 \n\t" /* A2-B2 a2-b2 A3-B3 a3-b3 */\ + "sdc1 $f8, 16+" #dst " \n\t" \ + "b 2f \n\t" \ + "1: \n\t" \ + "li $10, 16 \n\t" \ + "mtc1 $10, $f16 \n\t" \ + "psllw $f0, $f0, $f16 \n\t" \ + "ldc1 $f16, %4 \n\t" \ + "paddw $f0, $f0, $f16 \n\t" \ + "li $10, 13 \n\t" \ + "mtc1 $10, $f16 \n\t" \ + "psraw $f0, $f0, $f16 \n\t" \ + "packsswh $f0, $f0, $f0 \n\t" \ + "sdc1 $f0, " #dst " \n\t" \ + "sdc1 $f0, 8+" #dst " \n\t" \ + "sdc1 $f0, 16+" #dst " \n\t" \ + "sdc1 $f0, 24+" #dst " \n\t" \ + "2: \n\t" + +#undef Z_COND_IDCT +#define Z_COND_IDCT(src0, src4, src1, src5, dst, rounder, rarg, shift, bt) \ + "ldc1 $f0, " #src0 " \n\t" /* R4 R0 r4 r0 */\ + "ldc1 $f2, " #src4 " \n\t" /* R6 R2 r6 r2 */\ + "ldc1 $f4, " #src1 " \n\t" /* R3 R1 r3 r1 */\ + "ldc1 $f6, " #src5 " \n\t" /* R7 R5 r7 r5 */\ + "mov.d $f8, $f0 \n\t" \ + "or $f8, $f8, $f2 \n\t" \ + "or $f8, $f8, $f4 \n\t" \ + "or $f8, $f8, $f6 \n\t" \ + "packsswh $f8, $f8, $f8 \n\t" \ + "mfc1 $10, $f8 \n\t" \ + "beqz $10, " #bt " \n\t" \ + "ldc1 $f8, 16(%2) \n\t" /* C4 C4 C4 C4 */\ + "pmaddhw $f8, $f8, $f0 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f10, 24(%2) \n\t" /* -C4 C4 -C4 C4 */\ + "pmaddhw $f0, $f0, $f10 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "ldc1 $f10, 32(%2) \n\t" /* C6 C2 C6 C2 */\ + "pmaddhw $f10, $f10, $f2 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\ + "ldc1 $f12, 40(%2) \n\t" /* -C2 C6 -C2 C6 */\ + "pmaddhw $f2, $f2, $f12 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\ + "ldc1 $f14, 48(%2) \n\t" /* C3 C1 C3 C1 */\ + "ldc1 $f16, " #rarg " \n\t" \ + "pmaddhw $f14, $f14, $f4 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\ + #rounder " $f8, $f8, $f16 \n\t" \ + "mov.d $f12, $f8 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "paddw $f8, $f8, $f10 \n\t" /* A0 a0 */\ + "psubw $f12, $f12, $f10 \n\t" /* A3 a3 */\ + "ldc1 $f10, 56(%2) \n\t" /* C7 C5 C7 C5 */\ + "ldc1 $f16, " #rarg " \n\t" \ + "pmaddhw $f10, $f10, $f6 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\ + #rounder " $f0, $f0, $f16 \n\t" \ + "paddw $f2, $f2, $f0 \n\t" /* A1 a1 */\ + "paddw $f0, $f0, $f0 \n\t" \ + "ldc1 $f16, 64(%2) \n\t" \ + "psubw $f0, $f0, $f2 \n\t" /* A2 a2 */\ + "pmaddhw $f4, $f4, $f16 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\ + "paddw $f14, $f14, $f10 \n\t" /* B0 b0 */\ + "ldc1 $f10, 72(%2) \n\t" /* -C5 -C1 -C5 -C1 */\ + "pmaddhw $f10, $f10, $f6 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\ + "paddw $f14, $f14, $f8 \n\t" /* A0+B0 a0+b0 */\ + "paddw $f8, $f8, $f8 \n\t" /* 2A0 2a0 */\ + "li $10, " #shift " \n\t" \ + "psubw $f8, $f8, $f14 \n\t" /* A0-B0 a0-b0 */\ + "mtc1 $10, $f18 \n\t" \ + "paddw $f10, $f10, $f4 \n\t" /* B1 b1 */\ + "psraw $f14, $f14, $f18 \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "mov.d $f4, $f2 \n\t" /* A1 a1 */\ + "paddw $f2, $f2, $f10 \n\t" /* A1+B1 a1+b1 */\ + "psubw $f4, $f4, $f10 \n\t" /* A1-B1 a1-b1 */\ + "psraw $f2, $f2, $f18 \n\t" \ + "psraw $f4, $f4, $f18 \n\t" \ + "packsswh $f14, $f14, $f2 \n\t" /* A1+B1 a1+b1 A0+B0 a0+b0 */\ + "packsswh $f4, $f4, $f8 \n\t" /* A0-B0 a0-b0 A1-B1 a1-b1 */\ + "sdc1 $f14, " #dst " \n\t" \ + "ldc1 $f2, " #src1 " \n\t" /* R3 R1 r3 r1 */\ + "ldc1 $f8, 80(%2) \n\t" /* -C1 C5 -C1 C5 */\ + "sdc1 $f4, 24+" #dst " \n\t" \ + "pmaddhw $f8, $f8, $f2 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\ + "ldc1 $f16, 96(%2) \n\t" \ + "ldc1 $f14, 88(%2) \n\t" /* C3 C7 C3 C7 */\ + "pmaddhw $f2, $f2, $f16 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\ + "pmaddhw $f14, $f14, $f6 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\ + "ldc1 $f16, 104(%2) \n\t" \ + "mov.d $f4, $f0 \n\t" /* A2 a2 */\ + "pmaddhw $f6, $f6, $f16 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\ + "paddw $f8, $f8, $f14 \n\t" /* B2 b2 */\ + "paddw $f4, $f4, $f8 \n\t" /* A2+B2 a2+b2 */\ + "psubw $f0, $f0, $f8 \n\t" /* a2-B2 a2-b2 */\ + "psraw $f4, $f4, $f18 \n\t" \ + "psraw $f0, $f0, $f18 \n\t" \ + "mov.d $f8, $f12 \n\t" /* A3 a3 */\ + "paddw $f6, $f6, $f2 \n\t" /* B3 b3 */\ + "paddw $f12, $f12, $f6 \n\t" /* A3+B3 a3+b3 */\ + "psubw $f8, $f8, $f6 \n\t" /* a3-B3 a3-b3 */\ + "psraw $f12, $f12, $f18 \n\t" \ + "packsswh $f4, $f4, $f12 \n\t" /* A3+B3 a3+b3 A2+B2 a2+b2 */\ + "sdc1 $f4, 8+" #dst " \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "packsswh $f8, $f8, $f0 \n\t" /* A2-B2 a2-b2 A3-B3 a3-b3 */\ + "sdc1 $f8, 16+" #dst " \n\t" \ + + //IDCT( src0, src4, src1, src5, dst, rounder, shift) + DC_COND_IDCT(0(%0), 8(%0), 16(%0), 24(%0), 0(%1), paddw,8(%2), 11) + Z_COND_IDCT(32(%0), 40(%0), 48(%0), 56(%0), 32(%1), paddw,(%2), 11, 4f) + Z_COND_IDCT(64(%0), 72(%0), 80(%0), 88(%0), 64(%1), paddw,(%2), 11, 2f) + Z_COND_IDCT(96(%0),104(%0),112(%0),120(%0), 96(%1), paddw,(%2), 11, 1f) + +#undef IDCT +#define IDCT(src0, src4, src1, src5, dst, shift) \ + "ldc1 $f0, " #src0 " \n\t" /* R4 R0 r4 r0 */\ + "ldc1 $f2, " #src4 " \n\t" /* R6 R2 r6 r2 */\ + "ldc1 $f4, " #src1 " \n\t" /* R3 R1 r3 r1 */\ + "ldc1 $f6, " #src5 " \n\t" /* R7 R5 r7 r5 */\ + "ldc1 $f8, 16(%2) \n\t" /* C4 C4 C4 C4 */\ + "pmaddhw $f8, $f8, $f0 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f10, 24(%2) \n\t" /* -C4 C4 -C4 C4 */\ + "pmaddhw $f0, $f0, $f10 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "ldc1 $f10, 32(%2) \n\t" /* C6 C2 C6 C2 */\ + "pmaddhw $f10, $f10, $f2 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\ + "ldc1 $f12, 40(%2) \n\t" /* -C2 C6 -C2 C6 */\ + "pmaddhw $f2, $f2, $f12 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\ + "mov.d $f12, $f8 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f14, 48(%2) \n\t" /* C3 C1 C3 C1 */\ + "pmaddhw $f14, $f14, $f4 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\ + "paddw $f8, $f8, $f10 \n\t" /* A0 a0 */\ + "psubw $f12, $f12, $f10 \n\t" /* A3 a3 */\ + "mov.d $f10, $f0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "paddw $f0, $f0, $f2 \n\t" /* A1 a1 */\ + "psubw $f10, $f10, $f2 \n\t" /* A2 a2 */\ + "ldc1 $f2, 56(%2) \n\t" /* C7 C5 C7 C5 */\ + "ldc1 $f16, 64(%2) \n\t" \ + "pmaddhw $f2, $f2, $f6 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\ + "pmaddhw $f4, $f4, $f16 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\ + "li $10, " #shift " \n\t" \ + "paddw $f14, $f14, $f2 \n\t" /* B0 b0 */\ + "ldc1 $f2, 72(%2) \n\t" /* -C5 -C1 -C5 -C1 */\ + "mtc1 $10, $f18 \n\t" \ + "pmaddhw $f2, $f2, $f6 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\ + "paddw $f14, $f14, $f8 \n\t" /* A0+B0 a0+b0 */\ + "paddw $f8, $f8, $f8 \n\t" /* 2A0 2a0 */\ + "psubw $f8, $f8, $f14 \n\t" /* A0-B0 a0-b0 */\ + "paddw $f2, $f2, $f4 \n\t" /* B1 b1 */\ + "psraw $f14, $f14, $f18 \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "mov.d $f4, $f0 \n\t" /* A1 a1 */\ + "paddw $f0, $f0, $f2 \n\t" /* A1+B1 a1+b1 */\ + "psubw $f4, $f4, $f2 \n\t" /* A1-B1 a1-b1 */\ + "psraw $f0, $f0, $f18 \n\t" \ + "psraw $f4, $f4, $f18 \n\t" \ + "packsswh $f14, $f14, $f14 \n\t" /* A0+B0 a0+b0 */\ + "swc1 $f14, " #dst " \n\t" \ + "packsswh $f0, $f0, $f0 \n\t" /* A1+B1 a1+b1 */\ + "swc1 $f0, 16+" #dst " \n\t" \ + "packsswh $f4, $f4, $f4 \n\t" /* A1-B1 a1-b1 */\ + "swc1 $f4, 96+" #dst " \n\t" \ + "packsswh $f8, $f8, $f8 \n\t" /* A0-B0 a0-b0 */\ + "swc1 $f8, 112+" #dst " \n\t" \ + "ldc1 $f0, " #src1 " \n\t" /* R3 R1 r3 r1 */\ + "ldc1 $f8, 80(%2) \n\t" /* -C1 C5 -C1 C5 */\ + "pmaddhw $f8, $f8, $f0 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\ + "ldc1 $f16, 96(%2) \n\t" \ + "ldc1 $f14, 88(%2) \n\t" /* C3 C7 C3 C7 */\ + "pmaddhw $f0, $f0, $f16 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\ + "pmaddhw $f14, $f14, $f6 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\ + "ldc1 $f16, 104(%2) \n\t" \ + "mov.d $f4, $f10 \n\t" /* A2 a2 */\ + "pmaddhw $f6, $f6, $f16 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\ + "paddw $f8, $f8, $f14 \n\t" /* B2 b2 */\ + "paddw $f4, $f4, $f8 \n\t" /* A2+B2 a2+b2 */\ + "psubw $f10, $f10, $f8 \n\t" /* a2-B2 a2-b2 */\ + "psraw $f4, $f4, $f18 \n\t" \ + "psraw $f10, $f10, $f18 \n\t" \ + "mov.d $f8, $f12 \n\t" /* A3 a3 */\ + "paddw $f6, $f6, $f0 \n\t" /* B3 b3 */\ + "paddw $f12, $f12, $f6 \n\t" /* A3+B3 a3+b3 */\ + "psubw $f8, $f8, $f6 \n\t" /* a3-B3 a3-b3 */\ + "psraw $f12, $f12, $f18 \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "packsswh $f4, $f4, $f4 \n\t" /* A2+B2 a2+b2 */\ + "packsswh $f12, $f12, $f12 \n\t" /* A3+B3 a3+b3 */\ + "swc1 $f4, 32+" #dst " \n\t" \ + "packsswh $f8, $f8, $f8 \n\t" /* A3-B3 a3-b3 */\ + "packsswh $f10, $f10, $f10 \n\t" /* A2-B2 a2-b2 */\ + "swc1 $f12, 48+" #dst " \n\t" \ + "swc1 $f8, 64+" #dst " \n\t" \ + "swc1 $f10, 80+" #dst " \n\t" + + //IDCT( src0, src4, src1, src5, dst, shift) + IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20) + IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20) + IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20) + IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20) + "b 9f \n\t" + + "# .p2align 4 \n\t" + "4: \n\t" + Z_COND_IDCT(64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddw,(%2), 11, 6f) + Z_COND_IDCT(96(%0),104(%0),112(%0),120(%0), 96(%1),paddw,(%2), 11, 5f) + +#undef IDCT +#define IDCT(src0, src4, src1, src5, dst, shift) \ + "ldc1 $f0, " #src0 " \n\t" /* R4 R0 r4 r0 */\ + "ldc1 $f2, " #src4 " \n\t" /* R6 R2 r6 r2 */\ + "ldc1 $f6, " #src5 " \n\t" /* R7 R5 r7 r5 */\ + "ldc1 $f8, 16(%2) \n\t" /* C4 C4 C4 C4 */\ + "pmaddhw $f8, $f8, $f0 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f10, 24(%2) \n\t" /* -C4 C4 -C4 C4 */\ + "pmaddhw $f0, $f0, $f10 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "ldc1 $f10, 32(%2) \n\t" /* C6 C2 C6 C2 */\ + "pmaddhw $f10, $f10, $f2 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\ + "ldc1 $f12, 40(%2) \n\t" /* -C2 C6 -C2 C6 */\ + "pmaddhw $f2, $f2, $f12 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\ + "mov.d $f12, $f8 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "paddw $f8, $f8, $f10 \n\t" /* A0 a0 */\ + "psubw $f12, $f12, $f10 \n\t" /* A3 a3 */\ + "mov.d $f10, $f0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "paddw $f0, $f0, $f2 \n\t" /* A1 a1 */\ + "psubw $f10, $f10, $f2 \n\t" /* A2 a2 */\ + "ldc1 $f2, 56(%2) \n\t" /* C7 C5 C7 C5 */\ + "li $10, " #shift " \n\t" \ + "pmaddhw $f2, $f2, $f6 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\ + "ldc1 $f14, 72(%2) \n\t" /* -C5 -C1 -C5 -C1 */\ + "mtc1 $10, $f18 \n\t" \ + "pmaddhw $f14, $f14, $f6 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\ + "paddw $f2, $f2, $f8 \n\t" /* A0+B0 a0+b0 */\ + "paddw $f8, $f8, $f8 \n\t" /* 2A0 2a0 */\ + "psubw $f8, $f8, $f2 \n\t" /* A0-B0 a0-b0 */\ + "psraw $f2, $f2, $f18 \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "mov.d $f4, $f0 \n\t" /* A1 a1 */\ + "paddw $f0, $f0, $f14 \n\t" /* A1+B1 a1+b1 */\ + "psubw $f4, $f4, $f14 \n\t" /* A1-B1 a1-b1 */\ + "psraw $f0, $f0, $f18 \n\t" \ + "psraw $f4, $f4, $f18 \n\t" \ + "packsswh $f2, $f2, $f2 \n\t" /* A0+B0 a0+b0 */\ + "swc1 $f2, " #dst " \n\t" \ + "packsswh $f0, $f0, $f0 \n\t" /* A1+B1 a1+b1 */\ + "swc1 $f0, 16+" #dst " \n\t" \ + "packsswh $f4, $f4, $f4 \n\t" /* A1-B1 a1-b1 */\ + "swc1 $f4, 96+" #dst " \n\t" \ + "packsswh $f8, $f8, $f8 \n\t" /* A0-B0 a0-b0 */\ + "swc1 $f8, 112+" #dst " \n\t" \ + "ldc1 $f2, 88(%2) \n\t" /* C3 C7 C3 C7 */\ + "ldc1 $f16, 104(%2) \n\t" \ + "pmaddhw $f2, $f2, $f6 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\ + "mov.d $f4, $f10 \n\t" /* A2 a2 */\ + "pmaddhw $f6, $f6, $f16 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\ + "paddw $f4, $f4, $f2 \n\t" /* A2+B2 a2+b2 */\ + "psubw $f10, $f10, $f2 \n\t" /* a2-B2 a2-b2 */\ + "psraw $f4, $f4, $f18 \n\t" \ + "psraw $f10, $f10, $f18 \n\t" \ + "mov.d $f2, $f12 \n\t" /* A3 a3 */\ + "paddw $f12, $f12, $f6 \n\t" /* A3+B3 a3+b3 */\ + "psubw $f2, $f2, $f6 \n\t" /* a3-B3 a3-b3 */\ + "psraw $f12, $f12, $f18 \n\t" \ + "psraw $f2, $f2, $f18 \n\t" \ + "packsswh $f4, $f4, $f4 \n\t" /* A2+B2 a2+b2 */\ + "packsswh $f12, $f12, $f12 \n\t" /* A3+B3 a3+b3 */\ + "swc1 $f4, 32+" #dst " \n\t" \ + "packsswh $f2, $f2, $f2 \n\t" /* A3-B3 a3-b3 */\ + "packsswh $f10, $f10, $f10 \n\t" /* A2-B2 a2-b2 */\ + "swc1 $f12, 48+" #dst " \n\t" \ + "swc1 $f2, 64+" #dst " \n\t" \ + "swc1 $f10, 80+" #dst " \n\t" + + //IDCT( src0, src4, src1, src5, dst, shift) + IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20) + IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20) + IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20) + IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20) + "b 9f \n\t" + + "# .p2align 4 \n\t" + "6: \n\t" + Z_COND_IDCT(96(%0),104(%0),112(%0),120(%0), 96(%1),paddw,(%2), 11, 7f) + +#undef IDCT +#define IDCT(src0, src4, src1, src5, dst, shift) \ + "ldc1 $f0, " #src0 " \n\t" /* R4 R0 r4 r0 */\ + "ldc1 $f6, " #src5 " \n\t" /* R7 R5 r7 r5 */\ + "ldc1 $f8, 16(%2) \n\t" /* C4 C4 C4 C4 */\ + "pmaddhw $f8, $f8, $f0 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f10, 24(%2) \n\t" /* -C4 C4 -C4 C4 */\ + "pmaddhw $f0, $f0, $f10 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "mov.d $f12, $f8 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "mov.d $f10, $f0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "ldc1 $f2, 56(%2) \n\t" /* C7 C5 C7 C5 */\ + "pmaddhw $f2, $f2, $f6 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\ + "ldc1 $f14, 72(%2) \n\t" /* -C5 -C1 -C5 -C1 */\ + "li $10, " #shift " \n\t" \ + "pmaddhw $f14, $f14, $f6 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\ + "paddw $f2, $f2, $f8 \n\t" /* A0+B0 a0+b0 */\ + "mtc1 $10, $f18 \n\t" \ + "paddw $f8, $f8, $f8 \n\t" /* 2A0 2a0 */\ + "psubw $f8, $f8, $f2 \n\t" /* A0-B0 a0-b0 */\ + "psraw $f2, $f2, $f18 \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "mov.d $f4, $f0 \n\t" /* A1 a1 */\ + "paddw $f0, $f0, $f14 \n\t" /* A1+B1 a1+b1 */\ + "psubw $f4, $f4, $f14 \n\t" /* A1-B1 a1-b1 */\ + "psraw $f0, $f0, $f18 \n\t" \ + "psraw $f4, $f4, $f18 \n\t" \ + "packsswh $f2, $f2, $f2 \n\t" /* A0+B0 a0+b0 */\ + "swc1 $f2, " #dst " \n\t" \ + "packsswh $f0, $f0, $f0 \n\t" /* A1+B1 a1+b1 */\ + "swc1 $f0, 16+" #dst " \n\t" \ + "packsswh $f4, $f4, $f4 \n\t" /* A1-B1 a1-b1 */\ + "swc1 $f4, 96+" #dst " \n\t" \ + "packsswh $f8, $f8, $f8 \n\t" /* A0-B0 a0-b0 */\ + "swc1 $f8, 112+" #dst " \n\t" \ + "ldc1 $f2, 88(%2) \n\t" /* C3 C7 C3 C7 */\ + "ldc1 $f16, 104(%2) \n\t" \ + "pmaddhw $f2, $f2, $f6 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\ + "mov.d $f4, $f10 \n\t" /* A2 a2 */\ + "pmaddhw $f6, $f6, $f16 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\ + "paddw $f4, $f4, $f2 \n\t" /* A2+B2 a2+b2 */\ + "psubw $f10, $f10, $f2 \n\t" /* a2-B2 a2-b2 */\ + "psraw $f4, $f4, $f18 \n\t" \ + "psraw $f10, $f10, $f18 \n\t" \ + "mov.d $f2, $f12 \n\t" /* A3 a3 */\ + "paddw $f12, $f12, $f6 \n\t" /* A3+B3 a3+b3 */\ + "psubw $f2, $f2, $f6 \n\t" /* a3-B3 a3-b3 */\ + "psraw $f12, $f12, $f18 \n\t" \ + "psraw $f2, $f2, $f18 \n\t" \ + "packsswh $f4, $f4, $f4 \n\t" /* A2+B2 a2+b2 */\ + "packsswh $f12, $f12, $f12 \n\t" /* A3+B3 a3+b3 */\ + "swc1 $f4, 32+" #dst " \n\t" \ + "packsswh $f2, $f2, $f2 \n\t" /* A3-B3 a3-b3 */\ + "packsswh $f10, $f10, $f10 \n\t" /* A2-B2 a2-b2 */\ + "swc1 $f12, 48+" #dst " \n\t" \ + "swc1 $f2, 64+" #dst " \n\t" \ + "swc1 $f10, 80+" #dst " \n\t" + + //IDCT( src0, src4, src1, src5, dst, shift) + IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20) + IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20) + IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20) + IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20) + "b 9f \n\t" + + "# .p2align 4 \n\t" + "2: \n\t" + Z_COND_IDCT(96(%0),104(%0),112(%0),120(%0), 96(%1),paddw,(%2), 11, 3f) + +#undef IDCT +#define IDCT(src0, src4, src1, src5, dst, shift) \ + "ldc1 $f0, " #src0 " \n\t" /* R4 R0 r4 r0 */\ + "ldc1 $f4, " #src1 " \n\t" /* R3 R1 r3 r1 */\ + "ldc1 $f6, " #src5 " \n\t" /* R7 R5 r7 r5 */\ + "ldc1 $f8, 16(%2) \n\t" /* C4 C4 C4 C4 */\ + "pmaddhw $f8, $f8, $f0 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f10, 24(%2) \n\t" /* -C4 C4 -C4 C4 */\ + "pmaddhw $f0, $f0, $f10 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "mov.d $f12, $f8 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f14, 48(%2) \n\t" /* C3 C1 C3 C1 */\ + "pmaddhw $f14, $f14, $f4 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\ + "mov.d $f10, $f0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "ldc1 $f2, 56(%2) \n\t" /* C7 C5 C7 C5 */\ + "pmaddhw $f2, $f2, $f6 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\ + "ldc1 $f16, 64(%2) \n\t" \ + "pmaddhw $f4, $f4, $f16 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\ + "paddw $f14, $f14, $f2 \n\t" /* B0 b0 */\ + "ldc1 $f2, 72(%2) \n\t" /* -C5 -C1 -C5 -C1 */\ + "li $10, " #shift " \n\t" \ + "pmaddhw $f2, $f2, $f6 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\ + "paddw $f14, $f14, $f8 \n\t" /* A0+B0 a0+b0 */\ + "mtc1 $10, $f18 \n\t" \ + "paddw $f8, $f8, $f8 \n\t" /* 2A0 2a0 */\ + "psubw $f8, $f8, $f14 \n\t" /* A0-B0 a0-b0 */\ + "paddw $f2, $f2, $f4 \n\t" /* B1 b1 */\ + "psraw $f14, $f14, $f18 \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "mov.d $f4, $f0 \n\t" /* A1 a1 */\ + "paddw $f0, $f0, $f2 \n\t" /* A1+B1 a1+b1 */\ + "psubw $f4, $f4, $f2 \n\t" /* A1-B1 a1-b1 */\ + "psraw $f0, $f0, $f18 \n\t" \ + "psraw $f4, $f4, $f18 \n\t" \ + "packsswh $f14, $f14, $f14 \n\t" /* A0+B0 a0+b0 */\ + "swc1 $f14, " #dst " \n\t" \ + "packsswh $f0, $f0, $f0 \n\t" /* A1+B1 a1+b1 */\ + "swc1 $f0, 16+" #dst " \n\t" \ + "packsswh $f4, $f4, $f4 \n\t" /* A1-B1 a1-b1 */\ + "swc1 $f4, 96+" #dst " \n\t" \ + "packsswh $f8, $f8, $f8 \n\t" /* A0-B0 a0-b0 */\ + "swc1 $f8, 112+" #dst " \n\t" \ + "ldc1 $f0, " #src1 " \n\t" /* R3 R1 r3 r1 */\ + "ldc1 $f8, 80(%2) \n\t" /* -C1 C5 -C1 C5 */\ + "pmaddhw $f8, $f8, $f0 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\ + "ldc1 $f14, 88(%2) \n\t" /* C3 C7 C3 C7 */\ + "ldc1 $f16, 96(%2) \n\t" \ + "pmaddhw $f0, $f0, $f16 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\ + "pmaddhw $f14, $f14, $f6 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\ + "mov.d $f4, $f10 \n\t" /* A2 a2 */\ + "ldc1 $f16, 104(%2) \n\t" \ + "pmaddhw $f6, $f6, $f16 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\ + "paddw $f8, $f8, $f14 \n\t" /* B2 b2 */\ + "paddw $f4, $f4, $f8 \n\t" /* A2+B2 a2+b2 */\ + "psubw $f10, $f10, $f8 \n\t" /* a2-B2 a2-b2 */\ + "psraw $f4, $f4, $f18 \n\t" \ + "psraw $f10, $f10, $f18 \n\t" \ + "mov.d $f8, $f12 \n\t" /* A3 a3 */\ + "paddw $f6, $f6, $f0 \n\t" /* B3 b3 */\ + "paddw $f12, $f12, $f6 \n\t" /* A3+B3 a3+b3 */\ + "psubw $f8, $f8, $f6 \n\t" /* a3-B3 a3-b3 */\ + "psraw $f12, $f12, $f18 \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "packsswh $f4, $f4, $f4 \n\t" /* A2+B2 a2+b2 */\ + "packsswh $f12, $f12, $f12 \n\t" /* A3+B3 a3+b3 */\ + "swc1 $f4, 32+" #dst " \n\t" \ + "packsswh $f8, $f8, $f8 \n\t" /* A3-B3 a3-b3 */\ + "packsswh $f10, $f10, $f10 \n\t" /* A2-B2 a2-b2 */\ + "swc1 $f12, 48+" #dst " \n\t" \ + "swc1 $f8, 64+" #dst " \n\t" \ + "swc1 $f10, 80+" #dst " \n\t" + + //IDCT( src0, src4, src1, src5, dst, shift) + IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20) + IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20) + IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20) + IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20) + "b 9f \n\t" + + "# .p2align 4 \n\t" + "3: \n\t" + +#undef IDCT +#define IDCT(src0, src4, src1, src5, dst, shift) \ + "ldc1 $f0, " #src0 " \n\t" /* R4 R0 r4 r0 */\ + "ldc1 $f4, " #src1 " \n\t" /* R3 R1 r3 r1 */\ + "ldc1 $f8, 16(%2) \n\t" /* C4 C4 C4 C4 */\ + "pmaddhw $f8, $f8, $f0 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f10, 24(%2) \n\t" /* -C4 C4 -C4 C4 */\ + "pmaddhw $f0, $f0, $f10 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "mov.d $f12, $f8 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f14, 48(%2) \n\t" /* C3 C1 C3 C1 */\ + "pmaddhw $f14, $f14, $f4 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\ + "mov.d $f10, $f0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "ldc1 $f6, 64(%2) \n\t" \ + "pmaddhw $f6, $f6, $f4 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\ + "li $10, " #shift " \n\t" \ + "paddw $f14, $f14, $f8 \n\t" /* A0+B0 a0+b0 */\ + "mtc1 $10, $f18 \n\t" \ + "paddw $f8, $f8, $f8 \n\t" /* 2A0 2a0 */\ + "psubw $f8, $f8, $f14 \n\t" /* A0-B0 a0-b0 */\ + "psraw $f14, $f14, $f18 \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "mov.d $f2, $f0 \n\t" /* A1 a1 */\ + "paddw $f0, $f0, $f6 \n\t" /* A1+B1 a1+b1 */\ + "psubw $f2, $f2, $f6 \n\t" /* A1-B1 a1-b1 */\ + "psraw $f0, $f0, $f18 \n\t" \ + "psraw $f2, $f2, $f18 \n\t" \ + "packsswh $f14, $f14, $f14 \n\t" /* A0+B0 a0+b0 */\ + "swc1 $f14, " #dst " \n\t" \ + "packsswh $f0, $f0, $f0 \n\t" /* A1+B1 a1+b1 */\ + "swc1 $f0, 16+" #dst " \n\t" \ + "packsswh $f2, $f2, $f2 \n\t" /* A1-B1 a1-b1 */\ + "swc1 $f2, 96+" #dst " \n\t" \ + "packsswh $f8, $f8, $f8 \n\t" /* A0-B0 a0-b0 */\ + "swc1 $f8, 112+" #dst " \n\t" \ + "ldc1 $f8, 80(%2) \n\t" /* -C1 C5 -C1 C5 */\ + "ldc1 $f16, 96(%2) \n\t" \ + "pmaddhw $f8, $f8, $f4 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\ + "pmaddhw $f4, $f4, $f16 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\ + "mov.d $f2, $f10 \n\t" /* A2 a2 */\ + "paddw $f2, $f2, $f8 \n\t" /* A2+B2 a2+b2 */\ + "psubw $f10, $f10, $f8 \n\t" /* a2-B2 a2-b2 */\ + "psraw $f2, $f2, $f18 \n\t" \ + "psraw $f10, $f10, $f18 \n\t" \ + "mov.d $f8, $f12 \n\t" /* A3 a3 */\ + "paddw $f12, $f12, $f4 \n\t" /* A3+B3 a3+b3 */\ + "psubw $f8, $f8, $f4 \n\t" /* a3-B3 a3-b3 */\ + "psraw $f12, $f12, $f18 \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "packsswh $f2, $f2, $f2 \n\t" /* A2+B2 a2+b2 */\ + "packsswh $f12, $f12, $f12 \n\t" /* A3+B3 a3+b3 */\ + "swc1 $f2, 32+" #dst " \n\t" \ + "packsswh $f8, $f8, $f8 \n\t" /* A3-B3 a3-b3 */\ + "packsswh $f10, $f10, $f10 \n\t" /* A2-B2 a2-b2 */\ + "swc1 $f12, 48+" #dst " \n\t" \ + "swc1 $f8, 64+" #dst " \n\t" \ + "swc1 $f10, 80+" #dst " \n\t" + + //IDCT( src0, src4, src1, src5, dst, shift) + IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20) + IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20) + IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20) + IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20) + "b 9f \n\t" + + "# .p2align 4 \n\t" + "5: \n\t" + +#undef IDCT +#define IDCT(src0, src4, src1, src5, dst, shift) \ + "ldc1 $f0, " #src0 " \n\t" /* R4 R0 r4 r0 */\ + "ldc1 $f2, " #src4 " \n\t" /* R6 R2 r6 r2 */\ + "ldc1 $f8, 16(%2) \n\t" /* C4 C4 C4 C4 */\ + "pmaddhw $f8, $f8, $f0 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f10, 24(%2) \n\t" /* -C4 C4 -C4 C4 */\ + "pmaddhw $f0, $f0, $f10 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "ldc1 $f10, 32(%2) \n\t" /* C6 C2 C6 C2 */\ + "pmaddhw $f10, $f10, $f2 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\ + "ldc1 $f12, 40(%2) \n\t" /* -C2 C6 -C2 C6 */\ + "pmaddhw $f2, $f2, $f12 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\ + "mov.d $f12, $f8 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "paddw $f8, $f8, $f10 \n\t" /* A0 a0 */\ + "psubw $f12, $f12, $f10 \n\t" /* A3 a3 */\ + "mov.d $f10, $f0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "paddw $f0, $f0, $f2 \n\t" /* A1 a1 */\ + "psubw $f10, $f10, $f2 \n\t" /* A2 a2 */\ + "ldc1 $f4, 8+" #src0 " \n\t" /* R4 R0 r4 r0 */\ + "ldc1 $f6, 8+" #src4 " \n\t" /* R6 R2 r6 r2 */\ + "ldc1 $f2, 16(%2) \n\t" /* C4 C4 C4 C4 */\ + "pmaddhw $f2, $f2, $f4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f14, 24(%2) \n\t" /* -C4 C4 -C4 C4 */\ + "pmaddhw $f4, $f4, $f14 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "ldc1 $f14, 32(%2) \n\t" /* C6 C2 C6 C2 */\ + "ldc1 $f16, 40(%2) \n\t" \ + "pmaddhw $f14, $f14, $f6 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\ + "pmaddhw $f6, $f6, $f16 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\ + "paddw $f14, $f14, $f2 \n\t" /* A0 a0 */\ + "paddw $f2, $f2, $f2 \n\t" /* 2C0 2c0 */\ + "psubw $f2, $f2, $f14 \n\t" /* A3 a3 */\ + "li $10, " #shift " \n\t" \ + "paddw $f6, $f6, $f4 \n\t" /* A1 a1 */\ + "mtc1 $10, $f18 \n\t" \ + "paddw $f4, $f4, $f4 \n\t" /* 2C1 2c1 */\ + "psubw $f4, $f4, $f6 \n\t" /* A2 a2 */\ + "psraw $f8, $f8, $f18 \n\t" \ + "psraw $f14, $f14, $f18 \n\t" \ + "psraw $f6, $f6, $f18 \n\t" \ + "packsswh $f8, $f8, $f14 \n\t" /* A0 a0 */\ + "sdc1 $f8, " #dst " \n\t" \ + "psraw $f0, $f0, $f18 \n\t" \ + "packsswh $f0, $f0, $f6 \n\t" /* A1 a1 */\ + "sdc1 $f0, 16+" #dst " \n\t" \ + "sdc1 $f0, 96+" #dst " \n\t" \ + "sdc1 $f8, 112+" #dst " \n\t" \ + "psraw $f10, $f10, $f18 \n\t" \ + "psraw $f12, $f12, $f18 \n\t" \ + "psraw $f4, $f4, $f18 \n\t" \ + "packsswh $f10, $f10, $f4 \n\t" /* A2-B2 a2-b2 */\ + "sdc1 $f10, 32+" #dst " \n\t" \ + "psraw $f2, $f2, $f18 \n\t" \ + "packsswh $f12, $f12, $f2 \n\t" /* A3+B3 a3+b3 */\ + "sdc1 $f12, 48+" #dst " \n\t" \ + "sdc1 $f12, 64+" #dst " \n\t" \ + "sdc1 $f10, 80+" #dst " \n\t" + + //IDCT( src0, src4, src1, src5, dst, shift) + IDCT( 0(%1), 64(%1), 32(%1), 96(%1), 0(%0), 20) + IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20) + "b 9f \n\t" + + "# .p2align 4 \n\t" + "1: \n\t" + +#undef IDCT +#define IDCT(src0, src4, src1, src5, dst, shift) \ + "ldc1 $f0, " #src0 " \n\t" /* R4 R0 r4 r0 */\ + "ldc1 $f2, " #src4 " \n\t" /* R6 R2 r6 r2 */\ + "ldc1 $f4, " #src1 " \n\t" /* R3 R1 r3 r1 */\ + "ldc1 $f8, 16(%2) \n\t" /* C4 C4 C4 C4 */\ + "li $10, " #shift " \n\t" \ + "pmaddhw $f8, $f8, $f0 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f10, 24(%2) \n\t" /* -C4 C4 -C4 C4 */\ + "mtc1 $10, $f18 \n\t" \ + "pmaddhw $f0, $f0, $f10 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "ldc1 $f10, 32(%2) \n\t" /* C6 C2 C6 C2 */\ + "pmaddhw $f10, $f10, $f2 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\ + "ldc1 $f12, 40(%2) \n\t" /* -C2 C6 -C2 C6 */\ + "pmaddhw $f2, $f2, $f12 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\ + "mov.d $f12, $f8 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f14, 48(%2) \n\t" /* C3 C1 C3 C1 */\ + "pmaddhw $f14, $f14, $f4 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\ + "paddw $f8, $f8, $f10 \n\t" /* A0 a0 */\ + "psubw $f12, $f12, $f10 \n\t" /* A3 a3 */\ + "mov.d $f10, $f0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "paddw $f0, $f0, $f2 \n\t" /* A1 a1 */\ + "psubw $f10, $f10, $f2 \n\t" /* A2 a2 */\ + "ldc1 $f2, 64(%2) \n\t" \ + "pmaddhw $f2, $f2, $f4 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\ + "paddw $f14, $f14, $f8 \n\t" /* A0+B0 a0+b0 */\ + "paddw $f8, $f8, $f8 \n\t" /* 2A0 2a0 */\ + "psubw $f8, $f8, $f14 \n\t" /* A0-B0 a0-b0 */\ + "psraw $f14, $f14, $f18 \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "mov.d $f6, $f0 \n\t" /* A1 a1 */\ + "paddw $f0, $f0, $f2 \n\t" /* A1+B1 a1+b1 */\ + "psubw $f6, $f6, $f2 \n\t" /* A1-B1 a1-b1 */\ + "psraw $f0, $f0, $f18 \n\t" \ + "psraw $f6, $f6, $f18 \n\t" \ + "packsswh $f14, $f14, $f14 \n\t" /* A0+B0 a0+b0 */\ + "swc1 $f14, " #dst " \n\t" \ + "packsswh $f0, $f0, $f0 \n\t" /* A1+B1 a1+b1 */\ + "swc1 $f0, 16+" #dst " \n\t" \ + "packsswh $f6, $f6, $f6 \n\t" /* A1-B1 a1-b1 */\ + "swc1 $f6, 96+" #dst " \n\t" \ + "packsswh $f8, $f8, $f8 \n\t" /* A0-B0 a0-b0 */\ + "swc1 $f8, 112+" #dst " \n\t" \ + "ldc1 $f8, 80(%2) \n\t" /* -C1 C5 -C1 C5 */\ + "ldc1 $f16, 96(%2) \n\t" \ + "pmaddhw $f8, $f8, $f4 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\ + "pmaddhw $f4, $f4, $f16 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\ + "mov.d $f6, $f10 \n\t" /* A2 a2 */\ + "paddw $f6, $f6, $f8 \n\t" /* A2+B2 a2+b2 */\ + "psubw $f10, $f10, $f8 \n\t" /* a2-B2 a2-b2 */\ + "psraw $f6, $f6, $f18 \n\t" \ + "psraw $f10, $f10, $f18 \n\t" \ + "mov.d $f8, $f12 \n\t" /* A3 a3 */\ + "paddw $f12, $f12, $f4 \n\t" /* A3+B3 a3+b3 */\ + "psubw $f8, $f8, $f4 \n\t" /* a3-B3 a3-b3 */\ + "psraw $f12, $f12, $f18 \n\t" \ + "packsswh $f6, $f6, $f6 \n\t" /* A2+B2 a2+b2 */\ + "swc1 $f6, 32+" #dst " \n\t" \ + "psraw $f8, $f8, $f18 \n\t" \ + "packsswh $f12, $f12, $f12 \n\t" /* A3+B3 a3+b3 */\ + "swc1 $f12, 48+" #dst " \n\t" \ + "packsswh $f8, $f8, $f8 \n\t" /* A3-B3 a3-b3 */\ + "packsswh $f10, $f10, $f10 \n\t" /* A2-B2 a2-b2 */\ + "swc1 $f8, 64+" #dst " \n\t" \ + "swc1 $f10, 80+" #dst " \n\t" + + //IDCT( src0, src4, src1, src5, dst, shift) + IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20) + IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20) + IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20) + IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20) + "b 9f \n\t" + + "# .p2align 4 \n\t" + "7: \n\t" + +#undef IDCT +#define IDCT(src0, src4, src1, src5, dst, shift) \ + "ldc1 $f0, " #src0 " \n\t" /* R4 R0 r4 r0 */\ + "ldc1 $f8, 16(%2) \n\t" /* C4 C4 C4 C4 */\ + "li $10, " #shift " \n\t" \ + "pmaddhw $f8, $f8, $f0 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "mtc1 $10, $f18 \n\t" \ + "ldc1 $f10, 24(%2) \n\t" /* -C4 C4 -C4 C4 */\ + "pmaddhw $f0, $f0, $f10 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "psraw $f8, $f8, $f18 \n\t" \ + "psraw $f0, $f0, $f18 \n\t" \ + "ldc1 $f4, 8+" #src0 " \n\t" /* R4 R0 r4 r0 */\ + "ldc1 $f2, 16(%2) \n\t" /* C4 C4 C4 C4 */\ + "pmaddhw $f2, $f2, $f4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\ + "ldc1 $f14, 24(%2) \n\t" /* -C4 C4 -C4 C4 */\ + "pmaddhw $f4, $f4, $f14 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\ + "ldc1 $f14, 32(%2) \n\t" /* C6 C2 C6 C2 */\ + "psraw $f2, $f2, $f18 \n\t" \ + "packsswh $f8, $f8, $f2 \n\t" /* A0 a0 */\ + "sdc1 $f8, " #dst " \n\t" \ + "psraw $f4, $f4, $f18 \n\t" \ + "packsswh $f0, $f0, $f4 \n\t" /* A1 a1 */\ + "sdc1 $f0, 16+" #dst " \n\t" \ + "sdc1 $f0, 96+" #dst " \n\t" \ + "sdc1 $f8, 112+" #dst " \n\t" \ + "sdc1 $f0, 32+" #dst " \n\t" \ + "sdc1 $f8, 48+" #dst " \n\t" \ + "sdc1 $f8, 64+" #dst " \n\t" \ + "sdc1 $f0, 80+" #dst " \n\t" + + //IDCT( src0, src4, src1, src5, dst, shift) + IDCT( 0(%1), 64(%1), 32(%1), 96(%1), 0(%0), 20) + IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20) + + "9: \n\t" + ::"r"(block),"r"(temp),"r"(coeffs),"m"(ff_wm1010),"m"(ff_d40000) + : "$10","$11" + ); +} + +void ff_simple_idct_mmi(int16_t *block) +{ + simple_idct_mmi(block); +} + +void ff_simple_idct_put_mmi(uint8_t *dest, int32_t line_size, int16_t *block) +{ + simple_idct_mmi(block); + ff_put_pixels_clamped_mmi(block, dest, line_size); +} + +void ff_simple_idct_add_mmi(uint8_t *dest, int32_t line_size, int16_t *block) +{ + simple_idct_mmi(block); + ff_add_pixels_clamped_mmi(block, dest, line_size); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/simple_idct_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/simple_idct_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/simple_idct_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/simple_idct_msa.c 2015-07-07 17:20:03.000000000 +0000 @@ -0,0 +1,573 @@ +/* + * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mips/generic_macros_msa.h" +#include "idctdsp_mips.h" + +static void simple_idct_msa(int16_t *block) +{ + int32_t const_val; + v8i16 weights = { 0, 22725, 21407, 19266, 16383, 12873, 8867, 4520 }; + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + v8i16 w1, w3, w5, w7; + v8i16 const0, const1, const2, const3, const4, const5, const6, const7; + v4i32 temp0_r, temp1_r, temp2_r, temp3_r; + v4i32 temp0_l, temp1_l, temp2_l, temp3_l; + v4i32 a0_r, a1_r, a2_r, a3_r, a0_l, a1_l, a2_l, a3_l; + v4i32 b0_r, b1_r, b2_r, b3_r, b0_l, b1_l, b2_l, b3_l; + v4i32 w2, w4, w6; + v8i16 select_vec, temp; + v8i16 zero = { 0 }; + v4i32 const_val0 = __msa_ldi_w(1); + v4i32 const_val1 = __msa_ldi_w(1); + + LD_SH8(block, 8, in0, in1, in2, in3, in4, in5, in6, in7); + const_val0 <<= 10; + const_val = 16383 * ((1 << 19) / 16383); + const_val1 = __msa_insert_w(const_val0, 0, const_val); + const_val1 = __msa_splati_w(const_val1, 0); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + select_vec = in1 | in2 | in3 | in4 | in5 | in6 | in7; + select_vec = __msa_clti_u_h((v8u16) select_vec, 1); + UNPCK_SH_SW(in0, a0_r, a0_l); + UNPCK_SH_SW(in2, temp3_r, temp3_l); + temp = in0 << 3; + w2 = (v4i32) __msa_splati_h(weights, 2); + w2 = (v4i32) __msa_ilvr_h(zero, (v8i16) w2); + w4 = (v4i32) __msa_splati_h(weights, 4); + w4 = (v4i32) __msa_ilvr_h(zero, (v8i16) w4); + w6 = (v4i32) __msa_splati_h(weights, 6); + w6 = (v4i32) __msa_ilvr_h(zero, (v8i16) w6); + MUL2(a0_r, w4, a0_l, w4, a0_r, a0_l); + ADD2(a0_r, const_val0, a0_l, const_val0, temp0_r, temp0_l); + MUL4(w2, temp3_r, w2, temp3_l, w6, temp3_r, w6, temp3_l, + temp1_r, temp1_l, temp2_r, temp2_l); + BUTTERFLY_8(temp0_r, temp0_l, temp0_r, temp0_l, + temp2_l, temp2_r, temp1_l, temp1_r, + a0_r, a0_l, a1_r, a1_l, a2_l, a2_r, a3_l, a3_r); + UNPCK_SH_SW(in4, temp0_r, temp0_l); + UNPCK_SH_SW(in6, temp3_r, temp3_l); + MUL2(temp0_r, w4, temp0_l, w4, temp0_r, temp0_l); + MUL4(w2, temp3_r, w2, temp3_l, w6, temp3_r, w6, temp3_l, + temp2_r, temp2_l, temp1_r, temp1_l); + ADD2(a0_r, temp0_r, a0_l, temp0_l, a0_r, a0_l); + SUB4(a1_r, temp0_r, a1_l, temp0_l, a2_r, temp0_r, a2_l, temp0_l, + a1_r, a1_l, a2_r, a2_l); + ADD4(a3_r, temp0_r, a3_l, temp0_l, a0_r, temp1_r, a0_l, temp1_l, + a3_r, a3_l, a0_r, a0_l); + SUB2(a1_r, temp2_r, a1_l, temp2_l, a1_r, a1_l); + ADD2(a2_r, temp2_r, a2_l, temp2_l, a2_r, a2_l); + SUB2(a3_r, temp1_r, a3_l, temp1_l, a3_r, a3_l); + ILVRL_H2_SW(in1, in3, b3_r, b3_l); + SPLATI_H4_SH(weights, 1, 3, 5, 7, w1, w3, w5, w7); + ILVRL_H2_SW(in5, in7, temp0_r, temp0_l); + ILVR_H4_SH(w1, w3, w3, -w7, w5, -w1, w7, -w5, + const0, const1, const2, const3); + ILVR_H2_SH(w5, w7, w7, w3, const4, const6); + const5 = __msa_ilvod_h(-w1, -w5); + const7 = __msa_ilvod_h(w3, -w1); + DOTP_SH4_SW(b3_r, b3_r, b3_r, b3_r, const0, const1, const2, const3, + b0_r, b1_r, b2_r, b3_r); + DPADD_SH4_SW(temp0_r, temp0_r, temp0_r, temp0_r, + const4, const5, const6, const7, b0_r, b1_r, b2_r, b3_r); + DOTP_SH4_SW(b3_l, b3_l, b3_l, b3_l, const0, const1, const2, const3, + b0_l, b1_l, b2_l, b3_l); + DPADD_SH4_SW(temp0_l, temp0_l, temp0_l, temp0_l, + const4, const5, const6, const7, b0_l, b1_l, b2_l, b3_l); + BUTTERFLY_16(a0_r, a0_l, a1_r, a1_l, a2_r, a2_l, a3_r, a3_l, + b3_l, b3_r, b2_l, b2_r, b1_l, b1_r, b0_l, b0_r, + temp0_r, temp0_l, temp1_r, temp1_l, + temp2_r, temp2_l, temp3_r, temp3_l, + a3_l, a3_r, a2_l, a2_r, a1_l, a1_r, a0_l, a0_r); + SRA_4V(temp0_r, temp0_l, temp1_r, temp1_l, 11); + SRA_4V(temp2_r, temp2_l, temp3_r, temp3_l, 11); + PCKEV_H4_SW(temp0_l, temp0_r, temp1_l, temp1_r, + temp2_l, temp2_r, temp3_l, temp3_r, + temp0_r, temp1_r, temp2_r, temp3_r); + in0 = (v8i16) __msa_bmnz_v((v16u8) temp0_r, (v16u8) temp, + (v16u8) select_vec); + in1 = (v8i16) __msa_bmnz_v((v16u8) temp1_r, (v16u8) temp, + (v16u8) select_vec); + in2 = (v8i16) __msa_bmnz_v((v16u8) temp2_r, (v16u8) temp, + (v16u8) select_vec); + in3 = (v8i16) __msa_bmnz_v((v16u8) temp3_r, (v16u8) temp, + (v16u8) select_vec); + SRA_4V(a3_r, a3_l, a2_r, a2_l, 11); + SRA_4V(a1_r, a1_l, a0_r, a0_l, 11); + PCKEV_H4_SW(a0_l, a0_r, a1_l, a1_r, a2_l, a2_r, a3_l, a3_r, + a0_r, a1_r, a2_r, a3_r); + in4 = (v8i16) __msa_bmnz_v((v16u8) a3_r, (v16u8) temp, (v16u8) select_vec); + in5 = (v8i16) __msa_bmnz_v((v16u8) a2_r, (v16u8) temp, (v16u8) select_vec); + in6 = (v8i16) __msa_bmnz_v((v16u8) a1_r, (v16u8) temp, (v16u8) select_vec); + in7 = (v8i16) __msa_bmnz_v((v16u8) a0_r, (v16u8) temp, (v16u8) select_vec); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + UNPCK_SH_SW(in0, a0_r, a0_l); + UNPCK_SH_SW(in2, temp3_r, temp3_l); + w2 = (v4i32) __msa_splati_h(weights, 2); + w2 = (v4i32) __msa_ilvr_h(zero, (v8i16) w2); + w4 = (v4i32) __msa_splati_h(weights, 4); + w4 = (v4i32) __msa_ilvr_h(zero, (v8i16) w4); + w6 = (v4i32) __msa_splati_h(weights, 6); + w6 = (v4i32) __msa_ilvr_h(zero, (v8i16) w6); + MUL2(a0_r, w4, a0_l, w4, a0_r, a0_l); + ADD2(a0_r, const_val1, a0_l, const_val1, temp0_r, temp0_l); + MUL4(w2, temp3_r, w2, temp3_l, w6, temp3_r, w6, temp3_l, + temp1_r, temp1_l, temp2_r, temp2_l); + BUTTERFLY_8(temp0_r, temp0_l, temp0_r, temp0_l, + temp2_l, temp2_r, temp1_l, temp1_r, + a0_r, a0_l, a1_r, a1_l, a2_l, a2_r, a3_l, a3_r); + UNPCK_SH_SW(in4, temp0_r, temp0_l); + UNPCK_SH_SW(in6, temp3_r, temp3_l); + MUL2(temp0_r, w4, temp0_l, w4, temp0_r, temp0_l); + MUL4(w2, temp3_r, w2, temp3_l, w6, temp3_r, w6, temp3_l, + temp2_r, temp2_l, temp1_r, temp1_l); + ADD2(a0_r, temp0_r, a0_l, temp0_l, a0_r, a0_l); + SUB4(a1_r, temp0_r, a1_l, temp0_l, a2_r, temp0_r, a2_l, temp0_l, + a1_r, a1_l, a2_r, a2_l); + ADD4(a3_r, temp0_r, a3_l, temp0_l, a0_r, temp1_r, a0_l, temp1_l, + a3_r, a3_l, a0_r, a0_l); + SUB2(a1_r, temp2_r, a1_l, temp2_l, a1_r, a1_l); + ADD2(a2_r, temp2_r, a2_l, temp2_l, a2_r, a2_l); + SUB2(a3_r, temp1_r, a3_l, temp1_l, a3_r, a3_l); + ILVRL_H2_SW(in1, in3, b3_r, b3_l); + SPLATI_H4_SH(weights, 1, 3, 5, 7, w1, w3, w5, w7); + ILVR_H4_SH(w1, w3, w3, -w7, w5, -w1, w7, -w5, + const0, const1, const2, const3); + DOTP_SH4_SW(b3_r, b3_r, b3_r, b3_r, const0, const1, const2, const3, + b0_r, b1_r, b2_r, b3_r); + DOTP_SH4_SW(b3_l, b3_l, b3_l, b3_l, const0, const1, const2, const3, + b0_l, b1_l, b2_l, b3_l); + ILVRL_H2_SW(in5, in7, temp0_r, temp0_l); + ILVR_H2_SH(w5, w7, w7, w3, const4, const6); + const5 = __msa_ilvod_h(-w1, -w5); + const7 = __msa_ilvod_h(w3, -w1); + DPADD_SH4_SW(temp0_r, temp0_r, temp0_r, temp0_r, + const4, const5, const6, const7, b0_r, b1_r, b2_r, b3_r); + DPADD_SH4_SW(temp0_l, temp0_l, temp0_l, temp0_l, + const4, const5, const6, const7, b0_l, b1_l, b2_l, b3_l); + BUTTERFLY_16(a0_r, a0_l, a1_r, a1_l, a2_r, a2_l, a3_r, a3_l, + b3_l, b3_r, b2_l, b2_r, b1_l, b1_r, b0_l, b0_r, + temp0_r, temp0_l, temp1_r, temp1_l, + temp2_r, temp2_l, temp3_r, temp3_l, + a3_l, a3_r, a2_l, a2_r, a1_l, a1_r, a0_l, a0_r); + SRA_4V(temp0_r, temp0_l, temp1_r, temp1_l, 20); + SRA_4V(temp2_r, temp2_l, temp3_r, temp3_l, 20); + PCKEV_H4_SW(temp0_l, temp0_r, temp1_l, temp1_r, temp2_l, temp2_r, + temp3_l, temp3_r, temp0_r, temp1_r, temp2_r, temp3_r); + SRA_4V(a3_r, a3_l, a2_r, a2_l, 20); + SRA_4V(a1_r, a1_l, a0_r, a0_l, 20); + PCKEV_H4_SW(a0_l, a0_r, a1_l, a1_r, a2_l, a2_r, a3_l, a3_r, + a0_r, a1_r, a2_r, a3_r); + ST_SW8(temp0_r, temp1_r, temp2_r, temp3_r, a3_r, a2_r, a1_r, a0_r, + block, 8); +} + +static void simple_idct_put_msa(uint8_t *dst, int32_t dst_stride, + int16_t *block) +{ + int32_t const_val; + uint64_t tmp0, tmp1, tmp2, tmp3; + v8i16 weights = { 0, 22725, 21407, 19266, 16383, 12873, 8867, 4520 }; + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + v8i16 w1, w3, w5, w7; + v8i16 const0, const1, const2, const3, const4, const5, const6, const7; + v4i32 temp0_r, temp1_r, temp2_r, temp3_r; + v4i32 temp0_l, temp1_l, temp2_l, temp3_l; + v4i32 a0_r, a1_r, a2_r, a3_r, a0_l, a1_l, a2_l, a3_l; + v4i32 b0_r, b1_r, b2_r, b3_r, b0_l, b1_l, b2_l, b3_l; + v4i32 w2, w4, w6; + v8i16 select_vec, temp; + v8i16 zero = { 0 }; + v4i32 const_val0 = __msa_ldi_w(1); + v4i32 const_val1 = __msa_ldi_w(1); + + LD_SH8(block, 8, in0, in1, in2, in3, in4, in5, in6, in7); + const_val0 <<= 10; + const_val = 16383 * ((1 << 19) / 16383); + const_val1 = __msa_insert_w(const_val0, 0, const_val); + const_val1 = __msa_splati_w(const_val1, 0); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + select_vec = in1 | in2 | in3 | in4 | in5 | in6 | in7; + select_vec = __msa_clti_u_h((v8u16) select_vec, 1); + UNPCK_SH_SW(in0, a0_r, a0_l); + UNPCK_SH_SW(in2, temp3_r, temp3_l); + temp = in0 << 3; + w2 = (v4i32) __msa_splati_h(weights, 2); + w2 = (v4i32) __msa_ilvr_h(zero, (v8i16) w2); + w4 = (v4i32) __msa_splati_h(weights, 4); + w4 = (v4i32) __msa_ilvr_h(zero, (v8i16) w4); + w6 = (v4i32) __msa_splati_h(weights, 6); + w6 = (v4i32) __msa_ilvr_h(zero, (v8i16) w6); + MUL2(a0_r, w4, a0_l, w4, a0_r, a0_l); + ADD2(a0_r, const_val0, a0_l, const_val0, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp1_r, temp1_l); + MUL2(w6, temp3_r, w6, temp3_l, temp2_r, temp2_l); + BUTTERFLY_8(temp0_r, temp0_l, temp0_r, temp0_l, + temp2_l, temp2_r, temp1_l, temp1_r, + a0_r, a0_l, a1_r, a1_l, a2_l, a2_r, a3_l, a3_r); + UNPCK_SH_SW(in4, temp0_r, temp0_l); + UNPCK_SH_SW(in6, temp3_r, temp3_l); + MUL2(temp0_r, w4, temp0_l, w4, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp2_r, temp2_l); + MUL2(w6, temp3_r, w6, temp3_l, temp1_r, temp1_l); + ADD2(a0_r, temp0_r, a0_l, temp0_l, a0_r, a0_l); + SUB2(a1_r, temp0_r, a1_l, temp0_l, a1_r, a1_l); + SUB2(a2_r, temp0_r, a2_l, temp0_l, a2_r, a2_l); + ADD2(a3_r, temp0_r, a3_l, temp0_l, a3_r, a3_l); + ADD2(a0_r, temp1_r, a0_l, temp1_l, a0_r, a0_l); + SUB2(a1_r, temp2_r, a1_l, temp2_l, a1_r, a1_l); + ADD2(a2_r, temp2_r, a2_l, temp2_l, a2_r, a2_l); + SUB2(a3_r, temp1_r, a3_l, temp1_l, a3_r, a3_l); + ILVRL_H2_SW(in1, in3, b3_r, b3_l); + SPLATI_H4_SH(weights, 1, 3, 5, 7, w1, w3, w5, w7); + ILVRL_H2_SW(in5, in7, temp0_r, temp0_l); + ILVR_H4_SH(w1, w3, w3, -w7, w5, -w1, w7, -w5, + const0, const1, const2, const3); + ILVR_H2_SH(w5, w7, w7, w3, const4, const6); + const5 = __msa_ilvod_h(-w1, -w5); + const7 = __msa_ilvod_h(w3, -w1); + DOTP_SH4_SW(b3_r, b3_r, b3_r, b3_r, const0, const1, const2, const3, + b0_r, b1_r, b2_r, b3_r); + DPADD_SH4_SW(temp0_r, temp0_r, temp0_r, temp0_r, + const4, const5, const6, const7, b0_r, b1_r, b2_r, b3_r); + DOTP_SH4_SW(b3_l, b3_l, b3_l, b3_l, const0, const1, const2, const3, + b0_l, b1_l, b2_l, b3_l); + DPADD_SH4_SW(temp0_l, temp0_l, temp0_l, temp0_l, + const4, const5, const6, const7, b0_l, b1_l, b2_l, b3_l); + BUTTERFLY_16(a0_r, a0_l, a1_r, a1_l, a2_r, a2_l, a3_r, a3_l, + b3_l, b3_r, b2_l, b2_r, b1_l, b1_r, b0_l, b0_r, + temp0_r, temp0_l, temp1_r, temp1_l, + temp2_r, temp2_l, temp3_r, temp3_l, + a3_l, a3_r, a2_l, a2_r, a1_l, a1_r, a0_l, a0_r); + SRA_4V(temp0_r, temp0_l, temp1_r, temp1_l, 11); + SRA_4V(temp2_r, temp2_l, temp3_r, temp3_l, 11); + PCKEV_H4_SW(temp0_l, temp0_r, temp1_l, temp1_r, + temp2_l, temp2_r, temp3_l, temp3_r, + temp0_r, temp1_r, temp2_r, temp3_r); + in0 = (v8i16) __msa_bmnz_v((v16u8) temp0_r, (v16u8) temp, + (v16u8) select_vec); + in1 = (v8i16) __msa_bmnz_v((v16u8) temp1_r, (v16u8) temp, + (v16u8) select_vec); + in2 = (v8i16) __msa_bmnz_v((v16u8) temp2_r, (v16u8) temp, + (v16u8) select_vec); + in3 = (v8i16) __msa_bmnz_v((v16u8) temp3_r, (v16u8) temp, + (v16u8) select_vec); + SRA_4V(a3_r, a3_l, a2_r, a2_l, 11); + SRA_4V(a1_r, a1_l, a0_r, a0_l, 11); + PCKEV_H4_SW(a0_l, a0_r, a1_l, a1_r, a2_l, a2_r, a3_l, a3_r, + a0_r, a1_r, a2_r, a3_r); + in4 = (v8i16) __msa_bmnz_v((v16u8) a3_r, (v16u8) temp, (v16u8) select_vec); + in5 = (v8i16) __msa_bmnz_v((v16u8) a2_r, (v16u8) temp, (v16u8) select_vec); + in6 = (v8i16) __msa_bmnz_v((v16u8) a1_r, (v16u8) temp, (v16u8) select_vec); + in7 = (v8i16) __msa_bmnz_v((v16u8) a0_r, (v16u8) temp, (v16u8) select_vec); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + UNPCK_SH_SW(in0, a0_r, a0_l); + UNPCK_SH_SW(in2, temp3_r, temp3_l); + w2 = (v4i32) __msa_splati_h(weights, 2); + w2 = (v4i32) __msa_ilvr_h(zero, (v8i16) w2); + w4 = (v4i32) __msa_splati_h(weights, 4); + w4 = (v4i32) __msa_ilvr_h(zero, (v8i16) w4); + w6 = (v4i32) __msa_splati_h(weights, 6); + w6 = (v4i32) __msa_ilvr_h(zero, (v8i16) w6); + MUL2(a0_r, w4, a0_l, w4, a0_r, a0_l); + ADD2(a0_r, const_val1, a0_l, const_val1, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp1_r, temp1_l); + MUL2(w6, temp3_r, w6, temp3_l, temp2_r, temp2_l); + BUTTERFLY_8(temp0_r, temp0_l, temp0_r, temp0_l, + temp2_l, temp2_r, temp1_l, temp1_r, + a0_r, a0_l, a1_r, a1_l, a2_l, a2_r, a3_l, a3_r); + UNPCK_SH_SW(in4, temp0_r, temp0_l); + UNPCK_SH_SW(in6, temp3_r, temp3_l); + MUL2(temp0_r, w4, temp0_l, w4, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp2_r, temp2_l); + MUL2(w6, temp3_r, w6, temp3_l, temp1_r, temp1_l); + ADD2(a0_r, temp0_r, a0_l, temp0_l, a0_r, a0_l); + SUB2(a1_r, temp0_r, a1_l, temp0_l, a1_r, a1_l); + SUB2(a2_r, temp0_r, a2_l, temp0_l, a2_r, a2_l); + ADD2(a3_r, temp0_r, a3_l, temp0_l, a3_r, a3_l); + ADD2(a0_r, temp1_r, a0_l, temp1_l, a0_r, a0_l); + SUB2(a1_r, temp2_r, a1_l, temp2_l, a1_r, a1_l); + ADD2(a2_r, temp2_r, a2_l, temp2_l, a2_r, a2_l); + SUB2(a3_r, temp1_r, a3_l, temp1_l, a3_r, a3_l); + ILVRL_H2_SW(in1, in3, b3_r, b3_l); + SPLATI_H4_SH(weights, 1, 3, 5, 7, w1, w3, w5, w7); + ILVR_H4_SH(w1, w3, w3, -w7, w5, -w1, w7, -w5, + const0, const1, const2, const3); + DOTP_SH4_SW(b3_r, b3_r, b3_r, b3_r, const0, const1, const2, const3, + b0_r, b1_r, b2_r, b3_r); + DOTP_SH4_SW(b3_l, b3_l, b3_l, b3_l, const0, const1, const2, const3, + b0_l, b1_l, b2_l, b3_l); + ILVRL_H2_SW(in5, in7, temp0_r, temp0_l); + ILVR_H2_SH(w5, w7, w7, w3, const4, const6); + const5 = __msa_ilvod_h(-w1, -w5); + const7 = __msa_ilvod_h(w3, -w1); + DPADD_SH4_SW(temp0_r, temp0_r, temp0_r, temp0_r, + const4, const5, const6, const7, b0_r, b1_r, b2_r, b3_r); + DPADD_SH4_SW(temp0_l, temp0_l, temp0_l, temp0_l, + const4, const5, const6, const7, b0_l, b1_l, b2_l, b3_l); + BUTTERFLY_16(a0_r, a0_l, a1_r, a1_l, a2_r, a2_l, a3_r, a3_l, + b3_l, b3_r, b2_l, b2_r, b1_l, b1_r, b0_l, b0_r, + temp0_r, temp0_l, temp1_r, temp1_l, + temp2_r, temp2_l, temp3_r, temp3_l, + a3_l, a3_r, a2_l, a2_r, a1_l, a1_r, a0_l, a0_r); + SRA_4V(temp0_r, temp0_l, temp1_r, temp1_l, 20); + SRA_4V(temp2_r, temp2_l, temp3_r, temp3_l, 20); + SRA_4V(a3_r, a3_l, a2_r, a2_l, 20); + SRA_4V(a1_r, a1_l, a0_r, a0_l, 20); + PCKEV_H4_SW(temp0_l, temp0_r, temp1_l, temp1_r, temp2_l, temp2_r, + temp3_l, temp3_r, temp0_r, temp1_r, temp2_r, temp3_r); + PCKEV_H4_SW(a0_l, a0_r, a1_l, a1_r, a2_l, a2_r, a3_l, a3_r, + a0_r, a1_r, a2_r, a3_r); + temp0_r = (v4i32) CLIP_SH_0_255(temp0_r); + temp1_r = (v4i32) CLIP_SH_0_255(temp1_r); + temp2_r = (v4i32) CLIP_SH_0_255(temp2_r); + temp3_r = (v4i32) CLIP_SH_0_255(temp3_r); + PCKEV_B4_SW(temp0_r, temp0_r, temp1_r, temp1_r, + temp2_r, temp2_r, temp3_r, temp3_r, + temp0_r, temp1_r, temp2_r, temp3_r); + tmp0 = __msa_copy_u_d((v2i64) temp0_r, 1); + tmp1 = __msa_copy_u_d((v2i64) temp1_r, 1); + tmp2 = __msa_copy_u_d((v2i64) temp2_r, 1); + tmp3 = __msa_copy_u_d((v2i64) temp3_r, 1); + SD4(tmp0, tmp1, tmp2, tmp3, dst, dst_stride); + dst += 4 * dst_stride; + a0_r = (v4i32) CLIP_SH_0_255(a0_r); + a1_r = (v4i32) CLIP_SH_0_255(a1_r); + a2_r = (v4i32) CLIP_SH_0_255(a2_r); + a3_r = (v4i32) CLIP_SH_0_255(a3_r); + PCKEV_B4_SW(a0_r, a0_r, a1_r, a1_r, + a2_r, a2_r, a3_r, a3_r, a0_r, a1_r, a2_r, a3_r); + tmp3 = __msa_copy_u_d((v2i64) a0_r, 1); + tmp2 = __msa_copy_u_d((v2i64) a1_r, 1); + tmp1 = __msa_copy_u_d((v2i64) a2_r, 1); + tmp0 = __msa_copy_u_d((v2i64) a3_r, 1); + SD4(tmp0, tmp1, tmp2, tmp3, dst, dst_stride); + dst += 4 * dst_stride; +} + +static void simple_idct_add_msa(uint8_t *dst, int32_t dst_stride, + int16_t *block) +{ + int32_t const_val; + uint64_t tmp0, tmp1, tmp2, tmp3; + v8i16 weights = { 0, 22725, 21407, 19266, 16383, 12873, 8867, 4520 }; + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + v8i16 w1, w3, w5, w7; + v8i16 const0, const1, const2, const3, const4, const5, const6, const7; + v4i32 temp0_r, temp1_r, temp2_r, temp3_r; + v4i32 temp4_r, temp5_r, temp6_r, temp7_r, temp8_r; + v4i32 temp0_l, temp1_l, temp2_l, temp3_l; + v4i32 temp4_l, temp5_l, temp6_l, temp7_l, temp8_l; + v4i32 a0_r, a1_r, a2_r, a3_r, a0_l, a1_l, a2_l, a3_l; + v4i32 b0_r, b1_r, b2_r, b3_r, b0_l, b1_l, b2_l, b3_l; + v4i32 w2, w4, w6; + v8i16 select_vec, temp; + v8i16 zero = { 0 }; + v4i32 const_val0 = __msa_ldi_w(1); + v4i32 const_val1 = __msa_ldi_w(1); + + const_val0 <<= 10; + const_val = 16383 * ((1 << 19) / 16383); + const_val1 = __msa_insert_w(const_val0, 0, const_val); + const_val1 = __msa_splati_w(const_val1, 0); + LD_SH8(block, 8, in0, in1, in2, in3, in4, in5, in6, in7); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + select_vec = in1 | in2 | in3 | in4 | in5 | in6 | in7; + select_vec = __msa_clti_u_h((v8u16) select_vec, 1); + UNPCK_SH_SW(in0, a0_r, a0_l); + UNPCK_SH_SW(in2, temp3_r, temp3_l); + ILVRL_H2_SW(in1, in3, b3_r, b3_l); + UNPCK_SH_SW(in4, temp4_r, temp4_l); + UNPCK_SH_SW(in6, temp7_r, temp7_l); + ILVRL_H2_SW(in5, in7, temp8_r, temp8_l); + temp = in0 << 3; + SPLATI_H4_SH(weights, 1, 3, 5, 7, w1, w3, w5, w7); + ILVR_H4_SH(w1, w3, w3, -w7, w5, -w1, w7, -w5, + const0, const1, const2, const3); + ILVR_H2_SH(w5, w7, w7, w3, const4, const6); + const5 = __msa_ilvod_h(-w1, -w5); + const7 = __msa_ilvod_h(w3, -w1); + DOTP_SH4_SW(b3_r, b3_r, b3_r, b3_r, const0, const1, const2, const3, + b0_r, b1_r, b2_r, b3_r); + DPADD_SH4_SW(temp8_r, temp8_r, temp8_r, temp8_r, + const4, const5, const6, const7, b0_r, b1_r, b2_r, b3_r); + DOTP_SH4_SW(b3_l, b3_l, b3_l, b3_l, const0, const1, const2, const3, + b0_l, b1_l, b2_l, b3_l); + DPADD_SH4_SW(temp8_l, temp8_l, temp8_l, temp8_l, + const4, const5, const6, const7, b0_l, b1_l, b2_l, b3_l); + w2 = (v4i32) __msa_splati_h(weights, 2); + w2 = (v4i32) __msa_ilvr_h(zero, (v8i16) w2); + w4 = (v4i32) __msa_splati_h(weights, 4); + w4 = (v4i32) __msa_ilvr_h(zero, (v8i16) w4); + w6 = (v4i32) __msa_splati_h(weights, 6); + w6 = (v4i32) __msa_ilvr_h(zero, (v8i16) w6); + MUL2(a0_r, w4, a0_l, w4, a0_r, a0_l); + ADD2(a0_r, const_val0, a0_l, const_val0, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp1_r, temp1_l); + MUL2(w6, temp3_r, w6, temp3_l, temp2_r, temp2_l); + BUTTERFLY_8(temp0_r, temp0_l, temp0_r, temp0_l, + temp2_l, temp2_r, temp1_l, temp1_r, + a0_r, a0_l, a1_r, a1_l, a2_l, a2_r, a3_l, a3_r); + MUL2(temp4_r, w4, temp4_l, w4, temp4_r, temp4_l); + MUL2(temp7_r, w2, temp7_l, w2, temp6_r, temp6_l); + MUL2(temp7_r, w6, temp7_l, w6, temp5_r, temp5_l); + ADD2(a0_r, temp4_r, a0_l, temp4_l, a0_r, a0_l); + SUB2(a1_r, temp4_r, a1_l, temp4_l, a1_r, a1_l); + SUB2(a2_r, temp4_r, a2_l, temp4_l, a2_r, a2_l); + ADD2(a3_r, temp4_r, a3_l, temp4_l, a3_r, a3_l); + ADD2(a0_r, temp5_r, a0_l, temp5_l, a0_r, a0_l); + SUB2(a1_r, temp6_r, a1_l, temp6_l, a1_r, a1_l); + ADD2(a2_r, temp6_r, a2_l, temp6_l, a2_r, a2_l); + SUB2(a3_r, temp5_r, a3_l, temp5_l, a3_r, a3_l); + BUTTERFLY_16(a0_r, a0_l, a1_r, a1_l, a2_r, a2_l, a3_r, a3_l, + b3_l, b3_r, b2_l, b2_r, b1_l, b1_r, b0_l, b0_r, + temp0_r, temp0_l, temp1_r, temp1_l, + temp2_r, temp2_l, temp3_r, temp3_l, + a3_l, a3_r, a2_l, a2_r, a1_l, a1_r, a0_l, a0_r); + SRA_4V(temp0_r, temp0_l, temp1_r, temp1_l, 11); + SRA_4V(temp2_r, temp2_l, temp3_r, temp3_l, 11); + PCKEV_H4_SW(temp0_l, temp0_r, temp1_l, temp1_r, + temp2_l, temp2_r, temp3_l, temp3_r, + temp0_r, temp1_r, temp2_r, temp3_r); + in0 = (v8i16) __msa_bmnz_v((v16u8) temp0_r, (v16u8) temp, + (v16u8) select_vec); + in1 = (v8i16) __msa_bmnz_v((v16u8) temp1_r, (v16u8) temp, + (v16u8) select_vec); + in2 = (v8i16) __msa_bmnz_v((v16u8) temp2_r, (v16u8) temp, + (v16u8) select_vec); + in3 = (v8i16) __msa_bmnz_v((v16u8) temp3_r, (v16u8) temp, + (v16u8) select_vec); + SRA_4V(a3_r, a3_l, a2_r, a2_l, 11); + SRA_4V(a1_r, a1_l, a0_r, a0_l, 11); + PCKEV_H4_SW(a0_l, a0_r, a1_l, a1_r, a2_l, a2_r, a3_l, a3_r, + a0_r, a1_r, a2_r, a3_r); + in4 = (v8i16) __msa_bmnz_v((v16u8) a3_r, (v16u8) temp, (v16u8) select_vec); + in5 = (v8i16) __msa_bmnz_v((v16u8) a2_r, (v16u8) temp, (v16u8) select_vec); + in6 = (v8i16) __msa_bmnz_v((v16u8) a1_r, (v16u8) temp, (v16u8) select_vec); + in7 = (v8i16) __msa_bmnz_v((v16u8) a0_r, (v16u8) temp, (v16u8) select_vec); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + UNPCK_SH_SW(in0, a0_r, a0_l); + UNPCK_SH_SW(in2, temp3_r, temp3_l); + MUL2(a0_r, w4, a0_l, w4, a0_r, a0_l); + ADD2(a0_r, const_val1, a0_l, const_val1, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp1_r, temp1_l); + MUL2(w6, temp3_r, w6, temp3_l, temp2_r, temp2_l); + BUTTERFLY_8(temp0_r, temp0_l, temp0_r, temp0_l, + temp2_l, temp2_r, temp1_l, temp1_r, + a0_r, a0_l, a1_r, a1_l, a2_l, a2_r, a3_l, a3_r); + UNPCK_SH_SW(in4, temp0_r, temp0_l); + UNPCK_SH_SW(in6, temp3_r, temp3_l); + MUL2(temp0_r, w4, temp0_l, w4, temp0_r, temp0_l); + MUL2(w2, temp3_r, w2, temp3_l, temp2_r, temp2_l); + MUL2(w6, temp3_r, w6, temp3_l, temp1_r, temp1_l); + ADD2(a0_r, temp0_r, a0_l, temp0_l, a0_r, a0_l); + SUB2(a1_r, temp0_r, a1_l, temp0_l, a1_r, a1_l); + SUB2(a2_r, temp0_r, a2_l, temp0_l, a2_r, a2_l); + ADD2(a3_r, temp0_r, a3_l, temp0_l, a3_r, a3_l); + ADD2(a0_r, temp1_r, a0_l, temp1_l, a0_r, a0_l); + SUB2(a1_r, temp2_r, a1_l, temp2_l, a1_r, a1_l); + ADD2(a2_r, temp2_r, a2_l, temp2_l, a2_r, a2_l); + SUB2(a3_r, temp1_r, a3_l, temp1_l, a3_r, a3_l); + ILVRL_H2_SW(in1, in3, b3_r, b3_l); + ILVRL_H2_SW(in5, in7, temp0_r, temp0_l); + DOTP_SH4_SW(b3_r, b3_r, b3_r, b3_r, const0, const1, const2, const3, + b0_r, b1_r, b2_r, b3_r); + DOTP_SH4_SW(b3_l, b3_l, b3_l, b3_l, const0, const1, const2, const3, + b0_l, b1_l, b2_l, b3_l); + DPADD_SH4_SW(temp0_r, temp0_r, temp0_r, temp0_r, + const4, const5, const6, const7, b0_r, b1_r, b2_r, b3_r); + DPADD_SH4_SW(temp0_l, temp0_l, temp0_l, temp0_l, + const4, const5, const6, const7, b0_l, b1_l, b2_l, b3_l); + BUTTERFLY_16(a0_r, a0_l, a1_r, a1_l, a2_r, a2_l, a3_r, a3_l, + b3_l, b3_r, b2_l, b2_r, b1_l, b1_r, b0_l, b0_r, + temp0_r, temp0_l, temp1_r, temp1_l, + temp2_r, temp2_l, temp3_r, temp3_l, + a3_l, a3_r, a2_l, a2_r, a1_l, a1_r, a0_l, a0_r); + SRA_4V(temp0_r, temp0_l, temp1_r, temp1_l, 20); + SRA_4V(temp2_r, temp2_l, temp3_r, temp3_l, 20); + LD_SH4(dst, dst_stride, in0, in1, in2, in3); + PCKEV_H4_SW(temp0_l, temp0_r, temp1_l, temp1_r, temp2_l, temp2_r, + temp3_l, temp3_r, temp0_r, temp1_r, temp2_r, temp3_r); + ILVR_B4_SW(zero, in0, zero, in1, zero, in2, zero, in3, + temp0_l, temp1_l, temp2_l, temp3_l); + temp0_r = (v4i32) ((v8i16) (temp0_r) + (v8i16) (temp0_l)); + temp1_r = (v4i32) ((v8i16) (temp1_r) + (v8i16) (temp1_l)); + temp2_r = (v4i32) ((v8i16) (temp2_r) + (v8i16) (temp2_l)); + temp3_r = (v4i32) ((v8i16) (temp3_r) + (v8i16) (temp3_l)); + temp0_r = (v4i32) CLIP_SH_0_255(temp0_r); + temp1_r = (v4i32) CLIP_SH_0_255(temp1_r); + temp2_r = (v4i32) CLIP_SH_0_255(temp2_r); + temp3_r = (v4i32) CLIP_SH_0_255(temp3_r); + PCKEV_B4_SW(temp0_r, temp0_r, temp1_r, temp1_r, + temp2_r, temp2_r, temp3_r, temp3_r, + temp0_r, temp1_r, temp2_r, temp3_r); + tmp0 = __msa_copy_u_d((v2i64) temp0_r, 1); + tmp1 = __msa_copy_u_d((v2i64) temp1_r, 1); + tmp2 = __msa_copy_u_d((v2i64) temp2_r, 1); + tmp3 = __msa_copy_u_d((v2i64) temp3_r, 1); + SD4(tmp0, tmp1, tmp2, tmp3, dst, dst_stride); + + SRA_4V(a3_r, a3_l, a2_r, a2_l, 20); + SRA_4V(a1_r, a1_l, a0_r, a0_l, 20); + LD_SH4(dst + 4 * dst_stride, dst_stride, in4, in5, in6, in7); + PCKEV_H4_SW(a0_l, a0_r, a1_l, a1_r, a2_l, a2_r, a3_l, a3_r, + a0_r, a1_r, a2_r, a3_r); + ILVR_B4_SW(zero, in4, zero, in5, zero, in6, zero, in7, + a3_l, a2_l, a1_l, a0_l); + a3_r = (v4i32) ((v8i16) (a3_r) + (v8i16) (a3_l)); + a2_r = (v4i32) ((v8i16) (a2_r) + (v8i16) (a2_l)); + a1_r = (v4i32) ((v8i16) (a1_r) + (v8i16) (a1_l)); + a0_r = (v4i32) ((v8i16) (a0_r) + (v8i16) (a0_l)); + a3_r = (v4i32) CLIP_SH_0_255(a3_r); + a2_r = (v4i32) CLIP_SH_0_255(a2_r); + a1_r = (v4i32) CLIP_SH_0_255(a1_r); + a0_r = (v4i32) CLIP_SH_0_255(a0_r); + PCKEV_B4_SW(a0_r, a0_r, a1_r, a1_r, + a2_r, a2_r, a3_r, a3_r, a0_r, a1_r, a2_r, a3_r); + tmp0 = __msa_copy_u_d((v2i64) a3_r, 1); + tmp1 = __msa_copy_u_d((v2i64) a2_r, 1); + tmp2 = __msa_copy_u_d((v2i64) a1_r, 1); + tmp3 = __msa_copy_u_d((v2i64) a0_r, 1); + SD4(tmp0, tmp1, tmp2, tmp3, dst + 4 * dst_stride, dst_stride); +} + +void ff_simple_idct_msa(int16_t *block) +{ + simple_idct_msa(block); +} + +void ff_simple_idct_put_msa(uint8_t *dst, int32_t dst_stride, int16_t *block) +{ + simple_idct_put_msa(dst, dst_stride, block); +} + +void ff_simple_idct_add_msa(uint8_t *dst, int32_t dst_stride, int16_t *block) +{ + simple_idct_add_msa(dst, dst_stride, block); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp8dsp_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp8dsp_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp8dsp_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp8dsp_init_mips.c 2015-08-04 17:20:03.000000000 +0000 @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * 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 + */ + +/** + * @file + * VP8 compatible video decoder + */ + +#include "config.h" +#include "libavutil/attributes.h" +#include "libavcodec/vp8dsp.h" +#include "vp8dsp_mips.h" + +#define VP8_MC_MIPS_FUNC(IDX, SIZE) \ + dsp->put_vp8_epel_pixels_tab[IDX][0][1] = \ + ff_put_vp8_epel##SIZE##_h4_msa; \ + dsp->put_vp8_epel_pixels_tab[IDX][0][2] = \ + ff_put_vp8_epel##SIZE##_h6_msa; \ + dsp->put_vp8_epel_pixels_tab[IDX][1][0] = \ + ff_put_vp8_epel##SIZE##_v4_msa; \ + dsp->put_vp8_epel_pixels_tab[IDX][1][1] = \ + ff_put_vp8_epel##SIZE##_h4v4_msa; \ + dsp->put_vp8_epel_pixels_tab[IDX][1][2] = \ + ff_put_vp8_epel##SIZE##_h6v4_msa; \ + dsp->put_vp8_epel_pixels_tab[IDX][2][0] = \ + ff_put_vp8_epel##SIZE##_v6_msa; \ + dsp->put_vp8_epel_pixels_tab[IDX][2][1] = \ + ff_put_vp8_epel##SIZE##_h4v6_msa; \ + dsp->put_vp8_epel_pixels_tab[IDX][2][2] = \ + ff_put_vp8_epel##SIZE##_h6v6_msa + +#define VP8_BILINEAR_MC_MIPS_FUNC(IDX, SIZE) \ + dsp->put_vp8_bilinear_pixels_tab[IDX][0][1] = \ + ff_put_vp8_bilinear##SIZE##_h_msa; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][0][2] = \ + ff_put_vp8_bilinear##SIZE##_h_msa; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][1][0] = \ + ff_put_vp8_bilinear##SIZE##_v_msa; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][1][1] = \ + ff_put_vp8_bilinear##SIZE##_hv_msa; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][1][2] = \ + ff_put_vp8_bilinear##SIZE##_hv_msa; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][2][0] = \ + ff_put_vp8_bilinear##SIZE##_v_msa; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][2][1] = \ + ff_put_vp8_bilinear##SIZE##_hv_msa; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][2][2] = \ + ff_put_vp8_bilinear##SIZE##_hv_msa + +#define VP8_MC_MIPS_COPY(IDX, SIZE) \ + dsp->put_vp8_epel_pixels_tab[IDX][0][0] = \ + ff_put_vp8_pixels##SIZE##_msa; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][0][0] = \ + ff_put_vp8_pixels##SIZE##_msa; + +#if HAVE_MSA +static av_cold void vp8dsp_init_msa(VP8DSPContext *dsp) +{ + dsp->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_msa; + dsp->vp8_idct_add = ff_vp8_idct_add_msa; + dsp->vp8_idct_dc_add = ff_vp8_idct_dc_add_msa; + dsp->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_msa; + dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_msa; + + VP8_MC_MIPS_FUNC(0, 16); + VP8_MC_MIPS_FUNC(1, 8); + VP8_MC_MIPS_FUNC(2, 4); + + VP8_BILINEAR_MC_MIPS_FUNC(0, 16); + VP8_BILINEAR_MC_MIPS_FUNC(1, 8); + VP8_BILINEAR_MC_MIPS_FUNC(2, 4); + + VP8_MC_MIPS_COPY(0, 16); + VP8_MC_MIPS_COPY(1, 8); + + dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_msa; + dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_msa; + dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_msa; + dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_msa; + + dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_msa; + dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_msa; + dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_msa; + dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_msa; + + dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_msa; + dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_msa; +} +#endif // #if HAVE_MSA + +av_cold void ff_vp8dsp_init_mips(VP8DSPContext *dsp) +{ +#if HAVE_MSA + vp8dsp_init_msa(dsp); +#endif // #if HAVE_MSA +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp8dsp_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp8dsp_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp8dsp_mips.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp8dsp_mips.h 2015-08-04 17:20:03.000000000 +0000 @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * 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 + */ + +#ifndef AVCODEC_MIPS_VP8DSP_MIPS_H +#define AVCODEC_MIPS_VP8DSP_MIPS_H + +void ff_put_vp8_pixels4_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int x, int y); +void ff_put_vp8_pixels8_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int x, int y); +void ff_put_vp8_pixels16_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int x, int y); + +void ff_put_vp8_epel16_h4_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel16_h6_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel16_v4_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel16_v6_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel16_h4v4_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel16_h6v4_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel16_h4v6_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel16_h6v6_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); + +void ff_put_vp8_epel8_h4_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel8_h6_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel8_v4_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel8_v6_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel8_h4v4_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel8_h6v4_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel8_h4v6_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel8_h6v6_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); + +void ff_put_vp8_epel4_h4_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel4_h6_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel4_v4_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel4_v6_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel4_h4v4_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel4_h6v4_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel4_h4v6_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_epel4_h6v6_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); + +void ff_put_vp8_bilinear16_h_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_bilinear16_v_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_bilinear16_hv_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); + +void ff_put_vp8_bilinear8_h_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_bilinear8_v_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_bilinear8_hv_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); + +void ff_put_vp8_bilinear4_h_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_bilinear4_v_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); +void ff_put_vp8_bilinear4_hv_msa(uint8_t *dst, ptrdiff_t dststride, + uint8_t *src, ptrdiff_t srcstride, + int h, int mx, int my); + +/* loop filter */ +void ff_vp8_h_loop_filter16_inner_msa(uint8_t *dst, ptrdiff_t stride, + int32_t e, int32_t i, int32_t h); +void ff_vp8_v_loop_filter16_inner_msa(uint8_t *dst, ptrdiff_t stride, + int32_t e, int32_t i, int32_t h); +void ff_vp8_h_loop_filter8uv_inner_msa(uint8_t *dst_u, uint8_t *dst_v, + ptrdiff_t stride, + int flim_e, int flim_i, int hev_thresh); +void ff_vp8_v_loop_filter8uv_inner_msa(uint8_t *dst_u, uint8_t *dst_v, + ptrdiff_t stride, + int flim_e, int flim_i, int hev_thresh); +void ff_vp8_h_loop_filter16_msa(uint8_t *dst, ptrdiff_t stride, + int flim_e, int flim_i, int hev_thresh); +void ff_vp8_v_loop_filter16_msa(uint8_t *dst, ptrdiff_t stride, + int flim_e, int flim_i, int hev_thresh); +void ff_vp8_h_loop_filter8uv_msa(uint8_t *dst_u, uint8_t *dst_v, + ptrdiff_t stride, + int flim_e, int flim_i, int hev_thresh); +void ff_vp8_v_loop_filter8uv_msa(uint8_t *dst_u, uint8_t *dst_v, + ptrdiff_t stride, + int flim_e, int flim_i, int hev_thresh); +void ff_vp8_h_loop_filter_simple_msa(uint8_t *dst, ptrdiff_t stride, int flim); +void ff_vp8_v_loop_filter_simple_msa(uint8_t *dst, ptrdiff_t stride, int flim); + +/* Idct functions */ +void ff_vp8_luma_dc_wht_msa(int16_t block[4][4][16], int16_t dc[16]); +void ff_vp8_idct_add_msa(uint8_t *dst, int16_t block[16], ptrdiff_t stride); +void ff_vp8_idct_dc_add_msa(uint8_t *dst, int16_t block[16], ptrdiff_t stride); +void ff_vp8_idct_dc_add4uv_msa(uint8_t *dst, int16_t block[4][16], + ptrdiff_t stride); +void ff_vp8_idct_dc_add4y_msa(uint8_t *dst, int16_t block[4][16], + ptrdiff_t stride); + +#endif // #ifndef AVCODEC_MIPS_VP8DSP_MIPS_H diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp8_idct_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp8_idct_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp8_idct_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp8_idct_msa.c 2015-08-04 17:20:03.000000000 +0000 @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * 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 +#include "libavcodec/vp8dsp.h" +#include "libavutil/mips/generic_macros_msa.h" +#include "vp8dsp_mips.h" + +static const int cospi8sqrt2minus1 = 20091; +static const int sinpi8sqrt2 = 35468; + +#define VP8_IDCT_1D_W(in0, in1, in2, in3, out0, out1, out2, out3) \ +{ \ + v4i32 a1_m, b1_m, c1_m, d1_m; \ + v4i32 c_tmp1_m, c_tmp2_m, d_tmp1_m, d_tmp2_m; \ + v4i32 const_cospi8sqrt2minus1_m, sinpi8_sqrt2_m; \ + \ + const_cospi8sqrt2minus1_m = __msa_fill_w(cospi8sqrt2minus1); \ + sinpi8_sqrt2_m = __msa_fill_w(sinpi8sqrt2); \ + a1_m = in0 + in2; \ + b1_m = in0 - in2; \ + c_tmp1_m = ((in1) * sinpi8_sqrt2_m) >> 16; \ + c_tmp2_m = in3 + (((in3) * const_cospi8sqrt2minus1_m) >> 16); \ + c1_m = c_tmp1_m - c_tmp2_m; \ + d_tmp1_m = (in1) + (((in1) * const_cospi8sqrt2minus1_m) >> 16); \ + d_tmp2_m = ((in3) * sinpi8_sqrt2_m) >> 16; \ + d1_m = d_tmp1_m + d_tmp2_m; \ + BUTTERFLY_4(a1_m, b1_m, c1_m, d1_m, out0, out1, out2, out3); \ +} + +void ff_vp8_idct_add_msa(uint8_t *dst, int16_t input[16], ptrdiff_t stride) +{ + v8i16 input0, input1; + v4i32 in0, in1, in2, in3, hz0, hz1, hz2, hz3, vt0, vt1, vt2, vt3; + v4i32 res0, res1, res2, res3; + v16i8 zero = { 0 }; + v16i8 pred0, pred1, pred2, pred3, dest0, dest1; + v16i8 mask = { 0, 4, 8, 12, 16, 20, 24, 28, 0, 0, 0, 0, 0, 0, 0, 0 }; + + /* load short vector elements of 4x4 block */ + LD_SH2(input, 8, input0, input1); + UNPCK_SH_SW(input0, in0, in1); + UNPCK_SH_SW(input1, in2, in3); + VP8_IDCT_1D_W(in0, in1, in2, in3, hz0, hz1, hz2, hz3); + /* transpose the block */ + TRANSPOSE4x4_SW_SW(hz0, hz1, hz2, hz3, hz0, hz1, hz2, hz3); + VP8_IDCT_1D_W(hz0, hz1, hz2, hz3, vt0, vt1, vt2, vt3); + SRARI_W4_SW(vt0, vt1, vt2, vt3, 3); + /* transpose the block */ + TRANSPOSE4x4_SW_SW(vt0, vt1, vt2, vt3, vt0, vt1, vt2, vt3); + LD_SB4(dst, stride, pred0, pred1, pred2, pred3); + ILVR_B4_SW(zero, pred0, zero, pred1, zero, pred2, zero, pred3, + res0, res1, res2, res3); + ILVR_H4_SW(zero, res0, zero, res1, zero, res2, zero, res3, + res0, res1, res2, res3); + ADD4(res0, vt0, res1, vt1, res2, vt2, res3, vt3, res0, res1, res2, res3); + res0 = CLIP_SW_0_255(res0); + res1 = CLIP_SW_0_255(res1); + res2 = CLIP_SW_0_255(res2); + res3 = CLIP_SW_0_255(res3); + VSHF_B2_SB(res0, res1, res2, res3, mask, mask, dest0, dest1); + ST4x4_UB(dest0, dest1, 0, 1, 0, 1, dst, stride); + + memset(input, 0, 4 * 4 * sizeof(*input)); +} + +void ff_vp8_idct_dc_add_msa(uint8_t *dst, int16_t in_dc[16], ptrdiff_t stride) +{ + v8i16 vec; + v8i16 res0, res1, res2, res3; + v16i8 zero = { 0 }; + v16i8 pred0, pred1, pred2, pred3, dest0, dest1; + v16i8 mask = { 0, 2, 4, 6, 16, 18, 20, 22, 0, 0, 0, 0, 0, 0, 0, 0 }; + + vec = __msa_fill_h(in_dc[0]); + vec = __msa_srari_h(vec, 3); + LD_SB4(dst, stride, pred0, pred1, pred2, pred3); + ILVR_B4_SH(zero, pred0, zero, pred1, zero, pred2, zero, pred3, + res0, res1, res2, res3); + ADD4(res0, vec, res1, vec, res2, vec, res3, vec, res0, res1, res2, res3); + CLIP_SH4_0_255(res0, res1, res2, res3); + VSHF_B2_SB(res0, res1, res2, res3, mask, mask, dest0, dest1); + ST4x4_UB(dest0, dest1, 0, 1, 0, 1, dst, stride); + + in_dc[0] = 0; +} + +void ff_vp8_luma_dc_wht_msa(int16_t block[4][4][16], int16_t input[16]) +{ + int16_t *mb_dq_coeff = &block[0][0][0]; + v8i16 input0, input1; + v4i32 in0, in1, in2, in3, a1, b1, c1, d1; + v4i32 hz0, hz1, hz2, hz3, vt0, vt1, vt2, vt3; + + /* load short vector elements of 4x4 block */ + LD_SH2(input, 8, input0, input1); + UNPCK_SH_SW(input0, in0, in1); + UNPCK_SH_SW(input1, in2, in3); + BUTTERFLY_4(in0, in1, in2, in3, a1, b1, c1, d1); + BUTTERFLY_4(a1, d1, c1, b1, hz0, hz1, hz3, hz2); + /* transpose the block */ + TRANSPOSE4x4_SW_SW(hz0, hz1, hz2, hz3, hz0, hz1, hz2, hz3); + BUTTERFLY_4(hz0, hz1, hz2, hz3, a1, b1, c1, d1); + BUTTERFLY_4(a1, d1, c1, b1, vt0, vt1, vt3, vt2); + ADD4(vt0, 3, vt1, 3, vt2, 3, vt3, 3, vt0, vt1, vt2, vt3); + SRA_4V(vt0, vt1, vt2, vt3, 3); + mb_dq_coeff[0] = __msa_copy_s_h((v8i16) vt0, 0); + mb_dq_coeff[16] = __msa_copy_s_h((v8i16) vt1, 0); + mb_dq_coeff[32] = __msa_copy_s_h((v8i16) vt2, 0); + mb_dq_coeff[48] = __msa_copy_s_h((v8i16) vt3, 0); + mb_dq_coeff[64] = __msa_copy_s_h((v8i16) vt0, 2); + mb_dq_coeff[80] = __msa_copy_s_h((v8i16) vt1, 2); + mb_dq_coeff[96] = __msa_copy_s_h((v8i16) vt2, 2); + mb_dq_coeff[112] = __msa_copy_s_h((v8i16) vt3, 2); + mb_dq_coeff[128] = __msa_copy_s_h((v8i16) vt0, 4); + mb_dq_coeff[144] = __msa_copy_s_h((v8i16) vt1, 4); + mb_dq_coeff[160] = __msa_copy_s_h((v8i16) vt2, 4); + mb_dq_coeff[176] = __msa_copy_s_h((v8i16) vt3, 4); + mb_dq_coeff[192] = __msa_copy_s_h((v8i16) vt0, 6); + mb_dq_coeff[208] = __msa_copy_s_h((v8i16) vt1, 6); + mb_dq_coeff[224] = __msa_copy_s_h((v8i16) vt2, 6); + mb_dq_coeff[240] = __msa_copy_s_h((v8i16) vt3, 6); + + memset(input, 0, 4 * 4 * sizeof(int16_t)); +} + +void ff_vp8_idct_dc_add4y_msa(uint8_t *dst, int16_t block[4][16], + ptrdiff_t stride) +{ + ff_vp8_idct_dc_add_msa(dst, &block[0][0], stride); + ff_vp8_idct_dc_add_msa(dst + 4, &block[1][0], stride); + ff_vp8_idct_dc_add_msa(dst + 8, &block[2][0], stride); + ff_vp8_idct_dc_add_msa(dst + 12, &block[3][0], stride); +} + +void ff_vp8_idct_dc_add4uv_msa(uint8_t *dst, int16_t block[4][16], + ptrdiff_t stride) +{ + ff_vp8_idct_dc_add_msa(dst, &block[0][0], stride); + ff_vp8_idct_dc_add_msa(dst + 4, &block[1][0], stride); + ff_vp8_idct_dc_add_msa(dst + stride * 4, &block[2][0], stride); + ff_vp8_idct_dc_add_msa(dst + stride * 4 + 4, &block[3][0], stride); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp8_lpf_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp8_lpf_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp8_lpf_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp8_lpf_msa.c 2015-08-04 17:20:03.000000000 +0000 @@ -0,0 +1,690 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/vp8dsp.h" +#include "libavutil/mips/generic_macros_msa.h" +#include "vp8dsp_mips.h" + +#define VP8_SIMPLE_MASK(p1, p0, q0, q1, b_limit, mask) \ +{ \ + v16u8 p1_a_sub_q1, p0_a_sub_q0; \ + \ + p0_a_sub_q0 = __msa_asub_u_b(p0, q0); \ + p1_a_sub_q1 = __msa_asub_u_b(p1, q1); \ + p1_a_sub_q1 = (v16u8) __msa_srli_b((v16i8) p1_a_sub_q1, 1); \ + p0_a_sub_q0 = __msa_adds_u_b(p0_a_sub_q0, p0_a_sub_q0); \ + mask = __msa_adds_u_b(p0_a_sub_q0, p1_a_sub_q1); \ + mask = ((v16u8) mask <= b_limit); \ +} + +#define VP8_LPF_FILTER4_4W(p1_in_out, p0_in_out, q0_in_out, q1_in_out, \ + mask_in, hev_in) \ +{ \ + v16i8 p1_m, p0_m, q0_m, q1_m, q0_sub_p0, filt_sign; \ + v16i8 filt, filt1, filt2, cnst4b, cnst3b; \ + v8i16 q0_sub_p0_r, q0_sub_p0_l, filt_l, filt_r, cnst3h; \ + \ + p1_m = (v16i8) __msa_xori_b(p1_in_out, 0x80); \ + p0_m = (v16i8) __msa_xori_b(p0_in_out, 0x80); \ + q0_m = (v16i8) __msa_xori_b(q0_in_out, 0x80); \ + q1_m = (v16i8) __msa_xori_b(q1_in_out, 0x80); \ + \ + filt = __msa_subs_s_b(p1_m, q1_m); \ + \ + filt = filt & (v16i8) hev_in; \ + \ + q0_sub_p0 = q0_m - p0_m; \ + filt_sign = __msa_clti_s_b(filt, 0); \ + \ + cnst3h = __msa_ldi_h(3); \ + q0_sub_p0_r = (v8i16) __msa_ilvr_b(q0_sub_p0, q0_sub_p0); \ + q0_sub_p0_r = __msa_dotp_s_h((v16i8) q0_sub_p0_r, (v16i8) cnst3h); \ + filt_r = (v8i16) __msa_ilvr_b(filt_sign, filt); \ + filt_r += q0_sub_p0_r; \ + filt_r = __msa_sat_s_h(filt_r, 7); \ + \ + q0_sub_p0_l = (v8i16) __msa_ilvl_b(q0_sub_p0, q0_sub_p0); \ + q0_sub_p0_l = __msa_dotp_s_h((v16i8) q0_sub_p0_l, (v16i8) cnst3h); \ + filt_l = (v8i16) __msa_ilvl_b(filt_sign, filt); \ + filt_l += q0_sub_p0_l; \ + filt_l = __msa_sat_s_h(filt_l, 7); \ + \ + filt = __msa_pckev_b((v16i8) filt_l, (v16i8) filt_r); \ + filt = filt & (v16i8) mask_in; \ + \ + cnst4b = __msa_ldi_b(4); \ + filt1 = __msa_adds_s_b(filt, cnst4b); \ + filt1 >>= 3; \ + \ + cnst3b = __msa_ldi_b(3); \ + filt2 = __msa_adds_s_b(filt, cnst3b); \ + filt2 >>= 3; \ + \ + q0_m = __msa_subs_s_b(q0_m, filt1); \ + q0_in_out = __msa_xori_b((v16u8) q0_m, 0x80); \ + p0_m = __msa_adds_s_b(p0_m, filt2); \ + p0_in_out = __msa_xori_b((v16u8) p0_m, 0x80); \ + \ + filt = __msa_srari_b(filt1, 1); \ + hev_in = __msa_xori_b((v16u8) hev_in, 0xff); \ + filt = filt & (v16i8) hev_in; \ + \ + q1_m = __msa_subs_s_b(q1_m, filt); \ + q1_in_out = __msa_xori_b((v16u8) q1_m, 0x80); \ + p1_m = __msa_adds_s_b(p1_m, filt); \ + p1_in_out = __msa_xori_b((v16u8) p1_m, 0x80); \ +} + +#define VP8_SIMPLE_FILT(p1_in, p0_in, q0_in, q1_in, mask) \ +{ \ + v16i8 p1_m, p0_m, q0_m, q1_m, q0_sub_p0, q0_sub_p0_sign; \ + v16i8 filt, filt1, filt2, cnst4b, cnst3b, filt_sign; \ + v8i16 q0_sub_p0_r, q0_sub_p0_l, filt_l, filt_r, cnst3h; \ + \ + p1_m = (v16i8) __msa_xori_b(p1_in, 0x80); \ + p0_m = (v16i8) __msa_xori_b(p0_in, 0x80); \ + q0_m = (v16i8) __msa_xori_b(q0_in, 0x80); \ + q1_m = (v16i8) __msa_xori_b(q1_in, 0x80); \ + \ + filt = __msa_subs_s_b(p1_m, q1_m); \ + \ + q0_sub_p0 = q0_m - p0_m; \ + filt_sign = __msa_clti_s_b(filt, 0); \ + \ + cnst3h = __msa_ldi_h(3); \ + q0_sub_p0_sign = __msa_clti_s_b(q0_sub_p0, 0); \ + q0_sub_p0_r = (v8i16) __msa_ilvr_b(q0_sub_p0_sign, q0_sub_p0); \ + q0_sub_p0_r *= cnst3h; \ + filt_r = (v8i16) __msa_ilvr_b(filt_sign, filt); \ + filt_r += q0_sub_p0_r; \ + filt_r = __msa_sat_s_h(filt_r, 7); \ + \ + q0_sub_p0_l = (v8i16) __msa_ilvl_b(q0_sub_p0_sign, q0_sub_p0); \ + q0_sub_p0_l *= cnst3h; \ + filt_l = (v8i16) __msa_ilvl_b(filt_sign, filt); \ + filt_l += q0_sub_p0_l; \ + filt_l = __msa_sat_s_h(filt_l, 7); \ + \ + filt = __msa_pckev_b((v16i8) filt_l, (v16i8) filt_r); \ + filt = filt & (v16i8) (mask); \ + \ + cnst4b = __msa_ldi_b(4); \ + filt1 = __msa_adds_s_b(filt, cnst4b); \ + filt1 >>= 3; \ + \ + cnst3b = __msa_ldi_b(3); \ + filt2 = __msa_adds_s_b(filt, cnst3b); \ + filt2 >>= 3; \ + \ + q0_m = __msa_subs_s_b(q0_m, filt1); \ + p0_m = __msa_adds_s_b(p0_m, filt2); \ + q0_in = __msa_xori_b((v16u8) q0_m, 0x80); \ + p0_in = __msa_xori_b((v16u8) p0_m, 0x80); \ +} + +#define VP8_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev) \ +{ \ + v16i8 p2_m, p1_m, p0_m, q2_m, q1_m, q0_m; \ + v16i8 filt, q0_sub_p0, cnst4b, cnst3b; \ + v16i8 u, filt1, filt2, filt_sign, q0_sub_p0_sign; \ + v8i16 q0_sub_p0_r, q0_sub_p0_l, filt_r, u_r, u_l, filt_l; \ + v8i16 cnst3h, cnst27h, cnst18h, cnst63h; \ + \ + cnst3h = __msa_ldi_h(3); \ + \ + p2_m = (v16i8) __msa_xori_b(p2, 0x80); \ + p1_m = (v16i8) __msa_xori_b(p1, 0x80); \ + p0_m = (v16i8) __msa_xori_b(p0, 0x80); \ + q0_m = (v16i8) __msa_xori_b(q0, 0x80); \ + q1_m = (v16i8) __msa_xori_b(q1, 0x80); \ + q2_m = (v16i8) __msa_xori_b(q2, 0x80); \ + \ + filt = __msa_subs_s_b(p1_m, q1_m); \ + q0_sub_p0 = q0_m - p0_m; \ + q0_sub_p0_sign = __msa_clti_s_b(q0_sub_p0, 0); \ + filt_sign = __msa_clti_s_b(filt, 0); \ + \ + /* right part */ \ + q0_sub_p0_r = (v8i16) __msa_ilvr_b(q0_sub_p0_sign, q0_sub_p0); \ + q0_sub_p0_r *= cnst3h; \ + filt_r = (v8i16) __msa_ilvr_b(filt_sign, filt); \ + filt_r = filt_r + q0_sub_p0_r; \ + filt_r = __msa_sat_s_h(filt_r, 7); \ + \ + /* left part */ \ + q0_sub_p0_l = (v8i16) __msa_ilvl_b(q0_sub_p0_sign, q0_sub_p0); \ + q0_sub_p0_l *= cnst3h; \ + filt_l = (v8i16) __msa_ilvl_b(filt_sign, filt); \ + filt_l = filt_l + q0_sub_p0_l; \ + filt_l = __msa_sat_s_h(filt_l, 7); \ + \ + /* combine left and right part */ \ + filt = __msa_pckev_b((v16i8) filt_l, (v16i8) filt_r); \ + filt = filt & (v16i8) mask; \ + filt2 = filt & (v16i8) hev; \ + \ + /* filt_val &= ~hev */ \ + hev = __msa_xori_b(hev, 0xff); \ + filt = filt & (v16i8) hev; \ + cnst4b = __msa_ldi_b(4); \ + filt1 = __msa_adds_s_b(filt2, cnst4b); \ + filt1 >>= 3; \ + cnst3b = __msa_ldi_b(3); \ + filt2 = __msa_adds_s_b(filt2, cnst3b); \ + filt2 >>= 3; \ + q0_m = __msa_subs_s_b(q0_m, filt1); \ + p0_m = __msa_adds_s_b(p0_m, filt2); \ + \ + filt_sign = __msa_clti_s_b(filt, 0); \ + ILVRL_B2_SH(filt_sign, filt, filt_r, filt_l); \ + \ + cnst27h = __msa_ldi_h(27); \ + cnst63h = __msa_ldi_h(63); \ + \ + /* right part */ \ + u_r = filt_r * cnst27h; \ + u_r += cnst63h; \ + u_r >>= 7; \ + u_r = __msa_sat_s_h(u_r, 7); \ + /* left part */ \ + u_l = filt_l * cnst27h; \ + u_l += cnst63h; \ + u_l >>= 7; \ + u_l = __msa_sat_s_h(u_l, 7); \ + /* combine left and right part */ \ + u = __msa_pckev_b((v16i8) u_l, (v16i8) u_r); \ + q0_m = __msa_subs_s_b(q0_m, u); \ + q0 = __msa_xori_b((v16u8) q0_m, 0x80); \ + p0_m = __msa_adds_s_b(p0_m, u); \ + p0 = __msa_xori_b((v16u8) p0_m, 0x80); \ + cnst18h = __msa_ldi_h(18); \ + u_r = filt_r * cnst18h; \ + u_r += cnst63h; \ + u_r >>= 7; \ + u_r = __msa_sat_s_h(u_r, 7); \ + \ + /* left part */ \ + u_l = filt_l * cnst18h; \ + u_l += cnst63h; \ + u_l >>= 7; \ + u_l = __msa_sat_s_h(u_l, 7); \ + /* combine left and right part */ \ + u = __msa_pckev_b((v16i8) u_l, (v16i8) u_r); \ + q1_m = __msa_subs_s_b(q1_m, u); \ + q1 = __msa_xori_b((v16u8) q1_m, 0x80); \ + p1_m = __msa_adds_s_b(p1_m, u); \ + p1 = __msa_xori_b((v16u8) p1_m, 0x80); \ + u_r = filt_r << 3; \ + u_r += filt_r + cnst63h; \ + u_r >>= 7; \ + u_r = __msa_sat_s_h(u_r, 7); \ + \ + /* left part */ \ + u_l = filt_l << 3; \ + u_l += filt_l + cnst63h; \ + u_l >>= 7; \ + u_l = __msa_sat_s_h(u_l, 7); \ + /* combine left and right part */ \ + u = __msa_pckev_b((v16i8) u_l, (v16i8) u_r); \ + q2_m = __msa_subs_s_b(q2_m, u); \ + q2 = __msa_xori_b((v16u8) q2_m, 0x80); \ + p2_m = __msa_adds_s_b(p2_m, u); \ + p2 = __msa_xori_b((v16u8) p2_m, 0x80); \ +} + +#define LPF_MASK_HEV(p3_in, p2_in, p1_in, p0_in, \ + q0_in, q1_in, q2_in, q3_in, \ + limit_in, b_limit_in, thresh_in, \ + hev_out, mask_out, flat_out) \ +{ \ + v16u8 p3_asub_p2_m, p2_asub_p1_m, p1_asub_p0_m, q1_asub_q0_m; \ + v16u8 p1_asub_q1_m, p0_asub_q0_m, q3_asub_q2_m, q2_asub_q1_m; \ + \ + /* absolute subtraction of pixel values */ \ + p3_asub_p2_m = __msa_asub_u_b((p3_in), (p2_in)); \ + p2_asub_p1_m = __msa_asub_u_b((p2_in), (p1_in)); \ + p1_asub_p0_m = __msa_asub_u_b((p1_in), (p0_in)); \ + q1_asub_q0_m = __msa_asub_u_b((q1_in), (q0_in)); \ + q2_asub_q1_m = __msa_asub_u_b((q2_in), (q1_in)); \ + q3_asub_q2_m = __msa_asub_u_b((q3_in), (q2_in)); \ + p0_asub_q0_m = __msa_asub_u_b((p0_in), (q0_in)); \ + p1_asub_q1_m = __msa_asub_u_b((p1_in), (q1_in)); \ + /* calculation of hev */ \ + flat_out = __msa_max_u_b(p1_asub_p0_m, q1_asub_q0_m); \ + hev_out = (thresh_in) < (v16u8) flat_out; \ + /* calculation of mask */ \ + p0_asub_q0_m = __msa_adds_u_b(p0_asub_q0_m, p0_asub_q0_m); \ + p1_asub_q1_m >>= 1; \ + p0_asub_q0_m = __msa_adds_u_b(p0_asub_q0_m, p1_asub_q1_m); \ + mask_out = (b_limit_in) < p0_asub_q0_m; \ + mask_out = __msa_max_u_b(flat_out, mask_out); \ + p3_asub_p2_m = __msa_max_u_b(p3_asub_p2_m, p2_asub_p1_m); \ + mask_out = __msa_max_u_b(p3_asub_p2_m, mask_out); \ + q2_asub_q1_m = __msa_max_u_b(q2_asub_q1_m, q3_asub_q2_m); \ + mask_out = __msa_max_u_b(q2_asub_q1_m, mask_out); \ + mask_out = (limit_in) < (v16u8) mask_out; \ + mask_out = __msa_xori_b(mask_out, 0xff); \ +} + +#define VP8_ST6x1_UB(in0, in0_idx, in1, in1_idx, pdst, stride) \ +{ \ + uint16_t tmp0_h; \ + uint32_t tmp0_w; \ + \ + tmp0_w = __msa_copy_u_w((v4i32) in0, in0_idx); \ + tmp0_h = __msa_copy_u_h((v8i16) in1, in1_idx); \ + SW(tmp0_w, pdst); \ + SH(tmp0_h, pdst + stride); \ +} + +void ff_vp8_v_loop_filter16_msa(uint8_t *src, ptrdiff_t pitch, int b_limit_in, + int limit_in, int thresh_in) +{ + uint8_t *temp_src; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 mask, hev, flat, thresh, limit, b_limit; + + b_limit = (v16u8) __msa_fill_b(b_limit_in); + limit = (v16u8) __msa_fill_b(limit_in); + thresh = (v16u8) __msa_fill_b(thresh_in); + /* load vector elements */ + temp_src = src - (pitch << 2); + LD_UB8(temp_src, pitch, p3, p2, p1, p0, q0, q1, q2, q3); + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP8_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev); + /* store vector elements */ + temp_src = src - 3 * pitch; + ST_UB4(p2, p1, p0, q0, temp_src, pitch); + temp_src += (4 * pitch); + ST_UB2(q1, q2, temp_src, pitch); +} + +void ff_vp8_v_loop_filter8uv_msa(uint8_t *src_u, uint8_t *src_v, + ptrdiff_t pitch, int b_limit_in, int limit_in, + int thresh_in) +{ + uint8_t *temp_src; + uint64_t p2_d, p1_d, p0_d, q0_d, q1_d, q2_d; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 mask, hev, flat, thresh, limit, b_limit; + v16u8 p3_u, p2_u, p1_u, p0_u, q3_u, q2_u, q1_u, q0_u; + v16u8 p3_v, p2_v, p1_v, p0_v, q3_v, q2_v, q1_v, q0_v; + + b_limit = (v16u8) __msa_fill_b(b_limit_in); + limit = (v16u8) __msa_fill_b(limit_in); + thresh = (v16u8) __msa_fill_b(thresh_in); + + temp_src = src_u - (pitch << 2); + LD_UB8(temp_src, pitch, p3_u, p2_u, p1_u, p0_u, q0_u, q1_u, q2_u, q3_u); + temp_src = src_v - (pitch << 2); + LD_UB8(temp_src, pitch, p3_v, p2_v, p1_v, p0_v, q0_v, q1_v, q2_v, q3_v); + + /* rht 8 element of p3 are u pixel and left 8 element of p3 are v pixel */ + ILVR_D4_UB(p3_v, p3_u, p2_v, p2_u, p1_v, p1_u, p0_v, p0_u, p3, p2, p1, p0); + ILVR_D4_UB(q0_v, q0_u, q1_v, q1_u, q2_v, q2_u, q3_v, q3_u, q0, q1, q2, q3); + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP8_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev); + + p2_d = __msa_copy_u_d((v2i64) p2, 0); + p1_d = __msa_copy_u_d((v2i64) p1, 0); + p0_d = __msa_copy_u_d((v2i64) p0, 0); + q0_d = __msa_copy_u_d((v2i64) q0, 0); + q1_d = __msa_copy_u_d((v2i64) q1, 0); + q2_d = __msa_copy_u_d((v2i64) q2, 0); + src_u -= (pitch * 3); + SD4(p2_d, p1_d, p0_d, q0_d, src_u, pitch); + src_u += 4 * pitch; + SD(q1_d, src_u); + src_u += pitch; + SD(q2_d, src_u); + + p2_d = __msa_copy_u_d((v2i64) p2, 1); + p1_d = __msa_copy_u_d((v2i64) p1, 1); + p0_d = __msa_copy_u_d((v2i64) p0, 1); + q0_d = __msa_copy_u_d((v2i64) q0, 1); + q1_d = __msa_copy_u_d((v2i64) q1, 1); + q2_d = __msa_copy_u_d((v2i64) q2, 1); + src_v -= (pitch * 3); + SD4(p2_d, p1_d, p0_d, q0_d, src_v, pitch); + src_v += 4 * pitch; + SD(q1_d, src_v); + src_v += pitch; + SD(q2_d, src_v); +} + +void ff_vp8_h_loop_filter16_msa(uint8_t *src, ptrdiff_t pitch, int b_limit_in, + int limit_in, int thresh_in) +{ + uint8_t *temp_src; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 mask, hev, flat, thresh, limit, b_limit; + v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8; + v16u8 row9, row10, row11, row12, row13, row14, row15; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + + b_limit = (v16u8) __msa_fill_b(b_limit_in); + limit = (v16u8) __msa_fill_b(limit_in); + thresh = (v16u8) __msa_fill_b(thresh_in); + temp_src = src - 4; + LD_UB8(temp_src, pitch, row0, row1, row2, row3, row4, row5, row6, row7); + temp_src += (8 * pitch); + LD_UB8(temp_src, pitch, + row8, row9, row10, row11, row12, row13, row14, row15); + TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7, + row8, row9, row10, row11, row12, row13, row14, row15, + p3, p2, p1, p0, q0, q1, q2, q3); + + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP8_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev); + ILVR_B2_SH(p1, p2, q0, p0, tmp0, tmp1); + ILVRL_H2_SH(tmp1, tmp0, tmp3, tmp4); + ILVL_B2_SH(p1, p2, q0, p0, tmp0, tmp1); + ILVRL_H2_SH(tmp1, tmp0, tmp6, tmp7); + ILVRL_B2_SH(q2, q1, tmp2, tmp5); + + temp_src = src - 3; + VP8_ST6x1_UB(tmp3, 0, tmp2, 0, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp3, 1, tmp2, 1, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp3, 2, tmp2, 2, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp3, 3, tmp2, 3, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp4, 0, tmp2, 4, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp4, 1, tmp2, 5, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp4, 2, tmp2, 6, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp4, 3, tmp2, 7, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp6, 0, tmp5, 0, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp6, 1, tmp5, 1, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp6, 2, tmp5, 2, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp6, 3, tmp5, 3, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp7, 0, tmp5, 4, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp7, 1, tmp5, 5, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp7, 2, tmp5, 6, temp_src, 4); + temp_src += pitch; + VP8_ST6x1_UB(tmp7, 3, tmp5, 7, temp_src, 4); +} + +void ff_vp8_h_loop_filter8uv_msa(uint8_t *src_u, uint8_t *src_v, + ptrdiff_t pitch, int b_limit_in, int limit_in, + int thresh_in) +{ + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 mask, hev, flat, thresh, limit, b_limit; + v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8; + v16u8 row9, row10, row11, row12, row13, row14, row15; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + + b_limit = (v16u8) __msa_fill_b(b_limit_in); + limit = (v16u8) __msa_fill_b(limit_in); + thresh = (v16u8) __msa_fill_b(thresh_in); + + LD_UB8(src_u - 4, pitch, row0, row1, row2, row3, row4, row5, row6, row7); + LD_UB8(src_v - 4, pitch, + row8, row9, row10, row11, row12, row13, row14, row15); + TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7, + row8, row9, row10, row11, row12, row13, row14, row15, + p3, p2, p1, p0, q0, q1, q2, q3); + + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP8_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev); + + ILVR_B2_SH(p1, p2, q0, p0, tmp0, tmp1); + ILVRL_H2_SH(tmp1, tmp0, tmp3, tmp4); + ILVL_B2_SH(p1, p2, q0, p0, tmp0, tmp1); + ILVRL_H2_SH(tmp1, tmp0, tmp6, tmp7); + ILVRL_B2_SH(q2, q1, tmp2, tmp5); + + src_u -= 3; + VP8_ST6x1_UB(tmp3, 0, tmp2, 0, src_u, 4); + src_u += pitch; + VP8_ST6x1_UB(tmp3, 1, tmp2, 1, src_u, 4); + src_u += pitch; + VP8_ST6x1_UB(tmp3, 2, tmp2, 2, src_u, 4); + src_u += pitch; + VP8_ST6x1_UB(tmp3, 3, tmp2, 3, src_u, 4); + src_u += pitch; + VP8_ST6x1_UB(tmp4, 0, tmp2, 4, src_u, 4); + src_u += pitch; + VP8_ST6x1_UB(tmp4, 1, tmp2, 5, src_u, 4); + src_u += pitch; + VP8_ST6x1_UB(tmp4, 2, tmp2, 6, src_u, 4); + src_u += pitch; + VP8_ST6x1_UB(tmp4, 3, tmp2, 7, src_u, 4); + + src_v -= 3; + VP8_ST6x1_UB(tmp6, 0, tmp5, 0, src_v, 4); + src_v += pitch; + VP8_ST6x1_UB(tmp6, 1, tmp5, 1, src_v, 4); + src_v += pitch; + VP8_ST6x1_UB(tmp6, 2, tmp5, 2, src_v, 4); + src_v += pitch; + VP8_ST6x1_UB(tmp6, 3, tmp5, 3, src_v, 4); + src_v += pitch; + VP8_ST6x1_UB(tmp7, 0, tmp5, 4, src_v, 4); + src_v += pitch; + VP8_ST6x1_UB(tmp7, 1, tmp5, 5, src_v, 4); + src_v += pitch; + VP8_ST6x1_UB(tmp7, 2, tmp5, 6, src_v, 4); + src_v += pitch; + VP8_ST6x1_UB(tmp7, 3, tmp5, 7, src_v, 4); +} + +void ff_vp8_v_loop_filter_simple_msa(uint8_t *src, ptrdiff_t pitch, + int b_limit_ptr) +{ + v16u8 p1, p0, q1, q0; + v16u8 mask, b_limit; + + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + /* load vector elements */ + LD_UB4(src - (pitch << 1), pitch, p1, p0, q0, q1); + VP8_SIMPLE_MASK(p1, p0, q0, q1, b_limit, mask); + VP8_SIMPLE_FILT(p1, p0, q0, q1, mask); + ST_UB2(p0, q0, (src - pitch), pitch); +} + +void ff_vp8_h_loop_filter_simple_msa(uint8_t *src, ptrdiff_t pitch, + int b_limit_ptr) +{ + uint8_t *temp_src; + v16u8 p1, p0, q1, q0; + v16u8 mask, b_limit; + v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8; + v16u8 row9, row10, row11, row12, row13, row14, row15; + v8i16 tmp0, tmp1; + + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + temp_src = src - 2; + LD_UB8(temp_src, pitch, row0, row1, row2, row3, row4, row5, row6, row7); + temp_src += (8 * pitch); + LD_UB8(temp_src, pitch, + row8, row9, row10, row11, row12, row13, row14, row15); + TRANSPOSE16x4_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7, + row8, row9, row10, row11, row12, row13, row14, row15, + p1, p0, q0, q1); + VP8_SIMPLE_MASK(p1, p0, q0, q1, b_limit, mask); + VP8_SIMPLE_FILT(p1, p0, q0, q1, mask); + ILVRL_B2_SH(q0, p0, tmp1, tmp0); + + src -= 1; + ST2x4_UB(tmp1, 0, src, pitch); + src += 4 * pitch; + ST2x4_UB(tmp1, 4, src, pitch); + src += 4 * pitch; + ST2x4_UB(tmp0, 0, src, pitch); + src += 4 * pitch; + ST2x4_UB(tmp0, 4, src, pitch); + src += 4 * pitch; +} + +void ff_vp8_v_loop_filter8uv_inner_msa(uint8_t *src_u, uint8_t *src_v, + ptrdiff_t pitch, int b_limit_in, + int limit_in, int thresh_in) +{ + uint64_t p1_d, p0_d, q0_d, q1_d; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 mask, hev, flat, thresh, limit, b_limit; + v16u8 p3_u, p2_u, p1_u, p0_u, q3_u, q2_u, q1_u, q0_u; + v16u8 p3_v, p2_v, p1_v, p0_v, q3_v, q2_v, q1_v, q0_v; + + thresh = (v16u8) __msa_fill_b(thresh_in); + limit = (v16u8) __msa_fill_b(limit_in); + b_limit = (v16u8) __msa_fill_b(b_limit_in); + + src_u = src_u - (pitch << 2); + LD_UB8(src_u, pitch, p3_u, p2_u, p1_u, p0_u, q0_u, q1_u, q2_u, q3_u); + src_u += (5 * pitch); + src_v = src_v - (pitch << 2); + LD_UB8(src_v, pitch, p3_v, p2_v, p1_v, p0_v, q0_v, q1_v, q2_v, q3_v); + src_v += (5 * pitch); + + /* right 8 element of p3 are u pixel and + left 8 element of p3 are v pixel */ + ILVR_D4_UB(p3_v, p3_u, p2_v, p2_u, p1_v, p1_u, p0_v, p0_u, p3, p2, p1, p0); + ILVR_D4_UB(q0_v, q0_u, q1_v, q1_u, q2_v, q2_u, q3_v, q3_u, q0, q1, q2, q3); + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP8_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev); + + p1_d = __msa_copy_u_d((v2i64) p1, 0); + p0_d = __msa_copy_u_d((v2i64) p0, 0); + q0_d = __msa_copy_u_d((v2i64) q0, 0); + q1_d = __msa_copy_u_d((v2i64) q1, 0); + SD4(q1_d, q0_d, p0_d, p1_d, src_u, (- pitch)); + + p1_d = __msa_copy_u_d((v2i64) p1, 1); + p0_d = __msa_copy_u_d((v2i64) p0, 1); + q0_d = __msa_copy_u_d((v2i64) q0, 1); + q1_d = __msa_copy_u_d((v2i64) q1, 1); + SD4(q1_d, q0_d, p0_d, p1_d, src_v, (- pitch)); +} + +void ff_vp8_h_loop_filter8uv_inner_msa(uint8_t *src_u, uint8_t *src_v, + ptrdiff_t pitch, int b_limit_in, + int limit_in, int thresh_in) +{ + uint8_t *temp_src_u, *temp_src_v; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 mask, hev, flat, thresh, limit, b_limit; + v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8; + v16u8 row9, row10, row11, row12, row13, row14, row15; + v4i32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + + thresh = (v16u8) __msa_fill_b(thresh_in); + limit = (v16u8) __msa_fill_b(limit_in); + b_limit = (v16u8) __msa_fill_b(b_limit_in); + + LD_UB8(src_u - 4, pitch, row0, row1, row2, row3, row4, row5, row6, row7); + LD_UB8(src_v - 4, pitch, + row8, row9, row10, row11, row12, row13, row14, row15); + TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7, + row8, row9, row10, row11, row12, row13, row14, row15, + p3, p2, p1, p0, q0, q1, q2, q3); + + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP8_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev); + ILVR_B2_SW(p0, p1, q1, q0, tmp0, tmp1); + ILVRL_H2_SW(tmp1, tmp0, tmp2, tmp3); + tmp0 = (v4i32) __msa_ilvl_b((v16i8) p0, (v16i8) p1); + tmp1 = (v4i32) __msa_ilvl_b((v16i8) q1, (v16i8) q0); + ILVRL_H2_SW(tmp1, tmp0, tmp4, tmp5); + + temp_src_u = src_u - 2; + ST4x4_UB(tmp2, tmp2, 0, 1, 2, 3, temp_src_u, pitch); + temp_src_u += 4 * pitch; + ST4x4_UB(tmp3, tmp3, 0, 1, 2, 3, temp_src_u, pitch); + + temp_src_v = src_v - 2; + ST4x4_UB(tmp4, tmp4, 0, 1, 2, 3, temp_src_v, pitch); + temp_src_v += 4 * pitch; + ST4x4_UB(tmp5, tmp5, 0, 1, 2, 3, temp_src_v, pitch); +} + +void ff_vp8_v_loop_filter16_inner_msa(uint8_t *src, ptrdiff_t pitch, + int32_t e, int32_t i, int32_t h) +{ + v16u8 mask, hev, flat; + v16u8 thresh, b_limit, limit; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + + /* load vector elements */ + LD_UB8((src - 4 * pitch), pitch, p3, p2, p1, p0, q0, q1, q2, q3); + thresh = (v16u8) __msa_fill_b(h); + b_limit = (v16u8) __msa_fill_b(e); + limit = (v16u8) __msa_fill_b(i); + + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP8_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev); + + ST_UB4(p1, p0, q0, q1, (src - 2 * pitch), pitch); +} + +void ff_vp8_h_loop_filter16_inner_msa(uint8_t *src, ptrdiff_t pitch, + int32_t e, int32_t i, int32_t h) +{ + v16u8 mask, hev, flat; + v16u8 thresh, b_limit, limit; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 row0, row1, row2, row3, row4, row5, row6, row7; + v16u8 row8, row9, row10, row11, row12, row13, row14, row15; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + + LD_UB8(src - 4, pitch, row0, row1, row2, row3, row4, row5, row6, row7); + LD_UB8(src - 4 + (8 * pitch), pitch, + row8, row9, row10, row11, row12, row13, row14, row15); + TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7, + row8, row9, row10, row11, row12, row13, row14, row15, + p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(h); + b_limit = (v16u8) __msa_fill_b(e); + limit = (v16u8) __msa_fill_b(i); + + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP8_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev); + ILVR_B2_SH(p0, p1, q1, q0, tmp0, tmp1); + ILVRL_H2_SH(tmp1, tmp0, tmp2, tmp3); + ILVL_B2_SH(p0, p1, q1, q0, tmp0, tmp1); + ILVRL_H2_SH(tmp1, tmp0, tmp4, tmp5); + + src -= 2; + ST4x8_UB(tmp2, tmp3, src, pitch); + src += (8 * pitch); + ST4x8_UB(tmp4, tmp5, src, pitch); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp8_mc_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp8_mc_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp8_mc_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp8_mc_msa.c 2015-08-04 17:20:03.000000000 +0000 @@ -0,0 +1,2332 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/vp8dsp.h" +#include "libavutil/mips/generic_macros_msa.h" +#include "vp8dsp_mips.h" + +static const uint8_t mc_filt_mask_arr[16 * 3] = { + /* 8 width cases */ + 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, + /* 4 width cases */ + 0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20, + /* 4 width cases */ + 8, 9, 9, 10, 10, 11, 11, 12, 24, 25, 25, 26, 26, 27, 27, 28 +}; + +static const int8_t subpel_filters_msa[7][8] = { + {-6, 123, 12, -1, 0, 0, 0, 0}, + {2, -11, 108, 36, -8, 1, 0, 0}, /* New 1/4 pel 6 tap filter */ + {-9, 93, 50, -6, 0, 0, 0, 0}, + {3, -16, 77, 77, -16, 3, 0, 0}, /* New 1/2 pel 6 tap filter */ + {-6, 50, 93, -9, 0, 0, 0, 0}, + {1, -8, 36, 108, -11, 2, 0, 0}, /* New 1/4 pel 6 tap filter */ + {-1, 12, 123, -6, 0, 0, 0, 0}, +}; + +static const int8_t bilinear_filters_msa[7][2] = { + {112, 16}, + {96, 32}, + {80, 48}, + {64, 64}, + {48, 80}, + {32, 96}, + {16, 112} +}; + +#define HORIZ_6TAP_FILT(src0, src1, mask0, mask1, mask2, \ + filt_h0, filt_h1, filt_h2) \ +( { \ + v16i8 vec0_m, vec1_m, vec2_m; \ + v8i16 hz_out_m; \ + \ + VSHF_B3_SB(src0, src1, src0, src1, src0, src1, mask0, mask1, mask2, \ + vec0_m, vec1_m, vec2_m); \ + hz_out_m = DPADD_SH3_SH(vec0_m, vec1_m, vec2_m, \ + filt_h0, filt_h1, filt_h2); \ + \ + hz_out_m = __msa_srari_h(hz_out_m, 7); \ + hz_out_m = __msa_sat_s_h(hz_out_m, 7); \ + \ + hz_out_m; \ +} ) + +#define HORIZ_6TAP_4WID_4VECS_FILT(src0, src1, src2, src3, \ + mask0, mask1, mask2, \ + filt0, filt1, filt2, \ + out0, out1) \ +{ \ + v16i8 vec0_m, vec1_m, vec2_m, vec3_m, vec4_m, vec5_m; \ + \ + VSHF_B2_SB(src0, src1, src2, src3, mask0, mask0, vec0_m, vec1_m); \ + DOTP_SB2_SH(vec0_m, vec1_m, filt0, filt0, out0, out1); \ + VSHF_B2_SB(src0, src1, src2, src3, mask1, mask1, vec2_m, vec3_m); \ + DPADD_SB2_SH(vec2_m, vec3_m, filt1, filt1, out0, out1); \ + VSHF_B2_SB(src0, src1, src2, src3, mask2, mask2, vec4_m, vec5_m); \ + DPADD_SB2_SH(vec4_m, vec5_m, filt2, filt2, out0, out1); \ +} + +#define HORIZ_6TAP_8WID_4VECS_FILT(src0, src1, src2, src3, \ + mask0, mask1, mask2, \ + filt0, filt1, filt2, \ + out0, out1, out2, out3) \ +{ \ + v16i8 vec0_m, vec1_m, vec2_m, vec3_m, vec4_m, vec5_m, vec6_m, vec7_m; \ + \ + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec0_m, vec1_m); \ + VSHF_B2_SB(src2, src2, src3, src3, mask0, mask0, vec2_m, vec3_m); \ + DOTP_SB4_SH(vec0_m, vec1_m, vec2_m, vec3_m, filt0, filt0, filt0, filt0, \ + out0, out1, out2, out3); \ + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec0_m, vec1_m); \ + VSHF_B2_SB(src2, src2, src3, src3, mask1, mask1, vec2_m, vec3_m); \ + VSHF_B2_SB(src0, src0, src1, src1, mask2, mask2, vec4_m, vec5_m); \ + VSHF_B2_SB(src2, src2, src3, src3, mask2, mask2, vec6_m, vec7_m); \ + DPADD_SB4_SH(vec0_m, vec1_m, vec2_m, vec3_m, filt1, filt1, filt1, filt1, \ + out0, out1, out2, out3); \ + DPADD_SB4_SH(vec4_m, vec5_m, vec6_m, vec7_m, filt2, filt2, filt2, filt2, \ + out0, out1, out2, out3); \ +} + +#define FILT_4TAP_DPADD_S_H(vec0, vec1, filt0, filt1) \ +( { \ + v8i16 tmp0; \ + \ + tmp0 = __msa_dotp_s_h((v16i8) vec0, (v16i8) filt0); \ + tmp0 = __msa_dpadd_s_h(tmp0, (v16i8) vec1, (v16i8) filt1); \ + \ + tmp0; \ +} ) + +#define HORIZ_4TAP_FILT(src0, src1, mask0, mask1, filt_h0, filt_h1) \ +( { \ + v16i8 vec0_m, vec1_m; \ + v8i16 hz_out_m; \ + \ + VSHF_B2_SB(src0, src1, src0, src1, mask0, mask1, vec0_m, vec1_m); \ + hz_out_m = FILT_4TAP_DPADD_S_H(vec0_m, vec1_m, filt_h0, filt_h1); \ + \ + hz_out_m = __msa_srari_h(hz_out_m, 7); \ + hz_out_m = __msa_sat_s_h(hz_out_m, 7); \ + \ + hz_out_m; \ +} ) + +#define HORIZ_4TAP_4WID_4VECS_FILT(src0, src1, src2, src3, \ + mask0, mask1, filt0, filt1, \ + out0, out1) \ +{ \ + v16i8 vec0_m, vec1_m, vec2_m, vec3_m; \ + \ + VSHF_B2_SB(src0, src1, src2, src3, mask0, mask0, vec0_m, vec1_m); \ + DOTP_SB2_SH(vec0_m, vec1_m, filt0, filt0, out0, out1); \ + VSHF_B2_SB(src0, src1, src2, src3, mask1, mask1, vec2_m, vec3_m); \ + DPADD_SB2_SH(vec2_m, vec3_m, filt1, filt1, out0, out1); \ +} + +#define HORIZ_4TAP_8WID_4VECS_FILT(src0, src1, src2, src3, \ + mask0, mask1, filt0, filt1, \ + out0, out1, out2, out3) \ +{ \ + v16i8 vec0_m, vec1_m, vec2_m, vec3_m; \ + \ + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec0_m, vec1_m); \ + VSHF_B2_SB(src2, src2, src3, src3, mask0, mask0, vec2_m, vec3_m); \ + DOTP_SB4_SH(vec0_m, vec1_m, vec2_m, vec3_m, filt0, filt0, filt0, filt0, \ + out0, out1, out2, out3); \ + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec0_m, vec1_m); \ + VSHF_B2_SB(src2, src2, src3, src3, mask1, mask1, vec2_m, vec3_m); \ + DPADD_SB4_SH(vec0_m, vec1_m, vec2_m, vec3_m, filt1, filt1, filt1, filt1, \ + out0, out1, out2, out3); \ +} + +static void common_hz_6t_4x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, filt0, filt1, filt2; + v16u8 mask0, mask1, mask2, out; + v8i16 filt, out0, out1; + + mask0 = LD_UB(&mc_filt_mask_arr[16]); + src -= 2; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H3_SB(filt, 0, 1, 2, filt0, filt1, filt2); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_6TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + filt0, filt1, filt2, out0, out1); + SRARI_H2_SH(out0, out1, 7); + SAT_SH2_SH(out0, out1, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); +} + +static void common_hz_6t_4x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, filt0, filt1, filt2; + v16u8 mask0, mask1, mask2, out; + v8i16 filt, out0, out1, out2, out3; + + mask0 = LD_UB(&mc_filt_mask_arr[16]); + src -= 2; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H3_SB(filt, 0, 1, 2, filt0, filt1, filt2); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + HORIZ_6TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + filt0, filt1, filt2, out0, out1); + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_6TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + filt0, filt1, filt2, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + out = PCKEV_XORI128_UB(out2, out3); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); +} + +void ff_put_vp8_epel4_h6_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = subpel_filters_msa[mx - 1]; + + if (4 == height) { + common_hz_6t_4x4_msa(src, src_stride, dst, dst_stride, filter); + } else if (8 == height) { + common_hz_6t_4x8_msa(src, src_stride, dst, dst_stride, filter); + } +} + +void ff_put_vp8_epel8_h6_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = subpel_filters_msa[mx - 1]; + v16i8 src0, src1, src2, src3, filt0, filt1, filt2; + v16u8 mask0, mask1, mask2, tmp0, tmp1; + v8i16 filt, out0, out1, out2, out3; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + + src -= 2; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H3_SB(filt, 0, 1, 2, filt0, filt1, filt2); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + HORIZ_6TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + filt0, filt1, filt2, out0, out1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + tmp0 = PCKEV_XORI128_UB(out0, out1); + tmp1 = PCKEV_XORI128_UB(out2, out3); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); + dst += (4 * dst_stride); + + for (loop_cnt = (height >> 2) - 1; loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + HORIZ_6TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + filt0, filt1, filt2, out0, out1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + tmp0 = PCKEV_XORI128_UB(out0, out1); + tmp1 = PCKEV_XORI128_UB(out2, out3); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +void ff_put_vp8_epel16_h6_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = subpel_filters_msa[mx - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, filt0, filt1, filt2; + v16u8 mask0, mask1, mask2, out; + v8i16 filt, out0, out1, out2, out3, out4, out5, out6, out7; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= 2; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H3_SB(filt, 0, 1, 2, filt0, filt1, filt2); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src2, src4, src6); + LD_SB4(src + 8, src_stride, src1, src3, src5, src7); + XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); + src += (4 * src_stride); + + HORIZ_6TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + filt0, filt1, filt2, out0, out1, out2, out3); + HORIZ_6TAP_8WID_4VECS_FILT(src4, src5, src6, src7, mask0, mask1, mask2, + filt0, filt1, filt2, out4, out5, out6, out7); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SRARI_H4_SH(out4, out5, out6, out7, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out4, out5, out6, out7, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST_UB(out, dst); + dst += dst_stride; + out = PCKEV_XORI128_UB(out2, out3); + ST_UB(out, dst); + dst += dst_stride; + out = PCKEV_XORI128_UB(out4, out5); + ST_UB(out, dst); + dst += dst_stride; + out = PCKEV_XORI128_UB(out6, out7); + ST_UB(out, dst); + dst += dst_stride; + } +} + +void ff_put_vp8_epel4_v6_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r, src65_r; + v16i8 src87_r, src2110, src4332, src6554, src8776, filt0, filt1, filt2; + v16u8 out; + v8i16 filt, out10, out32; + + src -= (2 * src_stride); + + filt = LD_SH(filter); + SPLATI_H3_SB(filt, 0, 1, 2, filt0, filt1, filt2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, src10_r, src21_r, + src32_r, src43_r); + ILVR_D2_SB(src21_r, src10_r, src43_r, src32_r, src2110, src4332); + XORI_B2_128_SB(src2110, src4332); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src5, src6, src7, src8); + src += (4 * src_stride); + + ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, src54_r, + src65_r, src76_r, src87_r); + ILVR_D2_SB(src65_r, src54_r, src87_r, src76_r, src6554, src8776); + XORI_B2_128_SB(src6554, src8776); + out10 = DPADD_SH3_SH(src2110, src4332, src6554, filt0, filt1, filt2); + out32 = DPADD_SH3_SH(src4332, src6554, src8776, filt0, filt1, filt2); + SRARI_H2_SH(out10, out32, 7); + SAT_SH2_SH(out10, out32, 7); + out = PCKEV_XORI128_UB(out10, out32); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + + src2110 = src6554; + src4332 = src8776; + src4 = src8; + } +} + +void ff_put_vp8_epel8_v6_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src7, src8, src9, src10; + v16i8 src10_r, src32_r, src76_r, src98_r, src21_r, src43_r, src87_r; + v16i8 src109_r, filt0, filt1, filt2; + v16u8 tmp0, tmp1; + v8i16 filt, out0_r, out1_r, out2_r, out3_r; + + src -= (2 * src_stride); + + filt = LD_SH(filter); + SPLATI_H3_SB(filt, 0, 1, 2, filt0, filt1, filt2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + ILVR_B4_SB(src1, src0, src3, src2, src2, src1, src4, src3, + src10_r, src32_r, src21_r, src43_r); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + XORI_B4_128_SB(src7, src8, src9, src10); + src += (4 * src_stride); + + ILVR_B4_SB(src7, src4, src8, src7, src9, src8, src10, src9, src76_r, + src87_r, src98_r, src109_r); + out0_r = DPADD_SH3_SH(src10_r, src32_r, src76_r, filt0, filt1, filt2); + out1_r = DPADD_SH3_SH(src21_r, src43_r, src87_r, filt0, filt1, filt2); + out2_r = DPADD_SH3_SH(src32_r, src76_r, src98_r, filt0, filt1, filt2); + out3_r = DPADD_SH3_SH(src43_r, src87_r, src109_r, filt0, filt1, filt2); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + tmp0 = PCKEV_XORI128_UB(out0_r, out1_r); + tmp1 = PCKEV_XORI128_UB(out2_r, out3_r); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src76_r; + src32_r = src98_r; + src21_r = src87_r; + src43_r = src109_r; + src4 = src10; + } +} + +void ff_put_vp8_epel16_v6_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r, src65_r; + v16i8 src87_r, src10_l, src32_l, src54_l, src76_l, src21_l, src43_l; + v16i8 src65_l, src87_l, filt0, filt1, filt2; + v16u8 tmp0, tmp1, tmp2, tmp3; + v8i16 out0_r, out1_r, out2_r, out3_r, out0_l, out1_l, out2_l, out3_l, filt; + + src -= (2 * src_stride); + + filt = LD_SH(filter); + SPLATI_H3_SB(filt, 0, 1, 2, filt0, filt1, filt2); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + ILVR_B4_SB(src1, src0, src3, src2, src4, src3, src2, src1, src10_r, + src32_r, src43_r, src21_r); + ILVL_B4_SB(src1, src0, src3, src2, src4, src3, src2, src1, src10_l, + src32_l, src43_l, src21_l); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src5, src6, src7, src8); + src += (4 * src_stride); + + XORI_B4_128_SB(src5, src6, src7, src8); + ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, src54_r, + src65_r, src76_r, src87_r); + ILVL_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, src54_l, + src65_l, src76_l, src87_l); + out0_r = DPADD_SH3_SH(src10_r, src32_r, src54_r, filt0, filt1, + filt2); + out1_r = DPADD_SH3_SH(src21_r, src43_r, src65_r, filt0, filt1, + filt2); + out2_r = DPADD_SH3_SH(src32_r, src54_r, src76_r, filt0, filt1, + filt2); + out3_r = DPADD_SH3_SH(src43_r, src65_r, src87_r, filt0, filt1, + filt2); + out0_l = DPADD_SH3_SH(src10_l, src32_l, src54_l, filt0, filt1, + filt2); + out1_l = DPADD_SH3_SH(src21_l, src43_l, src65_l, filt0, filt1, + filt2); + out2_l = DPADD_SH3_SH(src32_l, src54_l, src76_l, filt0, filt1, + filt2); + out3_l = DPADD_SH3_SH(src43_l, src65_l, src87_l, filt0, filt1, + filt2); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SRARI_H4_SH(out0_l, out1_l, out2_l, out3_l, 7); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SAT_SH4_SH(out0_l, out1_l, out2_l, out3_l, 7); + PCKEV_B4_UB(out0_l, out0_r, out1_l, out1_r, out2_l, out2_r, out3_l, + out3_r, tmp0, tmp1, tmp2, tmp3); + XORI_B4_128_UB(tmp0, tmp1, tmp2, tmp3); + ST_UB4(tmp0, tmp1, tmp2, tmp3, dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src54_r; + src32_r = src76_r; + src21_r = src65_r; + src43_r = src87_r; + src10_l = src54_l; + src32_l = src76_l; + src21_l = src65_l; + src43_l = src87_l; + src4 = src8; + } +} + +void ff_put_vp8_epel4_h6v6_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter_horiz = subpel_filters_msa[mx - 1]; + const int8_t *filter_vert = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 filt_hz0, filt_hz1, filt_hz2; + v16u8 mask0, mask1, mask2, out; + v8i16 tmp0, tmp1; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6; + v8i16 hz_out7, filt, filt_vt0, filt_vt1, filt_vt2, out0, out1, out2, out3; + + mask0 = LD_UB(&mc_filt_mask_arr[16]); + src -= (2 + 2 * src_stride); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + SPLATI_H3_SB(filt, 0, 1, 2, filt_hz0, filt_hz1, filt_hz2); + + filt = LD_SH(filter_vert); + SPLATI_H3_SH(filt, 0, 1, 2, filt_vt0, filt_vt1, filt_vt2); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + hz_out0 = HORIZ_6TAP_FILT(src0, src1, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + hz_out2 = HORIZ_6TAP_FILT(src2, src3, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + hz_out1 = (v8i16) __msa_sldi_b((v16i8) hz_out2, (v16i8) hz_out0, 8); + hz_out3 = HORIZ_6TAP_FILT(src3, src4, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + ILVEV_B2_SH(hz_out0, hz_out1, hz_out2, hz_out3, out0, out1); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB2(src, src_stride, src5, src6); + src += (2 * src_stride); + + XORI_B2_128_SB(src5, src6); + hz_out5 = HORIZ_6TAP_FILT(src5, src6, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + hz_out4 = (v8i16) __msa_sldi_b((v16i8) hz_out5, (v16i8) hz_out3, 8); + + LD_SB2(src, src_stride, src7, src8); + src += (2 * src_stride); + + XORI_B2_128_SB(src7, src8); + hz_out7 = HORIZ_6TAP_FILT(src7, src8, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + hz_out6 = (v8i16) __msa_sldi_b((v16i8) hz_out7, (v16i8) hz_out5, 8); + + out2 = (v8i16) __msa_ilvev_b((v16i8) hz_out5, (v16i8) hz_out4); + tmp0 = DPADD_SH3_SH(out0, out1, out2, filt_vt0, filt_vt1, filt_vt2); + + out3 = (v8i16) __msa_ilvev_b((v16i8) hz_out7, (v16i8) hz_out6); + tmp1 = DPADD_SH3_SH(out1, out2, out3, filt_vt0, filt_vt1, filt_vt2); + + SRARI_H2_SH(tmp0, tmp1, 7); + SAT_SH2_SH(tmp0, tmp1, 7); + out = PCKEV_XORI128_UB(tmp0, tmp1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + + hz_out3 = hz_out7; + out0 = out2; + out1 = out3; + } +} + +void ff_put_vp8_epel8_h6v6_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter_horiz = subpel_filters_msa[mx - 1]; + const int8_t *filter_vert = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 filt_hz0, filt_hz1, filt_hz2; + v16u8 mask0, mask1, mask2, vec0, vec1; + v8i16 filt, filt_vt0, filt_vt1, filt_vt2; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6; + v8i16 hz_out7, hz_out8, out0, out1, out2, out3, out4, out5, out6, out7; + v8i16 tmp0, tmp1, tmp2, tmp3; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= (2 + 2 * src_stride); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + SPLATI_H3_SB(filt, 0, 1, 2, filt_hz0, filt_hz1, filt_hz2); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + hz_out0 = HORIZ_6TAP_FILT(src0, src0, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + hz_out1 = HORIZ_6TAP_FILT(src1, src1, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + hz_out2 = HORIZ_6TAP_FILT(src2, src2, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + hz_out3 = HORIZ_6TAP_FILT(src3, src3, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + hz_out4 = HORIZ_6TAP_FILT(src4, src4, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + + filt = LD_SH(filter_vert); + SPLATI_H3_SH(filt, 0, 1, 2, filt_vt0, filt_vt1, filt_vt2); + + ILVEV_B2_SH(hz_out0, hz_out1, hz_out2, hz_out3, out0, out1); + ILVEV_B2_SH(hz_out1, hz_out2, hz_out3, hz_out4, out3, out4); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src5, src6, src7, src8); + src += (4 * src_stride); + + XORI_B4_128_SB(src5, src6, src7, src8); + hz_out5 = HORIZ_6TAP_FILT(src5, src5, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + out2 = (v8i16) __msa_ilvev_b((v16i8) hz_out5, (v16i8) hz_out4); + tmp0 = DPADD_SH3_SH(out0, out1, out2, filt_vt0, filt_vt1, filt_vt2); + + hz_out6 = HORIZ_6TAP_FILT(src6, src6, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + out5 = (v8i16) __msa_ilvev_b((v16i8) hz_out6, (v16i8) hz_out5); + tmp1 = DPADD_SH3_SH(out3, out4, out5, filt_vt0, filt_vt1, filt_vt2); + + hz_out7 = HORIZ_6TAP_FILT(src7, src7, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + out7 = (v8i16) __msa_ilvev_b((v16i8) hz_out7, (v16i8) hz_out6); + tmp2 = DPADD_SH3_SH(out1, out2, out7, filt_vt0, filt_vt1, filt_vt2); + + hz_out8 = HORIZ_6TAP_FILT(src8, src8, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + out6 = (v8i16) __msa_ilvev_b((v16i8) hz_out8, (v16i8) hz_out7); + tmp3 = DPADD_SH3_SH(out4, out5, out6, filt_vt0, filt_vt1, filt_vt2); + + SRARI_H4_SH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_SH4_SH(tmp0, tmp1, tmp2, tmp3, 7); + vec0 = PCKEV_XORI128_UB(tmp0, tmp1); + vec1 = PCKEV_XORI128_UB(tmp2, tmp3); + ST8x4_UB(vec0, vec1, dst, dst_stride); + dst += (4 * dst_stride); + + hz_out4 = hz_out8; + out0 = out2; + out1 = out7; + out3 = out5; + out4 = out6; + } +} + + +void ff_put_vp8_epel16_h6v6_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + ff_put_vp8_epel8_h6v6_msa(dst, dst_stride, src, src_stride, height, + mx, my); + + src += 8; + dst += 8; + } +} + +static void common_hz_4t_4x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, filt0, filt1, mask0, mask1; + v8i16 filt, out0, out1; + v16u8 out; + + mask0 = LD_SB(&mc_filt_mask_arr[16]); + src -= 1; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_4TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, + filt0, filt1, out0, out1); + SRARI_H2_SH(out0, out1, 7); + SAT_SH2_SH(out0, out1, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); +} + +static void common_hz_4t_4x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, filt0, filt1, mask0, mask1; + v16u8 out; + v8i16 filt, out0, out1, out2, out3; + + mask0 = LD_SB(&mc_filt_mask_arr[16]); + src -= 1; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_4TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, + filt0, filt1, out0, out1); + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_4TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, + filt0, filt1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + out = PCKEV_XORI128_UB(out2, out3); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); +} + +static void common_hz_4t_4x16_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, src4, src5, src6, src7; + v16i8 filt0, filt1, mask0, mask1; + v16u8 out; + v8i16 filt, out0, out1, out2, out3; + + mask0 = LD_SB(&mc_filt_mask_arr[16]); + src -= 1; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); + HORIZ_4TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, + filt0, filt1, out0, out1); + HORIZ_4TAP_4WID_4VECS_FILT(src4, src5, src6, src7, mask0, mask1, + filt0, filt1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + out = PCKEV_XORI128_UB(out2, out3); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); + HORIZ_4TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, + filt0, filt1, out0, out1); + HORIZ_4TAP_4WID_4VECS_FILT(src4, src5, src6, src7, mask0, mask1, + filt0, filt1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + out = PCKEV_XORI128_UB(out2, out3); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); +} + +void ff_put_vp8_epel4_h4_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = subpel_filters_msa[mx - 1]; + + if (4 == height) { + common_hz_4t_4x4_msa(src, src_stride, dst, dst_stride, filter); + } else if (8 == height) { + common_hz_4t_4x8_msa(src, src_stride, dst, dst_stride, filter); + } else if (16 == height) { + common_hz_4t_4x16_msa(src, src_stride, dst, dst_stride, filter); + } +} + +void ff_put_vp8_epel8_h4_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = subpel_filters_msa[mx - 1]; + v16i8 src0, src1, src2, src3, filt0, filt1, mask0, mask1; + v16u8 tmp0, tmp1; + v8i16 filt, out0, out1, out2, out3; + + mask0 = LD_SB(&mc_filt_mask_arr[0]); + src -= 1; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_4TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, filt0, + filt1, out0, out1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + tmp0 = PCKEV_XORI128_UB(out0, out1); + tmp1 = PCKEV_XORI128_UB(out2, out3); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +void ff_put_vp8_epel16_h4_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = subpel_filters_msa[mx - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7; + v16i8 filt0, filt1, mask0, mask1; + v8i16 filt, out0, out1, out2, out3, out4, out5, out6, out7; + v16u8 out; + + mask0 = LD_SB(&mc_filt_mask_arr[0]); + src -= 1; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + mask1 = mask0 + 2; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src2, src4, src6); + LD_SB4(src + 8, src_stride, src1, src3, src5, src7); + src += (4 * src_stride); + + XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); + HORIZ_4TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, filt0, + filt1, out0, out1, out2, out3); + HORIZ_4TAP_8WID_4VECS_FILT(src4, src5, src6, src7, mask0, mask1, filt0, + filt1, out4, out5, out6, out7); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SRARI_H4_SH(out4, out5, out6, out7, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out4, out5, out6, out7, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST_UB(out, dst); + dst += dst_stride; + out = PCKEV_XORI128_UB(out2, out3); + ST_UB(out, dst); + dst += dst_stride; + out = PCKEV_XORI128_UB(out4, out5); + ST_UB(out, dst); + dst += dst_stride; + out = PCKEV_XORI128_UB(out6, out7); + ST_UB(out, dst); + dst += dst_stride; + } +} + +void ff_put_vp8_epel4_v4_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5; + v16i8 src10_r, src32_r, src54_r, src21_r, src43_r, src65_r; + v16i8 src2110, src4332, filt0, filt1; + v8i16 filt, out10, out32; + v16u8 out; + + src -= src_stride; + + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); + + src2110 = (v16i8) __msa_ilvr_d((v2i64) src21_r, (v2i64) src10_r); + src2110 = (v16i8) __msa_xori_b((v16u8) src2110, 128); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB3(src, src_stride, src3, src4, src5); + src += (3 * src_stride); + ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); + src4332 = (v16i8) __msa_ilvr_d((v2i64) src43_r, (v2i64) src32_r); + src4332 = (v16i8) __msa_xori_b((v16u8) src4332, 128); + out10 = FILT_4TAP_DPADD_S_H(src2110, src4332, filt0, filt1); + + src2 = LD_SB(src); + src += (src_stride); + ILVR_B2_SB(src5, src4, src2, src5, src54_r, src65_r); + src2110 = (v16i8) __msa_ilvr_d((v2i64) src65_r, (v2i64) src54_r); + src2110 = (v16i8) __msa_xori_b((v16u8) src2110, 128); + out32 = FILT_4TAP_DPADD_S_H(src4332, src2110, filt0, filt1); + SRARI_H2_SH(out10, out32, 7); + SAT_SH2_SH(out10, out32, 7); + out = PCKEV_XORI128_UB(out10, out32); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +void ff_put_vp8_epel8_v4_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src7, src8, src9, src10; + v16i8 src10_r, src72_r, src98_r, src21_r, src87_r, src109_r, filt0, filt1; + v16u8 tmp0, tmp1; + v8i16 filt, out0_r, out1_r, out2_r, out3_r; + + src -= src_stride; + + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + src += (4 * src_stride); + + XORI_B4_128_SB(src7, src8, src9, src10); + ILVR_B4_SB(src7, src2, src8, src7, src9, src8, src10, src9, + src72_r, src87_r, src98_r, src109_r); + out0_r = FILT_4TAP_DPADD_S_H(src10_r, src72_r, filt0, filt1); + out1_r = FILT_4TAP_DPADD_S_H(src21_r, src87_r, filt0, filt1); + out2_r = FILT_4TAP_DPADD_S_H(src72_r, src98_r, filt0, filt1); + out3_r = FILT_4TAP_DPADD_S_H(src87_r, src109_r, filt0, filt1); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + tmp0 = PCKEV_XORI128_UB(out0_r, out1_r); + tmp1 = PCKEV_XORI128_UB(out2_r, out3_r); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src98_r; + src21_r = src109_r; + src2 = src10; + } +} + +void ff_put_vp8_epel16_v4_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6; + v16i8 src10_r, src32_r, src54_r, src21_r, src43_r, src65_r, src10_l; + v16i8 src32_l, src54_l, src21_l, src43_l, src65_l, filt0, filt1; + v16u8 tmp0, tmp1, tmp2, tmp3; + v8i16 filt, out0_r, out1_r, out2_r, out3_r, out0_l, out1_l, out2_l, out3_l; + + src -= src_stride; + + filt = LD_SH(filter); + SPLATI_H2_SB(filt, 0, 1, filt0, filt1); + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); + ILVL_B2_SB(src1, src0, src2, src1, src10_l, src21_l); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src3, src4, src5, src6); + src += (4 * src_stride); + + XORI_B4_128_SB(src3, src4, src5, src6); + ILVR_B4_SB(src3, src2, src4, src3, src5, src4, src6, src5, + src32_r, src43_r, src54_r, src65_r); + ILVL_B4_SB(src3, src2, src4, src3, src5, src4, src6, src5, + src32_l, src43_l, src54_l, src65_l); + out0_r = FILT_4TAP_DPADD_S_H(src10_r, src32_r, filt0, filt1); + out1_r = FILT_4TAP_DPADD_S_H(src21_r, src43_r, filt0, filt1); + out2_r = FILT_4TAP_DPADD_S_H(src32_r, src54_r, filt0, filt1); + out3_r = FILT_4TAP_DPADD_S_H(src43_r, src65_r, filt0, filt1); + out0_l = FILT_4TAP_DPADD_S_H(src10_l, src32_l, filt0, filt1); + out1_l = FILT_4TAP_DPADD_S_H(src21_l, src43_l, filt0, filt1); + out2_l = FILT_4TAP_DPADD_S_H(src32_l, src54_l, filt0, filt1); + out3_l = FILT_4TAP_DPADD_S_H(src43_l, src65_l, filt0, filt1); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SRARI_H4_SH(out0_l, out1_l, out2_l, out3_l, 7); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SAT_SH4_SH(out0_l, out1_l, out2_l, out3_l, 7); + PCKEV_B4_UB(out0_l, out0_r, out1_l, out1_r, out2_l, out2_r, out3_l, + out3_r, tmp0, tmp1, tmp2, tmp3); + XORI_B4_128_UB(tmp0, tmp1, tmp2, tmp3); + ST_UB4(tmp0, tmp1, tmp2, tmp3, dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src54_r; + src21_r = src65_r; + src10_l = src54_l; + src21_l = src65_l; + src2 = src6; + } +} + +void ff_put_vp8_epel4_h4v4_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter_horiz = subpel_filters_msa[mx - 1]; + const int8_t *filter_vert = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, filt_hz0, filt_hz1; + v16u8 mask0, mask1, out; + v8i16 filt, filt_vt0, filt_vt1, tmp0, tmp1, vec0, vec1, vec2; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5; + + mask0 = LD_UB(&mc_filt_mask_arr[16]); + src -= (1 + 1 * src_stride); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + SPLATI_H2_SB(filt, 0, 1, filt_hz0, filt_hz1); + + mask1 = mask0 + 2; + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + hz_out0 = HORIZ_4TAP_FILT(src0, src1, mask0, mask1, filt_hz0, filt_hz1); + hz_out1 = HORIZ_4TAP_FILT(src1, src2, mask0, mask1, filt_hz0, filt_hz1); + vec0 = (v8i16) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + + filt = LD_SH(filter_vert); + SPLATI_H2_SH(filt, 0, 1, filt_vt0, filt_vt1); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src3, src4, src5, src6); + src += (4 * src_stride); + + XORI_B2_128_SB(src3, src4); + hz_out3 = HORIZ_4TAP_FILT(src3, src4, mask0, mask1, filt_hz0, filt_hz1); + hz_out2 = (v8i16) __msa_sldi_b((v16i8) hz_out3, (v16i8) hz_out1, 8); + vec1 = (v8i16) __msa_ilvev_b((v16i8) hz_out3, (v16i8) hz_out2); + tmp0 = FILT_4TAP_DPADD_S_H(vec0, vec1, filt_vt0, filt_vt1); + + XORI_B2_128_SB(src5, src6); + hz_out5 = HORIZ_4TAP_FILT(src5, src6, mask0, mask1, filt_hz0, filt_hz1); + hz_out4 = (v8i16) __msa_sldi_b((v16i8) hz_out5, (v16i8) hz_out3, 8); + vec2 = (v8i16) __msa_ilvev_b((v16i8) hz_out5, (v16i8) hz_out4); + tmp1 = FILT_4TAP_DPADD_S_H(vec1, vec2, filt_vt0, filt_vt1); + + SRARI_H2_SH(tmp0, tmp1, 7); + SAT_SH2_SH(tmp0, tmp1, 7); + out = PCKEV_XORI128_UB(tmp0, tmp1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + + hz_out1 = hz_out5; + vec0 = vec2; + } +} + +void ff_put_vp8_epel8_h4v4_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter_horiz = subpel_filters_msa[mx - 1]; + const int8_t *filter_vert = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, filt_hz0, filt_hz1; + v16u8 mask0, mask1, out0, out1; + v8i16 filt, filt_vt0, filt_vt1, tmp0, tmp1, tmp2, tmp3; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 vec0, vec1, vec2, vec3, vec4; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= (1 + 1 * src_stride); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + SPLATI_H2_SB(filt, 0, 1, filt_hz0, filt_hz1); + + mask1 = mask0 + 2; + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + hz_out0 = HORIZ_4TAP_FILT(src0, src0, mask0, mask1, filt_hz0, filt_hz1); + hz_out1 = HORIZ_4TAP_FILT(src1, src1, mask0, mask1, filt_hz0, filt_hz1); + hz_out2 = HORIZ_4TAP_FILT(src2, src2, mask0, mask1, filt_hz0, filt_hz1); + ILVEV_B2_SH(hz_out0, hz_out1, hz_out1, hz_out2, vec0, vec2); + + filt = LD_SH(filter_vert); + SPLATI_H2_SH(filt, 0, 1, filt_vt0, filt_vt1); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src3, src4, src5, src6); + src += (4 * src_stride); + + XORI_B4_128_SB(src3, src4, src5, src6); + hz_out3 = HORIZ_4TAP_FILT(src3, src3, mask0, mask1, filt_hz0, filt_hz1); + vec1 = (v8i16) __msa_ilvev_b((v16i8) hz_out3, (v16i8) hz_out2); + tmp0 = FILT_4TAP_DPADD_S_H(vec0, vec1, filt_vt0, filt_vt1); + + hz_out0 = HORIZ_4TAP_FILT(src4, src4, mask0, mask1, filt_hz0, filt_hz1); + vec3 = (v8i16) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out3); + tmp1 = FILT_4TAP_DPADD_S_H(vec2, vec3, filt_vt0, filt_vt1); + + hz_out1 = HORIZ_4TAP_FILT(src5, src5, mask0, mask1, filt_hz0, filt_hz1); + vec4 = (v8i16) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp2 = FILT_4TAP_DPADD_S_H(vec1, vec4, filt_vt0, filt_vt1); + + hz_out2 = HORIZ_4TAP_FILT(src6, src6, mask0, mask1, filt_hz0, filt_hz1); + ILVEV_B2_SH(hz_out3, hz_out0, hz_out1, hz_out2, vec0, vec1); + tmp3 = FILT_4TAP_DPADD_S_H(vec0, vec1, filt_vt0, filt_vt1); + + SRARI_H4_SH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_SH4_SH(tmp0, tmp1, tmp2, tmp3, 7); + out0 = PCKEV_XORI128_UB(tmp0, tmp1); + out1 = PCKEV_XORI128_UB(tmp2, tmp3); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + + vec0 = vec4; + vec2 = vec1; + } +} + +void ff_put_vp8_epel16_h4v4_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + ff_put_vp8_epel8_h4v4_msa(dst, dst_stride, src, src_stride, height, + mx, my); + + src += 8; + dst += 8; + } +} + +void ff_put_vp8_epel4_h6v4_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter_horiz = subpel_filters_msa[mx - 1]; + const int8_t *filter_vert = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6; + v16i8 filt_hz0, filt_hz1, filt_hz2; + v16u8 res0, res1, mask0, mask1, mask2; + v8i16 filt, filt_vt0, filt_vt1, tmp0, tmp1, vec0, vec1, vec2; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5; + + mask0 = LD_UB(&mc_filt_mask_arr[16]); + src -= (2 + 1 * src_stride); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + SPLATI_H3_SB(filt, 0, 1, 2, filt_hz0, filt_hz1, filt_hz2); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + hz_out0 = HORIZ_6TAP_FILT(src0, src1, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + hz_out1 = HORIZ_6TAP_FILT(src1, src2, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + vec0 = (v8i16) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + + filt = LD_SH(filter_vert); + SPLATI_H2_SH(filt, 0, 1, filt_vt0, filt_vt1); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src3, src4, src5, src6); + src += (4 * src_stride); + + XORI_B4_128_SB(src3, src4, src5, src6); + hz_out3 = HORIZ_6TAP_FILT(src3, src4, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + hz_out2 = (v8i16) __msa_sldi_b((v16i8) hz_out3, (v16i8) hz_out1, 8); + vec1 = (v8i16) __msa_ilvev_b((v16i8) hz_out3, (v16i8) hz_out2); + tmp0 = FILT_4TAP_DPADD_S_H(vec0, vec1, filt_vt0, filt_vt1); + + hz_out5 = HORIZ_6TAP_FILT(src5, src6, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + hz_out4 = (v8i16) __msa_sldi_b((v16i8) hz_out5, (v16i8) hz_out3, 8); + vec2 = (v8i16) __msa_ilvev_b((v16i8) hz_out5, (v16i8) hz_out4); + tmp1 = FILT_4TAP_DPADD_S_H(vec1, vec2, filt_vt0, filt_vt1); + + SRARI_H2_SH(tmp0, tmp1, 7); + SAT_SH2_SH(tmp0, tmp1, 7); + PCKEV_B2_UB(tmp0, tmp0, tmp1, tmp1, res0, res1); + XORI_B2_128_UB(res0, res1); + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + + hz_out1 = hz_out5; + vec0 = vec2; + } +} + +void ff_put_vp8_epel8_h6v4_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter_horiz = subpel_filters_msa[mx - 1]; + const int8_t *filter_vert = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6; + v16i8 filt_hz0, filt_hz1, filt_hz2, mask0, mask1, mask2; + v8i16 filt, filt_vt0, filt_vt1, hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 tmp0, tmp1, tmp2, tmp3, vec0, vec1, vec2, vec3; + v16u8 out0, out1; + + mask0 = LD_SB(&mc_filt_mask_arr[0]); + src -= (2 + src_stride); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + SPLATI_H3_SB(filt, 0, 1, 2, filt_hz0, filt_hz1, filt_hz2); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + + LD_SB3(src, src_stride, src0, src1, src2); + src += (3 * src_stride); + + XORI_B3_128_SB(src0, src1, src2); + hz_out0 = HORIZ_6TAP_FILT(src0, src0, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + hz_out1 = HORIZ_6TAP_FILT(src1, src1, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + hz_out2 = HORIZ_6TAP_FILT(src2, src2, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + ILVEV_B2_SH(hz_out0, hz_out1, hz_out1, hz_out2, vec0, vec2); + + filt = LD_SH(filter_vert); + SPLATI_H2_SH(filt, 0, 1, filt_vt0, filt_vt1); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src3, src4, src5, src6); + src += (4 * src_stride); + + XORI_B4_128_SB(src3, src4, src5, src6); + + hz_out3 = HORIZ_6TAP_FILT(src3, src3, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + vec1 = (v8i16) __msa_ilvev_b((v16i8) hz_out3, (v16i8) hz_out2); + tmp0 = FILT_4TAP_DPADD_S_H(vec0, vec1, filt_vt0, filt_vt1); + + hz_out0 = HORIZ_6TAP_FILT(src4, src4, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + vec3 = (v8i16) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out3); + tmp1 = FILT_4TAP_DPADD_S_H(vec2, vec3, filt_vt0, filt_vt1); + + hz_out1 = HORIZ_6TAP_FILT(src5, src5, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + vec0 = (v8i16) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp2 = FILT_4TAP_DPADD_S_H(vec1, vec0, filt_vt0, filt_vt1); + + hz_out2 = HORIZ_6TAP_FILT(src6, src6, mask0, mask1, mask2, filt_hz0, + filt_hz1, filt_hz2); + ILVEV_B2_SH(hz_out3, hz_out0, hz_out1, hz_out2, vec1, vec2); + tmp3 = FILT_4TAP_DPADD_S_H(vec1, vec2, filt_vt0, filt_vt1); + + SRARI_H4_SH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_SH4_SH(tmp0, tmp1, tmp2, tmp3, 7); + out0 = PCKEV_XORI128_UB(tmp0, tmp1); + out1 = PCKEV_XORI128_UB(tmp2, tmp3); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +void ff_put_vp8_epel16_h6v4_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + ff_put_vp8_epel8_h6v4_msa(dst, dst_stride, src, src_stride, height, + mx, my); + + src += 8; + dst += 8; + } +} + +void ff_put_vp8_epel4_h4v6_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter_horiz = subpel_filters_msa[mx - 1]; + const int8_t *filter_vert = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 filt_hz0, filt_hz1, mask0, mask1; + v16u8 out; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6; + v8i16 hz_out7, tmp0, tmp1, out0, out1, out2, out3; + v8i16 filt, filt_vt0, filt_vt1, filt_vt2; + + mask0 = LD_SB(&mc_filt_mask_arr[16]); + + src -= (1 + 2 * src_stride); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + SPLATI_H2_SB(filt, 0, 1, filt_hz0, filt_hz1); + + mask1 = mask0 + 2; + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + hz_out0 = HORIZ_4TAP_FILT(src0, src1, mask0, mask1, filt_hz0, filt_hz1); + hz_out2 = HORIZ_4TAP_FILT(src2, src3, mask0, mask1, filt_hz0, filt_hz1); + hz_out3 = HORIZ_4TAP_FILT(src3, src4, mask0, mask1, filt_hz0, filt_hz1); + hz_out1 = (v8i16) __msa_sldi_b((v16i8) hz_out2, (v16i8) hz_out0, 8); + ILVEV_B2_SH(hz_out0, hz_out1, hz_out2, hz_out3, out0, out1); + + filt = LD_SH(filter_vert); + SPLATI_H3_SH(filt, 0, 1, 2, filt_vt0, filt_vt1, filt_vt2); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src5, src6, src7, src8); + XORI_B4_128_SB(src5, src6, src7, src8); + src += (4 * src_stride); + + hz_out5 = HORIZ_4TAP_FILT(src5, src6, mask0, mask1, filt_hz0, filt_hz1); + hz_out4 = (v8i16) __msa_sldi_b((v16i8) hz_out5, (v16i8) hz_out3, 8); + out2 = (v8i16) __msa_ilvev_b((v16i8) hz_out5, (v16i8) hz_out4); + tmp0 = DPADD_SH3_SH(out0, out1, out2, filt_vt0, filt_vt1, filt_vt2); + + hz_out7 = HORIZ_4TAP_FILT(src7, src8, mask0, mask1, filt_hz0, filt_hz1); + hz_out6 = (v8i16) __msa_sldi_b((v16i8) hz_out7, (v16i8) hz_out5, 8); + out3 = (v8i16) __msa_ilvev_b((v16i8) hz_out7, (v16i8) hz_out6); + tmp1 = DPADD_SH3_SH(out1, out2, out3, filt_vt0, filt_vt1, filt_vt2); + + SRARI_H2_SH(tmp0, tmp1, 7); + SAT_SH2_SH(tmp0, tmp1, 7); + out = PCKEV_XORI128_UB(tmp0, tmp1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + + hz_out3 = hz_out7; + out0 = out2; + out1 = out3; + } +} + +void ff_put_vp8_epel8_h4v6_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter_horiz = subpel_filters_msa[mx - 1]; + const int8_t *filter_vert = subpel_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 filt_hz0, filt_hz1, mask0, mask1; + v8i16 filt, filt_vt0, filt_vt1, filt_vt2, tmp0, tmp1, tmp2, tmp3; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6; + v8i16 hz_out7, hz_out8, out0, out1, out2, out3, out4, out5, out6, out7; + v16u8 vec0, vec1; + + mask0 = LD_SB(&mc_filt_mask_arr[0]); + src -= (1 + 2 * src_stride); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + SPLATI_H2_SB(filt, 0, 1, filt_hz0, filt_hz1); + + mask1 = mask0 + 2; + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + XORI_B5_128_SB(src0, src1, src2, src3, src4); + hz_out0 = HORIZ_4TAP_FILT(src0, src0, mask0, mask1, filt_hz0, filt_hz1); + hz_out1 = HORIZ_4TAP_FILT(src1, src1, mask0, mask1, filt_hz0, filt_hz1); + hz_out2 = HORIZ_4TAP_FILT(src2, src2, mask0, mask1, filt_hz0, filt_hz1); + hz_out3 = HORIZ_4TAP_FILT(src3, src3, mask0, mask1, filt_hz0, filt_hz1); + hz_out4 = HORIZ_4TAP_FILT(src4, src4, mask0, mask1, filt_hz0, filt_hz1); + ILVEV_B2_SH(hz_out0, hz_out1, hz_out2, hz_out3, out0, out1); + ILVEV_B2_SH(hz_out1, hz_out2, hz_out3, hz_out4, out3, out4); + + filt = LD_SH(filter_vert); + SPLATI_H3_SH(filt, 0, 1, 2, filt_vt0, filt_vt1, filt_vt2); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src5, src6, src7, src8); + src += (4 * src_stride); + + XORI_B4_128_SB(src5, src6, src7, src8); + + hz_out5 = HORIZ_4TAP_FILT(src5, src5, mask0, mask1, filt_hz0, filt_hz1); + out2 = (v8i16) __msa_ilvev_b((v16i8) hz_out5, (v16i8) hz_out4); + tmp0 = DPADD_SH3_SH(out0, out1, out2, filt_vt0, filt_vt1, filt_vt2); + + hz_out6 = HORIZ_4TAP_FILT(src6, src6, mask0, mask1, filt_hz0, filt_hz1); + out5 = (v8i16) __msa_ilvev_b((v16i8) hz_out6, (v16i8) hz_out5); + tmp1 = DPADD_SH3_SH(out3, out4, out5, filt_vt0, filt_vt1, filt_vt2); + + hz_out7 = HORIZ_4TAP_FILT(src7, src7, mask0, mask1, filt_hz0, filt_hz1); + out6 = (v8i16) __msa_ilvev_b((v16i8) hz_out7, (v16i8) hz_out6); + tmp2 = DPADD_SH3_SH(out1, out2, out6, filt_vt0, filt_vt1, filt_vt2); + + hz_out8 = HORIZ_4TAP_FILT(src8, src8, mask0, mask1, filt_hz0, filt_hz1); + out7 = (v8i16) __msa_ilvev_b((v16i8) hz_out8, (v16i8) hz_out7); + tmp3 = DPADD_SH3_SH(out4, out5, out7, filt_vt0, filt_vt1, filt_vt2); + + SRARI_H4_SH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_SH4_SH(tmp0, tmp1, tmp2, tmp3, 7); + vec0 = PCKEV_XORI128_UB(tmp0, tmp1); + vec1 = PCKEV_XORI128_UB(tmp2, tmp3); + ST8x4_UB(vec0, vec1, dst, dst_stride); + dst += (4 * dst_stride); + + hz_out4 = hz_out8; + out0 = out2; + out1 = out6; + out3 = out5; + out4 = out7; + } +} + +void ff_put_vp8_epel16_h4v6_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + ff_put_vp8_epel8_h4v6_msa(dst, dst_stride, src, src_stride, height, + mx, my); + + src += 8; + dst += 8; + } +} + +static void common_hz_2t_4x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, mask; + v16u8 filt0, vec0, vec1, res0, res1; + v8u16 vec2, vec3, filt; + + mask = LD_SB(&mc_filt_mask_arr[16]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB4(src, src_stride, src0, src1, src2, src3); + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt0, filt0, vec2, vec3); + SRARI_H2_UH(vec2, vec3, 7); + PCKEV_B2_UB(vec2, vec2, vec3, vec3, res0, res1); + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); +} + +static void common_hz_2t_4x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16u8 vec0, vec1, vec2, vec3, filt0; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask; + v16i8 res0, res1, res2, res3; + v8u16 vec4, vec5, vec6, vec7, filt; + + mask = LD_SB(&mc_filt_mask_arr[16]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, vec0, vec1); + VSHF_B2_UB(src4, src5, src6, src7, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec4, vec5, vec6, vec7); + SRARI_H4_UH(vec4, vec5, vec6, vec7, 7); + PCKEV_B4_SB(vec4, vec4, vec5, vec5, vec6, vec6, vec7, vec7, + res0, res1, res2, res3); + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + ST4x4_UB(res2, res3, 0, 1, 0, 1, dst, dst_stride); +} + +void ff_put_vp8_bilinear4_h_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = bilinear_filters_msa[mx - 1]; + + if (4 == height) { + common_hz_2t_4x4_msa(src, src_stride, dst, dst_stride, filter); + } else if (8 == height) { + common_hz_2t_4x8_msa(src, src_stride, dst, dst_stride, filter); + } +} + +static void common_hz_2t_8x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16u8 filt0; + v16i8 src0, src1, src2, src3, mask; + v8u16 vec0, vec1, vec2, vec3, filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB4(src, src_stride, src0, src1, src2, src3); + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec0, vec1, vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + PCKEV_B2_SB(vec1, vec0, vec3, vec2, src0, src1); + ST8x4_UB(src0, src1, dst, dst_stride); +} + +static void common_hz_2t_8x8mult_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + v16u8 filt0; + v16i8 src0, src1, src2, src3, mask, out0, out1; + v8u16 vec0, vec1, vec2, vec3, filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec0, vec1, vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + PCKEV_B2_SB(vec1, vec0, vec3, vec2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec0, vec1, vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + PCKEV_B2_SB(vec1, vec0, vec3, vec2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + + if (16 == height) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec0, vec1, vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + PCKEV_B2_SB(vec1, vec0, vec3, vec2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec0, vec1, vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + PCKEV_B2_SB(vec1, vec0, vec3, vec2, out0, out1); + ST8x4_UB(out0, out1, dst + 4 * dst_stride, dst_stride); + } +} + +void ff_put_vp8_bilinear8_h_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = bilinear_filters_msa[mx - 1]; + + if (4 == height) { + common_hz_2t_8x4_msa(src, src_stride, dst, dst_stride, filter); + } else { + common_hz_2t_8x8mult_msa(src, src_stride, dst, dst_stride, filter, + height); + } +} + +void ff_put_vp8_bilinear16_h_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = bilinear_filters_msa[mx - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask; + v16u8 filt0, vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8u16 out0, out1, out2, out3, out4, out5, out6, out7, filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + loop_cnt = (height >> 2) - 1; + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB4(src, src_stride, src0, src2, src4, src6); + LD_SB4(src + 8, src_stride, src1, src3, src5, src7); + src += (4 * src_stride); + + VSHF_B2_UB(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UB(src2, src2, src3, src3, mask, mask, vec2, vec3); + VSHF_B2_UB(src4, src4, src5, src5, mask, mask, vec4, vec5); + VSHF_B2_UB(src6, src6, src7, src7, mask, mask, vec6, vec7); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + out0, out1, out2, out3); + DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, + out4, out5, out6, out7); + SRARI_H4_UH(out0, out1, out2, out3, 7); + SRARI_H4_UH(out4, out5, out6, out7, 7); + PCKEV_ST_SB(out0, out1, dst); + dst += dst_stride; + PCKEV_ST_SB(out2, out3, dst); + dst += dst_stride; + PCKEV_ST_SB(out4, out5, dst); + dst += dst_stride; + PCKEV_ST_SB(out6, out7, dst); + dst += dst_stride; + + for (; loop_cnt--;) { + LD_SB4(src, src_stride, src0, src2, src4, src6); + LD_SB4(src + 8, src_stride, src1, src3, src5, src7); + src += (4 * src_stride); + + VSHF_B2_UB(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UB(src2, src2, src3, src3, mask, mask, vec2, vec3); + VSHF_B2_UB(src4, src4, src5, src5, mask, mask, vec4, vec5); + VSHF_B2_UB(src6, src6, src7, src7, mask, mask, vec6, vec7); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + out0, out1, out2, out3); + DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, + out4, out5, out6, out7); + SRARI_H4_UH(out0, out1, out2, out3, 7); + SRARI_H4_UH(out4, out5, out6, out7, 7); + PCKEV_ST_SB(out0, out1, dst); + dst += dst_stride; + PCKEV_ST_SB(out2, out3, dst); + dst += dst_stride; + PCKEV_ST_SB(out4, out5, dst); + dst += dst_stride; + PCKEV_ST_SB(out6, out7, dst); + dst += dst_stride; + } +} + +static void common_vt_2t_4x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, src4; + v16i8 src10_r, src32_r, src21_r, src43_r, src2110, src4332; + v16u8 filt0; + v8i16 filt; + v8u16 tmp0, tmp1; + + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + ILVR_D2_SB(src21_r, src10_r, src43_r, src32_r, src2110, src4332); + DOTP_UB2_UH(src2110, src4332, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + src2110 = __msa_pckev_b((v16i8) tmp1, (v16i8) tmp0); + ST4x4_UB(src2110, src2110, 0, 1, 2, 3, dst, dst_stride); +} + +static void common_vt_2t_4x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r; + v16i8 src65_r, src87_r, src2110, src4332, src6554, src8776; + v8u16 tmp0, tmp1, tmp2, tmp3; + v16u8 filt0; + v8i16 filt; + + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + + src8 = LD_SB(src); + src += src_stride; + + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, src10_r, src21_r, + src32_r, src43_r); + ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, src54_r, src65_r, + src76_r, src87_r); + ILVR_D4_SB(src21_r, src10_r, src43_r, src32_r, src65_r, src54_r, + src87_r, src76_r, src2110, src4332, src6554, src8776); + DOTP_UB4_UH(src2110, src4332, src6554, src8776, filt0, filt0, filt0, filt0, + tmp0, tmp1, tmp2, tmp3); + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, src2110, src4332); + ST4x4_UB(src2110, src2110, 0, 1, 2, 3, dst, dst_stride); + ST4x4_UB(src4332, src4332, 0, 1, 2, 3, dst + 4 * dst_stride, dst_stride); +} + +void ff_put_vp8_bilinear4_v_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = bilinear_filters_msa[my - 1]; + + if (4 == height) { + common_vt_2t_4x4_msa(src, src_stride, dst, dst_stride, filter); + } else if (8 == height) { + common_vt_2t_4x8_msa(src, src_stride, dst, dst_stride, filter); + } +} + +static void common_vt_2t_8x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16u8 src0, src1, src2, src3, src4, vec0, vec1, vec2, vec3, filt0; + v16i8 out0, out1; + v8u16 tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + /* rearranging filter_y */ + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + LD_UB5(src, src_stride, src0, src1, src2, src3, src4); + ILVR_B2_UB(src1, src0, src2, src1, vec0, vec1); + ILVR_B2_UB(src3, src2, src4, src3, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + tmp0, tmp1, tmp2, tmp3); + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); +} + +static void common_vt_2t_8x8mult_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + uint32_t loop_cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0; + v16i8 out0, out1; + v8u16 tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + /* rearranging filter_y */ + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + src0 = LD_UB(src); + src += src_stride; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src, src_stride, src1, src2, src3, src4, src5, src6, src7, src8); + src += (8 * src_stride); + + ILVR_B4_UB(src1, src0, src2, src1, src3, src2, src4, src3, + vec0, vec1, vec2, vec3); + ILVR_B4_UB(src5, src4, src6, src5, src7, src6, src8, src7, + vec4, vec5, vec6, vec7); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + tmp0, tmp1, tmp2, tmp3); + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + + DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, + tmp0, tmp1, tmp2, tmp3); + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + + src0 = src8; + } +} + +void ff_put_vp8_bilinear8_v_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = bilinear_filters_msa[my - 1]; + + if (4 == height) { + common_vt_2t_8x4_msa(src, src_stride, dst, dst_stride, filter); + } else { + common_vt_2t_8x8mult_msa(src, src_stride, dst, dst_stride, filter, + height); + } +} + +void ff_put_vp8_bilinear16_v_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = bilinear_filters_msa[my - 1]; + v16u8 src0, src1, src2, src3, src4; + v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0; + v8u16 tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + /* rearranging filter_y */ + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + src0 = LD_UB(src); + src += src_stride; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + ILVR_B2_UB(src1, src0, src2, src1, vec0, vec2); + ILVL_B2_UB(src1, src0, src2, src1, vec1, vec3); + DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_ST_SB(tmp0, tmp1, dst); + dst += dst_stride; + + ILVR_B2_UB(src3, src2, src4, src3, vec4, vec6); + ILVL_B2_UB(src3, src2, src4, src3, vec5, vec7); + DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_ST_SB(tmp2, tmp3, dst); + dst += dst_stride; + + DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_ST_SB(tmp0, tmp1, dst); + dst += dst_stride; + + DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_ST_SB(tmp2, tmp3, dst); + dst += dst_stride; + + src0 = src4; + } +} + +static void common_hv_2ht_2vt_4x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert) +{ + v16i8 src0, src1, src2, src3, src4, mask; + v16u8 filt_vt, filt_hz, vec0, vec1, res0, res1; + v8u16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, filt, tmp0, tmp1; + + mask = LD_SB(&mc_filt_mask_arr[16]); + + /* rearranging filter */ + filt = LD_UH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h((v8i16) filt, 0); + + filt = LD_UH(filter_vert); + filt_vt = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src1, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src2, src3, mask, filt_hz, 7); + hz_out4 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + hz_out1 = (v8u16) __msa_sldi_b((v16i8) hz_out2, (v16i8) hz_out0, 8); + hz_out3 = (v8u16) __msa_pckod_d((v2i64) hz_out4, (v2i64) hz_out2); + + ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_B2_UB(tmp0, tmp0, tmp1, tmp1, res0, res1); + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); +} + +static void common_hv_2ht_2vt_4x8_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert) +{ + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, mask; + v16i8 res0, res1, res2, res3; + v16u8 filt_hz, filt_vt, vec0, vec1, vec2, vec3; + v8u16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6; + v8u16 hz_out7, hz_out8, vec4, vec5, vec6, vec7, filt; + + mask = LD_SB(&mc_filt_mask_arr[16]); + + /* rearranging filter */ + filt = LD_UH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h((v8i16) filt, 0); + + filt = LD_UH(filter_vert); + filt_vt = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + src8 = LD_SB(src); + + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src1, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src2, src3, mask, filt_hz, 7); + hz_out4 = HORIZ_2TAP_FILT_UH(src4, src5, mask, filt_hz, 7); + hz_out6 = HORIZ_2TAP_FILT_UH(src6, src7, mask, filt_hz, 7); + hz_out8 = HORIZ_2TAP_FILT_UH(src8, src8, mask, filt_hz, 7); + SLDI_B3_UH(hz_out2, hz_out4, hz_out6, hz_out0, hz_out2, hz_out4, hz_out1, + hz_out3, hz_out5, 8); + hz_out7 = (v8u16) __msa_pckod_d((v2i64) hz_out8, (v2i64) hz_out6); + + ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1); + ILVEV_B2_UB(hz_out4, hz_out5, hz_out6, hz_out7, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt_vt, filt_vt, filt_vt, filt_vt, + vec4, vec5, vec6, vec7); + SRARI_H4_UH(vec4, vec5, vec6, vec7, 7); + SAT_UH4_UH(vec4, vec5, vec6, vec7, 7); + PCKEV_B4_SB(vec4, vec4, vec5, vec5, vec6, vec6, vec7, vec7, + res0, res1, res2, res3); + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + ST4x4_UB(res2, res3, 0, 1, 0, 1, dst, dst_stride); +} + +void ff_put_vp8_bilinear4_hv_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter_horiz = bilinear_filters_msa[mx - 1]; + const int8_t *filter_vert = bilinear_filters_msa[my - 1]; + + if (4 == height) { + common_hv_2ht_2vt_4x4_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert); + } else if (8 == height) { + common_hv_2ht_2vt_4x8_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert); + } +} + +static void common_hv_2ht_2vt_8x4_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert) +{ + v16i8 src0, src1, src2, src3, src4, mask, out0, out1; + v16u8 filt_hz, filt_vt, vec0, vec1, vec2, vec3; + v8u16 hz_out0, hz_out1, tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h(filt, 0); + + filt = LD_SH(filter_vert); + filt_vt = (v16u8) __msa_splati_h(filt, 0); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, 7); + hz_out1 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp0 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, 7); + vec1 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp1 = __msa_dotp_u_h(vec1, filt_vt); + + hz_out1 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, 7); + vec2 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp2 = __msa_dotp_u_h(vec2, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + vec3 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp3 = __msa_dotp_u_h(vec3, filt_vt); + + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); +} + +static void common_hv_2ht_2vt_8x8mult_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, mask, out0, out1; + v16u8 filt_hz, filt_vt, vec0; + v8u16 hz_out0, hz_out1, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; + v8i16 filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h(filt, 0); + + filt = LD_SH(filter_vert); + filt_vt = (v16u8) __msa_splati_h(filt, 0); + + src0 = LD_SB(src); + src += src_stride; + + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, 7); + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_SB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + hz_out1 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp1 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp2 = __msa_dotp_u_h(vec0, filt_vt); + + SRARI_H2_UH(tmp1, tmp2, 7); + SAT_UH2_UH(tmp1, tmp2, 7); + + hz_out1 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp3 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + LD_SB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp4 = __msa_dotp_u_h(vec0, filt_vt); + + SRARI_H2_UH(tmp3, tmp4, 7); + SAT_UH2_UH(tmp3, tmp4, 7); + PCKEV_B2_SB(tmp2, tmp1, tmp4, tmp3, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + + hz_out1 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp5 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp6 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out1 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp7 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp8 = __msa_dotp_u_h(vec0, filt_vt); + + SRARI_H4_UH(tmp5, tmp6, tmp7, tmp8, 7); + SAT_UH4_UH(tmp5, tmp6, tmp7, tmp8, 7); + PCKEV_B2_SB(tmp6, tmp5, tmp8, tmp7, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +void ff_put_vp8_bilinear8_hv_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter_horiz = bilinear_filters_msa[mx - 1]; + const int8_t *filter_vert = bilinear_filters_msa[my - 1]; + + if (4 == height) { + common_hv_2ht_2vt_8x4_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert); + } else { + common_hv_2ht_2vt_8x8mult_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert, height); + } +} + +void ff_put_vp8_bilinear16_hv_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter_horiz = bilinear_filters_msa[mx - 1]; + const int8_t *filter_vert = bilinear_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask; + v16u8 filt_hz, filt_vt, vec0, vec1; + v8u16 tmp1, tmp2, hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h(filt, 0); + + filt = LD_SH(filter_vert); + filt_vt = (v16u8) __msa_splati_h(filt, 0); + + LD_SB2(src, 8, src0, src1); + src += src_stride; + + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src2, src4, src6); + LD_SB4(src + 8, src_stride, src1, src3, src5, src7); + src += (4 * src_stride); + + hz_out1 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, 7); + hz_out3 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp1, tmp2); + SRARI_H2_UH(tmp1, tmp2, 7); + SAT_UH2_UH(tmp1, tmp2, 7); + PCKEV_ST_SB(tmp1, tmp2, dst); + dst += dst_stride; + + hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, 7); + ILVEV_B2_UB(hz_out1, hz_out0, hz_out3, hz_out2, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp1, tmp2); + SRARI_H2_UH(tmp1, tmp2, 7); + SAT_UH2_UH(tmp1, tmp2, 7); + PCKEV_ST_SB(tmp1, tmp2, dst); + dst += dst_stride; + + hz_out1 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + hz_out3 = HORIZ_2TAP_FILT_UH(src5, src5, mask, filt_hz, 7); + ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp1, tmp2); + SRARI_H2_UH(tmp1, tmp2, 7); + SAT_UH2_UH(tmp1, tmp2, 7); + PCKEV_ST_SB(tmp1, tmp2, dst); + dst += dst_stride; + + hz_out0 = HORIZ_2TAP_FILT_UH(src6, src6, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src7, src7, mask, filt_hz, 7); + ILVEV_B2_UB(hz_out1, hz_out0, hz_out3, hz_out2, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp1, tmp2); + SRARI_H2_UH(tmp1, tmp2, 7); + SAT_UH2_UH(tmp1, tmp2, 7); + PCKEV_ST_SB(tmp1, tmp2, dst); + dst += dst_stride; + } +} + +void ff_put_vp8_pixels8_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + int32_t cnt; + uint64_t out0, out1, out2, out3, out4, out5, out6, out7; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + if (0 == height % 8) { + for (cnt = height >> 3; cnt--;) { + LD_UB8(src, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + out4 = __msa_copy_u_d((v2i64) src4, 0); + out5 = __msa_copy_u_d((v2i64) src5, 0); + out6 = __msa_copy_u_d((v2i64) src6, 0); + out7 = __msa_copy_u_d((v2i64) src7, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + SD4(out4, out5, out6, out7, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 4) { + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } + } +} + +static void copy_16multx8mult_msa(uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, int32_t width) +{ + int32_t cnt, loop_cnt; + uint8_t *src_tmp, *dst_tmp; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + for (cnt = (width >> 4); cnt--;) { + src_tmp = src; + dst_tmp = dst; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src_tmp, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src_tmp += (8 * src_stride); + + ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, + dst_tmp, dst_stride); + dst_tmp += (8 * dst_stride); + } + + src += 16; + dst += 16; + } +} + +void ff_put_vp8_pixels16_msa(uint8_t *dst, ptrdiff_t dst_stride, + uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + int32_t cnt; + v16u8 src0, src1, src2, src3; + + if (0 == height % 8) { + copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 16); + } else if (0 == height % 4) { + for (cnt = (height >> 2); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + dst += (4 * dst_stride); + } + } +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp9dsp_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp9dsp_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp9dsp_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp9dsp_init_mips.c 2015-07-27 17:20:04.000000000 +0000 @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * + * 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 "config.h" +#include "libavutil/common.h" +#include "libavcodec/vp9dsp.h" +#include "vp9dsp_mips.h" + +#if HAVE_MSA +static av_cold void vp9dsp_intrapred_init_msa(VP9DSPContext *dsp, int bpp) +{ + if (bpp == 8) { +#define init_intra_pred_msa(tx, sz) \ + dsp->intra_pred[tx][VERT_PRED] = ff_vert_##sz##_msa; \ + dsp->intra_pred[tx][HOR_PRED] = ff_hor_##sz##_msa; \ + dsp->intra_pred[tx][DC_PRED] = ff_dc_##sz##_msa; \ + dsp->intra_pred[tx][LEFT_DC_PRED] = ff_dc_left_##sz##_msa; \ + dsp->intra_pred[tx][TOP_DC_PRED] = ff_dc_top_##sz##_msa; \ + dsp->intra_pred[tx][DC_128_PRED] = ff_dc_128_##sz##_msa; \ + dsp->intra_pred[tx][DC_127_PRED] = ff_dc_127_##sz##_msa; \ + dsp->intra_pred[tx][DC_129_PRED] = ff_dc_129_##sz##_msa; \ + dsp->intra_pred[tx][TM_VP8_PRED] = ff_tm_##sz##_msa; \ + + init_intra_pred_msa(TX_16X16, 16x16); + init_intra_pred_msa(TX_32X32, 32x32); +#undef init_intra_pred_msa + +#define init_intra_pred_msa(tx, sz) \ + dsp->intra_pred[tx][DC_PRED] = ff_dc_##sz##_msa; \ + dsp->intra_pred[tx][LEFT_DC_PRED] = ff_dc_left_##sz##_msa; \ + dsp->intra_pred[tx][TOP_DC_PRED] = ff_dc_top_##sz##_msa; \ + dsp->intra_pred[tx][TM_VP8_PRED] = ff_tm_##sz##_msa; \ + + init_intra_pred_msa(TX_4X4, 4x4); + init_intra_pred_msa(TX_8X8, 8x8); +#undef init_intra_pred_msa + } +} + +static av_cold void vp9dsp_itxfm_init_msa(VP9DSPContext *dsp, int bpp) +{ + if (bpp == 8) { +#define init_itxfm(tx, sz) \ + dsp->itxfm_add[tx][DCT_DCT] = ff_idct_idct_##sz##_add_msa; \ + dsp->itxfm_add[tx][DCT_ADST] = ff_iadst_idct_##sz##_add_msa; \ + dsp->itxfm_add[tx][ADST_DCT] = ff_idct_iadst_##sz##_add_msa; \ + dsp->itxfm_add[tx][ADST_ADST] = ff_iadst_iadst_##sz##_add_msa \ + +#define init_idct(tx, nm) \ + dsp->itxfm_add[tx][DCT_DCT] = \ + dsp->itxfm_add[tx][ADST_DCT] = \ + dsp->itxfm_add[tx][DCT_ADST] = \ + dsp->itxfm_add[tx][ADST_ADST] = nm##_add_msa + + init_itxfm(TX_4X4, 4x4); + init_itxfm(TX_8X8, 8x8); + init_itxfm(TX_16X16, 16x16); + init_idct(TX_32X32, ff_idct_idct_32x32); +#undef init_itxfm +#undef init_idct + } +} + +static av_cold void vp9dsp_mc_init_msa(VP9DSPContext *dsp, int bpp) +{ + if (bpp == 8) { +#define init_fpel(idx1, idx2, sz, type) \ + dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][0][0] = ff_##type##sz##_msa; \ + dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][0][0] = ff_##type##sz##_msa; \ + dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][0][0] = ff_##type##sz##_msa; \ + dsp->mc[idx1][FILTER_BILINEAR ][idx2][0][0] = ff_##type##sz##_msa + +#define init_copy_avg(idx, sz) \ + init_fpel(idx, 0, sz, copy); \ + init_fpel(idx, 1, sz, avg) + +#define init_avg(idx, sz) \ + init_fpel(idx, 1, sz, avg) + + init_copy_avg(0, 64); + init_copy_avg(1, 32); + init_copy_avg(2, 16); + init_copy_avg(3, 8); + init_avg(4, 4); + +#undef init_copy_avg +#undef init_avg +#undef init_fpel + +#define init_subpel1(idx1, idx2, idxh, idxv, sz, dir, type) \ + dsp->mc[idx1][FILTER_BILINEAR ][idx2][idxh][idxv] = \ + ff_##type##_bilin_##sz##dir##_msa; \ + dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][idxh][idxv] = \ + ff_##type##_8tap_smooth_##sz##dir##_msa; \ + dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][idxh][idxv] = \ + ff_##type##_8tap_regular_##sz##dir##_msa; \ + dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][idxh][idxv] = \ + ff_##type##_8tap_sharp_##sz##dir##_msa; + +#define init_subpel2(idx, idxh, idxv, dir, type) \ + init_subpel1(0, idx, idxh, idxv, 64, dir, type); \ + init_subpel1(1, idx, idxh, idxv, 32, dir, type); \ + init_subpel1(2, idx, idxh, idxv, 16, dir, type); \ + init_subpel1(3, idx, idxh, idxv, 8, dir, type); \ + init_subpel1(4, idx, idxh, idxv, 4, dir, type) + +#define init_subpel3(idx, type) \ + init_subpel2(idx, 1, 1, hv, type); \ + init_subpel2(idx, 0, 1, v, type); \ + init_subpel2(idx, 1, 0, h, type) + + init_subpel3(0, put); + init_subpel3(1, avg); + +#undef init_subpel1 +#undef init_subpel2 +#undef init_subpel3 + } +} + +static av_cold void vp9dsp_loopfilter_init_msa(VP9DSPContext *dsp, int bpp) +{ + if (bpp == 8) { + dsp->loop_filter_8[0][0] = ff_loop_filter_h_4_8_msa; + dsp->loop_filter_8[0][1] = ff_loop_filter_v_4_8_msa; + dsp->loop_filter_8[1][0] = ff_loop_filter_h_8_8_msa; + dsp->loop_filter_8[1][1] = ff_loop_filter_v_8_8_msa; + dsp->loop_filter_8[2][0] = ff_loop_filter_h_16_8_msa; + dsp->loop_filter_8[2][1] = ff_loop_filter_v_16_8_msa; + + dsp->loop_filter_16[0] = ff_loop_filter_h_16_16_msa; + dsp->loop_filter_16[1] = ff_loop_filter_v_16_16_msa; + + dsp->loop_filter_mix2[0][0][0] = ff_loop_filter_h_44_16_msa; + dsp->loop_filter_mix2[0][0][1] = ff_loop_filter_v_44_16_msa; + dsp->loop_filter_mix2[0][1][0] = ff_loop_filter_h_48_16_msa; + dsp->loop_filter_mix2[0][1][1] = ff_loop_filter_v_48_16_msa; + dsp->loop_filter_mix2[1][0][0] = ff_loop_filter_h_84_16_msa; + dsp->loop_filter_mix2[1][0][1] = ff_loop_filter_v_84_16_msa; + dsp->loop_filter_mix2[1][1][0] = ff_loop_filter_h_88_16_msa; + dsp->loop_filter_mix2[1][1][1] = ff_loop_filter_v_88_16_msa; + } +} + +static av_cold void vp9dsp_init_msa(VP9DSPContext *dsp, int bpp) +{ + vp9dsp_intrapred_init_msa(dsp, bpp); + vp9dsp_itxfm_init_msa(dsp, bpp); + vp9dsp_mc_init_msa(dsp, bpp); + vp9dsp_loopfilter_init_msa(dsp, bpp); +} +#endif // #if HAVE_MSA + +av_cold void ff_vp9dsp_init_mips(VP9DSPContext *dsp, int bpp) +{ +#if HAVE_MSA + vp9dsp_init_msa(dsp, bpp); +#endif // #if HAVE_MSA +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp9dsp_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp9dsp_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp9dsp_mips.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp9dsp_mips.h 2015-07-27 17:20:04.000000000 +0000 @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * + * 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 + */ + +#ifndef AVCODEC_MIPS_VP9DSP_MIPS_H +#define AVCODEC_MIPS_VP9DSP_MIPS_H + +#define VP9_8TAP_MIPS_MSA_FUNC(SIZE, type, type_idx) \ +void ff_put_8tap_##type##_##SIZE##h_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, \ + ptrdiff_t srcstride, \ + int h, int mx, int my); \ + \ +void ff_put_8tap_##type##_##SIZE##v_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, \ + ptrdiff_t srcstride, \ + int h, int mx, int my); \ + \ +void ff_put_8tap_##type##_##SIZE##hv_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, \ + ptrdiff_t srcstride, \ + int h, int mx, int my); \ + \ +void ff_avg_8tap_##type##_##SIZE##h_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, \ + ptrdiff_t srcstride, \ + int h, int mx, int my); \ + \ +void ff_avg_8tap_##type##_##SIZE##v_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, \ + ptrdiff_t srcstride, \ + int h, int mx, int my); \ + \ +void ff_avg_8tap_##type##_##SIZE##hv_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, \ + ptrdiff_t srcstride, \ + int h, int mx, int my); + +#define VP9_BILINEAR_MIPS_MSA_FUNC(SIZE) \ +void ff_put_bilin_##SIZE##h_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, ptrdiff_t srcstride, \ + int h, int mx, int my); \ + \ +void ff_put_bilin_##SIZE##v_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, ptrdiff_t srcstride, \ + int h, int mx, int my); \ + \ +void ff_put_bilin_##SIZE##hv_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, ptrdiff_t srcstride, \ + int h, int mx, int my); \ + \ +void ff_avg_bilin_##SIZE##h_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, ptrdiff_t srcstride, \ + int h, int mx, int my); \ + \ +void ff_avg_bilin_##SIZE##v_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, ptrdiff_t srcstride, \ + int h, int mx, int my); \ + \ +void ff_avg_bilin_##SIZE##hv_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, ptrdiff_t srcstride, \ + int h, int mx, int my); + +#define VP9_COPY_AVG_MIPS_MSA_FUNC(SIZE) \ +void ff_copy##SIZE##_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, ptrdiff_t srcstride, \ + int h, int mx, int my); \ + \ +void ff_avg##SIZE##_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, ptrdiff_t srcstride, \ + int h, int mx, int my); + +VP9_8TAP_MIPS_MSA_FUNC(64, regular, FILTER_8TAP_REGULAR); +VP9_8TAP_MIPS_MSA_FUNC(32, regular, FILTER_8TAP_REGULAR); +VP9_8TAP_MIPS_MSA_FUNC(16, regular, FILTER_8TAP_REGULAR); +VP9_8TAP_MIPS_MSA_FUNC(8, regular, FILTER_8TAP_REGULAR); +VP9_8TAP_MIPS_MSA_FUNC(4, regular, FILTER_8TAP_REGULAR); + +VP9_8TAP_MIPS_MSA_FUNC(64, sharp, FILTER_8TAP_SHARP); +VP9_8TAP_MIPS_MSA_FUNC(32, sharp, FILTER_8TAP_SHARP); +VP9_8TAP_MIPS_MSA_FUNC(16, sharp, FILTER_8TAP_SHARP); +VP9_8TAP_MIPS_MSA_FUNC(8, sharp, FILTER_8TAP_SHARP); +VP9_8TAP_MIPS_MSA_FUNC(4, sharp, FILTER_8TAP_SHARP); + +VP9_8TAP_MIPS_MSA_FUNC(64, smooth, FILTER_8TAP_SMOOTH); +VP9_8TAP_MIPS_MSA_FUNC(32, smooth, FILTER_8TAP_SMOOTH); +VP9_8TAP_MIPS_MSA_FUNC(16, smooth, FILTER_8TAP_SMOOTH); +VP9_8TAP_MIPS_MSA_FUNC(8, smooth, FILTER_8TAP_SMOOTH); +VP9_8TAP_MIPS_MSA_FUNC(4, smooth, FILTER_8TAP_SMOOTH); + +VP9_BILINEAR_MIPS_MSA_FUNC(64); +VP9_BILINEAR_MIPS_MSA_FUNC(32); +VP9_BILINEAR_MIPS_MSA_FUNC(16); +VP9_BILINEAR_MIPS_MSA_FUNC(8); +VP9_BILINEAR_MIPS_MSA_FUNC(4); + +VP9_COPY_AVG_MIPS_MSA_FUNC(64); +VP9_COPY_AVG_MIPS_MSA_FUNC(32); +VP9_COPY_AVG_MIPS_MSA_FUNC(16); +VP9_COPY_AVG_MIPS_MSA_FUNC(8); +VP9_COPY_AVG_MIPS_MSA_FUNC(4); + +#undef VP9_8TAP_MIPS_MSA_FUNC +#undef VP9_BILINEAR_MIPS_MSA_FUNC +#undef VP9_COPY_AVG_MIPS_MSA_FUNC + +void ff_loop_filter_h_4_8_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_h_8_8_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_h_16_8_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_v_4_8_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_v_8_8_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_v_16_8_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_h_44_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_h_88_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_h_16_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_v_44_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_v_88_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_v_16_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_h_48_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_h_84_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_v_48_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_loop_filter_v_84_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e, + int32_t i, int32_t h); +void ff_idct_idct_4x4_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob); +void ff_idct_idct_8x8_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob); +void ff_idct_idct_16x16_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob); +void ff_idct_idct_32x32_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob); +void ff_iadst_iadst_4x4_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob); +void ff_iadst_iadst_8x8_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob); +void ff_iadst_iadst_16x16_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob); +void ff_iadst_idct_4x4_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob); +void ff_iadst_idct_8x8_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob); +void ff_iadst_idct_16x16_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob); +void ff_idct_iadst_4x4_add_msa(uint8_t *pu8Dest, ptrdiff_t stride, + int16_t *block, int eob); +void ff_idct_iadst_8x8_add_msa(uint8_t *pu8Dest, ptrdiff_t stride, + int16_t *block, int eob); +void ff_idct_iadst_16x16_add_msa(uint8_t *pu8Dest, ptrdiff_t stride, + int16_t *block, int eob); +void ff_iwht_iwht_4x4_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob); + +void ff_vert_16x16_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_vert_32x32_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_hor_16x16_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_hor_32x32_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_dc_4x4_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_dc_8x8_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_dc_16x16_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_dc_32x32_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_dc_left_4x4_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_dc_left_8x8_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_dc_left_16x16_msa(uint8_t *dst, ptrdiff_t stride, + const uint8_t *left, const uint8_t *top); +void ff_dc_left_32x32_msa(uint8_t *dst, ptrdiff_t stride, + const uint8_t *left, const uint8_t *top); +void ff_dc_top_4x4_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_dc_top_8x8_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_dc_top_16x16_msa(uint8_t *dst, ptrdiff_t stride, + const uint8_t *left, const uint8_t *top); +void ff_dc_top_32x32_msa(uint8_t *dst, ptrdiff_t stride, + const uint8_t *left, const uint8_t *top); +void ff_dc_128_16x16_msa(uint8_t *dst, ptrdiff_t stride, + const uint8_t *left, const uint8_t *top); +void ff_dc_128_32x32_msa(uint8_t *dst, ptrdiff_t stride, + const uint8_t *left, const uint8_t *top); +void ff_dc_127_16x16_msa(uint8_t *dst, ptrdiff_t stride, + const uint8_t *left, const uint8_t *top); +void ff_dc_127_32x32_msa(uint8_t *dst, ptrdiff_t stride, + const uint8_t *left, const uint8_t *top); +void ff_dc_129_16x16_msa(uint8_t *dst, ptrdiff_t stride, + const uint8_t *left, const uint8_t *top); +void ff_dc_129_32x32_msa(uint8_t *dst, ptrdiff_t stride, + const uint8_t *left, const uint8_t *top); +void ff_tm_4x4_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_tm_8x8_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_tm_16x16_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); +void ff_tm_32x32_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, + const uint8_t *top); + +#endif // #ifndef AVCODEC_MIPS_VP9DSP_MIPS_H diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp9_idct_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp9_idct_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp9_idct_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp9_idct_msa.c 2015-07-23 17:20:03.000000000 +0000 @@ -0,0 +1,2138 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * + * 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 +#include "libavcodec/vp9dsp.h" +#include "libavutil/mips/generic_macros_msa.h" +#include "vp9dsp_mips.h" + +#define VP9_DCT_CONST_BITS 14 +#define ROUND_POWER_OF_TWO(value, n) (((value) + (1 << ((n) - 1))) >> (n)) + +static const int32_t cospi_1_64 = 16364; +static const int32_t cospi_2_64 = 16305; +static const int32_t cospi_3_64 = 16207; +static const int32_t cospi_4_64 = 16069; +static const int32_t cospi_5_64 = 15893; +static const int32_t cospi_6_64 = 15679; +static const int32_t cospi_7_64 = 15426; +static const int32_t cospi_8_64 = 15137; +static const int32_t cospi_9_64 = 14811; +static const int32_t cospi_10_64 = 14449; +static const int32_t cospi_11_64 = 14053; +static const int32_t cospi_12_64 = 13623; +static const int32_t cospi_13_64 = 13160; +static const int32_t cospi_14_64 = 12665; +static const int32_t cospi_15_64 = 12140; +static const int32_t cospi_16_64 = 11585; +static const int32_t cospi_17_64 = 11003; +static const int32_t cospi_18_64 = 10394; +static const int32_t cospi_19_64 = 9760; +static const int32_t cospi_20_64 = 9102; +static const int32_t cospi_21_64 = 8423; +static const int32_t cospi_22_64 = 7723; +static const int32_t cospi_23_64 = 7005; +static const int32_t cospi_24_64 = 6270; +static const int32_t cospi_25_64 = 5520; +static const int32_t cospi_26_64 = 4756; +static const int32_t cospi_27_64 = 3981; +static const int32_t cospi_28_64 = 3196; +static const int32_t cospi_29_64 = 2404; +static const int32_t cospi_30_64 = 1606; +static const int32_t cospi_31_64 = 804; + +// 16384 * sqrt(2) * sin(kPi/9) * 2 / 3 +static const int32_t sinpi_1_9 = 5283; +static const int32_t sinpi_2_9 = 9929; +static const int32_t sinpi_3_9 = 13377; +static const int32_t sinpi_4_9 = 15212; + +#define VP9_DOTP_CONST_PAIR(reg0, reg1, cnst0, cnst1, out0, out1) \ +{ \ + v8i16 k0_m = __msa_fill_h(cnst0); \ + v4i32 s0_m, s1_m, s2_m, s3_m; \ + \ + s0_m = (v4i32) __msa_fill_h(cnst1); \ + k0_m = __msa_ilvev_h((v8i16) s0_m, k0_m); \ + \ + ILVRL_H2_SW((-reg1), reg0, s1_m, s0_m); \ + ILVRL_H2_SW(reg0, reg1, s3_m, s2_m); \ + DOTP_SH2_SW(s1_m, s0_m, k0_m, k0_m, s1_m, s0_m); \ + SRARI_W2_SW(s1_m, s0_m, VP9_DCT_CONST_BITS); \ + out0 = __msa_pckev_h((v8i16) s0_m, (v8i16) s1_m); \ + \ + DOTP_SH2_SW(s3_m, s2_m, k0_m, k0_m, s1_m, s0_m); \ + SRARI_W2_SW(s1_m, s0_m, VP9_DCT_CONST_BITS); \ + out1 = __msa_pckev_h((v8i16) s0_m, (v8i16) s1_m); \ +} + +#define VP9_DOT_ADD_SUB_SRARI_PCK(in0, in1, in2, in3, in4, in5, in6, in7, \ + dst0, dst1, dst2, dst3) \ +{ \ + v4i32 tp0_m, tp1_m, tp2_m, tp3_m, tp4_m; \ + v4i32 tp5_m, tp6_m, tp7_m, tp8_m, tp9_m; \ + \ + DOTP_SH4_SW(in0, in1, in0, in1, in4, in4, in5, in5, \ + tp0_m, tp2_m, tp3_m, tp4_m); \ + DOTP_SH4_SW(in2, in3, in2, in3, in6, in6, in7, in7, \ + tp5_m, tp6_m, tp7_m, tp8_m); \ + BUTTERFLY_4(tp0_m, tp3_m, tp7_m, tp5_m, tp1_m, tp9_m, tp7_m, tp5_m); \ + BUTTERFLY_4(tp2_m, tp4_m, tp8_m, tp6_m, tp3_m, tp0_m, tp4_m, tp2_m); \ + SRARI_W4_SW(tp1_m, tp9_m, tp7_m, tp5_m, VP9_DCT_CONST_BITS); \ + SRARI_W4_SW(tp3_m, tp0_m, tp4_m, tp2_m, VP9_DCT_CONST_BITS); \ + PCKEV_H4_SH(tp1_m, tp3_m, tp9_m, tp0_m, tp7_m, tp4_m, tp5_m, tp2_m, \ + dst0, dst1, dst2, dst3); \ +} + +#define VP9_DOT_SHIFT_RIGHT_PCK_H(in0, in1, in2) \ +( { \ + v8i16 dst_m; \ + v4i32 tp0_m, tp1_m; \ + \ + DOTP_SH2_SW(in0, in1, in2, in2, tp1_m, tp0_m); \ + SRARI_W2_SW(tp1_m, tp0_m, VP9_DCT_CONST_BITS); \ + dst_m = __msa_pckev_h((v8i16) tp1_m, (v8i16) tp0_m); \ + \ + dst_m; \ +} ) + +#define VP9_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, \ + out0, out1, out2, out3, out4, out5, out6, out7) \ +{ \ + v8i16 cnst0_m, cnst1_m, cnst2_m, cnst3_m, cnst4_m; \ + v8i16 vec0_m, vec1_m, vec2_m, vec3_m, s0_m, s1_m; \ + v8i16 coeff0_m = { cospi_2_64, cospi_6_64, cospi_10_64, cospi_14_64, \ + cospi_18_64, cospi_22_64, cospi_26_64, cospi_30_64 }; \ + v8i16 coeff1_m = { cospi_8_64, -cospi_8_64, cospi_16_64, \ + -cospi_16_64, cospi_24_64, -cospi_24_64, 0, 0 }; \ + \ + SPLATI_H2_SH(coeff0_m, 0, 7, cnst0_m, cnst1_m); \ + cnst2_m = -cnst0_m; \ + ILVEV_H2_SH(cnst0_m, cnst1_m, cnst1_m, cnst2_m, cnst0_m, cnst1_m); \ + SPLATI_H2_SH(coeff0_m, 4, 3, cnst2_m, cnst3_m); \ + cnst4_m = -cnst2_m; \ + ILVEV_H2_SH(cnst2_m, cnst3_m, cnst3_m, cnst4_m, cnst2_m, cnst3_m); \ + \ + ILVRL_H2_SH(in0, in7, vec1_m, vec0_m); \ + ILVRL_H2_SH(in4, in3, vec3_m, vec2_m); \ + VP9_DOT_ADD_SUB_SRARI_PCK(vec0_m, vec1_m, vec2_m, vec3_m, cnst0_m, \ + cnst1_m, cnst2_m, cnst3_m, in7, in0, \ + in4, in3); \ + \ + SPLATI_H2_SH(coeff0_m, 2, 5, cnst0_m, cnst1_m); \ + cnst2_m = -cnst0_m; \ + ILVEV_H2_SH(cnst0_m, cnst1_m, cnst1_m, cnst2_m, cnst0_m, cnst1_m); \ + SPLATI_H2_SH(coeff0_m, 6, 1, cnst2_m, cnst3_m); \ + cnst4_m = -cnst2_m; \ + ILVEV_H2_SH(cnst2_m, cnst3_m, cnst3_m, cnst4_m, cnst2_m, cnst3_m); \ + \ + ILVRL_H2_SH(in2, in5, vec1_m, vec0_m); \ + ILVRL_H2_SH(in6, in1, vec3_m, vec2_m); \ + \ + VP9_DOT_ADD_SUB_SRARI_PCK(vec0_m, vec1_m, vec2_m, vec3_m, cnst0_m, \ + cnst1_m, cnst2_m, cnst3_m, in5, in2, \ + in6, in1); \ + BUTTERFLY_4(in7, in0, in2, in5, s1_m, s0_m, in2, in5); \ + out7 = -s0_m; \ + out0 = s1_m; \ + \ + SPLATI_H4_SH(coeff1_m, 0, 4, 1, 5, \ + cnst0_m, cnst1_m, cnst2_m, cnst3_m); \ + \ + ILVEV_H2_SH(cnst3_m, cnst0_m, cnst1_m, cnst2_m, cnst3_m, cnst2_m); \ + cnst0_m = __msa_ilvev_h(cnst1_m, cnst0_m); \ + cnst1_m = cnst0_m; \ + \ + ILVRL_H2_SH(in4, in3, vec1_m, vec0_m); \ + ILVRL_H2_SH(in6, in1, vec3_m, vec2_m); \ + VP9_DOT_ADD_SUB_SRARI_PCK(vec0_m, vec1_m, vec2_m, vec3_m, cnst0_m, \ + cnst2_m, cnst3_m, cnst1_m, out1, out6, \ + s0_m, s1_m); \ + \ + SPLATI_H2_SH(coeff1_m, 2, 3, cnst0_m, cnst1_m); \ + cnst1_m = __msa_ilvev_h(cnst1_m, cnst0_m); \ + \ + ILVRL_H2_SH(in2, in5, vec1_m, vec0_m); \ + ILVRL_H2_SH(s0_m, s1_m, vec3_m, vec2_m); \ + out3 = VP9_DOT_SHIFT_RIGHT_PCK_H(vec0_m, vec1_m, cnst0_m); \ + out4 = VP9_DOT_SHIFT_RIGHT_PCK_H(vec0_m, vec1_m, cnst1_m); \ + out2 = VP9_DOT_SHIFT_RIGHT_PCK_H(vec2_m, vec3_m, cnst0_m); \ + out5 = VP9_DOT_SHIFT_RIGHT_PCK_H(vec2_m, vec3_m, cnst1_m); \ + \ + out1 = -out1; \ + out3 = -out3; \ + out5 = -out5; \ +} + +#define VP9_MADD_SHORT(m0, m1, c0, c1, res0, res1) \ +{ \ + v4i32 madd0_m, madd1_m, madd2_m, madd3_m; \ + v8i16 madd_s0_m, madd_s1_m; \ + \ + ILVRL_H2_SH(m1, m0, madd_s0_m, madd_s1_m); \ + DOTP_SH4_SW(madd_s0_m, madd_s1_m, madd_s0_m, madd_s1_m, \ + c0, c0, c1, c1, madd0_m, madd1_m, madd2_m, madd3_m); \ + SRARI_W4_SW(madd0_m, madd1_m, madd2_m, madd3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SH(madd1_m, madd0_m, madd3_m, madd2_m, res0, res1); \ +} + +#define VP9_MADD_BF(inp0, inp1, inp2, inp3, cst0, cst1, cst2, cst3, \ + out0, out1, out2, out3) \ +{ \ + v8i16 madd_s0_m, madd_s1_m, madd_s2_m, madd_s3_m; \ + v4i32 tmp0_m, tmp1_m, tmp2_m, tmp3_m, m4_m, m5_m; \ + \ + ILVRL_H2_SH(inp1, inp0, madd_s0_m, madd_s1_m); \ + ILVRL_H2_SH(inp3, inp2, madd_s2_m, madd_s3_m); \ + DOTP_SH4_SW(madd_s0_m, madd_s1_m, madd_s2_m, madd_s3_m, \ + cst0, cst0, cst2, cst2, tmp0_m, tmp1_m, tmp2_m, tmp3_m); \ + BUTTERFLY_4(tmp0_m, tmp1_m, tmp3_m, tmp2_m, \ + m4_m, m5_m, tmp3_m, tmp2_m); \ + SRARI_W4_SW(m4_m, m5_m, tmp2_m, tmp3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SH(m5_m, m4_m, tmp3_m, tmp2_m, out0, out1); \ + DOTP_SH4_SW(madd_s0_m, madd_s1_m, madd_s2_m, madd_s3_m, \ + cst1, cst1, cst3, cst3, tmp0_m, tmp1_m, tmp2_m, tmp3_m); \ + BUTTERFLY_4(tmp0_m, tmp1_m, tmp3_m, tmp2_m, \ + m4_m, m5_m, tmp3_m, tmp2_m); \ + SRARI_W4_SW(m4_m, m5_m, tmp2_m, tmp3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SH(m5_m, m4_m, tmp3_m, tmp2_m, out2, out3); \ +} + +#define VP9_SET_COSPI_PAIR(c0_h, c1_h) \ +( { \ + v8i16 out0_m, r0_m, r1_m; \ + \ + r0_m = __msa_fill_h(c0_h); \ + r1_m = __msa_fill_h(c1_h); \ + out0_m = __msa_ilvev_h(r1_m, r0_m); \ + \ + out0_m; \ +} ) + +#define VP9_ADDBLK_ST8x4_UB(dst, dst_stride, in0, in1, in2, in3) \ +{ \ + uint8_t *dst_m = (uint8_t *) (dst); \ + v16u8 dst0_m, dst1_m, dst2_m, dst3_m; \ + v16i8 tmp0_m, tmp1_m; \ + v16i8 zero_m = { 0 }; \ + v8i16 res0_m, res1_m, res2_m, res3_m; \ + \ + LD_UB4(dst_m, dst_stride, dst0_m, dst1_m, dst2_m, dst3_m); \ + ILVR_B4_SH(zero_m, dst0_m, zero_m, dst1_m, zero_m, dst2_m, \ + zero_m, dst3_m, res0_m, res1_m, res2_m, res3_m); \ + ADD4(res0_m, in0, res1_m, in1, res2_m, in2, res3_m, in3, \ + res0_m, res1_m, res2_m, res3_m); \ + CLIP_SH4_0_255(res0_m, res1_m, res2_m, res3_m); \ + PCKEV_B2_SB(res1_m, res0_m, res3_m, res2_m, tmp0_m, tmp1_m); \ + ST8x4_UB(tmp0_m, tmp1_m, dst_m, dst_stride); \ +} + +#define VP9_IDCT4x4(in0, in1, in2, in3, out0, out1, out2, out3) \ +{ \ + v8i16 c0_m, c1_m, c2_m, c3_m; \ + v8i16 step0_m, step1_m; \ + v4i32 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + \ + c0_m = VP9_SET_COSPI_PAIR(cospi_16_64, cospi_16_64); \ + c1_m = VP9_SET_COSPI_PAIR(cospi_16_64, -cospi_16_64); \ + step0_m = __msa_ilvr_h(in2, in0); \ + DOTP_SH2_SW(step0_m, step0_m, c0_m, c1_m, tmp0_m, tmp1_m); \ + \ + c2_m = VP9_SET_COSPI_PAIR(cospi_24_64, -cospi_8_64); \ + c3_m = VP9_SET_COSPI_PAIR(cospi_8_64, cospi_24_64); \ + step1_m = __msa_ilvr_h(in3, in1); \ + DOTP_SH2_SW(step1_m, step1_m, c2_m, c3_m, tmp2_m, tmp3_m); \ + SRARI_W4_SW(tmp0_m, tmp1_m, tmp2_m, tmp3_m, VP9_DCT_CONST_BITS); \ + \ + PCKEV_H2_SW(tmp1_m, tmp0_m, tmp3_m, tmp2_m, tmp0_m, tmp2_m); \ + SLDI_B2_0_SW(tmp0_m, tmp2_m, tmp1_m, tmp3_m, 8); \ + BUTTERFLY_4((v8i16) tmp0_m, (v8i16) tmp1_m, \ + (v8i16) tmp2_m, (v8i16) tmp3_m, \ + out0, out1, out2, out3); \ +} + +#define VP9_IADST4x4(in0, in1, in2, in3, out0, out1, out2, out3) \ +{ \ + v8i16 res0_m, res1_m, c0_m, c1_m; \ + v8i16 k1_m, k2_m, k3_m, k4_m; \ + v8i16 zero_m = { 0 }; \ + v4i32 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + v4i32 int0_m, int1_m, int2_m, int3_m; \ + v8i16 mask_m = { sinpi_1_9, sinpi_2_9, sinpi_3_9, \ + sinpi_4_9, -sinpi_1_9, -sinpi_2_9, -sinpi_3_9, \ + -sinpi_4_9 }; \ + \ + SPLATI_H4_SH(mask_m, 3, 0, 1, 2, c0_m, c1_m, k1_m, k2_m); \ + ILVEV_H2_SH(c0_m, c1_m, k1_m, k2_m, c0_m, c1_m); \ + ILVR_H2_SH(in0, in2, in1, in3, res0_m, res1_m); \ + DOTP_SH2_SW(res0_m, res1_m, c0_m, c1_m, tmp2_m, tmp1_m); \ + int0_m = tmp2_m + tmp1_m; \ + \ + SPLATI_H2_SH(mask_m, 4, 7, k4_m, k3_m); \ + ILVEV_H2_SH(k4_m, k1_m, k3_m, k2_m, c0_m, c1_m); \ + DOTP_SH2_SW(res0_m, res1_m, c0_m, c1_m, tmp0_m, tmp1_m); \ + int1_m = tmp0_m + tmp1_m; \ + \ + c0_m = __msa_splati_h(mask_m, 6); \ + ILVL_H2_SH(k2_m, c0_m, zero_m, k2_m, c0_m, c1_m); \ + ILVR_H2_SH(in0, in2, in1, in3, res0_m, res1_m); \ + DOTP_SH2_SW(res0_m, res1_m, c0_m, c1_m, tmp0_m, tmp1_m); \ + int2_m = tmp0_m + tmp1_m; \ + \ + c0_m = __msa_splati_h(mask_m, 6); \ + c0_m = __msa_ilvev_h(c0_m, k1_m); \ + \ + res0_m = __msa_ilvr_h((in1), (in3)); \ + tmp0_m = __msa_dotp_s_w(res0_m, c0_m); \ + int3_m = tmp2_m + tmp0_m; \ + \ + res0_m = __msa_ilvr_h((in2), (in3)); \ + c1_m = __msa_ilvev_h(k4_m, k3_m); \ + \ + tmp2_m = __msa_dotp_s_w(res0_m, c1_m); \ + res1_m = __msa_ilvr_h((in0), (in2)); \ + c1_m = __msa_ilvev_h(k1_m, zero_m); \ + \ + tmp3_m = __msa_dotp_s_w(res1_m, c1_m); \ + int3_m += tmp2_m; \ + int3_m += tmp3_m; \ + \ + SRARI_W4_SW(int0_m, int1_m, int2_m, int3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SH(int0_m, int0_m, int1_m, int1_m, out0, out1); \ + PCKEV_H2_SH(int2_m, int2_m, int3_m, int3_m, out2, out3); \ +} + +#define TRANSPOSE4X8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, \ + out0, out1, out2, out3, out4, out5, out6, out7) \ +{ \ + v8i16 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + v8i16 tmp0_n, tmp1_n, tmp2_n, tmp3_n; \ + v8i16 zero_m = { 0 }; \ + \ + ILVR_H4_SH(in1, in0, in3, in2, in5, in4, in7, in6, \ + tmp0_n, tmp1_n, tmp2_n, tmp3_n); \ + ILVRL_W2_SH(tmp1_n, tmp0_n, tmp0_m, tmp2_m); \ + ILVRL_W2_SH(tmp3_n, tmp2_n, tmp1_m, tmp3_m); \ + \ + out0 = (v8i16) __msa_ilvr_d((v2i64) tmp1_m, (v2i64) tmp0_m); \ + out1 = (v8i16) __msa_ilvl_d((v2i64) tmp1_m, (v2i64) tmp0_m); \ + out2 = (v8i16) __msa_ilvr_d((v2i64) tmp3_m, (v2i64) tmp2_m); \ + out3 = (v8i16) __msa_ilvl_d((v2i64) tmp3_m, (v2i64) tmp2_m); \ + \ + out4 = zero_m; \ + out5 = zero_m; \ + out6 = zero_m; \ + out7 = zero_m; \ +} + +static void vp9_idct4x4_1_add_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + int16_t out; + v8i16 vec; + + out = ROUND_POWER_OF_TWO((input[0] * cospi_16_64), VP9_DCT_CONST_BITS); + out = ROUND_POWER_OF_TWO((out * cospi_16_64), VP9_DCT_CONST_BITS); + out = ROUND_POWER_OF_TWO(out, 4); + vec = __msa_fill_h(out); + + ADDBLK_ST4x4_UB(vec, vec, vec, vec, dst, dst_stride); +} + +static void vp9_idct4x4_colcol_addblk_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + v8i16 in0, in1, in2, in3; + + /* load vector elements of 4x4 block */ + LD4x4_SH(input, in0, in1, in2, in3); + /* rows */ + VP9_IDCT4x4(in0, in1, in2, in3, in0, in1, in2, in3); + /* columns */ + TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3); + VP9_IDCT4x4(in0, in1, in2, in3, in0, in1, in2, in3); + /* rounding (add 2^3, divide by 2^4) */ + SRARI_H4_SH(in0, in1, in2, in3, 4); + ADDBLK_ST4x4_UB(in0, in1, in2, in3, dst, dst_stride); +} + +static void vp9_iadst4x4_colcol_addblk_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + v8i16 in0, in1, in2, in3; + + /* load vector elements of 4x4 block */ + LD4x4_SH(input, in0, in1, in2, in3); + /* rows */ + VP9_IADST4x4(in0, in1, in2, in3, in0, in1, in2, in3); + /* columns */ + TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3); + VP9_IADST4x4(in0, in1, in2, in3, in0, in1, in2, in3); + /* rounding (add 2^3, divide by 2^4) */ + SRARI_H4_SH(in0, in1, in2, in3, 4); + ADDBLK_ST4x4_UB(in0, in1, in2, in3, dst, dst_stride); +} + +static void vp9_iadst_idct_4x4_add_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride, int32_t eob) +{ + v8i16 in0, in1, in2, in3; + + /* load vector elements of 4x4 block */ + LD4x4_SH(input, in0, in1, in2, in3); + /* cols */ + VP9_IADST4x4(in0, in1, in2, in3, in0, in1, in2, in3); + /* columns */ + TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3); + VP9_IDCT4x4(in0, in1, in2, in3, in0, in1, in2, in3); + /* rounding (add 2^3, divide by 2^4) */ + SRARI_H4_SH(in0, in1, in2, in3, 4); + ADDBLK_ST4x4_UB(in0, in1, in2, in3, dst, dst_stride); +} + +static void vp9_idct_iadst_4x4_add_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride, int32_t eob) +{ + v8i16 in0, in1, in2, in3; + + /* load vector elements of 4x4 block */ + LD4x4_SH(input, in0, in1, in2, in3); + /* cols */ + VP9_IDCT4x4(in0, in1, in2, in3, in0, in1, in2, in3); + /* columns */ + TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3); + VP9_IADST4x4(in0, in1, in2, in3, in0, in1, in2, in3); + /* rounding (add 2^3, divide by 2^4) */ + SRARI_H4_SH(in0, in1, in2, in3, 4); + ADDBLK_ST4x4_UB(in0, in1, in2, in3, dst, dst_stride); +} + +#define VP9_SET_CONST_PAIR(mask_h, idx1_h, idx2_h) \ +( { \ + v8i16 c0_m, c1_m; \ + \ + SPLATI_H2_SH(mask_h, idx1_h, idx2_h, c0_m, c1_m); \ + c0_m = __msa_ilvev_h(c1_m, c0_m); \ + \ + c0_m; \ +} ) + +/* multiply and add macro */ +#define VP9_MADD(inp0, inp1, inp2, inp3, cst0, cst1, cst2, cst3, \ + out0, out1, out2, out3) \ +{ \ + v8i16 madd_s0_m, madd_s1_m, madd_s2_m, madd_s3_m; \ + v4i32 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + \ + ILVRL_H2_SH(inp1, inp0, madd_s1_m, madd_s0_m); \ + ILVRL_H2_SH(inp3, inp2, madd_s3_m, madd_s2_m); \ + DOTP_SH4_SW(madd_s1_m, madd_s0_m, madd_s1_m, madd_s0_m, \ + cst0, cst0, cst1, cst1, tmp0_m, tmp1_m, tmp2_m, tmp3_m); \ + SRARI_W4_SW(tmp0_m, tmp1_m, tmp2_m, tmp3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SH(tmp1_m, tmp0_m, tmp3_m, tmp2_m, out0, out1); \ + DOTP_SH4_SW(madd_s3_m, madd_s2_m, madd_s3_m, madd_s2_m, \ + cst2, cst2, cst3, cst3, tmp0_m, tmp1_m, tmp2_m, tmp3_m); \ + SRARI_W4_SW(tmp0_m, tmp1_m, tmp2_m, tmp3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SH(tmp1_m, tmp0_m, tmp3_m, tmp2_m, out2, out3); \ +} + +/* idct 8x8 macro */ +#define VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, \ + out0, out1, out2, out3, out4, out5, out6, out7) \ +{ \ + v8i16 tp0_m, tp1_m, tp2_m, tp3_m, tp4_m, tp5_m, tp6_m, tp7_m; \ + v8i16 k0_m, k1_m, k2_m, k3_m, res0_m, res1_m, res2_m, res3_m; \ + v4i32 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + v8i16 mask_m = { cospi_28_64, cospi_4_64, cospi_20_64, cospi_12_64, \ + cospi_16_64, -cospi_4_64, -cospi_20_64, -cospi_16_64 }; \ + \ + k0_m = VP9_SET_CONST_PAIR(mask_m, 0, 5); \ + k1_m = VP9_SET_CONST_PAIR(mask_m, 1, 0); \ + k2_m = VP9_SET_CONST_PAIR(mask_m, 6, 3); \ + k3_m = VP9_SET_CONST_PAIR(mask_m, 3, 2); \ + VP9_MADD(in1, in7, in3, in5, k0_m, k1_m, k2_m, k3_m, in1, in7, in3, in5); \ + SUB2(in1, in3, in7, in5, res0_m, res1_m); \ + k0_m = VP9_SET_CONST_PAIR(mask_m, 4, 7); \ + k1_m = __msa_splati_h(mask_m, 4); \ + \ + ILVRL_H2_SH(res0_m, res1_m, res2_m, res3_m); \ + DOTP_SH4_SW(res2_m, res3_m, res2_m, res3_m, k0_m, k0_m, k1_m, k1_m, \ + tmp0_m, tmp1_m, tmp2_m, tmp3_m); \ + SRARI_W4_SW(tmp0_m, tmp1_m, tmp2_m, tmp3_m, VP9_DCT_CONST_BITS); \ + tp4_m = in1 + in3; \ + PCKEV_H2_SH(tmp1_m, tmp0_m, tmp3_m, tmp2_m, tp5_m, tp6_m); \ + tp7_m = in7 + in5; \ + k2_m = VP9_SET_COSPI_PAIR(cospi_24_64, -cospi_8_64); \ + k3_m = VP9_SET_COSPI_PAIR(cospi_8_64, cospi_24_64); \ + VP9_MADD(in0, in4, in2, in6, k1_m, k0_m, k2_m, k3_m, \ + in0, in4, in2, in6); \ + BUTTERFLY_4(in0, in4, in2, in6, tp0_m, tp1_m, tp2_m, tp3_m); \ + BUTTERFLY_8(tp0_m, tp1_m, tp2_m, tp3_m, tp4_m, tp5_m, tp6_m, tp7_m, \ + out0, out1, out2, out3, out4, out5, out6, out7); \ +} + +#define VP9_IADST8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, \ + out0, out1, out2, out3, out4, out5, out6, out7) \ +{ \ + v4i32 r0_m, r1_m, r2_m, r3_m, r4_m, r5_m, r6_m, r7_m; \ + v4i32 m0_m, m1_m, m2_m, m3_m, t0_m, t1_m; \ + v8i16 res0_m, res1_m, res2_m, res3_m, k0_m, k1_m, in_s0, in_s1; \ + v8i16 mask1_m = { cospi_2_64, cospi_30_64, -cospi_2_64, \ + cospi_10_64, cospi_22_64, -cospi_10_64, cospi_18_64, cospi_14_64 }; \ + v8i16 mask2_m = { cospi_14_64, -cospi_18_64, cospi_26_64, \ + cospi_6_64, -cospi_26_64, cospi_8_64, cospi_24_64, -cospi_8_64 }; \ + v8i16 mask3_m = { -cospi_24_64, cospi_8_64, cospi_16_64, \ + -cospi_16_64, 0, 0, 0, 0 }; \ + \ + k0_m = VP9_SET_CONST_PAIR(mask1_m, 0, 1); \ + k1_m = VP9_SET_CONST_PAIR(mask1_m, 1, 2); \ + ILVRL_H2_SH(in1, in0, in_s1, in_s0); \ + DOTP_SH4_SW(in_s1, in_s0, in_s1, in_s0, k0_m, k0_m, k1_m, k1_m, \ + r0_m, r1_m, r2_m, r3_m); \ + k0_m = VP9_SET_CONST_PAIR(mask1_m, 6, 7); \ + k1_m = VP9_SET_CONST_PAIR(mask2_m, 0, 1); \ + ILVRL_H2_SH(in5, in4, in_s1, in_s0); \ + DOTP_SH4_SW(in_s1, in_s0, in_s1, in_s0, k0_m, k0_m, k1_m, k1_m, \ + r4_m, r5_m, r6_m, r7_m); \ + ADD4(r0_m, r4_m, r1_m, r5_m, r2_m, r6_m, r3_m, r7_m, \ + m0_m, m1_m, m2_m, m3_m); \ + SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SH(m1_m, m0_m, m3_m, m2_m, res0_m, res1_m); \ + SUB4(r0_m, r4_m, r1_m, r5_m, r2_m, r6_m, r3_m, r7_m, \ + m0_m, m1_m, m2_m, m3_m); \ + SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SW(m1_m, m0_m, m3_m, m2_m, t0_m, t1_m); \ + k0_m = VP9_SET_CONST_PAIR(mask1_m, 3, 4); \ + k1_m = VP9_SET_CONST_PAIR(mask1_m, 4, 5); \ + ILVRL_H2_SH(in3, in2, in_s1, in_s0); \ + DOTP_SH4_SW(in_s1, in_s0, in_s1, in_s0, k0_m, k0_m, k1_m, k1_m, \ + r0_m, r1_m, r2_m, r3_m); \ + k0_m = VP9_SET_CONST_PAIR(mask2_m, 2, 3); \ + k1_m = VP9_SET_CONST_PAIR(mask2_m, 3, 4); \ + ILVRL_H2_SH(in7, in6, in_s1, in_s0); \ + DOTP_SH4_SW(in_s1, in_s0, in_s1, in_s0, k0_m, k0_m, k1_m, k1_m, \ + r4_m, r5_m, r6_m, r7_m); \ + ADD4(r0_m, r4_m, r1_m, r5_m, r2_m, r6_m, r3_m, r7_m, \ + m0_m, m1_m, m2_m, m3_m); \ + SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SH(m1_m, m0_m, m3_m, m2_m, res2_m, res3_m); \ + SUB4(r0_m, r4_m, r1_m, r5_m, r2_m, r6_m, r3_m, r7_m, \ + m0_m, m1_m, m2_m, m3_m); \ + SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SW(m1_m, m0_m, m3_m, m2_m, r2_m, r3_m); \ + ILVRL_H2_SW(r3_m, r2_m, m2_m, m3_m); \ + BUTTERFLY_4(res0_m, res1_m, res3_m, res2_m, out0, in7, in4, in3); \ + k0_m = VP9_SET_CONST_PAIR(mask2_m, 5, 6); \ + k1_m = VP9_SET_CONST_PAIR(mask2_m, 6, 7); \ + ILVRL_H2_SH(t1_m, t0_m, in_s1, in_s0); \ + DOTP_SH4_SW(in_s1, in_s0, in_s1, in_s0, k0_m, k0_m, k1_m, k1_m, \ + r0_m, r1_m, r2_m, r3_m); \ + k1_m = VP9_SET_CONST_PAIR(mask3_m, 0, 1); \ + DOTP_SH4_SW(m2_m, m3_m, m2_m, m3_m, k0_m, k0_m, k1_m, k1_m, \ + r4_m, r5_m, r6_m, r7_m); \ + ADD4(r0_m, r6_m, r1_m, r7_m, r2_m, r4_m, r3_m, r5_m, \ + m0_m, m1_m, m2_m, m3_m); \ + SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SH(m1_m, m0_m, m3_m, m2_m, in1, out6); \ + SUB4(r0_m, r6_m, r1_m, r7_m, r2_m, r4_m, r3_m, r5_m, \ + m0_m, m1_m, m2_m, m3_m); \ + SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SH(m1_m, m0_m, m3_m, m2_m, in2, in5); \ + k0_m = VP9_SET_CONST_PAIR(mask3_m, 2, 2); \ + k1_m = VP9_SET_CONST_PAIR(mask3_m, 2, 3); \ + ILVRL_H2_SH(in4, in3, in_s1, in_s0); \ + DOTP_SH4_SW(in_s1, in_s0, in_s1, in_s0, k0_m, k0_m, k1_m, k1_m, \ + m0_m, m1_m, m2_m, m3_m); \ + SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SH(m1_m, m0_m, m3_m, m2_m, in3, out4); \ + ILVRL_H2_SW(in5, in2, m2_m, m3_m); \ + DOTP_SH4_SW(m2_m, m3_m, m2_m, m3_m, k0_m, k0_m, k1_m, k1_m, \ + m0_m, m1_m, m2_m, m3_m); \ + SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, VP9_DCT_CONST_BITS); \ + PCKEV_H2_SH(m1_m, m0_m, m3_m, m2_m, out2, in5); \ + \ + out1 = -in1; \ + out3 = -in3; \ + out5 = -in5; \ + out7 = -in7; \ +} + +static void vp9_idct8x8_1_add_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + int16_t out; + int32_t val; + v8i16 vec; + + out = ROUND_POWER_OF_TWO((input[0] * cospi_16_64), VP9_DCT_CONST_BITS); + out = ROUND_POWER_OF_TWO((out * cospi_16_64), VP9_DCT_CONST_BITS); + val = ROUND_POWER_OF_TWO(out, 5); + vec = __msa_fill_h(val); + + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, vec, vec, vec, vec); + dst += (4 * dst_stride); + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, vec, vec, vec, vec); +} + +static void vp9_idct8x8_12_colcol_addblk_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + v8i16 s0, s1, s2, s3, s4, s5, s6, s7, k0, k1, k2, k3, m0, m1, m2, m3; + v4i32 tmp0, tmp1, tmp2, tmp3; + v8i16 zero = { 0 }; + + /* load vector elements of 8x8 block */ + LD_SH8(input, 8, in0, in1, in2, in3, in4, in5, in6, in7); + ILVR_D2_SH(in1, in0, in3, in2, in0, in1); + ILVR_D2_SH(in5, in4, in7, in6, in2, in3); + //TRANSPOSE8X4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3); + + /* stage1 */ + ILVL_H2_SH(in3, in0, in2, in1, s0, s1); + k0 = VP9_SET_COSPI_PAIR(cospi_28_64, -cospi_4_64); + k1 = VP9_SET_COSPI_PAIR(cospi_4_64, cospi_28_64); + k2 = VP9_SET_COSPI_PAIR(-cospi_20_64, cospi_12_64); + k3 = VP9_SET_COSPI_PAIR(cospi_12_64, cospi_20_64); + DOTP_SH4_SW(s0, s0, s1, s1, k0, k1, k2, k3, tmp0, tmp1, tmp2, tmp3); + SRARI_W4_SW(tmp0, tmp1, tmp2, tmp3, VP9_DCT_CONST_BITS); + PCKEV_H2_SH(zero, tmp0, zero, tmp1, s0, s1); + PCKEV_H2_SH(zero, tmp2, zero, tmp3, s2, s3); + BUTTERFLY_4(s0, s1, s3, s2, s4, s7, s6, s5); + + /* stage2 */ + ILVR_H2_SH(in3, in1, in2, in0, s1, s0); + k0 = VP9_SET_COSPI_PAIR(cospi_16_64, cospi_16_64); + k1 = VP9_SET_COSPI_PAIR(cospi_16_64, -cospi_16_64); + k2 = VP9_SET_COSPI_PAIR(cospi_24_64, -cospi_8_64); + k3 = VP9_SET_COSPI_PAIR(cospi_8_64, cospi_24_64); + DOTP_SH4_SW(s0, s0, s1, s1, k0, k1, k2, k3, tmp0, tmp1, tmp2, tmp3); + SRARI_W4_SW(tmp0, tmp1, tmp2, tmp3, VP9_DCT_CONST_BITS); + PCKEV_H2_SH(zero, tmp0, zero, tmp1, s0, s1); + PCKEV_H2_SH(zero, tmp2, zero, tmp3, s2, s3); + BUTTERFLY_4(s0, s1, s2, s3, m0, m1, m2, m3); + + /* stage3 */ + s0 = __msa_ilvr_h(s6, s5); + + k1 = VP9_SET_COSPI_PAIR(-cospi_16_64, cospi_16_64); + DOTP_SH2_SW(s0, s0, k1, k0, tmp0, tmp1); + SRARI_W2_SW(tmp0, tmp1, VP9_DCT_CONST_BITS); + PCKEV_H2_SH(zero, tmp0, zero, tmp1, s2, s3); + + /* stage4 */ + BUTTERFLY_8(m0, m1, m2, m3, s4, s2, s3, s7, + in0, in1, in2, in3, in4, in5, in6, in7); + TRANSPOSE4X8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + /* final rounding (add 2^4, divide by 2^5) and shift */ + SRARI_H4_SH(in0, in1, in2, in3, 5); + SRARI_H4_SH(in4, in5, in6, in7, 5); + + /* add block and store 8x8 */ + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, in0, in1, in2, in3); + dst += (4 * dst_stride); + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, in4, in5, in6, in7); +} + +static void vp9_idct8x8_colcol_addblk_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + + /* load vector elements of 8x8 block */ + LD_SH8(input, 8, in0, in1, in2, in3, in4, in5, in6, in7); + /* 1D idct8x8 */ + VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + /* columns transform */ + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + /* 1D idct8x8 */ + VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + /* final rounding (add 2^4, divide by 2^5) and shift */ + SRARI_H4_SH(in0, in1, in2, in3, 5); + SRARI_H4_SH(in4, in5, in6, in7, 5); + /* add block and store 8x8 */ + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, in0, in1, in2, in3); + dst += (4 * dst_stride); + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, in4, in5, in6, in7); +} + +static void vp9_iadst8x8_colcol_addblk_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + v8i16 res0, res1, res2, res3, res4, res5, res6, res7; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v8i16 out0, out1, out2, out3, out4, out5, out6, out7; + v8i16 cnst0, cnst1, cnst2, cnst3, cnst4; + v8i16 temp0, temp1, temp2, temp3, s0, s1; + v16i8 zero = { 0 }; + + /* load vector elements of 8x8 block */ + LD_SH8(input, 8, in0, in1, in2, in3, in4, in5, in6, in7); + + /* 1D adst8x8 */ + VP9_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + /* columns transform */ + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + + cnst0 = __msa_fill_h(cospi_2_64); + cnst1 = __msa_fill_h(cospi_30_64); + cnst2 = -cnst0; + ILVEV_H2_SH(cnst0, cnst1, cnst1, cnst2, cnst0, cnst1); + cnst2 = __msa_fill_h(cospi_18_64); + cnst3 = __msa_fill_h(cospi_14_64); + cnst4 = -cnst2; + ILVEV_H2_SH(cnst2, cnst3, cnst3, cnst4, cnst2, cnst3); + + ILVRL_H2_SH(in0, in7, temp1, temp0); + ILVRL_H2_SH(in4, in3, temp3, temp2); + VP9_DOT_ADD_SUB_SRARI_PCK(temp0, temp1, temp2, temp3, cnst0, cnst1, cnst2, + cnst3, in7, in0, in4, in3); + + cnst0 = __msa_fill_h(cospi_10_64); + cnst1 = __msa_fill_h(cospi_22_64); + cnst2 = -cnst0; + ILVEV_H2_SH(cnst0, cnst1, cnst1, cnst2, cnst0, cnst1); + cnst2 = __msa_fill_h(cospi_26_64); + cnst3 = __msa_fill_h(cospi_6_64); + cnst4 = -cnst2; + ILVEV_H2_SH(cnst2, cnst3, cnst3, cnst4, cnst2, cnst3); + + ILVRL_H2_SH(in2, in5, temp1, temp0); + ILVRL_H2_SH(in6, in1, temp3, temp2); + VP9_DOT_ADD_SUB_SRARI_PCK(temp0, temp1, temp2, temp3, cnst0, cnst1, cnst2, + cnst3, in5, in2, in6, in1); + BUTTERFLY_4(in7, in0, in2, in5, s1, s0, in2, in5); + out7 = -s0; + out0 = s1; + SRARI_H2_SH(out0, out7, 5); + dst0 = LD_UB(dst + 0 * dst_stride); + dst7 = LD_UB(dst + 7 * dst_stride); + + res0 = (v8i16) __msa_ilvr_b(zero, (v16i8) dst0); + res0 += out0; + res0 = CLIP_SH_0_255(res0); + res0 = (v8i16) __msa_pckev_b((v16i8) res0, (v16i8) res0); + ST8x1_UB(res0, dst); + + res7 = (v8i16) __msa_ilvr_b(zero, (v16i8) dst7); + res7 += out7; + res7 = CLIP_SH_0_255(res7); + res7 = (v8i16) __msa_pckev_b((v16i8) res7, (v16i8) res7); + ST8x1_UB(res7, dst + 7 * dst_stride); + + cnst1 = __msa_fill_h(cospi_24_64); + cnst0 = __msa_fill_h(cospi_8_64); + cnst3 = -cnst1; + cnst2 = -cnst0; + + ILVEV_H2_SH(cnst3, cnst0, cnst1, cnst2, cnst3, cnst2); + cnst0 = __msa_ilvev_h(cnst1, cnst0); + cnst1 = cnst0; + + ILVRL_H2_SH(in4, in3, temp1, temp0); + ILVRL_H2_SH(in6, in1, temp3, temp2); + VP9_DOT_ADD_SUB_SRARI_PCK(temp0, temp1, temp2, temp3, cnst0, cnst2, cnst3, + cnst1, out1, out6, s0, s1); + out1 = -out1; + SRARI_H2_SH(out1, out6, 5); + dst1 = LD_UB(dst + 1 * dst_stride); + dst6 = LD_UB(dst + 6 * dst_stride); + ILVR_B2_SH(zero, dst1, zero, dst6, res1, res6); + ADD2(res1, out1, res6, out6, res1, res6); + CLIP_SH2_0_255(res1, res6); + PCKEV_B2_SH(res1, res1, res6, res6, res1, res6); + ST8x1_UB(res1, dst + dst_stride); + ST8x1_UB(res6, dst + 6 * dst_stride); + + cnst0 = __msa_fill_h(cospi_16_64); + cnst1 = -cnst0; + cnst1 = __msa_ilvev_h(cnst1, cnst0); + + ILVRL_H2_SH(in2, in5, temp1, temp0); + ILVRL_H2_SH(s0, s1, temp3, temp2); + out3 = VP9_DOT_SHIFT_RIGHT_PCK_H(temp0, temp1, cnst0); + out4 = VP9_DOT_SHIFT_RIGHT_PCK_H(temp0, temp1, cnst1); + out3 = -out3; + SRARI_H2_SH(out3, out4, 5); + dst3 = LD_UB(dst + 3 * dst_stride); + dst4 = LD_UB(dst + 4 * dst_stride); + ILVR_B2_SH(zero, dst3, zero, dst4, res3, res4); + ADD2(res3, out3, res4, out4, res3, res4); + CLIP_SH2_0_255(res3, res4); + PCKEV_B2_SH(res3, res3, res4, res4, res3, res4); + ST8x1_UB(res3, dst + 3 * dst_stride); + ST8x1_UB(res4, dst + 4 * dst_stride); + + out2 = VP9_DOT_SHIFT_RIGHT_PCK_H(temp2, temp3, cnst0); + out5 = VP9_DOT_SHIFT_RIGHT_PCK_H(temp2, temp3, cnst1); + out5 = -out5; + SRARI_H2_SH(out2, out5, 5); + dst2 = LD_UB(dst + 2 * dst_stride); + dst5 = LD_UB(dst + 5 * dst_stride); + ILVR_B2_SH(zero, dst2, zero, dst5, res2, res5); + ADD2(res2, out2, res5, out5, res2, res5); + CLIP_SH2_0_255(res2, res5); + PCKEV_B2_SH(res2, res2, res5, res5, res2, res5); + ST8x1_UB(res2, dst + 2 * dst_stride); + ST8x1_UB(res5, dst + 5 * dst_stride); +} + +static void vp9_iadst_idct_8x8_add_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride, int32_t eob) +{ + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + + /* load vector elements of 8x8 block */ + LD_SH8(input, 8, in1, in6, in3, in4, in5, in2, in7, in0); + /* 1D idct8x8 */ + VP9_IADST8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + /* columns transform */ + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + /* 1D idct8x8 */ + VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + /* final rounding (add 2^4, divide by 2^5) and shift */ + SRARI_H4_SH(in0, in1, in2, in3, 5); + SRARI_H4_SH(in4, in5, in6, in7, 5); + /* add block and store 8x8 */ + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, in0, in1, in2, in3); + dst += (4 * dst_stride); + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, in4, in5, in6, in7); +} + +static void vp9_idct_iadst_8x8_add_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride, int32_t eob) +{ + v8i16 in0, in1, in2, in3, in4, in5, in6, in7; + + /* load vector elements of 8x8 block */ + LD_SH8(input, 8, in0, in1, in2, in3, in4, in5, in6, in7); + + /* 1D idct8x8 */ + VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + /* columns transform */ + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, + in1, in6, in3, in4, in5, in2, in7, in0); + /* 1D idct8x8 */ + VP9_IADST8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, + in0, in1, in2, in3, in4, in5, in6, in7); + /* final rounding (add 2^4, divide by 2^5) and shift */ + SRARI_H4_SH(in0, in1, in2, in3, 5); + SRARI_H4_SH(in4, in5, in6, in7, 5); + /* add block and store 8x8 */ + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, in0, in1, in2, in3); + dst += (4 * dst_stride); + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, in4, in5, in6, in7); +} + +#define VP9_IADST8x16_1D(r0, r1, r2, r3, r4, r5, r6, r7, r8, \ + r9, r10, r11, r12, r13, r14, r15, \ + out0, out1, out2, out3, out4, out5, \ + out6, out7, out8, out9, out10, out11, \ + out12, out13, out14, out15) \ +{ \ + v8i16 g0_m, g1_m, g2_m, g3_m, g4_m, g5_m, g6_m, g7_m; \ + v8i16 g8_m, g9_m, g10_m, g11_m, g12_m, g13_m, g14_m, g15_m; \ + v8i16 h0_m, h1_m, h2_m, h3_m, h4_m, h5_m, h6_m, h7_m; \ + v8i16 h8_m, h9_m, h10_m, h11_m; \ + v8i16 k0_m, k1_m, k2_m, k3_m; \ + \ + /* stage 1 */ \ + k0_m = VP9_SET_COSPI_PAIR(cospi_1_64, cospi_31_64); \ + k1_m = VP9_SET_COSPI_PAIR(cospi_31_64, -cospi_1_64); \ + k2_m = VP9_SET_COSPI_PAIR(cospi_17_64, cospi_15_64); \ + k3_m = VP9_SET_COSPI_PAIR(cospi_15_64, -cospi_17_64); \ + VP9_MADD_BF(r15, r0, r7, r8, k0_m, k1_m, k2_m, k3_m, \ + g0_m, g1_m, g2_m, g3_m); \ + k0_m = VP9_SET_COSPI_PAIR(cospi_5_64, cospi_27_64); \ + k1_m = VP9_SET_COSPI_PAIR(cospi_27_64, -cospi_5_64); \ + k2_m = VP9_SET_COSPI_PAIR(cospi_21_64, cospi_11_64); \ + k3_m = VP9_SET_COSPI_PAIR(cospi_11_64, -cospi_21_64); \ + VP9_MADD_BF(r13, r2, r5, r10, k0_m, k1_m, k2_m, k3_m, \ + g4_m, g5_m, g6_m, g7_m); \ + k0_m = VP9_SET_COSPI_PAIR(cospi_9_64, cospi_23_64); \ + k1_m = VP9_SET_COSPI_PAIR(cospi_23_64, -cospi_9_64); \ + k2_m = VP9_SET_COSPI_PAIR(cospi_25_64, cospi_7_64); \ + k3_m = VP9_SET_COSPI_PAIR(cospi_7_64, -cospi_25_64); \ + VP9_MADD_BF(r11, r4, r3, r12, k0_m, k1_m, k2_m, k3_m, \ + g8_m, g9_m, g10_m, g11_m); \ + k0_m = VP9_SET_COSPI_PAIR(cospi_13_64, cospi_19_64); \ + k1_m = VP9_SET_COSPI_PAIR(cospi_19_64, -cospi_13_64); \ + k2_m = VP9_SET_COSPI_PAIR(cospi_29_64, cospi_3_64); \ + k3_m = VP9_SET_COSPI_PAIR(cospi_3_64, -cospi_29_64); \ + VP9_MADD_BF(r9, r6, r1, r14, k0_m, k1_m, k2_m, k3_m, \ + g12_m, g13_m, g14_m, g15_m); \ + \ + /* stage 2 */ \ + k0_m = VP9_SET_COSPI_PAIR(cospi_4_64, cospi_28_64); \ + k1_m = VP9_SET_COSPI_PAIR(cospi_28_64, -cospi_4_64); \ + k2_m = VP9_SET_COSPI_PAIR(-cospi_28_64, cospi_4_64); \ + VP9_MADD_BF(g1_m, g3_m, g9_m, g11_m, k0_m, k1_m, k2_m, k0_m, \ + h0_m, h1_m, h2_m, h3_m); \ + k0_m = VP9_SET_COSPI_PAIR(cospi_12_64, cospi_20_64); \ + k1_m = VP9_SET_COSPI_PAIR(-cospi_20_64, cospi_12_64); \ + k2_m = VP9_SET_COSPI_PAIR(cospi_20_64, -cospi_12_64); \ + VP9_MADD_BF(g7_m, g5_m, g15_m, g13_m, k0_m, k1_m, k2_m, k0_m, \ + h4_m, h5_m, h6_m, h7_m); \ + BUTTERFLY_4(h0_m, h2_m, h6_m, h4_m, out8, out9, out11, out10); \ + BUTTERFLY_8(g0_m, g2_m, g4_m, g6_m, g14_m, g12_m, g10_m, g8_m, \ + h8_m, h9_m, h10_m, h11_m, h6_m, h4_m, h2_m, h0_m); \ + \ + /* stage 3 */ \ + BUTTERFLY_4(h8_m, h9_m, h11_m, h10_m, out0, out1, h11_m, h10_m); \ + k0_m = VP9_SET_COSPI_PAIR(cospi_8_64, cospi_24_64); \ + k1_m = VP9_SET_COSPI_PAIR(cospi_24_64, -cospi_8_64); \ + k2_m = VP9_SET_COSPI_PAIR(-cospi_24_64, cospi_8_64); \ + VP9_MADD_BF(h0_m, h2_m, h4_m, h6_m, k0_m, k1_m, k2_m, k0_m, \ + out4, out6, out5, out7); \ + VP9_MADD_BF(h1_m, h3_m, h5_m, h7_m, k0_m, k1_m, k2_m, k0_m, \ + out12, out14, out13, out15); \ + \ + /* stage 4 */ \ + k0_m = VP9_SET_COSPI_PAIR(cospi_16_64, cospi_16_64); \ + k1_m = VP9_SET_COSPI_PAIR(-cospi_16_64, -cospi_16_64); \ + k2_m = VP9_SET_COSPI_PAIR(cospi_16_64, -cospi_16_64); \ + k3_m = VP9_SET_COSPI_PAIR(-cospi_16_64, cospi_16_64); \ + VP9_MADD_SHORT(h10_m, h11_m, k1_m, k2_m, out2, out3); \ + VP9_MADD_SHORT(out6, out7, k0_m, k3_m, out6, out7); \ + VP9_MADD_SHORT(out10, out11, k0_m, k3_m, out10, out11); \ + VP9_MADD_SHORT(out14, out15, k1_m, k2_m, out14, out15); \ +} + +static void vp9_idct16_1d_columns_addblk_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + v8i16 loc0, loc1, loc2, loc3; + v8i16 reg0, reg2, reg4, reg6, reg8, reg10, reg12, reg14; + v8i16 reg3, reg13, reg11, reg5, reg7, reg9, reg1, reg15; + v8i16 tmp5, tmp6, tmp7; + + /* load up 8x8 */ + LD_SH8(input, 16, reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7); + input += 8 * 16; + /* load bottom 8x8 */ + LD_SH8(input, 16, reg8, reg9, reg10, reg11, reg12, reg13, reg14, reg15); + + VP9_DOTP_CONST_PAIR(reg2, reg14, cospi_28_64, cospi_4_64, reg2, reg14); + VP9_DOTP_CONST_PAIR(reg10, reg6, cospi_12_64, cospi_20_64, reg10, reg6); + BUTTERFLY_4(reg2, reg14, reg6, reg10, loc0, loc1, reg14, reg2); + VP9_DOTP_CONST_PAIR(reg14, reg2, cospi_16_64, cospi_16_64, loc2, loc3); + VP9_DOTP_CONST_PAIR(reg0, reg8, cospi_16_64, cospi_16_64, reg0, reg8); + VP9_DOTP_CONST_PAIR(reg4, reg12, cospi_24_64, cospi_8_64, reg4, reg12); + BUTTERFLY_4(reg8, reg0, reg4, reg12, reg2, reg6, reg10, reg14); + + reg0 = reg2 - loc1; + reg2 = reg2 + loc1; + reg12 = reg14 - loc0; + reg14 = reg14 + loc0; + reg4 = reg6 - loc3; + reg6 = reg6 + loc3; + reg8 = reg10 - loc2; + reg10 = reg10 + loc2; + + /* stage 2 */ + VP9_DOTP_CONST_PAIR(reg1, reg15, cospi_30_64, cospi_2_64, reg1, reg15); + VP9_DOTP_CONST_PAIR(reg9, reg7, cospi_14_64, cospi_18_64, loc2, loc3); + + reg9 = reg1 - loc2; + reg1 = reg1 + loc2; + reg7 = reg15 - loc3; + reg15 = reg15 + loc3; + + VP9_DOTP_CONST_PAIR(reg5, reg11, cospi_22_64, cospi_10_64, reg5, reg11); + VP9_DOTP_CONST_PAIR(reg13, reg3, cospi_6_64, cospi_26_64, loc0, loc1); + BUTTERFLY_4(loc0, loc1, reg11, reg5, reg13, reg3, reg11, reg5); + + loc1 = reg15 + reg3; + reg3 = reg15 - reg3; + loc2 = reg2 + loc1; + reg15 = reg2 - loc1; + + loc1 = reg1 + reg13; + reg13 = reg1 - reg13; + loc0 = reg0 + loc1; + loc1 = reg0 - loc1; + tmp6 = loc0; + tmp7 = loc1; + reg0 = loc2; + + VP9_DOTP_CONST_PAIR(reg7, reg9, cospi_24_64, cospi_8_64, reg7, reg9); + VP9_DOTP_CONST_PAIR((-reg5), (-reg11), cospi_8_64, cospi_24_64, reg5, + reg11); + + loc0 = reg9 + reg5; + reg5 = reg9 - reg5; + reg2 = reg6 + loc0; + reg1 = reg6 - loc0; + + loc0 = reg7 + reg11; + reg11 = reg7 - reg11; + loc1 = reg4 + loc0; + loc2 = reg4 - loc0; + tmp5 = loc1; + + VP9_DOTP_CONST_PAIR(reg5, reg11, cospi_16_64, cospi_16_64, reg5, reg11); + BUTTERFLY_4(reg8, reg10, reg11, reg5, loc0, reg4, reg9, loc1); + + reg10 = loc0; + reg11 = loc1; + + VP9_DOTP_CONST_PAIR(reg3, reg13, cospi_16_64, cospi_16_64, reg3, reg13); + BUTTERFLY_4(reg12, reg14, reg13, reg3, reg8, reg6, reg7, reg5); + reg13 = loc2; + + /* Transpose and store the output */ + reg12 = tmp5; + reg14 = tmp6; + reg3 = tmp7; + + SRARI_H4_SH(reg0, reg2, reg4, reg6, 6); + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, reg0, reg2, reg4, reg6); + dst += (4 * dst_stride); + SRARI_H4_SH(reg8, reg10, reg12, reg14, 6); + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, reg8, reg10, reg12, reg14); + dst += (4 * dst_stride); + SRARI_H4_SH(reg3, reg13, reg11, reg5, 6); + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, reg3, reg13, reg11, reg5); + dst += (4 * dst_stride); + SRARI_H4_SH(reg7, reg9, reg1, reg15, 6); + VP9_ADDBLK_ST8x4_UB(dst, dst_stride, reg7, reg9, reg1, reg15); +} + +static void vp9_idct16_1d_columns_msa(int16_t *input, int16_t *output) +{ + v8i16 loc0, loc1, loc2, loc3; + v8i16 reg0, reg2, reg4, reg6, reg8, reg10, reg12, reg14; + v8i16 reg3, reg13, reg11, reg5, reg7, reg9, reg1, reg15; + v8i16 tmp5, tmp6, tmp7; + + /* load up 8x8 */ + LD_SH8(input, 16, reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7); + input += 8 * 16; + /* load bottom 8x8 */ + LD_SH8(input, 16, reg8, reg9, reg10, reg11, reg12, reg13, reg14, reg15); + + VP9_DOTP_CONST_PAIR(reg2, reg14, cospi_28_64, cospi_4_64, reg2, reg14); + VP9_DOTP_CONST_PAIR(reg10, reg6, cospi_12_64, cospi_20_64, reg10, reg6); + BUTTERFLY_4(reg2, reg14, reg6, reg10, loc0, loc1, reg14, reg2); + VP9_DOTP_CONST_PAIR(reg14, reg2, cospi_16_64, cospi_16_64, loc2, loc3); + VP9_DOTP_CONST_PAIR(reg0, reg8, cospi_16_64, cospi_16_64, reg0, reg8); + VP9_DOTP_CONST_PAIR(reg4, reg12, cospi_24_64, cospi_8_64, reg4, reg12); + BUTTERFLY_4(reg8, reg0, reg4, reg12, reg2, reg6, reg10, reg14); + + reg0 = reg2 - loc1; + reg2 = reg2 + loc1; + reg12 = reg14 - loc0; + reg14 = reg14 + loc0; + reg4 = reg6 - loc3; + reg6 = reg6 + loc3; + reg8 = reg10 - loc2; + reg10 = reg10 + loc2; + + /* stage 2 */ + VP9_DOTP_CONST_PAIR(reg1, reg15, cospi_30_64, cospi_2_64, reg1, reg15); + VP9_DOTP_CONST_PAIR(reg9, reg7, cospi_14_64, cospi_18_64, loc2, loc3); + + reg9 = reg1 - loc2; + reg1 = reg1 + loc2; + reg7 = reg15 - loc3; + reg15 = reg15 + loc3; + + VP9_DOTP_CONST_PAIR(reg5, reg11, cospi_22_64, cospi_10_64, reg5, reg11); + VP9_DOTP_CONST_PAIR(reg13, reg3, cospi_6_64, cospi_26_64, loc0, loc1); + BUTTERFLY_4(loc0, loc1, reg11, reg5, reg13, reg3, reg11, reg5); + + loc1 = reg15 + reg3; + reg3 = reg15 - reg3; + loc2 = reg2 + loc1; + reg15 = reg2 - loc1; + + loc1 = reg1 + reg13; + reg13 = reg1 - reg13; + loc0 = reg0 + loc1; + loc1 = reg0 - loc1; + tmp6 = loc0; + tmp7 = loc1; + reg0 = loc2; + + VP9_DOTP_CONST_PAIR(reg7, reg9, cospi_24_64, cospi_8_64, reg7, reg9); + VP9_DOTP_CONST_PAIR((-reg5), (-reg11), cospi_8_64, cospi_24_64, reg5, + reg11); + + loc0 = reg9 + reg5; + reg5 = reg9 - reg5; + reg2 = reg6 + loc0; + reg1 = reg6 - loc0; + + loc0 = reg7 + reg11; + reg11 = reg7 - reg11; + loc1 = reg4 + loc0; + loc2 = reg4 - loc0; + + tmp5 = loc1; + + VP9_DOTP_CONST_PAIR(reg5, reg11, cospi_16_64, cospi_16_64, reg5, reg11); + BUTTERFLY_4(reg8, reg10, reg11, reg5, loc0, reg4, reg9, loc1); + + reg10 = loc0; + reg11 = loc1; + + VP9_DOTP_CONST_PAIR(reg3, reg13, cospi_16_64, cospi_16_64, reg3, reg13); + BUTTERFLY_4(reg12, reg14, reg13, reg3, reg8, reg6, reg7, reg5); + reg13 = loc2; + + /* Transpose and store the output */ + reg12 = tmp5; + reg14 = tmp6; + reg3 = tmp7; + + /* transpose block */ + TRANSPOSE8x8_SH_SH(reg0, reg2, reg4, reg6, reg8, reg10, reg12, reg14, + reg0, reg2, reg4, reg6, reg8, reg10, reg12, reg14); + ST_SH4(reg0, reg2, reg4, reg6, output, 16); + ST_SH4(reg8, reg10, reg12, reg14, (output + 4 * 16), 16); + + /* transpose block */ + TRANSPOSE8x8_SH_SH(reg3, reg13, reg11, reg5, reg7, reg9, reg1, reg15, + reg3, reg13, reg11, reg5, reg7, reg9, reg1, reg15); + ST_SH4(reg3, reg13, reg11, reg5, (output + 8), 16); + ST_SH4(reg7, reg9, reg1, reg15, (output + 8 + 4 * 16), 16); +} + +static void vp9_idct16x16_1_add_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + uint8_t i; + int16_t out; + v8i16 vec, res0, res1, res2, res3, res4, res5, res6, res7; + v16u8 dst0, dst1, dst2, dst3, tmp0, tmp1, tmp2, tmp3; + + out = ROUND_POWER_OF_TWO((input[0] * cospi_16_64), VP9_DCT_CONST_BITS); + out = ROUND_POWER_OF_TWO((out * cospi_16_64), VP9_DCT_CONST_BITS); + out = ROUND_POWER_OF_TWO(out, 6); + + vec = __msa_fill_h(out); + + for (i = 4; i--;) + { + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + UNPCK_UB_SH(dst0, res0, res4); + UNPCK_UB_SH(dst1, res1, res5); + UNPCK_UB_SH(dst2, res2, res6); + UNPCK_UB_SH(dst3, res3, res7); + ADD4(res0, vec, res1, vec, res2, vec, res3, vec, res0, res1, res2, + res3); + ADD4(res4, vec, res5, vec, res6, vec, res7, vec, res4, res5, res6, + res7); + CLIP_SH4_0_255(res0, res1, res2, res3); + CLIP_SH4_0_255(res4, res5, res6, res7); + PCKEV_B4_UB(res4, res0, res5, res1, res6, res2, res7, res3, + tmp0, tmp1, tmp2, tmp3); + ST_UB4(tmp0, tmp1, tmp2, tmp3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void vp9_idct16x16_10_colcol_addblk_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + int32_t i; + int16_t out_arr[16 * 16] ALLOC_ALIGNED(ALIGNMENT); + int16_t *out = out_arr; + + /* transform rows */ + vp9_idct16_1d_columns_msa(input, out); + + /* short case just considers top 4 rows as valid output */ + out += 4 * 16; + for (i = 12; i--;) { + __asm__ volatile ( + "sw $zero, 0(%[out]) \n\t" + "sw $zero, 4(%[out]) \n\t" + "sw $zero, 8(%[out]) \n\t" + "sw $zero, 12(%[out]) \n\t" + "sw $zero, 16(%[out]) \n\t" + "sw $zero, 20(%[out]) \n\t" + "sw $zero, 24(%[out]) \n\t" + "sw $zero, 28(%[out]) \n\t" + + : + : [out] "r" (out) + ); + + out += 16; + } + + out = out_arr; + + /* transform columns */ + for (i = 0; i < 2; i++) { + /* process 8 * 16 block */ + vp9_idct16_1d_columns_addblk_msa((out + (i << 3)), (dst + (i << 3)), + dst_stride); + } +} + +static void vp9_idct16x16_colcol_addblk_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + int32_t i; + int16_t out_arr[16 * 16] ALLOC_ALIGNED(ALIGNMENT); + int16_t *out = out_arr; + + /* transform rows */ + for (i = 0; i < 2; i++) { + /* process 8 * 16 block */ + vp9_idct16_1d_columns_msa((input + (i << 3)), (out + (i << 7))); + } + + /* transform columns */ + for (i = 0; i < 2; i++) { + /* process 8 * 16 block */ + vp9_idct16_1d_columns_addblk_msa((out + (i << 3)), (dst + (i << 3)), + dst_stride); + } +} + +static void vp9_iadst16_1d_columns_msa(int16_t *input, int16_t *output) +{ + v8i16 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15; + v8i16 l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15; + + /* load input data */ + LD_SH16(input, 16, + l0, l1, l2, l3, l4, l5, l6, l7, + l8, l9, l10, l11, l12, l13, l14, l15); + + /* ADST in horizontal */ + VP9_IADST8x16_1D(l0, l1, l2, l3, l4, l5, l6, l7, + l8, l9, l10, l11, l12, l13, l14, l15, + r0, r1, r2, r3, r4, r5, r6, r7, + r8, r9, r10, r11, r12, r13, r14, r15); + + l1 = -r8; + l3 = -r4; + l13 = -r13; + l15 = -r1; + + TRANSPOSE8x8_SH_SH(r0, l1, r12, l3, r6, r14, r10, r2, + l0, l1, l2, l3, l4, l5, l6, l7); + ST_SH8(l0, l1, l2, l3, l4, l5, l6, l7, output, 16); + TRANSPOSE8x8_SH_SH(r3, r11, r15, r7, r5, l13, r9, l15, + l8, l9, l10, l11, l12, l13, l14, l15); + ST_SH8(l8, l9, l10, l11, l12, l13, l14, l15, (output + 8), 16); +} + +static void vp9_iadst16_1d_columns_addblk_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + v8i16 v0, v2, v4, v6, k0, k1, k2, k3; + v8i16 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15; + v8i16 out0, out1, out2, out3, out4, out5, out6, out7; + v8i16 out8, out9, out10, out11, out12, out13, out14, out15; + v8i16 g0, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15; + v8i16 h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11; + v8i16 res0, res1, res2, res3, res4, res5, res6, res7; + v8i16 res8, res9, res10, res11, res12, res13, res14, res15; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v16u8 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; + v16i8 zero = { 0 }; + + r0 = LD_SH(input + 0 * 16); + r3 = LD_SH(input + 3 * 16); + r4 = LD_SH(input + 4 * 16); + r7 = LD_SH(input + 7 * 16); + r8 = LD_SH(input + 8 * 16); + r11 = LD_SH(input + 11 * 16); + r12 = LD_SH(input + 12 * 16); + r15 = LD_SH(input + 15 * 16); + + /* stage 1 */ + k0 = VP9_SET_COSPI_PAIR(cospi_1_64, cospi_31_64); + k1 = VP9_SET_COSPI_PAIR(cospi_31_64, -cospi_1_64); + k2 = VP9_SET_COSPI_PAIR(cospi_17_64, cospi_15_64); + k3 = VP9_SET_COSPI_PAIR(cospi_15_64, -cospi_17_64); + VP9_MADD_BF(r15, r0, r7, r8, k0, k1, k2, k3, g0, g1, g2, g3); + k0 = VP9_SET_COSPI_PAIR(cospi_9_64, cospi_23_64); + k1 = VP9_SET_COSPI_PAIR(cospi_23_64, -cospi_9_64); + k2 = VP9_SET_COSPI_PAIR(cospi_25_64, cospi_7_64); + k3 = VP9_SET_COSPI_PAIR(cospi_7_64, -cospi_25_64); + VP9_MADD_BF(r11, r4, r3, r12, k0, k1, k2, k3, g8, g9, g10, g11); + BUTTERFLY_4(g0, g2, g10, g8, h8, h9, v2, v0); + k0 = VP9_SET_COSPI_PAIR(cospi_4_64, cospi_28_64); + k1 = VP9_SET_COSPI_PAIR(cospi_28_64, -cospi_4_64); + k2 = VP9_SET_COSPI_PAIR(-cospi_28_64, cospi_4_64); + VP9_MADD_BF(g1, g3, g9, g11, k0, k1, k2, k0, h0, h1, h2, h3); + + r1 = LD_SH(input + 1 * 16); + r2 = LD_SH(input + 2 * 16); + r5 = LD_SH(input + 5 * 16); + r6 = LD_SH(input + 6 * 16); + r9 = LD_SH(input + 9 * 16); + r10 = LD_SH(input + 10 * 16); + r13 = LD_SH(input + 13 * 16); + r14 = LD_SH(input + 14 * 16); + + k0 = VP9_SET_COSPI_PAIR(cospi_5_64, cospi_27_64); + k1 = VP9_SET_COSPI_PAIR(cospi_27_64, -cospi_5_64); + k2 = VP9_SET_COSPI_PAIR(cospi_21_64, cospi_11_64); + k3 = VP9_SET_COSPI_PAIR(cospi_11_64, -cospi_21_64); + VP9_MADD_BF(r13, r2, r5, r10, k0, k1, k2, k3, g4, g5, g6, g7); + k0 = VP9_SET_COSPI_PAIR(cospi_13_64, cospi_19_64); + k1 = VP9_SET_COSPI_PAIR(cospi_19_64, -cospi_13_64); + k2 = VP9_SET_COSPI_PAIR(cospi_29_64, cospi_3_64); + k3 = VP9_SET_COSPI_PAIR(cospi_3_64, -cospi_29_64); + VP9_MADD_BF(r9, r6, r1, r14, k0, k1, k2, k3, g12, g13, g14, g15); + BUTTERFLY_4(g4, g6, g14, g12, h10, h11, v6, v4); + BUTTERFLY_4(h8, h9, h11, h10, out0, out1, h11, h10); + out1 = -out1; + SRARI_H2_SH(out0, out1, 6); + dst0 = LD_UB(dst + 0 * dst_stride); + dst1 = LD_UB(dst + 15 * dst_stride); + ILVR_B2_SH(zero, dst0, zero, dst1, res0, res1); + ADD2(res0, out0, res1, out1, res0, res1); + CLIP_SH2_0_255(res0, res1); + PCKEV_B2_SH(res0, res0, res1, res1, res0, res1); + ST8x1_UB(res0, dst); + ST8x1_UB(res1, dst + 15 * dst_stride); + + k0 = VP9_SET_COSPI_PAIR(cospi_12_64, cospi_20_64); + k1 = VP9_SET_COSPI_PAIR(-cospi_20_64, cospi_12_64); + k2 = VP9_SET_COSPI_PAIR(cospi_20_64, -cospi_12_64); + VP9_MADD_BF(g7, g5, g15, g13, k0, k1, k2, k0, h4, h5, h6, h7); + BUTTERFLY_4(h0, h2, h6, h4, out8, out9, out11, out10); + out8 = -out8; + + SRARI_H2_SH(out8, out9, 6); + dst8 = LD_UB(dst + 1 * dst_stride); + dst9 = LD_UB(dst + 14 * dst_stride); + ILVR_B2_SH(zero, dst8, zero, dst9, res8, res9); + ADD2(res8, out8, res9, out9, res8, res9); + CLIP_SH2_0_255(res8, res9); + PCKEV_B2_SH(res8, res8, res9, res9, res8, res9); + ST8x1_UB(res8, dst + dst_stride); + ST8x1_UB(res9, dst + 14 * dst_stride); + + k0 = VP9_SET_COSPI_PAIR(cospi_8_64, cospi_24_64); + k1 = VP9_SET_COSPI_PAIR(cospi_24_64, -cospi_8_64); + k2 = VP9_SET_COSPI_PAIR(-cospi_24_64, cospi_8_64); + VP9_MADD_BF(v0, v2, v4, v6, k0, k1, k2, k0, out4, out6, out5, out7); + out4 = -out4; + SRARI_H2_SH(out4, out5, 6); + dst4 = LD_UB(dst + 3 * dst_stride); + dst5 = LD_UB(dst + 12 * dst_stride); + ILVR_B2_SH(zero, dst4, zero, dst5, res4, res5); + ADD2(res4, out4, res5, out5, res4, res5); + CLIP_SH2_0_255(res4, res5); + PCKEV_B2_SH(res4, res4, res5, res5, res4, res5); + ST8x1_UB(res4, dst + 3 * dst_stride); + ST8x1_UB(res5, dst + 12 * dst_stride); + + VP9_MADD_BF(h1, h3, h5, h7, k0, k1, k2, k0, out12, out14, out13, out15); + out13 = -out13; + SRARI_H2_SH(out12, out13, 6); + dst12 = LD_UB(dst + 2 * dst_stride); + dst13 = LD_UB(dst + 13 * dst_stride); + ILVR_B2_SH(zero, dst12, zero, dst13, res12, res13); + ADD2(res12, out12, res13, out13, res12, res13); + CLIP_SH2_0_255(res12, res13); + PCKEV_B2_SH(res12, res12, res13, res13, res12, res13); + ST8x1_UB(res12, dst + 2 * dst_stride); + ST8x1_UB(res13, dst + 13 * dst_stride); + + k0 = VP9_SET_COSPI_PAIR(cospi_16_64, cospi_16_64); + k3 = VP9_SET_COSPI_PAIR(-cospi_16_64, cospi_16_64); + VP9_MADD_SHORT(out6, out7, k0, k3, out6, out7); + SRARI_H2_SH(out6, out7, 6); + dst6 = LD_UB(dst + 4 * dst_stride); + dst7 = LD_UB(dst + 11 * dst_stride); + ILVR_B2_SH(zero, dst6, zero, dst7, res6, res7); + ADD2(res6, out6, res7, out7, res6, res7); + CLIP_SH2_0_255(res6, res7); + PCKEV_B2_SH(res6, res6, res7, res7, res6, res7); + ST8x1_UB(res6, dst + 4 * dst_stride); + ST8x1_UB(res7, dst + 11 * dst_stride); + + VP9_MADD_SHORT(out10, out11, k0, k3, out10, out11); + SRARI_H2_SH(out10, out11, 6); + dst10 = LD_UB(dst + 6 * dst_stride); + dst11 = LD_UB(dst + 9 * dst_stride); + ILVR_B2_SH(zero, dst10, zero, dst11, res10, res11); + ADD2(res10, out10, res11, out11, res10, res11); + CLIP_SH2_0_255(res10, res11); + PCKEV_B2_SH(res10, res10, res11, res11, res10, res11); + ST8x1_UB(res10, dst + 6 * dst_stride); + ST8x1_UB(res11, dst + 9 * dst_stride); + + k1 = VP9_SET_COSPI_PAIR(-cospi_16_64, -cospi_16_64); + k2 = VP9_SET_COSPI_PAIR(cospi_16_64, -cospi_16_64); + VP9_MADD_SHORT(h10, h11, k1, k2, out2, out3); + SRARI_H2_SH(out2, out3, 6); + dst2 = LD_UB(dst + 7 * dst_stride); + dst3 = LD_UB(dst + 8 * dst_stride); + ILVR_B2_SH(zero, dst2, zero, dst3, res2, res3); + ADD2(res2, out2, res3, out3, res2, res3); + CLIP_SH2_0_255(res2, res3); + PCKEV_B2_SH(res2, res2, res3, res3, res2, res3); + ST8x1_UB(res2, dst + 7 * dst_stride); + ST8x1_UB(res3, dst + 8 * dst_stride); + + VP9_MADD_SHORT(out14, out15, k1, k2, out14, out15); + SRARI_H2_SH(out14, out15, 6); + dst14 = LD_UB(dst + 5 * dst_stride); + dst15 = LD_UB(dst + 10 * dst_stride); + ILVR_B2_SH(zero, dst14, zero, dst15, res14, res15); + ADD2(res14, out14, res15, out15, res14, res15); + CLIP_SH2_0_255(res14, res15); + PCKEV_B2_SH(res14, res14, res15, res15, res14, res15); + ST8x1_UB(res14, dst + 5 * dst_stride); + ST8x1_UB(res15, dst + 10 * dst_stride); +} + +static void vp9_iadst16x16_colcol_addblk_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + int16_t out_arr[16 * 16] ALLOC_ALIGNED(ALIGNMENT); + int16_t *out = out_arr; + int32_t i; + + /* transform rows */ + for (i = 0; i < 2; i++) { + /* process 16 * 8 block */ + vp9_iadst16_1d_columns_msa((input + (i << 3)), (out + (i << 7))); + } + + /* transform columns */ + for (i = 0; i < 2; i++) { + /* process 8 * 16 block */ + vp9_iadst16_1d_columns_addblk_msa((out + (i << 3)), (dst + (i << 3)), + dst_stride); + } +} + +static void vp9_iadst_idct_16x16_add_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride, int32_t eob) +{ + int32_t i; + int16_t out[16 * 16]; + int16_t *out_ptr = &out[0]; + + /* transform rows */ + for (i = 0; i < 2; i++) { + /* process 8 * 16 block */ + vp9_iadst16_1d_columns_msa((input + (i << 3)), (out_ptr + (i << 7))); + } + + /* transform columns */ + for (i = 0; i < 2; i++) { + /* process 8 * 16 block */ + vp9_idct16_1d_columns_addblk_msa((out_ptr + (i << 3)), + (dst + (i << 3)), dst_stride); + } +} + +static void vp9_idct_iadst_16x16_add_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride, int32_t eob) +{ + int32_t i; + int16_t out[16 * 16]; + int16_t *out_ptr = &out[0]; + + /* transform rows */ + for (i = 0; i < 2; i++) { + /* process 8 * 16 block */ + vp9_idct16_1d_columns_msa((input + (i << 3)), (out_ptr + (i << 7))); + } + + /* transform columns */ + for (i = 0; i < 2; i++) { + /* process 8 * 16 block */ + vp9_iadst16_1d_columns_addblk_msa((out_ptr + (i << 3)), + (dst + (i << 3)), dst_stride); + } +} + +static void vp9_idct_butterfly_transpose_store(int16_t *tmp_buf, + int16_t *tmp_eve_buf, + int16_t *tmp_odd_buf, + int16_t *dst) +{ + v8i16 vec0, vec1, vec2, vec3, loc0, loc1, loc2, loc3; + v8i16 m0, m1, m2, m3, m4, m5, m6, m7, n0, n1, n2, n3, n4, n5, n6, n7; + + /* FINAL BUTTERFLY : Dependency on Even & Odd */ + vec0 = LD_SH(tmp_odd_buf); + vec1 = LD_SH(tmp_odd_buf + 9 * 8); + vec2 = LD_SH(tmp_odd_buf + 14 * 8); + vec3 = LD_SH(tmp_odd_buf + 6 * 8); + loc0 = LD_SH(tmp_eve_buf); + loc1 = LD_SH(tmp_eve_buf + 8 * 8); + loc2 = LD_SH(tmp_eve_buf + 4 * 8); + loc3 = LD_SH(tmp_eve_buf + 12 * 8); + + ADD4(loc0, vec3, loc1, vec2, loc2, vec1, loc3, vec0, m0, m4, m2, m6); + + ST_SH((loc0 - vec3), (tmp_buf + 31 * 8)); + ST_SH((loc1 - vec2), (tmp_buf + 23 * 8)); + ST_SH((loc2 - vec1), (tmp_buf + 27 * 8)); + ST_SH((loc3 - vec0), (tmp_buf + 19 * 8)); + + /* Load 8 & Store 8 */ + vec0 = LD_SH(tmp_odd_buf + 4 * 8); + vec1 = LD_SH(tmp_odd_buf + 13 * 8); + vec2 = LD_SH(tmp_odd_buf + 10 * 8); + vec3 = LD_SH(tmp_odd_buf + 3 * 8); + loc0 = LD_SH(tmp_eve_buf + 2 * 8); + loc1 = LD_SH(tmp_eve_buf + 10 * 8); + loc2 = LD_SH(tmp_eve_buf + 6 * 8); + loc3 = LD_SH(tmp_eve_buf + 14 * 8); + + ADD4(loc0, vec3, loc1, vec2, loc2, vec1, loc3, vec0, m1, m5, m3, m7); + + ST_SH((loc0 - vec3), (tmp_buf + 29 * 8)); + ST_SH((loc1 - vec2), (tmp_buf + 21 * 8)); + ST_SH((loc2 - vec1), (tmp_buf + 25 * 8)); + ST_SH((loc3 - vec0), (tmp_buf + 17 * 8)); + + /* Load 8 & Store 8 */ + vec0 = LD_SH(tmp_odd_buf + 2 * 8); + vec1 = LD_SH(tmp_odd_buf + 11 * 8); + vec2 = LD_SH(tmp_odd_buf + 12 * 8); + vec3 = LD_SH(tmp_odd_buf + 7 * 8); + loc0 = LD_SH(tmp_eve_buf + 1 * 8); + loc1 = LD_SH(tmp_eve_buf + 9 * 8); + loc2 = LD_SH(tmp_eve_buf + 5 * 8); + loc3 = LD_SH(tmp_eve_buf + 13 * 8); + + ADD4(loc0, vec3, loc1, vec2, loc2, vec1, loc3, vec0, n0, n4, n2, n6); + + ST_SH((loc0 - vec3), (tmp_buf + 30 * 8)); + ST_SH((loc1 - vec2), (tmp_buf + 22 * 8)); + ST_SH((loc2 - vec1), (tmp_buf + 26 * 8)); + ST_SH((loc3 - vec0), (tmp_buf + 18 * 8)); + + /* Load 8 & Store 8 */ + vec0 = LD_SH(tmp_odd_buf + 5 * 8); + vec1 = LD_SH(tmp_odd_buf + 15 * 8); + vec2 = LD_SH(tmp_odd_buf + 8 * 8); + vec3 = LD_SH(tmp_odd_buf + 1 * 8); + loc0 = LD_SH(tmp_eve_buf + 3 * 8); + loc1 = LD_SH(tmp_eve_buf + 11 * 8); + loc2 = LD_SH(tmp_eve_buf + 7 * 8); + loc3 = LD_SH(tmp_eve_buf + 15 * 8); + + ADD4(loc0, vec3, loc1, vec2, loc2, vec1, loc3, vec0, n1, n5, n3, n7); + + ST_SH((loc0 - vec3), (tmp_buf + 28 * 8)); + ST_SH((loc1 - vec2), (tmp_buf + 20 * 8)); + ST_SH((loc2 - vec1), (tmp_buf + 24 * 8)); + ST_SH((loc3 - vec0), (tmp_buf + 16 * 8)); + + /* Transpose : 16 vectors */ + /* 1st & 2nd 8x8 */ + TRANSPOSE8x8_SH_SH(m0, n0, m1, n1, m2, n2, m3, n3, + m0, n0, m1, n1, m2, n2, m3, n3); + ST_SH4(m0, n0, m1, n1, (dst + 0), 32); + ST_SH4(m2, n2, m3, n3, (dst + 4 * 32), 32); + + TRANSPOSE8x8_SH_SH(m4, n4, m5, n5, m6, n6, m7, n7, + m4, n4, m5, n5, m6, n6, m7, n7); + ST_SH4(m4, n4, m5, n5, (dst + 8), 32); + ST_SH4(m6, n6, m7, n7, (dst + 8 + 4 * 32), 32); + + /* 3rd & 4th 8x8 */ + LD_SH8((tmp_buf + 8 * 16), 8, m0, n0, m1, n1, m2, n2, m3, n3); + LD_SH8((tmp_buf + 12 * 16), 8, m4, n4, m5, n5, m6, n6, m7, n7); + TRANSPOSE8x8_SH_SH(m0, n0, m1, n1, m2, n2, m3, n3, + m0, n0, m1, n1, m2, n2, m3, n3); + ST_SH4(m0, n0, m1, n1, (dst + 16), 32); + ST_SH4(m2, n2, m3, n3, (dst + 16 + 4 * 32), 32); + + TRANSPOSE8x8_SH_SH(m4, n4, m5, n5, m6, n6, m7, n7, + m4, n4, m5, n5, m6, n6, m7, n7); + ST_SH4(m4, n4, m5, n5, (dst + 24), 32); + ST_SH4(m6, n6, m7, n7, (dst + 24 + 4 * 32), 32); +} + +static void vp9_idct8x32_column_even_process_store(int16_t *tmp_buf, + int16_t *tmp_eve_buf) +{ + v8i16 vec0, vec1, vec2, vec3, loc0, loc1, loc2, loc3; + v8i16 reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7; + v8i16 stp0, stp1, stp2, stp3, stp4, stp5, stp6, stp7; + + /* Even stage 1 */ + LD_SH8(tmp_buf, (4 * 32), reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7); + tmp_buf += (2 * 32); + + VP9_DOTP_CONST_PAIR(reg1, reg7, cospi_28_64, cospi_4_64, reg1, reg7); + VP9_DOTP_CONST_PAIR(reg5, reg3, cospi_12_64, cospi_20_64, reg5, reg3); + BUTTERFLY_4(reg1, reg7, reg3, reg5, vec1, vec3, vec2, vec0); + VP9_DOTP_CONST_PAIR(vec2, vec0, cospi_16_64, cospi_16_64, loc2, loc3); + + loc1 = vec3; + loc0 = vec1; + + VP9_DOTP_CONST_PAIR(reg0, reg4, cospi_16_64, cospi_16_64, reg0, reg4); + VP9_DOTP_CONST_PAIR(reg2, reg6, cospi_24_64, cospi_8_64, reg2, reg6); + BUTTERFLY_4(reg4, reg0, reg2, reg6, vec1, vec3, vec2, vec0); + BUTTERFLY_4(vec0, vec1, loc1, loc0, stp3, stp0, stp7, stp4); + BUTTERFLY_4(vec2, vec3, loc3, loc2, stp2, stp1, stp6, stp5); + + /* Even stage 2 */ + /* Load 8 */ + LD_SH8(tmp_buf, (4 * 32), reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7); + + VP9_DOTP_CONST_PAIR(reg0, reg7, cospi_30_64, cospi_2_64, reg0, reg7); + VP9_DOTP_CONST_PAIR(reg4, reg3, cospi_14_64, cospi_18_64, reg4, reg3); + VP9_DOTP_CONST_PAIR(reg2, reg5, cospi_22_64, cospi_10_64, reg2, reg5); + VP9_DOTP_CONST_PAIR(reg6, reg1, cospi_6_64, cospi_26_64, reg6, reg1); + + vec0 = reg0 + reg4; + reg0 = reg0 - reg4; + reg4 = reg6 + reg2; + reg6 = reg6 - reg2; + reg2 = reg1 + reg5; + reg1 = reg1 - reg5; + reg5 = reg7 + reg3; + reg7 = reg7 - reg3; + reg3 = vec0; + + vec1 = reg2; + reg2 = reg3 + reg4; + reg3 = reg3 - reg4; + reg4 = reg5 - vec1; + reg5 = reg5 + vec1; + + VP9_DOTP_CONST_PAIR(reg7, reg0, cospi_24_64, cospi_8_64, reg0, reg7); + VP9_DOTP_CONST_PAIR((-reg6), reg1, cospi_24_64, cospi_8_64, reg6, reg1); + + vec0 = reg0 - reg6; + reg0 = reg0 + reg6; + vec1 = reg7 - reg1; + reg7 = reg7 + reg1; + + VP9_DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, reg6, reg1); + VP9_DOTP_CONST_PAIR(reg4, reg3, cospi_16_64, cospi_16_64, reg3, reg4); + + /* Even stage 3 : Dependency on Even stage 1 & Even stage 2 */ + /* Store 8 */ + BUTTERFLY_4(stp0, stp1, reg7, reg5, loc1, loc3, loc2, loc0); + ST_SH2(loc1, loc3, tmp_eve_buf, 8); + ST_SH2(loc2, loc0, (tmp_eve_buf + 14 * 8), 8); + + BUTTERFLY_4(stp2, stp3, reg4, reg1, loc1, loc3, loc2, loc0); + ST_SH2(loc1, loc3, (tmp_eve_buf + 2 * 8), 8); + ST_SH2(loc2, loc0, (tmp_eve_buf + 12 * 8), 8); + + /* Store 8 */ + BUTTERFLY_4(stp4, stp5, reg6, reg3, loc1, loc3, loc2, loc0); + ST_SH2(loc1, loc3, (tmp_eve_buf + 4 * 8), 8); + ST_SH2(loc2, loc0, (tmp_eve_buf + 10 * 8), 8); + + BUTTERFLY_4(stp6, stp7, reg2, reg0, loc1, loc3, loc2, loc0); + ST_SH2(loc1, loc3, (tmp_eve_buf + 6 * 8), 8); + ST_SH2(loc2, loc0, (tmp_eve_buf + 8 * 8), 8); +} + +static void vp9_idct8x32_column_odd_process_store(int16_t *tmp_buf, + int16_t *tmp_odd_buf) +{ + v8i16 vec0, vec1, vec2, vec3, loc0, loc1, loc2, loc3; + v8i16 reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7; + + /* Odd stage 1 */ + reg0 = LD_SH(tmp_buf + 32); + reg1 = LD_SH(tmp_buf + 7 * 32); + reg2 = LD_SH(tmp_buf + 9 * 32); + reg3 = LD_SH(tmp_buf + 15 * 32); + reg4 = LD_SH(tmp_buf + 17 * 32); + reg5 = LD_SH(tmp_buf + 23 * 32); + reg6 = LD_SH(tmp_buf + 25 * 32); + reg7 = LD_SH(tmp_buf + 31 * 32); + + VP9_DOTP_CONST_PAIR(reg0, reg7, cospi_31_64, cospi_1_64, reg0, reg7); + VP9_DOTP_CONST_PAIR(reg4, reg3, cospi_15_64, cospi_17_64, reg3, reg4); + VP9_DOTP_CONST_PAIR(reg2, reg5, cospi_23_64, cospi_9_64, reg2, reg5); + VP9_DOTP_CONST_PAIR(reg6, reg1, cospi_7_64, cospi_25_64, reg1, reg6); + + vec0 = reg0 + reg3; + reg0 = reg0 - reg3; + reg3 = reg7 + reg4; + reg7 = reg7 - reg4; + reg4 = reg1 + reg2; + reg1 = reg1 - reg2; + reg2 = reg6 + reg5; + reg6 = reg6 - reg5; + reg5 = vec0; + + /* 4 Stores */ + ADD2(reg5, reg4, reg3, reg2, vec0, vec1); + ST_SH2(vec0, vec1, (tmp_odd_buf + 4 * 8), 8); + SUB2(reg5, reg4, reg3, reg2, vec0, vec1); + VP9_DOTP_CONST_PAIR(vec1, vec0, cospi_24_64, cospi_8_64, vec0, vec1); + ST_SH2(vec0, vec1, tmp_odd_buf, 8); + + /* 4 Stores */ + VP9_DOTP_CONST_PAIR(reg7, reg0, cospi_28_64, cospi_4_64, reg0, reg7); + VP9_DOTP_CONST_PAIR(reg6, reg1, -cospi_4_64, cospi_28_64, reg1, reg6); + BUTTERFLY_4(reg0, reg7, reg6, reg1, vec0, vec1, vec2, vec3); + ST_SH2(vec0, vec1, (tmp_odd_buf + 6 * 8), 8); + VP9_DOTP_CONST_PAIR(vec2, vec3, cospi_24_64, cospi_8_64, vec2, vec3); + ST_SH2(vec2, vec3, (tmp_odd_buf + 2 * 8), 8); + + /* Odd stage 2 */ + /* 8 loads */ + reg0 = LD_SH(tmp_buf + 3 * 32); + reg1 = LD_SH(tmp_buf + 5 * 32); + reg2 = LD_SH(tmp_buf + 11 * 32); + reg3 = LD_SH(tmp_buf + 13 * 32); + reg4 = LD_SH(tmp_buf + 19 * 32); + reg5 = LD_SH(tmp_buf + 21 * 32); + reg6 = LD_SH(tmp_buf + 27 * 32); + reg7 = LD_SH(tmp_buf + 29 * 32); + + VP9_DOTP_CONST_PAIR(reg1, reg6, cospi_27_64, cospi_5_64, reg1, reg6); + VP9_DOTP_CONST_PAIR(reg5, reg2, cospi_11_64, cospi_21_64, reg2, reg5); + VP9_DOTP_CONST_PAIR(reg3, reg4, cospi_19_64, cospi_13_64, reg3, reg4); + VP9_DOTP_CONST_PAIR(reg7, reg0, cospi_3_64, cospi_29_64, reg0, reg7); + + /* 4 Stores */ + SUB4(reg1, reg2, reg6, reg5, reg0, reg3, reg7, reg4, + vec0, vec1, vec2, vec3); + VP9_DOTP_CONST_PAIR(vec1, vec0, cospi_12_64, cospi_20_64, loc0, loc1); + VP9_DOTP_CONST_PAIR(vec3, vec2, -cospi_20_64, cospi_12_64, loc2, loc3); + BUTTERFLY_4(loc2, loc3, loc1, loc0, vec0, vec1, vec3, vec2); + ST_SH2(vec0, vec1, (tmp_odd_buf + 12 * 8), 3 * 8); + VP9_DOTP_CONST_PAIR(vec3, vec2, -cospi_8_64, cospi_24_64, vec0, vec1); + ST_SH2(vec0, vec1, (tmp_odd_buf + 10 * 8), 8); + + /* 4 Stores */ + ADD4(reg0, reg3, reg1, reg2, reg5, reg6, reg4, reg7, + vec0, vec1, vec2, vec3); + BUTTERFLY_4(vec0, vec3, vec2, vec1, reg0, reg1, reg3, reg2); + ST_SH2(reg0, reg1, (tmp_odd_buf + 13 * 8), 8); + VP9_DOTP_CONST_PAIR(reg3, reg2, -cospi_8_64, cospi_24_64, reg0, reg1); + ST_SH2(reg0, reg1, (tmp_odd_buf + 8 * 8), 8); + + /* Odd stage 3 : Dependency on Odd stage 1 & Odd stage 2 */ + /* Load 8 & Store 8 */ + LD_SH4(tmp_odd_buf, 8, reg0, reg1, reg2, reg3); + LD_SH4((tmp_odd_buf + 8 * 8), 8, reg4, reg5, reg6, reg7); + + ADD4(reg0, reg4, reg1, reg5, reg2, reg6, reg3, reg7, + loc0, loc1, loc2, loc3); + ST_SH4(loc0, loc1, loc2, loc3, tmp_odd_buf, 8); + + SUB2(reg0, reg4, reg1, reg5, vec0, vec1); + VP9_DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, loc0, loc1); + + SUB2(reg2, reg6, reg3, reg7, vec0, vec1); + VP9_DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, loc2, loc3); + ST_SH4(loc0, loc1, loc2, loc3, (tmp_odd_buf + 8 * 8), 8); + + /* Load 8 & Store 8 */ + LD_SH4((tmp_odd_buf + 4 * 8), 8, reg1, reg2, reg0, reg3); + LD_SH4((tmp_odd_buf + 12 * 8), 8, reg4, reg5, reg6, reg7); + + ADD4(reg0, reg4, reg1, reg5, reg2, reg6, reg3, reg7, + loc0, loc1, loc2, loc3); + ST_SH4(loc0, loc1, loc2, loc3, (tmp_odd_buf + 4 * 8), 8); + + SUB2(reg0, reg4, reg3, reg7, vec0, vec1); + VP9_DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, loc0, loc1); + + SUB2(reg1, reg5, reg2, reg6, vec0, vec1); + VP9_DOTP_CONST_PAIR(vec1, vec0, cospi_16_64, cospi_16_64, loc2, loc3); + ST_SH4(loc0, loc1, loc2, loc3, (tmp_odd_buf + 12 * 8), 8); +} + +static void vp9_idct8x32_column_butterfly_addblk(int16_t *tmp_eve_buf, + int16_t *tmp_odd_buf, + uint8_t *dst, + int32_t dst_stride) +{ + v8i16 vec0, vec1, vec2, vec3, loc0, loc1, loc2, loc3; + v8i16 m0, m1, m2, m3, m4, m5, m6, m7, n0, n1, n2, n3, n4, n5, n6, n7; + + /* FINAL BUTTERFLY : Dependency on Even & Odd */ + vec0 = LD_SH(tmp_odd_buf); + vec1 = LD_SH(tmp_odd_buf + 9 * 8); + vec2 = LD_SH(tmp_odd_buf + 14 * 8); + vec3 = LD_SH(tmp_odd_buf + 6 * 8); + loc0 = LD_SH(tmp_eve_buf); + loc1 = LD_SH(tmp_eve_buf + 8 * 8); + loc2 = LD_SH(tmp_eve_buf + 4 * 8); + loc3 = LD_SH(tmp_eve_buf + 12 * 8); + + ADD4(loc0, vec3, loc1, vec2, loc2, vec1, loc3, vec0, m0, m4, m2, m6); + SRARI_H4_SH(m0, m2, m4, m6, 6); + VP9_ADDBLK_ST8x4_UB(dst, (4 * dst_stride), m0, m2, m4, m6); + + SUB4(loc0, vec3, loc1, vec2, loc2, vec1, loc3, vec0, m6, m2, m4, m0); + SRARI_H4_SH(m0, m2, m4, m6, 6); + VP9_ADDBLK_ST8x4_UB((dst + 19 * dst_stride), (4 * dst_stride), + m0, m2, m4, m6); + + /* Load 8 & Store 8 */ + vec0 = LD_SH(tmp_odd_buf + 4 * 8); + vec1 = LD_SH(tmp_odd_buf + 13 * 8); + vec2 = LD_SH(tmp_odd_buf + 10 * 8); + vec3 = LD_SH(tmp_odd_buf + 3 * 8); + loc0 = LD_SH(tmp_eve_buf + 2 * 8); + loc1 = LD_SH(tmp_eve_buf + 10 * 8); + loc2 = LD_SH(tmp_eve_buf + 6 * 8); + loc3 = LD_SH(tmp_eve_buf + 14 * 8); + + ADD4(loc0, vec3, loc1, vec2, loc2, vec1, loc3, vec0, m1, m5, m3, m7); + SRARI_H4_SH(m1, m3, m5, m7, 6); + VP9_ADDBLK_ST8x4_UB((dst + 2 * dst_stride), (4 * dst_stride), + m1, m3, m5, m7); + + SUB4(loc0, vec3, loc1, vec2, loc2, vec1, loc3, vec0, m7, m3, m5, m1); + SRARI_H4_SH(m1, m3, m5, m7, 6); + VP9_ADDBLK_ST8x4_UB((dst + 17 * dst_stride), (4 * dst_stride), + m1, m3, m5, m7); + + /* Load 8 & Store 8 */ + vec0 = LD_SH(tmp_odd_buf + 2 * 8); + vec1 = LD_SH(tmp_odd_buf + 11 * 8); + vec2 = LD_SH(tmp_odd_buf + 12 * 8); + vec3 = LD_SH(tmp_odd_buf + 7 * 8); + loc0 = LD_SH(tmp_eve_buf + 1 * 8); + loc1 = LD_SH(tmp_eve_buf + 9 * 8); + loc2 = LD_SH(tmp_eve_buf + 5 * 8); + loc3 = LD_SH(tmp_eve_buf + 13 * 8); + + ADD4(loc0, vec3, loc1, vec2, loc2, vec1, loc3, vec0, n0, n4, n2, n6); + SRARI_H4_SH(n0, n2, n4, n6, 6); + VP9_ADDBLK_ST8x4_UB((dst + 1 * dst_stride), (4 * dst_stride), + n0, n2, n4, n6); + + SUB4(loc0, vec3, loc1, vec2, loc2, vec1, loc3, vec0, n6, n2, n4, n0); + SRARI_H4_SH(n0, n2, n4, n6, 6); + VP9_ADDBLK_ST8x4_UB((dst + 18 * dst_stride), (4 * dst_stride), + n0, n2, n4, n6); + + /* Load 8 & Store 8 */ + vec0 = LD_SH(tmp_odd_buf + 5 * 8); + vec1 = LD_SH(tmp_odd_buf + 15 * 8); + vec2 = LD_SH(tmp_odd_buf + 8 * 8); + vec3 = LD_SH(tmp_odd_buf + 1 * 8); + loc0 = LD_SH(tmp_eve_buf + 3 * 8); + loc1 = LD_SH(tmp_eve_buf + 11 * 8); + loc2 = LD_SH(tmp_eve_buf + 7 * 8); + loc3 = LD_SH(tmp_eve_buf + 15 * 8); + + ADD4(loc0, vec3, loc1, vec2, loc2, vec1, loc3, vec0, n1, n5, n3, n7); + SRARI_H4_SH(n1, n3, n5, n7, 6); + VP9_ADDBLK_ST8x4_UB((dst + 3 * dst_stride), (4 * dst_stride), + n1, n3, n5, n7); + + SUB4(loc0, vec3, loc1, vec2, loc2, vec1, loc3, vec0, n7, n3, n5, n1); + SRARI_H4_SH(n1, n3, n5, n7, 6); + VP9_ADDBLK_ST8x4_UB((dst + 16 * dst_stride), (4 * dst_stride), + n1, n3, n5, n7); +} + +static void vp9_idct8x32_1d_columns_addblk_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + int16_t tmp_odd_buf[16 * 8] ALLOC_ALIGNED(ALIGNMENT); + int16_t tmp_eve_buf[16 * 8] ALLOC_ALIGNED(ALIGNMENT); + + vp9_idct8x32_column_even_process_store(input, &tmp_eve_buf[0]); + vp9_idct8x32_column_odd_process_store(input, &tmp_odd_buf[0]); + vp9_idct8x32_column_butterfly_addblk(&tmp_eve_buf[0], &tmp_odd_buf[0], + dst, dst_stride); +} + +static void vp9_idct8x32_1d_columns_msa(int16_t *input, int16_t *output, + int16_t *tmp_buf) +{ + int16_t tmp_odd_buf[16 * 8] ALLOC_ALIGNED(ALIGNMENT); + int16_t tmp_eve_buf[16 * 8] ALLOC_ALIGNED(ALIGNMENT); + + vp9_idct8x32_column_even_process_store(input, &tmp_eve_buf[0]); + vp9_idct8x32_column_odd_process_store(input, &tmp_odd_buf[0]); + vp9_idct_butterfly_transpose_store(tmp_buf, &tmp_eve_buf[0], + &tmp_odd_buf[0], output); +} + +static void vp9_idct32x32_1_add_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + int32_t i; + int16_t out; + v16u8 dst0, dst1, dst2, dst3, tmp0, tmp1, tmp2, tmp3; + v8i16 res0, res1, res2, res3, res4, res5, res6, res7, vec; + + out = ROUND_POWER_OF_TWO((input[0] * cospi_16_64), VP9_DCT_CONST_BITS); + out = ROUND_POWER_OF_TWO((out * cospi_16_64), VP9_DCT_CONST_BITS); + out = ROUND_POWER_OF_TWO(out, 6); + + vec = __msa_fill_h(out); + + for (i = 16; i--;) + { + LD_UB2(dst, 16, dst0, dst1); + LD_UB2(dst + dst_stride, 16, dst2, dst3); + + UNPCK_UB_SH(dst0, res0, res4); + UNPCK_UB_SH(dst1, res1, res5); + UNPCK_UB_SH(dst2, res2, res6); + UNPCK_UB_SH(dst3, res3, res7); + ADD4(res0, vec, res1, vec, res2, vec, res3, vec, res0, res1, res2, + res3); + ADD4(res4, vec, res5, vec, res6, vec, res7, vec, res4, res5, res6, + res7); + CLIP_SH4_0_255(res0, res1, res2, res3); + CLIP_SH4_0_255(res4, res5, res6, res7); + PCKEV_B4_UB(res4, res0, res5, res1, res6, res2, res7, res3, + tmp0, tmp1, tmp2, tmp3); + + ST_UB2(tmp0, tmp1, dst, 16); + dst += dst_stride; + ST_UB2(tmp2, tmp3, dst, 16); + dst += dst_stride; + } +} + +static void vp9_idct32x32_34_colcol_addblk_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + int32_t i; + int16_t out_arr[32 * 32] ALLOC_ALIGNED(ALIGNMENT); + int16_t *out_ptr = out_arr; + int16_t tmp_buf[8 * 32] ALLOC_ALIGNED(ALIGNMENT); + + for (i = 32; i--;) { + __asm__ volatile ( + "sw $zero, (%[out_ptr]) \n\t" + "sw $zero, 4(%[out_ptr]) \n\t" + "sw $zero, 8(%[out_ptr]) \n\t" + "sw $zero, 12(%[out_ptr]) \n\t" + "sw $zero, 16(%[out_ptr]) \n\t" + "sw $zero, 20(%[out_ptr]) \n\t" + "sw $zero, 24(%[out_ptr]) \n\t" + "sw $zero, 28(%[out_ptr]) \n\t" + "sw $zero, 32(%[out_ptr]) \n\t" + "sw $zero, 36(%[out_ptr]) \n\t" + "sw $zero, 40(%[out_ptr]) \n\t" + "sw $zero, 44(%[out_ptr]) \n\t" + "sw $zero, 48(%[out_ptr]) \n\t" + "sw $zero, 52(%[out_ptr]) \n\t" + "sw $zero, 56(%[out_ptr]) \n\t" + "sw $zero, 60(%[out_ptr]) \n\t" + + : + : [out_ptr] "r" (out_ptr) + ); + + out_ptr += 32; + } + + out_ptr = out_arr; + + /* process 8*32 block */ + vp9_idct8x32_1d_columns_msa(input, out_ptr, &tmp_buf[0]); + + /* transform columns */ + for (i = 0; i < 4; i++) { + /* process 8*32 block */ + vp9_idct8x32_1d_columns_addblk_msa((out_ptr + (i << 3)), + (dst + (i << 3)), dst_stride); + } +} + +static void vp9_idct32x32_colcol_addblk_msa(int16_t *input, uint8_t *dst, + int32_t dst_stride) +{ + int32_t i; + int16_t out_arr[32 * 32] ALLOC_ALIGNED(ALIGNMENT); + int16_t *out_ptr = out_arr; + int16_t tmp_buf[8 * 32] ALLOC_ALIGNED(ALIGNMENT); + + /* transform rows */ + for (i = 0; i < 4; i++) { + /* process 8*32 block */ + vp9_idct8x32_1d_columns_msa((input + (i << 3)), (out_ptr + (i << 8)), + &tmp_buf[0]); + } + + /* transform columns */ + for (i = 0; i < 4; i++) { + /* process 8*32 block */ + vp9_idct8x32_1d_columns_addblk_msa((out_ptr + (i << 3)), + (dst + (i << 3)), dst_stride); + } +} + +void ff_idct_idct_4x4_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob) +{ + if (eob > 1) { + vp9_idct4x4_colcol_addblk_msa(block, dst, stride); + memset(block, 0, 4 * 4 * sizeof(*block)); + } + else { + vp9_idct4x4_1_add_msa(block, dst, stride); + block[0] = 0; + } +} + +void ff_idct_idct_8x8_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob) +{ + if (eob == 1) { + vp9_idct8x8_1_add_msa(block, dst, stride); + block[0] = 0; + } + else if (eob <= 12) { + vp9_idct8x8_12_colcol_addblk_msa(block, dst, stride); + memset(block, 0, 4 * 8 * sizeof(*block)); + } + else { + vp9_idct8x8_colcol_addblk_msa(block, dst, stride); + memset(block, 0, 8 * 8 * sizeof(*block)); + } +} + +void ff_idct_idct_16x16_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob) +{ + int i; + + if (eob == 1) { + /* DC only DCT coefficient. */ + vp9_idct16x16_1_add_msa(block, dst, stride); + block[0] = 0; + } + else if (eob <= 10) { + vp9_idct16x16_10_colcol_addblk_msa(block, dst, stride); + for (i = 0; i < 4; ++i) { + memset(block, 0, 4 * sizeof(*block)); + block += 16; + } + } + else { + vp9_idct16x16_colcol_addblk_msa(block, dst, stride); + memset(block, 0, 16 * 16 * sizeof(*block)); + } +} + +void ff_idct_idct_32x32_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob) +{ + int i; + + if (eob == 1) { + vp9_idct32x32_1_add_msa(block, dst, stride); + block[0] = 0; + } + else if (eob <= 34) { + vp9_idct32x32_34_colcol_addblk_msa(block, dst, stride); + for (i = 0; i < 8; ++i) { + memset(block, 0, 8 * sizeof(*block)); + block += 32; + } + } + else { + vp9_idct32x32_colcol_addblk_msa(block, dst, stride); + memset(block, 0, 32 * 32 * sizeof(*block)); + } +} + +void ff_iadst_iadst_4x4_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob) +{ + vp9_iadst4x4_colcol_addblk_msa(block, dst, stride); + memset(block, 0, 4 * 4 * sizeof(*block)); +} + +void ff_iadst_iadst_8x8_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob) +{ + vp9_iadst8x8_colcol_addblk_msa(block, dst, stride); + memset(block, 0, 8 * 8 * sizeof(*block)); +} + +void ff_iadst_iadst_16x16_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob) +{ + vp9_iadst16x16_colcol_addblk_msa(block, dst, stride); + memset(block, 0, 16 * 16 * sizeof(*block)); +} + +void ff_idct_iadst_4x4_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob) +{ + vp9_idct_iadst_4x4_add_msa(block, dst, stride, eob); + memset(block, 0, 4 * 4 * sizeof(*block)); +} + +void ff_idct_iadst_8x8_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob) +{ + vp9_idct_iadst_8x8_add_msa(block, dst, stride, eob); + memset(block, 0, 8 * 8 * sizeof(*block)); +} + +void ff_idct_iadst_16x16_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob) +{ + vp9_idct_iadst_16x16_add_msa(block, dst, stride, eob); + memset(block, 0, 16 * 16 * sizeof(*block)); +} + +void ff_iadst_idct_4x4_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob) +{ + vp9_iadst_idct_4x4_add_msa(block, dst, stride, eob); + memset(block, 0, 4 * 4 * sizeof(*block)); +} + +void ff_iadst_idct_8x8_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob) +{ + vp9_iadst_idct_8x8_add_msa(block, dst, stride, eob); + memset(block, 0, 8 * 8 * sizeof(*block)); +} + +void ff_iadst_idct_16x16_add_msa(uint8_t *dst, ptrdiff_t stride, + int16_t *block, int eob) +{ + vp9_iadst_idct_16x16_add_msa(block, dst, stride, eob); + memset(block, 0, 16 * 16 * sizeof(*block)); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp9_intra_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp9_intra_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp9_intra_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp9_intra_msa.c 2015-07-25 17:20:02.000000000 +0000 @@ -0,0 +1,533 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/vp9dsp.h" +#include "libavutil/mips/generic_macros_msa.h" +#include "vp9dsp_mips.h" + +#define IPRED_SUBS_UH2_UH(in0, in1, out0, out1) \ +{ \ + out0 = __msa_subs_u_h(out0, in0); \ + out1 = __msa_subs_u_h(out1, in1); \ +} + +void ff_vert_16x16_msa(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *left, + const uint8_t *src) +{ + uint32_t row; + v16u8 src0; + + src0 = LD_UB(src); + + for (row = 16; row--;) { + ST_UB(src0, dst); + dst += dst_stride; + } +} + +void ff_vert_32x32_msa(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *left, + const uint8_t *src) +{ + uint32_t row; + v16u8 src1, src2; + + src1 = LD_UB(src); + src2 = LD_UB(src + 16); + + for (row = 32; row--;) { + ST_UB2(src1, src2, dst, 16); + dst += dst_stride; + } +} + +void ff_hor_16x16_msa(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, + const uint8_t *top) +{ + uint32_t row, inp; + v16u8 src0, src1, src2, src3; + + src += 12; + for (row = 4; row--;) { + inp = LW(src); + src -= 4; + + src0 = (v16u8) __msa_fill_b(inp >> 24); + src1 = (v16u8) __msa_fill_b(inp >> 16); + src2 = (v16u8) __msa_fill_b(inp >> 8); + src3 = (v16u8) __msa_fill_b(inp); + + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +void ff_hor_32x32_msa(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, + const uint8_t *top) +{ + uint32_t row, inp; + v16u8 src0, src1, src2, src3; + + src += 28; + for (row = 8; row--;) { + inp = LW(src); + src -= 4; + + src0 = (v16u8) __msa_fill_b(inp >> 24); + src1 = (v16u8) __msa_fill_b(inp >> 16); + src2 = (v16u8) __msa_fill_b(inp >> 8); + src3 = (v16u8) __msa_fill_b(inp); + + ST_UB2(src0, src0, dst, 16); + dst += dst_stride; + ST_UB2(src1, src1, dst, 16); + dst += dst_stride; + ST_UB2(src2, src2, dst, 16); + dst += dst_stride; + ST_UB2(src3, src3, dst, 16); + dst += dst_stride; + } +} + +void ff_dc_4x4_msa(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src_left, + const uint8_t *src_top) +{ + uint32_t val0, val1; + v16i8 store, src = { 0 }; + v8u16 sum_h; + v4u32 sum_w; + v2u64 sum_d; + + val0 = LW(src_top); + val1 = LW(src_left); + INSERT_W2_SB(val0, val1, src); + sum_h = __msa_hadd_u_h((v16u8) src, (v16u8) src); + sum_w = __msa_hadd_u_w(sum_h, sum_h); + sum_d = __msa_hadd_u_d(sum_w, sum_w); + sum_w = (v4u32) __msa_srari_w((v4i32) sum_d, 3); + store = __msa_splati_b((v16i8) sum_w, 0); + val0 = __msa_copy_u_w((v4i32) store, 0); + + SW4(val0, val0, val0, val0, dst, dst_stride); +} + +#define INTRA_DC_TL_4x4(dir) \ +void ff_dc_##dir##_4x4_msa(uint8_t *dst, ptrdiff_t dst_stride, \ + const uint8_t *left, \ + const uint8_t *top) \ +{ \ + uint32_t val0; \ + v16i8 store, data = { 0 }; \ + v8u16 sum_h; \ + v4u32 sum_w; \ + \ + val0 = LW(dir); \ + data = (v16i8) __msa_insert_w((v4i32) data, 0, val0); \ + sum_h = __msa_hadd_u_h((v16u8) data, (v16u8) data); \ + sum_w = __msa_hadd_u_w(sum_h, sum_h); \ + sum_w = (v4u32) __msa_srari_w((v4i32) sum_w, 2); \ + store = __msa_splati_b((v16i8) sum_w, 0); \ + val0 = __msa_copy_u_w((v4i32) store, 0); \ + \ + SW4(val0, val0, val0, val0, dst, dst_stride); \ +} +INTRA_DC_TL_4x4(top); +INTRA_DC_TL_4x4(left); + +void ff_dc_8x8_msa(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src_left, + const uint8_t *src_top) +{ + uint64_t val0, val1; + v16i8 store; + v16u8 src = { 0 }; + v8u16 sum_h; + v4u32 sum_w; + v2u64 sum_d; + + val0 = LD(src_top); + val1 = LD(src_left); + INSERT_D2_UB(val0, val1, src); + sum_h = __msa_hadd_u_h(src, src); + sum_w = __msa_hadd_u_w(sum_h, sum_h); + sum_d = __msa_hadd_u_d(sum_w, sum_w); + sum_w = (v4u32) __msa_pckev_w((v4i32) sum_d, (v4i32) sum_d); + sum_d = __msa_hadd_u_d(sum_w, sum_w); + sum_w = (v4u32) __msa_srari_w((v4i32) sum_d, 4); + store = __msa_splati_b((v16i8) sum_w, 0); + val0 = __msa_copy_u_d((v2i64) store, 0); + + SD4(val0, val0, val0, val0, dst, dst_stride); + dst += (4 * dst_stride); + SD4(val0, val0, val0, val0, dst, dst_stride); +} + +#define INTRA_DC_TL_8x8(dir) \ +void ff_dc_##dir##_8x8_msa(uint8_t *dst, ptrdiff_t dst_stride, \ + const uint8_t *left, \ + const uint8_t *top) \ +{ \ + uint64_t val0; \ + v16i8 store; \ + v16u8 data = { 0 }; \ + v8u16 sum_h; \ + v4u32 sum_w; \ + v2u64 sum_d; \ + \ + val0 = LD(dir); \ + data = (v16u8) __msa_insert_d((v2i64) data, 0, val0); \ + sum_h = __msa_hadd_u_h(data, data); \ + sum_w = __msa_hadd_u_w(sum_h, sum_h); \ + sum_d = __msa_hadd_u_d(sum_w, sum_w); \ + sum_w = (v4u32) __msa_srari_w((v4i32) sum_d, 3); \ + store = __msa_splati_b((v16i8) sum_w, 0); \ + val0 = __msa_copy_u_d((v2i64) store, 0); \ + \ + SD4(val0, val0, val0, val0, dst, dst_stride); \ + dst += (4 * dst_stride); \ + SD4(val0, val0, val0, val0, dst, dst_stride); \ +} + +INTRA_DC_TL_8x8(top); +INTRA_DC_TL_8x8(left); + +void ff_dc_16x16_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src_left, const uint8_t *src_top) +{ + v16u8 top, left, out; + v8u16 sum_h, sum_top, sum_left; + v4u32 sum_w; + v2u64 sum_d; + + top = LD_UB(src_top); + left = LD_UB(src_left); + HADD_UB2_UH(top, left, sum_top, sum_left); + sum_h = sum_top + sum_left; + sum_w = __msa_hadd_u_w(sum_h, sum_h); + sum_d = __msa_hadd_u_d(sum_w, sum_w); + sum_w = (v4u32) __msa_pckev_w((v4i32) sum_d, (v4i32) sum_d); + sum_d = __msa_hadd_u_d(sum_w, sum_w); + sum_w = (v4u32) __msa_srari_w((v4i32) sum_d, 5); + out = (v16u8) __msa_splati_b((v16i8) sum_w, 0); + + ST_UB8(out, out, out, out, out, out, out, out, dst, dst_stride); + dst += (8 * dst_stride); + ST_UB8(out, out, out, out, out, out, out, out, dst, dst_stride); +} + +#define INTRA_DC_TL_16x16(dir) \ +void ff_dc_##dir##_16x16_msa(uint8_t *dst, ptrdiff_t dst_stride, \ + const uint8_t *left, \ + const uint8_t *top) \ +{ \ + v16u8 data, out; \ + v8u16 sum_h; \ + v4u32 sum_w; \ + v2u64 sum_d; \ + \ + data = LD_UB(dir); \ + sum_h = __msa_hadd_u_h(data, data); \ + sum_w = __msa_hadd_u_w(sum_h, sum_h); \ + sum_d = __msa_hadd_u_d(sum_w, sum_w); \ + sum_w = (v4u32) __msa_pckev_w((v4i32) sum_d, (v4i32) sum_d); \ + sum_d = __msa_hadd_u_d(sum_w, sum_w); \ + sum_w = (v4u32) __msa_srari_w((v4i32) sum_d, 4); \ + out = (v16u8) __msa_splati_b((v16i8) sum_w, 0); \ + \ + ST_UB8(out, out, out, out, out, out, out, out, dst, dst_stride); \ + dst += (8 * dst_stride); \ + ST_UB8(out, out, out, out, out, out, out, out, dst, dst_stride); \ +} +INTRA_DC_TL_16x16(top); +INTRA_DC_TL_16x16(left); + +void ff_dc_32x32_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src_left, const uint8_t *src_top) +{ + uint32_t row; + v16u8 top0, top1, left0, left1, out; + v8u16 sum_h, sum_top0, sum_top1, sum_left0, sum_left1; + v4u32 sum_w; + v2u64 sum_d; + + LD_UB2(src_top, 16, top0, top1); + LD_UB2(src_left, 16, left0, left1); + HADD_UB2_UH(top0, top1, sum_top0, sum_top1); + HADD_UB2_UH(left0, left1, sum_left0, sum_left1); + sum_h = sum_top0 + sum_top1; + sum_h += sum_left0 + sum_left1; + sum_w = __msa_hadd_u_w(sum_h, sum_h); + sum_d = __msa_hadd_u_d(sum_w, sum_w); + sum_w = (v4u32) __msa_pckev_w((v4i32) sum_d, (v4i32) sum_d); + sum_d = __msa_hadd_u_d(sum_w, sum_w); + sum_w = (v4u32) __msa_srari_w((v4i32) sum_d, 6); + out = (v16u8) __msa_splati_b((v16i8) sum_w, 0); + + for (row = 16; row--;) + { + ST_UB2(out, out, dst, 16); + dst += dst_stride; + ST_UB2(out, out, dst, 16); + dst += dst_stride; + } +} + +#define INTRA_DC_TL_32x32(dir) \ +void ff_dc_##dir##_32x32_msa(uint8_t *dst, ptrdiff_t dst_stride, \ + const uint8_t *left, \ + const uint8_t *top) \ +{ \ + uint32_t row; \ + v16u8 data0, data1, out; \ + v8u16 sum_h, sum_data0, sum_data1; \ + v4u32 sum_w; \ + v2u64 sum_d; \ + \ + LD_UB2(dir, 16, data0, data1); \ + HADD_UB2_UH(data0, data1, sum_data0, sum_data1); \ + sum_h = sum_data0 + sum_data1; \ + sum_w = __msa_hadd_u_w(sum_h, sum_h); \ + sum_d = __msa_hadd_u_d(sum_w, sum_w); \ + sum_w = (v4u32) __msa_pckev_w((v4i32) sum_d, (v4i32) sum_d); \ + sum_d = __msa_hadd_u_d(sum_w, sum_w); \ + sum_w = (v4u32) __msa_srari_w((v4i32) sum_d, 5); \ + out = (v16u8) __msa_splati_b((v16i8) sum_w, 0); \ + \ + for (row = 16; row--;) \ + { \ + ST_UB2(out, out, dst, 16); \ + dst += dst_stride; \ + ST_UB2(out, out, dst, 16); \ + dst += dst_stride; \ + } \ +} +INTRA_DC_TL_32x32(top); +INTRA_DC_TL_32x32(left); + +#define INTRA_PREDICT_VALDC_16X16_MSA(val) \ +void ff_dc_##val##_16x16_msa(uint8_t *dst, ptrdiff_t dst_stride, \ + const uint8_t *left, const uint8_t *top) \ +{ \ + v16u8 out = (v16u8) __msa_ldi_b(val); \ + \ + ST_UB8(out, out, out, out, out, out, out, out, dst, dst_stride); \ + dst += (8 * dst_stride); \ + ST_UB8(out, out, out, out, out, out, out, out, dst, dst_stride); \ +} + +INTRA_PREDICT_VALDC_16X16_MSA(127); +INTRA_PREDICT_VALDC_16X16_MSA(128); +INTRA_PREDICT_VALDC_16X16_MSA(129); + +#define INTRA_PREDICT_VALDC_32X32_MSA(val) \ +void ff_dc_##val##_32x32_msa(uint8_t *dst, ptrdiff_t dst_stride, \ + const uint8_t *left, const uint8_t *top) \ +{ \ + uint32_t row; \ + v16u8 out = (v16u8) __msa_ldi_b(val); \ + \ + for (row = 16; row--;) \ + { \ + ST_UB2(out, out, dst, 16); \ + dst += dst_stride; \ + ST_UB2(out, out, dst, 16); \ + dst += dst_stride; \ + } \ +} + +INTRA_PREDICT_VALDC_32X32_MSA(127); +INTRA_PREDICT_VALDC_32X32_MSA(128); +INTRA_PREDICT_VALDC_32X32_MSA(129); + +void ff_tm_4x4_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src_left, const uint8_t *src_top_ptr) +{ + uint32_t left; + uint8_t top_left = src_top_ptr[-1]; + v16i8 src_top, src_left0, src_left1, src_left2, src_left3, tmp0, tmp1; + v16u8 src0, src1, src2, src3; + v8u16 src_top_left, vec0, vec1, vec2, vec3; + + src_top_left = (v8u16) __msa_fill_h(top_left); + src_top = LD_SB(src_top_ptr); + left = LW(src_left); + src_left0 = __msa_fill_b(left >> 24); + src_left1 = __msa_fill_b(left >> 16); + src_left2 = __msa_fill_b(left >> 8); + src_left3 = __msa_fill_b(left); + + ILVR_B4_UB(src_left0, src_top, src_left1, src_top, src_left2, src_top, + src_left3, src_top, src0, src1, src2, src3); + HADD_UB4_UH(src0, src1, src2, src3, vec0, vec1, vec2, vec3); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, vec0, vec1); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, vec2, vec3); + SAT_UH4_UH(vec0, vec1, vec2, vec3, 7); + PCKEV_B2_SB(vec1, vec0, vec3, vec2, tmp0, tmp1); + ST4x4_UB(tmp0, tmp1, 0, 2, 0, 2, dst, dst_stride); +} + +void ff_tm_8x8_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src_left, const uint8_t *src_top_ptr) +{ + uint8_t top_left = src_top_ptr[-1]; + uint32_t loop_cnt, left; + v16i8 src_top, src_left0, src_left1, src_left2, src_left3, tmp0, tmp1; + v8u16 src_top_left, vec0, vec1, vec2, vec3; + v16u8 src0, src1, src2, src3; + + src_top = LD_SB(src_top_ptr); + src_top_left = (v8u16) __msa_fill_h(top_left); + + src_left += 4; + for (loop_cnt = 2; loop_cnt--;) { + left = LW(src_left); + src_left0 = __msa_fill_b(left >> 24); + src_left1 = __msa_fill_b(left >> 16); + src_left2 = __msa_fill_b(left >> 8); + src_left3 = __msa_fill_b(left); + src_left -= 4; + + ILVR_B4_UB(src_left0, src_top, src_left1, src_top, src_left2, src_top, + src_left3, src_top, src0, src1, src2, src3); + HADD_UB4_UH(src0, src1, src2, src3, vec0, vec1, vec2, vec3); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, vec0, vec1); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, vec2, vec3); + SAT_UH4_UH(vec0, vec1, vec2, vec3, 7); + PCKEV_B2_SB(vec1, vec0, vec3, vec2, tmp0, tmp1); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +void ff_tm_16x16_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src_left, const uint8_t *src_top_ptr) +{ + uint8_t top_left = src_top_ptr[-1]; + uint32_t loop_cnt, left; + v16i8 src_top, src_left0, src_left1, src_left2, src_left3; + v8u16 src_top_left, res_r, res_l; + + src_top = LD_SB(src_top_ptr); + src_top_left = (v8u16) __msa_fill_h(top_left); + + src_left += 12; + for (loop_cnt = 4; loop_cnt--;) { + left = LW(src_left); + src_left0 = __msa_fill_b(left >> 24); + src_left1 = __msa_fill_b(left >> 16); + src_left2 = __msa_fill_b(left >> 8); + src_left3 = __msa_fill_b(left); + src_left -= 4; + + ILVRL_B2_UH(src_left0, src_top, res_r, res_l); + HADD_UB2_UH(res_r, res_l, res_r, res_l); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, res_r, res_l); + + SAT_UH2_UH(res_r, res_l, 7); + PCKEV_ST_SB(res_r, res_l, dst); + dst += dst_stride; + + ILVRL_B2_UH(src_left1, src_top, res_r, res_l); + HADD_UB2_UH(res_r, res_l, res_r, res_l); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, res_r, res_l); + SAT_UH2_UH(res_r, res_l, 7); + PCKEV_ST_SB(res_r, res_l, dst); + dst += dst_stride; + + ILVRL_B2_UH(src_left2, src_top, res_r, res_l); + HADD_UB2_UH(res_r, res_l, res_r, res_l); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, res_r, res_l); + SAT_UH2_UH(res_r, res_l, 7); + PCKEV_ST_SB(res_r, res_l, dst); + dst += dst_stride; + + ILVRL_B2_UH(src_left3, src_top, res_r, res_l); + HADD_UB2_UH(res_r, res_l, res_r, res_l); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, res_r, res_l); + SAT_UH2_UH(res_r, res_l, 7); + PCKEV_ST_SB(res_r, res_l, dst); + dst += dst_stride; + } +} + +void ff_tm_32x32_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src_left, const uint8_t *src_top_ptr) +{ + uint8_t top_left = src_top_ptr[-1]; + uint32_t loop_cnt, left; + v16i8 src_top0, src_top1, src_left0, src_left1, src_left2, src_left3; + v8u16 src_top_left, res_r0, res_r1, res_l0, res_l1; + + src_top0 = LD_SB(src_top_ptr); + src_top1 = LD_SB(src_top_ptr + 16); + src_top_left = (v8u16) __msa_fill_h(top_left); + + src_left += 28; + for (loop_cnt = 8; loop_cnt--;) { + left = LW(src_left); + src_left0 = __msa_fill_b(left >> 24); + src_left1 = __msa_fill_b(left >> 16); + src_left2 = __msa_fill_b(left >> 8); + src_left3 = __msa_fill_b(left); + src_left -= 4; + + ILVR_B2_UH(src_left0, src_top0, src_left0, src_top1, res_r0, res_r1); + ILVL_B2_UH(src_left0, src_top0, src_left0, src_top1, res_l0, res_l1); + HADD_UB4_UH(res_r0, res_l0, res_r1, res_l1, res_r0, res_l0, res_r1, + res_l1); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, res_r0, res_l0); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, res_r1, res_l1); + SAT_UH4_UH(res_r0, res_l0, res_r1, res_l1, 7); + PCKEV_ST_SB(res_r0, res_l0, dst); + PCKEV_ST_SB(res_r1, res_l1, dst + 16); + dst += dst_stride; + + ILVR_B2_UH(src_left1, src_top0, src_left1, src_top1, res_r0, res_r1); + ILVL_B2_UH(src_left1, src_top0, src_left1, src_top1, res_l0, res_l1); + HADD_UB4_UH(res_r0, res_l0, res_r1, res_l1, res_r0, res_l0, res_r1, + res_l1); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, res_r0, res_l0); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, res_r1, res_l1); + SAT_UH4_UH(res_r0, res_l0, res_r1, res_l1, 7); + PCKEV_ST_SB(res_r0, res_l0, dst); + PCKEV_ST_SB(res_r1, res_l1, dst + 16); + dst += dst_stride; + + ILVR_B2_UH(src_left2, src_top0, src_left2, src_top1, res_r0, res_r1); + ILVL_B2_UH(src_left2, src_top0, src_left2, src_top1, res_l0, res_l1); + HADD_UB4_UH(res_r0, res_l0, res_r1, res_l1, res_r0, res_l0, res_r1, + res_l1); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, res_r0, res_l0); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, res_r1, res_l1); + SAT_UH4_UH(res_r0, res_l0, res_r1, res_l1, 7); + PCKEV_ST_SB(res_r0, res_l0, dst); + PCKEV_ST_SB(res_r1, res_l1, dst + 16); + dst += dst_stride; + + ILVR_B2_UH(src_left3, src_top0, src_left3, src_top1, res_r0, res_r1); + ILVL_B2_UH(src_left3, src_top0, src_left3, src_top1, res_l0, res_l1); + HADD_UB4_UH(res_r0, res_l0, res_r1, res_l1, res_r0, res_l0, res_r1, + res_l1); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, res_r0, res_l0); + IPRED_SUBS_UH2_UH(src_top_left, src_top_left, res_r1, res_l1); + SAT_UH4_UH(res_r0, res_l0, res_r1, res_l1, 7); + PCKEV_ST_SB(res_r0, res_l0, dst); + PCKEV_ST_SB(res_r1, res_l1, dst + 16); + dst += dst_stride; + } +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp9_lpf_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp9_lpf_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp9_lpf_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp9_lpf_msa.c 2015-07-23 17:20:03.000000000 +0000 @@ -0,0 +1,2599 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/vp9dsp.h" +#include "libavutil/mips/generic_macros_msa.h" +#include "vp9dsp_mips.h" + +#define VP9_LPF_FILTER4_8W(p1_in, p0_in, q0_in, q1_in, mask_in, hev_in, \ + p1_out, p0_out, q0_out, q1_out) \ +{ \ + v16i8 p1_m, p0_m, q0_m, q1_m, q0_sub_p0, filt_sign; \ + v16i8 filt, filt1, filt2, cnst4b, cnst3b; \ + v8i16 q0_sub_p0_r, filt_r, cnst3h; \ + \ + p1_m = (v16i8) __msa_xori_b(p1_in, 0x80); \ + p0_m = (v16i8) __msa_xori_b(p0_in, 0x80); \ + q0_m = (v16i8) __msa_xori_b(q0_in, 0x80); \ + q1_m = (v16i8) __msa_xori_b(q1_in, 0x80); \ + \ + filt = __msa_subs_s_b(p1_m, q1_m); \ + filt = filt & (v16i8) hev_in; \ + q0_sub_p0 = q0_m - p0_m; \ + filt_sign = __msa_clti_s_b(filt, 0); \ + \ + cnst3h = __msa_ldi_h(3); \ + q0_sub_p0_r = (v8i16) __msa_ilvr_b(q0_sub_p0, q0_sub_p0); \ + q0_sub_p0_r = __msa_dotp_s_h((v16i8) q0_sub_p0_r, (v16i8) cnst3h); \ + filt_r = (v8i16) __msa_ilvr_b(filt_sign, filt); \ + filt_r += q0_sub_p0_r; \ + filt_r = __msa_sat_s_h(filt_r, 7); \ + \ + /* combine left and right part */ \ + filt = __msa_pckev_b((v16i8) filt_r, (v16i8) filt_r); \ + \ + filt = filt & (v16i8) mask_in; \ + cnst4b = __msa_ldi_b(4); \ + filt1 = __msa_adds_s_b(filt, cnst4b); \ + filt1 >>= 3; \ + \ + cnst3b = __msa_ldi_b(3); \ + filt2 = __msa_adds_s_b(filt, cnst3b); \ + filt2 >>= 3; \ + \ + q0_m = __msa_subs_s_b(q0_m, filt1); \ + q0_out = __msa_xori_b((v16u8) q0_m, 0x80); \ + p0_m = __msa_adds_s_b(p0_m, filt2); \ + p0_out = __msa_xori_b((v16u8) p0_m, 0x80); \ + \ + filt = __msa_srari_b(filt1, 1); \ + hev_in = __msa_xori_b((v16u8) hev_in, 0xff); \ + filt = filt & (v16i8) hev_in; \ + \ + q1_m = __msa_subs_s_b(q1_m, filt); \ + q1_out = __msa_xori_b((v16u8) q1_m, 0x80); \ + p1_m = __msa_adds_s_b(p1_m, filt); \ + p1_out = __msa_xori_b((v16u8) p1_m, 0x80); \ +} + +#define VP9_LPF_FILTER4_4W(p1_in, p0_in, q0_in, q1_in, mask_in, hev_in, \ + p1_out, p0_out, q0_out, q1_out) \ +{ \ + v16i8 p1_m, p0_m, q0_m, q1_m, q0_sub_p0, filt_sign; \ + v16i8 filt, filt1, filt2, cnst4b, cnst3b; \ + v8i16 q0_sub_p0_r, q0_sub_p0_l, filt_l, filt_r, cnst3h; \ + \ + p1_m = (v16i8) __msa_xori_b(p1_in, 0x80); \ + p0_m = (v16i8) __msa_xori_b(p0_in, 0x80); \ + q0_m = (v16i8) __msa_xori_b(q0_in, 0x80); \ + q1_m = (v16i8) __msa_xori_b(q1_in, 0x80); \ + \ + filt = __msa_subs_s_b(p1_m, q1_m); \ + \ + filt = filt & (v16i8) hev_in; \ + \ + q0_sub_p0 = q0_m - p0_m; \ + filt_sign = __msa_clti_s_b(filt, 0); \ + \ + cnst3h = __msa_ldi_h(3); \ + q0_sub_p0_r = (v8i16) __msa_ilvr_b(q0_sub_p0, q0_sub_p0); \ + q0_sub_p0_r = __msa_dotp_s_h((v16i8) q0_sub_p0_r, (v16i8) cnst3h); \ + filt_r = (v8i16) __msa_ilvr_b(filt_sign, filt); \ + filt_r += q0_sub_p0_r; \ + filt_r = __msa_sat_s_h(filt_r, 7); \ + \ + q0_sub_p0_l = (v8i16) __msa_ilvl_b(q0_sub_p0, q0_sub_p0); \ + q0_sub_p0_l = __msa_dotp_s_h((v16i8) q0_sub_p0_l, (v16i8) cnst3h); \ + filt_l = (v8i16) __msa_ilvl_b(filt_sign, filt); \ + filt_l += q0_sub_p0_l; \ + filt_l = __msa_sat_s_h(filt_l, 7); \ + \ + filt = __msa_pckev_b((v16i8) filt_l, (v16i8) filt_r); \ + filt = filt & (v16i8) mask_in; \ + \ + cnst4b = __msa_ldi_b(4); \ + filt1 = __msa_adds_s_b(filt, cnst4b); \ + filt1 >>= 3; \ + \ + cnst3b = __msa_ldi_b(3); \ + filt2 = __msa_adds_s_b(filt, cnst3b); \ + filt2 >>= 3; \ + \ + q0_m = __msa_subs_s_b(q0_m, filt1); \ + q0_out = __msa_xori_b((v16u8) q0_m, 0x80); \ + p0_m = __msa_adds_s_b(p0_m, filt2); \ + p0_out = __msa_xori_b((v16u8) p0_m, 0x80); \ + \ + filt = __msa_srari_b(filt1, 1); \ + hev_in = __msa_xori_b((v16u8) hev_in, 0xff); \ + filt = filt & (v16i8) hev_in; \ + \ + q1_m = __msa_subs_s_b(q1_m, filt); \ + q1_out = __msa_xori_b((v16u8) q1_m, 0x80); \ + p1_m = __msa_adds_s_b(p1_m, filt); \ + p1_out = __msa_xori_b((v16u8) p1_m, 0x80); \ +} + +#define VP9_FLAT4(p3_in, p2_in, p0_in, q0_in, q2_in, q3_in, flat_out) \ +{ \ + v16u8 tmp, p2_a_sub_p0, q2_a_sub_q0, p3_a_sub_p0, q3_a_sub_q0; \ + v16u8 zero_in = { 0 }; \ + \ + tmp = __msa_ori_b(zero_in, 1); \ + p2_a_sub_p0 = __msa_asub_u_b(p2_in, p0_in); \ + q2_a_sub_q0 = __msa_asub_u_b(q2_in, q0_in); \ + p3_a_sub_p0 = __msa_asub_u_b(p3_in, p0_in); \ + q3_a_sub_q0 = __msa_asub_u_b(q3_in, q0_in); \ + \ + p2_a_sub_p0 = __msa_max_u_b(p2_a_sub_p0, q2_a_sub_q0); \ + flat_out = __msa_max_u_b(p2_a_sub_p0, flat_out); \ + p3_a_sub_p0 = __msa_max_u_b(p3_a_sub_p0, q3_a_sub_q0); \ + flat_out = __msa_max_u_b(p3_a_sub_p0, flat_out); \ + \ + flat_out = (tmp < (v16u8) flat_out); \ + flat_out = __msa_xori_b(flat_out, 0xff); \ + flat_out = flat_out & (mask); \ +} + +#define VP9_FLAT5(p7_in, p6_in, p5_in, p4_in, p0_in, q0_in, q4_in, \ + q5_in, q6_in, q7_in, flat_in, flat2_out) \ +{ \ + v16u8 tmp, zero_in = { 0 }; \ + v16u8 p4_a_sub_p0, q4_a_sub_q0, p5_a_sub_p0, q5_a_sub_q0; \ + v16u8 p6_a_sub_p0, q6_a_sub_q0, p7_a_sub_p0, q7_a_sub_q0; \ + \ + tmp = __msa_ori_b(zero_in, 1); \ + p4_a_sub_p0 = __msa_asub_u_b(p4_in, p0_in); \ + q4_a_sub_q0 = __msa_asub_u_b(q4_in, q0_in); \ + p5_a_sub_p0 = __msa_asub_u_b(p5_in, p0_in); \ + q5_a_sub_q0 = __msa_asub_u_b(q5_in, q0_in); \ + p6_a_sub_p0 = __msa_asub_u_b(p6_in, p0_in); \ + q6_a_sub_q0 = __msa_asub_u_b(q6_in, q0_in); \ + p7_a_sub_p0 = __msa_asub_u_b(p7_in, p0_in); \ + q7_a_sub_q0 = __msa_asub_u_b(q7_in, q0_in); \ + \ + p4_a_sub_p0 = __msa_max_u_b(p4_a_sub_p0, q4_a_sub_q0); \ + flat2_out = __msa_max_u_b(p5_a_sub_p0, q5_a_sub_q0); \ + flat2_out = __msa_max_u_b(p4_a_sub_p0, flat2_out); \ + p6_a_sub_p0 = __msa_max_u_b(p6_a_sub_p0, q6_a_sub_q0); \ + flat2_out = __msa_max_u_b(p6_a_sub_p0, flat2_out); \ + p7_a_sub_p0 = __msa_max_u_b(p7_a_sub_p0, q7_a_sub_q0); \ + flat2_out = __msa_max_u_b(p7_a_sub_p0, flat2_out); \ + \ + flat2_out = (tmp < (v16u8) flat2_out); \ + flat2_out = __msa_xori_b(flat2_out, 0xff); \ + flat2_out = flat2_out & flat_in; \ +} + +#define VP9_FILTER8(p3_in, p2_in, p1_in, p0_in, \ + q0_in, q1_in, q2_in, q3_in, \ + p2_filt8_out, p1_filt8_out, p0_filt8_out, \ + q0_filt8_out, q1_filt8_out, q2_filt8_out) \ +{ \ + v8u16 tmp0, tmp1, tmp2; \ + \ + tmp2 = p2_in + p1_in + p0_in; \ + tmp0 = p3_in << 1; \ + \ + tmp0 = tmp0 + tmp2 + q0_in; \ + tmp1 = tmp0 + p3_in + p2_in; \ + p2_filt8_out = (v8i16) __msa_srari_h((v8i16) tmp1, 3); \ + \ + tmp1 = tmp0 + p1_in + q1_in; \ + p1_filt8_out = (v8i16) __msa_srari_h((v8i16) tmp1, 3); \ + \ + tmp1 = q2_in + q1_in + q0_in; \ + tmp2 = tmp2 + tmp1; \ + tmp0 = tmp2 + (p0_in); \ + tmp0 = tmp0 + (p3_in); \ + p0_filt8_out = (v8i16) __msa_srari_h((v8i16) tmp0, 3); \ + \ + tmp0 = q2_in + q3_in; \ + tmp0 = p0_in + tmp1 + tmp0; \ + tmp1 = q3_in + q3_in; \ + tmp1 = tmp1 + tmp0; \ + q2_filt8_out = (v8i16) __msa_srari_h((v8i16) tmp1, 3); \ + \ + tmp0 = tmp2 + q3_in; \ + tmp1 = tmp0 + q0_in; \ + q0_filt8_out = (v8i16) __msa_srari_h((v8i16) tmp1, 3); \ + \ + tmp1 = tmp0 - p2_in; \ + tmp0 = q1_in + q3_in; \ + tmp1 = tmp0 + tmp1; \ + q1_filt8_out = (v8i16) __msa_srari_h((v8i16) tmp1, 3); \ +} + +#define LPF_MASK_HEV(p3_in, p2_in, p1_in, p0_in, \ + q0_in, q1_in, q2_in, q3_in, \ + limit_in, b_limit_in, thresh_in, \ + hev_out, mask_out, flat_out) \ +{ \ + v16u8 p3_asub_p2_m, p2_asub_p1_m, p1_asub_p0_m, q1_asub_q0_m; \ + v16u8 p1_asub_q1_m, p0_asub_q0_m, q3_asub_q2_m, q2_asub_q1_m; \ + \ + /* absolute subtraction of pixel values */ \ + p3_asub_p2_m = __msa_asub_u_b(p3_in, p2_in); \ + p2_asub_p1_m = __msa_asub_u_b(p2_in, p1_in); \ + p1_asub_p0_m = __msa_asub_u_b(p1_in, p0_in); \ + q1_asub_q0_m = __msa_asub_u_b(q1_in, q0_in); \ + q2_asub_q1_m = __msa_asub_u_b(q2_in, q1_in); \ + q3_asub_q2_m = __msa_asub_u_b(q3_in, q2_in); \ + p0_asub_q0_m = __msa_asub_u_b(p0_in, q0_in); \ + p1_asub_q1_m = __msa_asub_u_b(p1_in, q1_in); \ + \ + /* calculation of hev */ \ + flat_out = __msa_max_u_b(p1_asub_p0_m, q1_asub_q0_m); \ + hev_out = thresh_in < (v16u8) flat_out; \ + \ + /* calculation of mask */ \ + p0_asub_q0_m = __msa_adds_u_b(p0_asub_q0_m, p0_asub_q0_m); \ + p1_asub_q1_m >>= 1; \ + p0_asub_q0_m = __msa_adds_u_b(p0_asub_q0_m, p1_asub_q1_m); \ + \ + mask_out = b_limit_in < p0_asub_q0_m; \ + mask_out = __msa_max_u_b(flat_out, mask_out); \ + p3_asub_p2_m = __msa_max_u_b(p3_asub_p2_m, p2_asub_p1_m); \ + mask_out = __msa_max_u_b(p3_asub_p2_m, mask_out); \ + q2_asub_q1_m = __msa_max_u_b(q2_asub_q1_m, q3_asub_q2_m); \ + mask_out = __msa_max_u_b(q2_asub_q1_m, mask_out); \ + \ + mask_out = limit_in < (v16u8) mask_out; \ + mask_out = __msa_xori_b(mask_out, 0xff); \ +} + +void ff_loop_filter_v_4_8_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + uint64_t p1_d, p0_d, q0_d, q1_d; + v16u8 mask, hev, flat, thresh, b_limit, limit; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0, p1_out, p0_out, q0_out, q1_out; + + /* load vector elements */ + LD_UB8((src - 4 * pitch), pitch, p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + limit = (v16u8) __msa_fill_b(limit_ptr); + + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, + q1_out); + + p1_d = __msa_copy_u_d((v2i64) p1_out, 0); + p0_d = __msa_copy_u_d((v2i64) p0_out, 0); + q0_d = __msa_copy_u_d((v2i64) q0_out, 0); + q1_d = __msa_copy_u_d((v2i64) q1_out, 0); + SD4(p1_d, p0_d, q0_d, q1_d, (src - 2 * pitch), pitch); +} + + +void ff_loop_filter_v_44_16_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + v16u8 mask, hev, flat, thresh0, b_limit0, limit0, thresh1, b_limit1, limit1; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + + /* load vector elements */ + LD_UB8((src - 4 * pitch), pitch, p3, p2, p1, p0, q0, q1, q2, q3); + + thresh0 = (v16u8) __msa_fill_b(thresh_ptr); + thresh1 = (v16u8) __msa_fill_b(thresh_ptr >> 8); + thresh0 = (v16u8) __msa_ilvr_d((v2i64) thresh1, (v2i64) thresh0); + + b_limit0 = (v16u8) __msa_fill_b(b_limit_ptr); + b_limit1 = (v16u8) __msa_fill_b(b_limit_ptr >> 8); + b_limit0 = (v16u8) __msa_ilvr_d((v2i64) b_limit1, (v2i64) b_limit0); + + limit0 = (v16u8) __msa_fill_b(limit_ptr); + limit1 = (v16u8) __msa_fill_b(limit_ptr >> 8); + limit0 = (v16u8) __msa_ilvr_d((v2i64) limit1, (v2i64) limit0); + + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit0, b_limit0, thresh0, + hev, mask, flat); + VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1, p0, q0, q1); + + ST_UB4(p1, p0, q0, q1, (src - 2 * pitch), pitch); +} + +void ff_loop_filter_v_8_8_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + uint64_t p2_d, p1_d, p0_d, q0_d, q1_d, q2_d; + v16u8 mask, hev, flat, thresh, b_limit, limit; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 p2_out, p1_out, p0_out, q0_out, q1_out, q2_out; + v8i16 p2_filter8, p1_filter8, p0_filter8; + v8i16 q0_filter8, q1_filter8, q2_filter8; + v8u16 p3_r, p2_r, p1_r, p0_r, q3_r, q2_r, q1_r, q0_r; + v16i8 zero = { 0 }; + + /* load vector elements */ + LD_UB8((src - 4 * pitch), pitch, p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + limit = (v16u8) __msa_fill_b(limit_ptr); + + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat); + VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, + q1_out); + + flat = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) flat); + + /* if flat is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat)) { + p1_d = __msa_copy_u_d((v2i64) p1_out, 0); + p0_d = __msa_copy_u_d((v2i64) p0_out, 0); + q0_d = __msa_copy_u_d((v2i64) q0_out, 0); + q1_d = __msa_copy_u_d((v2i64) q1_out, 0); + SD4(p1_d, p0_d, q0_d, q1_d, (src - 2 * pitch), pitch); + } else { + ILVR_B8_UH(zero, p3, zero, p2, zero, p1, zero, p0, zero, q0, zero, q1, + zero, q2, zero, q3, p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, + q2_r, q3_r); + VP9_FILTER8(p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r, p2_filter8, + p1_filter8, p0_filter8, q0_filter8, q1_filter8, q2_filter8); + + /* convert 16 bit output data into 8 bit */ + PCKEV_B4_SH(zero, p2_filter8, zero, p1_filter8, zero, p0_filter8, + zero, q0_filter8, p2_filter8, p1_filter8, p0_filter8, + q0_filter8); + PCKEV_B2_SH(zero, q1_filter8, zero, q2_filter8, q1_filter8, q2_filter8); + + /* store pixel values */ + p2_out = __msa_bmnz_v(p2, (v16u8) p2_filter8, flat); + p1_out = __msa_bmnz_v(p1_out, (v16u8) p1_filter8, flat); + p0_out = __msa_bmnz_v(p0_out, (v16u8) p0_filter8, flat); + q0_out = __msa_bmnz_v(q0_out, (v16u8) q0_filter8, flat); + q1_out = __msa_bmnz_v(q1_out, (v16u8) q1_filter8, flat); + q2_out = __msa_bmnz_v(q2, (v16u8) q2_filter8, flat); + + p2_d = __msa_copy_u_d((v2i64) p2_out, 0); + p1_d = __msa_copy_u_d((v2i64) p1_out, 0); + p0_d = __msa_copy_u_d((v2i64) p0_out, 0); + q0_d = __msa_copy_u_d((v2i64) q0_out, 0); + q1_d = __msa_copy_u_d((v2i64) q1_out, 0); + q2_d = __msa_copy_u_d((v2i64) q2_out, 0); + + src -= 3 * pitch; + + SD4(p2_d, p1_d, p0_d, q0_d, src, pitch); + src += (4 * pitch); + SD(q1_d, src); + src += pitch; + SD(q2_d, src); + } +} + +void ff_loop_filter_v_88_16_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 p2_out, p1_out, p0_out, q0_out, q1_out, q2_out; + v16u8 flat, mask, hev, tmp, thresh, b_limit, limit; + v8u16 p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r; + v8u16 p3_l, p2_l, p1_l, p0_l, q0_l, q1_l, q2_l, q3_l; + v8i16 p2_filt8_r, p1_filt8_r, p0_filt8_r; + v8i16 q0_filt8_r, q1_filt8_r, q2_filt8_r; + v8i16 p2_filt8_l, p1_filt8_l, p0_filt8_l; + v8i16 q0_filt8_l, q1_filt8_l, q2_filt8_l; + v16u8 zero = { 0 }; + + /* load vector elements */ + LD_UB8(src - (4 * pitch), pitch, p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + tmp = (v16u8) __msa_fill_b(thresh_ptr >> 8); + thresh = (v16u8) __msa_ilvr_d((v2i64) tmp, (v2i64) thresh); + + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + tmp = (v16u8) __msa_fill_b(b_limit_ptr >> 8); + b_limit = (v16u8) __msa_ilvr_d((v2i64) tmp, (v2i64) b_limit); + + limit = (v16u8) __msa_fill_b(limit_ptr); + tmp = (v16u8) __msa_fill_b(limit_ptr >> 8); + limit = (v16u8) __msa_ilvr_d((v2i64) tmp, (v2i64) limit); + + /* mask and hev */ + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat); + VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, + q1_out); + + /* if flat is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat)) { + ST_UB4(p1_out, p0_out, q0_out, q1_out, (src - 2 * pitch), pitch); + } else { + ILVR_B8_UH(zero, p3, zero, p2, zero, p1, zero, p0, zero, q0, zero, q1, + zero, q2, zero, q3, p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, + q2_r, q3_r); + VP9_FILTER8(p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r, p2_filt8_r, + p1_filt8_r, p0_filt8_r, q0_filt8_r, q1_filt8_r, q2_filt8_r); + + ILVL_B4_UH(zero, p3, zero, p2, zero, p1, zero, p0, p3_l, p2_l, p1_l, + p0_l); + ILVL_B4_UH(zero, q0, zero, q1, zero, q2, zero, q3, q0_l, q1_l, q2_l, + q3_l); + VP9_FILTER8(p3_l, p2_l, p1_l, p0_l, q0_l, q1_l, q2_l, q3_l, p2_filt8_l, + p1_filt8_l, p0_filt8_l, q0_filt8_l, q1_filt8_l, q2_filt8_l); + + /* convert 16 bit output data into 8 bit */ + PCKEV_B4_SH(p2_filt8_l, p2_filt8_r, p1_filt8_l, p1_filt8_r, p0_filt8_l, + p0_filt8_r, q0_filt8_l, q0_filt8_r, p2_filt8_r, p1_filt8_r, + p0_filt8_r, q0_filt8_r); + PCKEV_B2_SH(q1_filt8_l, q1_filt8_r, q2_filt8_l, q2_filt8_r, + q1_filt8_r, q2_filt8_r); + + /* store pixel values */ + p2_out = __msa_bmnz_v(p2, (v16u8) p2_filt8_r, flat); + p1_out = __msa_bmnz_v(p1_out, (v16u8) p1_filt8_r, flat); + p0_out = __msa_bmnz_v(p0_out, (v16u8) p0_filt8_r, flat); + q0_out = __msa_bmnz_v(q0_out, (v16u8) q0_filt8_r, flat); + q1_out = __msa_bmnz_v(q1_out, (v16u8) q1_filt8_r, flat); + q2_out = __msa_bmnz_v(q2, (v16u8) q2_filt8_r, flat); + + src -= 3 * pitch; + + ST_UB4(p2_out, p1_out, p0_out, q0_out, src, pitch); + src += (4 * pitch); + ST_UB2(q1_out, q2_out, src, pitch); + src += (2 * pitch); + } +} + +void ff_loop_filter_v_84_16_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 p2_out, p1_out, p0_out, q0_out, q1_out, q2_out; + v16u8 flat, mask, hev, tmp, thresh, b_limit, limit; + v8u16 p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r; + v8i16 p2_filt8_r, p1_filt8_r, p0_filt8_r; + v8i16 q0_filt8_r, q1_filt8_r, q2_filt8_r; + v16u8 zero = { 0 }; + + /* load vector elements */ + LD_UB8(src - (4 * pitch), pitch, p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + tmp = (v16u8) __msa_fill_b(thresh_ptr >> 8); + thresh = (v16u8) __msa_ilvr_d((v2i64) tmp, (v2i64) thresh); + + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + tmp = (v16u8) __msa_fill_b(b_limit_ptr >> 8); + b_limit = (v16u8) __msa_ilvr_d((v2i64) tmp, (v2i64) b_limit); + + limit = (v16u8) __msa_fill_b(limit_ptr); + tmp = (v16u8) __msa_fill_b(limit_ptr >> 8); + limit = (v16u8) __msa_ilvr_d((v2i64) tmp, (v2i64) limit); + + /* mask and hev */ + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat); + VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, + q1_out); + + flat = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) flat); + + /* if flat is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat)) { + ST_UB4(p1_out, p0_out, q0_out, q1_out, (src - 2 * pitch), pitch); + } else { + ILVR_B8_UH(zero, p3, zero, p2, zero, p1, zero, p0, zero, q0, zero, q1, + zero, q2, zero, q3, p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, + q2_r, q3_r); + VP9_FILTER8(p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r, p2_filt8_r, + p1_filt8_r, p0_filt8_r, q0_filt8_r, q1_filt8_r, q2_filt8_r); + + /* convert 16 bit output data into 8 bit */ + PCKEV_B4_SH(p2_filt8_r, p2_filt8_r, p1_filt8_r, p1_filt8_r, + p0_filt8_r, p0_filt8_r, q0_filt8_r, q0_filt8_r, + p2_filt8_r, p1_filt8_r, p0_filt8_r, q0_filt8_r); + PCKEV_B2_SH(q1_filt8_r, q1_filt8_r, q2_filt8_r, q2_filt8_r, + q1_filt8_r, q2_filt8_r); + + /* store pixel values */ + p2_out = __msa_bmnz_v(p2, (v16u8) p2_filt8_r, flat); + p1_out = __msa_bmnz_v(p1_out, (v16u8) p1_filt8_r, flat); + p0_out = __msa_bmnz_v(p0_out, (v16u8) p0_filt8_r, flat); + q0_out = __msa_bmnz_v(q0_out, (v16u8) q0_filt8_r, flat); + q1_out = __msa_bmnz_v(q1_out, (v16u8) q1_filt8_r, flat); + q2_out = __msa_bmnz_v(q2, (v16u8) q2_filt8_r, flat); + + src -= 3 * pitch; + + ST_UB4(p2_out, p1_out, p0_out, q0_out, src, pitch); + src += (4 * pitch); + ST_UB2(q1_out, q2_out, src, pitch); + src += (2 * pitch); + } +} + +void ff_loop_filter_v_48_16_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 p2_out, p1_out, p0_out, q0_out, q1_out, q2_out; + v16u8 flat, mask, hev, tmp, thresh, b_limit, limit; + v8u16 p3_l, p2_l, p1_l, p0_l, q0_l, q1_l, q2_l, q3_l; + v8i16 p2_filt8_l, p1_filt8_l, p0_filt8_l; + v8i16 q0_filt8_l, q1_filt8_l, q2_filt8_l; + v16u8 zero = { 0 }; + + /* load vector elements */ + LD_UB8(src - (4 * pitch), pitch, p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + tmp = (v16u8) __msa_fill_b(thresh_ptr >> 8); + thresh = (v16u8) __msa_ilvr_d((v2i64) tmp, (v2i64) thresh); + + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + tmp = (v16u8) __msa_fill_b(b_limit_ptr >> 8); + b_limit = (v16u8) __msa_ilvr_d((v2i64) tmp, (v2i64) b_limit); + + limit = (v16u8) __msa_fill_b(limit_ptr); + tmp = (v16u8) __msa_fill_b(limit_ptr >> 8); + limit = (v16u8) __msa_ilvr_d((v2i64) tmp, (v2i64) limit); + + /* mask and hev */ + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat); + VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, + q1_out); + + flat = (v16u8) __msa_insve_d((v2i64) flat, 0, (v2i64) zero); + + /* if flat is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat)) { + ST_UB4(p1_out, p0_out, q0_out, q1_out, (src - 2 * pitch), pitch); + } else { + ILVL_B4_UH(zero, p3, zero, p2, zero, p1, zero, p0, p3_l, p2_l, p1_l, + p0_l); + ILVL_B4_UH(zero, q0, zero, q1, zero, q2, zero, q3, q0_l, q1_l, q2_l, + q3_l); + VP9_FILTER8(p3_l, p2_l, p1_l, p0_l, q0_l, q1_l, q2_l, q3_l, p2_filt8_l, + p1_filt8_l, p0_filt8_l, q0_filt8_l, q1_filt8_l, q2_filt8_l); + + /* convert 16 bit output data into 8 bit */ + PCKEV_B4_SH(p2_filt8_l, p2_filt8_l, p1_filt8_l, p1_filt8_l, + p0_filt8_l, p0_filt8_l, q0_filt8_l, q0_filt8_l, + p2_filt8_l, p1_filt8_l, p0_filt8_l, q0_filt8_l); + PCKEV_B2_SH(q1_filt8_l, q1_filt8_l, q2_filt8_l, q2_filt8_l, + q1_filt8_l, q2_filt8_l); + + /* store pixel values */ + p2_out = __msa_bmnz_v(p2, (v16u8) p2_filt8_l, flat); + p1_out = __msa_bmnz_v(p1_out, (v16u8) p1_filt8_l, flat); + p0_out = __msa_bmnz_v(p0_out, (v16u8) p0_filt8_l, flat); + q0_out = __msa_bmnz_v(q0_out, (v16u8) q0_filt8_l, flat); + q1_out = __msa_bmnz_v(q1_out, (v16u8) q1_filt8_l, flat); + q2_out = __msa_bmnz_v(q2, (v16u8) q2_filt8_l, flat); + + src -= 3 * pitch; + + ST_UB4(p2_out, p1_out, p0_out, q0_out, src, pitch); + src += (4 * pitch); + ST_UB2(q1_out, q2_out, src, pitch); + src += (2 * pitch); + } +} + +static int32_t vp9_hz_lpf_t4_and_t8_16w(uint8_t *src, int32_t pitch, + uint8_t *filter48, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 p2_out, p1_out, p0_out, q0_out, q1_out, q2_out; + v16u8 flat, mask, hev, thresh, b_limit, limit; + v8u16 p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r; + v8u16 p3_l, p2_l, p1_l, p0_l, q0_l, q1_l, q2_l, q3_l; + v8i16 p2_filt8_r, p1_filt8_r, p0_filt8_r; + v8i16 q0_filt8_r, q1_filt8_r, q2_filt8_r; + v8i16 p2_filt8_l, p1_filt8_l, p0_filt8_l; + v8i16 q0_filt8_l, q1_filt8_l, q2_filt8_l; + v16u8 zero = { 0 }; + + /* load vector elements */ + LD_UB8(src - (4 * pitch), pitch, p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + limit = (v16u8) __msa_fill_b(limit_ptr); + + /* mask and hev */ + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat); + VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, + q1_out); + + /* if flat is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat)) { + ST_UB4(p1_out, p0_out, q0_out, q1_out, (src - 2 * pitch), pitch); + + return 1; + } else { + ILVR_B8_UH(zero, p3, zero, p2, zero, p1, zero, p0, zero, q0, zero, q1, + zero, q2, zero, q3, p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, + q2_r, q3_r); + VP9_FILTER8(p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r, p2_filt8_r, + p1_filt8_r, p0_filt8_r, q0_filt8_r, q1_filt8_r, q2_filt8_r); + + ILVL_B4_UH(zero, p3, zero, p2, zero, p1, zero, p0, p3_l, p2_l, p1_l, + p0_l); + ILVL_B4_UH(zero, q0, zero, q1, zero, q2, zero, q3, q0_l, q1_l, q2_l, + q3_l); + VP9_FILTER8(p3_l, p2_l, p1_l, p0_l, q0_l, q1_l, q2_l, q3_l, p2_filt8_l, + p1_filt8_l, p0_filt8_l, q0_filt8_l, q1_filt8_l, q2_filt8_l); + + /* convert 16 bit output data into 8 bit */ + PCKEV_B4_SH(p2_filt8_l, p2_filt8_r, p1_filt8_l, p1_filt8_r, p0_filt8_l, + p0_filt8_r, q0_filt8_l, q0_filt8_r, p2_filt8_r, p1_filt8_r, + p0_filt8_r, q0_filt8_r); + PCKEV_B2_SH(q1_filt8_l, q1_filt8_r, q2_filt8_l, q2_filt8_r, q1_filt8_r, + q2_filt8_r); + + /* store pixel values */ + p2_out = __msa_bmnz_v(p2, (v16u8) p2_filt8_r, flat); + p1_out = __msa_bmnz_v(p1_out, (v16u8) p1_filt8_r, flat); + p0_out = __msa_bmnz_v(p0_out, (v16u8) p0_filt8_r, flat); + q0_out = __msa_bmnz_v(q0_out, (v16u8) q0_filt8_r, flat); + q1_out = __msa_bmnz_v(q1_out, (v16u8) q1_filt8_r, flat); + q2_out = __msa_bmnz_v(q2, (v16u8) q2_filt8_r, flat); + + ST_UB4(p2_out, p1_out, p0_out, q0_out, filter48, 16); + filter48 += (4 * 16); + ST_UB2(q1_out, q2_out, filter48, 16); + filter48 += (2 * 16); + ST_UB(flat, filter48); + + return 0; + } +} + +static void vp9_hz_lpf_t16_16w(uint8_t *src, int32_t pitch, uint8_t *filter48) +{ + v16u8 flat, flat2, filter8; + v16i8 zero = { 0 }; + v16u8 p7, p6, p5, p4, p3, p2, p1, p0, q0, q1, q2, q3, q4, q5, q6, q7; + v8u16 p7_r_in, p6_r_in, p5_r_in, p4_r_in; + v8u16 p3_r_in, p2_r_in, p1_r_in, p0_r_in; + v8u16 q7_r_in, q6_r_in, q5_r_in, q4_r_in; + v8u16 q3_r_in, q2_r_in, q1_r_in, q0_r_in; + v8u16 p7_l_in, p6_l_in, p5_l_in, p4_l_in; + v8u16 p3_l_in, p2_l_in, p1_l_in, p0_l_in; + v8u16 q7_l_in, q6_l_in, q5_l_in, q4_l_in; + v8u16 q3_l_in, q2_l_in, q1_l_in, q0_l_in; + v8u16 tmp0_r, tmp1_r, tmp0_l, tmp1_l; + v8i16 l_out, r_out; + + flat = LD_UB(filter48 + 96); + + LD_UB8((src - 8 * pitch), pitch, p7, p6, p5, p4, p3, p2, p1, p0); + LD_UB8(src, pitch, q0, q1, q2, q3, q4, q5, q6, q7); + VP9_FLAT5(p7, p6, p5, p4, p0, q0, q4, q5, q6, q7, flat, flat2); + + /* if flat2 is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat2)) { + LD_UB4(filter48, 16, p2, p1, p0, q0); + LD_UB2(filter48 + 4 * 16, 16, q1, q2); + + src -= 3 * pitch; + ST_UB4(p2, p1, p0, q0, src, pitch); + src += (4 * pitch); + ST_UB2(q1, q2, src, pitch); + } else { + src -= 7 * pitch; + + ILVR_B8_UH(zero, p7, zero, p6, zero, p5, zero, p4, zero, p3, zero, p2, + zero, p1, zero, p0, p7_r_in, p6_r_in, p5_r_in, p4_r_in, + p3_r_in, p2_r_in, p1_r_in, p0_r_in); + + q0_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q0); + + tmp0_r = p7_r_in << 3; + tmp0_r -= p7_r_in; + tmp0_r += p6_r_in; + tmp0_r += q0_r_in; + tmp1_r = p6_r_in + p5_r_in; + tmp1_r += p4_r_in; + tmp1_r += p3_r_in; + tmp1_r += p2_r_in; + tmp1_r += p1_r_in; + tmp1_r += p0_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + ILVL_B4_UH(zero, p7, zero, p6, zero, p5, zero, p4, p7_l_in, p6_l_in, + p5_l_in, p4_l_in); + ILVL_B4_UH(zero, p3, zero, p2, zero, p1, zero, p0, p3_l_in, p2_l_in, + p1_l_in, p0_l_in); + q0_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q0); + + tmp0_l = p7_l_in << 3; + tmp0_l -= p7_l_in; + tmp0_l += p6_l_in; + tmp0_l += q0_l_in; + tmp1_l = p6_l_in + p5_l_in; + tmp1_l += p4_l_in; + tmp1_l += p3_l_in; + tmp1_l += p2_l_in; + tmp1_l += p1_l_in; + tmp1_l += p0_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + p6 = __msa_bmnz_v(p6, (v16u8) r_out, flat2); + ST_UB(p6, src); + src += pitch; + + /* p5 */ + q1_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q1); + tmp0_r = p5_r_in - p6_r_in; + tmp0_r += q1_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + q1_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q1); + tmp0_l = p5_l_in - p6_l_in; + tmp0_l += q1_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + p5 = __msa_bmnz_v(p5, (v16u8) r_out, flat2); + ST_UB(p5, src); + src += pitch; + + /* p4 */ + q2_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q2); + tmp0_r = p4_r_in - p5_r_in; + tmp0_r += q2_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = (v8i16) __msa_srari_h((v8i16) tmp1_r, 4); + + q2_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q2); + tmp0_l = p4_l_in - p5_l_in; + tmp0_l += q2_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + p4 = __msa_bmnz_v(p4, (v16u8) r_out, flat2); + ST_UB(p4, src); + src += pitch; + + /* p3 */ + q3_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q3); + tmp0_r = p3_r_in - p4_r_in; + tmp0_r += q3_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + q3_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q3); + tmp0_l = p3_l_in - p4_l_in; + tmp0_l += q3_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + p3 = __msa_bmnz_v(p3, (v16u8) r_out, flat2); + ST_UB(p3, src); + src += pitch; + + /* p2 */ + q4_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q4); + filter8 = LD_UB(filter48); + tmp0_r = p2_r_in - p3_r_in; + tmp0_r += q4_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + q4_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q4); + tmp0_l = p2_l_in - p3_l_in; + tmp0_l += q4_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST_UB(filter8, src); + src += pitch; + + /* p1 */ + q5_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q5); + filter8 = LD_UB(filter48 + 16); + tmp0_r = p1_r_in - p2_r_in; + tmp0_r += q5_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + q5_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q5); + tmp0_l = p1_l_in - p2_l_in; + tmp0_l += q5_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST_UB(filter8, src); + src += pitch; + + /* p0 */ + q6_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q6); + filter8 = LD_UB(filter48 + 32); + tmp0_r = p0_r_in - p1_r_in; + tmp0_r += q6_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + q6_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q6); + tmp0_l = p0_l_in - p1_l_in; + tmp0_l += q6_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST_UB(filter8, src); + src += pitch; + + /* q0 */ + q7_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q7); + filter8 = LD_UB(filter48 + 48); + tmp0_r = q7_r_in - p0_r_in; + tmp0_r += q0_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + q7_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q7); + tmp0_l = q7_l_in - p0_l_in; + tmp0_l += q0_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST_UB(filter8, src); + src += pitch; + + /* q1 */ + filter8 = LD_UB(filter48 + 64); + tmp0_r = q7_r_in - q0_r_in; + tmp0_r += q1_r_in; + tmp0_r -= p6_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + tmp0_l = q7_l_in - q0_l_in; + tmp0_l += q1_l_in; + tmp0_l -= p6_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST_UB(filter8, src); + src += pitch; + + /* q2 */ + filter8 = LD_UB(filter48 + 80); + tmp0_r = q7_r_in - q1_r_in; + tmp0_r += q2_r_in; + tmp0_r -= p5_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + tmp0_l = q7_l_in - q1_l_in; + tmp0_l += q2_l_in; + tmp0_l -= p5_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST_UB(filter8, src); + src += pitch; + + /* q3 */ + tmp0_r = q7_r_in - q2_r_in; + tmp0_r += q3_r_in; + tmp0_r -= p4_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + tmp0_l = q7_l_in - q2_l_in; + tmp0_l += q3_l_in; + tmp0_l -= p4_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + q3 = __msa_bmnz_v(q3, (v16u8) r_out, flat2); + ST_UB(q3, src); + src += pitch; + + /* q4 */ + tmp0_r = q7_r_in - q3_r_in; + tmp0_r += q4_r_in; + tmp0_r -= p3_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + tmp0_l = q7_l_in - q3_l_in; + tmp0_l += q4_l_in; + tmp0_l -= p3_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + q4 = __msa_bmnz_v(q4, (v16u8) r_out, flat2); + ST_UB(q4, src); + src += pitch; + + /* q5 */ + tmp0_r = q7_r_in - q4_r_in; + tmp0_r += q5_r_in; + tmp0_r -= p2_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + tmp0_l = q7_l_in - q4_l_in; + tmp0_l += q5_l_in; + tmp0_l -= p2_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + q5 = __msa_bmnz_v(q5, (v16u8) r_out, flat2); + ST_UB(q5, src); + src += pitch; + + /* q6 */ + tmp0_r = q7_r_in - q5_r_in; + tmp0_r += q6_r_in; + tmp0_r -= p1_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + tmp0_l = q7_l_in - q5_l_in; + tmp0_l += q6_l_in; + tmp0_l -= p1_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + q6 = __msa_bmnz_v(q6, (v16u8) r_out, flat2); + ST_UB(q6, src); + } +} + +void ff_loop_filter_v_16_16_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + uint8_t filter48[16 * 8] ALLOC_ALIGNED(ALIGNMENT); + uint8_t early_exit = 0; + + early_exit = vp9_hz_lpf_t4_and_t8_16w(src, pitch, &filter48[0], + b_limit_ptr, limit_ptr, thresh_ptr); + + if (0 == early_exit) { + vp9_hz_lpf_t16_16w(src, pitch, filter48); + } +} + +void ff_loop_filter_v_16_8_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + uint64_t p2_d, p1_d, p0_d, q0_d, q1_d, q2_d; + uint64_t dword0, dword1; + v16u8 flat2, mask, hev, flat, thresh, b_limit, limit; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0, p7, p6, p5, p4, q4, q5, q6, q7; + v16u8 p2_out, p1_out, p0_out, q0_out, q1_out, q2_out; + v16u8 p0_filter16, p1_filter16; + v8i16 p2_filter8, p1_filter8, p0_filter8; + v8i16 q0_filter8, q1_filter8, q2_filter8; + v8u16 p7_r, p6_r, p5_r, p4_r, q7_r, q6_r, q5_r, q4_r; + v8u16 p3_r, p2_r, p1_r, p0_r, q3_r, q2_r, q1_r, q0_r; + v16i8 zero = { 0 }; + v8u16 tmp0, tmp1, tmp2; + + /* load vector elements */ + LD_UB8((src - 4 * pitch), pitch, p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + limit = (v16u8) __msa_fill_b(limit_ptr); + + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat); + VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, + q1_out); + + flat = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) flat); + + /* if flat is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat)) { + p1_d = __msa_copy_u_d((v2i64) p1_out, 0); + p0_d = __msa_copy_u_d((v2i64) p0_out, 0); + q0_d = __msa_copy_u_d((v2i64) q0_out, 0); + q1_d = __msa_copy_u_d((v2i64) q1_out, 0); + SD4(p1_d, p0_d, q0_d, q1_d, src - 2 * pitch, pitch); + } else { + /* convert 8 bit input data into 16 bit */ + ILVR_B8_UH(zero, p3, zero, p2, zero, p1, zero, p0, zero, q0, zero, + q1, zero, q2, zero, q3, p3_r, p2_r, p1_r, p0_r, q0_r, + q1_r, q2_r, q3_r); + VP9_FILTER8(p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r, + p2_filter8, p1_filter8, p0_filter8, q0_filter8, + q1_filter8, q2_filter8); + + /* convert 16 bit output data into 8 bit */ + PCKEV_B4_SH(zero, p2_filter8, zero, p1_filter8, zero, p0_filter8, + zero, q0_filter8, p2_filter8, p1_filter8, p0_filter8, + q0_filter8); + PCKEV_B2_SH(zero, q1_filter8, zero, q2_filter8, q1_filter8, + q2_filter8); + + /* store pixel values */ + p2_out = __msa_bmnz_v(p2, (v16u8) p2_filter8, flat); + p1_out = __msa_bmnz_v(p1_out, (v16u8) p1_filter8, flat); + p0_out = __msa_bmnz_v(p0_out, (v16u8) p0_filter8, flat); + q0_out = __msa_bmnz_v(q0_out, (v16u8) q0_filter8, flat); + q1_out = __msa_bmnz_v(q1_out, (v16u8) q1_filter8, flat); + q2_out = __msa_bmnz_v(q2, (v16u8) q2_filter8, flat); + + /* load 16 vector elements */ + LD_UB4((src - 8 * pitch), pitch, p7, p6, p5, p4); + LD_UB4(src + (4 * pitch), pitch, q4, q5, q6, q7); + + VP9_FLAT5(p7, p6, p5, p4, p0, q0, q4, q5, q6, q7, flat, flat2); + + /* if flat2 is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat2)) { + p2_d = __msa_copy_u_d((v2i64) p2_out, 0); + p1_d = __msa_copy_u_d((v2i64) p1_out, 0); + p0_d = __msa_copy_u_d((v2i64) p0_out, 0); + q0_d = __msa_copy_u_d((v2i64) q0_out, 0); + q1_d = __msa_copy_u_d((v2i64) q1_out, 0); + q2_d = __msa_copy_u_d((v2i64) q2_out, 0); + + SD4(p2_d, p1_d, p0_d, q0_d, src - 3 * pitch, pitch); + SD(q1_d, src + pitch); + SD(q2_d, src + 2 * pitch); + } else { + /* LSB(right) 8 pixel operation */ + ILVR_B8_UH(zero, p7, zero, p6, zero, p5, zero, p4, zero, q4, + zero, q5, zero, q6, zero, q7, p7_r, p6_r, p5_r, p4_r, + q4_r, q5_r, q6_r, q7_r); + + tmp0 = p7_r << 3; + tmp0 -= p7_r; + tmp0 += p6_r; + tmp0 += q0_r; + + src -= 7 * pitch; + + /* calculation of p6 and p5 */ + tmp1 = p6_r + p5_r + p4_r + p3_r; + tmp1 += (p2_r + p1_r + p0_r); + tmp1 += tmp0; + p0_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + tmp0 = p5_r - p6_r + q1_r - p7_r; + tmp1 += tmp0; + p1_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + PCKEV_B2_UB(zero, p0_filter16, zero, p1_filter16, + p0_filter16, p1_filter16); + p0_filter16 = __msa_bmnz_v(p6, p0_filter16, flat2); + p1_filter16 = __msa_bmnz_v(p5, p1_filter16, flat2); + dword0 = __msa_copy_u_d((v2i64) p0_filter16, 0); + dword1 = __msa_copy_u_d((v2i64) p1_filter16, 0); + SD(dword0, src); + src += pitch; + SD(dword1, src); + src += pitch; + + /* calculation of p4 and p3 */ + tmp0 = p4_r - p5_r + q2_r - p7_r; + tmp2 = p3_r - p4_r + q3_r - p7_r; + tmp1 += tmp0; + p0_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + tmp1 += tmp2; + p1_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + PCKEV_B2_UB(zero, p0_filter16, zero, p1_filter16, + p0_filter16, p1_filter16); + p0_filter16 = __msa_bmnz_v(p4, p0_filter16, flat2); + p1_filter16 = __msa_bmnz_v(p3, p1_filter16, flat2); + dword0 = __msa_copy_u_d((v2i64) p0_filter16, 0); + dword1 = __msa_copy_u_d((v2i64) p1_filter16, 0); + SD(dword0, src); + src += pitch; + SD(dword1, src); + src += pitch; + + /* calculation of p2 and p1 */ + tmp0 = p2_r - p3_r + q4_r - p7_r; + tmp2 = p1_r - p2_r + q5_r - p7_r; + tmp1 += tmp0; + p0_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + tmp1 += tmp2; + p1_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + PCKEV_B2_UB(zero, p0_filter16, zero, p1_filter16, + p0_filter16, p1_filter16); + p0_filter16 = __msa_bmnz_v(p2_out, p0_filter16, flat2); + p1_filter16 = __msa_bmnz_v(p1_out, p1_filter16, flat2); + dword0 = __msa_copy_u_d((v2i64) p0_filter16, 0); + dword1 = __msa_copy_u_d((v2i64) p1_filter16, 0); + SD(dword0, src); + src += pitch; + SD(dword1, src); + src += pitch; + + /* calculation of p0 and q0 */ + tmp0 = (p0_r - p1_r) + (q6_r - p7_r); + tmp2 = (q7_r - p0_r) + (q0_r - p7_r); + tmp1 += tmp0; + p0_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + tmp1 += tmp2; + p1_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + PCKEV_B2_UB(zero, p0_filter16, zero, p1_filter16, + p0_filter16, p1_filter16); + p0_filter16 = __msa_bmnz_v(p0_out, p0_filter16, flat2); + p1_filter16 = __msa_bmnz_v(q0_out, p1_filter16, flat2); + dword0 = __msa_copy_u_d((v2i64) p0_filter16, 0); + dword1 = __msa_copy_u_d((v2i64) p1_filter16, 0); + SD(dword0, src); + src += pitch; + SD(dword1, src); + src += pitch; + + /* calculation of q1 and q2 */ + tmp0 = q7_r - q0_r + q1_r - p6_r; + tmp2 = q7_r - q1_r + q2_r - p5_r; + tmp1 += tmp0; + p0_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + tmp1 += tmp2; + p1_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + PCKEV_B2_UB(zero, p0_filter16, zero, p1_filter16, + p0_filter16, p1_filter16); + p0_filter16 = __msa_bmnz_v(q1_out, p0_filter16, flat2); + p1_filter16 = __msa_bmnz_v(q2_out, p1_filter16, flat2); + dword0 = __msa_copy_u_d((v2i64) p0_filter16, 0); + dword1 = __msa_copy_u_d((v2i64) p1_filter16, 0); + SD(dword0, src); + src += pitch; + SD(dword1, src); + src += pitch; + + /* calculation of q3 and q4 */ + tmp0 = (q7_r - q2_r) + (q3_r - p4_r); + tmp2 = (q7_r - q3_r) + (q4_r - p3_r); + tmp1 += tmp0; + p0_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + tmp1 += tmp2; + p1_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + PCKEV_B2_UB(zero, p0_filter16, zero, p1_filter16, + p0_filter16, p1_filter16); + p0_filter16 = __msa_bmnz_v(q3, p0_filter16, flat2); + p1_filter16 = __msa_bmnz_v(q4, p1_filter16, flat2); + dword0 = __msa_copy_u_d((v2i64) p0_filter16, 0); + dword1 = __msa_copy_u_d((v2i64) p1_filter16, 0); + SD(dword0, src); + src += pitch; + SD(dword1, src); + src += pitch; + + /* calculation of q5 and q6 */ + tmp0 = (q7_r - q4_r) + (q5_r - p2_r); + tmp2 = (q7_r - q5_r) + (q6_r - p1_r); + tmp1 += tmp0; + p0_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + tmp1 += tmp2; + p1_filter16 = (v16u8) __msa_srari_h((v8i16) tmp1, 4); + PCKEV_B2_UB(zero, p0_filter16, zero, p1_filter16, + p0_filter16, p1_filter16); + p0_filter16 = __msa_bmnz_v(q5, p0_filter16, flat2); + p1_filter16 = __msa_bmnz_v(q6, p1_filter16, flat2); + dword0 = __msa_copy_u_d((v2i64) p0_filter16, 0); + dword1 = __msa_copy_u_d((v2i64) p1_filter16, 0); + SD(dword0, src); + src += pitch; + SD(dword1, src); + } + } +} + +void ff_loop_filter_h_4_8_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + v16u8 mask, hev, flat, limit, thresh, b_limit; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v8i16 vec0, vec1, vec2, vec3; + + LD_UB8((src - 4), pitch, p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + limit = (v16u8) __msa_fill_b(limit_ptr); + + TRANSPOSE8x8_UB_UB(p3, p2, p1, p0, q0, q1, q2, q3, + p3, p2, p1, p0, q0, q1, q2, q3); + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1, p0, q0, q1); + ILVR_B2_SH(p0, p1, q1, q0, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec2, vec3); + + src -= 2; + ST4x4_UB(vec2, vec2, 0, 1, 2, 3, src, pitch); + src += 4 * pitch; + ST4x4_UB(vec3, vec3, 0, 1, 2, 3, src, pitch); +} + +void ff_loop_filter_h_44_16_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + v16u8 mask, hev, flat; + v16u8 thresh0, b_limit0, limit0, thresh1, b_limit1, limit1; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 row0, row1, row2, row3, row4, row5, row6, row7; + v16u8 row8, row9, row10, row11, row12, row13, row14, row15; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + + LD_UB8(src - 4, pitch, row0, row1, row2, row3, row4, row5, row6, row7); + LD_UB8(src - 4 + (8 * pitch), pitch, + row8, row9, row10, row11, row12, row13, row14, row15); + + TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7, + row8, row9, row10, row11, row12, row13, row14, row15, + p3, p2, p1, p0, q0, q1, q2, q3); + + thresh0 = (v16u8) __msa_fill_b(thresh_ptr); + thresh1 = (v16u8) __msa_fill_b(thresh_ptr >> 8); + thresh0 = (v16u8) __msa_ilvr_d((v2i64) thresh1, (v2i64) thresh0); + + b_limit0 = (v16u8) __msa_fill_b(b_limit_ptr); + b_limit1 = (v16u8) __msa_fill_b(b_limit_ptr >> 8); + b_limit0 = (v16u8) __msa_ilvr_d((v2i64) b_limit1, (v2i64) b_limit0); + + limit0 = (v16u8) __msa_fill_b(limit_ptr); + limit1 = (v16u8) __msa_fill_b(limit_ptr >> 8); + limit0 = (v16u8) __msa_ilvr_d((v2i64) limit1, (v2i64) limit0); + + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit0, b_limit0, thresh0, + hev, mask, flat); + VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1, p0, q0, q1); + ILVR_B2_SH(p0, p1, q1, q0, tmp0, tmp1); + ILVRL_H2_SH(tmp1, tmp0, tmp2, tmp3); + ILVL_B2_SH(p0, p1, q1, q0, tmp0, tmp1); + ILVRL_H2_SH(tmp1, tmp0, tmp4, tmp5); + + src -= 2; + + ST4x8_UB(tmp2, tmp3, src, pitch); + src += (8 * pitch); + ST4x8_UB(tmp4, tmp5, src, pitch); +} + +void ff_loop_filter_h_8_8_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 p1_out, p0_out, q0_out, q1_out; + v16u8 flat, mask, hev, thresh, b_limit, limit; + v8u16 p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r; + v8i16 p2_filt8_r, p1_filt8_r, p0_filt8_r; + v8i16 q0_filt8_r, q1_filt8_r, q2_filt8_r; + v16u8 zero = { 0 }; + v8i16 vec0, vec1, vec2, vec3, vec4; + + /* load vector elements */ + LD_UB8(src - 4, pitch, p3, p2, p1, p0, q0, q1, q2, q3); + + TRANSPOSE8x8_UB_UB(p3, p2, p1, p0, q0, q1, q2, q3, + p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + limit = (v16u8) __msa_fill_b(limit_ptr); + + /* mask and hev */ + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + /* flat4 */ + VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat); + /* filter4 */ + VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, + q1_out); + + flat = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) flat); + + /* if flat is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat)) { + /* Store 4 pixels p1-_q1 */ + ILVR_B2_SH(p0_out, p1_out, q1_out, q0_out, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec2, vec3); + + src -= 2; + ST4x4_UB(vec2, vec2, 0, 1, 2, 3, src, pitch); + src += 4 * pitch; + ST4x4_UB(vec3, vec3, 0, 1, 2, 3, src, pitch); + } else { + ILVR_B8_UH(zero, p3, zero, p2, zero, p1, zero, p0, zero, q0, zero, q1, + zero, q2, zero, q3, p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, + q3_r); + VP9_FILTER8(p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r, p2_filt8_r, + p1_filt8_r, p0_filt8_r, q0_filt8_r, q1_filt8_r, q2_filt8_r); + /* convert 16 bit output data into 8 bit */ + PCKEV_B4_SH(p2_filt8_r, p2_filt8_r, p1_filt8_r, p1_filt8_r, p0_filt8_r, + p0_filt8_r, q0_filt8_r, q0_filt8_r, p2_filt8_r, p1_filt8_r, + p0_filt8_r, q0_filt8_r); + PCKEV_B2_SH(q1_filt8_r, q1_filt8_r, q2_filt8_r, q2_filt8_r, q1_filt8_r, + q2_filt8_r); + + /* store pixel values */ + p2 = __msa_bmnz_v(p2, (v16u8) p2_filt8_r, flat); + p1 = __msa_bmnz_v(p1_out, (v16u8) p1_filt8_r, flat); + p0 = __msa_bmnz_v(p0_out, (v16u8) p0_filt8_r, flat); + q0 = __msa_bmnz_v(q0_out, (v16u8) q0_filt8_r, flat); + q1 = __msa_bmnz_v(q1_out, (v16u8) q1_filt8_r, flat); + q2 = __msa_bmnz_v(q2, (v16u8) q2_filt8_r, flat); + + /* Store 6 pixels p2-_q2 */ + ILVR_B2_SH(p1, p2, q0, p0, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec2, vec3); + vec4 = (v8i16) __msa_ilvr_b((v16i8) q2, (v16i8) q1); + + src -= 3; + ST4x4_UB(vec2, vec2, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec4, 0, src + 4, pitch); + src += (4 * pitch); + ST4x4_UB(vec3, vec3, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec4, 4, src + 4, pitch); + } +} + +void ff_loop_filter_h_88_16_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + uint8_t *temp_src; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 p1_out, p0_out, q0_out, q1_out; + v16u8 flat, mask, hev, thresh, b_limit, limit; + v16u8 row4, row5, row6, row7, row12, row13, row14, row15; + v8u16 p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r; + v8u16 p3_l, p2_l, p1_l, p0_l, q0_l, q1_l, q2_l, q3_l; + v8i16 p2_filt8_r, p1_filt8_r, p0_filt8_r; + v8i16 q0_filt8_r, q1_filt8_r, q2_filt8_r; + v8i16 p2_filt8_l, p1_filt8_l, p0_filt8_l; + v8i16 q0_filt8_l, q1_filt8_l, q2_filt8_l; + v16u8 zero = { 0 }; + v8i16 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + + temp_src = src - 4; + + LD_UB8(temp_src, pitch, p0, p1, p2, p3, row4, row5, row6, row7); + temp_src += (8 * pitch); + LD_UB8(temp_src, pitch, q3, q2, q1, q0, row12, row13, row14, row15); + + /* transpose 16x8 matrix into 8x16 */ + TRANSPOSE16x8_UB_UB(p0, p1, p2, p3, row4, row5, row6, row7, + q3, q2, q1, q0, row12, row13, row14, row15, + p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + vec0 = (v8i16) __msa_fill_b(thresh_ptr >> 8); + thresh = (v16u8) __msa_ilvr_d((v2i64) vec0, (v2i64) thresh); + + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + vec0 = (v8i16) __msa_fill_b(b_limit_ptr >> 8); + b_limit = (v16u8) __msa_ilvr_d((v2i64) vec0, (v2i64) b_limit); + + limit = (v16u8) __msa_fill_b(limit_ptr); + vec0 = (v8i16) __msa_fill_b(limit_ptr >> 8); + limit = (v16u8) __msa_ilvr_d((v2i64) vec0, (v2i64) limit); + + /* mask and hev */ + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + /* flat4 */ + VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat); + /* filter4 */ + VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, + q1_out); + + /* if flat is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat)) { + ILVR_B2_SH(p0_out, p1_out, q1_out, q0_out, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec2, vec3); + ILVL_B2_SH(p0_out, p1_out, q1_out, q0_out, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec4, vec5); + + src -= 2; + ST4x8_UB(vec2, vec3, src, pitch); + src += 8 * pitch; + ST4x8_UB(vec4, vec5, src, pitch); + } else { + ILVR_B8_UH(zero, p3, zero, p2, zero, p1, zero, p0, zero, q0, zero, q1, + zero, q2, zero, q3, p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, + q3_r); + VP9_FILTER8(p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r, p2_filt8_r, + p1_filt8_r, p0_filt8_r, q0_filt8_r, q1_filt8_r, q2_filt8_r); + + ILVL_B4_UH(zero, p3, zero, p2, zero, p1, zero, p0, p3_l, p2_l, p1_l, + p0_l); + ILVL_B4_UH(zero, q0, zero, q1, zero, q2, zero, q3, q0_l, q1_l, q2_l, + q3_l); + + /* filter8 */ + VP9_FILTER8(p3_l, p2_l, p1_l, p0_l, q0_l, q1_l, q2_l, q3_l, p2_filt8_l, + p1_filt8_l, p0_filt8_l, q0_filt8_l, q1_filt8_l, q2_filt8_l); + + /* convert 16 bit output data into 8 bit */ + PCKEV_B4_SH(p2_filt8_l, p2_filt8_r, p1_filt8_l, p1_filt8_r, p0_filt8_l, + p0_filt8_r, q0_filt8_l, q0_filt8_r, p2_filt8_r, p1_filt8_r, + p0_filt8_r, q0_filt8_r); + PCKEV_B2_SH(q1_filt8_l, q1_filt8_r, q2_filt8_l, q2_filt8_r, q1_filt8_r, + q2_filt8_r); + + /* store pixel values */ + p2 = __msa_bmnz_v(p2, (v16u8) p2_filt8_r, flat); + p1 = __msa_bmnz_v(p1_out, (v16u8) p1_filt8_r, flat); + p0 = __msa_bmnz_v(p0_out, (v16u8) p0_filt8_r, flat); + q0 = __msa_bmnz_v(q0_out, (v16u8) q0_filt8_r, flat); + q1 = __msa_bmnz_v(q1_out, (v16u8) q1_filt8_r, flat); + q2 = __msa_bmnz_v(q2, (v16u8) q2_filt8_r, flat); + + ILVR_B2_SH(p1, p2, q0, p0, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec3, vec4); + ILVL_B2_SH(p1, p2, q0, p0, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec6, vec7); + ILVRL_B2_SH(q2, q1, vec2, vec5); + + src -= 3; + ST4x4_UB(vec3, vec3, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec2, 0, src + 4, pitch); + src += (4 * pitch); + ST4x4_UB(vec4, vec4, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec2, 4, src + 4, pitch); + src += (4 * pitch); + ST4x4_UB(vec6, vec6, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec5, 0, src + 4, pitch); + src += (4 * pitch); + ST4x4_UB(vec7, vec7, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec5, 4, src + 4, pitch); + } +} + +void ff_loop_filter_h_84_16_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + uint8_t *temp_src; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 p1_out, p0_out, q0_out, q1_out; + v16u8 flat, mask, hev, thresh, b_limit, limit; + v16u8 row4, row5, row6, row7, row12, row13, row14, row15; + v8u16 p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r; + v8i16 p2_filt8_r, p1_filt8_r, p0_filt8_r; + v8i16 q0_filt8_r, q1_filt8_r, q2_filt8_r; + v16u8 zero = { 0 }; + v8i16 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + + temp_src = src - 4; + + LD_UB8(temp_src, pitch, p0, p1, p2, p3, row4, row5, row6, row7); + temp_src += (8 * pitch); + LD_UB8(temp_src, pitch, q3, q2, q1, q0, row12, row13, row14, row15); + + /* transpose 16x8 matrix into 8x16 */ + TRANSPOSE16x8_UB_UB(p0, p1, p2, p3, row4, row5, row6, row7, + q3, q2, q1, q0, row12, row13, row14, row15, + p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + vec0 = (v8i16) __msa_fill_b(thresh_ptr >> 8); + thresh = (v16u8) __msa_ilvr_d((v2i64) vec0, (v2i64) thresh); + + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + vec0 = (v8i16) __msa_fill_b(b_limit_ptr >> 8); + b_limit = (v16u8) __msa_ilvr_d((v2i64) vec0, (v2i64) b_limit); + + limit = (v16u8) __msa_fill_b(limit_ptr); + vec0 = (v8i16) __msa_fill_b(limit_ptr >> 8); + limit = (v16u8) __msa_ilvr_d((v2i64) vec0, (v2i64) limit); + + /* mask and hev */ + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + /* flat4 */ + VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat); + /* filter4 */ + VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, + q1_out); + + flat = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) flat); + + /* if flat is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat)) { + ILVR_B2_SH(p0_out, p1_out, q1_out, q0_out, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec2, vec3); + ILVL_B2_SH(p0_out, p1_out, q1_out, q0_out, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec4, vec5); + + src -= 2; + ST4x8_UB(vec2, vec3, src, pitch); + src += 8 * pitch; + ST4x8_UB(vec4, vec5, src, pitch); + } else { + ILVR_B8_UH(zero, p3, zero, p2, zero, p1, zero, p0, zero, q0, zero, q1, + zero, q2, zero, q3, p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, + q3_r); + VP9_FILTER8(p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r, p2_filt8_r, + p1_filt8_r, p0_filt8_r, q0_filt8_r, q1_filt8_r, q2_filt8_r); + + /* convert 16 bit output data into 8 bit */ + PCKEV_B4_SH(p2_filt8_r, p2_filt8_r, p1_filt8_r, p1_filt8_r, + p0_filt8_r, p0_filt8_r, q0_filt8_r, q0_filt8_r, + p2_filt8_r, p1_filt8_r, p0_filt8_r, q0_filt8_r); + PCKEV_B2_SH(q1_filt8_r, q1_filt8_r, q2_filt8_r, q2_filt8_r, + q1_filt8_r, q2_filt8_r); + + /* store pixel values */ + p2 = __msa_bmnz_v(p2, (v16u8) p2_filt8_r, flat); + p1 = __msa_bmnz_v(p1_out, (v16u8) p1_filt8_r, flat); + p0 = __msa_bmnz_v(p0_out, (v16u8) p0_filt8_r, flat); + q0 = __msa_bmnz_v(q0_out, (v16u8) q0_filt8_r, flat); + q1 = __msa_bmnz_v(q1_out, (v16u8) q1_filt8_r, flat); + q2 = __msa_bmnz_v(q2, (v16u8) q2_filt8_r, flat); + + ILVR_B2_SH(p1, p2, q0, p0, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec3, vec4); + ILVL_B2_SH(p1, p2, q0, p0, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec6, vec7); + ILVRL_B2_SH(q2, q1, vec2, vec5); + + src -= 3; + ST4x4_UB(vec3, vec3, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec2, 0, src + 4, pitch); + src += (4 * pitch); + ST4x4_UB(vec4, vec4, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec2, 4, src + 4, pitch); + src += (4 * pitch); + ST4x4_UB(vec6, vec6, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec5, 0, src + 4, pitch); + src += (4 * pitch); + ST4x4_UB(vec7, vec7, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec5, 4, src + 4, pitch); + } +} + +void ff_loop_filter_h_48_16_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + uint8_t *temp_src; + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 p1_out, p0_out, q0_out, q1_out; + v16u8 flat, mask, hev, thresh, b_limit, limit; + v16u8 row4, row5, row6, row7, row12, row13, row14, row15; + v8u16 p3_l, p2_l, p1_l, p0_l, q0_l, q1_l, q2_l, q3_l; + v8i16 p2_filt8_l, p1_filt8_l, p0_filt8_l; + v8i16 q0_filt8_l, q1_filt8_l, q2_filt8_l; + v16u8 zero = { 0 }; + v8i16 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + + temp_src = src - 4; + + LD_UB8(temp_src, pitch, p0, p1, p2, p3, row4, row5, row6, row7); + temp_src += (8 * pitch); + LD_UB8(temp_src, pitch, q3, q2, q1, q0, row12, row13, row14, row15); + + /* transpose 16x8 matrix into 8x16 */ + TRANSPOSE16x8_UB_UB(p0, p1, p2, p3, row4, row5, row6, row7, + q3, q2, q1, q0, row12, row13, row14, row15, + p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + vec0 = (v8i16) __msa_fill_b(thresh_ptr >> 8); + thresh = (v16u8) __msa_ilvr_d((v2i64) vec0, (v2i64) thresh); + + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + vec0 = (v8i16) __msa_fill_b(b_limit_ptr >> 8); + b_limit = (v16u8) __msa_ilvr_d((v2i64) vec0, (v2i64) b_limit); + + limit = (v16u8) __msa_fill_b(limit_ptr); + vec0 = (v8i16) __msa_fill_b(limit_ptr >> 8); + limit = (v16u8) __msa_ilvr_d((v2i64) vec0, (v2i64) limit); + + /* mask and hev */ + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + /* flat4 */ + VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat); + /* filter4 */ + VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, + q1_out); + + flat = (v16u8) __msa_insve_d((v2i64) flat, 0, (v2i64) zero); + + /* if flat is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat)) { + ILVR_B2_SH(p0_out, p1_out, q1_out, q0_out, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec2, vec3); + ILVL_B2_SH(p0_out, p1_out, q1_out, q0_out, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec4, vec5); + + src -= 2; + ST4x8_UB(vec2, vec3, src, pitch); + src += 8 * pitch; + ST4x8_UB(vec4, vec5, src, pitch); + } else { + ILVL_B4_UH(zero, p3, zero, p2, zero, p1, zero, p0, p3_l, p2_l, p1_l, + p0_l); + ILVL_B4_UH(zero, q0, zero, q1, zero, q2, zero, q3, q0_l, q1_l, q2_l, + q3_l); + + VP9_FILTER8(p3_l, p2_l, p1_l, p0_l, q0_l, q1_l, q2_l, q3_l, p2_filt8_l, + p1_filt8_l, p0_filt8_l, q0_filt8_l, q1_filt8_l, q2_filt8_l); + + /* convert 16 bit output data into 8 bit */ + PCKEV_B4_SH(p2_filt8_l, p2_filt8_l, p1_filt8_l, p1_filt8_l, + p0_filt8_l, p0_filt8_l, q0_filt8_l, q0_filt8_l, + p2_filt8_l, p1_filt8_l, p0_filt8_l, q0_filt8_l); + PCKEV_B2_SH(q1_filt8_l, q1_filt8_l, q2_filt8_l, q2_filt8_l, + q1_filt8_l, q2_filt8_l); + + /* store pixel values */ + p2 = __msa_bmnz_v(p2, (v16u8) p2_filt8_l, flat); + p1 = __msa_bmnz_v(p1_out, (v16u8) p1_filt8_l, flat); + p0 = __msa_bmnz_v(p0_out, (v16u8) p0_filt8_l, flat); + q0 = __msa_bmnz_v(q0_out, (v16u8) q0_filt8_l, flat); + q1 = __msa_bmnz_v(q1_out, (v16u8) q1_filt8_l, flat); + q2 = __msa_bmnz_v(q2, (v16u8) q2_filt8_l, flat); + + ILVR_B2_SH(p1, p2, q0, p0, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec3, vec4); + ILVL_B2_SH(p1, p2, q0, p0, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec6, vec7); + ILVRL_B2_SH(q2, q1, vec2, vec5); + + src -= 3; + ST4x4_UB(vec3, vec3, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec2, 0, src + 4, pitch); + src += (4 * pitch); + ST4x4_UB(vec4, vec4, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec2, 4, src + 4, pitch); + src += (4 * pitch); + ST4x4_UB(vec6, vec6, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec5, 0, src + 4, pitch); + src += (4 * pitch); + ST4x4_UB(vec7, vec7, 0, 1, 2, 3, src, pitch); + ST2x4_UB(vec5, 4, src + 4, pitch); + } +} + +static void vp9_transpose_16x8_to_8x16(uint8_t *input, int32_t in_pitch, + uint8_t *output, int32_t out_pitch) +{ + v16u8 p7_org, p6_org, p5_org, p4_org, p3_org, p2_org, p1_org, p0_org; + v16i8 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v16u8 p7, p6, p5, p4, p3, p2, p1, p0, q0, q1, q2, q3, q4, q5, q6, q7; + + LD_UB8(input, in_pitch, + p7_org, p6_org, p5_org, p4_org, p3_org, p2_org, p1_org, p0_org); + /* 8x8 transpose */ + TRANSPOSE8x8_UB_UB(p7_org, p6_org, p5_org, p4_org, p3_org, p2_org, p1_org, + p0_org, p7, p6, p5, p4, p3, p2, p1, p0); + /* 8x8 transpose */ + ILVL_B4_SB(p5_org, p7_org, p4_org, p6_org, p1_org, p3_org, p0_org, p2_org, + tmp0, tmp1, tmp2, tmp3); + ILVR_B2_SB(tmp1, tmp0, tmp3, tmp2, tmp4, tmp6); + ILVL_B2_SB(tmp1, tmp0, tmp3, tmp2, tmp5, tmp7); + ILVR_W2_UB(tmp6, tmp4, tmp7, tmp5, q0, q4); + ILVL_W2_UB(tmp6, tmp4, tmp7, tmp5, q2, q6); + SLDI_B4_0_UB(q0, q2, q4, q6, q1, q3, q5, q7, 8); + + ST_UB8(p7, p6, p5, p4, p3, p2, p1, p0, output, out_pitch); + output += (8 * out_pitch); + ST_UB8(q0, q1, q2, q3, q4, q5, q6, q7, output, out_pitch); +} + +static void vp9_transpose_8x16_to_16x8(uint8_t *input, int32_t in_pitch, + uint8_t *output, int32_t out_pitch) +{ + v16u8 p7_o, p6_o, p5_o, p4_o, p3_o, p2_o, p1_o, p0_o; + v16u8 p7, p6, p5, p4, p3, p2, p1, p0, q0, q1, q2, q3, q4, q5, q6, q7; + + LD_UB8(input, in_pitch, p7, p6, p5, p4, p3, p2, p1, p0); + LD_UB8(input + (8 * in_pitch), in_pitch, q0, q1, q2, q3, q4, q5, q6, q7); + TRANSPOSE16x8_UB_UB(p7, p6, p5, p4, p3, p2, p1, p0, q0, q1, q2, q3, q4, q5, + q6, q7, p7_o, p6_o, p5_o, p4_o, p3_o, p2_o, p1_o, p0_o); + ST_UB8(p7_o, p6_o, p5_o, p4_o, p3_o, p2_o, p1_o, p0_o, output, out_pitch); +} + +static void vp9_transpose_16x16(uint8_t *input, int32_t in_pitch, + uint8_t *output, int32_t out_pitch) +{ + v16u8 row0, row1, row2, row3, row4, row5, row6, row7; + v16u8 row8, row9, row10, row11, row12, row13, row14, row15; + v8i16 tmp0, tmp1, tmp4, tmp5, tmp6, tmp7; + v4i32 tmp2, tmp3; + v16u8 p7, p6, p5, p4, p3, p2, p1, p0, q0, q1, q2, q3, q4, q5, q6, q7; + + LD_UB8(input, in_pitch, row0, row1, row2, row3, row4, row5, row6, row7); + input += (8 * in_pitch); + LD_UB8(input, in_pitch, + row8, row9, row10, row11, row12, row13, row14, row15); + + TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7, + row8, row9, row10, row11, row12, row13, row14, row15, + p7, p6, p5, p4, p3, p2, p1, p0); + + /* transpose 16x8 matrix into 8x16 */ + /* total 8 intermediate register and 32 instructions */ + q7 = (v16u8) __msa_ilvod_d((v2i64) row8, (v2i64) row0); + q6 = (v16u8) __msa_ilvod_d((v2i64) row9, (v2i64) row1); + q5 = (v16u8) __msa_ilvod_d((v2i64) row10, (v2i64) row2); + q4 = (v16u8) __msa_ilvod_d((v2i64) row11, (v2i64) row3); + q3 = (v16u8) __msa_ilvod_d((v2i64) row12, (v2i64) row4); + q2 = (v16u8) __msa_ilvod_d((v2i64) row13, (v2i64) row5); + q1 = (v16u8) __msa_ilvod_d((v2i64) row14, (v2i64) row6); + q0 = (v16u8) __msa_ilvod_d((v2i64) row15, (v2i64) row7); + + ILVEV_B2_SH(q7, q6, q5, q4, tmp0, tmp1); + tmp4 = (v8i16) __msa_ilvod_b((v16i8) q6, (v16i8) q7); + tmp5 = (v8i16) __msa_ilvod_b((v16i8) q4, (v16i8) q5); + + ILVEV_B2_UB(q3, q2, q1, q0, q5, q7); + tmp6 = (v8i16) __msa_ilvod_b((v16i8) q2, (v16i8) q3); + tmp7 = (v8i16) __msa_ilvod_b((v16i8) q0, (v16i8) q1); + + ILVEV_H2_SW(tmp0, tmp1, q5, q7, tmp2, tmp3); + q0 = (v16u8) __msa_ilvev_w(tmp3, tmp2); + q4 = (v16u8) __msa_ilvod_w(tmp3, tmp2); + + tmp2 = (v4i32) __msa_ilvod_h(tmp1, tmp0); + tmp3 = (v4i32) __msa_ilvod_h((v8i16) q7, (v8i16) q5); + q2 = (v16u8) __msa_ilvev_w(tmp3, tmp2); + q6 = (v16u8) __msa_ilvod_w(tmp3, tmp2); + + ILVEV_H2_SW(tmp4, tmp5, tmp6, tmp7, tmp2, tmp3); + q1 = (v16u8) __msa_ilvev_w(tmp3, tmp2); + q5 = (v16u8) __msa_ilvod_w(tmp3, tmp2); + + tmp2 = (v4i32) __msa_ilvod_h(tmp5, tmp4); + tmp3 = (v4i32) __msa_ilvod_h(tmp7, tmp6); + q3 = (v16u8) __msa_ilvev_w(tmp3, tmp2); + q7 = (v16u8) __msa_ilvod_w(tmp3, tmp2); + + ST_UB8(p7, p6, p5, p4, p3, p2, p1, p0, output, out_pitch); + output += (8 * out_pitch); + ST_UB8(q0, q1, q2, q3, q4, q5, q6, q7, output, out_pitch); +} + +static int32_t vp9_vt_lpf_t4_and_t8_8w(uint8_t *src, uint8_t *filter48, + uint8_t *src_org, int32_t pitch_org, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 p2_out, p1_out, p0_out, q0_out, q1_out, q2_out; + v16u8 flat, mask, hev, thresh, b_limit, limit; + v8u16 p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r; + v8i16 p2_filt8_r, p1_filt8_r, p0_filt8_r; + v8i16 q0_filt8_r, q1_filt8_r, q2_filt8_r; + v16i8 zero = { 0 }; + v8i16 vec0, vec1, vec2, vec3; + + /* load vector elements */ + LD_UB8(src - (4 * 16), 16, p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + limit = (v16u8) __msa_fill_b(limit_ptr); + + /* mask and hev */ + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + /* flat4 */ + VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat); + /* filter4 */ + VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, + q1_out); + + flat = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) flat); + + /* if flat is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat)) { + ILVR_B2_SH(p0_out, p1_out, q1_out, q0_out, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec2, vec3); + ST4x8_UB(vec2, vec3, (src_org - 2), pitch_org); + return 1; + } else { + ILVR_B8_UH(zero, p3, zero, p2, zero, p1, zero, p0, zero, q0, zero, q1, + zero, q2, zero, q3, p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, + q3_r); + VP9_FILTER8(p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r, p2_filt8_r, + p1_filt8_r, p0_filt8_r, q0_filt8_r, q1_filt8_r, q2_filt8_r); + + /* convert 16 bit output data into 8 bit */ + p2_r = (v8u16) __msa_pckev_b((v16i8) p2_filt8_r, (v16i8) p2_filt8_r); + p1_r = (v8u16) __msa_pckev_b((v16i8) p1_filt8_r, (v16i8) p1_filt8_r); + p0_r = (v8u16) __msa_pckev_b((v16i8) p0_filt8_r, (v16i8) p0_filt8_r); + q0_r = (v8u16) __msa_pckev_b((v16i8) q0_filt8_r, (v16i8) q0_filt8_r); + q1_r = (v8u16) __msa_pckev_b((v16i8) q1_filt8_r, (v16i8) q1_filt8_r); + q2_r = (v8u16) __msa_pckev_b((v16i8) q2_filt8_r, (v16i8) q2_filt8_r); + + /* store pixel values */ + p2_out = __msa_bmnz_v(p2, (v16u8) p2_r, flat); + p1_out = __msa_bmnz_v(p1_out, (v16u8) p1_r, flat); + p0_out = __msa_bmnz_v(p0_out, (v16u8) p0_r, flat); + q0_out = __msa_bmnz_v(q0_out, (v16u8) q0_r, flat); + q1_out = __msa_bmnz_v(q1_out, (v16u8) q1_r, flat); + q2_out = __msa_bmnz_v(q2, (v16u8) q2_r, flat); + + ST_UB4(p2_out, p1_out, p0_out, q0_out, filter48, 16); + filter48 += (4 * 16); + ST_UB2(q1_out, q2_out, filter48, 16); + filter48 += (2 * 16); + ST_UB(flat, filter48); + + return 0; + } +} + +static int32_t vp9_vt_lpf_t16_8w(uint8_t *src, uint8_t *src_org, int32_t pitch, + uint8_t *filter48) +{ + v16i8 zero = { 0 }; + v16u8 filter8, flat, flat2; + v16u8 p7, p6, p5, p4, p3, p2, p1, p0, q0, q1, q2, q3, q4, q5, q6, q7; + v8u16 p7_r_in, p6_r_in, p5_r_in, p4_r_in; + v8u16 p3_r_in, p2_r_in, p1_r_in, p0_r_in; + v8u16 q7_r_in, q6_r_in, q5_r_in, q4_r_in; + v8u16 q3_r_in, q2_r_in, q1_r_in, q0_r_in; + v8u16 tmp0_r, tmp1_r; + v8i16 r_out; + + flat = LD_UB(filter48 + 6 * 16); + + LD_UB8((src - 8 * 16), 16, p7, p6, p5, p4, p3, p2, p1, p0); + LD_UB8(src, 16, q0, q1, q2, q3, q4, q5, q6, q7); + + VP9_FLAT5(p7, p6, p5, p4, p0, q0, q4, q5, q6, q7, flat, flat2); + + /* if flat2 is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat2)) { + v8i16 vec0, vec1, vec2, vec3, vec4; + + LD_UB4(filter48, 16, p2, p1, p0, q0); + LD_UB2(filter48 + 4 * 16, 16, q1, q2); + + ILVR_B2_SH(p1, p2, q0, p0, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec3, vec4); + vec2 = (v8i16) __msa_ilvr_b((v16i8) q2, (v16i8) q1); + + src_org -= 3; + ST4x4_UB(vec3, vec3, 0, 1, 2, 3, src_org, pitch); + ST2x4_UB(vec2, 0, (src_org + 4), pitch); + src_org += (4 * pitch); + ST4x4_UB(vec4, vec4, 0, 1, 2, 3, src_org, pitch); + ST2x4_UB(vec2, 4, (src_org + 4), pitch); + + return 1; + } else { + src -= 7 * 16; + + ILVR_B8_UH(zero, p7, zero, p6, zero, p5, zero, p4, zero, p3, zero, p2, + zero, p1, zero, p0, p7_r_in, p6_r_in, p5_r_in, p4_r_in, + p3_r_in, p2_r_in, p1_r_in, p0_r_in); + q0_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q0); + + tmp0_r = p7_r_in << 3; + tmp0_r -= p7_r_in; + tmp0_r += p6_r_in; + tmp0_r += q0_r_in; + tmp1_r = p6_r_in + p5_r_in; + tmp1_r += p4_r_in; + tmp1_r += p3_r_in; + tmp1_r += p2_r_in; + tmp1_r += p1_r_in; + tmp1_r += p0_r_in; + tmp1_r += tmp0_r; + + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + p6 = __msa_bmnz_v(p6, (v16u8) r_out, flat2); + ST8x1_UB(p6, src); + src += 16; + + /* p5 */ + q1_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q1); + tmp0_r = p5_r_in - p6_r_in; + tmp0_r += q1_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + p5 = __msa_bmnz_v(p5, (v16u8) r_out, flat2); + ST8x1_UB(p5, src); + src += 16; + + /* p4 */ + q2_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q2); + tmp0_r = p4_r_in - p5_r_in; + tmp0_r += q2_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + p4 = __msa_bmnz_v(p4, (v16u8) r_out, flat2); + ST8x1_UB(p4, src); + src += 16; + + /* p3 */ + q3_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q3); + tmp0_r = p3_r_in - p4_r_in; + tmp0_r += q3_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + p3 = __msa_bmnz_v(p3, (v16u8) r_out, flat2); + ST8x1_UB(p3, src); + src += 16; + + /* p2 */ + q4_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q4); + filter8 = LD_UB(filter48); + tmp0_r = p2_r_in - p3_r_in; + tmp0_r += q4_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST8x1_UB(filter8, src); + src += 16; + + /* p1 */ + q5_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q5); + filter8 = LD_UB(filter48 + 16); + tmp0_r = p1_r_in - p2_r_in; + tmp0_r += q5_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST8x1_UB(filter8, src); + src += 16; + + /* p0 */ + q6_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q6); + filter8 = LD_UB(filter48 + 32); + tmp0_r = p0_r_in - p1_r_in; + tmp0_r += q6_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST8x1_UB(filter8, src); + src += 16; + + /* q0 */ + q7_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q7); + filter8 = LD_UB(filter48 + 48); + tmp0_r = q7_r_in - p0_r_in; + tmp0_r += q0_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST8x1_UB(filter8, src); + src += 16; + + /* q1 */ + filter8 = LD_UB(filter48 + 64); + tmp0_r = q7_r_in - q0_r_in; + tmp0_r += q1_r_in; + tmp0_r -= p6_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST8x1_UB(filter8, src); + src += 16; + + /* q2 */ + filter8 = LD_UB(filter48 + 80); + tmp0_r = q7_r_in - q1_r_in; + tmp0_r += q2_r_in; + tmp0_r -= p5_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST8x1_UB(filter8, src); + src += 16; + + /* q3 */ + tmp0_r = q7_r_in - q2_r_in; + tmp0_r += q3_r_in; + tmp0_r -= p4_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + q3 = __msa_bmnz_v(q3, (v16u8) r_out, flat2); + ST8x1_UB(q3, src); + src += 16; + + /* q4 */ + tmp0_r = q7_r_in - q3_r_in; + tmp0_r += q4_r_in; + tmp0_r -= p3_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + q4 = __msa_bmnz_v(q4, (v16u8) r_out, flat2); + ST8x1_UB(q4, src); + src += 16; + + /* q5 */ + tmp0_r = q7_r_in - q4_r_in; + tmp0_r += q5_r_in; + tmp0_r -= p2_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + q5 = __msa_bmnz_v(q5, (v16u8) r_out, flat2); + ST8x1_UB(q5, src); + src += 16; + + /* q6 */ + tmp0_r = q7_r_in - q5_r_in; + tmp0_r += q6_r_in; + tmp0_r -= p1_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) r_out, (v16i8) r_out); + q6 = __msa_bmnz_v(q6, (v16u8) r_out, flat2); + ST8x1_UB(q6, src); + + return 0; + } +} + +void ff_loop_filter_h_16_8_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + uint8_t early_exit = 0; + uint8_t transposed_input[16 * 24] ALLOC_ALIGNED(ALIGNMENT); + uint8_t *filter48 = &transposed_input[16 * 16]; + + vp9_transpose_16x8_to_8x16(src - 8, pitch, transposed_input, 16); + + early_exit = vp9_vt_lpf_t4_and_t8_8w((transposed_input + 16 * 8), + &filter48[0], src, pitch, + b_limit_ptr, limit_ptr, thresh_ptr); + + if (0 == early_exit) { + early_exit = vp9_vt_lpf_t16_8w((transposed_input + 16 * 8), src, pitch, + &filter48[0]); + + if (0 == early_exit) { + vp9_transpose_8x16_to_16x8(transposed_input, 16, src - 8, pitch); + } + } +} + +static int32_t vp9_vt_lpf_t4_and_t8_16w(uint8_t *src, uint8_t *filter48, + uint8_t *src_org, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + v16u8 p3, p2, p1, p0, q3, q2, q1, q0; + v16u8 p2_out, p1_out, p0_out, q0_out, q1_out, q2_out; + v16u8 flat, mask, hev, thresh, b_limit, limit; + v8u16 p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r; + v8u16 p3_l, p2_l, p1_l, p0_l, q0_l, q1_l, q2_l, q3_l; + v8i16 p2_filt8_r, p1_filt8_r, p0_filt8_r; + v8i16 q0_filt8_r, q1_filt8_r, q2_filt8_r; + v8i16 p2_filt8_l, p1_filt8_l, p0_filt8_l; + v8i16 q0_filt8_l, q1_filt8_l, q2_filt8_l; + v16i8 zero = { 0 }; + v8i16 vec0, vec1, vec2, vec3, vec4, vec5; + + /* load vector elements */ + LD_UB8(src - (4 * 16), 16, p3, p2, p1, p0, q0, q1, q2, q3); + + thresh = (v16u8) __msa_fill_b(thresh_ptr); + b_limit = (v16u8) __msa_fill_b(b_limit_ptr); + limit = (v16u8) __msa_fill_b(limit_ptr); + + /* mask and hev */ + LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh, + hev, mask, flat); + /* flat4 */ + VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat); + /* filter4 */ + VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out, + q1_out); + + /* if flat is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat)) { + ILVR_B2_SH(p0_out, p1_out, q1_out, q0_out, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec2, vec3); + ILVL_B2_SH(p0_out, p1_out, q1_out, q0_out, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec4, vec5); + + src_org -= 2; + ST4x8_UB(vec2, vec3, src_org, pitch); + src_org += 8 * pitch; + ST4x8_UB(vec4, vec5, src_org, pitch); + + return 1; + } else { + ILVR_B8_UH(zero, p3, zero, p2, zero, p1, zero, p0, zero, q0, zero, q1, + zero, q2, zero, q3, p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, + q3_r); + VP9_FILTER8(p3_r, p2_r, p1_r, p0_r, q0_r, q1_r, q2_r, q3_r, p2_filt8_r, + p1_filt8_r, p0_filt8_r, q0_filt8_r, q1_filt8_r, q2_filt8_r); + ILVL_B4_UH(zero, p3, zero, p2, zero, p1, zero, p0, p3_l, p2_l, p1_l, + p0_l); + ILVL_B4_UH(zero, q0, zero, q1, zero, q2, zero, q3, q0_l, q1_l, q2_l, + q3_l); + VP9_FILTER8(p3_l, p2_l, p1_l, p0_l, q0_l, q1_l, q2_l, q3_l, p2_filt8_l, + p1_filt8_l, p0_filt8_l, q0_filt8_l, q1_filt8_l, q2_filt8_l); + + /* convert 16 bit output data into 8 bit */ + PCKEV_B4_SH(p2_filt8_l, p2_filt8_r, p1_filt8_l, p1_filt8_r, p0_filt8_l, + p0_filt8_r, q0_filt8_l, q0_filt8_r, p2_filt8_r, p1_filt8_r, + p0_filt8_r, q0_filt8_r); + PCKEV_B2_SH(q1_filt8_l, q1_filt8_r, q2_filt8_l, q2_filt8_r, q1_filt8_r, + q2_filt8_r); + + /* store pixel values */ + p2_out = __msa_bmnz_v(p2, (v16u8) p2_filt8_r, flat); + p1_out = __msa_bmnz_v(p1_out, (v16u8) p1_filt8_r, flat); + p0_out = __msa_bmnz_v(p0_out, (v16u8) p0_filt8_r, flat); + q0_out = __msa_bmnz_v(q0_out, (v16u8) q0_filt8_r, flat); + q1_out = __msa_bmnz_v(q1_out, (v16u8) q1_filt8_r, flat); + q2_out = __msa_bmnz_v(q2, (v16u8) q2_filt8_r, flat); + + ST_UB4(p2_out, p1_out, p0_out, q0_out, filter48, 16); + filter48 += (4 * 16); + ST_UB2(q1_out, q2_out, filter48, 16); + filter48 += (2 * 16); + ST_UB(flat, filter48); + + return 0; + } +} + +static int32_t vp9_vt_lpf_t16_16w(uint8_t *src, uint8_t *src_org, int32_t pitch, + uint8_t *filter48) +{ + v16u8 flat, flat2, filter8; + v16i8 zero = { 0 }; + v16u8 p7, p6, p5, p4, p3, p2, p1, p0, q0, q1, q2, q3, q4, q5, q6, q7; + v8u16 p7_r_in, p6_r_in, p5_r_in, p4_r_in; + v8u16 p3_r_in, p2_r_in, p1_r_in, p0_r_in; + v8u16 q7_r_in, q6_r_in, q5_r_in, q4_r_in; + v8u16 q3_r_in, q2_r_in, q1_r_in, q0_r_in; + v8u16 p7_l_in, p6_l_in, p5_l_in, p4_l_in; + v8u16 p3_l_in, p2_l_in, p1_l_in, p0_l_in; + v8u16 q7_l_in, q6_l_in, q5_l_in, q4_l_in; + v8u16 q3_l_in, q2_l_in, q1_l_in, q0_l_in; + v8u16 tmp0_r, tmp1_r, tmp0_l, tmp1_l; + v8i16 l_out, r_out; + + flat = LD_UB(filter48 + 6 * 16); + + LD_UB8((src - 8 * 16), 16, p7, p6, p5, p4, p3, p2, p1, p0); + LD_UB8(src, 16, q0, q1, q2, q3, q4, q5, q6, q7); + + VP9_FLAT5(p7, p6, p5, p4, p0, q0, q4, q5, q6, q7, flat, flat2); + + /* if flat2 is zero for all pixels, then no need to calculate other filter */ + if (__msa_test_bz_v(flat2)) { + v8i16 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + + LD_UB4(filter48, 16, p2, p1, p0, q0); + LD_UB2(filter48 + 4 * 16, 16, q1, q2); + + ILVR_B2_SH(p1, p2, q0, p0, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec3, vec4); + ILVL_B2_SH(p1, p2, q0, p0, vec0, vec1); + ILVRL_H2_SH(vec1, vec0, vec6, vec7); + ILVRL_B2_SH(q2, q1, vec2, vec5); + + src_org -= 3; + ST4x4_UB(vec3, vec3, 0, 1, 2, 3, src_org, pitch); + ST2x4_UB(vec2, 0, (src_org + 4), pitch); + src_org += (4 * pitch); + ST4x4_UB(vec4, vec4, 0, 1, 2, 3, src_org, pitch); + ST2x4_UB(vec2, 4, (src_org + 4), pitch); + src_org += (4 * pitch); + ST4x4_UB(vec6, vec6, 0, 1, 2, 3, src_org, pitch); + ST2x4_UB(vec5, 0, (src_org + 4), pitch); + src_org += (4 * pitch); + ST4x4_UB(vec7, vec7, 0, 1, 2, 3, src_org, pitch); + ST2x4_UB(vec5, 4, (src_org + 4), pitch); + + return 1; + } else { + src -= 7 * 16; + + ILVR_B8_UH(zero, p7, zero, p6, zero, p5, zero, p4, zero, p3, zero, p2, + zero, p1, zero, p0, p7_r_in, p6_r_in, p5_r_in, p4_r_in, + p3_r_in, p2_r_in, p1_r_in, p0_r_in); + q0_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q0); + + tmp0_r = p7_r_in << 3; + tmp0_r -= p7_r_in; + tmp0_r += p6_r_in; + tmp0_r += q0_r_in; + tmp1_r = p6_r_in + p5_r_in; + tmp1_r += p4_r_in; + tmp1_r += p3_r_in; + tmp1_r += p2_r_in; + tmp1_r += p1_r_in; + tmp1_r += p0_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + + ILVL_B4_UH(zero, p7, zero, p6, zero, p5, zero, p4, p7_l_in, p6_l_in, + p5_l_in, p4_l_in); + ILVL_B4_UH(zero, p3, zero, p2, zero, p1, zero, p0, p3_l_in, p2_l_in, + p1_l_in, p0_l_in); + q0_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q0); + + tmp0_l = p7_l_in << 3; + tmp0_l -= p7_l_in; + tmp0_l += p6_l_in; + tmp0_l += q0_l_in; + tmp1_l = p6_l_in + p5_l_in; + tmp1_l += p4_l_in; + tmp1_l += p3_l_in; + tmp1_l += p2_l_in; + tmp1_l += p1_l_in; + tmp1_l += p0_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + p6 = __msa_bmnz_v(p6, (v16u8) r_out, flat2); + ST_UB(p6, src); + src += 16; + + /* p5 */ + q1_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q1); + tmp0_r = p5_r_in - p6_r_in; + tmp0_r += q1_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + q1_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q1); + tmp0_l = p5_l_in - p6_l_in; + tmp0_l += q1_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + p5 = __msa_bmnz_v(p5, (v16u8) r_out, flat2); + ST_UB(p5, src); + src += 16; + + /* p4 */ + q2_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q2); + tmp0_r = p4_r_in - p5_r_in; + tmp0_r += q2_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + q2_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q2); + tmp0_l = p4_l_in - p5_l_in; + tmp0_l += q2_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + p4 = __msa_bmnz_v(p4, (v16u8) r_out, flat2); + ST_UB(p4, src); + src += 16; + + /* p3 */ + q3_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q3); + tmp0_r = p3_r_in - p4_r_in; + tmp0_r += q3_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + q3_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q3); + tmp0_l = p3_l_in - p4_l_in; + tmp0_l += q3_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + p3 = __msa_bmnz_v(p3, (v16u8) r_out, flat2); + ST_UB(p3, src); + src += 16; + + /* p2 */ + q4_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q4); + filter8 = LD_UB(filter48); + tmp0_r = p2_r_in - p3_r_in; + tmp0_r += q4_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + q4_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q4); + tmp0_l = p2_l_in - p3_l_in; + tmp0_l += q4_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST_UB(filter8, src); + src += 16; + + /* p1 */ + q5_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q5); + filter8 = LD_UB(filter48 + 16); + tmp0_r = p1_r_in - p2_r_in; + tmp0_r += q5_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + q5_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q5); + tmp0_l = p1_l_in - p2_l_in; + tmp0_l += q5_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) (tmp1_l), 4); + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST_UB(filter8, src); + src += 16; + + /* p0 */ + q6_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q6); + filter8 = LD_UB(filter48 + 32); + tmp0_r = p0_r_in - p1_r_in; + tmp0_r += q6_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + q6_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q6); + tmp0_l = p0_l_in - p1_l_in; + tmp0_l += q6_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST_UB(filter8, src); + src += 16; + + /* q0 */ + q7_r_in = (v8u16) __msa_ilvr_b(zero, (v16i8) q7); + filter8 = LD_UB(filter48 + 48); + tmp0_r = q7_r_in - p0_r_in; + tmp0_r += q0_r_in; + tmp0_r -= p7_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + q7_l_in = (v8u16) __msa_ilvl_b(zero, (v16i8) q7); + tmp0_l = q7_l_in - p0_l_in; + tmp0_l += q0_l_in; + tmp0_l -= p7_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST_UB(filter8, src); + src += 16; + + /* q1 */ + filter8 = LD_UB(filter48 + 64); + tmp0_r = q7_r_in - q0_r_in; + tmp0_r += q1_r_in; + tmp0_r -= p6_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + tmp0_l = q7_l_in - q0_l_in; + tmp0_l += q1_l_in; + tmp0_l -= p6_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST_UB(filter8, src); + src += 16; + + /* q2 */ + filter8 = LD_UB(filter48 + 80); + tmp0_r = q7_r_in - q1_r_in; + tmp0_r += q2_r_in; + tmp0_r -= p5_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + tmp0_l = q7_l_in - q1_l_in; + tmp0_l += q2_l_in; + tmp0_l -= p5_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + filter8 = __msa_bmnz_v(filter8, (v16u8) r_out, flat2); + ST_UB(filter8, src); + src += 16; + + /* q3 */ + tmp0_r = q7_r_in - q2_r_in; + tmp0_r += q3_r_in; + tmp0_r -= p4_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + tmp0_l = q7_l_in - q2_l_in; + tmp0_l += q3_l_in; + tmp0_l -= p4_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + q3 = __msa_bmnz_v(q3, (v16u8) r_out, flat2); + ST_UB(q3, src); + src += 16; + + /* q4 */ + tmp0_r = q7_r_in - q3_r_in; + tmp0_r += q4_r_in; + tmp0_r -= p3_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + tmp0_l = q7_l_in - q3_l_in; + tmp0_l += q4_l_in; + tmp0_l -= p3_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + q4 = __msa_bmnz_v(q4, (v16u8) r_out, flat2); + ST_UB(q4, src); + src += 16; + + /* q5 */ + tmp0_r = q7_r_in - q4_r_in; + tmp0_r += q5_r_in; + tmp0_r -= p2_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + tmp0_l = q7_l_in - q4_l_in; + tmp0_l += q5_l_in; + tmp0_l -= p2_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + q5 = __msa_bmnz_v(q5, (v16u8) r_out, flat2); + ST_UB(q5, src); + src += 16; + + /* q6 */ + tmp0_r = q7_r_in - q5_r_in; + tmp0_r += q6_r_in; + tmp0_r -= p1_r_in; + tmp1_r += tmp0_r; + r_out = __msa_srari_h((v8i16) tmp1_r, 4); + tmp0_l = q7_l_in - q5_l_in; + tmp0_l += q6_l_in; + tmp0_l -= p1_l_in; + tmp1_l += tmp0_l; + l_out = __msa_srari_h((v8i16) tmp1_l, 4); + r_out = (v8i16) __msa_pckev_b((v16i8) l_out, (v16i8) r_out); + q6 = __msa_bmnz_v(q6, (v16u8) r_out, flat2); + ST_UB(q6, src); + + return 0; + } +} + +void ff_loop_filter_h_16_16_msa(uint8_t *src, int32_t pitch, + int32_t b_limit_ptr, + int32_t limit_ptr, + int32_t thresh_ptr) +{ + uint8_t early_exit = 0; + uint8_t transposed_input[16 * 24] ALLOC_ALIGNED(ALIGNMENT); + uint8_t *filter48 = &transposed_input[16 * 16]; + + vp9_transpose_16x16((src - 8), pitch, &transposed_input[0], 16); + + early_exit = vp9_vt_lpf_t4_and_t8_16w((transposed_input + 16 * 8), + &filter48[0], src, pitch, + b_limit_ptr, limit_ptr, thresh_ptr); + + if (0 == early_exit) { + early_exit = vp9_vt_lpf_t16_16w((transposed_input + 16 * 8), src, pitch, + &filter48[0]); + + if (0 == early_exit) { + vp9_transpose_16x16(transposed_input, 16, (src - 8), pitch); + } + } +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp9_mc_msa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp9_mc_msa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/vp9_mc_msa.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/vp9_mc_msa.c 2015-07-27 17:20:04.000000000 +0000 @@ -0,0 +1,4510 @@ +/* + * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/vp9dsp.h" +#include "libavutil/mips/generic_macros_msa.h" +#include "vp9dsp_mips.h" + +static const uint8_t mc_filt_mask_arr[16 * 3] = { + /* 8 width cases */ + 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, + /* 4 width cases */ + 0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20, + /* 4 width cases */ + 8, 9, 9, 10, 10, 11, 11, 12, 24, 25, 25, 26, 26, 27, 27, 28 +}; + +static const int8_t vp9_bilinear_filters_msa[15][2] = { + {120, 8}, + {112, 16}, + {104, 24}, + {96, 32}, + {88, 40}, + {80, 48}, + {72, 56}, + {64, 64}, + {56, 72}, + {48, 80}, + {40, 88}, + {32, 96}, + {24, 104}, + {16, 112}, + {8, 120} +}; + +#define FILT_8TAP_DPADD_S_H(vec0, vec1, vec2, vec3, \ + filt0, filt1, filt2, filt3) \ +( { \ + v8i16 tmp0, tmp1; \ + \ + tmp0 = __msa_dotp_s_h((v16i8) vec0, (v16i8) filt0); \ + tmp0 = __msa_dpadd_s_h(tmp0, (v16i8) vec1, (v16i8) filt1); \ + tmp1 = __msa_dotp_s_h((v16i8) vec2, (v16i8) filt2); \ + tmp1 = __msa_dpadd_s_h(tmp1, (v16i8) vec3, (v16i8) filt3); \ + tmp0 = __msa_adds_s_h(tmp0, tmp1); \ + \ + tmp0; \ +} ) + +#define HORIZ_8TAP_FILT(src0, src1, mask0, mask1, mask2, mask3, \ + filt_h0, filt_h1, filt_h2, filt_h3) \ +( { \ + v16i8 vec0_m, vec1_m, vec2_m, vec3_m; \ + v8i16 hz_out_m; \ + \ + VSHF_B4_SB(src0, src1, mask0, mask1, mask2, mask3, \ + vec0_m, vec1_m, vec2_m, vec3_m); \ + hz_out_m = FILT_8TAP_DPADD_S_H(vec0_m, vec1_m, vec2_m, vec3_m, \ + filt_h0, filt_h1, filt_h2, filt_h3); \ + \ + hz_out_m = __msa_srari_h(hz_out_m, 7); \ + hz_out_m = __msa_sat_s_h(hz_out_m, 7); \ + \ + hz_out_m; \ +} ) + +#define HORIZ_8TAP_4WID_4VECS_FILT(src0, src1, src2, src3, \ + mask0, mask1, mask2, mask3, \ + filt0, filt1, filt2, filt3, \ + out0, out1) \ +{ \ + v16i8 vec0_m, vec1_m, vec2_m, vec3_m, vec4_m, vec5_m, vec6_m, vec7_m; \ + v8i16 res0_m, res1_m, res2_m, res3_m; \ + \ + VSHF_B2_SB(src0, src1, src2, src3, mask0, mask0, vec0_m, vec1_m); \ + DOTP_SB2_SH(vec0_m, vec1_m, filt0, filt0, res0_m, res1_m); \ + VSHF_B2_SB(src0, src1, src2, src3, mask1, mask1, vec2_m, vec3_m); \ + DPADD_SB2_SH(vec2_m, vec3_m, filt1, filt1, res0_m, res1_m); \ + VSHF_B2_SB(src0, src1, src2, src3, mask2, mask2, vec4_m, vec5_m); \ + DOTP_SB2_SH(vec4_m, vec5_m, filt2, filt2, res2_m, res3_m); \ + VSHF_B2_SB(src0, src1, src2, src3, mask3, mask3, vec6_m, vec7_m); \ + DPADD_SB2_SH(vec6_m, vec7_m, filt3, filt3, res2_m, res3_m); \ + ADDS_SH2_SH(res0_m, res2_m, res1_m, res3_m, out0, out1); \ +} + +#define HORIZ_8TAP_8WID_4VECS_FILT(src0, src1, src2, src3, \ + mask0, mask1, mask2, mask3, \ + filt0, filt1, filt2, filt3, \ + out0, out1, out2, out3) \ +{ \ + v16i8 vec0_m, vec1_m, vec2_m, vec3_m, vec4_m, vec5_m, vec6_m, vec7_m; \ + v8i16 res0_m, res1_m, res2_m, res3_m, res4_m, res5_m, res6_m, res7_m; \ + \ + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec0_m, vec1_m); \ + VSHF_B2_SB(src2, src2, src3, src3, mask0, mask0, vec2_m, vec3_m); \ + DOTP_SB4_SH(vec0_m, vec1_m, vec2_m, vec3_m, filt0, filt0, filt0, filt0, \ + res0_m, res1_m, res2_m, res3_m); \ + VSHF_B2_SB(src0, src0, src1, src1, mask2, mask2, vec0_m, vec1_m); \ + VSHF_B2_SB(src2, src2, src3, src3, mask2, mask2, vec2_m, vec3_m); \ + DOTP_SB4_SH(vec0_m, vec1_m, vec2_m, vec3_m, filt2, filt2, filt2, filt2, \ + res4_m, res5_m, res6_m, res7_m); \ + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec4_m, vec5_m); \ + VSHF_B2_SB(src2, src2, src3, src3, mask1, mask1, vec6_m, vec7_m); \ + DPADD_SB4_SH(vec4_m, vec5_m, vec6_m, vec7_m, filt1, filt1, filt1, filt1, \ + res0_m, res1_m, res2_m, res3_m); \ + VSHF_B2_SB(src0, src0, src1, src1, mask3, mask3, vec4_m, vec5_m); \ + VSHF_B2_SB(src2, src2, src3, src3, mask3, mask3, vec6_m, vec7_m); \ + DPADD_SB4_SH(vec4_m, vec5_m, vec6_m, vec7_m, filt3, filt3, filt3, filt3, \ + res4_m, res5_m, res6_m, res7_m); \ + ADDS_SH4_SH(res0_m, res4_m, res1_m, res5_m, res2_m, res6_m, res3_m, \ + res7_m, out0, out1, out2, out3); \ +} + +#define PCKEV_XORI128_AVG_ST_UB(in0, in1, dst, pdst) \ +{ \ + v16u8 tmp_m; \ + \ + tmp_m = PCKEV_XORI128_UB(in1, in0); \ + tmp_m = __msa_aver_u_b(tmp_m, (v16u8) dst); \ + ST_UB(tmp_m, (pdst)); \ +} + +#define PCKEV_AVG_ST_UB(in0, in1, dst, pdst) \ +{ \ + v16u8 tmp_m; \ + \ + tmp_m = (v16u8) __msa_pckev_b((v16i8) in0, (v16i8) in1); \ + tmp_m = __msa_aver_u_b(tmp_m, (v16u8) dst); \ + ST_UB(tmp_m, (pdst)); \ +} + +#define PCKEV_AVG_ST8x4_UB(in1, dst0, in2, dst1, in3, dst2, in4, dst3, \ + pdst, stride) \ +{ \ + v16u8 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + uint8_t *pdst_m = (uint8_t *) (pdst); \ + \ + PCKEV_B2_UB(in2, in1, in4, in3, tmp0_m, tmp1_m); \ + PCKEV_D2_UB(dst1, dst0, dst3, dst2, tmp2_m, tmp3_m); \ + AVER_UB2_UB(tmp0_m, tmp2_m, tmp1_m, tmp3_m, tmp0_m, tmp1_m); \ + ST8x4_UB(tmp0_m, tmp1_m, pdst_m, stride); \ +} + +static void common_hz_8t_4x4_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16u8 mask0, mask1, mask2, mask3, out; + v16i8 src0, src1, src2, src3, filt0, filt1, filt2, filt3; + v8i16 filt, out0, out1; + + mask0 = LD_UB(&mc_filt_mask_arr[16]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_8TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, out0, out1); + SRARI_H2_SH(out0, out1, 7); + SAT_SH2_SH(out0, out1, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); +} + +static void common_hz_8t_4x8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 filt0, filt1, filt2, filt3; + v16i8 src0, src1, src2, src3; + v16u8 mask0, mask1, mask2, mask3, out; + v8i16 filt, out0, out1, out2, out3; + + mask0 = LD_UB(&mc_filt_mask_arr[16]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + HORIZ_8TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, out0, out1); + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_8TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + out = PCKEV_XORI128_UB(out2, out3); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); +} + +static void common_hz_8t_4x16_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16u8 mask0, mask1, mask2, mask3, out; + v16i8 src0, src1, src2, src3, filt0, filt1, filt2, filt3; + v8i16 filt, out0, out1, out2, out3; + + mask0 = LD_UB(&mc_filt_mask_arr[16]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + HORIZ_8TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, out0, out1); + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + HORIZ_8TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + out = PCKEV_XORI128_UB(out2, out3); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + HORIZ_8TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, out0, out1); + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + HORIZ_8TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, out2, out3); + + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + out = PCKEV_XORI128_UB(out2, out3); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); +} + +static void common_hz_8t_4w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + if (4 == height) { + common_hz_8t_4x4_msa(src, src_stride, dst, dst_stride, filter); + } else if (8 == height) { + common_hz_8t_4x8_msa(src, src_stride, dst, dst_stride, filter); + } else if (16 == height) { + common_hz_8t_4x16_msa(src, src_stride, dst, dst_stride, filter); + } +} + +static void common_hz_8t_8x4_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, filt0, filt1, filt2, filt3; + v16u8 mask0, mask1, mask2, mask3, tmp0, tmp1; + v8i16 filt, out0, out1, out2, out3; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_8TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, out0, out1, + out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + tmp0 = PCKEV_XORI128_UB(out0, out1); + tmp1 = PCKEV_XORI128_UB(out2, out3); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); +} + +static void common_hz_8t_8x8mult_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, filt0, filt1, filt2, filt3; + v16u8 mask0, mask1, mask2, mask3, tmp0, tmp1; + v8i16 filt, out0, out1, out2, out3; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + HORIZ_8TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, out0, + out1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + tmp0 = PCKEV_XORI128_UB(out0, out1); + tmp1 = PCKEV_XORI128_UB(out2, out3); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void common_hz_8t_8w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + if (4 == height) { + common_hz_8t_8x4_msa(src, src_stride, dst, dst_stride, filter); + } else { + common_hz_8t_8x8mult_msa(src, src_stride, dst, dst_stride, filter, + height); + } +} + +static void common_hz_8t_16w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, filt0, filt1, filt2, filt3; + v16u8 mask0, mask1, mask2, mask3, out; + v8i16 filt, out0, out1, out2, out3; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + for (loop_cnt = (height >> 1); loop_cnt--;) { + LD_SB2(src, src_stride, src0, src2); + LD_SB2(src + 8, src_stride, src1, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (2 * src_stride); + HORIZ_8TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, out0, + out1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST_UB(out, dst); + dst += dst_stride; + out = PCKEV_XORI128_UB(out2, out3); + ST_UB(out, dst); + dst += dst_stride; + } +} + +static void common_hz_8t_32w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, filt0, filt1, filt2, filt3; + v16u8 mask0, mask1, mask2, mask3, out; + v8i16 filt, out0, out1, out2, out3; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + for (loop_cnt = (height >> 1); loop_cnt--;) { + src0 = LD_SB(src); + src2 = LD_SB(src + 16); + src3 = LD_SB(src + 24); + src1 = __msa_sldi_b(src2, src0, 8); + src += src_stride; + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_8TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, out0, + out1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + + src0 = LD_SB(src); + src2 = LD_SB(src + 16); + src3 = LD_SB(src + 24); + src1 = __msa_sldi_b(src2, src0, 8); + src += src_stride; + + out = PCKEV_XORI128_UB(out0, out1); + ST_UB(out, dst); + out = PCKEV_XORI128_UB(out2, out3); + ST_UB(out, dst + 16); + dst += dst_stride; + + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_8TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, out0, + out1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST_UB(out, dst); + out = PCKEV_XORI128_UB(out2, out3); + ST_UB(out, dst + 16); + dst += dst_stride; + } +} + +static void common_hz_8t_64w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + int32_t loop_cnt; + v16i8 src0, src1, src2, src3, filt0, filt1, filt2, filt3; + v16u8 mask0, mask1, mask2, mask3, out; + v8i16 filt, out0, out1, out2, out3; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + for (loop_cnt = height; loop_cnt--;) { + src0 = LD_SB(src); + src2 = LD_SB(src + 16); + src3 = LD_SB(src + 24); + src1 = __msa_sldi_b(src2, src0, 8); + + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_8TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, + mask2, mask3, filt0, filt1, filt2, filt3, + out0, out1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST_UB(out, dst); + out = PCKEV_XORI128_UB(out2, out3); + ST_UB(out, dst + 16); + + src0 = LD_SB(src + 32); + src2 = LD_SB(src + 48); + src3 = LD_SB(src + 56); + src1 = __msa_sldi_b(src2, src0, 8); + src += src_stride; + + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_8TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, + mask2, mask3, filt0, filt1, filt2, filt3, + out0, out1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + out = PCKEV_XORI128_UB(out0, out1); + ST_UB(out, dst + 32); + out = PCKEV_XORI128_UB(out2, out3); + ST_UB(out, dst + 48); + dst += dst_stride; + } +} + +static void common_vt_8t_4w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16i8 src10_r, src32_r, src54_r, src76_r, src98_r, src21_r, src43_r; + v16i8 src65_r, src87_r, src109_r, src2110, src4332, src6554, src8776; + v16i8 src10998, filt0, filt1, filt2, filt3; + v16u8 out; + v8i16 filt, out10, out32; + + src -= (3 * src_stride); + + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); + src += (7 * src_stride); + + ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r, + src54_r, src21_r); + ILVR_B2_SB(src4, src3, src6, src5, src43_r, src65_r); + ILVR_D3_SB(src21_r, src10_r, src43_r, src32_r, src65_r, src54_r, src2110, + src4332, src6554); + XORI_B3_128_SB(src2110, src4332, src6554); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + src += (4 * src_stride); + + ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_r, + src87_r, src98_r, src109_r); + ILVR_D2_SB(src87_r, src76_r, src109_r, src98_r, src8776, src10998); + XORI_B2_128_SB(src8776, src10998); + out10 = FILT_8TAP_DPADD_S_H(src2110, src4332, src6554, src8776, filt0, + filt1, filt2, filt3); + out32 = FILT_8TAP_DPADD_S_H(src4332, src6554, src8776, src10998, filt0, + filt1, filt2, filt3); + SRARI_H2_SH(out10, out32, 7); + SAT_SH2_SH(out10, out32, 7); + out = PCKEV_XORI128_UB(out10, out32); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + + src2110 = src6554; + src4332 = src8776; + src6554 = src10998; + src6 = src10; + } +} + +static void common_vt_8t_8w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16i8 src10_r, src32_r, src54_r, src76_r, src98_r, src21_r, src43_r; + v16i8 src65_r, src87_r, src109_r, filt0, filt1, filt2, filt3; + v16u8 tmp0, tmp1; + v8i16 filt, out0_r, out1_r, out2_r, out3_r; + + src -= (3 * src_stride); + + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); + XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); + src += (7 * src_stride); + ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r, + src54_r, src21_r); + ILVR_B2_SB(src4, src3, src6, src5, src43_r, src65_r); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + XORI_B4_128_SB(src7, src8, src9, src10); + src += (4 * src_stride); + + ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_r, + src87_r, src98_r, src109_r); + out0_r = FILT_8TAP_DPADD_S_H(src10_r, src32_r, src54_r, src76_r, filt0, + filt1, filt2, filt3); + out1_r = FILT_8TAP_DPADD_S_H(src21_r, src43_r, src65_r, src87_r, filt0, + filt1, filt2, filt3); + out2_r = FILT_8TAP_DPADD_S_H(src32_r, src54_r, src76_r, src98_r, filt0, + filt1, filt2, filt3); + out3_r = FILT_8TAP_DPADD_S_H(src43_r, src65_r, src87_r, src109_r, filt0, + filt1, filt2, filt3); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + tmp0 = PCKEV_XORI128_UB(out0_r, out1_r); + tmp1 = PCKEV_XORI128_UB(out2_r, out3_r); + ST8x4_UB(tmp0, tmp1, dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src54_r; + src32_r = src76_r; + src54_r = src98_r; + src21_r = src65_r; + src43_r = src87_r; + src65_r = src109_r; + src6 = src10; + } +} + +static void common_vt_8t_16w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16i8 filt0, filt1, filt2, filt3; + v16i8 src10_r, src32_r, src54_r, src76_r, src98_r, src21_r, src43_r; + v16i8 src65_r, src87_r, src109_r, src10_l, src32_l, src54_l, src76_l; + v16i8 src98_l, src21_l, src43_l, src65_l, src87_l, src109_l; + v16u8 tmp0, tmp1, tmp2, tmp3; + v8i16 filt, out0_r, out1_r, out2_r, out3_r, out0_l, out1_l, out2_l, out3_l; + + src -= (3 * src_stride); + + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); + XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); + src += (7 * src_stride); + ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r, + src54_r, src21_r); + ILVR_B2_SB(src4, src3, src6, src5, src43_r, src65_r); + ILVL_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_l, src32_l, + src54_l, src21_l); + ILVL_B2_SB(src4, src3, src6, src5, src43_l, src65_l); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + XORI_B4_128_SB(src7, src8, src9, src10); + src += (4 * src_stride); + + ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_r, + src87_r, src98_r, src109_r); + ILVL_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_l, + src87_l, src98_l, src109_l); + out0_r = FILT_8TAP_DPADD_S_H(src10_r, src32_r, src54_r, src76_r, filt0, + filt1, filt2, filt3); + out1_r = FILT_8TAP_DPADD_S_H(src21_r, src43_r, src65_r, src87_r, filt0, + filt1, filt2, filt3); + out2_r = FILT_8TAP_DPADD_S_H(src32_r, src54_r, src76_r, src98_r, filt0, + filt1, filt2, filt3); + out3_r = FILT_8TAP_DPADD_S_H(src43_r, src65_r, src87_r, src109_r, filt0, + filt1, filt2, filt3); + out0_l = FILT_8TAP_DPADD_S_H(src10_l, src32_l, src54_l, src76_l, filt0, + filt1, filt2, filt3); + out1_l = FILT_8TAP_DPADD_S_H(src21_l, src43_l, src65_l, src87_l, filt0, + filt1, filt2, filt3); + out2_l = FILT_8TAP_DPADD_S_H(src32_l, src54_l, src76_l, src98_l, filt0, + filt1, filt2, filt3); + out3_l = FILT_8TAP_DPADD_S_H(src43_l, src65_l, src87_l, src109_l, filt0, + filt1, filt2, filt3); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SRARI_H4_SH(out0_l, out1_l, out2_l, out3_l, 7); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SAT_SH4_SH(out0_l, out1_l, out2_l, out3_l, 7); + PCKEV_B4_UB(out0_l, out0_r, out1_l, out1_r, out2_l, out2_r, out3_l, + out3_r, tmp0, tmp1, tmp2, tmp3); + XORI_B4_128_UB(tmp0, tmp1, tmp2, tmp3); + ST_UB4(tmp0, tmp1, tmp2, tmp3, dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src54_r; + src32_r = src76_r; + src54_r = src98_r; + src21_r = src65_r; + src43_r = src87_r; + src65_r = src109_r; + src10_l = src54_l; + src32_l = src76_l; + src54_l = src98_l; + src21_l = src65_l; + src43_l = src87_l; + src65_l = src109_l; + src6 = src10; + } +} + +static void common_vt_8t_16w_mult_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height, + int32_t width) +{ + const uint8_t *src_tmp; + uint8_t *dst_tmp; + uint32_t loop_cnt, cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16i8 filt0, filt1, filt2, filt3; + v16i8 src10_r, src32_r, src54_r, src76_r, src98_r, src21_r, src43_r; + v16i8 src65_r, src87_r, src109_r, src10_l, src32_l, src54_l, src76_l; + v16i8 src98_l, src21_l, src43_l, src65_l, src87_l, src109_l; + v16u8 tmp0, tmp1, tmp2, tmp3; + v8i16 filt, out0_r, out1_r, out2_r, out3_r, out0_l, out1_l, out2_l, out3_l; + + src -= (3 * src_stride); + + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + for (cnt = (width >> 4); cnt--;) { + src_tmp = src; + dst_tmp = dst; + + LD_SB7(src_tmp, src_stride, src0, src1, src2, src3, src4, src5, src6); + XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); + src_tmp += (7 * src_stride); + ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, + src32_r, src54_r, src21_r); + ILVR_B2_SB(src4, src3, src6, src5, src43_r, src65_r); + ILVL_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_l, + src32_l, src54_l, src21_l); + ILVL_B2_SB(src4, src3, src6, src5, src43_l, src65_l); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src_tmp, src_stride, src7, src8, src9, src10); + XORI_B4_128_SB(src7, src8, src9, src10); + src_tmp += (4 * src_stride); + ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_r, + src87_r, src98_r, src109_r); + ILVL_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_l, + src87_l, src98_l, src109_l); + out0_r = FILT_8TAP_DPADD_S_H(src10_r, src32_r, src54_r, src76_r, + filt0, filt1, filt2, filt3); + out1_r = FILT_8TAP_DPADD_S_H(src21_r, src43_r, src65_r, src87_r, + filt0, filt1, filt2, filt3); + out2_r = FILT_8TAP_DPADD_S_H(src32_r, src54_r, src76_r, src98_r, + filt0, filt1, filt2, filt3); + out3_r = FILT_8TAP_DPADD_S_H(src43_r, src65_r, src87_r, src109_r, + filt0, filt1, filt2, filt3); + out0_l = FILT_8TAP_DPADD_S_H(src10_l, src32_l, src54_l, src76_l, + filt0, filt1, filt2, filt3); + out1_l = FILT_8TAP_DPADD_S_H(src21_l, src43_l, src65_l, src87_l, + filt0, filt1, filt2, filt3); + out2_l = FILT_8TAP_DPADD_S_H(src32_l, src54_l, src76_l, src98_l, + filt0, filt1, filt2, filt3); + out3_l = FILT_8TAP_DPADD_S_H(src43_l, src65_l, src87_l, src109_l, + filt0, filt1, filt2, filt3); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SRARI_H4_SH(out0_l, out1_l, out2_l, out3_l, 7); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SAT_SH4_SH(out0_l, out1_l, out2_l, out3_l, 7); + PCKEV_B4_UB(out0_l, out0_r, out1_l, out1_r, out2_l, out2_r, out3_l, + out3_r, tmp0, tmp1, tmp2, tmp3); + XORI_B4_128_UB(tmp0, tmp1, tmp2, tmp3); + ST_UB4(tmp0, tmp1, tmp2, tmp3, dst_tmp, dst_stride); + dst_tmp += (4 * dst_stride); + + src10_r = src54_r; + src32_r = src76_r; + src54_r = src98_r; + src21_r = src65_r; + src43_r = src87_r; + src65_r = src109_r; + src10_l = src54_l; + src32_l = src76_l; + src54_l = src98_l; + src21_l = src65_l; + src43_l = src87_l; + src65_l = src109_l; + src6 = src10; + } + + src += 16; + dst += 16; + } +} + +static void common_vt_8t_32w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + common_vt_8t_16w_mult_msa(src, src_stride, dst, dst_stride, filter, height, + 32); +} + +static void common_vt_8t_64w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + common_vt_8t_16w_mult_msa(src, src_stride, dst, dst_stride, filter, height, + 64); +} + +static void common_hv_8ht_8vt_4w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16i8 filt_hz0, filt_hz1, filt_hz2, filt_hz3; + v16u8 mask0, mask1, mask2, mask3, out; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6; + v8i16 hz_out7, hz_out8, hz_out9, tmp0, tmp1, out0, out1, out2, out3, out4; + v8i16 filt, filt_vt0, filt_vt1, filt_vt2, filt_vt3; + + mask0 = LD_UB(&mc_filt_mask_arr[16]); + src -= (3 + 3 * src_stride); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt_hz0, filt_hz1, filt_hz2, filt_hz3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); + XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); + src += (7 * src_stride); + + hz_out0 = HORIZ_8TAP_FILT(src0, src1, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out2 = HORIZ_8TAP_FILT(src2, src3, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out4 = HORIZ_8TAP_FILT(src4, src5, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out5 = HORIZ_8TAP_FILT(src5, src6, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + SLDI_B2_SH(hz_out2, hz_out4, hz_out0, hz_out2, hz_out1, hz_out3, 8); + + filt = LD_SH(filter_vert); + SPLATI_H4_SH(filt, 0, 1, 2, 3, filt_vt0, filt_vt1, filt_vt2, filt_vt3); + + ILVEV_B2_SH(hz_out0, hz_out1, hz_out2, hz_out3, out0, out1); + out2 = (v8i16) __msa_ilvev_b((v16i8) hz_out5, (v16i8) hz_out4); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + XORI_B4_128_SB(src7, src8, src9, src10); + src += (4 * src_stride); + + hz_out7 = HORIZ_8TAP_FILT(src7, src8, mask0, mask1, mask2, mask3, + filt_hz0, filt_hz1, filt_hz2, filt_hz3); + hz_out6 = (v8i16) __msa_sldi_b((v16i8) hz_out7, (v16i8) hz_out5, 8); + out3 = (v8i16) __msa_ilvev_b((v16i8) hz_out7, (v16i8) hz_out6); + tmp0 = FILT_8TAP_DPADD_S_H(out0, out1, out2, out3, filt_vt0, filt_vt1, + filt_vt2, filt_vt3); + + hz_out9 = HORIZ_8TAP_FILT(src9, src10, mask0, mask1, mask2, mask3, + filt_hz0, filt_hz1, filt_hz2, filt_hz3); + hz_out8 = (v8i16) __msa_sldi_b((v16i8) hz_out9, (v16i8) hz_out7, 8); + out4 = (v8i16) __msa_ilvev_b((v16i8) hz_out9, (v16i8) hz_out8); + tmp1 = FILT_8TAP_DPADD_S_H(out1, out2, out3, out4, filt_vt0, filt_vt1, + filt_vt2, filt_vt3); + SRARI_H2_SH(tmp0, tmp1, 7); + SAT_SH2_SH(tmp0, tmp1, 7); + out = PCKEV_XORI128_UB(tmp0, tmp1); + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + + hz_out5 = hz_out9; + out0 = out2; + out1 = out3; + out2 = out4; + } +} + +static void common_hv_8ht_8vt_8w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16i8 filt_hz0, filt_hz1, filt_hz2, filt_hz3; + v16u8 mask0, mask1, mask2, mask3, vec0, vec1; + v8i16 filt, filt_vt0, filt_vt1, filt_vt2, filt_vt3; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6; + v8i16 hz_out7, hz_out8, hz_out9, hz_out10, tmp0, tmp1, tmp2, tmp3; + v8i16 out0, out1, out2, out3, out4, out5, out6, out7, out8, out9; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= (3 + 3 * src_stride); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt_hz0, filt_hz1, filt_hz2, filt_hz3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); + src += (7 * src_stride); + + XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); + hz_out0 = HORIZ_8TAP_FILT(src0, src0, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out1 = HORIZ_8TAP_FILT(src1, src1, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out2 = HORIZ_8TAP_FILT(src2, src2, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out3 = HORIZ_8TAP_FILT(src3, src3, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out4 = HORIZ_8TAP_FILT(src4, src4, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out5 = HORIZ_8TAP_FILT(src5, src5, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out6 = HORIZ_8TAP_FILT(src6, src6, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + + filt = LD_SH(filter_vert); + SPLATI_H4_SH(filt, 0, 1, 2, 3, filt_vt0, filt_vt1, filt_vt2, filt_vt3); + + ILVEV_B2_SH(hz_out0, hz_out1, hz_out2, hz_out3, out0, out1); + ILVEV_B2_SH(hz_out4, hz_out5, hz_out1, hz_out2, out2, out4); + ILVEV_B2_SH(hz_out3, hz_out4, hz_out5, hz_out6, out5, out6); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + src += (4 * src_stride); + + XORI_B4_128_SB(src7, src8, src9, src10); + + hz_out7 = HORIZ_8TAP_FILT(src7, src7, mask0, mask1, mask2, mask3, + filt_hz0, filt_hz1, filt_hz2, filt_hz3); + out3 = (v8i16) __msa_ilvev_b((v16i8) hz_out7, (v16i8) hz_out6); + tmp0 = FILT_8TAP_DPADD_S_H(out0, out1, out2, out3, filt_vt0, filt_vt1, + filt_vt2, filt_vt3); + + hz_out8 = HORIZ_8TAP_FILT(src8, src8, mask0, mask1, mask2, mask3, + filt_hz0, filt_hz1, filt_hz2, filt_hz3); + out7 = (v8i16) __msa_ilvev_b((v16i8) hz_out8, (v16i8) hz_out7); + tmp1 = FILT_8TAP_DPADD_S_H(out4, out5, out6, out7, filt_vt0, filt_vt1, + filt_vt2, filt_vt3); + + hz_out9 = HORIZ_8TAP_FILT(src9, src9, mask0, mask1, mask2, mask3, + filt_hz0, filt_hz1, filt_hz2, filt_hz3); + out8 = (v8i16) __msa_ilvev_b((v16i8) hz_out9, (v16i8) hz_out8); + tmp2 = FILT_8TAP_DPADD_S_H(out1, out2, out3, out8, filt_vt0, + filt_vt1, filt_vt2, filt_vt3); + + hz_out10 = HORIZ_8TAP_FILT(src10, src10, mask0, mask1, mask2, mask3, + filt_hz0, filt_hz1, filt_hz2, filt_hz3); + out9 = (v8i16) __msa_ilvev_b((v16i8) hz_out10, (v16i8) hz_out9); + tmp3 = FILT_8TAP_DPADD_S_H(out5, out6, out7, out9, filt_vt0, filt_vt1, + filt_vt2, filt_vt3); + SRARI_H4_SH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_SH4_SH(tmp0, tmp1, tmp2, tmp3, 7); + vec0 = PCKEV_XORI128_UB(tmp0, tmp1); + vec1 = PCKEV_XORI128_UB(tmp2, tmp3); + ST8x4_UB(vec0, vec1, dst, dst_stride); + dst += (4 * dst_stride); + + hz_out6 = hz_out10; + out0 = out2; + out1 = out3; + out2 = out8; + out4 = out6; + out5 = out7; + out6 = out9; + } +} + +static void common_hv_8ht_8vt_16w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert, + int32_t height) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + common_hv_8ht_8vt_8w_msa(src, src_stride, dst, dst_stride, filter_horiz, + filter_vert, height); + + src += 8; + dst += 8; + } +} + +static void common_hv_8ht_8vt_32w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert, + int32_t height) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 4; multiple8_cnt--;) { + common_hv_8ht_8vt_8w_msa(src, src_stride, dst, dst_stride, filter_horiz, + filter_vert, height); + + src += 8; + dst += 8; + } +} + +static void common_hv_8ht_8vt_64w_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert, + int32_t height) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 8; multiple8_cnt--;) { + common_hv_8ht_8vt_8w_msa(src, src_stride, dst, dst_stride, filter_horiz, + filter_vert, height); + + src += 8; + dst += 8; + } +} + +static void common_hz_8t_and_aver_dst_4x4_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, filt0, filt1, filt2, filt3; + v16u8 dst0, dst1, dst2, dst3, res2, res3; + v16u8 mask0, mask1, mask2, mask3; + v8i16 filt, res0, res1; + + mask0 = LD_UB(&mc_filt_mask_arr[16]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_8TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, res0, res1); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + SRARI_H2_SH(res0, res1, 7); + SAT_SH2_SH(res0, res1, 7); + PCKEV_B2_UB(res0, res0, res1, res1, res2, res3); + ILVR_W2_UB(dst1, dst0, dst3, dst2, dst0, dst2); + XORI_B2_128_UB(res2, res3); + AVER_UB2_UB(res2, dst0, res3, dst2, res2, res3); + ST4x4_UB(res2, res3, 0, 1, 0, 1, dst, dst_stride); +} + +static void common_hz_8t_and_aver_dst_4x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, filt0, filt1, filt2, filt3; + v16u8 mask0, mask1, mask2, mask3, res0, res1, res2, res3; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v8i16 filt, vec0, vec1, vec2, vec3; + + mask0 = LD_UB(&mc_filt_mask_arr[16]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + HORIZ_8TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, vec0, vec1); + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + HORIZ_8TAP_4WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, vec2, vec3); + SRARI_H4_SH(vec0, vec1, vec2, vec3, 7); + SAT_SH4_SH(vec0, vec1, vec2, vec3, 7); + PCKEV_B4_UB(vec0, vec0, vec1, vec1, vec2, vec2, vec3, vec3, + res0, res1, res2, res3); + ILVR_D2_UB(res1, res0, res3, res2, res0, res2); + XORI_B2_128_UB(res0, res2); + ILVR_W4_UB(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + dst0, dst2, dst4, dst6); + ILVR_D2_UB(dst2, dst0, dst6, dst4, dst0, dst4); + AVER_UB2_UB(res0, dst0, res2, dst4, res0, res2); + ST4x8_UB(res0, res2, dst, dst_stride); +} + +static void common_hz_8t_and_aver_dst_4w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, + int32_t height) +{ + if (4 == height) { + common_hz_8t_and_aver_dst_4x4_msa(src, src_stride, dst, dst_stride, + filter); + } else if (8 == height) { + common_hz_8t_and_aver_dst_4x8_msa(src, src_stride, dst, dst_stride, + filter); + } +} + +static void common_hz_8t_and_aver_dst_8w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, + int32_t height) +{ + int32_t loop_cnt; + v16i8 src0, src1, src2, src3, filt0, filt1, filt2, filt3; + v16u8 mask0, mask1, mask2, mask3, dst0, dst1, dst2, dst3; + v8i16 filt, out0, out1, out2, out3; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + XORI_B4_128_SB(src0, src1, src2, src3); + src += (4 * src_stride); + HORIZ_8TAP_8WID_4VECS_FILT(src0, src1, src2, src3, mask0, mask1, mask2, + mask3, filt0, filt1, filt2, filt3, out0, + out1, out2, out3); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + CONVERT_UB_AVG_ST8x4_UB(out0, out1, out2, out3, dst0, dst1, dst2, dst3, + dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void common_hz_8t_and_aver_dst_16w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, + int32_t height) +{ + int32_t loop_cnt; + v16i8 src0, src1, src2, src3, filt0, filt1, filt2, filt3; + v16u8 mask0, mask1, mask2, mask3, dst0, dst1; + v8i16 filt, out0, out1, out2, out3; + v8i16 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8i16 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + for (loop_cnt = height >> 1; loop_cnt--;) { + LD_SB2(src, src_stride, src0, src2); + LD_SB2(src + 8, src_stride, src1, src3); + src += (2 * src_stride); + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B4_SH(src0, src0, mask0, mask1, mask2, mask3, vec0, vec4, vec8, + vec12); + VSHF_B4_SH(src1, src1, mask0, mask1, mask2, mask3, vec1, vec5, vec9, + vec13); + VSHF_B4_SH(src2, src2, mask0, mask1, mask2, mask3, vec2, vec6, vec10, + vec14); + VSHF_B4_SH(src3, src3, mask0, mask1, mask2, mask3, vec3, vec7, vec11, + vec15); + DOTP_SB4_SH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, vec0, + vec1, vec2, vec3); + DOTP_SB4_SH(vec8, vec9, vec10, vec11, filt2, filt2, filt2, filt2, vec8, + vec9, vec10, vec11); + DPADD_SB4_SH(vec4, vec5, vec6, vec7, filt1, filt1, filt1, filt1, vec0, + vec1, vec2, vec3); + DPADD_SB4_SH(vec12, vec13, vec14, vec15, filt3, filt3, filt3, filt3, + vec8, vec9, vec10, vec11); + ADDS_SH4_SH(vec0, vec8, vec1, vec9, vec2, vec10, vec3, vec11, out0, + out1, out2, out3); + LD_UB2(dst, dst_stride, dst0, dst1); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + PCKEV_XORI128_AVG_ST_UB(out1, out0, dst0, dst); + dst += dst_stride; + PCKEV_XORI128_AVG_ST_UB(out3, out2, dst1, dst); + dst += dst_stride; + } +} + +static void common_hz_8t_and_aver_dst_32w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, filt0, filt1, filt2, filt3; + v16u8 dst1, dst2, mask0, mask1, mask2, mask3; + v8i16 filt, out0, out1, out2, out3; + v8i16 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8i16 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + for (loop_cnt = height; loop_cnt--;) { + src0 = LD_SB(src); + src2 = LD_SB(src + 16); + src3 = LD_SB(src + 24); + src1 = __msa_sldi_b(src2, src0, 8); + src += src_stride; + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B4_SH(src0, src0, mask0, mask1, mask2, mask3, vec0, vec4, vec8, + vec12); + VSHF_B4_SH(src1, src1, mask0, mask1, mask2, mask3, vec1, vec5, vec9, + vec13); + VSHF_B4_SH(src2, src2, mask0, mask1, mask2, mask3, vec2, vec6, vec10, + vec14); + VSHF_B4_SH(src3, src3, mask0, mask1, mask2, mask3, vec3, vec7, vec11, + vec15); + DOTP_SB4_SH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, vec0, + vec1, vec2, vec3); + DOTP_SB4_SH(vec8, vec9, vec10, vec11, filt2, filt2, filt2, filt2, vec8, + vec9, vec10, vec11); + DPADD_SB4_SH(vec4, vec5, vec6, vec7, filt1, filt1, filt1, filt1, vec0, + vec1, vec2, vec3); + DPADD_SB4_SH(vec12, vec13, vec14, vec15, filt3, filt3, filt3, filt3, + vec8, vec9, vec10, vec11); + ADDS_SH4_SH(vec0, vec8, vec1, vec9, vec2, vec10, vec3, vec11, out0, + out1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + LD_UB2(dst, 16, dst1, dst2); + PCKEV_XORI128_AVG_ST_UB(out1, out0, dst1, dst); + PCKEV_XORI128_AVG_ST_UB(out3, out2, dst2, dst + 16); + dst += dst_stride; + } +} + +static void common_hz_8t_and_aver_dst_64w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, + int32_t height) +{ + uint32_t loop_cnt, cnt; + v16i8 src0, src1, src2, src3, filt0, filt1, filt2, filt3; + v16u8 dst1, dst2, mask0, mask1, mask2, mask3; + v8i16 filt, out0, out1, out2, out3; + v8i16 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8i16 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= 3; + + /* rearranging filter */ + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + for (loop_cnt = height; loop_cnt--;) { + for (cnt = 0; cnt < 2; ++cnt) { + src0 = LD_SB(&src[cnt << 5]); + src2 = LD_SB(&src[16 + (cnt << 5)]); + src3 = LD_SB(&src[24 + (cnt << 5)]); + src1 = __msa_sldi_b(src2, src0, 8); + + XORI_B4_128_SB(src0, src1, src2, src3); + VSHF_B4_SH(src0, src0, mask0, mask1, mask2, mask3, vec0, vec4, vec8, + vec12); + VSHF_B4_SH(src1, src1, mask0, mask1, mask2, mask3, vec1, vec5, vec9, + vec13); + VSHF_B4_SH(src2, src2, mask0, mask1, mask2, mask3, vec2, vec6, + vec10, vec14); + VSHF_B4_SH(src3, src3, mask0, mask1, mask2, mask3, vec3, vec7, + vec11, vec15); + DOTP_SB4_SH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec0, vec1, vec2, vec3); + DOTP_SB4_SH(vec8, vec9, vec10, vec11, filt2, filt2, filt2, filt2, + vec8, vec9, vec10, vec11); + DPADD_SB4_SH(vec4, vec5, vec6, vec7, filt1, filt1, filt1, filt1, + vec0, vec1, vec2, vec3); + DPADD_SB4_SH(vec12, vec13, vec14, vec15, filt3, filt3, filt3, filt3, + vec8, vec9, vec10, vec11); + ADDS_SH4_SH(vec0, vec8, vec1, vec9, vec2, vec10, vec3, vec11, out0, + out1, out2, out3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + LD_UB2(&dst[cnt << 5], 16, dst1, dst2); + PCKEV_XORI128_AVG_ST_UB(out1, out0, dst1, &dst[cnt << 5]); + PCKEV_XORI128_AVG_ST_UB(out3, out2, dst2, &dst[16 + (cnt << 5)]); + } + + src += src_stride; + dst += dst_stride; + } +} + +static void common_vt_8t_and_aver_dst_4w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16u8 dst0, dst1, dst2, dst3, out; + v16i8 src10_r, src32_r, src54_r, src76_r, src98_r, src21_r, src43_r; + v16i8 src65_r, src87_r, src109_r, src2110, src4332, src6554, src8776; + v16i8 src10998, filt0, filt1, filt2, filt3; + v8i16 filt, out10, out32; + + src -= (3 * src_stride); + + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); + src += (7 * src_stride); + + ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r, + src54_r, src21_r); + ILVR_B2_SB(src4, src3, src6, src5, src43_r, src65_r); + ILVR_D3_SB(src21_r, src10_r, src43_r, src32_r, src65_r, src54_r, src2110, + src4332, src6554); + XORI_B3_128_SB(src2110, src4332, src6554); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_r, + src87_r, src98_r, src109_r); + ILVR_D2_SB(src87_r, src76_r, src109_r, src98_r, src8776, src10998); + XORI_B2_128_SB(src8776, src10998); + out10 = FILT_8TAP_DPADD_S_H(src2110, src4332, src6554, src8776, filt0, + filt1, filt2, filt3); + out32 = FILT_8TAP_DPADD_S_H(src4332, src6554, src8776, src10998, filt0, + filt1, filt2, filt3); + SRARI_H2_SH(out10, out32, 7); + SAT_SH2_SH(out10, out32, 7); + out = PCKEV_XORI128_UB(out10, out32); + ILVR_W2_UB(dst1, dst0, dst3, dst2, dst0, dst2); + + dst0 = (v16u8) __msa_ilvr_d((v2i64) dst2, (v2i64) dst0); + out = __msa_aver_u_b(out, dst0); + + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + + src2110 = src6554; + src4332 = src8776; + src6554 = src10998; + src6 = src10; + } +} + +static void common_vt_8t_and_aver_dst_8w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16u8 dst0, dst1, dst2, dst3; + v16i8 src10_r, src32_r, src54_r, src76_r, src98_r, src21_r, src43_r; + v16i8 src65_r, src87_r, src109_r, filt0, filt1, filt2, filt3; + v8i16 filt, out0, out1, out2, out3; + + src -= (3 * src_stride); + + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); + src += (7 * src_stride); + + XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); + ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r, + src54_r, src21_r); + ILVR_B2_SB(src4, src3, src6, src5, src43_r, src65_r); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + XORI_B4_128_SB(src7, src8, src9, src10); + ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_r, + src87_r, src98_r, src109_r); + out0 = FILT_8TAP_DPADD_S_H(src10_r, src32_r, src54_r, src76_r, filt0, + filt1, filt2, filt3); + out1 = FILT_8TAP_DPADD_S_H(src21_r, src43_r, src65_r, src87_r, filt0, + filt1, filt2, filt3); + out2 = FILT_8TAP_DPADD_S_H(src32_r, src54_r, src76_r, src98_r, filt0, + filt1, filt2, filt3); + out3 = FILT_8TAP_DPADD_S_H(src43_r, src65_r, src87_r, src109_r, filt0, + filt1, filt2, filt3); + SRARI_H4_SH(out0, out1, out2, out3, 7); + SAT_SH4_SH(out0, out1, out2, out3, 7); + CONVERT_UB_AVG_ST8x4_UB(out0, out1, out2, out3, dst0, dst1, dst2, dst3, + dst, dst_stride); + dst += (4 * dst_stride); + + src10_r = src54_r; + src32_r = src76_r; + src54_r = src98_r; + src21_r = src65_r; + src43_r = src87_r; + src65_r = src109_r; + src6 = src10; + } +} + +static void common_vt_8t_and_aver_dst_16w_mult_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter, + int32_t height, + int32_t width) +{ + const uint8_t *src_tmp; + uint8_t *dst_tmp; + uint32_t loop_cnt, cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16i8 src10_r, src32_r, src54_r, src76_r, src98_r, src21_r, src43_r; + v16i8 src65_r, src87_r, src109_r, src10_l, src32_l, src54_l, src76_l; + v16i8 src98_l, src21_l, src43_l, src65_l, src87_l, src109_l; + v16i8 filt0, filt1, filt2, filt3; + v16u8 dst0, dst1, dst2, dst3, tmp0, tmp1, tmp2, tmp3; + v8i16 out0_r, out1_r, out2_r, out3_r, out0_l, out1_l, out2_l, out3_l, filt; + + src -= (3 * src_stride); + + filt = LD_SH(filter); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + + for (cnt = (width >> 4); cnt--;) { + src_tmp = src; + dst_tmp = dst; + + LD_SB7(src_tmp, src_stride, src0, src1, src2, src3, src4, src5, src6); + XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); + src_tmp += (7 * src_stride); + + ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, + src32_r, src54_r, src21_r); + ILVR_B2_SB(src4, src3, src6, src5, src43_r, src65_r); + ILVL_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_l, + src32_l, src54_l, src21_l); + ILVL_B2_SB(src4, src3, src6, src5, src43_l, src65_l); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src_tmp, src_stride, src7, src8, src9, src10); + src_tmp += (4 * src_stride); + + LD_UB4(dst_tmp, dst_stride, dst0, dst1, dst2, dst3); + XORI_B4_128_SB(src7, src8, src9, src10); + ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_r, + src87_r, src98_r, src109_r); + ILVL_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_l, + src87_l, src98_l, src109_l); + out0_r = FILT_8TAP_DPADD_S_H(src10_r, src32_r, src54_r, src76_r, + filt0, filt1, filt2, filt3); + out1_r = FILT_8TAP_DPADD_S_H(src21_r, src43_r, src65_r, src87_r, + filt0, filt1, filt2, filt3); + out2_r = FILT_8TAP_DPADD_S_H(src32_r, src54_r, src76_r, src98_r, + filt0, filt1, filt2, filt3); + out3_r = FILT_8TAP_DPADD_S_H(src43_r, src65_r, src87_r, src109_r, + filt0, filt1, filt2, filt3); + out0_l = FILT_8TAP_DPADD_S_H(src10_l, src32_l, src54_l, src76_l, + filt0, filt1, filt2, filt3); + out1_l = FILT_8TAP_DPADD_S_H(src21_l, src43_l, src65_l, src87_l, + filt0, filt1, filt2, filt3); + out2_l = FILT_8TAP_DPADD_S_H(src32_l, src54_l, src76_l, src98_l, + filt0, filt1, filt2, filt3); + out3_l = FILT_8TAP_DPADD_S_H(src43_l, src65_l, src87_l, src109_l, + filt0, filt1, filt2, filt3); + SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SRARI_H4_SH(out0_l, out1_l, out2_l, out3_l, 7); + SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7); + SAT_SH4_SH(out0_l, out1_l, out2_l, out3_l, 7); + PCKEV_B4_UB(out0_l, out0_r, out1_l, out1_r, out2_l, out2_r, out3_l, + out3_r, tmp0, tmp1, tmp2, tmp3); + XORI_B4_128_UB(tmp0, tmp1, tmp2, tmp3); + AVER_UB4_UB(tmp0, dst0, tmp1, dst1, tmp2, dst2, tmp3, dst3, + dst0, dst1, dst2, dst3); + ST_UB4(dst0, dst1, dst2, dst3, dst_tmp, dst_stride); + dst_tmp += (4 * dst_stride); + + src10_r = src54_r; + src32_r = src76_r; + src54_r = src98_r; + src21_r = src65_r; + src43_r = src87_r; + src65_r = src109_r; + src10_l = src54_l; + src32_l = src76_l; + src54_l = src98_l; + src21_l = src65_l; + src43_l = src87_l; + src65_l = src109_l; + src6 = src10; + } + + src += 16; + dst += 16; + } +} + +static void common_vt_8t_and_aver_dst_16w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, + int32_t height) +{ + common_vt_8t_and_aver_dst_16w_mult_msa(src, src_stride, dst, dst_stride, + filter, height, 16); +} + +static void common_vt_8t_and_aver_dst_32w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, + int32_t height) +{ + common_vt_8t_and_aver_dst_16w_mult_msa(src, src_stride, dst, dst_stride, + filter, height, 32); +} + +static void common_vt_8t_and_aver_dst_64w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, + int32_t height) +{ + common_vt_8t_and_aver_dst_16w_mult_msa(src, src_stride, dst, dst_stride, + filter, height, 64); +} + +static void common_hv_8ht_8vt_and_aver_dst_4w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16u8 dst0, dst1, dst2, dst3, mask0, mask1, mask2, mask3, tmp0, tmp1; + v16i8 filt_hz0, filt_hz1, filt_hz2, filt_hz3; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6; + v8i16 hz_out7, hz_out8, hz_out9, res0, res1, vec0, vec1, vec2, vec3, vec4; + v8i16 filt, filt_vt0, filt_vt1, filt_vt2, filt_vt3; + + mask0 = LD_UB(&mc_filt_mask_arr[16]); + src -= (3 + 3 * src_stride); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt_hz0, filt_hz1, filt_hz2, filt_hz3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); + XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); + src += (7 * src_stride); + + hz_out0 = HORIZ_8TAP_FILT(src0, src1, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out2 = HORIZ_8TAP_FILT(src2, src3, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out4 = HORIZ_8TAP_FILT(src4, src5, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out5 = HORIZ_8TAP_FILT(src5, src6, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + SLDI_B2_SH(hz_out2, hz_out4, hz_out0, hz_out2, hz_out1, hz_out3, 8); + + filt = LD_SH(filter_vert); + SPLATI_H4_SH(filt, 0, 1, 2, 3, filt_vt0, filt_vt1, filt_vt2, filt_vt3); + + ILVEV_B2_SH(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1); + vec2 = (v8i16) __msa_ilvev_b((v16i8) hz_out5, (v16i8) hz_out4); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + XORI_B4_128_SB(src7, src8, src9, src10); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + hz_out7 = HORIZ_8TAP_FILT(src7, src8, mask0, mask1, mask2, mask3, + filt_hz0, filt_hz1, filt_hz2, filt_hz3); + hz_out6 = (v8i16) __msa_sldi_b((v16i8) hz_out7, (v16i8) hz_out5, 8); + vec3 = (v8i16) __msa_ilvev_b((v16i8) hz_out7, (v16i8) hz_out6); + res0 = FILT_8TAP_DPADD_S_H(vec0, vec1, vec2, vec3, filt_vt0, filt_vt1, + filt_vt2, filt_vt3); + + hz_out9 = HORIZ_8TAP_FILT(src9, src10, mask0, mask1, mask2, mask3, + filt_hz0, filt_hz1, filt_hz2, filt_hz3); + hz_out8 = (v8i16) __msa_sldi_b((v16i8) hz_out9, (v16i8) hz_out7, 8); + vec4 = (v8i16) __msa_ilvev_b((v16i8) hz_out9, (v16i8) hz_out8); + res1 = FILT_8TAP_DPADD_S_H(vec1, vec2, vec3, vec4, filt_vt0, filt_vt1, + filt_vt2, filt_vt3); + ILVR_W2_UB(dst1, dst0, dst3, dst2, dst0, dst2); + + SRARI_H2_SH(res0, res1, 7); + SAT_SH2_SH(res0, res1, 7); + PCKEV_B2_UB(res0, res0, res1, res1, tmp0, tmp1); + XORI_B2_128_UB(tmp0, tmp1); + AVER_UB2_UB(tmp0, dst0, tmp1, dst2, tmp0, tmp1); + ST4x4_UB(tmp0, tmp1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + + hz_out5 = hz_out9; + vec0 = vec2; + vec1 = vec3; + vec2 = vec4; + } +} + +static void common_hv_8ht_8vt_and_aver_dst_8w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16i8 filt_hz0, filt_hz1, filt_hz2, filt_hz3; + v8i16 filt, filt_vt0, filt_vt1, filt_vt2, filt_vt3; + v16u8 dst0, dst1, dst2, dst3, mask0, mask1, mask2, mask3; + v8i16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6; + v8i16 hz_out7, hz_out8, hz_out9, hz_out10, tmp0, tmp1, tmp2, tmp3; + v8i16 out0, out1, out2, out3, out4, out5, out6, out7, out8, out9; + + mask0 = LD_UB(&mc_filt_mask_arr[0]); + src -= (3 + 3 * src_stride); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + SPLATI_H4_SB(filt, 0, 1, 2, 3, filt_hz0, filt_hz1, filt_hz2, filt_hz3); + + mask1 = mask0 + 2; + mask2 = mask0 + 4; + mask3 = mask0 + 6; + + LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); + src += (7 * src_stride); + + XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); + hz_out0 = HORIZ_8TAP_FILT(src0, src0, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out1 = HORIZ_8TAP_FILT(src1, src1, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out2 = HORIZ_8TAP_FILT(src2, src2, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out3 = HORIZ_8TAP_FILT(src3, src3, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out4 = HORIZ_8TAP_FILT(src4, src4, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out5 = HORIZ_8TAP_FILT(src5, src5, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + hz_out6 = HORIZ_8TAP_FILT(src6, src6, mask0, mask1, mask2, mask3, filt_hz0, + filt_hz1, filt_hz2, filt_hz3); + + filt = LD_SH(filter_vert); + SPLATI_H4_SH(filt, 0, 1, 2, 3, filt_vt0, filt_vt1, filt_vt2, filt_vt3); + + ILVEV_B2_SH(hz_out0, hz_out1, hz_out2, hz_out3, out0, out1); + ILVEV_B2_SH(hz_out4, hz_out5, hz_out1, hz_out2, out2, out4); + ILVEV_B2_SH(hz_out3, hz_out4, hz_out5, hz_out6, out5, out6); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src7, src8, src9, src10); + XORI_B4_128_SB(src7, src8, src9, src10); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + hz_out7 = HORIZ_8TAP_FILT(src7, src7, mask0, mask1, mask2, mask3, + filt_hz0, filt_hz1, filt_hz2, filt_hz3); + out3 = (v8i16) __msa_ilvev_b((v16i8) hz_out7, (v16i8) hz_out6); + tmp0 = FILT_8TAP_DPADD_S_H(out0, out1, out2, out3, filt_vt0, filt_vt1, + filt_vt2, filt_vt3); + + hz_out8 = HORIZ_8TAP_FILT(src8, src8, mask0, mask1, mask2, mask3, + filt_hz0, filt_hz1, filt_hz2, filt_hz3); + out7 = (v8i16) __msa_ilvev_b((v16i8) hz_out8, (v16i8) hz_out7); + tmp1 = FILT_8TAP_DPADD_S_H(out4, out5, out6, out7, filt_vt0, filt_vt1, + filt_vt2, filt_vt3); + + hz_out9 = HORIZ_8TAP_FILT(src9, src9, mask0, mask1, mask2, mask3, + filt_hz0, filt_hz1, filt_hz2, filt_hz3); + out8 = (v8i16) __msa_ilvev_b((v16i8) hz_out9, (v16i8) hz_out8); + tmp2 = FILT_8TAP_DPADD_S_H(out1, out2, out3, out8, filt_vt0, filt_vt1, + filt_vt2, filt_vt3); + + hz_out10 = HORIZ_8TAP_FILT(src10, src10, mask0, mask1, mask2, mask3, + filt_hz0, filt_hz1, filt_hz2, filt_hz3); + out9 = (v8i16) __msa_ilvev_b((v16i8) hz_out10, (v16i8) hz_out9); + tmp3 = FILT_8TAP_DPADD_S_H(out5, out6, out7, out9, filt_vt0, filt_vt1, + filt_vt2, filt_vt3); + + SRARI_H4_SH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_SH4_SH(tmp0, tmp1, tmp2, tmp3, 7); + CONVERT_UB_AVG_ST8x4_UB(tmp0, tmp1, tmp2, tmp3, dst0, dst1, dst2, dst3, + dst, dst_stride); + dst += (4 * dst_stride); + + hz_out6 = hz_out10; + out0 = out2; + out1 = out3; + out2 = out8; + out4 = out6; + out5 = out7; + out6 = out9; + } +} + +static void common_hv_8ht_8vt_and_aver_dst_16w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert, + int32_t height) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + common_hv_8ht_8vt_and_aver_dst_8w_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert, + height); + + src += 8; + dst += 8; + } +} + +static void common_hv_8ht_8vt_and_aver_dst_32w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert, + int32_t height) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 4; multiple8_cnt--;) { + common_hv_8ht_8vt_and_aver_dst_8w_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert, + height); + + src += 8; + dst += 8; + } +} + +static void common_hv_8ht_8vt_and_aver_dst_64w_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert, + int32_t height) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 8; multiple8_cnt--;) { + common_hv_8ht_8vt_and_aver_dst_8w_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert, + height); + + src += 8; + dst += 8; + } +} + +static void common_hz_2t_4x4_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, mask; + v16u8 filt0, vec0, vec1, res0, res1; + v8u16 vec2, vec3, filt; + + mask = LD_SB(&mc_filt_mask_arr[16]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB4(src, src_stride, src0, src1, src2, src3); + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt0, filt0, vec2, vec3); + SRARI_H2_UH(vec2, vec3, 7); + PCKEV_B2_UB(vec2, vec2, vec3, vec3, res0, res1); + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); +} + +static void common_hz_2t_4x8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16u8 vec0, vec1, vec2, vec3, filt0; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask; + v16i8 res0, res1, res2, res3; + v8u16 vec4, vec5, vec6, vec7, filt; + + mask = LD_SB(&mc_filt_mask_arr[16]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, vec0, vec1); + VSHF_B2_UB(src4, src5, src6, src7, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec4, vec5, vec6, vec7); + SRARI_H4_UH(vec4, vec5, vec6, vec7, 7); + PCKEV_B4_SB(vec4, vec4, vec5, vec5, vec6, vec6, vec7, vec7, + res0, res1, res2, res3); + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + ST4x4_UB(res2, res3, 0, 1, 0, 1, dst, dst_stride); +} + +void ff_put_bilin_4h_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = vp9_bilinear_filters_msa[mx - 1]; + + if (4 == height) { + common_hz_2t_4x4_msa(src, src_stride, dst, dst_stride, filter); + } else if (8 == height) { + common_hz_2t_4x8_msa(src, src_stride, dst, dst_stride, filter); + } +} + +static void common_hz_2t_8x4_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16u8 filt0; + v16i8 src0, src1, src2, src3, mask; + v8u16 vec0, vec1, vec2, vec3, filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB4(src, src_stride, src0, src1, src2, src3); + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec0, vec1, vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + PCKEV_B2_SB(vec1, vec0, vec3, vec2, src0, src1); + ST8x4_UB(src0, src1, dst, dst_stride); +} + +static void common_hz_2t_8x8mult_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + v16u8 filt0; + v16i8 src0, src1, src2, src3, mask, out0, out1; + v8u16 vec0, vec1, vec2, vec3, filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec0, vec1, vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + PCKEV_B2_SB(vec1, vec0, vec3, vec2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec0, vec1, vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + PCKEV_B2_SB(vec1, vec0, vec3, vec2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + + if (16 == height) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec0, vec1, vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + PCKEV_B2_SB(vec1, vec0, vec3, vec2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec0, vec1, vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + PCKEV_B2_SB(vec1, vec0, vec3, vec2, out0, out1); + ST8x4_UB(out0, out1, dst + 4 * dst_stride, dst_stride); + } +} + +void ff_put_bilin_8h_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = vp9_bilinear_filters_msa[mx - 1]; + + if (4 == height) { + common_hz_2t_8x4_msa(src, src_stride, dst, dst_stride, filter); + } else { + common_hz_2t_8x8mult_msa(src, src_stride, dst, dst_stride, filter, + height); + } +} + +void ff_put_bilin_16h_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = vp9_bilinear_filters_msa[mx - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask; + v16u8 filt0, vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8u16 out0, out1, out2, out3, out4, out5, out6, out7, filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + loop_cnt = (height >> 2) - 1; + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB4(src, src_stride, src0, src2, src4, src6); + LD_SB4(src + 8, src_stride, src1, src3, src5, src7); + src += (4 * src_stride); + + VSHF_B2_UB(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UB(src2, src2, src3, src3, mask, mask, vec2, vec3); + VSHF_B2_UB(src4, src4, src5, src5, mask, mask, vec4, vec5); + VSHF_B2_UB(src6, src6, src7, src7, mask, mask, vec6, vec7); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + out0, out1, out2, out3); + DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, + out4, out5, out6, out7); + SRARI_H4_UH(out0, out1, out2, out3, 7); + SRARI_H4_UH(out4, out5, out6, out7, 7); + PCKEV_ST_SB(out0, out1, dst); + dst += dst_stride; + PCKEV_ST_SB(out2, out3, dst); + dst += dst_stride; + PCKEV_ST_SB(out4, out5, dst); + dst += dst_stride; + PCKEV_ST_SB(out6, out7, dst); + dst += dst_stride; + + for (; loop_cnt--;) { + LD_SB4(src, src_stride, src0, src2, src4, src6); + LD_SB4(src + 8, src_stride, src1, src3, src5, src7); + src += (4 * src_stride); + + VSHF_B2_UB(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UB(src2, src2, src3, src3, mask, mask, vec2, vec3); + VSHF_B2_UB(src4, src4, src5, src5, mask, mask, vec4, vec5); + VSHF_B2_UB(src6, src6, src7, src7, mask, mask, vec6, vec7); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + out0, out1, out2, out3); + DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, + out4, out5, out6, out7); + SRARI_H4_UH(out0, out1, out2, out3, 7); + SRARI_H4_UH(out4, out5, out6, out7, 7); + PCKEV_ST_SB(out0, out1, dst); + dst += dst_stride; + PCKEV_ST_SB(out2, out3, dst); + dst += dst_stride; + PCKEV_ST_SB(out4, out5, dst); + dst += dst_stride; + PCKEV_ST_SB(out6, out7, dst); + dst += dst_stride; + } +} + +void ff_put_bilin_32h_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = vp9_bilinear_filters_msa[mx - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask; + v16u8 filt0, vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8u16 out0, out1, out2, out3, out4, out5, out6, out7, filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + for (loop_cnt = height >> 1; loop_cnt--;) { + src0 = LD_SB(src); + src2 = LD_SB(src + 16); + src3 = LD_SB(src + 24); + src1 = __msa_sldi_b(src2, src0, 8); + src += src_stride; + src4 = LD_SB(src); + src6 = LD_SB(src + 16); + src7 = LD_SB(src + 24); + src5 = __msa_sldi_b(src6, src4, 8); + src += src_stride; + + VSHF_B2_UB(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UB(src2, src2, src3, src3, mask, mask, vec2, vec3); + VSHF_B2_UB(src4, src4, src5, src5, mask, mask, vec4, vec5); + VSHF_B2_UB(src6, src6, src7, src7, mask, mask, vec6, vec7); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + out0, out1, out2, out3); + DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, + out4, out5, out6, out7); + SRARI_H4_UH(out0, out1, out2, out3, 7); + SRARI_H4_UH(out4, out5, out6, out7, 7); + PCKEV_ST_SB(out0, out1, dst); + PCKEV_ST_SB(out2, out3, dst + 16); + dst += dst_stride; + PCKEV_ST_SB(out4, out5, dst); + PCKEV_ST_SB(out6, out7, dst + 16); + dst += dst_stride; + } +} + +void ff_put_bilin_64h_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = vp9_bilinear_filters_msa[mx - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask; + v16u8 filt0, vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8u16 out0, out1, out2, out3, out4, out5, out6, out7, filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + for (loop_cnt = height; loop_cnt--;) { + src0 = LD_SB(src); + src2 = LD_SB(src + 16); + src4 = LD_SB(src + 32); + src6 = LD_SB(src + 48); + src7 = LD_SB(src + 56); + SLDI_B3_SB(src2, src4, src6, src0, src2, src4, src1, src3, src5, 8); + src += src_stride; + + VSHF_B2_UB(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UB(src2, src2, src3, src3, mask, mask, vec2, vec3); + VSHF_B2_UB(src4, src4, src5, src5, mask, mask, vec4, vec5); + VSHF_B2_UB(src6, src6, src7, src7, mask, mask, vec6, vec7); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + out0, out1, out2, out3); + DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, + out4, out5, out6, out7); + SRARI_H4_UH(out0, out1, out2, out3, 7); + SRARI_H4_UH(out4, out5, out6, out7, 7); + PCKEV_ST_SB(out0, out1, dst); + PCKEV_ST_SB(out2, out3, dst + 16); + PCKEV_ST_SB(out4, out5, dst + 32); + PCKEV_ST_SB(out6, out7, dst + 48); + dst += dst_stride; + } +} + +static void common_vt_2t_4x4_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, src4; + v16i8 src10_r, src32_r, src21_r, src43_r, src2110, src4332; + v16u8 filt0; + v8i16 filt; + v8u16 tmp0, tmp1; + + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + ILVR_D2_SB(src21_r, src10_r, src43_r, src32_r, src2110, src4332); + DOTP_UB2_UH(src2110, src4332, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + src2110 = __msa_pckev_b((v16i8) tmp1, (v16i8) tmp0); + ST4x4_UB(src2110, src2110, 0, 1, 2, 3, dst, dst_stride); +} + +static void common_vt_2t_4x8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r; + v16i8 src65_r, src87_r, src2110, src4332, src6554, src8776; + v8u16 tmp0, tmp1, tmp2, tmp3; + v16u8 filt0; + v8i16 filt; + + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + + src8 = LD_SB(src); + src += src_stride; + + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, src10_r, src21_r, + src32_r, src43_r); + ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, src54_r, src65_r, + src76_r, src87_r); + ILVR_D4_SB(src21_r, src10_r, src43_r, src32_r, src65_r, src54_r, + src87_r, src76_r, src2110, src4332, src6554, src8776); + DOTP_UB4_UH(src2110, src4332, src6554, src8776, filt0, filt0, filt0, filt0, + tmp0, tmp1, tmp2, tmp3); + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, src2110, src4332); + ST4x4_UB(src2110, src2110, 0, 1, 2, 3, dst, dst_stride); + ST4x4_UB(src4332, src4332, 0, 1, 2, 3, dst + 4 * dst_stride, dst_stride); +} + +void ff_put_bilin_4v_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = vp9_bilinear_filters_msa[my - 1]; + + if (4 == height) { + common_vt_2t_4x4_msa(src, src_stride, dst, dst_stride, filter); + } else if (8 == height) { + common_vt_2t_4x8_msa(src, src_stride, dst, dst_stride, filter); + } +} + +static void common_vt_2t_8x4_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16u8 src0, src1, src2, src3, src4, vec0, vec1, vec2, vec3, filt0; + v16i8 out0, out1; + v8u16 tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + /* rearranging filter_y */ + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + LD_UB5(src, src_stride, src0, src1, src2, src3, src4); + ILVR_B2_UB(src1, src0, src2, src1, vec0, vec1); + ILVR_B2_UB(src3, src2, src4, src3, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + tmp0, tmp1, tmp2, tmp3); + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); +} + +static void common_vt_2t_8x8mult_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter, int32_t height) +{ + uint32_t loop_cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0; + v16i8 out0, out1; + v8u16 tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + /* rearranging filter_y */ + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + src0 = LD_UB(src); + src += src_stride; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src, src_stride, src1, src2, src3, src4, src5, src6, src7, src8); + src += (8 * src_stride); + + ILVR_B4_UB(src1, src0, src2, src1, src3, src2, src4, src3, + vec0, vec1, vec2, vec3); + ILVR_B4_UB(src5, src4, src6, src5, src7, src6, src8, src7, + vec4, vec5, vec6, vec7); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + tmp0, tmp1, tmp2, tmp3); + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + + DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, + tmp0, tmp1, tmp2, tmp3); + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + + src0 = src8; + } +} + +void ff_put_bilin_8v_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = vp9_bilinear_filters_msa[my - 1]; + + if (4 == height) { + common_vt_2t_8x4_msa(src, src_stride, dst, dst_stride, filter); + } else { + common_vt_2t_8x8mult_msa(src, src_stride, dst, dst_stride, filter, + height); + } +} + +void ff_put_bilin_16v_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = vp9_bilinear_filters_msa[my - 1]; + v16u8 src0, src1, src2, src3, src4; + v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0; + v8u16 tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + /* rearranging filter_y */ + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + src0 = LD_UB(src); + src += src_stride; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + ILVR_B2_UB(src1, src0, src2, src1, vec0, vec2); + ILVL_B2_UB(src1, src0, src2, src1, vec1, vec3); + DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_ST_SB(tmp0, tmp1, dst); + dst += dst_stride; + + ILVR_B2_UB(src3, src2, src4, src3, vec4, vec6); + ILVL_B2_UB(src3, src2, src4, src3, vec5, vec7); + DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_ST_SB(tmp2, tmp3, dst); + dst += dst_stride; + + DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_ST_SB(tmp0, tmp1, dst); + dst += dst_stride; + + DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_ST_SB(tmp2, tmp3, dst); + dst += dst_stride; + + src0 = src4; + } +} + +void ff_put_bilin_32v_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = vp9_bilinear_filters_msa[my - 1]; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9; + v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0; + v8u16 tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + /* rearranging filter_y */ + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + src0 = LD_UB(src); + src5 = LD_UB(src + 16); + src += src_stride; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + ILVR_B2_UB(src1, src0, src2, src1, vec0, vec2); + ILVL_B2_UB(src1, src0, src2, src1, vec1, vec3); + + LD_UB4(src + 16, src_stride, src6, src7, src8, src9); + src += (4 * src_stride); + + DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_ST_SB(tmp0, tmp1, dst); + DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_ST_SB(tmp2, tmp3, dst + dst_stride); + + ILVR_B2_UB(src3, src2, src4, src3, vec4, vec6); + ILVL_B2_UB(src3, src2, src4, src3, vec5, vec7); + DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_ST_SB(tmp0, tmp1, dst + 2 * dst_stride); + + DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_ST_SB(tmp2, tmp3, dst + 3 * dst_stride); + + ILVR_B2_UB(src6, src5, src7, src6, vec0, vec2); + ILVL_B2_UB(src6, src5, src7, src6, vec1, vec3); + DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_ST_SB(tmp0, tmp1, dst + 16); + + DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_ST_SB(tmp2, tmp3, dst + 16 + dst_stride); + + ILVR_B2_UB(src8, src7, src9, src8, vec4, vec6); + ILVL_B2_UB(src8, src7, src9, src8, vec5, vec7); + DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_ST_SB(tmp0, tmp1, dst + 16 + 2 * dst_stride); + + DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_ST_SB(tmp2, tmp3, dst + 16 + 3 * dst_stride); + dst += (4 * dst_stride); + + src0 = src4; + src5 = src9; + } +} + +void ff_put_bilin_64v_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = vp9_bilinear_filters_msa[my - 1]; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; + v16u8 src11, vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0; + v8u16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v8i16 filt; + + /* rearranging filter_y */ + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + LD_UB4(src, 16, src0, src3, src6, src9); + src += src_stride; + + for (loop_cnt = (height >> 1); loop_cnt--;) { + LD_UB2(src, src_stride, src1, src2); + LD_UB2(src + 16, src_stride, src4, src5); + LD_UB2(src + 32, src_stride, src7, src8); + LD_UB2(src + 48, src_stride, src10, src11); + src += (2 * src_stride); + + ILVR_B2_UB(src1, src0, src2, src1, vec0, vec2); + ILVL_B2_UB(src1, src0, src2, src1, vec1, vec3); + DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_ST_SB(tmp0, tmp1, dst); + + DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_ST_SB(tmp2, tmp3, dst + dst_stride); + + ILVR_B2_UB(src4, src3, src5, src4, vec4, vec6); + ILVL_B2_UB(src4, src3, src5, src4, vec5, vec7); + DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp4, tmp5); + SRARI_H2_UH(tmp4, tmp5, 7); + SAT_UH2_UH(tmp4, tmp5, 7); + PCKEV_ST_SB(tmp4, tmp5, dst + 16); + + DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp6, tmp7); + SRARI_H2_UH(tmp6, tmp7, 7); + SAT_UH2_UH(tmp6, tmp7, 7); + PCKEV_ST_SB(tmp6, tmp7, dst + 16 + dst_stride); + + ILVR_B2_UB(src7, src6, src8, src7, vec0, vec2); + ILVL_B2_UB(src7, src6, src8, src7, vec1, vec3); + DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_ST_SB(tmp0, tmp1, dst + 32); + + DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_ST_SB(tmp2, tmp3, dst + 32 + dst_stride); + + ILVR_B2_UB(src10, src9, src11, src10, vec4, vec6); + ILVL_B2_UB(src10, src9, src11, src10, vec5, vec7); + DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp4, tmp5); + SRARI_H2_UH(tmp4, tmp5, 7); + SAT_UH2_UH(tmp4, tmp5, 7); + PCKEV_ST_SB(tmp4, tmp5, dst + 48); + + DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp6, tmp7); + SRARI_H2_UH(tmp6, tmp7, 7); + SAT_UH2_UH(tmp6, tmp7, 7); + PCKEV_ST_SB(tmp6, tmp7, dst + 48 + dst_stride); + dst += (2 * dst_stride); + + src0 = src2; + src3 = src5; + src6 = src8; + src9 = src11; + } +} + +static void common_hv_2ht_2vt_4x4_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter_horiz, const int8_t *filter_vert) +{ + v16i8 src0, src1, src2, src3, src4, mask; + v16u8 filt_vt, filt_hz, vec0, vec1, res0, res1; + v8u16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, filt, tmp0, tmp1; + + mask = LD_SB(&mc_filt_mask_arr[16]); + + /* rearranging filter */ + filt = LD_UH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h((v8i16) filt, 0); + + filt = LD_UH(filter_vert); + filt_vt = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src1, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src2, src3, mask, filt_hz, 7); + hz_out4 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + hz_out1 = (v8u16) __msa_sldi_b((v16i8) hz_out2, (v16i8) hz_out0, 8); + hz_out3 = (v8u16) __msa_pckod_d((v2i64) hz_out4, (v2i64) hz_out2); + + ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_B2_UB(tmp0, tmp0, tmp1, tmp1, res0, res1); + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); +} + +static void common_hv_2ht_2vt_4x8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter_horiz, const int8_t *filter_vert) +{ + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, mask; + v16i8 res0, res1, res2, res3; + v16u8 filt_hz, filt_vt, vec0, vec1, vec2, vec3; + v8u16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6; + v8u16 hz_out7, hz_out8, vec4, vec5, vec6, vec7, filt; + + mask = LD_SB(&mc_filt_mask_arr[16]); + + /* rearranging filter */ + filt = LD_UH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h((v8i16) filt, 0); + + filt = LD_UH(filter_vert); + filt_vt = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + src8 = LD_SB(src); + + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src1, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src2, src3, mask, filt_hz, 7); + hz_out4 = HORIZ_2TAP_FILT_UH(src4, src5, mask, filt_hz, 7); + hz_out6 = HORIZ_2TAP_FILT_UH(src6, src7, mask, filt_hz, 7); + hz_out8 = HORIZ_2TAP_FILT_UH(src8, src8, mask, filt_hz, 7); + SLDI_B3_UH(hz_out2, hz_out4, hz_out6, hz_out0, hz_out2, hz_out4, hz_out1, + hz_out3, hz_out5, 8); + hz_out7 = (v8u16) __msa_pckod_d((v2i64) hz_out8, (v2i64) hz_out6); + + ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1); + ILVEV_B2_UB(hz_out4, hz_out5, hz_out6, hz_out7, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt_vt, filt_vt, filt_vt, filt_vt, + vec4, vec5, vec6, vec7); + SRARI_H4_UH(vec4, vec5, vec6, vec7, 7); + SAT_UH4_UH(vec4, vec5, vec6, vec7, 7); + PCKEV_B4_SB(vec4, vec4, vec5, vec5, vec6, vec6, vec7, vec7, + res0, res1, res2, res3); + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + ST4x4_UB(res2, res3, 0, 1, 0, 1, dst, dst_stride); +} + +void ff_put_bilin_4hv_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter_horiz = vp9_bilinear_filters_msa[mx - 1]; + const int8_t *filter_vert = vp9_bilinear_filters_msa[my - 1]; + + if (4 == height) { + common_hv_2ht_2vt_4x4_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert); + } else if (8 == height) { + common_hv_2ht_2vt_4x8_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert); + } +} + +static void common_hv_2ht_2vt_8x4_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter_horiz, const int8_t *filter_vert) +{ + v16i8 src0, src1, src2, src3, src4, mask, out0, out1; + v16u8 filt_hz, filt_vt, vec0, vec1, vec2, vec3; + v8u16 hz_out0, hz_out1, tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h(filt, 0); + + filt = LD_SH(filter_vert); + filt_vt = (v16u8) __msa_splati_h(filt, 0); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, 7); + hz_out1 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp0 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, 7); + vec1 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp1 = __msa_dotp_u_h(vec1, filt_vt); + + hz_out1 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, 7); + vec2 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp2 = __msa_dotp_u_h(vec2, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + vec3 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp3 = __msa_dotp_u_h(vec3, filt_vt); + + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); +} + +static void common_hv_2ht_2vt_8x8mult_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter_horiz, const int8_t *filter_vert, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, mask, out0, out1; + v16u8 filt_hz, filt_vt, vec0; + v8u16 hz_out0, hz_out1, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; + v8i16 filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h(filt, 0); + + filt = LD_SH(filter_vert); + filt_vt = (v16u8) __msa_splati_h(filt, 0); + + src0 = LD_SB(src); + src += src_stride; + + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, 7); + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_SB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + hz_out1 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp1 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp2 = __msa_dotp_u_h(vec0, filt_vt); + + SRARI_H2_UH(tmp1, tmp2, 7); + SAT_UH2_UH(tmp1, tmp2, 7); + + hz_out1 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp3 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + LD_SB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp4 = __msa_dotp_u_h(vec0, filt_vt); + + SRARI_H2_UH(tmp3, tmp4, 7); + SAT_UH2_UH(tmp3, tmp4, 7); + PCKEV_B2_SB(tmp2, tmp1, tmp4, tmp3, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + + hz_out1 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp5 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp6 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out1 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp7 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp8 = __msa_dotp_u_h(vec0, filt_vt); + + SRARI_H4_UH(tmp5, tmp6, tmp7, tmp8, 7); + SAT_UH4_UH(tmp5, tmp6, tmp7, tmp8, 7); + PCKEV_B2_SB(tmp6, tmp5, tmp8, tmp7, out0, out1); + ST8x4_UB(out0, out1, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +void ff_put_bilin_8hv_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter_horiz = vp9_bilinear_filters_msa[mx - 1]; + const int8_t *filter_vert = vp9_bilinear_filters_msa[my - 1]; + + if (4 == height) { + common_hv_2ht_2vt_8x4_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert); + } else { + common_hv_2ht_2vt_8x8mult_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert, height); + } +} + +void ff_put_bilin_16hv_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter_horiz = vp9_bilinear_filters_msa[mx - 1]; + const int8_t *filter_vert = vp9_bilinear_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask; + v16u8 filt_hz, filt_vt, vec0, vec1; + v8u16 tmp1, tmp2, hz_out0, hz_out1, hz_out2, hz_out3; + v8i16 filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h(filt, 0); + + filt = LD_SH(filter_vert); + filt_vt = (v16u8) __msa_splati_h(filt, 0); + + LD_SB2(src, 8, src0, src1); + src += src_stride; + + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src2, src4, src6); + LD_SB4(src + 8, src_stride, src1, src3, src5, src7); + src += (4 * src_stride); + + hz_out1 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, 7); + hz_out3 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp1, tmp2); + SRARI_H2_UH(tmp1, tmp2, 7); + SAT_UH2_UH(tmp1, tmp2, 7); + PCKEV_ST_SB(tmp1, tmp2, dst); + dst += dst_stride; + + hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, 7); + ILVEV_B2_UB(hz_out1, hz_out0, hz_out3, hz_out2, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp1, tmp2); + SRARI_H2_UH(tmp1, tmp2, 7); + SAT_UH2_UH(tmp1, tmp2, 7); + PCKEV_ST_SB(tmp1, tmp2, dst); + dst += dst_stride; + + hz_out1 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + hz_out3 = HORIZ_2TAP_FILT_UH(src5, src5, mask, filt_hz, 7); + ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp1, tmp2); + SRARI_H2_UH(tmp1, tmp2, 7); + SAT_UH2_UH(tmp1, tmp2, 7); + PCKEV_ST_SB(tmp1, tmp2, dst); + dst += dst_stride; + + hz_out0 = HORIZ_2TAP_FILT_UH(src6, src6, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src7, src7, mask, filt_hz, 7); + ILVEV_B2_UB(hz_out1, hz_out0, hz_out3, hz_out2, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp1, tmp2); + SRARI_H2_UH(tmp1, tmp2, 7); + SAT_UH2_UH(tmp1, tmp2, 7); + PCKEV_ST_SB(tmp1, tmp2, dst); + dst += dst_stride; + } +} + +void ff_put_bilin_32hv_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + ff_put_bilin_16hv_msa(dst, dst_stride, src, src_stride, height, mx, my); + + src += 16; + dst += 16; + } +} + +void ff_put_bilin_64hv_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 4; multiple8_cnt--;) { + ff_put_bilin_16hv_msa(dst, dst_stride, src, src_stride, height, mx, my); + + src += 16; + dst += 16; + } +} + +static void common_hz_2t_and_aver_dst_4x4_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, mask; + v16u8 filt0, dst0, dst1, dst2, dst3, vec0, vec1, res0, res1; + v8u16 vec2, vec3, filt; + + mask = LD_SB(&mc_filt_mask_arr[16]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB4(src, src_stride, src0, src1, src2, src3); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt0, filt0, vec2, vec3); + SRARI_H2_UH(vec2, vec3, 7); + PCKEV_B2_UB(vec2, vec2, vec3, vec3, res0, res1); + ILVR_W2_UB(dst1, dst0, dst3, dst2, dst0, dst2); + AVER_UB2_UB(res0, dst0, res1, dst2, res0, res1); + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); +} + +static void common_hz_2t_and_aver_dst_4x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask; + v16u8 filt0, vec0, vec1, vec2, vec3, res0, res1, res2, res3; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v8u16 vec4, vec5, vec6, vec7, filt; + + mask = LD_SB(&mc_filt_mask_arr[16]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + LD_UB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + VSHF_B2_UB(src0, src1, src2, src3, mask, mask, vec0, vec1); + VSHF_B2_UB(src4, src5, src6, src7, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, vec4, vec5, + vec6, vec7); + SRARI_H4_UH(vec4, vec5, vec6, vec7, 7); + PCKEV_B4_UB(vec4, vec4, vec5, vec5, vec6, vec6, vec7, vec7, res0, res1, + res2, res3); + ILVR_W4_UB(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, dst0, dst2, + dst4, dst6); + AVER_UB4_UB(res0, dst0, res1, dst2, res2, dst4, res3, dst6, res0, res1, + res2, res3); + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + ST4x4_UB(res2, res3, 0, 1, 0, 1, dst, dst_stride); +} + +void ff_avg_bilin_4h_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = vp9_bilinear_filters_msa[mx - 1]; + + if (4 == height) { + common_hz_2t_and_aver_dst_4x4_msa(src, src_stride, dst, dst_stride, + filter); + } else if (8 == height) { + common_hz_2t_and_aver_dst_4x8_msa(src, src_stride, dst, dst_stride, + filter); + } +} + +static void common_hz_2t_and_aver_dst_8x4_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, mask; + v16u8 filt0, dst0, dst1, dst2, dst3; + v8u16 vec0, vec1, vec2, vec3, filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB4(src, src_stride, src0, src1, src2, src3); + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + vec0, vec1, vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + PCKEV_AVG_ST8x4_UB(vec0, dst0, vec1, dst1, vec2, dst2, vec3, dst3, + dst, dst_stride); +} + +static void common_hz_2t_and_aver_dst_8x8mult_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter, + int32_t height) +{ + v16i8 src0, src1, src2, src3, mask; + v16u8 filt0, dst0, dst1, dst2, dst3; + v8u16 vec0, vec1, vec2, vec3, filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, vec0, vec1, + vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + PCKEV_AVG_ST8x4_UB(vec0, dst0, vec1, dst1, vec2, dst2, vec3, dst3, + dst, dst_stride); + dst += (4 * dst_stride); + + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, vec0, vec1, + vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + PCKEV_AVG_ST8x4_UB(vec0, dst0, vec1, dst1, vec2, dst2, vec3, dst3, + dst, dst_stride); + dst += (4 * dst_stride); + + if (16 == height) { + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, vec0, + vec1, vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + LD_SB4(src, src_stride, src0, src1, src2, src3); + PCKEV_AVG_ST8x4_UB(vec0, dst0, vec1, dst1, vec2, dst2, vec3, dst3, + dst, dst_stride); + dst += (4 * dst_stride); + + VSHF_B2_UH(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UH(src2, src2, src3, src3, mask, mask, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, vec0, + vec1, vec2, vec3); + SRARI_H4_UH(vec0, vec1, vec2, vec3, 7); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + PCKEV_AVG_ST8x4_UB(vec0, dst0, vec1, dst1, vec2, dst2, vec3, dst3, + dst, dst_stride); + } +} + +void ff_avg_bilin_8h_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = vp9_bilinear_filters_msa[mx - 1]; + + if (4 == height) { + common_hz_2t_and_aver_dst_8x4_msa(src, src_stride, dst, dst_stride, + filter); + } else { + common_hz_2t_and_aver_dst_8x8mult_msa(src, src_stride, dst, dst_stride, + filter, height); + } +} + +void ff_avg_bilin_16h_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = vp9_bilinear_filters_msa[mx - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask; + v16u8 filt0, dst0, dst1, dst2, dst3; + v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8u16 res0, res1, res2, res3, res4, res5, res6, res7, filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB4(src, src_stride, src0, src2, src4, src6); + LD_SB4(src + 8, src_stride, src1, src3, src5, src7); + src += (4 * src_stride); + + VSHF_B2_UB(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UB(src2, src2, src3, src3, mask, mask, vec2, vec3); + VSHF_B2_UB(src4, src4, src5, src5, mask, mask, vec4, vec5); + VSHF_B2_UB(src6, src6, src7, src7, mask, mask, vec6, vec7); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, res0, res1, + res2, res3); + DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, res4, res5, + res6, res7); + SRARI_H4_UH(res0, res1, res2, res3, 7); + SRARI_H4_UH(res4, res5, res6, res7, 7); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + PCKEV_AVG_ST_UB(res1, res0, dst0, dst); + dst += dst_stride; + PCKEV_AVG_ST_UB(res3, res2, dst1, dst); + dst += dst_stride; + PCKEV_AVG_ST_UB(res5, res4, dst2, dst); + dst += dst_stride; + PCKEV_AVG_ST_UB(res7, res6, dst3, dst); + dst += dst_stride; + + for (loop_cnt = (height >> 2) - 1; loop_cnt--;) { + LD_SB4(src, src_stride, src0, src2, src4, src6); + LD_SB4(src + 8, src_stride, src1, src3, src5, src7); + src += (4 * src_stride); + + VSHF_B2_UB(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UB(src2, src2, src3, src3, mask, mask, vec2, vec3); + VSHF_B2_UB(src4, src4, src5, src5, mask, mask, vec4, vec5); + VSHF_B2_UB(src6, src6, src7, src7, mask, mask, vec6, vec7); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, res0, + res1, res2, res3); + DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, res4, + res5, res6, res7); + SRARI_H4_UH(res0, res1, res2, res3, 7); + SRARI_H4_UH(res4, res5, res6, res7, 7); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + PCKEV_AVG_ST_UB(res1, res0, dst0, dst); + dst += dst_stride; + PCKEV_AVG_ST_UB(res3, res2, dst1, dst); + dst += dst_stride; + PCKEV_AVG_ST_UB(res5, res4, dst2, dst); + dst += dst_stride; + PCKEV_AVG_ST_UB(res7, res6, dst3, dst); + dst += dst_stride; + } +} + +void ff_avg_bilin_32h_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = vp9_bilinear_filters_msa[mx - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask; + v16u8 filt0, dst0, dst1, dst2, dst3; + v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8u16 res0, res1, res2, res3, res4, res5, res6, res7, filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + for (loop_cnt = (height >> 1); loop_cnt--;) { + src0 = LD_SB(src); + src2 = LD_SB(src + 16); + src3 = LD_SB(src + 24); + src1 = __msa_sldi_b(src2, src0, 8); + src += src_stride; + src4 = LD_SB(src); + src6 = LD_SB(src + 16); + src7 = LD_SB(src + 24); + src5 = __msa_sldi_b(src6, src4, 8); + src += src_stride; + + VSHF_B2_UB(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UB(src2, src2, src3, src3, mask, mask, vec2, vec3); + VSHF_B2_UB(src4, src4, src5, src5, mask, mask, vec4, vec5); + VSHF_B2_UB(src6, src6, src7, src7, mask, mask, vec6, vec7); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + res0, res1, res2, res3); + DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, + res4, res5, res6, res7); + SRARI_H4_UH(res0, res1, res2, res3, 7); + SRARI_H4_UH(res4, res5, res6, res7, 7); + LD_UB2(dst, 16, dst0, dst1); + PCKEV_AVG_ST_UB(res1, res0, dst0, dst); + PCKEV_AVG_ST_UB(res3, res2, dst1, (dst + 16)); + dst += dst_stride; + LD_UB2(dst, 16, dst2, dst3); + PCKEV_AVG_ST_UB(res5, res4, dst2, dst); + PCKEV_AVG_ST_UB(res7, res6, dst3, (dst + 16)); + dst += dst_stride; + } +} + +void ff_avg_bilin_64h_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = vp9_bilinear_filters_msa[mx - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask; + v16u8 filt0, dst0, dst1, dst2, dst3; + v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8u16 out0, out1, out2, out3, out4, out5, out6, out7, filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + for (loop_cnt = height; loop_cnt--;) { + LD_SB4(src, 16, src0, src2, src4, src6); + src7 = LD_SB(src + 56); + SLDI_B3_SB(src2, src4, src6, src0, src2, src4, src1, src3, src5, 8); + src += src_stride; + + VSHF_B2_UB(src0, src0, src1, src1, mask, mask, vec0, vec1); + VSHF_B2_UB(src2, src2, src3, src3, mask, mask, vec2, vec3); + VSHF_B2_UB(src4, src4, src5, src5, mask, mask, vec4, vec5); + VSHF_B2_UB(src6, src6, src7, src7, mask, mask, vec6, vec7); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + out0, out1, out2, out3); + DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, + out4, out5, out6, out7); + SRARI_H4_UH(out0, out1, out2, out3, 7); + SRARI_H4_UH(out4, out5, out6, out7, 7); + LD_UB4(dst, 16, dst0, dst1, dst2, dst3); + PCKEV_AVG_ST_UB(out1, out0, dst0, dst); + PCKEV_AVG_ST_UB(out3, out2, dst1, dst + 16); + PCKEV_AVG_ST_UB(out5, out4, dst2, dst + 32); + PCKEV_AVG_ST_UB(out7, out6, dst3, dst + 48); + dst += dst_stride; + } +} + +static void common_vt_2t_and_aver_dst_4x4_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16i8 src0, src1, src2, src3, src4; + v16u8 dst0, dst1, dst2, dst3, out, filt0, src2110, src4332; + v16i8 src10_r, src32_r, src21_r, src43_r; + v8i16 filt; + v8u16 tmp0, tmp1; + + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + LD_SB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + src4 = LD_SB(src); + src += src_stride; + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + ILVR_W2_UB(dst1, dst0, dst3, dst2, dst0, dst1); + dst0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0); + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, + src10_r, src21_r, src32_r, src43_r); + ILVR_D2_UB(src21_r, src10_r, src43_r, src32_r, src2110, src4332); + DOTP_UB2_UH(src2110, src4332, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + + out = (v16u8) __msa_pckev_b((v16i8) tmp1, (v16i8) tmp0); + out = __msa_aver_u_b(out, dst0); + + ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride); +} + +static void common_vt_2t_and_aver_dst_4x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + const int8_t *filter) +{ + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src87_r; + v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r, src65_r; + v16u8 src2110, src4332, src6554, src8776, filt0; + v8u16 tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + src8 = LD_SB(src); + + LD_UB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + ILVR_W4_UB(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, dst0, dst1, + dst2, dst3); + ILVR_D2_UB(dst1, dst0, dst3, dst2, dst0, dst1); + ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, src10_r, src21_r, + src32_r, src43_r); + ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, src54_r, src65_r, + src76_r, src87_r); + ILVR_D4_UB(src21_r, src10_r, src43_r, src32_r, src65_r, src54_r, + src87_r, src76_r, src2110, src4332, src6554, src8776); + DOTP_UB4_UH(src2110, src4332, src6554, src8776, filt0, filt0, filt0, filt0, + tmp0, tmp1, tmp2, tmp3); + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, src2110, src4332); + AVER_UB2_UB(src2110, dst0, src4332, dst1, src2110, src4332); + ST4x4_UB(src2110, src2110, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + ST4x4_UB(src4332, src4332, 0, 1, 2, 3, dst, dst_stride); +} + +void ff_avg_bilin_4v_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = vp9_bilinear_filters_msa[my - 1]; + + if (4 == height) { + common_vt_2t_and_aver_dst_4x4_msa(src, src_stride, dst, dst_stride, + filter); + } else if (8 == height) { + common_vt_2t_and_aver_dst_4x8_msa(src, src_stride, dst, dst_stride, + filter); + } +} + +static void common_vt_2t_and_aver_dst_8x4_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter) +{ + v16u8 src0, src1, src2, src3, src4; + v16u8 dst0, dst1, dst2, dst3, vec0, vec1, vec2, vec3, filt0; + v8u16 tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + /* rearranging filter_y */ + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + LD_UB5(src, src_stride, src0, src1, src2, src3, src4); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + ILVR_B2_UB(src1, src0, src2, src1, vec0, vec1); + ILVR_B2_UB(src3, src2, src4, src3, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + tmp0, tmp1, tmp2, tmp3); + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_AVG_ST8x4_UB(tmp0, dst0, tmp1, dst1, tmp2, dst2, tmp3, dst3, + dst, dst_stride); +} + +static void common_vt_2t_and_aver_dst_8x8mult_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter, + int32_t height) +{ + uint32_t loop_cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8; + v16u8 dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst8; + v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0; + v8u16 tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + /* rearranging filter_y */ + filt = LD_SH(filter); + filt0 = (v16u8) __msa_splati_h(filt, 0); + + src0 = LD_UB(src); + src += src_stride; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src, src_stride, src1, src2, src3, src4, src5, src6, src7, src8); + src += (8 * src_stride); + LD_UB8(dst, dst_stride, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst8); + + ILVR_B4_UB(src1, src0, src2, src1, src3, src2, src4, src3, + vec0, vec1, vec2, vec3); + ILVR_B4_UB(src5, src4, src6, src5, src7, src6, src8, src7, + vec4, vec5, vec6, vec7); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, + tmp0, tmp1, tmp2, tmp3); + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_AVG_ST8x4_UB(tmp0, dst1, tmp1, dst2, tmp2, dst3, tmp3, + dst4, dst, dst_stride); + dst += (4 * dst_stride); + + DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, + tmp0, tmp1, tmp2, tmp3); + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_AVG_ST8x4_UB(tmp0, dst5, tmp1, dst6, tmp2, dst7, tmp3, + dst8, dst, dst_stride); + dst += (4 * dst_stride); + + src0 = src8; + } +} + +void ff_avg_bilin_8v_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter = vp9_bilinear_filters_msa[my - 1]; + + if (4 == height) { + common_vt_2t_and_aver_dst_8x4_msa(src, src_stride, dst, dst_stride, + filter); + } else { + common_vt_2t_and_aver_dst_8x8mult_msa(src, src_stride, dst, dst_stride, + filter, height); + } +} + +void ff_avg_bilin_16v_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = vp9_bilinear_filters_msa[my - 1]; + v16u8 src0, src1, src2, src3, src4, dst0, dst1, dst2, dst3, filt0; + v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8u16 tmp0, tmp1, tmp2, tmp3, filt; + + /* rearranging filter_y */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + src0 = LD_UB(src); + src += src_stride; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + ILVR_B2_UB(src1, src0, src2, src1, vec0, vec2); + ILVL_B2_UB(src1, src0, src2, src1, vec1, vec3); + DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_AVG_ST_UB(tmp1, tmp0, dst0, dst); + dst += dst_stride; + + ILVR_B2_UB(src3, src2, src4, src3, vec4, vec6); + ILVL_B2_UB(src3, src2, src4, src3, vec5, vec7); + DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_AVG_ST_UB(tmp3, tmp2, dst1, dst); + dst += dst_stride; + + DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_AVG_ST_UB(tmp1, tmp0, dst2, dst); + dst += dst_stride; + + DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_AVG_ST_UB(tmp3, tmp2, dst3, dst); + dst += dst_stride; + + src0 = src4; + } +} + +void ff_avg_bilin_32v_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = vp9_bilinear_filters_msa[my - 1]; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0; + v8u16 tmp0, tmp1, tmp2, tmp3, filt; + + /* rearranging filter_y */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_UB2(src, 16, src0, src5); + src += src_stride; + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_UB4(src, src_stride, src1, src2, src3, src4); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + ILVR_B2_UB(src1, src0, src2, src1, vec0, vec2); + ILVL_B2_UB(src1, src0, src2, src1, vec1, vec3); + + LD_UB4(src + 16, src_stride, src6, src7, src8, src9); + LD_UB4(dst + 16, dst_stride, dst4, dst5, dst6, dst7); + src += (4 * src_stride); + + DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_AVG_ST_UB(tmp1, tmp0, dst0, dst); + + DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_AVG_ST_UB(tmp3, tmp2, dst1, dst + dst_stride); + + ILVR_B2_UB(src3, src2, src4, src3, vec4, vec6); + ILVL_B2_UB(src3, src2, src4, src3, vec5, vec7); + DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_AVG_ST_UB(tmp1, tmp0, dst2, dst + 2 * dst_stride); + + DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_AVG_ST_UB(tmp3, tmp2, dst3, dst + 3 * dst_stride); + + ILVR_B2_UB(src6, src5, src7, src6, vec0, vec2); + ILVL_B2_UB(src6, src5, src7, src6, vec1, vec3); + DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_AVG_ST_UB(tmp1, tmp0, dst4, dst + 16); + + DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_AVG_ST_UB(tmp3, tmp2, dst5, dst + 16 + dst_stride); + + ILVR_B2_UB(src8, src7, src9, src8, vec4, vec6); + ILVL_B2_UB(src8, src7, src9, src8, vec5, vec7); + DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_AVG_ST_UB(tmp1, tmp0, dst6, dst + 16 + 2 * dst_stride); + + DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_AVG_ST_UB(tmp3, tmp2, dst7, dst + 16 + 3 * dst_stride); + dst += (4 * dst_stride); + + src0 = src4; + src5 = src9; + } +} + +void ff_avg_bilin_64v_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter = vp9_bilinear_filters_msa[my - 1]; + v16u8 src0, src1, src2, src3, src4, src5; + v16u8 src6, src7, src8, src9, src10, src11, filt0; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8u16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v8u16 filt; + + /* rearranging filter_y */ + filt = LD_UH(filter); + filt0 = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_UB4(src, 16, src0, src3, src6, src9); + src += src_stride; + + for (loop_cnt = (height >> 1); loop_cnt--;) { + LD_UB2(src, src_stride, src1, src2); + LD_UB2(dst, dst_stride, dst0, dst1); + LD_UB2(src + 16, src_stride, src4, src5); + LD_UB2(dst + 16, dst_stride, dst2, dst3); + LD_UB2(src + 32, src_stride, src7, src8); + LD_UB2(dst + 32, dst_stride, dst4, dst5); + LD_UB2(src + 48, src_stride, src10, src11); + LD_UB2(dst + 48, dst_stride, dst6, dst7); + src += (2 * src_stride); + + ILVR_B2_UB(src1, src0, src2, src1, vec0, vec2); + ILVL_B2_UB(src1, src0, src2, src1, vec1, vec3); + DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_AVG_ST_UB(tmp1, tmp0, dst0, dst); + + DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_AVG_ST_UB(tmp3, tmp2, dst1, dst + dst_stride); + + ILVR_B2_UB(src4, src3, src5, src4, vec4, vec6); + ILVL_B2_UB(src4, src3, src5, src4, vec5, vec7); + DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp4, tmp5); + SRARI_H2_UH(tmp4, tmp5, 7); + SAT_UH2_UH(tmp4, tmp5, 7); + PCKEV_AVG_ST_UB(tmp5, tmp4, dst2, dst + 16); + + DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp6, tmp7); + SRARI_H2_UH(tmp6, tmp7, 7); + SAT_UH2_UH(tmp6, tmp7, 7); + PCKEV_AVG_ST_UB(tmp7, tmp6, dst3, dst + 16 + dst_stride); + + ILVR_B2_UB(src7, src6, src8, src7, vec0, vec2); + ILVL_B2_UB(src7, src6, src8, src7, vec1, vec3); + DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_AVG_ST_UB(tmp1, tmp0, dst4, dst + 32); + + DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3); + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + PCKEV_AVG_ST_UB(tmp3, tmp2, dst5, dst + 32 + dst_stride); + + ILVR_B2_UB(src10, src9, src11, src10, vec4, vec6); + ILVL_B2_UB(src10, src9, src11, src10, vec5, vec7); + DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp4, tmp5); + SRARI_H2_UH(tmp4, tmp5, 7); + SAT_UH2_UH(tmp4, tmp5, 7); + PCKEV_AVG_ST_UB(tmp5, tmp4, dst6, (dst + 48)); + + DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp6, tmp7); + SRARI_H2_UH(tmp6, tmp7, 7); + SAT_UH2_UH(tmp6, tmp7, 7); + PCKEV_AVG_ST_UB(tmp7, tmp6, dst7, dst + 48 + dst_stride); + dst += (2 * dst_stride); + + src0 = src2; + src3 = src5; + src6 = src8; + src9 = src11; + } +} + +static void common_hv_2ht_2vt_and_aver_dst_4x4_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert) +{ + v16i8 src0, src1, src2, src3, src4, mask; + v16u8 filt_hz, filt_vt, vec0, vec1; + v16u8 dst0, dst1, dst2, dst3, res0, res1; + v8u16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, tmp0, tmp1, filt; + + mask = LD_SB(&mc_filt_mask_arr[16]); + + /* rearranging filter */ + filt = LD_UH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h((v8i16) filt, 0); + + filt = LD_UH(filter_vert); + filt_vt = (v16u8) __msa_splati_h((v8i16) filt, 0); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src1, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src2, src3, mask, filt_hz, 7); + hz_out4 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + hz_out1 = (v8u16) __msa_sldi_b((v16i8) hz_out2, (v16i8) hz_out0, 8); + hz_out3 = (v8u16) __msa_pckod_d((v2i64) hz_out4, (v2i64) hz_out2); + ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + ILVR_W2_UB(dst1, dst0, dst3, dst2, dst0, dst2); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_B2_UB(tmp0, tmp0, tmp1, tmp1, res0, res1); + AVER_UB2_UB(res0, dst0, res1, dst2, res0, res1); + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); +} + +static void common_hv_2ht_2vt_and_aver_dst_4x8_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert) +{ + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, mask; + v16u8 filt_hz, filt_vt, vec0, vec1, vec2, vec3, res0, res1, res2, res3; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v8u16 hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6; + v8u16 hz_out7, hz_out8, tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + mask = LD_SB(&mc_filt_mask_arr[16]); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h(filt, 0); + + filt = LD_SH(filter_vert); + filt_vt = (v16u8) __msa_splati_h(filt, 0); + + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + src8 = LD_SB(src); + + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src1, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src2, src3, mask, filt_hz, 7); + hz_out4 = HORIZ_2TAP_FILT_UH(src4, src5, mask, filt_hz, 7); + hz_out6 = HORIZ_2TAP_FILT_UH(src6, src7, mask, filt_hz, 7); + hz_out8 = HORIZ_2TAP_FILT_UH(src8, src8, mask, filt_hz, 7); + SLDI_B3_UH(hz_out2, hz_out4, hz_out6, hz_out0, hz_out2, hz_out4, hz_out1, + hz_out3, hz_out5, 8); + hz_out7 = (v8u16) __msa_pckod_d((v2i64) hz_out8, (v2i64) hz_out6); + + LD_UB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + ILVR_W4_UB(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, dst0, dst2, + dst4, dst6); + ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1); + ILVEV_B2_UB(hz_out4, hz_out5, hz_out6, hz_out7, vec2, vec3); + DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt_vt, filt_vt, filt_vt, filt_vt, + tmp0, tmp1, tmp2, tmp3); + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_B4_UB(tmp0, tmp0, tmp1, tmp1, tmp2, tmp2, tmp3, tmp3, res0, res1, + res2, res3); + AVER_UB4_UB(res0, dst0, res1, dst2, res2, dst4, res3, dst6, res0, res1, + res2, res3); + ST4x4_UB(res0, res1, 0, 1, 0, 1, dst, dst_stride); + dst += (4 * dst_stride); + ST4x4_UB(res2, res3, 0, 1, 0, 1, dst, dst_stride); +} + +void ff_avg_bilin_4hv_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter_horiz = vp9_bilinear_filters_msa[mx - 1]; + const int8_t *filter_vert = vp9_bilinear_filters_msa[my - 1]; + + if (4 == height) { + common_hv_2ht_2vt_and_aver_dst_4x4_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert); + } else if (8 == height) { + common_hv_2ht_2vt_and_aver_dst_4x8_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert); + } +} + +static void common_hv_2ht_2vt_and_aver_dst_8x4_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert) +{ + v16i8 src0, src1, src2, src3, src4, mask; + v16u8 filt_hz, filt_vt, dst0, dst1, dst2, dst3, vec0, vec1, vec2, vec3; + v8u16 hz_out0, hz_out1, tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h(filt, 0); + + filt = LD_SH(filter_vert); + filt_vt = (v16u8) __msa_splati_h(filt, 0); + + LD_SB5(src, src_stride, src0, src1, src2, src3, src4); + src += (5 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, 7); + hz_out1 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp0 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, 7); + vec1 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp1 = __msa_dotp_u_h(vec1, filt_vt); + + hz_out1 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, 7); + vec2 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp2 = __msa_dotp_u_h(vec2, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + vec3 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp3 = __msa_dotp_u_h(vec3, filt_vt); + + SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, 7); + SAT_UH4_UH(tmp0, tmp1, tmp2, tmp3, 7); + PCKEV_AVG_ST8x4_UB(tmp0, dst0, tmp1, dst1, tmp2, dst2, tmp3, dst3, + dst, dst_stride); +} + +static void common_hv_2ht_2vt_and_aver_dst_8x8mult_msa(const uint8_t *src, + int32_t src_stride, + uint8_t *dst, + int32_t dst_stride, + const int8_t *filter_horiz, + const int8_t *filter_vert, + int32_t height) +{ + uint32_t loop_cnt; + v16i8 src0, src1, src2, src3, src4, mask; + v16u8 filt_hz, filt_vt, vec0, dst0, dst1, dst2, dst3; + v8u16 hz_out0, hz_out1, tmp0, tmp1, tmp2, tmp3; + v8i16 filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h(filt, 0); + + filt = LD_SH(filter_vert); + filt_vt = (v16u8) __msa_splati_h(filt, 0); + + src0 = LD_SB(src); + src += src_stride; + + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, 7); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src1, src2, src3, src4); + src += (4 * src_stride); + + hz_out1 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp0 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp1 = __msa_dotp_u_h(vec0, filt_vt); + + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + + hz_out1 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out1, (v16i8) hz_out0); + tmp2 = __msa_dotp_u_h(vec0, filt_vt); + + hz_out0 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + vec0 = (v16u8) __msa_ilvev_b((v16i8) hz_out0, (v16i8) hz_out1); + tmp3 = __msa_dotp_u_h(vec0, filt_vt); + + SRARI_H2_UH(tmp2, tmp3, 7); + SAT_UH2_UH(tmp2, tmp3, 7); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + PCKEV_AVG_ST8x4_UB(tmp0, dst0, tmp1, dst1, tmp2, dst2, tmp3, + dst3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +void ff_avg_bilin_8hv_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + const int8_t *filter_horiz = vp9_bilinear_filters_msa[mx - 1]; + const int8_t *filter_vert = vp9_bilinear_filters_msa[my - 1]; + + if (4 == height) { + common_hv_2ht_2vt_and_aver_dst_8x4_msa(src, src_stride, dst, dst_stride, + filter_horiz, filter_vert); + } else { + common_hv_2ht_2vt_and_aver_dst_8x8mult_msa(src, src_stride, + dst, dst_stride, + filter_horiz, filter_vert, + height); + } +} + +void ff_avg_bilin_16hv_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + uint32_t loop_cnt; + const int8_t *filter_horiz = vp9_bilinear_filters_msa[mx - 1]; + const int8_t *filter_vert = vp9_bilinear_filters_msa[my - 1]; + v16i8 src0, src1, src2, src3, src4, src5, src6, src7, mask; + v16u8 filt_hz, filt_vt, vec0, vec1, dst0, dst1, dst2, dst3; + v8u16 hz_out0, hz_out1, hz_out2, hz_out3, tmp0, tmp1; + v8i16 filt; + + mask = LD_SB(&mc_filt_mask_arr[0]); + + /* rearranging filter */ + filt = LD_SH(filter_horiz); + filt_hz = (v16u8) __msa_splati_h(filt, 0); + + filt = LD_SH(filter_vert); + filt_vt = (v16u8) __msa_splati_h(filt, 0); + + LD_SB2(src, 8, src0, src1); + src += src_stride; + + hz_out0 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + + for (loop_cnt = (height >> 2); loop_cnt--;) { + LD_SB4(src, src_stride, src0, src2, src4, src6); + LD_SB4(src + 8, src_stride, src1, src3, src5, src7); + src += (4 * src_stride); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + hz_out1 = HORIZ_2TAP_FILT_UH(src0, src0, mask, filt_hz, 7); + hz_out3 = HORIZ_2TAP_FILT_UH(src1, src1, mask, filt_hz, 7); + ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_AVG_ST_UB(tmp1, tmp0, dst0, dst); + dst += dst_stride; + + hz_out0 = HORIZ_2TAP_FILT_UH(src2, src2, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src3, src3, mask, filt_hz, 7); + ILVEV_B2_UB(hz_out1, hz_out0, hz_out3, hz_out2, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_AVG_ST_UB(tmp1, tmp0, dst1, dst); + dst += dst_stride; + + hz_out1 = HORIZ_2TAP_FILT_UH(src4, src4, mask, filt_hz, 7); + hz_out3 = HORIZ_2TAP_FILT_UH(src5, src5, mask, filt_hz, 7); + ILVEV_B2_UB(hz_out0, hz_out1, hz_out2, hz_out3, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_AVG_ST_UB(tmp1, tmp0, dst2, dst); + dst += dst_stride; + + hz_out0 = HORIZ_2TAP_FILT_UH(src6, src6, mask, filt_hz, 7); + hz_out2 = HORIZ_2TAP_FILT_UH(src7, src7, mask, filt_hz, 7); + ILVEV_B2_UB(hz_out1, hz_out0, hz_out3, hz_out2, vec0, vec1); + DOTP_UB2_UH(vec0, vec1, filt_vt, filt_vt, tmp0, tmp1); + SRARI_H2_UH(tmp0, tmp1, 7); + SAT_UH2_UH(tmp0, tmp1, 7); + PCKEV_AVG_ST_UB(tmp1, tmp0, dst3, dst); + dst += dst_stride; + } +} + +void ff_avg_bilin_32hv_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 2; multiple8_cnt--;) { + ff_avg_bilin_16hv_msa(dst, dst_stride, src, src_stride, height, mx, my); + + src += 16; + dst += 16; + } +} + +void ff_avg_bilin_64hv_msa(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + int height, int mx, int my) +{ + int32_t multiple8_cnt; + + for (multiple8_cnt = 4; multiple8_cnt--;) { + ff_avg_bilin_16hv_msa(dst, dst_stride, src, src_stride, height, mx, my); + + src += 16; + dst += 16; + } +} + +static void copy_width8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint64_t out0, out1, out2, out3, out4, out5, out6, out7; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + if (0 == height % 12) { + for (cnt = (height / 12); cnt--;) { + LD_UB8(src, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + out4 = __msa_copy_u_d((v2i64) src4, 0); + out5 = __msa_copy_u_d((v2i64) src5, 0); + out6 = __msa_copy_u_d((v2i64) src6, 0); + out7 = __msa_copy_u_d((v2i64) src7, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + SD4(out4, out5, out6, out7, dst, dst_stride); + dst += (4 * dst_stride); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 8) { + for (cnt = height >> 3; cnt--;) { + LD_UB8(src, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + out4 = __msa_copy_u_d((v2i64) src4, 0); + out5 = __msa_copy_u_d((v2i64) src5, 0); + out6 = __msa_copy_u_d((v2i64) src6, 0); + out7 = __msa_copy_u_d((v2i64) src7, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + SD4(out4, out5, out6, out7, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 4) { + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + out2 = __msa_copy_u_d((v2i64) src2, 0); + out3 = __msa_copy_u_d((v2i64) src3, 0); + + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 2) { + for (cnt = (height / 2); cnt--;) { + LD_UB2(src, src_stride, src0, src1); + src += (2 * src_stride); + out0 = __msa_copy_u_d((v2i64) src0, 0); + out1 = __msa_copy_u_d((v2i64) src1, 0); + + SD(out0, dst); + dst += dst_stride; + SD(out1, dst); + dst += dst_stride; + } + } +} + +static void copy_16multx8mult_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height, int32_t width) +{ + int32_t cnt, loop_cnt; + const uint8_t *src_tmp; + uint8_t *dst_tmp; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + for (cnt = (width >> 4); cnt--;) { + src_tmp = src; + dst_tmp = dst; + + for (loop_cnt = (height >> 3); loop_cnt--;) { + LD_UB8(src_tmp, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src_tmp += (8 * src_stride); + + ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, + dst_tmp, dst_stride); + dst_tmp += (8 * dst_stride); + } + + src += 16; + dst += 16; + } +} + +static void copy_width16_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + if (0 == height % 12) { + for (cnt = (height / 12); cnt--;) { + LD_UB8(src, src_stride, + src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, + dst, dst_stride); + dst += (8 * dst_stride); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 8) { + copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 16); + } else if (0 == height % 4) { + for (cnt = (height >> 2); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + dst += (4 * dst_stride); + } + } +} + +static void copy_width32_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + + if (0 == height % 12) { + for (cnt = (height / 12); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + LD_UB4(src + 16, src_stride, src4, src5, src6, src7); + src += (4 * src_stride); + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + ST_UB4(src4, src5, src6, src7, dst + 16, dst_stride); + dst += (4 * dst_stride); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + LD_UB4(src + 16, src_stride, src4, src5, src6, src7); + src += (4 * src_stride); + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + ST_UB4(src4, src5, src6, src7, dst + 16, dst_stride); + dst += (4 * dst_stride); + + LD_UB4(src, src_stride, src0, src1, src2, src3); + LD_UB4(src + 16, src_stride, src4, src5, src6, src7); + src += (4 * src_stride); + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + ST_UB4(src4, src5, src6, src7, dst + 16, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == height % 8) { + copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 32); + } else if (0 == height % 4) { + for (cnt = (height >> 2); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + LD_UB4(src + 16, src_stride, src4, src5, src6, src7); + src += (4 * src_stride); + ST_UB4(src0, src1, src2, src3, dst, dst_stride); + ST_UB4(src4, src5, src6, src7, dst + 16, dst_stride); + dst += (4 * dst_stride); + } + } +} + +static void copy_width64_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 64); +} + +static void avg_width4_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint32_t out0, out1, out2, out3; + v16u8 src0, src1, src2, src3; + v16u8 dst0, dst1, dst2, dst3; + + if (0 == (height % 4)) { + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + + out0 = __msa_copy_u_w((v4i32) dst0, 0); + out1 = __msa_copy_u_w((v4i32) dst1, 0); + out2 = __msa_copy_u_w((v4i32) dst2, 0); + out3 = __msa_copy_u_w((v4i32) dst3, 0); + SW4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } + } else if (0 == (height % 2)) { + for (cnt = (height / 2); cnt--;) { + LD_UB2(src, src_stride, src0, src1); + src += (2 * src_stride); + + LD_UB2(dst, dst_stride, dst0, dst1); + + AVER_UB2_UB(src0, dst0, src1, dst1, dst0, dst1); + + out0 = __msa_copy_u_w((v4i32) dst0, 0); + out1 = __msa_copy_u_w((v4i32) dst1, 0); + SW(out0, dst); + dst += dst_stride; + SW(out1, dst); + dst += dst_stride; + } + } +} + +static void avg_width8_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint64_t out0, out1, out2, out3; + v16u8 src0, src1, src2, src3; + v16u8 dst0, dst1, dst2, dst3; + + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, src_stride, src0, src1, src2, src3); + src += (4 * src_stride); + LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + + out0 = __msa_copy_u_d((v2i64) dst0, 0); + out1 = __msa_copy_u_d((v2i64) dst1, 0); + out2 = __msa_copy_u_d((v2i64) dst2, 0); + out3 = __msa_copy_u_d((v2i64) dst3, 0); + SD4(out0, out1, out2, out3, dst, dst_stride); + dst += (4 * dst_stride); + } +} + +static void avg_width16_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + + for (cnt = (height / 8); cnt--;) { + LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + src += (8 * src_stride); + LD_UB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + AVER_UB4_UB(src4, dst4, src5, dst5, src6, dst6, src7, dst7, + dst4, dst5, dst6, dst7); + ST_UB8(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst, dst_stride); + dst += (8 * dst_stride); + } +} + +static void avg_width32_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint8_t *dst_dup = dst; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + v16u8 src8, src9, src10, src11, src12, src13, src14, src15; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v16u8 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; + + for (cnt = (height / 8); cnt--;) { + LD_UB4(src, src_stride, src0, src2, src4, src6); + LD_UB4(src + 16, src_stride, src1, src3, src5, src7); + src += (4 * src_stride); + LD_UB4(dst_dup, dst_stride, dst0, dst2, dst4, dst6); + LD_UB4(dst_dup + 16, dst_stride, dst1, dst3, dst5, dst7); + dst_dup += (4 * dst_stride); + LD_UB4(src, src_stride, src8, src10, src12, src14); + LD_UB4(src + 16, src_stride, src9, src11, src13, src15); + src += (4 * src_stride); + LD_UB4(dst_dup, dst_stride, dst8, dst10, dst12, dst14); + LD_UB4(dst_dup + 16, dst_stride, dst9, dst11, dst13, dst15); + dst_dup += (4 * dst_stride); + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + AVER_UB4_UB(src4, dst4, src5, dst5, src6, dst6, src7, dst7, + dst4, dst5, dst6, dst7); + AVER_UB4_UB(src8, dst8, src9, dst9, src10, dst10, src11, dst11, + dst8, dst9, dst10, dst11); + AVER_UB4_UB(src12, dst12, src13, dst13, src14, dst14, src15, dst15, + dst12, dst13, dst14, dst15); + + ST_UB4(dst0, dst2, dst4, dst6, dst, dst_stride); + ST_UB4(dst1, dst3, dst5, dst7, dst + 16, dst_stride); + dst += (4 * dst_stride); + ST_UB4(dst8, dst10, dst12, dst14, dst, dst_stride); + ST_UB4(dst9, dst11, dst13, dst15, dst + 16, dst_stride); + dst += (4 * dst_stride); + } +} + +static void avg_width64_msa(const uint8_t *src, int32_t src_stride, + uint8_t *dst, int32_t dst_stride, + int32_t height) +{ + int32_t cnt; + uint8_t *dst_dup = dst; + v16u8 src0, src1, src2, src3, src4, src5, src6, src7; + v16u8 src8, src9, src10, src11, src12, src13, src14, src15; + v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v16u8 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; + + for (cnt = (height / 4); cnt--;) { + LD_UB4(src, 16, src0, src1, src2, src3); + src += src_stride; + LD_UB4(src, 16, src4, src5, src6, src7); + src += src_stride; + LD_UB4(src, 16, src8, src9, src10, src11); + src += src_stride; + LD_UB4(src, 16, src12, src13, src14, src15); + src += src_stride; + + LD_UB4(dst_dup, 16, dst0, dst1, dst2, dst3); + dst_dup += dst_stride; + LD_UB4(dst_dup, 16, dst4, dst5, dst6, dst7); + dst_dup += dst_stride; + LD_UB4(dst_dup, 16, dst8, dst9, dst10, dst11); + dst_dup += dst_stride; + LD_UB4(dst_dup, 16, dst12, dst13, dst14, dst15); + dst_dup += dst_stride; + + AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3, + dst0, dst1, dst2, dst3); + AVER_UB4_UB(src4, dst4, src5, dst5, src6, dst6, src7, dst7, + dst4, dst5, dst6, dst7); + AVER_UB4_UB(src8, dst8, src9, dst9, src10, dst10, src11, dst11, + dst8, dst9, dst10, dst11); + AVER_UB4_UB(src12, dst12, src13, dst13, src14, dst14, src15, dst15, + dst12, dst13, dst14, dst15); + + ST_UB4(dst0, dst1, dst2, dst3, dst, 16); + dst += dst_stride; + ST_UB4(dst4, dst5, dst6, dst7, dst, 16); + dst += dst_stride; + ST_UB4(dst8, dst9, dst10, dst11, dst, 16); + dst += dst_stride; + ST_UB4(dst12, dst13, dst14, dst15, dst, 16); + dst += dst_stride; + } +} + +static const int8_t vp9_subpel_filters_msa[3][15][8] = { + [FILTER_8TAP_REGULAR] = { + {0, 1, -5, 126, 8, -3, 1, 0}, + {-1, 3, -10, 122, 18, -6, 2, 0}, + {-1, 4, -13, 118, 27, -9, 3, -1}, + {-1, 4, -16, 112, 37, -11, 4, -1}, + {-1, 5, -18, 105, 48, -14, 4, -1}, + {-1, 5, -19, 97, 58, -16, 5, -1}, + {-1, 6, -19, 88, 68, -18, 5, -1}, + {-1, 6, -19, 78, 78, -19, 6, -1}, + {-1, 5, -18, 68, 88, -19, 6, -1}, + {-1, 5, -16, 58, 97, -19, 5, -1}, + {-1, 4, -14, 48, 105, -18, 5, -1}, + {-1, 4, -11, 37, 112, -16, 4, -1}, + {-1, 3, -9, 27, 118, -13, 4, -1}, + {0, 2, -6, 18, 122, -10, 3, -1}, + {0, 1, -3, 8, 126, -5, 1, 0}, + }, [FILTER_8TAP_SHARP] = { + {-1, 3, -7, 127, 8, -3, 1, 0}, + {-2, 5, -13, 125, 17, -6, 3, -1}, + {-3, 7, -17, 121, 27, -10, 5, -2}, + {-4, 9, -20, 115, 37, -13, 6, -2}, + {-4, 10, -23, 108, 48, -16, 8, -3}, + {-4, 10, -24, 100, 59, -19, 9, -3}, + {-4, 11, -24, 90, 70, -21, 10, -4}, + {-4, 11, -23, 80, 80, -23, 11, -4}, + {-4, 10, -21, 70, 90, -24, 11, -4}, + {-3, 9, -19, 59, 100, -24, 10, -4}, + {-3, 8, -16, 48, 108, -23, 10, -4}, + {-2, 6, -13, 37, 115, -20, 9, -4}, + {-2, 5, -10, 27, 121, -17, 7, -3}, + {-1, 3, -6, 17, 125, -13, 5, -2}, + {0, 1, -3, 8, 127, -7, 3, -1}, + }, [FILTER_8TAP_SMOOTH] = { + {-3, -1, 32, 64, 38, 1, -3, 0}, + {-2, -2, 29, 63, 41, 2, -3, 0}, + {-2, -2, 26, 63, 43, 4, -4, 0}, + {-2, -3, 24, 62, 46, 5, -4, 0}, + {-2, -3, 21, 60, 49, 7, -4, 0}, + {-1, -4, 18, 59, 51, 9, -4, 0}, + {-1, -4, 16, 57, 53, 12, -4, -1}, + {-1, -4, 14, 55, 55, 14, -4, -1}, + {-1, -4, 12, 53, 57, 16, -4, -1}, + {0, -4, 9, 51, 59, 18, -4, -1}, + {0, -4, 7, 49, 60, 21, -3, -2}, + {0, -4, 5, 46, 62, 24, -3, -2}, + {0, -4, 4, 43, 63, 26, -2, -2}, + {0, -3, 2, 41, 63, 29, -2, -2}, + {0, -3, 1, 38, 64, 32, -1, -3}, + } +}; + +#define VP9_8TAP_MIPS_MSA_FUNC(SIZE, type, type_idx) \ +void ff_put_8tap_##type##_##SIZE##h_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, \ + ptrdiff_t srcstride, \ + int h, int mx, int my) \ +{ \ + const int8_t *filter = vp9_subpel_filters_msa[type_idx][mx-1]; \ + \ + common_hz_8t_##SIZE##w_msa(src, srcstride, dst, dststride, filter, h); \ +} \ + \ +void ff_put_8tap_##type##_##SIZE##v_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, \ + ptrdiff_t srcstride, \ + int h, int mx, int my) \ +{ \ + const int8_t *filter = vp9_subpel_filters_msa[type_idx][my-1]; \ + \ + common_vt_8t_##SIZE##w_msa(src, srcstride, dst, dststride, filter, h); \ +} \ + \ +void ff_put_8tap_##type##_##SIZE##hv_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, \ + ptrdiff_t srcstride, \ + int h, int mx, int my) \ +{ \ + const uint8_t *hfilter = vp9_subpel_filters_msa[type_idx][mx-1]; \ + const uint8_t *vfilter = vp9_subpel_filters_msa[type_idx][my-1]; \ + \ + common_hv_8ht_8vt_##SIZE##w_msa(src, srcstride, dst, dststride, hfilter, \ + vfilter, h); \ +} \ + \ +void ff_avg_8tap_##type##_##SIZE##h_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, \ + ptrdiff_t srcstride, \ + int h, int mx, int my) \ +{ \ + const int8_t *filter = vp9_subpel_filters_msa[type_idx][mx-1]; \ + \ + common_hz_8t_and_aver_dst_##SIZE##w_msa(src, srcstride, dst, \ + dststride, filter, h); \ +} \ + \ +void ff_avg_8tap_##type##_##SIZE##v_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, \ + ptrdiff_t srcstride, \ + int h, int mx, int my) \ +{ \ + const int8_t *filter = vp9_subpel_filters_msa[type_idx][my-1]; \ + \ + common_vt_8t_and_aver_dst_##SIZE##w_msa(src, srcstride, dst, dststride, \ + filter, h); \ +} \ + \ +void ff_avg_8tap_##type##_##SIZE##hv_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, \ + ptrdiff_t srcstride, \ + int h, int mx, int my) \ +{ \ + const uint8_t *hfilter = vp9_subpel_filters_msa[type_idx][mx-1]; \ + const uint8_t *vfilter = vp9_subpel_filters_msa[type_idx][my-1]; \ + \ + common_hv_8ht_8vt_and_aver_dst_##SIZE##w_msa(src, srcstride, dst, \ + dststride, hfilter, \ + vfilter, h); \ +} + +#define VP9_COPY_AVG_MIPS_MSA_FUNC(SIZE) \ +void ff_copy##SIZE##_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, ptrdiff_t srcstride, \ + int h, int mx, int my) \ +{ \ + \ + copy_width##SIZE##_msa(src, srcstride, dst, dststride, h); \ +} \ + \ +void ff_avg##SIZE##_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, ptrdiff_t srcstride, \ + int h, int mx, int my) \ +{ \ + \ + avg_width##SIZE##_msa(src, srcstride, dst, dststride, h); \ +} + +#define VP9_AVG_MIPS_MSA_FUNC(SIZE) \ +void ff_avg##SIZE##_msa(uint8_t *dst, ptrdiff_t dststride, \ + const uint8_t *src, ptrdiff_t srcstride, \ + int h, int mx, int my) \ +{ \ + \ + avg_width##SIZE##_msa(src, srcstride, dst, dststride, h); \ +} + +VP9_8TAP_MIPS_MSA_FUNC(64, regular, FILTER_8TAP_REGULAR); +VP9_8TAP_MIPS_MSA_FUNC(32, regular, FILTER_8TAP_REGULAR); +VP9_8TAP_MIPS_MSA_FUNC(16, regular, FILTER_8TAP_REGULAR); +VP9_8TAP_MIPS_MSA_FUNC(8, regular, FILTER_8TAP_REGULAR); +VP9_8TAP_MIPS_MSA_FUNC(4, regular, FILTER_8TAP_REGULAR); + +VP9_8TAP_MIPS_MSA_FUNC(64, sharp, FILTER_8TAP_SHARP); +VP9_8TAP_MIPS_MSA_FUNC(32, sharp, FILTER_8TAP_SHARP); +VP9_8TAP_MIPS_MSA_FUNC(16, sharp, FILTER_8TAP_SHARP); +VP9_8TAP_MIPS_MSA_FUNC(8, sharp, FILTER_8TAP_SHARP); +VP9_8TAP_MIPS_MSA_FUNC(4, sharp, FILTER_8TAP_SHARP); + +VP9_8TAP_MIPS_MSA_FUNC(64, smooth, FILTER_8TAP_SMOOTH); +VP9_8TAP_MIPS_MSA_FUNC(32, smooth, FILTER_8TAP_SMOOTH); +VP9_8TAP_MIPS_MSA_FUNC(16, smooth, FILTER_8TAP_SMOOTH); +VP9_8TAP_MIPS_MSA_FUNC(8, smooth, FILTER_8TAP_SMOOTH); +VP9_8TAP_MIPS_MSA_FUNC(4, smooth, FILTER_8TAP_SMOOTH); + +VP9_COPY_AVG_MIPS_MSA_FUNC(64); +VP9_COPY_AVG_MIPS_MSA_FUNC(32); +VP9_COPY_AVG_MIPS_MSA_FUNC(16); +VP9_COPY_AVG_MIPS_MSA_FUNC(8); +VP9_AVG_MIPS_MSA_FUNC(4); + +#undef VP9_8TAP_MIPS_MSA_FUNC +#undef VP9_COPY_AVG_MIPS_MSA_FUNC +#undef VP9_AVG_MIPS_MSA_FUNC diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/xvididct_init_mips.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/xvididct_init_mips.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/xvididct_init_mips.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/xvididct_init_mips.c 2015-07-21 17:20:03.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015 Zhou Xiaoyong + * + * 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 "xvididct_mips.h" + +#if HAVE_MMI +static av_cold void xvid_idct_init_mmi(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth) +{ + if (!high_bit_depth) { + if (avctx->idct_algo == FF_IDCT_AUTO || + avctx->idct_algo == FF_IDCT_XVID) { + c->idct_put = ff_xvid_idct_put_mmi; + c->idct_add = ff_xvid_idct_add_mmi; + c->idct = ff_xvid_idct_mmi; + c->perm_type = FF_IDCT_PERM_NONE; + } + } +} +#endif /* HAVE_MMI */ + +av_cold void ff_xvid_idct_init_mips(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth) +{ +#if HAVE_MMI + xvid_idct_init_mmi(c, avctx, high_bit_depth); +#endif /* HAVE_MMI */ +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/xvididct_mips.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/xvididct_mips.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/xvididct_mips.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/xvididct_mips.h 2015-07-21 17:20:03.000000000 +0000 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015 Zhou Xiaoyong + * + * 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 + */ + +#ifndef AVCODEC_MIPS_XVIDIDCT_MIPS_H +#define AVCODEC_MIPS_XVIDIDCT_MIPS_H + +#include "libavcodec/xvididct.h" + +void ff_xvid_idct_mmi(int16_t *block); +void ff_xvid_idct_put_mmi(uint8_t *dest, int32_t line_size, int16_t *block); +void ff_xvid_idct_add_mmi(uint8_t *dest, int32_t line_size, int16_t *block); + +#endif /* AVCODEC_MIPS_XVIDIDCT_MIPS_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/xvid_idct_mmi.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/xvid_idct_mmi.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mips/xvid_idct_mmi.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mips/xvid_idct_mmi.c 2015-07-21 17:20:03.000000000 +0000 @@ -0,0 +1,253 @@ +/* + * Loongson SIMD optimized xvid idct + * + * Copyright (c) 2015 Loongson Technology Corporation Limited + * Copyright (c) 2015 Zhou Xiaoyong + * + * 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 "idctdsp_mips.h" +#include "xvididct_mips.h" + +#define BITS_INV_ACC 5 // 4 or 5 for IEEE +#define SHIFT_INV_ROW (16 - BITS_INV_ACC) //11 +#define SHIFT_INV_COL (1 + BITS_INV_ACC) //6 +#define RND_INV_ROW (1024 * (6 - BITS_INV_ACC)) +#define RND_INV_COL (16 * (BITS_INV_ACC - 3)) +#define RND_INV_CORR (RND_INV_COL - 1) + +#define BITS_FRW_ACC 3 // 2 or 3 for accuracy +#define SHIFT_FRW_COL BITS_FRW_ACC +#define SHIFT_FRW_ROW (BITS_FRW_ACC + 17) +#define RND_FRW_ROW (262144*(BITS_FRW_ACC - 1)) + +DECLARE_ALIGNED(8, static const int16_t, tg_1_16)[4*4] = { + 13036, 13036, 13036, 13036, // tg * (2<<16) + 0.5 + 27146, 27146, 27146, 27146, // tg * (2<<16) + 0.5 + -21746,-21746,-21746,-21746, // tg * (2<<16) + 0.5 + 23170, 23170, 23170, 23170 // cos * (2<<15) + 0.5 +}; + +DECLARE_ALIGNED(8, static const int32_t, rounder_0)[2*8] = { + 65536,65536, + 3597, 3597, + 2260, 2260, + 1203, 1203, + 0, 0, + 120, 120, + 512, 512, + 512, 512 +}; + +DECLARE_ALIGNED(8, static const int16_t, tab_i_04_mmi)[32*4] = { + 16384, 21407, 16384, 8867, // w05 w04 w01 w00 + 16384, 8867,-16384,-21407, // w07 w06 w03 w02 + 16384, -8867, 16384,-21407, // w13 w12 w09 w08 + -16384, 21407, 16384, -8867, // w15 w14 w11 w10 + 22725, 19266, 19266, -4520, // w21 w20 w17 w16 + 12873, 4520,-22725,-12873, // w23 w22 w19 w18 + 12873,-22725, 4520,-12873, // w29 w28 w25 w24 + 4520, 19266, 19266,-22725, // w31 w30 w27 w26 + + 22725, 29692, 22725, 12299, // w05 w04 w01 w00 + 22725, 12299,-22725,-29692, // w07 w06 w03 w02 + 22725,-12299, 22725,-29692, // w13 w12 w09 w08 + -22725, 29692, 22725,-12299, // w15 w14 w11 w10 + 31521, 26722, 26722, -6270, // w21 w20 w17 w16 + 17855, 6270,-31521,-17855, // w23 w22 w19 w18 + 17855,-31521, 6270,-17855, // w29 w28 w25 w24 + 6270, 26722, 26722,-31521, // w31 w30 w27 w26 + + 21407, 27969, 21407, 11585, // w05 w04 w01 w00 + 21407, 11585,-21407,-27969, // w07 w06 w03 w02 + 21407,-11585, 21407,-27969, // w13 w12 w09 w08 + -21407, 27969, 21407,-11585, // w15 w14 w11 w10 + 29692, 25172, 25172, -5906, // w21 w20 w17 w16 + 16819, 5906,-29692,-16819, // w23 w22 w19 w18 + 16819,-29692, 5906,-16819, // w29 w28 w25 w24 + 5906, 25172, 25172,-29692, // w31 w30 w27 w26 + + 19266, 25172, 19266, 10426, // w05 w04 w01 w00 + 19266, 10426,-19266,-25172, // w07 w06 w03 w02 + 19266,-10426, 19266,-25172, // w13 w12 w09 w08 + -19266, 25172, 19266,-10426, // w15 w14 w11 w10 + 26722, 22654, 22654, -5315, // w21 w20 w17 w16 + 15137, 5315,-26722,-15137, // w23 w22 w19 w18 + 15137,-26722, 5315,-15137, // w29 w28 w25 w24 + 5315, 22654, 22654,-26722, // w31 w30 w27 w26 +}; + +#define DCT_8_INV_ROW_MMI(A1,A2,A3,A4) \ + "dli $10, 0x88 \n\t" \ + "ldc1 $f4, "#A1" \n\t" /* 0; x3 x2 x1 x0 */\ + "dmtc1 $10, $f16 \n\t" \ + "ldc1 $f10, 8+"#A1" \n\t" /* 1; x7 x6 x5 x4 */\ + "ldc1 $f6, "#A3" \n\t" /* 3; w05 w04 w01 w00 */\ + "pshufh $f0, $f4, $f16 \n\t" /* x2 x0 x2 x0 */\ + "ldc1 $f8, 8+"#A3" \n\t" /* 4; w07 w06 w03 w02 */\ + "ldc1 $f12, 32+"#A3" \n\t" /* 6; w21 w20 w17 w16 */\ + "pmaddhw $f6, $f6, $f0 \n\t" /* x2*w05+x0*w04 x2*w01+x0*w00 */\ + "dli $10, 0xdd \n\t" \ + "pshufh $f2, $f10, $f16 \n\t" /* x6 x4 x6 x4 */\ + "dmtc1 $10, $f16 \n\t" \ + "pmaddhw $f8, $f8, $f2 \n\t" /* x6*w07+x4*w06 x6*w03+x4*w02 */\ + "ldc1 $f14, 40+"#A3" \n\t" /* 7; w23 w22 w19 w18 */\ + "pshufh $f4, $f4, $f16 \n\t" /* x3 x1 x3 x1 */\ + "pmaddhw $f12, $f12, $f4 \n\t" /* x3*w21+x1*w20 x3*w17+x1*w16 */\ + "pshufh $f10, $f10, $f16 \n\t" /* x7 x5 x7 x5 */\ + "ldc1 $f18, "#A4" \n\t" \ + "pmaddhw $f14, $f14, $f10 \n\t" /* x7*w23+x5*w22 x7*w19+x5*w18 */\ + "paddw $f6, $f6, $f18 \n\t" /* +%4 */\ + "ldc1 $f16, 16+"#A3" \n\t" \ + "pmaddhw $f0, $f0, $f16 \n\t" /* x2*w13+x0*w12 x2*w09+x0*w08 */\ + "ldc1 $f16, 24+"#A3" \n\t" \ + "paddw $f6, $f6, $f8 \n\t" /* 4; a1=sum(even1) a0=sum(even0) */\ + "pmaddhw $f2, $f2, $f16 \n\t" /* x6*w15+x4*w14 x6*w11+x4*w10 */\ + "ldc1 $f16, 48+"#A3" \n\t" \ + "pmaddhw $f4, $f4, $f16 \n\t" /* x3*w29+x1*w28 x3*w25+x1*w24 */\ + "ldc1 $f16, 56+"#A3" \n\t" \ + "paddw $f12, $f12, $f14 \n\t" /* 7; b1=sum(odd1) b0=sum(odd0) */\ + "dli $10, 11 \n\t" \ + "pmaddhw $f10, $f10, $f16 \n\t" /* x7*w31+x5*w30 x7*w27+x5*w26 */\ + "dmtc1 $10, $f16 \n\t" \ + "psubw $f8, $f6, $f12 \n\t" /* 6; a1-b1 a0-b0 */\ + "paddw $f6, $f6, $f12 \n\t" /* a1+b1 a0+b0 */\ + "paddw $f0, $f0, $f18 \n\t" /* +%4 */\ + "psraw $f6, $f6, $f16 \n\t" /* y1=a1+b1 y0=a0+b0 */\ + "paddw $f0, $f0, $f2 \n\t" /* 1; a3=sum(even3) a2=sum(even2) */\ + "paddw $f4, $f4, $f10 \n\t" /* 5; b3=sum(odd3) b2=sum(odd2) */\ + "psraw $f8, $f8, $f16 \n\t" /* y6=a1-b1 y7=a0-b0 */\ + "psubw $f14, $f0, $f4 \n\t" /* 2; a3-b3 a2-b2 */\ + "paddw $f0, $f0, $f4 \n\t" /* a3+b3 a2+b2 */\ + "psraw $f0, $f0, $f16 \n\t" /* y3=a3+b3 y2=a2+b2 */\ + "psraw $f14, $f14, $f16 \n\t" /* y4=a3-b3 y5=a2-b2 */\ + "dli $10, 0xb1 \n\t" \ + "packsswh $f6, $f6, $f0 \n\t" /* 0; y3 y2 y1 y0 */\ + "dmtc1 $10, $f16 \n\t" \ + "packsswh $f14, $f14, $f8 \n\t" /* 4; y6 y7 y4 y5 */\ + "sdc1 $f6, "#A2" \n\t" /* 3; save y3 y2 y1 y0 */\ + "pshufh $f14, $f14, $f16 \n\t" /* y7 y6 y5 y4 */\ + "sdc1 $f14, 8+"#A2" \n\t" /* 7; save y7 y6 y5 y4 */\ + + +#define DCT_8_INV_COL(A1,A2) \ + "ldc1 $f2, 2*8(%3) \n\t" \ + "ldc1 $f6, 16*3+"#A1" \n\t" \ + "ldc1 $f10, 16*5+"#A1" \n\t" \ + "pmulhh $f0, $f2, $f6 \n\t" /* x3*(tg_3_16-1) */\ + "ldc1 $f4, 0(%3) \n\t" \ + "pmulhh $f2, $f2, $f10 \n\t" /* x5*(tg_3_16-1) */\ + "ldc1 $f14, 16*7+"#A1" \n\t" \ + "ldc1 $f12, 16*1+"#A1" \n\t" \ + "pmulhh $f8, $f4, $f14 \n\t" /* x7*tg_1_16 */\ + "paddsh $f0, $f0, $f6 \n\t" /* x3*tg_3_16 */\ + "pmulhh $f4, $f4, $f12 \n\t" /* x1*tg_1_16 */\ + "paddsh $f2, $f2, $f6 \n\t" /* x3+x5*(tg_3_16-1) */\ + "psubsh $f0, $f0, $f10 \n\t" /* x3*tg_3_16-x5 = tm35 */\ + "ldc1 $f6, 3*8(%3) \n\t" \ + "paddsh $f2, $f2, $f10 \n\t" /* x3+x5*tg_3_16 = tp35 */\ + "paddsh $f8, $f8, $f12 \n\t" /* x1+tg_1_16*x7 = tp17 */\ + "psubsh $f4, $f4, $f14 \n\t" /* x1*tg_1_16-x7 = tm17 */\ + "paddsh $f10, $f8, $f2 \n\t" /* tp17+tp35 = b0 */\ + "psubsh $f12, $f4, $f0 \n\t" /* tm17-tm35 = b3 */\ + "psubsh $f8, $f8, $f2 \n\t" /* tp17-tp35 = t1 */\ + "paddsh $f4, $f4, $f0 \n\t" /* tm17+tm35 = t2 */\ + "ldc1 $f14, 1*8(%3) \n\t" \ + "sdc1 $f10, 3*16+"#A2" \n\t" /* save b0 */\ + "paddsh $f2, $f8, $f4 \n\t" /* t1+t2 */\ + "sdc1 $f12, 5*16+"#A2" \n\t" /* save b3 */\ + "psubsh $f8, $f8, $f4 \n\t" /* t1-t2 */\ + "ldc1 $f10, 2*16+"#A1" \n\t" \ + "ldc1 $f12, 6*16+"#A1" \n\t" \ + "pmulhh $f0, $f14, $f10 \n\t" /* x2*tg_2_16 */\ + "pmulhh $f14, $f14, $f12 \n\t" /* x6*tg_2_16 */\ + "pmulhh $f2, $f2, $f6 \n\t" /* ocos_4_16*(t1+t2) = b1/2 */\ + "ldc1 $f4, 0*16+"#A1" \n\t" \ + "pmulhh $f8, $f8, $f6 \n\t" /* ocos_4_16*(t1-t2) = b2/2 */\ + "psubsh $f0, $f0, $f12 \n\t" /* t2*tg_2_16-x6 = tm26 */\ + "ldc1 $f12, 4*16+"#A1" \n\t" \ + "paddsh $f14, $f14, $f10 \n\t" /* x2+x6*tg_2_16 = tp26 */\ + "psubsh $f6, $f4, $f12 \n\t" /* x0-x4 = tm04 */\ + "paddsh $f4, $f4, $f12 \n\t" /* x0+x4 = tp04 */\ + "paddsh $f10, $f4, $f14 \n\t" /* tp04+tp26 = a0 */\ + "psubsh $f12, $f6, $f0 \n\t" /* tm04-tm26 = a2 */\ + "psubsh $f4, $f4, $f14 \n\t" /* tp04-tp26 = a3 */\ + "paddsh $f6, $f6, $f0 \n\t" /* tm04+tm26 = a1 */\ + "paddsh $f2, $f2, $f2 \n\t" /* b1 */\ + "paddsh $f8, $f8, $f8 \n\t" /* b2 */\ + "psubsh $f14, $f6, $f2 \n\t" /* a1-b1 */\ + "dli $10, 6 \n\t" \ + "paddsh $f6, $f6, $f2 \n\t" /* a1+b1 */\ + "dmtc1 $10, $f16 \n\t" \ + "psubsh $f0, $f12, $f8 \n\t" /* a2-b2 */\ + "paddsh $f12, $f12, $f8 \n\t" /* a2+b2 */\ + "psrah $f6, $f6, $f16 \n\t" /* dst1 */\ + "psrah $f12, $f12, $f16 \n\t" /* dst2 */\ + "ldc1 $f2, 3*16+"#A2" \n\t" /* load b0 */\ + "psrah $f14, $f14, $f16 \n\t" /* dst6 */\ + "psrah $f0, $f0, $f16 \n\t" /* dst5 */\ + "sdc1 $f6, 1*16+"#A2" \n\t" \ + "psubsh $f8, $f10, $f2 \n\t" /* a0-b0 */\ + "paddsh $f10, $f10, $f2 \n\t" /* a0+b0 */\ + "sdc1 $f12, 2*16+"#A2" \n\t" \ + "ldc1 $f6, 5*16+"#A2" \n\t" /* load b3 */\ + "psrah $f10, $f10, $f16 \n\t" /* dst0 */\ + "psrah $f8, $f8, $f16 \n\t" /* dst7 */\ + "sdc1 $f0, 5*16+"#A2" \n\t" \ + "psubsh $f12, $f4, $f6 \n\t" /* a3-b3 */\ + "paddsh $f4, $f4, $f6 \n\t" /* a3+b3 */\ + "sdc1 $f14, 6*16+"#A2" \n\t" \ + "sdc1 $f10, 0*16+"#A2" \n\t" \ + "psrah $f4, $f4, $f16 \n\t" /* dst3 */\ + "sdc1 $f8, 7*16+"#A2" \n\t" \ + "psrah $f12, $f12, $f16 \n\t" /* dst4 */\ + "sdc1 $f4, 3*16+"#A2" \n\t" \ + "sdc1 $f12, 4*16+"#A2" \n\t" \ + + +void ff_xvid_idct_mmi(int16_t *block) +{ + __asm__ volatile ( + //# Process each row + DCT_8_INV_ROW_MMI(0*16(%0), 0*16(%0), 64*0(%2), 8*0(%1)) + DCT_8_INV_ROW_MMI(1*16(%0), 1*16(%0), 64*1(%2), 8*1(%1)) + DCT_8_INV_ROW_MMI(2*16(%0), 2*16(%0), 64*2(%2), 8*2(%1)) + DCT_8_INV_ROW_MMI(3*16(%0), 3*16(%0), 64*3(%2), 8*3(%1)) + DCT_8_INV_ROW_MMI(4*16(%0), 4*16(%0), 64*0(%2), 8*4(%1)) + DCT_8_INV_ROW_MMI(5*16(%0), 5*16(%0), 64*3(%2), 8*5(%1)) + DCT_8_INV_ROW_MMI(6*16(%0), 6*16(%0), 64*2(%2), 8*6(%1)) + DCT_8_INV_ROW_MMI(7*16(%0), 7*16(%0), 64*1(%2), 8*7(%1)) + //# Process the columns (4 at a time) + DCT_8_INV_COL(0(%0), 0(%0)) + DCT_8_INV_COL(8(%0), 8(%0)) + ::"r"(block),"r"(rounder_0),"r"(tab_i_04_mmi),"r"(tg_1_16) + : "$10" + ); +} + +void ff_xvid_idct_put_mmi(uint8_t *dest, int32_t line_size, int16_t *block) +{ + ff_xvid_idct_mmi(block); + ff_put_pixels_clamped_mmi(block, dest, line_size); +} + +void ff_xvid_idct_add_mmi(uint8_t *dest, int32_t line_size, int16_t *block) +{ + ff_xvid_idct_mmi(block); + ff_add_pixels_clamped_mmi(block, dest, line_size); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mjpega_dump_header_bsf.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mjpega_dump_header_bsf.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mjpega_dump_header_bsf.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mjpega_dump_header_bsf.c 2015-07-28 17:20:07.000000000 +0000 @@ -44,7 +44,7 @@ } *poutbuf_size = 0; - *poutbuf = av_malloc(buf_size + 44 + FF_INPUT_BUFFER_PADDING_SIZE); + *poutbuf = av_malloc(buf_size + 44 + AV_INPUT_BUFFER_PADDING_SIZE); if (!*poutbuf) return AVERROR(ENOMEM); poutbufp = *poutbuf; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mjpegbdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mjpegbdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mjpegbdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mjpegbdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -166,7 +166,7 @@ .init = ff_mjpeg_decode_init, .close = ff_mjpeg_decode_end, .decode = mjpegb_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .max_lowres = 3, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mjpegdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mjpegdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mjpegdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mjpegdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -367,6 +367,7 @@ /* test interlaced mode */ if (s->first_picture && + (s->multiscope != 2 || s->avctx->time_base.den >= 25 * s->avctx->time_base.num) && s->org_height != 0 && s->height < ((s->org_height * 3) / 4)) { s->interlaced = 1; @@ -671,6 +672,7 @@ return AVERROR_INVALIDDATA; } val = val * quant_matrix[0] + s->last_dc[component]; + val = FFMIN(val, 32767); s->last_dc[component] = val; block[0] = val; /* AC coefs */ @@ -718,7 +720,7 @@ av_log(s->avctx, AV_LOG_ERROR, "error dc\n"); return AVERROR_INVALIDDATA; } - val = (val * quant_matrix[0] << Al) + s->last_dc[component]; + val = (val * (quant_matrix[0] << Al)) + s->last_dc[component]; s->last_dc[component] = val; block[0] = val; return 0; @@ -761,14 +763,14 @@ if (i >= se) { if (i == se) { j = s->scantable.permutated[se]; - block[j] = level * quant_matrix[j] << Al; + block[j] = level * (quant_matrix[j] << Al); break; } av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i); return AVERROR_INVALIDDATA; } j = s->scantable.permutated[i]; - block[j] = level * quant_matrix[j] << Al; + block[j] = level * (quant_matrix[j] << Al); } else { if (run == 0xF) {// ZRL - skip 15 coefficients i += 15; @@ -847,7 +849,7 @@ ZERO_RUN; j = s->scantable.permutated[i]; val--; - block[j] = ((quant_matrix[j]^val) - val) << Al; + block[j] = ((quant_matrix[j] << Al) ^ val) - val; if (i == se) { if (i > *last_nnz) *last_nnz = i; @@ -1830,6 +1832,8 @@ else if ((!strncmp(cbuf, "Intel(R) JPEG Library, version 1", 32) && s->avctx->codec_tag) || (!strncmp(cbuf, "Metasoft MJPEG Codec", 20))) s->flipped = 1; + else if (!strcmp(cbuf, "MULTISCOPE II")) + s->multiscope = 2; av_free(cbuf); } @@ -1901,7 +1905,7 @@ *unescaped_buf_ptr = s->buffer; *unescaped_buf_size = dst - s->buffer; memset(s->buffer + *unescaped_buf_size, 0, - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); av_log(s->avctx, AV_LOG_DEBUG, "escaping removed %"PTRDIFF_SPECIFIER" bytes\n", (buf_end - *buf_ptr) - (dst - s->buffer)); @@ -1946,7 +1950,7 @@ *unescaped_buf_ptr = dst; *unescaped_buf_size = (bit_count + 7) >> 3; memset(s->buffer + *unescaped_buf_size, 0, - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); } else { *unescaped_buf_ptr = *buf_ptr; *unescaped_buf_size = buf_end - *buf_ptr; @@ -2055,6 +2059,7 @@ goto fail; break; case SOF3: + s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS; s->lossless = 1; s->ls = 0; s->progressive = 0; @@ -2062,6 +2067,7 @@ goto fail; break; case SOF48: + s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS; s->lossless = 1; s->ls = 1; s->progressive = 0; @@ -2192,11 +2198,13 @@ } } else if (s->upscale_h[p] == 2) { if (is16bit) { - ((uint16_t*)line)[w - 1] = - ((uint16_t*)line)[w - 2] = ((uint16_t*)line)[(w - 1) / 3]; + ((uint16_t*)line)[w - 1] = ((uint16_t*)line)[(w - 1) / 3]; + if (w > 1) + ((uint16_t*)line)[w - 2] = ((uint16_t*)line)[w - 1]; } else { - line[w - 1] = - line[w - 2] = line[(w - 1) / 3]; + line[w - 1] = line[(w - 1) / 3]; + if (w > 1) + line[w - 2] = line[w - 1]; } for (index = w - 3; index > 0; index--) { line[index] = (line[index / 3] + line[(index + 1) / 3] + line[(index + 2) / 3] + 1) / 3; @@ -2396,7 +2404,7 @@ .close = ff_mjpeg_decode_end, .decode = ff_mjpeg_decode_frame, .flush = decode_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .max_lowres = 3, .priv_class = &mjpegdec_class, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, @@ -2413,7 +2421,7 @@ .close = ff_mjpeg_decode_end, .decode = ff_mjpeg_decode_frame, .flush = decode_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .max_lowres = 3, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mjpegdec.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mjpegdec.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mjpegdec.h 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mjpegdec.h 2015-06-21 17:20:02.000000000 +0000 @@ -114,6 +114,7 @@ int buggy_avid; int cs_itu601; int interlace_polarity; + int multiscope; int mjpb_skiptosod; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mjpegenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mjpegenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mjpegenc.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mjpegenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -252,7 +252,13 @@ } #if CONFIG_MJPEG_ENCODER -FF_MPV_GENERIC_CLASS(mjpeg) + +static const AVClass mjpeg_class = { + .class_name = "mjpeg encoder", + .item_name = av_default_item_name, + .option = ff_mpv_generic_options, + .version = LIBAVUTIL_VERSION_INT, +}; AVCodec ff_mjpeg_encoder = { .name = "mjpeg", @@ -263,7 +269,7 @@ .init = ff_mpv_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, - .capabilities = CODEC_CAP_SLICE_THREADS | CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY, + .capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_NONE }, @@ -271,7 +277,12 @@ }; #endif #if CONFIG_AMV_ENCODER -FF_MPV_GENERIC_CLASS(amv) +static const AVClass amv_class = { + .class_name = "amv encoder", + .item_name = av_default_item_name, + .option = ff_mpv_generic_options, + .version = LIBAVUTIL_VERSION_INT, +}; AVCodec ff_amv_encoder = { .name = "amv", diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mjpegenc_common.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mjpegenc_common.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mjpegenc_common.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mjpegenc_common.c 2015-07-28 17:20:07.000000000 +0000 @@ -135,7 +135,7 @@ } /* comment */ - if (!(avctx->flags & CODEC_FLAG_BITEXACT)) { + if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) { put_marker(p, COM); flush_put_bits(p); ptr = put_bits_ptr(p); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mlpdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mlpdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mlpdec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mlpdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -1314,7 +1314,7 @@ .priv_data_size = sizeof(MLPDecodeContext), .init = mlp_decode_init, .decode = read_access_unit, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif #if CONFIG_TRUEHD_DECODER @@ -1326,6 +1326,6 @@ .priv_data_size = sizeof(MLPDecodeContext), .init = mlp_decode_init, .decode = read_access_unit, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif /* CONFIG_TRUEHD_DECODER */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mmaldec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mmaldec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mmaldec.c 2015-06-19 20:44:39.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mmaldec.c 2015-07-28 17:20:07.000000000 +0000 @@ -771,7 +771,7 @@ .decode = ffmmal_decode, .flush = ffmmal_flush, .priv_class = &ffmmaldec_class, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MMAL, AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE}, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mmvideo.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mmvideo.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mmvideo.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mmvideo.c 2015-07-28 17:20:07.000000000 +0000 @@ -247,5 +247,5 @@ .init = mm_decode_init, .close = mm_decode_end, .decode = mm_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/motion_est.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/motion_est.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/motion_est.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/motion_est.c 2015-07-28 17:20:07.000000000 +0000 @@ -99,7 +99,7 @@ } static int get_flags(MotionEstContext *c, int direct, int chroma){ - return ((c->avctx->flags&CODEC_FLAG_QPEL) ? FLAG_QPEL : 0) + return ((c->avctx->flags&AV_CODEC_FLAG_QPEL) ? FLAG_QPEL : 0) + (direct ? FLAG_DIRECT : 0) + (chroma ? FLAG_CHROMA : 0); } @@ -183,8 +183,8 @@ const int stride= c->stride; const int uvstride= c->uvstride; const int dxy= subx + (suby<<(1+qpel)); //FIXME log2_subpel? - const int hx= subx + (x<<(1+qpel)); - const int hy= suby + (y<<(1+qpel)); + const int hx= subx + x*(1<<(1+qpel)); + const int hy= suby + y*(1<<(1+qpel)); uint8_t * const * const ref= c->ref[ref_index]; uint8_t * const * const src= c->src[src_index]; int d; @@ -312,11 +312,26 @@ av_log(s->avctx, AV_LOG_ERROR, "ME_MAP size is too small for SAB diamond\n"); return -1; } + +#if FF_API_MOTION_EST //special case of snow is needed because snow uses its own iterative ME code - if(s->me_method!=ME_ZERO && s->me_method!=ME_EPZS && s->me_method!=ME_X1 && s->avctx->codec_id != AV_CODEC_ID_SNOW){ - av_log(s->avctx, AV_LOG_ERROR, "me_method is only allowed to be set to zero and epzs; for hex,umh,full and others see dia_size\n"); - return -1; +FF_DISABLE_DEPRECATION_WARNINGS + if (s->motion_est == FF_ME_EPZS) { + if (s->me_method == ME_ZERO) + s->motion_est = FF_ME_ZERO; + else if (s->me_method == ME_EPZS) + s->motion_est = FF_ME_EPZS; + else if (s->me_method == ME_X1) + s->motion_est = FF_ME_XONE; + else if (s->avctx->codec_id != AV_CODEC_ID_SNOW) { + av_log(s->avctx, AV_LOG_ERROR, + "me_method is only allowed to be set to zero and epzs; " + "for hex,umh,full and others see dia_size\n"); + return -1; + } } +FF_ENABLE_DEPRECATION_WARNINGS +#endif c->avctx= s->avctx; @@ -337,7 +352,7 @@ c->mb_flags = get_flags(c, 0, c->avctx->mb_cmp &FF_CMP_CHROMA); /*FIXME s->no_rounding b_type*/ - if (s->avctx->flags & CODEC_FLAG_QPEL) { + if (s->avctx->flags & AV_CODEC_FLAG_QPEL) { c->sub_motion_search= qpel_motion_search; c->qpel_avg = s->qdsp.avg_qpel_pixels_tab; if (s->no_rounding) @@ -426,13 +441,13 @@ my > ymin && my < ymax) { int dx=0, dy=0; int d, pen_x, pen_y; - const int index= (my<me; uint8_t *pix, *ppix; - int sum, mx, my, dmin; + int sum, mx = 0, my = 0, dmin = 0; int varc; ///< the variance of the block (sum of squared (p[y][x]-average)) int vard; ///< sum of squared differences with the estimated motion vector int P[10][2]; @@ -923,52 +938,43 @@ pic->mb_var [s->mb_stride * mb_y + mb_x] = (varc+128)>>8; c->mb_var_sum_temp += (varc+128)>>8; - switch(s->me_method) { - case ME_ZERO: - default: - mx = 0; - my = 0; - dmin = 0; - break; - case ME_X1: - case ME_EPZS: - { - const int mot_stride = s->b8_stride; - const int mot_xy = s->block_index[0]; - - P_LEFT[0] = s->current_picture.motion_val[0][mot_xy - 1][0]; - P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1]; - - if(P_LEFT[0] > (c->xmax<xmax<first_slice_line) { - P_TOP[0] = s->current_picture.motion_val[0][mot_xy - mot_stride ][0]; - P_TOP[1] = s->current_picture.motion_val[0][mot_xy - mot_stride ][1]; - P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][0]; - P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][1]; - if(P_TOP[1] > (c->ymax<ymax<xmin<xmin< (c->ymax<ymax<motion_est != FF_ME_ZERO) { + const int mot_stride = s->b8_stride; + const int mot_xy = s->block_index[0]; - P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]); - P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]); + P_LEFT[0] = s->current_picture.motion_val[0][mot_xy - 1][0]; + P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1]; - if(s->out_format == FMT_H263){ - c->pred_x = P_MEDIAN[0]; - c->pred_y = P_MEDIAN[1]; - }else { /* mpeg1 at least */ - c->pred_x= P_LEFT[0]; - c->pred_y= P_LEFT[1]; - } - }else{ - c->pred_x= P_LEFT[0]; - c->pred_y= P_LEFT[1]; - } + if (P_LEFT[0] > (c->xmax << shift)) + P_LEFT[0] = c->xmax << shift; + + if (!s->first_slice_line) { + P_TOP[0] = s->current_picture.motion_val[0][mot_xy - mot_stride ][0]; + P_TOP[1] = s->current_picture.motion_val[0][mot_xy - mot_stride ][1]; + P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][0]; + P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][1]; + if (P_TOP[1] > (c->ymax << shift)) + P_TOP[1] = c->ymax << shift; + if (P_TOPRIGHT[0] < (c->xmin << shift)) + P_TOPRIGHT[0] = c->xmin << shift; + if (P_TOPRIGHT[1] > (c->ymax << shift)) + P_TOPRIGHT[1] = c->ymax << shift; + + P_MEDIAN[0] = mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]); + P_MEDIAN[1] = mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]); + if (s->out_format == FMT_H263) { + c->pred_x = P_MEDIAN[0]; + c->pred_y = P_MEDIAN[1]; + } else { /* mpeg1 at least */ + c->pred_x = P_LEFT[0]; + c->pred_y = P_LEFT[1]; + } + } else { + c->pred_x = P_LEFT[0]; + c->pred_y = P_LEFT[1]; } dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, s->p_mv_table, (1<<16)>>shift, 0, 16); - - break; } /* At this point (mx,my) are full-pell and the relative displacement */ @@ -997,7 +1003,7 @@ mx <<=shift; my <<=shift; } - if ((s->avctx->flags & CODEC_FLAG_4MV) + if ((s->avctx->flags & AV_CODEC_FLAG_4MV) && !c->skip && varc>50<<8 && vard>10<<8){ if(h263_mv4_search(s, mx, my, shift) < INT_MAX) mb_type|=CANDIDATE_MB_TYPE_INTER4V; @@ -1005,7 +1011,7 @@ set_p_mv_tables(s, mx, my, 0); }else set_p_mv_tables(s, mx, my, 1); - if ((s->avctx->flags & CODEC_FLAG_INTERLACED_ME) + if ((s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) && !c->skip){ //FIXME varc/d checks if(interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 0) < INT_MAX) mb_type |= CANDIDATE_MB_TYPE_INTER_I; @@ -1018,7 +1024,7 @@ if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip) dmin= get_mb_score(s, mx, my, 0, 0, 0, 16, 1); - if ((s->avctx->flags & CODEC_FLAG_4MV) + if ((s->avctx->flags & AV_CODEC_FLAG_4MV) && !c->skip && varc>50<<8 && vard>10<<8){ int dmin4= h263_mv4_search(s, mx, my, shift); if(dmin4 < dmin){ @@ -1026,7 +1032,7 @@ dmin=dmin4; } } - if ((s->avctx->flags & CODEC_FLAG_INTERLACED_ME) + if ((s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) && !c->skip){ //FIXME varc/d checks int dmin_i= interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 0); if(dmin_i < dmin){ @@ -1128,7 +1134,7 @@ int16_t (*mv_table)[2], int ref_index, int f_code) { MotionEstContext * const c= &s->me; - int mx, my, dmin; + int mx = 0, my = 0, dmin = 0; int P[10][2]; const int shift= 1+s->quarter_sample; const int mot_stride = s->mb_stride; @@ -1143,15 +1149,7 @@ get_limits(s, 16*mb_x, 16*mb_y); - switch(s->me_method) { - case ME_ZERO: - default: - mx = 0; - my = 0; - dmin = 0; - break; - case ME_X1: - case ME_EPZS: + if (s->motion_est != FF_ME_ZERO) { P_LEFT[0] = mv_table[mot_xy - 1][0]; P_LEFT[1] = mv_table[mot_xy - 1][1]; @@ -1180,8 +1178,6 @@ } dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, ref_index, s->p_mv_table, mv_scale, 0, 16); - - break; } dmin= c->sub_motion_search(s, &mx, &my, dmin, 0, ref_index, 0, 16); @@ -1554,7 +1550,7 @@ fbmin= bidir_refine(s, mb_x, mb_y) + penalty_factor; ff_dlog(s, "%d %d %d %d\n", dmin, fmin, bmin, fbmin); - if (s->avctx->flags & CODEC_FLAG_INTERLACED_ME) { + if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) { //FIXME mb type penalty c->skip=0; c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV; @@ -1620,7 +1616,7 @@ /* find best f_code for ME which do unlimited searches */ int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type) { - if(s->me_method>=ME_EPZS){ + if (s->motion_est != FF_ME_ZERO) { int score[8]; int i, y, range= s->avctx->me_range ? s->avctx->me_range : (INT_MAX/2); uint8_t * fcode_tab= s->fcode_tab; @@ -1685,7 +1681,7 @@ if(c->avctx->me_range && range > c->avctx->me_range) range= c->avctx->me_range; - if (s->avctx->flags & CODEC_FLAG_4MV) { + if (s->avctx->flags & AV_CODEC_FLAG_4MV) { const int wrap= s->b8_stride; /* clip / convert to intra 8x8 type MVs */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/motion_est.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/motion_est.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/motion_est.h 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/motion_est.h 2015-07-28 17:20:07.000000000 +0000 @@ -31,6 +31,10 @@ #define MAX_MV 4096 +#define FF_ME_ZERO 0 +#define FF_ME_EPZS 1 +#define FF_ME_XONE 2 + /** * Motion estimation context. */ @@ -122,7 +126,4 @@ int field_select, int16_t (*mv_table)[2], int f_code, int type, int truncate); -extern const uint8_t ff_aic_dc_scale_table[32]; -extern const uint8_t ff_h263_chroma_qscale_table[32]; - #endif /* AVCODEC_MOTIONEST_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/motion_est_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/motion_est_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/motion_est_template.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/motion_est_template.c 2015-07-10 17:20:03.000000000 +0000 @@ -358,8 +358,8 @@ #define CHECK_MV(x,y)\ {\ - const unsigned key = ((y)<= xmin);\ av_assert2((x) <= xmax);\ av_assert2((y) >= ymin);\ @@ -368,7 +368,7 @@ d= cmp(s, x, y, 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);\ map[index]= key;\ score_map[index]= d;\ - d += (mv_penalty[((x)<mecc.me_cmp[size + 1]; { /* ensure that the best point is in the MAP as h/qpel refinement needs it */ - const unsigned key = (best[1]<flags |= CODEC_FLAG_BITEXACT; + ctx->flags |= AV_CODEC_FLAG_BITEXACT; av_force_cpu_flags(0); memset(&cctx, 0, sizeof(cctx)); ff_me_cmp_init(&cctx, ctx); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/movsub_bsf.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/movsub_bsf.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/movsub_bsf.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/movsub_bsf.c 2015-07-28 17:20:07.000000000 +0000 @@ -28,7 +28,7 @@ const uint8_t *buf, int buf_size, int keyframe){ if (buf_size > 0xffff) return 0; *poutbuf_size = buf_size + 2; - *poutbuf = av_malloc(*poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE); + *poutbuf = av_malloc(*poutbuf_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!*poutbuf) return AVERROR(ENOMEM); AV_WB16(*poutbuf, buf_size); @@ -46,7 +46,7 @@ const uint8_t *buf, int buf_size, int keyframe){ if (buf_size < 2) return 0; *poutbuf_size = FFMIN(buf_size - 2, AV_RB16(buf)); - *poutbuf = av_malloc(*poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE); + *poutbuf = av_malloc(*poutbuf_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!*poutbuf) return AVERROR(ENOMEM); memcpy(*poutbuf, buf + 2, *poutbuf_size); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/movtextdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/movtextdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/movtextdec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/movtextdec.c 2015-07-26 17:20:03.000000000 +0000 @@ -27,24 +27,167 @@ #include "libavutil/intreadwrite.h" #include "libavutil/mem.h" -#define STYLE_FLAG_BOLD 1 -#define STYLE_FLAG_ITALIC 2 -#define STYLE_FLAG_UNDERLINE 4 +#define STYLE_FLAG_BOLD (1<<0) +#define STYLE_FLAG_ITALIC (1<<1) +#define STYLE_FLAG_UNDERLINE (1<<2) + +#define STYL_BOX (1<<0) +#define HLIT_BOX (1<<1) +#define HCLR_BOX (1<<2) + +typedef struct { + uint16_t style_start; + uint16_t style_end; + uint8_t style_flag; + uint8_t fontsize; +} StyleBox; + +typedef struct { + uint16_t hlit_start; + uint16_t hlit_end; +} HighlightBox; + +typedef struct { + uint8_t hlit_color[4]; +} HilightcolorBox; + +typedef struct { + StyleBox **s; + StyleBox *s_temp; + HighlightBox h; + HilightcolorBox c; + uint8_t box_flags; + uint16_t style_entries; + uint64_t tracksize; + int size_var; + int count_s; +} MovTextContext; + +typedef struct { + uint32_t type; + size_t base_size; + int (*decode)(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt); +} Box; + +static void mov_text_cleanup(MovTextContext *m) +{ + int i; + if (m->box_flags & STYL_BOX) { + for(i = 0; i < m->count_s; i++) { + av_freep(&m->s[i]); + } + av_freep(&m->s); + } +} + +static int decode_hlit(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt) +{ + m->box_flags |= HLIT_BOX; + m->h.hlit_start = AV_RB16(tsmb); + tsmb += 2; + m->h.hlit_end = AV_RB16(tsmb); + tsmb += 2; + return 0; +} + +static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt) +{ + m->box_flags |= HCLR_BOX; + memcpy(m->c.hlit_color, tsmb, 4); + tsmb += 4; + return 0; +} + +static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt) +{ + int i; + m->style_entries = AV_RB16(tsmb); + tsmb += 2; + // A single style record is of length 12 bytes. + if (m->tracksize + m->size_var + 2 + m->style_entries * 12 > avpkt->size) + return -1; + + m->box_flags |= STYL_BOX; + for(i = 0; i < m->style_entries; i++) { + m->s_temp = av_malloc(sizeof(*m->s_temp)); + if (!m->s_temp) { + mov_text_cleanup(m); + return AVERROR(ENOMEM); + } + m->s_temp->style_start = AV_RB16(tsmb); + tsmb += 2; + m->s_temp->style_end = AV_RB16(tsmb); + tsmb += 2; + // fontID = AV_RB16(tsmb); + tsmb += 2; + m->s_temp->style_flag = AV_RB8(tsmb); + tsmb++; + m->s_temp->fontsize = AV_RB8(tsmb); + av_dynarray_add(&m->s, &m->count_s, m->s_temp); + if(!m->s) { + mov_text_cleanup(m); + return AVERROR(ENOMEM); + } + tsmb++; + // text-color-rgba + tsmb += 4; + } + return 0; +} + +static const Box box_types[] = { + { MKBETAG('s','t','y','l'), 2, decode_styl }, + { MKBETAG('h','l','i','t'), 4, decode_hlit }, + { MKBETAG('h','c','l','r'), 4, decode_hclr } +}; + +const static size_t box_count = FF_ARRAY_ELEMS(box_types); static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, - char **style_start, char **style_end, - uint8_t **style_flags, int style_entries) + MovTextContext *m) { int i = 0; + int text_pos = 0; while (text < text_end) { - for (i = 0; i < style_entries; i++) { - if (*style_flags[i] && text == style_start[i]) { - if (*style_flags[i] & STYLE_FLAG_BOLD) - av_bprintf(buf, "{\\b1}"); - if (*style_flags[i] & STYLE_FLAG_ITALIC) - av_bprintf(buf, "{\\i1}"); - if (*style_flags[i] & STYLE_FLAG_UNDERLINE) - av_bprintf(buf, "{\\u1}"); + if (m->box_flags & STYL_BOX) { + for (i = 0; i < m->style_entries; i++) { + if (m->s[i]->style_flag && text_pos == m->s[i]->style_end) { + av_bprintf(buf, "{\\r}"); + } + } + for (i = 0; i < m->style_entries; i++) { + if (m->s[i]->style_flag && text_pos == m->s[i]->style_start) { + if (m->s[i]->style_flag & STYLE_FLAG_BOLD) + av_bprintf(buf, "{\\b1}"); + if (m->s[i]->style_flag & STYLE_FLAG_ITALIC) + av_bprintf(buf, "{\\i1}"); + if (m->s[i]->style_flag & STYLE_FLAG_UNDERLINE) + av_bprintf(buf, "{\\u1}"); + av_bprintf(buf, "{\\fs%d}", m->s[i]->fontsize); + } + } + } + if (m->box_flags & HLIT_BOX) { + if (text_pos == m->h.hlit_start) { + /* If hclr box is present, set the secondary color to the color + * specified. Otherwise, set primary color to white and secondary + * color to black. These colors will come from TextSampleModifier + * boxes in future and inverse video technique for highlight will + * be implemented. + */ + if (m->box_flags & HCLR_BOX) { + av_bprintf(buf, "{\\2c&H%02x%02x%02x&}", m->c.hlit_color[2], + m->c.hlit_color[1], m->c.hlit_color[0]); + } else { + av_bprintf(buf, "{\\1c&H000000&}{\\2c&HFFFFFF&}"); + } + } + if (text_pos == m->h.hlit_end) { + if (m->box_flags & HCLR_BOX) { + av_bprintf(buf, "{\\2c&H000000&}"); + } else { + av_bprintf(buf, "{\\1c&HFFFFFF&}{\\2c&H000000&}"); + } } } @@ -58,18 +201,8 @@ av_bprint_chars(buf, *text, 1); break; } - - for (i = 0; i < style_entries; i++) { - if (*style_flags[i] && text == style_end[i]) { - if (*style_flags[i] & STYLE_FLAG_BOLD) - av_bprintf(buf, "{\\b0}"); - if (*style_flags[i] & STYLE_FLAG_ITALIC) - av_bprintf(buf, "{\\i0}"); - if (*style_flags[i] & STYLE_FLAG_UNDERLINE) - av_bprintf(buf, "{\\u0}"); - } - } text++; + text_pos++; } return 0; @@ -89,20 +222,14 @@ void *data, int *got_sub_ptr, AVPacket *avpkt) { AVSubtitle *sub = data; + MovTextContext *m = avctx->priv_data; int ret, ts_start, ts_end; AVBPrint buf; char *ptr = avpkt->data; char *end; - //char *ptr_temp; - int text_length, tsmb_type, style_entries; - uint64_t tsmb_size, tracksize; - char **style_start = { 0, }; - char **style_end = { 0, }; - uint8_t **style_flags = { 0, }; + int text_length, tsmb_type, ret_tsmb; + uint64_t tsmb_size; const uint8_t *tsmb; - int index, i, size_var; - uint8_t *flag; - char *style_pos; if (!ptr || avpkt->size < 2) return AVERROR_INVALIDDATA; @@ -134,76 +261,49 @@ (AVRational){1,100}); tsmb_size = 0; - tracksize = 2 + text_length; + m->tracksize = 2 + text_length; + m->style_entries = 0; + m->box_flags = 0; + m->count_s = 0; // Note that the spec recommends lines be no longer than 2048 characters. av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED); if (text_length + 2 != avpkt->size) { - while (tracksize + 8 <= avpkt->size) { + while (m->tracksize + 8 <= avpkt->size) { // A box is a minimum of 8 bytes. - tsmb = ptr + tracksize - 2; + tsmb = ptr + m->tracksize - 2; tsmb_size = AV_RB32(tsmb); tsmb += 4; tsmb_type = AV_RB32(tsmb); tsmb += 4; if (tsmb_size == 1) { - if (tracksize + 16 > avpkt->size) + if (m->tracksize + 16 > avpkt->size) break; tsmb_size = AV_RB64(tsmb); tsmb += 8; - size_var = 18; + m->size_var = 16; } else - size_var = 10; - //size_var is equal to 10 or 18 depending on the size of box + m->size_var = 8; + //size_var is equal to 8 or 16 depending on the size of box - if (tracksize + tsmb_size > avpkt->size) + if (m->tracksize + tsmb_size > avpkt->size) break; - if (tsmb_type == MKBETAG('s','t','y','l')) { - if (tracksize + size_var > avpkt->size) - break; - style_entries = AV_RB16(tsmb); - tsmb += 2; - - // A single style record is of length 12 bytes. - if (tracksize + size_var + style_entries * 12 > avpkt->size) - break; - - for(i = 0; i < style_entries; i++) { - style_pos = ptr + AV_RB16(tsmb); - index = i; - av_dynarray_add(&style_start, &index, style_pos); - tsmb += 2; - style_pos = ptr + AV_RB16(tsmb); - index = i; - av_dynarray_add(&style_end, &index, style_pos); - tsmb += 2; - // fontID = AV_RB16(tsmb); - tsmb += 2; - flag = av_malloc(1); - if (!flag) - return AVERROR(ENOMEM); - *flag = AV_RB8(tsmb); - index = i; - av_dynarray_add(&style_flags, &index, flag); - //fontsize=AV_RB8(tsmb); - tsmb += 2; - // text-color-rgba - tsmb += 4; - } - text_to_ass(&buf, ptr, end, style_start, style_end, style_flags, style_entries); - - for(i = 0; i < style_entries; i++) { - av_freep(&style_flags[i]); + for (size_t i = 0; i < box_count; i++) { + if (tsmb_type == box_types[i].type) { + if (m->tracksize + m->size_var + box_types[i].base_size > avpkt->size) + break; + ret_tsmb = box_types[i].decode(tsmb, m, avpkt); + if (ret_tsmb == -1) + break; } - av_freep(&style_start); - av_freep(&style_end); - av_freep(&style_flags); } - tracksize = tracksize + tsmb_size; + m->tracksize = m->tracksize + tsmb_size; } + text_to_ass(&buf, ptr, end, m); + mov_text_cleanup(m); } else - text_to_ass(&buf, ptr, end, NULL, NULL, 0, 0); + text_to_ass(&buf, ptr, end, m); ret = ff_ass_add_rect_bprint(sub, &buf, ts_start, ts_end - ts_start); av_bprint_finalize(&buf, NULL); @@ -218,6 +318,7 @@ .long_name = NULL_IF_CONFIG_SMALL("3GPP Timed Text subtitle"), .type = AVMEDIA_TYPE_SUBTITLE, .id = AV_CODEC_ID_MOV_TEXT, + .priv_data_size = sizeof(MovTextContext), .init = mov_text_init, .decode = mov_text_decode_frame, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/movtextenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/movtextenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/movtextenc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/movtextenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -24,16 +24,130 @@ #include "libavutil/avassert.h" #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" +#include "libavutil/common.h" #include "ass_split.h" #include "ass.h" +#define STYLE_FLAG_BOLD (1<<0) +#define STYLE_FLAG_ITALIC (1<<1) +#define STYLE_FLAG_UNDERLINE (1<<2) +#define STYLE_RECORD_SIZE 12 +#define SIZE_ADD 10 + +#define STYL_BOX (1<<0) +#define HLIT_BOX (1<<1) +#define HCLR_BOX (1<<2) + +#define av_bprint_append_any(buf, data, size) av_bprint_append_data(buf, ((const char*)data), size) + +typedef struct { + uint16_t style_start; + uint16_t style_end; + uint8_t style_flag; +} StyleBox; + +typedef struct { + uint16_t start; + uint16_t end; +} HighlightBox; + +typedef struct { + uint32_t color; +} HilightcolorBox; + typedef struct { ASSSplitContext *ass_ctx; - char buffer[2048]; - char *ptr; - char *end; + AVBPrint buffer; + StyleBox **style_attributes; + StyleBox *style_attributes_temp; + HighlightBox hlit; + HilightcolorBox hclr; + int count; + uint8_t box_flags; + uint16_t style_entries; + uint16_t style_fontID; + uint8_t style_fontsize; + uint32_t style_color; + uint16_t text_pos; } MovTextContext; +typedef struct { + uint32_t type; + void (*encode)(MovTextContext *s, uint32_t tsmb_type); +} Box; + +static void mov_text_cleanup(MovTextContext *s) +{ + int j; + if (s->box_flags & STYL_BOX) { + for (j = 0; j < s->count; j++) { + av_freep(&s->style_attributes[j]); + } + av_freep(&s->style_attributes); + } +} + +static void encode_styl(MovTextContext *s, uint32_t tsmb_type) +{ + int j; + uint32_t tsmb_size; + if (s->box_flags & STYL_BOX) { + tsmb_size = s->count * STYLE_RECORD_SIZE + SIZE_ADD; + tsmb_size = AV_RB32(&tsmb_size); + s->style_entries = AV_RB16(&s->count); + s->style_fontID = 0x00 | 0x01<<8; + s->style_fontsize = 0x12; + s->style_color = MKTAG(0xFF, 0xFF, 0xFF, 0xFF); + /*The above three attributes are hard coded for now + but will come from ASS style in the future*/ + av_bprint_append_any(&s->buffer, &tsmb_size, 4); + av_bprint_append_any(&s->buffer, &tsmb_type, 4); + av_bprint_append_any(&s->buffer, &s->style_entries, 2); + for (j = 0; j < s->count; j++) { + av_bprint_append_any(&s->buffer, &s->style_attributes[j]->style_start, 2); + av_bprint_append_any(&s->buffer, &s->style_attributes[j]->style_end, 2); + av_bprint_append_any(&s->buffer, &s->style_fontID, 2); + av_bprint_append_any(&s->buffer, &s->style_attributes[j]->style_flag, 1); + av_bprint_append_any(&s->buffer, &s->style_fontsize, 1); + av_bprint_append_any(&s->buffer, &s->style_color, 4); + } + mov_text_cleanup(s); + } +} + +static void encode_hlit(MovTextContext *s, uint32_t tsmb_type) +{ + uint32_t tsmb_size; + if (s->box_flags & HLIT_BOX) { + tsmb_size = 12; + tsmb_size = AV_RB32(&tsmb_size); + av_bprint_append_any(&s->buffer, &tsmb_size, 4); + av_bprint_append_any(&s->buffer, &tsmb_type, 4); + av_bprint_append_any(&s->buffer, &s->hlit.start, 2); + av_bprint_append_any(&s->buffer, &s->hlit.end, 2); + } +} + +static void encode_hclr(MovTextContext *s, uint32_t tsmb_type) +{ + uint32_t tsmb_size; + if (s->box_flags & HCLR_BOX) { + tsmb_size = 12; + tsmb_size = AV_RB32(&tsmb_size); + av_bprint_append_any(&s->buffer, &tsmb_size, 4); + av_bprint_append_any(&s->buffer, &tsmb_type, 4); + av_bprint_append_any(&s->buffer, &s->hclr.color, 4); + } +} + +static const Box box_types[] = { + { MKTAG('s','t','y','l'), encode_styl }, + { MKTAG('h','l','i','t'), encode_hlit }, + { MKTAG('h','c','l','r'), encode_hclr }, +}; + +const static size_t box_count = FF_ARRAY_ELEMS(box_types); static av_cold int mov_text_encode_init(AVCodecContext *avctx) { @@ -75,36 +189,134 @@ MovTextContext *s = avctx->priv_data; avctx->extradata_size = sizeof text_sample_entry; - avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) return AVERROR(ENOMEM); + av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED); + memcpy(avctx->extradata, text_sample_entry, avctx->extradata_size); s->ass_ctx = ff_ass_split(avctx->subtitle_header); return s->ass_ctx ? 0 : AVERROR_INVALIDDATA; } +static void mov_text_style_cb(void *priv, const char style, int close) +{ + MovTextContext *s = priv; + if (!close) { + if (!(s->box_flags & STYL_BOX)) { //first style entry + + s->style_attributes_temp = av_malloc(sizeof(*s->style_attributes_temp)); + + if (!s->style_attributes_temp) { + av_bprint_clear(&s->buffer); + s->box_flags &= ~STYL_BOX; + return; + } + + s->style_attributes_temp->style_flag = 0; + s->style_attributes_temp->style_start = AV_RB16(&s->text_pos); + } else { + if (s->style_attributes_temp->style_flag) { //break the style record here and start a new one + s->style_attributes_temp->style_end = AV_RB16(&s->text_pos); + av_dynarray_add(&s->style_attributes, &s->count, s->style_attributes_temp); + s->style_attributes_temp = av_malloc(sizeof(*s->style_attributes_temp)); + if (!s->style_attributes_temp) { + mov_text_cleanup(s); + av_bprint_clear(&s->buffer); + s->box_flags &= ~STYL_BOX; + return; + } + + s->style_attributes_temp->style_flag = s->style_attributes[s->count - 1]->style_flag; + s->style_attributes_temp->style_start = AV_RB16(&s->text_pos); + } else { + s->style_attributes_temp->style_flag = 0; + s->style_attributes_temp->style_start = AV_RB16(&s->text_pos); + } + } + switch (style){ + case 'b': + s->style_attributes_temp->style_flag |= STYLE_FLAG_BOLD; + break; + case 'i': + s->style_attributes_temp->style_flag |= STYLE_FLAG_ITALIC; + break; + case 'u': + s->style_attributes_temp->style_flag |= STYLE_FLAG_UNDERLINE; + break; + } + } else { + s->style_attributes_temp->style_end = AV_RB16(&s->text_pos); + av_dynarray_add(&s->style_attributes, &s->count, s->style_attributes_temp); + + s->style_attributes_temp = av_malloc(sizeof(*s->style_attributes_temp)); + + if (!s->style_attributes_temp) { + mov_text_cleanup(s); + av_bprint_clear(&s->buffer); + s->box_flags &= ~STYL_BOX; + return; + } + + s->style_attributes_temp->style_flag = s->style_attributes[s->count - 1]->style_flag; + switch (style){ + case 'b': + s->style_attributes_temp->style_flag &= ~STYLE_FLAG_BOLD; + break; + case 'i': + s->style_attributes_temp->style_flag &= ~STYLE_FLAG_ITALIC; + break; + case 'u': + s->style_attributes_temp->style_flag &= ~STYLE_FLAG_UNDERLINE; + break; + } + if (s->style_attributes_temp->style_flag) { //start of new style record + s->style_attributes_temp->style_start = AV_RB16(&s->text_pos); + } + } + s->box_flags |= STYL_BOX; +} + +static void mov_text_color_cb(void *priv, unsigned int color, unsigned int color_id) +{ + MovTextContext *s = priv; + if (color_id == 2) { //secondary color changes + if (s->box_flags & HLIT_BOX) { //close tag + s->hlit.end = AV_RB16(&s->text_pos); + } else { + s->box_flags |= HCLR_BOX; + s->box_flags |= HLIT_BOX; + s->hlit.start = AV_RB16(&s->text_pos); + s->hclr.color = color | (0xFF << 24); //set alpha value to FF + } + } + /* If there are more than one secondary color changes in ASS, take start of + first section and end of last section. Movtext allows only one + highlight box per sample. + */ +} + static void mov_text_text_cb(void *priv, const char *text, int len) { MovTextContext *s = priv; - av_assert0(s->end >= s->ptr); - av_strlcpy(s->ptr, text, FFMIN(s->end - s->ptr, len + 1)); - s->ptr += FFMIN(s->end - s->ptr, len); + av_bprint_append_data(&s->buffer, text, len); + s->text_pos += len; } static void mov_text_new_line_cb(void *priv, int forced) { MovTextContext *s = priv; - av_assert0(s->end >= s->ptr); - av_strlcpy(s->ptr, "\n", FFMIN(s->end - s->ptr, 2)); - if (s->end > s->ptr) - s->ptr++; + av_bprint_append_data(&s->buffer, "\n", 1); + s->text_pos += 1; } static const ASSCodesCallbacks mov_text_callbacks = { .text = mov_text_text_cb, .new_line = mov_text_new_line_cb, + .style = mov_text_style_cb, + .color = mov_text_color_cb, }; static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf, @@ -112,11 +324,13 @@ { MovTextContext *s = avctx->priv_data; ASSDialog *dialog; - int i, len, num; - - s->ptr = s->buffer; - s->end = s->ptr + sizeof(s->buffer); + int i, num, length; + size_t j; + s->text_pos = 0; + s->count = 0; + s->box_flags = 0; + s->style_entries = 0; for (i = 0; i < sub->num_rects; i++) { if (sub->rects[i]->type != SUBTITLE_ASS) { @@ -128,28 +342,44 @@ for (; dialog && num--; dialog++) { ff_ass_split_override_codes(&mov_text_callbacks, s, dialog->text); } - } - if (s->ptr == s->buffer) - return 0; + for (j = 0; j < box_count; j++) { + box_types[j].encode(s, box_types[j].type); + } + } - AV_WB16(buf, strlen(s->buffer)); + AV_WB16(buf, s->text_pos); buf += 2; - len = av_strlcpy(buf, s->buffer, bufsize - 2); + if (!av_bprint_is_complete(&s->buffer)) { + length = AVERROR(ENOMEM); + goto exit; + } - if (len > bufsize-3) { + if (!s->buffer.len) { + length = 0; + goto exit; + } + + if (s->buffer.len > bufsize - 3) { av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n"); - return AVERROR(EINVAL); + length = AVERROR(EINVAL); + goto exit; } - return len + 2; + memcpy(buf, s->buffer.str, s->buffer.len); + length = s->buffer.len + 2; + +exit: + av_bprint_clear(&s->buffer); + return length; } static int mov_text_encode_close(AVCodecContext *avctx) { MovTextContext *s = avctx->priv_data; ff_ass_split_free(s->ass_ctx); + av_bprint_finalize(&s->buffer, NULL); return 0; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mp3_header_decompress_bsf.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mp3_header_decompress_bsf.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mp3_header_decompress_bsf.c 2015-06-18 18:54:58.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mp3_header_decompress_bsf.c 2015-07-28 17:20:07.000000000 +0000 @@ -71,8 +71,8 @@ header |= (frame_size == buf_size + 4)<<16; //FIXME actually set a correct crc instead of 0 *poutbuf_size= frame_size; - *poutbuf= av_malloc(frame_size + FF_INPUT_BUFFER_PADDING_SIZE); - memcpy(*poutbuf + frame_size - buf_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + *poutbuf= av_malloc(frame_size + AV_INPUT_BUFFER_PADDING_SIZE); + memcpy(*poutbuf + frame_size - buf_size, buf, buf_size + AV_INPUT_BUFFER_PADDING_SIZE); if(avctx->channels==2){ uint8_t *p= *poutbuf + frame_size - buf_size; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpc7.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpc7.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpc7.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpc7.c 2015-07-28 17:20:07.000000000 +0000 @@ -337,7 +337,7 @@ .close = mpc7_decode_close, .decode = mpc7_decode_frame, .flush = mpc7_decode_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpc8.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpc8.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpc8.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpc8.c 2015-07-28 17:20:07.000000000 +0000 @@ -440,7 +440,7 @@ .init = mpc8_decode_init, .decode = mpc8_decode_frame, .flush = mpc8_decode_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg12dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg12dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg12dec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg12dec.c 2015-08-03 17:20:02.000000000 +0000 @@ -844,7 +844,7 @@ ff_xvmc_pack_pblocks(s, -1); // inter are always full blocks if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { - if (s->avctx->flags2 & CODEC_FLAG2_FAST) { + if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) { for (i = 0; i < 6; i++) mpeg2_fast_decode_block_intra(s, *s->pblocks[i], i); } else { @@ -1064,7 +1064,7 @@ ff_xvmc_pack_pblocks(s, cbp); if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { - if (s->avctx->flags2 & CODEC_FLAG2_FAST) { + if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) { for (i = 0; i < 6; i++) { if (cbp & 32) mpeg2_fast_decode_block_non_intra(s, *s->pblocks[i], i); @@ -1086,7 +1086,7 @@ } } } else { - if (s->avctx->flags2 & CODEC_FLAG2_FAST) { + if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) { for (i = 0; i < 6; i++) { if (cbp & 32) mpeg1_fast_decode_block_inter(s, *s->pblocks[i], i); @@ -1211,6 +1211,9 @@ #if CONFIG_MPEG2_VAAPI_HWACCEL AV_PIX_FMT_VAAPI_VLD, #endif +#if CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL + AV_PIX_FMT_VIDEOTOOLBOX, +#endif AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }; @@ -1235,7 +1238,7 @@ MpegEncContext *s = &s1->mpeg_enc_ctx; const enum AVPixelFormat *pix_fmts; - if (CONFIG_GRAY && (avctx->flags & CODEC_FLAG_GRAY)) + if (CONFIG_GRAY && (avctx->flags & AV_CODEC_FLAG_GRAY)) return AV_PIX_FMT_GRAY8; if (s->chroma_format < 2) @@ -1473,7 +1476,7 @@ s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10; s->low_delay = get_bits1(&s->gb); - if (s->avctx->flags & CODEC_FLAG_LOW_DELAY) + if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) s->low_delay = 1; s1->frame_rate_ext.num = get_bits(&s->gb, 2) + 1; @@ -1685,6 +1688,7 @@ if (sd) memcpy(sd->data, s1->a53_caption, s1->a53_caption_size); av_freep(&s1->a53_caption); + avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; } if (s1->has_stereo3d) { @@ -1938,7 +1942,6 @@ // area, we detect this here instead of running into the end expecting // more data if (s->mb_y >= ((s->height + 15) >> 4) && - s->progressive_frame && !s->progressive_sequence && get_bits_left(&s->gb) <= 8 && get_bits_left(&s->gb) >= 0 && @@ -2196,7 +2199,7 @@ s->avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO; s->out_format = FMT_MPEG1; s->swap_uv = 0; // AFAIK VCR2 does not have SEQ_HEADER - if (s->avctx->flags & CODEC_FLAG_LOW_DELAY) + if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) s->low_delay = 1; if (s->avctx->debug & FF_DEBUG_PICT_INFO) @@ -2649,7 +2652,7 @@ } } } - if (s2->pict_type == AV_PICTURE_TYPE_I || (s2->avctx->flags2 & CODEC_FLAG2_SHOW_ALL)) + if (s2->pict_type == AV_PICTURE_TYPE_I || (s2->avctx->flags2 & AV_CODEC_FLAG2_SHOW_ALL)) s->sync = 1; if (!s2->next_picture_ptr) { /* Skip P-frames if we do not have a reference frame or @@ -2770,7 +2773,7 @@ return buf_size; } - if (s2->avctx->flags & CODEC_FLAG_TRUNCATED) { + if (s2->avctx->flags & AV_CODEC_FLAG_TRUNCATED) { int next = ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size, NULL); @@ -2848,9 +2851,9 @@ .init = mpeg_decode_init, .close = mpeg_decode_end, .decode = mpeg_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | - CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | - CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SLICE_THREADS, .flush = flush, .max_lowres = 3, .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context) @@ -2865,9 +2868,9 @@ .init = mpeg_decode_init, .close = mpeg_decode_end, .decode = mpeg_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | - CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | - CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SLICE_THREADS, .flush = flush, .max_lowres = 3, .profiles = NULL_IF_CONFIG_SMALL(mpeg2_video_profiles), @@ -2883,7 +2886,7 @@ .init = mpeg_decode_init, .close = mpeg_decode_end, .decode = mpeg_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, .flush = flush, .max_lowres = 3, }; @@ -2916,8 +2919,9 @@ .init = mpeg_mc_decode_init, .close = mpeg_decode_end, .decode = mpeg_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | - CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL | + AV_CODEC_CAP_DELAY, .flush = flush, }; @@ -2934,8 +2938,8 @@ .init = mpeg_decode_init, .close = mpeg_decode_end, .decode = mpeg_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | - CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | + AV_CODEC_CAP_HWACCEL_VDPAU | AV_CODEC_CAP_DELAY, .flush = flush, }; #endif @@ -2950,8 +2954,8 @@ .init = mpeg_decode_init, .close = mpeg_decode_end, .decode = mpeg_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | - CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | + AV_CODEC_CAP_HWACCEL_VDPAU | AV_CODEC_CAP_DELAY, .flush = flush, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg12enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg12enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg12enc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg12enc.c 2015-07-30 17:20:02.000000000 +0000 @@ -42,9 +42,10 @@ #include "mpegutils.h" #include "mpegvideo.h" - -static const uint8_t inv_non_linear_qscale[] = { +static const int8_t inv_non_linear_qscale[] = { 0, 2, 4, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, + -1,17,-1,18,-1,19, -1, 20, -1, 21, -1, 22, -1, + 23,-1,24,-1,-1,-1 }; static const uint8_t svcd_scan_offset_placeholder[] = { @@ -205,7 +206,7 @@ } } - s->drop_frame_timecode = s->drop_frame_timecode || !!(avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE); + s->drop_frame_timecode = s->drop_frame_timecode || !!(avctx->flags2 & AV_CODEC_FLAG2_DROP_FRAME_TIMECODE); if (s->drop_frame_timecode) s->tc.flags |= AV_TIMECODE_FLAG_DROPFRAME; if (s->drop_frame_timecode && s->frame_rate_index != 4) { @@ -384,7 +385,7 @@ put_bits(&s->pb, 1, 1); put_bits(&s->pb, 6, (uint32_t)((time_code / fps) % 60)); put_bits(&s->pb, 6, (uint32_t)((time_code % fps))); - put_bits(&s->pb, 1, !!(s->avctx->flags & CODEC_FLAG_CLOSED_GOP) || s->intra_only || !s->gop_picture_number); + put_bits(&s->pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) || s->intra_only || !s->gop_picture_number); put_bits(&s->pb, 1, 0); // broken link } } @@ -402,8 +403,9 @@ static av_always_inline void put_qscale(MpegEncContext *s) { if (s->q_scale_type) { - av_assert2(s->qscale >= 1 && s->qscale <= 12); - put_bits(&s->pb, 5, inv_non_linear_qscale[s->qscale]); + int qp = inv_non_linear_qscale[s->qscale]; + av_assert2(s->qscale >= 1 && qp > 0); + put_bits(&s->pb, 5, qp); } else { put_bits(&s->pb, 5, s->qscale); } @@ -1155,7 +1157,7 @@ .supported_framerates = ff_mpeg12_frame_rate_tab + 1, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, .priv_class = &mpeg1_class, }; @@ -1172,6 +1174,6 @@ .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE }, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, .priv_class = &mpeg2_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg12.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg12.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg12.h 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg12.h 2015-06-13 17:20:02.000000000 +0000 @@ -22,29 +22,12 @@ #ifndef AVCODEC_MPEG12_H #define AVCODEC_MPEG12_H +#include "mpeg12vlc.h" #include "mpegvideo.h" -#define DC_VLC_BITS 9 -#define MV_VLC_BITS 9 -#define TEX_VLC_BITS 9 - -#define MBINCR_VLC_BITS 9 -#define MB_PAT_VLC_BITS 9 -#define MB_PTYPE_VLC_BITS 6 -#define MB_BTYPE_VLC_BITS 6 - -extern VLC ff_dc_lum_vlc; -extern VLC ff_dc_chroma_vlc; -extern VLC ff_mbincr_vlc; -extern VLC ff_mb_ptype_vlc; -extern VLC ff_mb_btype_vlc; -extern VLC ff_mb_pat_vlc; -extern VLC ff_mv_vlc; - extern uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3]; void ff_mpeg12_common_init(MpegEncContext *s); -void ff_mpeg12_init_vlcs(void); static inline int decode_dc(GetBitContext *gb, int component) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg12vlc.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg12vlc.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg12vlc.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg12vlc.h 2015-06-13 17:20:02.000000000 +0000 @@ -0,0 +1,52 @@ +/* + * MPEG1/2 VLC + * copyright (c) 2000,2001 Fabrice Bellard + * copyright (c) 2002-2004 Michael Niedermayer + * + * 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 + */ + +/** + * @file + * MPEG1/2 VLC. + */ + +#ifndef AVCODEC_MPEG12VLC_H +#define AVCODEC_MPEG12VLC_H + +#include "get_bits.h" + +#define DC_VLC_BITS 9 +#define MV_VLC_BITS 9 +#define TEX_VLC_BITS 9 + +#define MBINCR_VLC_BITS 9 +#define MB_PAT_VLC_BITS 9 +#define MB_PTYPE_VLC_BITS 6 +#define MB_BTYPE_VLC_BITS 6 + +extern VLC ff_dc_lum_vlc; +extern VLC ff_dc_chroma_vlc; +extern VLC ff_mbincr_vlc; +extern VLC ff_mb_ptype_vlc; +extern VLC ff_mb_btype_vlc; +extern VLC ff_mb_pat_vlc; +extern VLC ff_mv_vlc; + +void ff_mpeg12_init_vlcs(void); + +#endif /* AVCODEC_MPEG12VLC_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg4_unpack_bframes_bsf.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg4_unpack_bframes_bsf.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg4_unpack_bframes_bsf.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg4_unpack_bframes_bsf.c 2015-07-28 17:20:07.000000000 +0000 @@ -73,11 +73,11 @@ /* allocate new buffer and copy size bytes from src */ static uint8_t *create_new_buffer(const uint8_t *src, int size) { - uint8_t *dst = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); + uint8_t *dst = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE); if (dst) { memcpy(dst, src, size); - memset(dst + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(dst + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); } return dst; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg4videodec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg4videodec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg4videodec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg4videodec.c 2015-07-28 17:20:07.000000000 +0000 @@ -1298,7 +1298,7 @@ Mpeg4DecContext *ctx = (Mpeg4DecContext *)s; int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant; int16_t *mot_val; - static int8_t quant_tab[4] = { -1, -2, 1, 2 }; + static const int8_t quant_tab[4] = { -1, -2, 1, 2 }; const int xy = s->mb_x + s->mb_y * s->mb_stride; av_assert2(s->h263_pred); @@ -1354,6 +1354,11 @@ else s->mcsel = 0; cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1) ^ 0x0F; + if (cbpy < 0) { + av_log(s->avctx, AV_LOG_ERROR, + "P cbpy damaged at %d %d\n", s->mb_x, s->mb_y); + return AVERROR_INVALIDDATA; + } cbp = (cbpc & 3) | (cbpy << 2); if (dquant) @@ -2223,7 +2228,7 @@ s->pict_type = get_bits(gb, 2) + AV_PICTURE_TYPE_I; /* pict type: I = 0 , P = 1 */ if (s->pict_type == AV_PICTURE_TYPE_B && s->low_delay && - ctx->vol_control_parameters == 0 && !(s->avctx->flags & CODEC_FLAG_LOW_DELAY)) { + ctx->vol_control_parameters == 0 && !(s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY)) { av_log(s->avctx, AV_LOG_ERROR, "low_delay flag set incorrectly, clearing it\n"); s->low_delay = 0; } @@ -2602,7 +2607,7 @@ } end: - if (s->avctx->flags & CODEC_FLAG_LOW_DELAY) + if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) s->low_delay = 1; s->avctx->has_b_frames = !s->low_delay; @@ -2665,7 +2670,7 @@ if (!ctx->showed_packed_warning) { av_log(s->avctx, AV_LOG_INFO, "Video uses a non-standard and " "wasteful way to store B-frames ('packed B-frames'). " - "Consider using the mpeg4_unpack_bframes bitstream filter to fix it.\n"); + "Consider using the mpeg4_unpack_bframes bitstream filter without encoding but stream copy to fix it.\n"); ctx->showed_packed_warning = 1; } av_fast_padded_malloc(&s->bitstream_buffer, @@ -2773,9 +2778,9 @@ .init = decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | - CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | - CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_FRAME_THREADS, .flush = ff_mpeg_flush, .max_lowres = 3, .pix_fmts = ff_h263_hwaccel_pixfmt_list_420, @@ -2802,8 +2807,8 @@ .init = decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | - CODEC_CAP_HWACCEL_VDPAU, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_HWACCEL_VDPAU, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_VDPAU_MPEG4, AV_PIX_FMT_NONE }, .priv_class = &mpeg4_vdpau_class, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg4videoenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg4videoenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg4videoenc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg4videoenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -430,7 +430,7 @@ int i; if (scan_table) { - if (s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT) { + if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) { for (i = 0; i < 6; i++) skip_put_bits(&s->pb, mpeg4_get_block_length(s, block[i], i, @@ -442,7 +442,7 @@ intra_dc[i], scan_table[i], dc_pb, ac_pb); } } else { - if (s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT) { + if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) { for (i = 0; i < 6; i++) skip_put_bits(&s->pb, mpeg4_get_block_length(s, block[i], i, 0, @@ -507,7 +507,7 @@ PutBitContext *const pb2 = s->data_partitioning ? &s->pb2 : &s->pb; PutBitContext *const tex_pb = s->data_partitioning && s->pict_type != AV_PICTURE_TYPE_B ? &s->tex_pb : &s->pb; PutBitContext *const dc_pb = s->data_partitioning && s->pict_type != AV_PICTURE_TYPE_I ? &s->pb2 : &s->pb; - const int interleaved_stats = (s->avctx->flags & CODEC_FLAG_PASS1) && !s->data_partitioning ? 1 : 0; + const int interleaved_stats = (s->avctx->flags & AV_CODEC_FLAG_PASS1) && !s->data_partitioning ? 1 : 0; if (!s->mb_intra) { int i, cbp; @@ -832,7 +832,7 @@ for (i = 0; i < 6; i++) dc_diff[i] = ff_mpeg4_pred_dc(s, i, block[i][0], &dir[i], 1); - if (s->avctx->flags & CODEC_FLAG_AC_PRED) { + if (s->avctx->flags & AV_CODEC_FLAG_AC_PRED) { s->ac_pred = decide_ac_pred(s, block, dir, scan_table, zigzag_last_index); } else { for (i = 0; i < 6; i++) @@ -932,7 +932,7 @@ put_bits(&s->pb, 1, 1); put_bits(&s->pb, 6, seconds); - put_bits(&s->pb, 1, !!(s->avctx->flags & CODEC_FLAG_CLOSED_GOP)); + put_bits(&s->pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)); put_bits(&s->pb, 1, 0); // broken link == NO ff_mpeg4_stuffing(&s->pb); @@ -1078,7 +1078,7 @@ ff_mpeg4_stuffing(&s->pb); /* user data */ - if (!(s->avctx->flags & CODEC_FLAG_BITEXACT)) { + if (!(s->avctx->flags & AV_CODEC_FLAG_BITEXACT)) { put_bits(&s->pb, 16, 0); put_bits(&s->pb, 16, 0x1B2); /* user_data */ avpriv_put_string(&s->pb, LIBAVCODEC_IDENT, 0); @@ -1092,7 +1092,7 @@ int time_div, time_mod; if (s->pict_type == AV_PICTURE_TYPE_I) { - if (!(s->avctx->flags & CODEC_FLAG_GLOBAL_HEADER)) { + if (!(s->avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) { if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT) // HACK, the reference sw is buggy mpeg4_encode_visual_object_header(s); if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || picture_number == 0) // HACK, the reference sw is buggy @@ -1325,7 +1325,7 @@ s->y_dc_scale_table = ff_mpeg4_y_dc_scale_table; s->c_dc_scale_table = ff_mpeg4_c_dc_scale_table; - if (s->avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { + if (s->avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { s->avctx->extradata = av_malloc(1024); init_put_bits(&s->pb, s->avctx->extradata, 1024); @@ -1417,6 +1417,6 @@ .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, .priv_class = &mpeg4enc_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegaudiodec_fixed.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegaudiodec_fixed.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegaudiodec_fixed.c 2015-06-18 18:54:58.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegaudiodec_fixed.c 2015-07-28 17:20:07.000000000 +0000 @@ -47,7 +47,7 @@ .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = flush, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, @@ -63,7 +63,7 @@ .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = flush, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, @@ -79,7 +79,7 @@ .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = flush, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, @@ -95,7 +95,7 @@ .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame_adu, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = flush, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, @@ -112,7 +112,7 @@ .init = decode_init_mp3on4, .close = decode_close_mp3on4, .decode = decode_frame_mp3on4, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = flush_mp3on4, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegaudiodec_float.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegaudiodec_float.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegaudiodec_float.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegaudiodec_float.c 2015-07-28 17:20:07.000000000 +0000 @@ -48,7 +48,7 @@ .init = decode_init, .close = decode_close, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = flush, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT, @@ -65,7 +65,7 @@ .init = decode_init, .decode = decode_frame, .close = decode_close, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = flush, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT, @@ -82,7 +82,7 @@ .init = decode_init, .close = decode_close, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = flush, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT, @@ -99,7 +99,7 @@ .init = decode_init, .close = decode_close, .decode = decode_frame_adu, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = flush, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT, @@ -116,7 +116,7 @@ .init = decode_init_mp3on4, .close = decode_close_mp3on4, .decode = decode_frame_mp3on4, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = flush_mp3on4, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegaudiodec_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegaudiodec_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegaudiodec_template.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegaudiodec_template.c 2015-07-28 17:20:07.000000000 +0000 @@ -429,7 +429,7 @@ s->avctx = avctx; #if USE_FLOATS - s->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!s->fdsp) return AVERROR(ENOMEM); #endif @@ -1686,7 +1686,7 @@ if (!avctx->bit_rate) avctx->bit_rate = s->bit_rate; - if (s->frame_size <= 0 || s->frame_size > buf_size) { + if (s->frame_size <= 0) { av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); return AVERROR_INVALIDDATA; } else if (s->frame_size < buf_size) { @@ -1893,6 +1893,7 @@ s->mp3decctx[i]->adu_mode = 1; s->mp3decctx[i]->avctx = avctx; s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp; + s->mp3decctx[i]->fdsp = s->mp3decctx[0]->fdsp; } return 0; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegaudioenc_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegaudioenc_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegaudioenc_template.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegaudioenc_template.c 2015-07-28 17:20:07.000000000 +0000 @@ -763,7 +763,7 @@ } compute_bit_allocation(s, smr, bit_alloc, &padding); - if ((ret = ff_alloc_packet2(avctx, avpkt, MPA_MAX_CODED_FRAME_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, MPA_MAX_CODED_FRAME_SIZE, 0)) < 0) return ret; init_put_bits(&s->pb, avpkt->data, avpkt->size); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegaudio_parser.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegaudio_parser.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegaudio_parser.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegaudio_parser.c 2015-06-24 17:20:02.000000000 +0000 @@ -23,7 +23,7 @@ #include "parser.h" #include "mpegaudiodecheader.h" #include "libavutil/common.h" - +#include "libavformat/id3v1.h" // for ID3v1_TAG_SIZE typedef struct MpegAudioParseContext { ParseContext pc; @@ -49,6 +49,7 @@ uint32_t state= pc->state; int i; int next= END_NOT_FOUND; + int flush = !buf_size; for(i=0; iframe_size){ @@ -113,6 +114,12 @@ return buf_size; } + if (flush && buf_size >= ID3v1_TAG_SIZE && memcmp(buf, "TAG", 3) == 0) { + *poutbuf = NULL; + *poutbuf_size = 0; + return next; + } + *poutbuf = buf; *poutbuf_size = buf_size; return next; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg_er.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg_er.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg_er.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg_er.c 2015-06-13 17:20:02.000000000 +0000 @@ -58,3 +58,74 @@ ff_er_frame_start(er); } + +static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, + int (*mv)[2][4][2], int mb_x, int mb_y, + int mb_intra, int mb_skipped) +{ + MpegEncContext *s = opaque; + + s->mv_dir = mv_dir; + s->mv_type = mv_type; + s->mb_intra = mb_intra; + s->mb_skipped = mb_skipped; + s->mb_x = mb_x; + s->mb_y = mb_y; + memcpy(s->mv, mv, sizeof(*mv)); + + ff_init_block_index(s); + ff_update_block_index(s); + + s->bdsp.clear_blocks(s->block[0]); + + s->dest[0] = s->current_picture.f->data[0] + + s->mb_y * 16 * s->linesize + + s->mb_x * 16; + s->dest[1] = s->current_picture.f->data[1] + + s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize + + s->mb_x * (16 >> s->chroma_x_shift); + s->dest[2] = s->current_picture.f->data[2] + + s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize + + s->mb_x * (16 >> s->chroma_x_shift); + + if (ref) + av_log(s->avctx, AV_LOG_DEBUG, + "Interlaced error concealment is not fully implemented\n"); + ff_mpv_decode_mb(s, s->block); +} + +int ff_mpeg_er_init(MpegEncContext *s) +{ + ERContext *er = &s->er; + int mb_array_size = s->mb_height * s->mb_stride; + int i; + + er->avctx = s->avctx; + + er->mb_index2xy = s->mb_index2xy; + er->mb_num = s->mb_num; + er->mb_width = s->mb_width; + er->mb_height = s->mb_height; + er->mb_stride = s->mb_stride; + er->b8_stride = s->b8_stride; + + er->er_temp_buffer = av_malloc(s->mb_height * s->mb_stride); + er->error_status_table = av_mallocz(mb_array_size); + if (!er->er_temp_buffer || !er->error_status_table) + goto fail; + + er->mbskip_table = s->mbskip_table; + er->mbintra_table = s->mbintra_table; + + for (i = 0; i < FF_ARRAY_ELEMS(s->dc_val); i++) + er->dc_val[i] = s->dc_val[i]; + + er->decode_mb = mpeg_er_decode_mb; + er->opaque = s; + + return 0; +fail: + av_freep(&er->er_temp_buffer); + av_freep(&er->error_status_table); + return AVERROR(ENOMEM); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg_er.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg_er.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpeg_er.h 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpeg_er.h 2015-06-13 17:20:02.000000000 +0000 @@ -21,6 +21,7 @@ #include "mpegvideo.h" +int ff_mpeg_er_init(MpegEncContext *s); void ff_mpeg_er_frame_start(MpegEncContext *s); #endif /* AVCODEC_MPEG_ER_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegpicture.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegpicture.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegpicture.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegpicture.c 2015-07-28 17:20:07.000000000 +0000 @@ -0,0 +1,466 @@ +/* + * Mpeg video formats-related picture management functions + * + * 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 + +#include "libavutil/avassert.h" +#include "libavutil/common.h" + +#include "avcodec.h" +#include "motion_est.h" +#include "mpegpicture.h" +#include "mpegutils.h" + +static int make_tables_writable(Picture *pic) +{ + int ret, i; +#define MAKE_WRITABLE(table) \ +do {\ + if (pic->table &&\ + (ret = av_buffer_make_writable(&pic->table)) < 0)\ + return ret;\ +} while (0) + + MAKE_WRITABLE(mb_var_buf); + MAKE_WRITABLE(mc_mb_var_buf); + MAKE_WRITABLE(mb_mean_buf); + MAKE_WRITABLE(mbskip_table_buf); + MAKE_WRITABLE(qscale_table_buf); + MAKE_WRITABLE(mb_type_buf); + + for (i = 0; i < 2; i++) { + MAKE_WRITABLE(motion_val_buf[i]); + MAKE_WRITABLE(ref_index_buf[i]); + } + + return 0; +} + +int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, + ScratchpadContext *sc, int linesize) +{ + int alloc_size = FFALIGN(FFABS(linesize) + 64, 32); + + if (avctx->hwaccel || avctx->codec->capabilities & AV_CODEC_CAP_HWACCEL_VDPAU) + return 0; + + if (linesize < 24) { + av_log(avctx, AV_LOG_ERROR, "Image too small, temporary buffers cannot function\n"); + return AVERROR_PATCHWELCOME; + } + + // edge emu needs blocksize + filter length - 1 + // (= 17x17 for halfpel / 21x21 for h264) + // VC1 computes luma and chroma simultaneously and needs 19X19 + 9x9 + // at uvlinesize. It supports only YUV420 so 24x24 is enough + // linesize * interlaced * MBsize + // we also use this buffer for encoding in encode_mb_internal() needig an additional 32 lines + FF_ALLOCZ_ARRAY_OR_GOTO(avctx, sc->edge_emu_buffer, alloc_size, 4 * 68, + fail); + + FF_ALLOCZ_ARRAY_OR_GOTO(avctx, me->scratchpad, alloc_size, 4 * 16 * 2, + fail) + me->temp = me->scratchpad; + sc->rd_scratchpad = me->scratchpad; + sc->b_scratchpad = me->scratchpad; + sc->obmc_scratchpad = me->scratchpad + 16; + + return 0; +fail: + av_freep(&sc->edge_emu_buffer); + return AVERROR(ENOMEM); +} + +/** + * Allocate a frame buffer + */ +static int alloc_frame_buffer(AVCodecContext *avctx, Picture *pic, + MotionEstContext *me, ScratchpadContext *sc, + int chroma_x_shift, int chroma_y_shift, + int linesize, int uvlinesize) +{ + int edges_needed = av_codec_is_encoder(avctx->codec); + int r, ret; + + pic->tf.f = pic->f; + if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE && + avctx->codec_id != AV_CODEC_ID_VC1IMAGE && + avctx->codec_id != AV_CODEC_ID_MSS2) { + if (edges_needed) { + pic->f->width = avctx->width + 2 * EDGE_WIDTH; + pic->f->height = avctx->height + 2 * EDGE_WIDTH; + } + + r = ff_thread_get_buffer(avctx, &pic->tf, + pic->reference ? AV_GET_BUFFER_FLAG_REF : 0); + } else { + pic->f->width = avctx->width; + pic->f->height = avctx->height; + pic->f->format = avctx->pix_fmt; + r = avcodec_default_get_buffer2(avctx, pic->f, 0); + } + + if (r < 0 || !pic->f->buf[0]) { + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed (%d %p)\n", + r, pic->f->data[0]); + return -1; + } + + if (edges_needed) { + int i; + for (i = 0; pic->f->data[i]; i++) { + int offset = (EDGE_WIDTH >> (i ? chroma_y_shift : 0)) * + pic->f->linesize[i] + + (EDGE_WIDTH >> (i ? chroma_x_shift : 0)); + pic->f->data[i] += offset; + } + pic->f->width = avctx->width; + pic->f->height = avctx->height; + } + + if (avctx->hwaccel) { + assert(!pic->hwaccel_picture_private); + if (avctx->hwaccel->frame_priv_data_size) { + pic->hwaccel_priv_buf = av_buffer_allocz(avctx->hwaccel->frame_priv_data_size); + if (!pic->hwaccel_priv_buf) { + av_log(avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n"); + return -1; + } + pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data; + } + } + + if (linesize && (linesize != pic->f->linesize[0] || + uvlinesize != pic->f->linesize[1])) { + av_log(avctx, AV_LOG_ERROR, + "get_buffer() failed (stride changed)\n"); + ff_mpeg_unref_picture(avctx, pic); + return -1; + } + + if (pic->f->linesize[1] != pic->f->linesize[2]) { + av_log(avctx, AV_LOG_ERROR, + "get_buffer() failed (uv stride mismatch)\n"); + ff_mpeg_unref_picture(avctx, pic); + return -1; + } + + if (!sc->edge_emu_buffer && + (ret = ff_mpeg_framesize_alloc(avctx, me, sc, + pic->f->linesize[0])) < 0) { + av_log(avctx, AV_LOG_ERROR, + "get_buffer() failed to allocate context scratch buffers.\n"); + ff_mpeg_unref_picture(avctx, pic); + return ret; + } + + return 0; +} + +static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encoding, int out_format, + int mb_stride, int mb_width, int mb_height, int b8_stride) +{ + const int big_mb_num = mb_stride * (mb_height + 1) + 1; + const int mb_array_size = mb_stride * mb_height; + const int b8_array_size = b8_stride * mb_height * 2; + int i; + + + pic->mbskip_table_buf = av_buffer_allocz(mb_array_size + 2); + pic->qscale_table_buf = av_buffer_allocz(big_mb_num + mb_stride); + pic->mb_type_buf = av_buffer_allocz((big_mb_num + mb_stride) * + sizeof(uint32_t)); + if (!pic->mbskip_table_buf || !pic->qscale_table_buf || !pic->mb_type_buf) + return AVERROR(ENOMEM); + + if (encoding) { + pic->mb_var_buf = av_buffer_allocz(mb_array_size * sizeof(int16_t)); + pic->mc_mb_var_buf = av_buffer_allocz(mb_array_size * sizeof(int16_t)); + pic->mb_mean_buf = av_buffer_allocz(mb_array_size); + if (!pic->mb_var_buf || !pic->mc_mb_var_buf || !pic->mb_mean_buf) + return AVERROR(ENOMEM); + } + + if (out_format == FMT_H263 || encoding || avctx->debug_mv || + (avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MVS)) { + int mv_size = 2 * (b8_array_size + 4) * sizeof(int16_t); + int ref_index_size = 4 * mb_array_size; + + for (i = 0; mv_size && i < 2; i++) { + pic->motion_val_buf[i] = av_buffer_allocz(mv_size); + pic->ref_index_buf[i] = av_buffer_allocz(ref_index_size); + if (!pic->motion_val_buf[i] || !pic->ref_index_buf[i]) + return AVERROR(ENOMEM); + } + } + + pic->alloc_mb_width = mb_width; + pic->alloc_mb_height = mb_height; + + return 0; +} + +/** + * Allocate a Picture. + * The pixels are allocated/set by calling get_buffer() if shared = 0 + */ +int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me, + ScratchpadContext *sc, int shared, int encoding, + int chroma_x_shift, int chroma_y_shift, int out_format, + int mb_stride, int mb_width, int mb_height, int b8_stride, + ptrdiff_t *linesize, ptrdiff_t *uvlinesize) +{ + int i, ret; + + if (pic->qscale_table_buf) + if ( pic->alloc_mb_width != mb_width + || pic->alloc_mb_height != mb_height) + ff_free_picture_tables(pic); + + if (shared) { + av_assert0(pic->f->data[0]); + pic->shared = 1; + } else { + av_assert0(!pic->f->buf[0]); + if (alloc_frame_buffer(avctx, pic, me, sc, + chroma_x_shift, chroma_y_shift, + *linesize, *uvlinesize) < 0) + return -1; + + *linesize = pic->f->linesize[0]; + *uvlinesize = pic->f->linesize[1]; + } + + if (!pic->qscale_table_buf) + ret = alloc_picture_tables(avctx, pic, encoding, out_format, + mb_stride, mb_width, mb_height, b8_stride); + else + ret = make_tables_writable(pic); + if (ret < 0) + goto fail; + + if (encoding) { + pic->mb_var = (uint16_t*)pic->mb_var_buf->data; + pic->mc_mb_var = (uint16_t*)pic->mc_mb_var_buf->data; + pic->mb_mean = pic->mb_mean_buf->data; + } + + pic->mbskip_table = pic->mbskip_table_buf->data; + pic->qscale_table = pic->qscale_table_buf->data + 2 * mb_stride + 1; + pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * mb_stride + 1; + + if (pic->motion_val_buf[0]) { + for (i = 0; i < 2; i++) { + pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4; + pic->ref_index[i] = pic->ref_index_buf[i]->data; + } + } + + return 0; +fail: + av_log(avctx, AV_LOG_ERROR, "Error allocating a picture.\n"); + ff_mpeg_unref_picture(avctx, pic); + ff_free_picture_tables(pic); + return AVERROR(ENOMEM); +} + +/** + * Deallocate a picture. + */ +void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic) +{ + int off = offsetof(Picture, mb_mean) + sizeof(pic->mb_mean); + + pic->tf.f = pic->f; + /* WM Image / Screen codecs allocate internal buffers with different + * dimensions / colorspaces; ignore user-defined callbacks for these. */ + if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE && + avctx->codec_id != AV_CODEC_ID_VC1IMAGE && + avctx->codec_id != AV_CODEC_ID_MSS2) + ff_thread_release_buffer(avctx, &pic->tf); + else if (pic->f) + av_frame_unref(pic->f); + + av_buffer_unref(&pic->hwaccel_priv_buf); + + if (pic->needs_realloc) + ff_free_picture_tables(pic); + + memset((uint8_t*)pic + off, 0, sizeof(*pic) - off); +} + +int ff_update_picture_tables(Picture *dst, Picture *src) +{ + int i; + +#define UPDATE_TABLE(table) \ +do { \ + if (src->table && \ + (!dst->table || dst->table->buffer != src->table->buffer)) { \ + av_buffer_unref(&dst->table); \ + dst->table = av_buffer_ref(src->table); \ + if (!dst->table) { \ + ff_free_picture_tables(dst); \ + return AVERROR(ENOMEM); \ + } \ + } \ +} while (0) + + UPDATE_TABLE(mb_var_buf); + UPDATE_TABLE(mc_mb_var_buf); + UPDATE_TABLE(mb_mean_buf); + UPDATE_TABLE(mbskip_table_buf); + UPDATE_TABLE(qscale_table_buf); + UPDATE_TABLE(mb_type_buf); + for (i = 0; i < 2; i++) { + UPDATE_TABLE(motion_val_buf[i]); + UPDATE_TABLE(ref_index_buf[i]); + } + + dst->mb_var = src->mb_var; + dst->mc_mb_var = src->mc_mb_var; + dst->mb_mean = src->mb_mean; + dst->mbskip_table = src->mbskip_table; + dst->qscale_table = src->qscale_table; + dst->mb_type = src->mb_type; + for (i = 0; i < 2; i++) { + dst->motion_val[i] = src->motion_val[i]; + dst->ref_index[i] = src->ref_index[i]; + } + + dst->alloc_mb_width = src->alloc_mb_width; + dst->alloc_mb_height = src->alloc_mb_height; + + return 0; +} + +int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src) +{ + int ret; + + av_assert0(!dst->f->buf[0]); + av_assert0(src->f->buf[0]); + + src->tf.f = src->f; + dst->tf.f = dst->f; + ret = ff_thread_ref_frame(&dst->tf, &src->tf); + if (ret < 0) + goto fail; + + ret = ff_update_picture_tables(dst, src); + if (ret < 0) + goto fail; + + if (src->hwaccel_picture_private) { + dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); + if (!dst->hwaccel_priv_buf) + goto fail; + dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data; + } + + dst->field_picture = src->field_picture; + dst->mb_var_sum = src->mb_var_sum; + dst->mc_mb_var_sum = src->mc_mb_var_sum; + dst->b_frame_score = src->b_frame_score; + dst->needs_realloc = src->needs_realloc; + dst->reference = src->reference; + dst->shared = src->shared; + + return 0; +fail: + ff_mpeg_unref_picture(avctx, dst); + return ret; +} + +static inline int pic_is_unused(Picture *pic) +{ + if (!pic->f->buf[0]) + return 1; + if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF)) + return 1; + return 0; +} + +static int find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared) +{ + int i; + + if (shared) { + for (i = 0; i < MAX_PICTURE_COUNT; i++) { + if (!picture[i].f->buf[0]) + return i; + } + } else { + for (i = 0; i < MAX_PICTURE_COUNT; i++) { + if (pic_is_unused(&picture[i])) + return i; + } + } + + av_log(avctx, AV_LOG_FATAL, + "Internal error, picture buffer overflow\n"); + /* We could return -1, but the codec would crash trying to draw into a + * non-existing frame anyway. This is safer than waiting for a random crash. + * Also the return of this is never useful, an encoder must only allocate + * as much as allowed in the specification. This has no relationship to how + * much libavcodec could allocate (and MAX_PICTURE_COUNT is always large + * enough for such valid streams). + * Plus, a decoder has to check stream validity and remove frames if too + * many reference frames are around. Waiting for "OOM" is not correct at + * all. Similarly, missing reference frames have to be replaced by + * interpolated/MC frames, anything else is a bug in the codec ... + */ + abort(); + return -1; +} + +int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared) +{ + int ret = find_unused_picture(avctx, picture, shared); + + if (ret >= 0 && ret < MAX_PICTURE_COUNT) { + if (picture[ret].needs_realloc) { + picture[ret].needs_realloc = 0; + ff_free_picture_tables(&picture[ret]); + ff_mpeg_unref_picture(avctx, &picture[ret]); + } + } + return ret; +} + +void ff_free_picture_tables(Picture *pic) +{ + int i; + + pic->alloc_mb_width = + pic->alloc_mb_height = 0; + + av_buffer_unref(&pic->mb_var_buf); + av_buffer_unref(&pic->mc_mb_var_buf); + av_buffer_unref(&pic->mb_mean_buf); + av_buffer_unref(&pic->mbskip_table_buf); + av_buffer_unref(&pic->qscale_table_buf); + av_buffer_unref(&pic->mb_type_buf); + + for (i = 0; i < 2; i++) { + av_buffer_unref(&pic->motion_val_buf[i]); + av_buffer_unref(&pic->ref_index_buf[i]); + } +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegpicture.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegpicture.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegpicture.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegpicture.h 2015-06-11 17:20:04.000000000 +0000 @@ -0,0 +1,114 @@ +/* + * Mpeg video formats-related defines and utility functions + * + * 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 + */ + +#ifndef AVCODEC_MPEGPICTURE_H +#define AVCODEC_MPEGPICTURE_H + +#include + +#include "libavutil/frame.h" + +#include "avcodec.h" +#include "motion_est.h" +#include "thread.h" + +#define MAX_PICTURE_COUNT 36 +#define EDGE_WIDTH 16 + +typedef struct ScratchpadContext { + uint8_t *edge_emu_buffer; ///< temporary buffer for if MVs point to out-of-frame data + uint8_t *rd_scratchpad; ///< scratchpad for rate distortion mb decision + uint8_t *obmc_scratchpad; + uint8_t *b_scratchpad; ///< scratchpad used for writing into write only buffers +} ScratchpadContext; + +/** + * Picture. + */ +typedef struct Picture { + struct AVFrame *f; + ThreadFrame tf; + + AVBufferRef *qscale_table_buf; + int8_t *qscale_table; + + AVBufferRef *motion_val_buf[2]; + int16_t (*motion_val[2])[2]; + + AVBufferRef *mb_type_buf; + uint32_t *mb_type; ///< types and macros are defined in mpegutils.h + + AVBufferRef *mbskip_table_buf; + uint8_t *mbskip_table; + + AVBufferRef *ref_index_buf[2]; + int8_t *ref_index[2]; + + AVBufferRef *mb_var_buf; + uint16_t *mb_var; ///< Table for MB variances + + AVBufferRef *mc_mb_var_buf; + uint16_t *mc_mb_var; ///< Table for motion compensated MB variances + + int alloc_mb_width; ///< mb_width used to allocate tables + int alloc_mb_height; ///< mb_height used to allocate tables + + AVBufferRef *mb_mean_buf; + uint8_t *mb_mean; ///< Table for MB luminance + + AVBufferRef *hwaccel_priv_buf; + void *hwaccel_picture_private; ///< Hardware accelerator private data + + int field_picture; ///< whether or not the picture was encoded in separate fields + + int64_t mb_var_sum; ///< sum of MB variance for current frame + int64_t mc_mb_var_sum; ///< motion compensated MB variance for current frame + + int b_frame_score; + int needs_realloc; ///< Picture needs to be reallocated (eg due to a frame size change) + + int reference; + int shared; + + uint64_t error[AV_NUM_DATA_POINTERS]; +} Picture; + +/** + * Allocate a Picture. + * The pixels are allocated/set by calling get_buffer() if shared = 0. + */ +int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me, + ScratchpadContext *sc, int shared, int encoding, + int chroma_x_shift, int chroma_y_shift, int out_format, + int mb_stride, int mb_width, int mb_height, int b8_stride, + ptrdiff_t *linesize, ptrdiff_t *uvlinesize); + +int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, + ScratchpadContext *sc, int linesize); + +int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src); +void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *picture); + +void ff_free_picture_tables(Picture *pic); +int ff_update_picture_tables(Picture *dst, Picture *src); + +int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared); + +#endif /* AVCODEC_MPEGPICTURE_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideo.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideo.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideo.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideo.c 2015-07-28 17:20:07.000000000 +0000 @@ -39,6 +39,7 @@ #include "idctdsp.h" #include "internal.h" #include "mathops.h" +#include "mpeg_er.h" #include "mpegutils.h" #include "mpegvideo.h" #include "mpegvideodata.h" @@ -256,34 +257,6 @@ } } -static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, - int (*mv)[2][4][2], - int mb_x, int mb_y, int mb_intra, int mb_skipped) -{ - MpegEncContext *s = opaque; - - s->mv_dir = mv_dir; - s->mv_type = mv_type; - s->mb_intra = mb_intra; - s->mb_skipped = mb_skipped; - s->mb_x = mb_x; - s->mb_y = mb_y; - memcpy(s->mv, mv, sizeof(*mv)); - - ff_init_block_index(s); - ff_update_block_index(s); - - s->bdsp.clear_blocks(s->block[0]); - - s->dest[0] = s->current_picture.f->data[0] + (s->mb_y * 16 * s->linesize) + s->mb_x * 16; - s->dest[1] = s->current_picture.f->data[1] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift); - s->dest[2] = s->current_picture.f->data[2] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift); - - if (ref) - av_log(s->avctx, AV_LOG_DEBUG, - "Interlaced error concealment is not fully implemented\n"); - ff_mpv_decode_mb(s, s->block); -} static void gray16(uint8_t *dst, const uint8_t *src, ptrdiff_t linesize, int h) { @@ -324,7 +297,7 @@ s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c; s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_c; s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_c; - if (s->avctx->flags & CODEC_FLAG_BITEXACT) + if (s->avctx->flags & AV_CODEC_FLAG_BITEXACT) s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_bitexact; s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_c; @@ -339,6 +312,8 @@ ff_mpv_common_init_ppc(s); if (ARCH_X86) ff_mpv_common_init_x86(s); + if (ARCH_MIPS) + ff_mpv_common_init_mips(s); return 0; } @@ -361,215 +336,6 @@ ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan); } -int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, - ScratchpadContext *sc, int linesize) -{ - int alloc_size = FFALIGN(FFABS(linesize) + 64, 32); - - if (avctx->hwaccel || avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) - return 0; - - if (linesize < 24) { - av_log(avctx, AV_LOG_ERROR, "Image too small, temporary buffers cannot function\n"); - return AVERROR_PATCHWELCOME; - } - - // edge emu needs blocksize + filter length - 1 - // (= 17x17 for halfpel / 21x21 for h264) - // VC1 computes luma and chroma simultaneously and needs 19X19 + 9x9 - // at uvlinesize. It supports only YUV420 so 24x24 is enough - // linesize * interlaced * MBsize - // we also use this buffer for encoding in encode_mb_internal() needig an additional 32 lines - FF_ALLOCZ_ARRAY_OR_GOTO(avctx, sc->edge_emu_buffer, alloc_size, 4 * 68, - fail); - - FF_ALLOCZ_ARRAY_OR_GOTO(avctx, me->scratchpad, alloc_size, 4 * 16 * 2, - fail) - me->temp = me->scratchpad; - sc->rd_scratchpad = me->scratchpad; - sc->b_scratchpad = me->scratchpad; - sc->obmc_scratchpad = me->scratchpad + 16; - - return 0; -fail: - av_freep(&sc->edge_emu_buffer); - return AVERROR(ENOMEM); -} - -/** - * Allocate a frame buffer - */ -static int alloc_frame_buffer(AVCodecContext *avctx, Picture *pic, - MotionEstContext *me, ScratchpadContext *sc, - int chroma_x_shift, int chroma_y_shift, - int linesize, int uvlinesize) -{ - int edges_needed = av_codec_is_encoder(avctx->codec); - int r, ret; - - pic->tf.f = pic->f; - if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE && - avctx->codec_id != AV_CODEC_ID_VC1IMAGE && - avctx->codec_id != AV_CODEC_ID_MSS2) { - if (edges_needed) { - pic->f->width = avctx->width + 2 * EDGE_WIDTH; - pic->f->height = avctx->height + 2 * EDGE_WIDTH; - } - - r = ff_thread_get_buffer(avctx, &pic->tf, - pic->reference ? AV_GET_BUFFER_FLAG_REF : 0); - } else { - pic->f->width = avctx->width; - pic->f->height = avctx->height; - pic->f->format = avctx->pix_fmt; - r = avcodec_default_get_buffer2(avctx, pic->f, 0); - } - - if (r < 0 || !pic->f->buf[0]) { - av_log(avctx, AV_LOG_ERROR, "get_buffer() failed (%d %p)\n", - r, pic->f->data[0]); - return -1; - } - - if (edges_needed) { - int i; - for (i = 0; pic->f->data[i]; i++) { - int offset = (EDGE_WIDTH >> (i ? chroma_y_shift : 0)) * - pic->f->linesize[i] + - (EDGE_WIDTH >> (i ? chroma_x_shift : 0)); - pic->f->data[i] += offset; - } - pic->f->width = avctx->width; - pic->f->height = avctx->height; - } - - if (avctx->hwaccel) { - assert(!pic->hwaccel_picture_private); - if (avctx->hwaccel->frame_priv_data_size) { - pic->hwaccel_priv_buf = av_buffer_allocz(avctx->hwaccel->frame_priv_data_size); - if (!pic->hwaccel_priv_buf) { - av_log(avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n"); - return -1; - } - pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data; - } - } - - if (linesize && (linesize != pic->f->linesize[0] || - uvlinesize != pic->f->linesize[1])) { - av_log(avctx, AV_LOG_ERROR, - "get_buffer() failed (stride changed)\n"); - ff_mpeg_unref_picture(avctx, pic); - return -1; - } - - if (pic->f->linesize[1] != pic->f->linesize[2]) { - av_log(avctx, AV_LOG_ERROR, - "get_buffer() failed (uv stride mismatch)\n"); - ff_mpeg_unref_picture(avctx, pic); - return -1; - } - - if (!sc->edge_emu_buffer && - (ret = ff_mpeg_framesize_alloc(avctx, me, sc, - pic->f->linesize[0])) < 0) { - av_log(avctx, AV_LOG_ERROR, - "get_buffer() failed to allocate context scratch buffers.\n"); - ff_mpeg_unref_picture(avctx, pic); - return ret; - } - - return 0; -} - -void ff_free_picture_tables(Picture *pic) -{ - int i; - - pic->alloc_mb_width = - pic->alloc_mb_height = 0; - - av_buffer_unref(&pic->mb_var_buf); - av_buffer_unref(&pic->mc_mb_var_buf); - av_buffer_unref(&pic->mb_mean_buf); - av_buffer_unref(&pic->mbskip_table_buf); - av_buffer_unref(&pic->qscale_table_buf); - av_buffer_unref(&pic->mb_type_buf); - - for (i = 0; i < 2; i++) { - av_buffer_unref(&pic->motion_val_buf[i]); - av_buffer_unref(&pic->ref_index_buf[i]); - } -} - -static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encoding, int out_format, - int mb_stride, int mb_width, int mb_height, int b8_stride) -{ - const int big_mb_num = mb_stride * (mb_height + 1) + 1; - const int mb_array_size = mb_stride * mb_height; - const int b8_array_size = b8_stride * mb_height * 2; - int i; - - - pic->mbskip_table_buf = av_buffer_allocz(mb_array_size + 2); - pic->qscale_table_buf = av_buffer_allocz(big_mb_num + mb_stride); - pic->mb_type_buf = av_buffer_allocz((big_mb_num + mb_stride) * - sizeof(uint32_t)); - if (!pic->mbskip_table_buf || !pic->qscale_table_buf || !pic->mb_type_buf) - return AVERROR(ENOMEM); - - if (encoding) { - pic->mb_var_buf = av_buffer_allocz(mb_array_size * sizeof(int16_t)); - pic->mc_mb_var_buf = av_buffer_allocz(mb_array_size * sizeof(int16_t)); - pic->mb_mean_buf = av_buffer_allocz(mb_array_size); - if (!pic->mb_var_buf || !pic->mc_mb_var_buf || !pic->mb_mean_buf) - return AVERROR(ENOMEM); - } - - if (out_format == FMT_H263 || encoding || avctx->debug_mv || - (avctx->flags2 & CODEC_FLAG2_EXPORT_MVS)) { - int mv_size = 2 * (b8_array_size + 4) * sizeof(int16_t); - int ref_index_size = 4 * mb_array_size; - - for (i = 0; mv_size && i < 2; i++) { - pic->motion_val_buf[i] = av_buffer_allocz(mv_size); - pic->ref_index_buf[i] = av_buffer_allocz(ref_index_size); - if (!pic->motion_val_buf[i] || !pic->ref_index_buf[i]) - return AVERROR(ENOMEM); - } - } - - pic->alloc_mb_width = mb_width; - pic->alloc_mb_height = mb_height; - - return 0; -} - -static int make_tables_writable(Picture *pic) -{ - int ret, i; -#define MAKE_WRITABLE(table) \ -do {\ - if (pic->table &&\ - (ret = av_buffer_make_writable(&pic->table)) < 0)\ - return ret;\ -} while (0) - - MAKE_WRITABLE(mb_var_buf); - MAKE_WRITABLE(mc_mb_var_buf); - MAKE_WRITABLE(mb_mean_buf); - MAKE_WRITABLE(mbskip_table_buf); - MAKE_WRITABLE(qscale_table_buf); - MAKE_WRITABLE(mb_type_buf); - - for (i = 0; i < 2; i++) { - MAKE_WRITABLE(motion_val_buf[i]); - MAKE_WRITABLE(ref_index_buf[i]); - } - - return 0; -} - static int alloc_picture(MpegEncContext *s, Picture *pic, int shared) { return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, shared, 0, @@ -578,178 +344,6 @@ &s->linesize, &s->uvlinesize); } -/** - * Allocate a Picture. - * The pixels are allocated/set by calling get_buffer() if shared = 0 - */ -int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me, - ScratchpadContext *sc, int shared, int encoding, - int chroma_x_shift, int chroma_y_shift, int out_format, - int mb_stride, int mb_width, int mb_height, int b8_stride, - ptrdiff_t *linesize, ptrdiff_t *uvlinesize) -{ - int i, ret; - - if (pic->qscale_table_buf) - if ( pic->alloc_mb_width != mb_width - || pic->alloc_mb_height != mb_height) - ff_free_picture_tables(pic); - - if (shared) { - av_assert0(pic->f->data[0]); - pic->shared = 1; - } else { - av_assert0(!pic->f->buf[0]); - if (alloc_frame_buffer(avctx, pic, me, sc, - chroma_x_shift, chroma_y_shift, - *linesize, *uvlinesize) < 0) - return -1; - - *linesize = pic->f->linesize[0]; - *uvlinesize = pic->f->linesize[1]; - } - - if (!pic->qscale_table_buf) - ret = alloc_picture_tables(avctx, pic, encoding, out_format, - mb_stride, mb_width, mb_height, b8_stride); - else - ret = make_tables_writable(pic); - if (ret < 0) - goto fail; - - if (encoding) { - pic->mb_var = (uint16_t*)pic->mb_var_buf->data; - pic->mc_mb_var = (uint16_t*)pic->mc_mb_var_buf->data; - pic->mb_mean = pic->mb_mean_buf->data; - } - - pic->mbskip_table = pic->mbskip_table_buf->data; - pic->qscale_table = pic->qscale_table_buf->data + 2 * mb_stride + 1; - pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * mb_stride + 1; - - if (pic->motion_val_buf[0]) { - for (i = 0; i < 2; i++) { - pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4; - pic->ref_index[i] = pic->ref_index_buf[i]->data; - } - } - - return 0; -fail: - av_log(avctx, AV_LOG_ERROR, "Error allocating a picture.\n"); - ff_mpeg_unref_picture(avctx, pic); - ff_free_picture_tables(pic); - return AVERROR(ENOMEM); -} - -/** - * Deallocate a picture. - */ -void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic) -{ - int off = offsetof(Picture, mb_mean) + sizeof(pic->mb_mean); - - pic->tf.f = pic->f; - /* WM Image / Screen codecs allocate internal buffers with different - * dimensions / colorspaces; ignore user-defined callbacks for these. */ - if (avctx->codec->id != AV_CODEC_ID_WMV3IMAGE && - avctx->codec->id != AV_CODEC_ID_VC1IMAGE && - avctx->codec->id != AV_CODEC_ID_MSS2) - ff_thread_release_buffer(avctx, &pic->tf); - else if (pic->f) - av_frame_unref(pic->f); - - av_buffer_unref(&pic->hwaccel_priv_buf); - - if (pic->needs_realloc) - ff_free_picture_tables(pic); - - memset((uint8_t*)pic + off, 0, sizeof(*pic) - off); -} - -static int update_picture_tables(Picture *dst, Picture *src) -{ - int i; - -#define UPDATE_TABLE(table)\ -do {\ - if (src->table &&\ - (!dst->table || dst->table->buffer != src->table->buffer)) {\ - av_buffer_unref(&dst->table);\ - dst->table = av_buffer_ref(src->table);\ - if (!dst->table) {\ - ff_free_picture_tables(dst);\ - return AVERROR(ENOMEM);\ - }\ - }\ -} while (0) - - UPDATE_TABLE(mb_var_buf); - UPDATE_TABLE(mc_mb_var_buf); - UPDATE_TABLE(mb_mean_buf); - UPDATE_TABLE(mbskip_table_buf); - UPDATE_TABLE(qscale_table_buf); - UPDATE_TABLE(mb_type_buf); - for (i = 0; i < 2; i++) { - UPDATE_TABLE(motion_val_buf[i]); - UPDATE_TABLE(ref_index_buf[i]); - } - - dst->mb_var = src->mb_var; - dst->mc_mb_var = src->mc_mb_var; - dst->mb_mean = src->mb_mean; - dst->mbskip_table = src->mbskip_table; - dst->qscale_table = src->qscale_table; - dst->mb_type = src->mb_type; - for (i = 0; i < 2; i++) { - dst->motion_val[i] = src->motion_val[i]; - dst->ref_index[i] = src->ref_index[i]; - } - - dst->alloc_mb_width = src->alloc_mb_width; - dst->alloc_mb_height = src->alloc_mb_height; - - return 0; -} - -int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src) -{ - int ret; - - av_assert0(!dst->f->buf[0]); - av_assert0(src->f->buf[0]); - - src->tf.f = src->f; - dst->tf.f = dst->f; - ret = ff_thread_ref_frame(&dst->tf, &src->tf); - if (ret < 0) - goto fail; - - ret = update_picture_tables(dst, src); - if (ret < 0) - goto fail; - - if (src->hwaccel_picture_private) { - dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); - if (!dst->hwaccel_priv_buf) - goto fail; - dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data; - } - - dst->field_picture = src->field_picture; - dst->mb_var_sum = src->mb_var_sum; - dst->mc_mb_var_sum = src->mc_mb_var_sum; - dst->b_frame_score = src->b_frame_score; - dst->needs_realloc = src->needs_realloc; - dst->reference = src->reference; - dst->shared = src->shared; - - return 0; -fail: - ff_mpeg_unref_picture(avctx, dst); - return ret; -} - static int init_duplicate_context(MpegEncContext *s) { int y_size = s->b8_stride * (2 * s->mb_height + 1); @@ -930,7 +524,7 @@ if(s->picture) for (i = 0; i < MAX_PICTURE_COUNT; i++) { ff_mpeg_unref_picture(s->avctx, &s->picture[i]); - if (s1->picture[i].f->buf[0] && + if (s1->picture && s1->picture[i].f->buf[0] && (ret = ff_mpeg_ref_picture(s->avctx, &s->picture[i], &s1->picture[i])) < 0) return ret; } @@ -941,7 +535,7 @@ if (s1->pic.f && s1->pic.f->buf[0])\ ret = ff_mpeg_ref_picture(s->avctx, &s->pic, &s1->pic);\ else\ - ret = update_picture_tables(&s->pic, &s1->pic);\ + ret = ff_update_picture_tables(&s->pic, &s1->pic);\ if (ret < 0)\ return ret;\ } while (0) @@ -979,7 +573,7 @@ if (s1->bitstream_buffer) { if (s1->bitstream_buffer_size + - FF_INPUT_BUFFER_PADDING_SIZE > s->allocated_bitstream_buffer_size) { + AV_INPUT_BUFFER_PADDING_SIZE > s->allocated_bitstream_buffer_size) { av_fast_malloc(&s->bitstream_buffer, &s->allocated_bitstream_buffer_size, s1->allocated_bitstream_buffer_size); @@ -992,7 +586,7 @@ memcpy(s->bitstream_buffer, s1->bitstream_buffer, s1->bitstream_buffer_size); memset(s->bitstream_buffer + s->bitstream_buffer_size, 0, - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); } // linesize dependend scratch buffer allocation @@ -1068,42 +662,6 @@ s->codec_tag = avpriv_toupper4(avctx->codec_tag); } -static int init_er(MpegEncContext *s) -{ - ERContext *er = &s->er; - int mb_array_size = s->mb_height * s->mb_stride; - int i; - - er->avctx = s->avctx; - - er->mb_index2xy = s->mb_index2xy; - er->mb_num = s->mb_num; - er->mb_width = s->mb_width; - er->mb_height = s->mb_height; - er->mb_stride = s->mb_stride; - er->b8_stride = s->b8_stride; - - er->er_temp_buffer = av_malloc(s->mb_height * s->mb_stride); - er->error_status_table = av_mallocz(mb_array_size); - if (!er->er_temp_buffer || !er->error_status_table) - goto fail; - - er->mbskip_table = s->mbskip_table; - er->mbintra_table = s->mbintra_table; - - for (i = 0; i < FF_ARRAY_ELEMS(s->dc_val); i++) - er->dc_val[i] = s->dc_val[i]; - - er->decode_mb = mpeg_er_decode_mb; - er->opaque = s; - - return 0; -fail: - av_freep(&er->er_temp_buffer); - av_freep(&er->error_status_table); - return AVERROR(ENOMEM); -} - /** * Initialize and allocates MpegEncContext fields dependent on the resolution. */ @@ -1173,7 +731,7 @@ } if (s->codec_id == AV_CODEC_ID_MPEG4 || - (s->avctx->flags & CODEC_FLAG_INTERLACED_ME)) { + (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME)) { /* interlaced direct mode decoding tables */ for (i = 0; i < 2; i++) { int j, k; @@ -1222,11 +780,87 @@ FF_ALLOCZ_OR_GOTO(s->avctx, s->mbskip_table, mb_array_size + 2, fail); // Note the + 1 is for a quicker mpeg4 slice_end detection - return init_er(s); + return ff_mpeg_er_init(s); fail: return AVERROR(ENOMEM); } +static void clear_context(MpegEncContext *s) +{ + int i, j, k; + + memset(&s->next_picture, 0, sizeof(s->next_picture)); + memset(&s->last_picture, 0, sizeof(s->last_picture)); + memset(&s->current_picture, 0, sizeof(s->current_picture)); + memset(&s->new_picture, 0, sizeof(s->new_picture)); + + memset(s->thread_context, 0, sizeof(s->thread_context)); + + s->me.map = NULL; + s->me.score_map = NULL; + s->dct_error_sum = NULL; + s->block = NULL; + s->blocks = NULL; + memset(s->pblocks, 0, sizeof(s->pblocks)); + s->ac_val_base = NULL; + s->ac_val[0] = + s->ac_val[1] = + s->ac_val[2] =NULL; + s->sc.edge_emu_buffer = NULL; + s->me.scratchpad = NULL; + s->me.temp = + s->sc.rd_scratchpad = + s->sc.b_scratchpad = + s->sc.obmc_scratchpad = NULL; + + s->parse_context.buffer = NULL; + s->parse_context.buffer_size = 0; + s->bitstream_buffer = NULL; + s->allocated_bitstream_buffer_size = 0; + s->picture = NULL; + s->mb_type = NULL; + s->p_mv_table_base = NULL; + s->b_forw_mv_table_base = NULL; + s->b_back_mv_table_base = NULL; + s->b_bidir_forw_mv_table_base = NULL; + s->b_bidir_back_mv_table_base = NULL; + s->b_direct_mv_table_base = NULL; + s->p_mv_table = NULL; + s->b_forw_mv_table = NULL; + s->b_back_mv_table = NULL; + s->b_bidir_forw_mv_table = NULL; + s->b_bidir_back_mv_table = NULL; + s->b_direct_mv_table = NULL; + for (i = 0; i < 2; i++) { + for (j = 0; j < 2; j++) { + for (k = 0; k < 2; k++) { + s->b_field_mv_table_base[i][j][k] = NULL; + s->b_field_mv_table[i][j][k] = NULL; + } + s->b_field_select_table[i][j] = NULL; + s->p_field_mv_table_base[i][j] = NULL; + s->p_field_mv_table[i][j] = NULL; + } + s->p_field_select_table[i] = NULL; + } + + s->dc_val_base = NULL; + s->coded_block_base = NULL; + s->mbintra_table = NULL; + s->cbp_table = NULL; + s->pred_dir_table = NULL; + + s->mbskip_table = NULL; + + s->er.error_status_table = NULL; + s->er.er_temp_buffer = NULL; + s->mb_index2xy = NULL; + s->lambda_table = NULL; + + s->cplx_tab = NULL; + s->bits_tab = NULL; +} + /** * init common structure for both encoder and decoder. * this assumes that some variables like width/height are already set @@ -1238,6 +872,8 @@ s->avctx->active_thread_type & FF_THREAD_SLICE) ? s->avctx->thread_count : 1; + clear_context(s); + if (s->encoding && s->avctx->slices) nb_slices = s->avctx->slices; @@ -1282,10 +918,6 @@ if (!s->picture[i].f) goto fail; } - memset(&s->next_picture, 0, sizeof(s->next_picture)); - memset(&s->last_picture, 0, sizeof(s->last_picture)); - memset(&s->current_picture, 0, sizeof(s->current_picture)); - memset(&s->new_picture, 0, sizeof(s->new_picture)); s->next_picture.f = av_frame_alloc(); if (!s->next_picture.f) goto fail; @@ -1475,6 +1107,9 @@ { int i; + if (!s) + return ; + if (s->slice_context_count > 1) { for (i = 0; i < s->slice_context_count; i++) { free_duplicate_context(s->thread_context[i]); @@ -1521,72 +1156,6 @@ s->linesize = s->uvlinesize = 0; } -static void release_unused_pictures(AVCodecContext *avctx, Picture *picture) -{ - int i; - - /* release non reference frames */ - for (i = 0; i < MAX_PICTURE_COUNT; i++) { - if (!picture[i].reference) - ff_mpeg_unref_picture(avctx, &picture[i]); - } -} - -static inline int pic_is_unused(Picture *pic) -{ - if (!pic->f->buf[0]) - return 1; - if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF)) - return 1; - return 0; -} - -static int find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared) -{ - int i; - - if (shared) { - for (i = 0; i < MAX_PICTURE_COUNT; i++) { - if (!picture[i].f->buf[0]) - return i; - } - } else { - for (i = 0; i < MAX_PICTURE_COUNT; i++) { - if (pic_is_unused(&picture[i])) - return i; - } - } - - av_log(avctx, AV_LOG_FATAL, - "Internal error, picture buffer overflow\n"); - /* We could return -1, but the codec would crash trying to draw into a - * non-existing frame anyway. This is safer than waiting for a random crash. - * Also the return of this is never useful, an encoder must only allocate - * as much as allowed in the specification. This has no relationship to how - * much libavcodec could allocate (and MAX_PICTURE_COUNT is always large - * enough for such valid streams). - * Plus, a decoder has to check stream validity and remove frames if too - * many reference frames are around. Waiting for "OOM" is not correct at - * all. Similarly, missing reference frames have to be replaced by - * interpolated/MC frames, anything else is a bug in the codec ... - */ - abort(); - return -1; -} - -int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared) -{ - int ret = find_unused_picture(avctx, picture, shared); - - if (ret >= 0 && ret < MAX_PICTURE_COUNT) { - if (picture[ret].needs_realloc) { - picture[ret].needs_realloc = 0; - ff_free_picture_tables(&picture[ret]); - ff_mpeg_unref_picture(avctx, &picture[ret]); - } - } - return ret; -} static void gray_frame(AVFrame *frame) { @@ -1641,7 +1210,11 @@ ff_mpeg_unref_picture(s->avctx, &s->current_picture); - release_unused_pictures(s->avctx, s->picture); + /* release non reference frames */ + for (i = 0; i < MAX_PICTURE_COUNT; i++) { + if (!s->picture[i].reference) + ff_mpeg_unref_picture(s->avctx, &s->picture[i]); + } if (s->current_picture_ptr && !s->current_picture_ptr->f->buf[0]) { // we already have a unused image @@ -1681,7 +1254,7 @@ s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME; s->current_picture_ptr->f->pict_type = s->pict_type; - // if (s->avctx->flags && CODEC_FLAG_QSCALE) + // if (s->avctx->flags && AV_CODEC_FLAG_QSCALE) // s->current_picture_ptr->quality = s->new_picture_ptr->quality; s->current_picture_ptr->f->key_frame = s->pict_type == AV_PICTURE_TYPE_I; @@ -1734,7 +1307,7 @@ return -1; } - if (!avctx->hwaccel && !(avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)) { + if (!avctx->hwaccel && !(avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU)) { for(i=0; iheight; i++) memset(s->last_picture_ptr->f->data[0] + s->last_picture_ptr->f->linesize[0]*i, 0x80, avctx->width); @@ -1995,7 +1568,7 @@ int *low_delay, int mb_width, int mb_height, int mb_stride, int quarter_sample) { - if ((avctx->flags2 & CODEC_FLAG2_EXPORT_MVS) && mbtype_table && motion_val[0]) { + if ((avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MVS) && mbtype_table && motion_val[0]) { const int shift = 1 + quarter_sample; const int mv_sample_log2 = avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_SVQ3 ? 2 : 1; const int mv_stride = (mb_width << mv_sample_log2) + @@ -2079,7 +1652,7 @@ /* TODO: export all the following to make them accessible for users (and filters) */ if (avctx->hwaccel || !mbtype_table - || (avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)) + || (avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU)) return; @@ -2523,7 +2096,7 @@ src_x, src_y << field_based, h_edge_pos, v_edge_pos); ptr_y = s->sc.edge_emu_buffer; - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize; uint8_t *vbuf =ubuf + 9 * s->uvlinesize; s->vdsp.emulated_edge_mc(ubuf, ptr_cb, @@ -2558,7 +2131,7 @@ sy = (sy << 2) >> lowres; pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { int hc = s->chroma_y_shift ? (h+1-bottom_field)>>1 : h; uvsx = (uvsx << 2) >> lowres; uvsy = (uvsy << 2) >> lowres; @@ -2678,7 +2251,7 @@ my += s->mv[dir][i][1]; } - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) chroma_4mv_motion_lowres(s, dest_cb, dest_cr, ref_picture, pix_op, mx, my); break; @@ -2772,7 +2345,7 @@ /** * find the lowest MB row referenced in the MVs */ -int ff_mpv_lowest_referenced_row(MpegEncContext *s, int dir) +static int lowest_referenced_row(MpegEncContext *s, int dir) { int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->quarter_sample; int my, off, i, mvs; @@ -2918,7 +2491,7 @@ else if (!is_mpeg12 && (s->h263_pred || s->h263_aic)) s->mbintra_table[mb_xy]=1; - if ((s->avctx->flags & CODEC_FLAG_PSNR) || s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor || + if ((s->avctx->flags & AV_CODEC_FLAG_PSNR) || s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor || !(s->encoding && (s->intra_only || s->pict_type == AV_PICTURE_TYPE_B) && s->avctx->mb_decision != FF_MB_DECISION_RD)) { // FIXME precalc uint8_t *dest_y, *dest_cb, *dest_cr; @@ -2967,12 +2540,12 @@ if(HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) { if (s->mv_dir & MV_DIR_FORWARD) { ff_thread_await_progress(&s->last_picture_ptr->tf, - ff_mpv_lowest_referenced_row(s, 0), + lowest_referenced_row(s, 0), 0); } if (s->mv_dir & MV_DIR_BACKWARD) { ff_thread_await_progress(&s->next_picture_ptr->tf, - ff_mpv_lowest_referenced_row(s, 1), + lowest_referenced_row(s, 1), 0); } } @@ -3021,7 +2594,7 @@ add_dequant_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale); add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { if (s->chroma_y_shift){ add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale); add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale); @@ -3040,7 +2613,7 @@ add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize); add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { if(s->chroma_y_shift){//Chroma420 add_dct(s, block[4], 4, dest_cb, uvlinesize); add_dct(s, block[5], 5, dest_cr, uvlinesize); @@ -3073,7 +2646,7 @@ put_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale); put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { if(s->chroma_y_shift){ put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale); put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale); @@ -3092,7 +2665,7 @@ s->idsp.idct_put(dest_y + dct_offset, dct_linesize, block[2]); s->idsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { if(s->chroma_y_shift){ s->idsp.idct_put(dest_cb, uvlinesize, block[4]); s->idsp.idct_put(dest_cr, uvlinesize, block[5]); @@ -3118,7 +2691,7 @@ skip_idct: if(!readable){ s->hdsp.put_pixels_tab[0][0](s->dest[0], dest_y , linesize,16); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { s->hdsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[1], dest_cb, uvlinesize,16 >> s->chroma_y_shift); s->hdsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[2], dest_cr, uvlinesize,16 >> s->chroma_y_shift); } @@ -3177,35 +2750,6 @@ } } -/** - * Permute an 8x8 block. - * @param block the block which will be permuted according to the given permutation vector - * @param permutation the permutation vector - * @param last the last non zero coefficient in scantable order, used to speed the permutation up - * @param scantable the used scantable, this is only used to speed the permutation up, the block is not - * (inverse) permutated to scantable order! - */ -void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last) -{ - int i; - int16_t temp[64]; - - if(last<=0) return; - //if(permutation[1]==1) return; //FIXME it is ok but not clean and might fail for some permutations - - for(i=0; i<=last; i++){ - const int j= scantable[i]; - temp[j]= block[j]; - block[j]=0; - } - - for(i=0; i<=last; i++){ - const int j= scantable[i]; - const int perm_j= permutation[j]; - block[perm_j]= temp[j]; - } -} - void ff_mpeg_flush(AVCodecContext *avctx){ int i; MpegEncContext *s = avctx->priv_data; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideo_enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideo_enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideo_enc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideo_enc.c 2015-07-30 17:20:02.000000000 +0000 @@ -43,6 +43,7 @@ #include "mpegvideodata.h" #include "h261.h" #include "h263.h" +#include "h263data.h" #include "mjpegenc_common.h" #include "mathops.h" #include "mpegutils.h" @@ -58,6 +59,7 @@ #include "internal.h" #include "bytestream.h" #include "wmv2.h" +#include "rv10.h" #include #include "sp5x.h" @@ -161,9 +163,30 @@ static inline void update_qscale(MpegEncContext *s) { - s->qscale = (s->lambda * 139 + FF_LAMBDA_SCALE * 64) >> - (FF_LAMBDA_SHIFT + 7); - s->qscale = av_clip(s->qscale, s->avctx->qmin, s->avctx->qmax); + if (s->q_scale_type == 1) { + int i; + int bestdiff=INT_MAX; + int best = 1; + static const uint8_t non_linear_qscale[] = { + 1,2,3,4,5,6,7,8,9,10,11,12,14,16,18,20,24,26,28 + }; + + for (i = 0 ; ilambda * 139); + if (non_linear_qscale[i] < s->avctx->qmin || + (non_linear_qscale[i] > s->avctx->qmax && !s->vbv_ignore_qmax)) + continue; + if (diff < bestdiff) { + bestdiff = diff; + best = non_linear_qscale[i]; + } + } + s->qscale = best; + } else { + s->qscale = (s->lambda * 139 + FF_LAMBDA_SCALE * 64) >> + (FF_LAMBDA_SHIFT + 7); + s->qscale = av_clip(s->qscale, s->avctx->qmin, s->vbv_ignore_qmax ? 31 : s->avctx->qmax); + } s->lambda2 = (s->lambda * s->lambda + FF_LAMBDA_SCALE / 2) >> FF_LAMBDA_SHIFT; @@ -337,7 +360,7 @@ s->max_b_frames = avctx->max_b_frames; s->codec_id = avctx->codec->id; s->strict_std_compliance = avctx->strict_std_compliance; - s->quarter_sample = (avctx->flags & CODEC_FLAG_QPEL) != 0; + s->quarter_sample = (avctx->flags & AV_CODEC_FLAG_QPEL) != 0; s->mpeg_quant = avctx->mpeg_quant; s->rtp_mode = !!avctx->rtp_payload_size; s->intra_dc_precision = avctx->intra_dc_precision; @@ -368,10 +391,14 @@ s->intra_only = 0; } +#if FF_API_MOTION_EST +FF_DISABLE_DEPRECATION_WARNINGS s->me_method = avctx->me_method; +FF_ENABLE_DEPRECATION_WARNINGS +#endif /* Fixed QSCALE */ - s->fixed_qscale = !!(avctx->flags & CODEC_FLAG_QSCALE); + s->fixed_qscale = !!(avctx->flags & AV_CODEC_FLAG_QSCALE); #if FF_API_MPV_OPT FF_DISABLE_DEPRECATION_WARNINGS @@ -389,7 +416,7 @@ (s->mpv_flags & FF_MPV_FLAG_QP_RD)) && !s->fixed_qscale; - s->loop_filter = !!(s->avctx->flags & CODEC_FLAG_LOOP_FILTER); + s->loop_filter = !!(s->avctx->flags & AV_CODEC_FLAG_LOOP_FILTER); if (avctx->rc_max_rate && !avctx->rc_buffer_size) { switch(avctx->codec_id) { @@ -470,7 +497,7 @@ "specified vbv buffer is too large for the given bitrate!\n"); } - if ((s->avctx->flags & CODEC_FLAG_4MV) && s->codec_id != AV_CODEC_ID_MPEG4 && + if ((s->avctx->flags & AV_CODEC_FLAG_4MV) && s->codec_id != AV_CODEC_ID_MPEG4 && s->codec_id != AV_CODEC_ID_H263 && s->codec_id != AV_CODEC_ID_H263P && s->codec_id != AV_CODEC_ID_FLV1) { av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n"); @@ -563,7 +590,7 @@ return -1; } - if ((s->avctx->flags & (CODEC_FLAG_INTERLACED_DCT | CODEC_FLAG_INTERLACED_ME)) && + if ((s->avctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME)) && s->codec_id != AV_CODEC_ID_MPEG4 && s->codec_id != AV_CODEC_ID_MPEG2VIDEO) { av_log(avctx, AV_LOG_ERROR, "interlacing not supported by codec\n"); return -1; @@ -589,14 +616,14 @@ } if (s->avctx->scenechange_threshold < 1000000000 && - (s->avctx->flags & CODEC_FLAG_CLOSED_GOP)) { + (s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)) { av_log(avctx, AV_LOG_ERROR, "closed gop with scene change detection are not supported yet, " "set threshold to 1000000000\n"); return -1; } - if (s->avctx->flags & CODEC_FLAG_LOW_DELAY) { + if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) { if (s->codec_id != AV_CODEC_ID_MPEG2VIDEO) { av_log(avctx, AV_LOG_ERROR, "low delay forcing is only available for mpeg2\n"); @@ -610,9 +637,9 @@ } if (s->q_scale_type == 1) { - if (avctx->qmax > 12) { + if (avctx->qmax > 28) { av_log(avctx, AV_LOG_ERROR, - "non linear quant only supports qmax <= 12 currently\n"); + "non linear quant only supports qmax <= 28 currently\n"); return -1; } } @@ -646,7 +673,7 @@ return -1; } - if (avctx->b_frame_strategy && (avctx->flags & CODEC_FLAG_PASS2)) { + if (avctx->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) { av_log(avctx, AV_LOG_INFO, "notice: b_frame_strategy only affects the first pass\n"); avctx->b_frame_strategy = 0; @@ -675,10 +702,16 @@ return AVERROR(EINVAL); } - if (avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS) +#if FF_API_QUANT_BIAS +FF_DISABLE_DEPRECATION_WARNINGS + if (s->intra_quant_bias == FF_DEFAULT_QUANT_BIAS && + avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS) s->intra_quant_bias = avctx->intra_quant_bias; - if (avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS) + if (s->inter_quant_bias == FF_DEFAULT_QUANT_BIAS && + avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS) s->inter_quant_bias = avctx->inter_quant_bias; +FF_ENABLE_DEPRECATION_WARNINGS +#endif av_log(avctx, AV_LOG_DEBUG, "intra_quant_bias = %d inter_quant_bias = %d\n",s->intra_quant_bias,s->inter_quant_bias); @@ -696,12 +729,12 @@ switch (avctx->codec->id) { case AV_CODEC_ID_MPEG1VIDEO: s->out_format = FMT_MPEG1; - s->low_delay = !!(s->avctx->flags & CODEC_FLAG_LOW_DELAY); + s->low_delay = !!(s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY); avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1); break; case AV_CODEC_ID_MPEG2VIDEO: s->out_format = FMT_MPEG1; - s->low_delay = !!(s->avctx->flags & CODEC_FLAG_LOW_DELAY); + s->low_delay = !!(s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY); avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1); s->rtp_mode = 1; break; @@ -750,9 +783,9 @@ s->out_format = FMT_H263; s->h263_plus = 1; /* Fx */ - s->h263_aic = (avctx->flags & CODEC_FLAG_AC_PRED) ? 1 : 0; + s->h263_aic = (avctx->flags & AV_CODEC_FLAG_AC_PRED) ? 1 : 0; s->modified_quant = s->h263_aic; - s->loop_filter = (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1 : 0; + s->loop_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0; s->unrestricted_mv = s->obmc || s->loop_filter || s->umvplus; /* /Fx */ @@ -834,8 +867,8 @@ s->encoding = 1; s->progressive_frame = - s->progressive_sequence = !(avctx->flags & (CODEC_FLAG_INTERLACED_DCT | - CODEC_FLAG_INTERLACED_ME) || + s->progressive_sequence = !(avctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | + AV_CODEC_FLAG_INTERLACED_ME) || s->alternate_scan); /* init */ @@ -849,8 +882,6 @@ ff_pixblockdsp_init(&s->pdsp, avctx); ff_qpeldsp_init(&s->qdsp); - s->avctx->coded_frame = s->current_picture.f; - if (s->msmpeg4_version) { FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats, 2 * 2 * (MAX_LEVEL + 1) * @@ -1304,8 +1335,8 @@ c->width = s->width >> scale; c->height = s->height >> scale; - c->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR; - c->flags |= s->avctx->flags & CODEC_FLAG_QPEL; + c->flags = AV_CODEC_FLAG_QSCALE | AV_CODEC_FLAG_PSNR; + c->flags |= s->avctx->flags & AV_CODEC_FLAG_QPEL; c->mb_decision = s->avctx->mb_decision; c->me_cmp = s->avctx->me_cmp; c->mb_cmp = s->avctx->mb_cmp; @@ -1429,7 +1460,7 @@ } else { int b_frames; - if (s->avctx->flags & CODEC_FLAG_PASS2) { + if (s->avctx->flags & AV_CODEC_FLAG_PASS2) { for (i = 0; i < s->max_b_frames + 1; i++) { int pict_num = s->input_picture[0]->f->display_picture_number + i; @@ -1498,13 +1529,13 @@ s->gop_size > s->picture_in_gop_number) { b_frames = s->gop_size - s->picture_in_gop_number - 1; } else { - if (s->avctx->flags & CODEC_FLAG_CLOSED_GOP) + if (s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) b_frames = 0; s->input_picture[b_frames]->f->pict_type = AV_PICTURE_TYPE_I; } } - if ((s->avctx->flags & CODEC_FLAG_CLOSED_GOP) && b_frames && + if ((s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) && b_frames && s->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_I) b_frames--; @@ -1611,8 +1642,11 @@ if (s->pict_type!= AV_PICTURE_TYPE_B) s->last_non_b_pict_type = s->pict_type; - s->avctx->coded_frame = s->current_picture_ptr->f; - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + av_frame_copy_props(s->avctx->coded_frame, s->current_picture.f); +FF_ENABLE_DEPRECATION_WARNINGS +#endif } static void update_noise_reduction(MpegEncContext *s) @@ -1715,6 +1749,8 @@ int i, stuffing_count, ret; int context_count = s->slice_context_count; + s->vbv_ignore_qmax = 0; + s->picture_in_gop_number++; if (load_input_picture(s, pic_arg) < 0) @@ -1727,10 +1763,10 @@ /* output? */ if (s->new_picture.f->data[0]) { int growing_buffer = context_count == 1 && !pkt->data && !s->data_partitioning; - int pkt_size = growing_buffer ? FFMAX(s->mb_width*s->mb_height*64+10000, avctx->internal->byte_buffer_size) - FF_INPUT_BUFFER_PADDING_SIZE + int pkt_size = growing_buffer ? FFMAX(s->mb_width*s->mb_height*64+10000, avctx->internal->byte_buffer_size) - AV_INPUT_BUFFER_PADDING_SIZE : s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+10000; - if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, 0)) < 0) return ret; if (s->mb_info) { s->mb_info_ptr = av_packet_new_side_data(pkt, @@ -1811,6 +1847,7 @@ PutBitContext *pb = &s->thread_context[i]->pb; init_put_bits(pb, pb->buf, pb->buf_end - pb->buf); } + s->vbv_ignore_qmax = 1; av_log(s->avctx, AV_LOG_VERBOSE, "reencoding frame due to VBV\n"); goto vbv_retry; } @@ -1818,7 +1855,7 @@ av_assert0(s->avctx->rc_max_rate); } - if (s->avctx->flags & CODEC_FLAG_PASS1) + if (s->avctx->flags & AV_CODEC_FLAG_PASS1) ff_write_pass1_stats(s); for (i = 0; i < 4; i++) { @@ -1827,8 +1864,12 @@ s->current_picture.error[i]; avctx->error[i] += s->current_picture_ptr->f->error[i]; } + ff_side_data_set_encoder_stats(pkt, s->current_picture.f->quality, + s->current_picture_ptr->f->error, + (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? 4 : 0, + s->pict_type); - if (s->avctx->flags & CODEC_FLAG_PASS1) + if (s->avctx->flags & AV_CODEC_FLAG_PASS1) assert(avctx->header_bits + avctx->mv_bits + avctx->misc_bits + avctx->i_tex_bits + avctx->p_tex_bits == put_bits_count(&s->pb)); @@ -2130,7 +2171,7 @@ } if (s->mb_intra) { - if (s->avctx->flags & CODEC_FLAG_INTERLACED_DCT) { + if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { int progressive_score, interlaced_score; s->interlaced_dct = 0; @@ -2161,7 +2202,7 @@ s->pdsp.get_pixels(s->block[2], ptr_y + dct_offset, wrap_y); s->pdsp.get_pixels(s->block[3], ptr_y + dct_offset + 8, wrap_y); - if (s->avctx->flags & CODEC_FLAG_GRAY) { + if (s->avctx->flags & AV_CODEC_FLAG_GRAY) { skip_dct[4] = 1; skip_dct[5] = 1; } else { @@ -2209,7 +2250,7 @@ op_pix, op_qpix); } - if (s->avctx->flags & CODEC_FLAG_INTERLACED_DCT) { + if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { int progressive_score, interlaced_score; s->interlaced_dct = 0; @@ -2247,7 +2288,7 @@ s->pdsp.diff_pixels(s->block[3], ptr_y + dct_offset + 8, dest_y + dct_offset + 8, wrap_y); - if (s->avctx->flags & CODEC_FLAG_GRAY) { + if (s->avctx->flags & AV_CODEC_FLAG_GRAY) { skip_dct[4] = 1; skip_dct[5] = 1; } else { @@ -2357,7 +2398,7 @@ } } - if ((s->avctx->flags & CODEC_FLAG_GRAY) && s->mb_intra) { + if ((s->avctx->flags & AV_CODEC_FLAG_GRAY) && s->mb_intra) { s->block_last_index[4] = s->block_last_index[5] = 0; s->block[4][0] = @@ -2681,7 +2722,7 @@ avpriv_align_put_bits(&s->pb); flush_put_bits(&s->pb); - if ((s->avctx->flags & CODEC_FLAG_PASS1) && !s->partitioned_frame) + if ((s->avctx->flags & AV_CODEC_FLAG_PASS1) && !s->partitioned_frame) s->misc_bits+= get_bits_diff(s); } @@ -2934,7 +2975,7 @@ break; } - if (s->avctx->flags & CODEC_FLAG_PASS1) { + if (s->avctx->flags & AV_CODEC_FLAG_PASS1) { int bits= put_bits_count(&s->pb); s->misc_bits+= bits - s->last_bits; s->last_bits= bits; @@ -3354,7 +3395,7 @@ s->p_mv_table[xy][1]=0; } - if (s->avctx->flags & CODEC_FLAG_PSNR) { + if (s->avctx->flags & AV_CODEC_FLAG_PSNR) { int w= 16; int h= 16; @@ -3519,11 +3560,11 @@ s->no_rounding ^= 1; } - if (s->avctx->flags & CODEC_FLAG_PASS2) { + if (s->avctx->flags & AV_CODEC_FLAG_PASS2) { if (estimate_qp(s,1) < 0) return -1; ff_get_2pass_fcode(s); - } else if (!(s->avctx->flags & CODEC_FLAG_QSCALE)) { + } else if (!(s->avctx->flags & AV_CODEC_FLAG_QSCALE)) { if(s->pict_type==AV_PICTURE_TYPE_B) s->lambda= s->last_lambda_for[s->pict_type]; else @@ -3590,7 +3631,7 @@ if(s->pict_type==AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) { s->f_code= ff_get_best_fcode(s, s->p_mv_table, CANDIDATE_MB_TYPE_INTER); - if (s->avctx->flags & CODEC_FLAG_INTERLACED_ME) { + if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) { int a,b; a= ff_get_best_fcode(s, s->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I); //FIXME field_select b= ff_get_best_fcode(s, s->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I); @@ -3599,7 +3640,7 @@ ff_fix_long_p_mvs(s); ff_fix_long_mvs(s, NULL, 0, s->p_mv_table, s->f_code, CANDIDATE_MB_TYPE_INTER, 0); - if (s->avctx->flags & CODEC_FLAG_INTERLACED_ME) { + if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) { int j; for(i=0; i<2; i++){ for(j=0; j<2; j++) @@ -3624,7 +3665,7 @@ ff_fix_long_mvs(s, NULL, 0, s->b_back_mv_table, s->b_code, CANDIDATE_MB_TYPE_BACKWARD, 1); ff_fix_long_mvs(s, NULL, 0, s->b_bidir_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_BIDIR, 1); ff_fix_long_mvs(s, NULL, 0, s->b_bidir_back_mv_table, s->b_code, CANDIDATE_MB_TYPE_BIDIR, 1); - if (s->avctx->flags & CODEC_FLAG_INTERLACED_ME) { + if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) { int dir, j; for(dir=0; dir<2; dir++){ for(i=0; i<2; i++){ @@ -3645,7 +3686,7 @@ if (s->qscale < 3 && s->max_qcoeff <= 128 && s->pict_type == AV_PICTURE_TYPE_I && - !(s->avctx->flags & CODEC_FLAG_QSCALE)) + !(s->avctx->flags & AV_CODEC_FLAG_QSCALE)) s->qscale= 3; //reduce clipping problems if (s->out_format == FMT_MJPEG) { @@ -4489,6 +4530,42 @@ return last_non_zero; } +/** + * Permute an 8x8 block according to permuatation. + * @param block the block which will be permuted according to + * the given permutation vector + * @param permutation the permutation vector + * @param last the last non zero coefficient in scantable order, used to + * speed the permutation up + * @param scantable the used scantable, this is only used to speed the + * permutation up, the block is not (inverse) permutated + * to scantable order! + */ +static void block_permute(int16_t *block, uint8_t *permutation, + const uint8_t *scantable, int last) +{ + int i; + int16_t temp[64]; + + if (last <= 0) + return; + //FIXME it is ok but not clean and might fail for some permutations + // if (permutation[1] == 1) + // return; + + for (i = 0; i <= last; i++) { + const int j = scantable[i]; + temp[j] = block[j]; + block[j] = 0; + } + + for (i = 0; i <= last; i++) { + const int j = scantable[i]; + const int perm_j = permutation[j]; + block[perm_j] = temp[j]; + } +} + int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow) @@ -4521,12 +4598,12 @@ start_i = 1; last_non_zero = 0; qmat = n < 4 ? s->q_intra_matrix[qscale] : s->q_chroma_intra_matrix[qscale]; - bias= s->intra_quant_bias<<(QMAT_SHIFT - QUANT_BIAS_SHIFT); + bias= s->intra_quant_bias*(1<<(QMAT_SHIFT - QUANT_BIAS_SHIFT)); } else { start_i = 0; last_non_zero = -1; qmat = s->q_inter_matrix[qscale]; - bias= s->inter_quant_bias<<(QMAT_SHIFT - QUANT_BIAS_SHIFT); + bias= s->inter_quant_bias*(1<<(QMAT_SHIFT - QUANT_BIAS_SHIFT)); } threshold1= (1<idsp.perm_type != FF_IDCT_PERM_NONE) - ff_block_permute(block, s->idsp.idct_permutation, - scantable, last_non_zero); + block_permute(block, s->idsp.idct_permutation, + scantable, last_non_zero); return last_non_zero; } @@ -4624,12 +4701,17 @@ .init = ff_mpv_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, - .capabilities = CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_SLICE_THREADS, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, .priv_class = &h263p_class, }; -FF_MPV_GENERIC_CLASS(msmpeg4v2) +static const AVClass msmpeg4v2_class = { + .class_name = "msmpeg4v2 encoder", + .item_name = av_default_item_name, + .option = ff_mpv_generic_options, + .version = LIBAVUTIL_VERSION_INT, +}; AVCodec ff_msmpeg4v2_encoder = { .name = "msmpeg4v2", @@ -4644,7 +4726,12 @@ .priv_class = &msmpeg4v2_class, }; -FF_MPV_GENERIC_CLASS(msmpeg4v3) +static const AVClass msmpeg4v3_class = { + .class_name = "msmpeg4v3 encoder", + .item_name = av_default_item_name, + .option = ff_mpv_generic_options, + .version = LIBAVUTIL_VERSION_INT, +}; AVCodec ff_msmpeg4v3_encoder = { .name = "msmpeg4", @@ -4659,7 +4746,12 @@ .priv_class = &msmpeg4v3_class, }; -FF_MPV_GENERIC_CLASS(wmv1) +static const AVClass wmv1_class = { + .class_name = "wmv1 encoder", + .item_name = av_default_item_name, + .option = ff_mpv_generic_options, + .version = LIBAVUTIL_VERSION_INT, +}; AVCodec ff_wmv1_encoder = { .name = "wmv1", diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideoencdsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideoencdsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideoencdsp.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideoencdsp.c 2015-07-06 17:20:03.000000000 +0000 @@ -176,4 +176,6 @@ ff_mpegvideoencdsp_init_ppc(c, avctx); if (ARCH_X86) ff_mpegvideoencdsp_init_x86(c, avctx); + if (ARCH_MIPS) + ff_mpegvideoencdsp_init_mips(c, avctx); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideoencdsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideoencdsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideoencdsp.h 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideoencdsp.h 2015-07-06 17:20:03.000000000 +0000 @@ -52,5 +52,7 @@ AVCodecContext *avctx); void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c, AVCodecContext *avctx); +void ff_mpegvideoencdsp_init_mips(MpegvideoEncDSPContext *c, + AVCodecContext *avctx); #endif /* AVCODEC_MPEGVIDEOENCDSP_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideo.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideo.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideo.h 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideo.h 2015-07-30 17:20:02.000000000 +0000 @@ -39,8 +39,10 @@ #include "h263dsp.h" #include "hpeldsp.h" #include "idctdsp.h" +#include "internal.h" #include "me_cmp.h" #include "motion_est.h" +#include "mpegpicture.h" #include "mpegvideodsp.h" #include "mpegvideoencdsp.h" #include "pixblockdsp.h" @@ -61,7 +63,6 @@ #define MAX_FCODE 7 #define MAX_THREADS 32 -#define MAX_PICTURE_COUNT 36 #define MAX_B_FRAMES 16 @@ -71,8 +72,6 @@ #define INPLACE_OFFSET 16 -#define EDGE_WIDTH 16 - /* Start codes. */ #define SEQ_END_CODE 0x000001b7 #define SEQ_START_CODE 0x000001b3 @@ -84,67 +83,6 @@ #define USER_START_CODE 0x000001b2 /** - * Picture. - */ -typedef struct Picture{ - struct AVFrame *f; - ThreadFrame tf; - - AVBufferRef *qscale_table_buf; - int8_t *qscale_table; - - AVBufferRef *motion_val_buf[2]; - int16_t (*motion_val[2])[2]; - - AVBufferRef *mb_type_buf; - uint32_t *mb_type; ///< types and macros are defined in mpegutils.h - - AVBufferRef *mbskip_table_buf; - uint8_t *mbskip_table; - - AVBufferRef *ref_index_buf[2]; - int8_t *ref_index[2]; - - AVBufferRef *mb_var_buf; - uint16_t *mb_var; ///< Table for MB variances - - AVBufferRef *mc_mb_var_buf; - uint16_t *mc_mb_var; ///< Table for motion compensated MB variances - - int alloc_mb_width; ///< mb_width used to allocate tables - int alloc_mb_height; ///< mb_height used to allocate tables - - AVBufferRef *mb_mean_buf; - uint8_t *mb_mean; ///< Table for MB luminance - - AVBufferRef *hwaccel_priv_buf; - /** - * hardware accelerator private data - */ - void *hwaccel_picture_private; - - int field_picture; ///< whether or not the picture was encoded in separate fields - - int64_t mb_var_sum; ///< sum of MB variance for current frame - int64_t mc_mb_var_sum; ///< motion compensated MB variance for current frame - - int b_frame_score; - int needs_realloc; ///< Picture needs to be reallocated (eg due to a frame size change) - - int reference; - int shared; - - uint64_t error[AV_NUM_DATA_POINTERS]; -} Picture; - -typedef struct ScratchpadContext { - uint8_t *edge_emu_buffer; ///< temporary buffer for if MVs point to out-of-frame data - uint8_t *rd_scratchpad; ///< scratchpad for rate distortion mb decision - uint8_t *obmc_scratchpad; - uint8_t *b_scratchpad; ///< scratchpad used for writing into write only buffers -} ScratchpadContext; - -/** * MpegEncContext. */ typedef struct MpegEncContext { @@ -324,7 +262,10 @@ int16_t (*b_field_mv_table[2][2][2])[2];///< MV table (4MV per MB) interlaced b-frame encoding uint8_t (*p_field_select_table[2]); uint8_t (*b_field_select_table[2][2]); +#if FF_API_MOTION_EST int me_method; ///< ME algorithm +#endif + int motion_est; ///< ME algorithm int mv_dir; #define MV_DIR_FORWARD 1 #define MV_DIR_BACKWARD 2 @@ -435,6 +376,7 @@ uint8_t *mb_info_ptr; int mb_info_size; int ehc_mode; + int rc_strategy; /* H.263+ specific */ int umvplus; ///< == H263+ && unrestricted_mv @@ -597,6 +539,7 @@ float rc_buffer_aggressivity; float border_masking; int lmin, lmax; + int vbv_ignore_qmax; char *rc_eq; @@ -656,17 +599,16 @@ {"border_mask", "increase the quantizer for macroblocks close to borders", FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ {"lmin", "minimum Lagrange factor (VBR)", FF_MPV_OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 2*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"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 = 0 }, 0, 1, FF_MPV_OPT_FLAGS }, \ +{"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" }, \ +{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ extern const AVOption ff_mpv_generic_options[]; -#define FF_MPV_GENERIC_CLASS(name) \ -static const AVClass name ## _class = {\ - .class_name = #name " encoder",\ - .item_name = av_default_item_name,\ - .option = ff_mpv_generic_options,\ - .version = LIBAVUTIL_VERSION_INT,\ -}; - /** * Set the given MpegEncContext to common defaults (same for encoding * and decoding). The changed fields will not depend upon the prior @@ -682,6 +624,7 @@ void ff_mpv_common_init_neon(MpegEncContext *s); void ff_mpv_common_init_ppc(MpegEncContext *s); void ff_mpv_common_init_x86(MpegEncContext *s); +void ff_mpv_common_init_mips(MpegEncContext *s); int ff_mpv_common_frame_size_change(MpegEncContext *s); void ff_mpv_common_end(MpegEncContext *s); @@ -694,8 +637,6 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx); void ff_mpv_frame_end(MpegEncContext *s); -int ff_mpv_lowest_referenced_row(MpegEncContext *s, int dir); - int ff_mpv_encode_init(AVCodecContext *avctx); void ff_mpv_encode_init_x86(MpegEncContext *s); @@ -718,7 +659,6 @@ void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix); -int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared); int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src); int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); void ff_set_qscale(MpegEncContext * s, int qscale); @@ -738,24 +678,6 @@ op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16]); -/** - * Allocate a Picture. - * The pixels are allocated/set by calling get_buffer() if shared = 0. - */ -int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me, - ScratchpadContext *sc, int shared, int encoding, - int chroma_x_shift, int chroma_y_shift, int out_format, - int mb_stride, int mb_width, int mb_height, int b8_stride, - ptrdiff_t *linesize, ptrdiff_t *uvlinesize); - -int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, - ScratchpadContext *sc, int linesize); -/** - * permute block according to permuatation. - * @param last last non zero element in scantable order - */ -void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last); - static inline void ff_update_block_index(MpegEncContext *s){ const int block_size= 8 >> s->avctx->lowres; @@ -779,14 +701,4 @@ return bits - last; } -/* rv10.c */ -int ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number); -int ff_rv_decode_dc(MpegEncContext *s, int n); -void ff_rv20_encode_picture_header(MpegEncContext *s, int picture_number); - -int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src); -void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *picture); -void ff_free_picture_tables(Picture *pic); - - #endif /* AVCODEC_MPEGVIDEO_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideo_motion.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideo_motion.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideo_motion.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideo_motion.c 2015-07-28 17:20:07.000000000 +0000 @@ -88,7 +88,7 @@ } } - if (CONFIG_GRAY && s->avctx->flags & CODEC_FLAG_GRAY) + if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) return; motion_x = s->sprite_offset[1][0]; @@ -165,7 +165,7 @@ a + 1, (1 << (2 * a + 1)) - s->no_rounding, s->h_edge_pos, s->v_edge_pos); - if (CONFIG_GRAY && s->avctx->flags & CODEC_FLAG_GRAY) + if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) return; ox = s->sprite_offset[1][0] + s->sprite_delta[0][0] * s->mb_x * 8 + @@ -324,7 +324,7 @@ src_x, src_y, s->h_edge_pos, s->v_edge_pos); ptr_y = s->sc.edge_emu_buffer; - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize; uint8_t *vbuf = ubuf + 9 * s->uvlinesize; uvsrc_y = (unsigned)uvsrc_y << field_based; @@ -359,7 +359,7 @@ pix_op[0][dxy](dest_y, ptr_y, linesize, h); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { pix_op[s->chroma_x_shift][uvdxy] (dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift); pix_op[s->chroma_x_shift][uvdxy] @@ -547,7 +547,7 @@ src_x, src_y << field_based, s->h_edge_pos, s->v_edge_pos); ptr_y = s->sc.edge_emu_buffer; - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize; uint8_t *vbuf = ubuf + 9 * s->uvlinesize; s->vdsp.emulated_edge_mc(ubuf, ptr_cb, @@ -584,7 +584,7 @@ qpix_op[1][dxy](dest_y, ptr_y, linesize); qpix_op[1][dxy](dest_y + 8, ptr_y + 8, linesize); } - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { pix_op[1][uvdxy](dest_cr, ptr_cr, uvlinesize, h >> 1); pix_op[1][uvdxy](dest_cb, ptr_cb, uvlinesize, h >> 1); } @@ -740,7 +740,7 @@ mx += mv[0][0]; my += mv[0][1]; } - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my); @@ -813,7 +813,7 @@ } } - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideo_parser.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideo_parser.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideo_parser.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideo_parser.c 2015-07-13 17:20:03.000000000 +0000 @@ -47,6 +47,8 @@ int set_dim_ret = 0; int bit_rate = 0; int vbv_delay = 0; + int chroma_format; + enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; //FIXME replace the crap with get_bits() s->repeat_pict = 0; @@ -70,6 +72,7 @@ set_dim_ret = ff_set_dimensions(avctx, pc->width, pc->height); did_set_size=1; } + pix_fmt = AV_PIX_FMT_YUV420P; frame_rate_index = buf[3] & 0xf; pc->frame_rate = avctx->framerate = ff_mpeg12_frame_rate_tab[frame_rate_index]; bit_rate = (buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6); @@ -91,6 +94,13 @@ pc->progressive_sequence = buf[1] & (1 << 3); avctx->has_b_frames= !(buf[5] >> 7); + chroma_format = (buf[1] >> 1) & 3; + switch (chroma_format) { + case 1: pix_fmt = AV_PIX_FMT_YUV420P; break; + case 2: pix_fmt = AV_PIX_FMT_YUV422P; break; + case 3: pix_fmt = AV_PIX_FMT_YUV444P; break; + } + pc->width = (pc->width & 0xFFF) | (horiz_size_ext << 12); pc->height = (pc->height& 0xFFF) | ( vert_size_ext << 12); bit_rate = (bit_rate&0x3FFFF) | (bit_rate_ext << 18); @@ -155,6 +165,13 @@ ((avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && bit_rate != 0x3FFFF) || vbv_delay != 0xFFFF)) { avctx->bit_rate = 400*bit_rate; } + + if (pix_fmt != AV_PIX_FMT_NONE) { + s->format = pix_fmt; + s->width = s->coded_width = pc->width; + s->height = s->coded_height = pc->height; + } + #if FF_API_AVCTX_TIMEBASE if (avctx->framerate.num) avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1})); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideo_xvmc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideo_xvmc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mpegvideo_xvmc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mpegvideo_xvmc.c 2015-07-28 17:20:07.000000000 +0000 @@ -298,7 +298,7 @@ cbp++; } - if (s->avctx->flags & CODEC_FLAG_GRAY) { + if (s->avctx->flags & AV_CODEC_FLAG_GRAY) { if (s->mb_intra) { // intra frames are always full chroma blocks for (i = 4; i < blocks_per_mb; i++) { memset(s->pblocks[i], 0, sizeof(*s->pblocks[i])); // so we need to clear them diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mqcdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mqcdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mqcdec.c 2015-03-15 02:46:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mqcdec.c 2015-06-15 17:20:04.000000000 +0000 @@ -68,9 +68,11 @@ return d; } -void ff_mqc_initdec(MqcState *mqc, uint8_t *bp) +void ff_mqc_initdec(MqcState *mqc, uint8_t *bp, int raw, int reset) { - ff_mqc_init_contexts(mqc); + mqc->raw = raw; + if (reset) + ff_mqc_init_contexts(mqc); mqc->bp = bp; mqc->c = (*mqc->bp ^ 0xff) << 16; bytein(mqc); @@ -78,8 +80,20 @@ mqc->a = 0x8000; } +static int mqc_decode_bypass(MqcState *mqc) { + int bit = !(mqc->c & 0x40000000); + if (!(mqc->c & 0xff)) { + mqc->c -= 0x100; + bytein(mqc); + } + mqc->c += mqc->c; + return bit; +} + int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate) { + if (mqc->raw) + return mqc_decode_bypass(mqc); mqc->a -= ff_mqc_qe[*cxstate]; if ((mqc->c >> 16) < mqc->a) { if (mqc->a & 0x8000) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mqcenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mqcenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mqcenc.c 2014-12-01 00:21:43.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mqcenc.c 2015-06-21 17:20:02.000000000 +0000 @@ -25,6 +25,7 @@ * @author Kamil Nowosad */ +#include "libavutil/avassert.h" #include "mqc.h" static void byteout(MqcState *mqc) @@ -117,3 +118,22 @@ mqc->bp++; return mqc->bp - mqc->bpstart; } + +int ff_mqc_flush_to(MqcState *mqc, uint8_t *dst, int *dst_len) +{ + MqcState mqc2 = *mqc; + mqc2.bpstart= + mqc2.bp = dst; + *mqc2.bp = *mqc->bp; + ff_mqc_flush(&mqc2); + *dst_len = mqc2.bp - dst; + if (mqc->bp < mqc->bpstart) { + av_assert1(mqc->bpstart - mqc->bp == 1); + av_assert1(*dst_len > 0); + av_assert1(mqc->bp[0] == 0 && dst[0] == 0); + (*dst_len) --; + memmove(dst, dst+1, *dst_len); + return mqc->bp - mqc->bpstart + 1 + *dst_len; + } + return mqc->bp - mqc->bpstart + *dst_len; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mqc.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/mqc.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mqc.h 2015-03-15 02:46:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mqc.h 2015-06-18 17:20:02.000000000 +0000 @@ -43,6 +43,7 @@ unsigned int c; unsigned int ct; uint8_t cx_states[19]; + int raw; } MqcState; /* encoder */ @@ -58,6 +59,7 @@ /** flush the encoder [returns number of bytes encoded] */ int ff_mqc_flush(MqcState *mqc); +int ff_mqc_flush_to(MqcState *mqc, uint8_t *dst, int *dst_len); /* decoder */ @@ -65,8 +67,10 @@ * Initialize MQ-decoder. * @param mqc MQ decoder state * @param bp byte poiter + * @param raw raw mode + * @param reset reset states */ -void ff_mqc_initdec(MqcState *mqc, uint8_t *bp); +void ff_mqc_initdec(MqcState *mqc, uint8_t *bp, int raw, int reset); /** * MQ decoder. diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/msmpeg4dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/msmpeg4dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/msmpeg4dec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/msmpeg4dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -924,7 +924,7 @@ .init = ff_msmpeg4_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, .max_lowres = 3, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, @@ -941,7 +941,7 @@ .init = ff_msmpeg4_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, .max_lowres = 3, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, @@ -958,7 +958,7 @@ .init = ff_msmpeg4_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, .max_lowres = 3, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, @@ -975,7 +975,7 @@ .init = ff_msmpeg4_decode_init, .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, .max_lowres = 3, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/msrle.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/msrle.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/msrle.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/msrle.c 2015-07-28 17:20:07.000000000 +0000 @@ -166,5 +166,5 @@ .init = msrle_decode_init, .close = msrle_decode_end, .decode = msrle_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mss1.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mss1.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mss1.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mss1.c 2015-07-28 17:20:07.000000000 +0000 @@ -224,5 +224,5 @@ .init = mss1_decode_init, .close = mss1_decode_end, .decode = mss1_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mss2.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mss2.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mss2.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mss2.c 2015-07-28 17:20:07.000000000 +0000 @@ -52,9 +52,9 @@ c->value ^= 0x8000; c->low ^= 0x8000; } - c->high = c->high << 8 & 0xFFFFFF | 0xFF; - c->value = c->value << 8 & 0xFFFFFF | bytestream2_get_byte(c->gbc.gB); - c->low = c->low << 8 & 0xFFFFFF; + c->high = (uint16_t)c->high << 8 | 0xFF; + c->value = (uint16_t)c->value << 8 | bytestream2_get_byte(c->gbc.gB); + c->low = (uint16_t)c->low << 8; } } @@ -477,7 +477,7 @@ Rectangle wmv9rects[MAX_WMV9_RECTANGLES], *r; int used_rects = 0, i, implicit_rect = 0, av_uninit(wmv9_mask); - av_assert0(FF_INPUT_BUFFER_PADDING_SIZE >= + av_assert0(AV_INPUT_BUFFER_PADDING_SIZE >= ARITH2_PADDING + (MIN_CACHE_BITS + 7) / 8); if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0) @@ -849,5 +849,5 @@ .init = mss2_decode_init, .close = mss2_decode_end, .decode = mss2_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mss3.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mss3.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mss3.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mss3.c 2015-07-28 17:20:07.000000000 +0000 @@ -869,5 +869,5 @@ .init = mss3_decode_init, .close = mss3_decode_end, .decode = mss3_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mss4.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mss4.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mss4.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mss4.c 2015-07-28 17:20:07.000000000 +0000 @@ -679,5 +679,5 @@ .init = mss4_decode_init, .close = mss4_decode_end, .decode = mss4_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/msvideo1.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/msvideo1.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/msvideo1.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/msvideo1.c 2015-07-28 17:20:07.000000000 +0000 @@ -346,5 +346,5 @@ .init = msvideo1_decode_init, .close = msvideo1_decode_end, .decode = msvideo1_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/msvideo1enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/msvideo1enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/msvideo1enc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/msvideo1enc.c 2015-07-28 17:20:07.000000000 +0000 @@ -76,7 +76,7 @@ int skips = 0; int quality = 24; - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width*avctx->height*9 + FF_MIN_BUFFER_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width*avctx->height*9 + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return ret; dst= buf= pkt->data; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mvcdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mvcdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mvcdec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mvcdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -274,7 +274,7 @@ .init = mvc_decode_init, .close = mvc_decode_end, .decode = mvc_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif @@ -288,6 +288,6 @@ .init = mvc_decode_init, .close = mvc_decode_end, .decode = mvc_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/mxpegdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/mxpegdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/mxpegdec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/mxpegdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -343,7 +343,7 @@ .init = mxpeg_decode_init, .close = mxpeg_decode_end, .decode = mxpeg_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .max_lowres = 3, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/nellymoserdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/nellymoserdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/nellymoserdec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/nellymoserdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -121,7 +121,7 @@ av_lfg_init(&s->random_state, 0); ff_mdct_init(&s->imdct_ctx, 8, 1, 1.0); - s->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!s->fdsp) return AVERROR(ENOMEM); @@ -205,7 +205,7 @@ .init = decode_init, .close = decode_end, .decode = decode_tag, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_PARAM_CHANGE, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_PARAM_CHANGE, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/nellymoserenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/nellymoserenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/nellymoserenc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/nellymoserenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -171,7 +171,7 @@ s->avctx = avctx; if ((ret = ff_mdct_init(&s->mdct_ctx, 8, 0, 32768.0)) < 0) goto error; - s->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!s->fdsp) { ret = AVERROR(ENOMEM); goto error; @@ -397,7 +397,7 @@ s->last_frame = 1; } - if ((ret = ff_alloc_packet2(avctx, avpkt, NELLY_BLOCK_LEN)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, NELLY_BLOCK_LEN, 0)) < 0) return ret; encode_block(s, avpkt->data, avpkt->size); @@ -418,7 +418,7 @@ .init = encode_init, .encode2 = encode_frame, .close = encode_end, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/noise_bsf.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/noise_bsf.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/noise_bsf.c 2015-06-18 18:54:59.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/noise_bsf.c 2015-07-28 17:20:07.000000000 +0000 @@ -35,11 +35,11 @@ if(amount <= 0) return AVERROR(EINVAL); - *poutbuf= av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + *poutbuf= av_malloc(buf_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!*poutbuf) return AVERROR(ENOMEM); - memcpy(*poutbuf, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + memcpy(*poutbuf, buf, buf_size + AV_INPUT_BUFFER_PADDING_SIZE); for(i=0; iwidth || height != c->height) { // also reserve space for a possible additional header int buf_size = height * width * 3 / 2 - + FFMAX(AV_LZO_OUTPUT_PADDING, FF_INPUT_BUFFER_PADDING_SIZE) + + FFMAX(AV_LZO_OUTPUT_PADDING, AV_INPUT_BUFFER_PADDING_SIZE) + RTJPEG_HEADER_SIZE; if (buf_size > INT_MAX/8) return -1; @@ -208,15 +208,15 @@ buf = &buf[12]; buf_size -= 12; if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) { - int outlen = c->decomp_size - FFMAX(FF_INPUT_BUFFER_PADDING_SIZE, AV_LZO_OUTPUT_PADDING); + int outlen = c->decomp_size - FFMAX(AV_INPUT_BUFFER_PADDING_SIZE, AV_LZO_OUTPUT_PADDING); int inlen = buf_size; if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen)) { av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n"); return AVERROR_INVALIDDATA; } buf = c->decomp_buf; - buf_size = c->decomp_size - FFMAX(FF_INPUT_BUFFER_PADDING_SIZE, AV_LZO_OUTPUT_PADDING) - outlen; - memset(c->decomp_buf + buf_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + buf_size = c->decomp_size - FFMAX(AV_INPUT_BUFFER_PADDING_SIZE, AV_LZO_OUTPUT_PADDING) - outlen; + memset(c->decomp_buf + buf_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); } if (c->codec_frameheader) { int w, h, q; @@ -347,5 +347,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/nvenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/nvenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/nvenc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/nvenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -93,7 +93,7 @@ union { int64_t timestamp; NvencOutputSurface *surface; - }; + } u; } NvencData; typedef struct NvencDataList @@ -163,6 +163,7 @@ int cbr; int twopass; int gpu; + int buffer_delay; } NvencContext; static const NvencValuePair nvenc_h264_level_pairs[] = { @@ -296,7 +297,7 @@ static int out_surf_queue_enqueue(NvencDataList* queue, NvencOutputSurface* surface) { NvencData data; - data.surface = surface; + data.u.surface = surface; return data_queue_enqueue(queue, &data); } @@ -308,13 +309,13 @@ if (!res) return NULL; - return res->surface; + return res->u.surface; } static int timestamp_queue_enqueue(NvencDataList* queue, int64_t timestamp) { NvencData data; - data.timestamp = timestamp; + data.u.timestamp = timestamp; return data_queue_enqueue(queue, &data); } @@ -326,7 +327,7 @@ if (!res) return AV_NOPTS_VALUE; - return res->timestamp; + return res->u.timestamp; } #define CHECK_LOAD_FUNC(t, f, s) \ @@ -401,7 +402,7 @@ switch (avctx->codec->id) { case AV_CODEC_ID_H264: - target_smver = 0x30; + target_smver = avctx->pix_fmt == AV_PIX_FMT_YUV444P ? 0x52 : 0x30; break; case AV_CODEC_ID_H265: target_smver = 0x52; @@ -552,6 +553,7 @@ int surfaceCount = 0; int i, num_mbs; int isLL = 0; + int lossless = 0; int res = 0; int dw, dh; @@ -562,12 +564,6 @@ if (!nvenc_dyload_nvenc(avctx)) return AVERROR_EXTERNAL; - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) { - res = AVERROR(ENOMEM); - goto error; - } - ctx->last_dts = AV_NOPTS_VALUE; ctx->encode_config.version = NV_ENC_CONFIG_VER; @@ -627,10 +623,16 @@ } else if (!strcmp(ctx->preset, "llhq")) { encoder_preset = NV_ENC_PRESET_LOW_LATENCY_HQ_GUID; isLL = 1; + } else if (!strcmp(ctx->preset, "lossless")) { + encoder_preset = NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID; + lossless = 1; + } else if (!strcmp(ctx->preset, "losslesshp")) { + encoder_preset = NV_ENC_PRESET_LOSSLESS_HP_GUID; + lossless = 1; } else if (!strcmp(ctx->preset, "default")) { encoder_preset = NV_ENC_PRESET_DEFAULT_GUID; } else { - av_log(avctx, AV_LOG_FATAL, "Preset \"%s\" is unknown! Supported presets: hp, hq, bd, ll, llhp, llhq, default\n", ctx->preset); + av_log(avctx, AV_LOG_FATAL, "Preset \"%s\" is unknown! Supported presets: hp, hq, bd, ll, llhp, llhq, lossless, losslesshp, default\n", ctx->preset); res = AVERROR(EINVAL); goto error; } @@ -691,6 +693,9 @@ num_mbs = ((avctx->width + 15) >> 4) * ((avctx->height + 15) >> 4); ctx->max_surface_count = (num_mbs >= 8160) ? 32 : 48; + if (ctx->buffer_delay >= ctx->max_surface_count) + ctx->buffer_delay = ctx->max_surface_count - 1; + ctx->init_encode_params.enableEncodeAsync = 0; ctx->init_encode_params.enablePTD = 1; @@ -753,7 +758,16 @@ if (avctx->rc_max_rate > 0) ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate; - if (ctx->cbr) { + if (lossless) { + ctx->encode_config.encodeCodecConfig.h264Config.qpPrimeYZeroTransformBypassFlag = 1; + ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CONSTQP; + ctx->encode_config.rcParams.constQP.qpInterB = 0; + ctx->encode_config.rcParams.constQP.qpInterP = 0; + ctx->encode_config.rcParams.constQP.qpIntra = 0; + + avctx->qmin = -1; + avctx->qmax = -1; + } else if (ctx->cbr) { if (!ctx->twopass) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR; } else if (ctx->twopass == 1 || isLL) { @@ -763,9 +777,6 @@ ctx->encode_config.encodeCodecConfig.h264Config.adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE; ctx->encode_config.encodeCodecConfig.h264Config.fmoMode = NV_ENC_H264_FMO_DISABLE; } - - if (!isLL) - av_log(avctx, AV_LOG_WARNING, "Twopass mode is only known to work with low latency (ll, llhq, llhp) presets.\n"); } else { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR; } @@ -795,7 +806,7 @@ if (avctx->rc_buffer_size > 0) ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size; - if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) { + if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD; } else { ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME; @@ -812,11 +823,14 @@ ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag = avctx->color_range == AVCOL_RANGE_JPEG; - ctx->encode_config.encodeCodecConfig.h264Config.disableSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; - ctx->encode_config.encodeCodecConfig.h264Config.repeatSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; + ctx->encode_config.encodeCodecConfig.h264Config.disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; + ctx->encode_config.encodeCodecConfig.h264Config.repeatSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; if (!ctx->profile) { switch (avctx->profile) { + case FF_PROFILE_H264_HIGH_444_PREDICTIVE: + ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_444_GUID; + break; case FF_PROFILE_H264_BASELINE: ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID; break; @@ -842,6 +856,9 @@ } else if (!strcmp(ctx->profile, "baseline")) { ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID; avctx->profile = FF_PROFILE_H264_BASELINE; + } else if (!strcmp(ctx->profile, "high444p")) { + ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_444_GUID; + avctx->profile = FF_PROFILE_H264_HIGH_444_PREDICTIVE; } else { av_log(avctx, AV_LOG_FATAL, "Profile \"%s\" is unknown! Supported profiles: high, main, baseline\n", ctx->profile); res = AVERROR(EINVAL); @@ -849,6 +866,8 @@ } } + ctx->encode_config.encodeCodecConfig.h264Config.chromaFormatIDC = avctx->profile == FF_PROFILE_H264_HIGH_444_PREDICTIVE ? 3 : 1; + if (ctx->level) { res = input_string_to_uint32(avctx, nvenc_h264_level_pairs, ctx->level, &ctx->encode_config.encodeCodecConfig.h264Config.level); @@ -862,8 +881,8 @@ break; case AV_CODEC_ID_H265: - ctx->encode_config.encodeCodecConfig.hevcConfig.disableSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; - ctx->encode_config.encodeCodecConfig.hevcConfig.repeatSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; + ctx->encode_config.encodeCodecConfig.hevcConfig.disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; + ctx->encode_config.encodeCodecConfig.hevcConfig.repeatSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; /* No other profile is supported in the current SDK version 5 */ ctx->encode_config.profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID; @@ -978,7 +997,7 @@ ctx->output_surfaces[surfaceCount].busy = 0; } - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { uint32_t outSize = 0; char tmpHeader[256]; NV_ENC_SEQUENCE_PARAM_PAYLOAD payload = { 0 }; @@ -995,7 +1014,7 @@ } avctx->extradata_size = outSize; - avctx->extradata = av_mallocz(outSize + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_mallocz(outSize + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { res = AVERROR(ENOMEM); @@ -1027,8 +1046,6 @@ if (ctx->cu_context) dl_fn->cu_ctx_destroy(ctx->cu_context); - av_frame_free(&avctx->coded_frame); - nvenc_unload_nvenc(avctx); ctx->nvencoder = NULL; @@ -1062,12 +1079,10 @@ nvenc_unload_nvenc(avctx); - av_frame_free(&avctx->coded_frame); - return 0; } -static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, AVFrame *coded_frame, NvencOutputSurface *tmpoutsurf) +static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, NvencOutputSurface *tmpoutsurf) { NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; @@ -1109,7 +1124,7 @@ goto error; } - if (res = ff_alloc_packet2(avctx, pkt, lock_params.bitstreamSizeInBytes)) { + if (res = ff_alloc_packet2(avctx, pkt, lock_params.bitstreamSizeInBytes, 0)) { p_nvenc->nvEncUnlockBitstream(ctx->nvencoder, tmpoutsurf->output_surface); goto error; } @@ -1123,6 +1138,8 @@ switch (lock_params.pictureType) { case NV_ENC_PIC_TYPE_IDR: pkt->flags |= AV_PKT_FLAG_KEY; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS case NV_ENC_PIC_TYPE_I: avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; break; @@ -1140,6 +1157,8 @@ av_log(avctx, AV_LOG_ERROR, "Please report this error and include as much information on how to reproduce it as possible.\n"); res = AVERROR_EXTERNAL; goto error; +FF_ENABLE_DEPRECATION_WARNINGS +#endif } pkt->pts = lock_params.outputTimeStamp; @@ -1285,7 +1304,7 @@ pic_params.outputBitstream = ctx->output_surfaces[i].output_surface; pic_params.completionEvent = 0; - if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) { + if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { if (frame->top_field_first) { pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM; } else { @@ -1355,10 +1374,10 @@ } } - if (ctx->output_surface_ready_queue.count) { + if (ctx->output_surface_ready_queue.count && (!frame || ctx->output_surface_ready_queue.count + ctx->output_surface_queue.count >= ctx->buffer_delay)) { tmpoutsurf = out_surf_queue_dequeue(&ctx->output_surface_ready_queue); - res = process_output_surface(avctx, pkt, avctx->coded_frame, tmpoutsurf); + res = process_output_surface(avctx, pkt, tmpoutsurf); if (res) return res; @@ -1376,7 +1395,9 @@ } static const enum AVPixelFormat pix_fmts_nvenc[] = { + AV_PIX_FMT_YUV420P, AV_PIX_FMT_NV12, + AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE }; @@ -1388,8 +1409,9 @@ { "level", "Set the encoding level restriction (auto, 1.0, 1.0b, 1.1, 1.2, ..., 4.2, 5.0, 5.1)", OFFSET(level), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE }, { "tier", "Set the encoding tier (main or high)", OFFSET(tier), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE }, { "cbr", "Use cbr encoding mode", OFFSET(cbr), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, - { "2pass", "Use 2pass cbr encoding mode (low latency mode only)", OFFSET(twopass), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, + { "2pass", "Use 2pass cbr encoding mode", OFFSET(twopass), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, { "gpu", "Selects which NVENC capable GPU to use. First GPU is 0, second is 1, and so on.", OFFSET(gpu), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, + { "delay", "Delays frame output by the given amount of frames.", OFFSET(buffer_delay), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 0, INT_MAX, VE }, { NULL } }; @@ -1420,7 +1442,7 @@ .init = nvenc_encode_init, .encode2 = nvenc_encode_frame, .close = nvenc_encode_close, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .priv_class = &nvenc_class, .defaults = nvenc_defaults, .pix_fmts = pix_fmts_nvenc, @@ -1445,7 +1467,7 @@ .init = nvenc_encode_init, .encode2 = nvenc_encode_frame, .close = nvenc_encode_close, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .priv_class = &nvenc_h264_class, .defaults = nvenc_defaults, .pix_fmts = pix_fmts_nvenc, @@ -1469,7 +1491,7 @@ .init = nvenc_encode_init, .encode2 = nvenc_encode_frame, .close = nvenc_encode_close, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .priv_class = &nvenc_hevc_class, .defaults = nvenc_defaults, .pix_fmts = pix_fmts_nvenc, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/on2avc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/on2avc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/on2avc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/on2avc.c 2015-07-28 17:20:07.000000000 +0000 @@ -186,7 +186,7 @@ static inline float on2avc_scale(int v, float scale) { - return v * sqrtf(fabsf(v)) * scale; + return v * sqrtf(abs(v)) * scale; } // spectral data is coded completely differently - there are no unsigned codebooks @@ -951,7 +951,7 @@ ff_fft_init(&c->fft256, 7, 0); ff_fft_init(&c->fft512, 8, 1); ff_fft_init(&c->fft1024, 9, 1); - c->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + c->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!c->fdsp) return AVERROR(ENOMEM); @@ -1016,7 +1016,7 @@ .init = on2avc_decode_init, .decode = on2avc_decode_frame, .close = on2avc_decode_close, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/options.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/options.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/options.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/options.c 2015-07-28 17:20:07.000000000 +0000 @@ -33,7 +33,9 @@ #include /* FLT_MIN, FLT_MAX */ #include +FF_DISABLE_DEPRECATION_WARNINGS #include "options_table.h" +FF_ENABLE_DEPRECATION_WARNINGS static const char* context_to_name(void* ptr) { AVCodecContext *avc= ptr; @@ -230,7 +232,7 @@ memset(((uint8_t *) dest->obj) + size, 0, pad); \ } alloc_and_copy_or_fail(extradata, src->extradata_size, - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); dest->extradata_size = src->extradata_size; alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0); alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0); @@ -316,7 +318,6 @@ //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); - ctx->coded_frame = av_frame_alloc(); return 0; } @@ -324,7 +325,6 @@ { av_freep(&ctx->extradata); ctx->extradata_size = 0; - av_frame_free(&ctx->coded_frame); return 0; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/options_table.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/options_table.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/options_table.h 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/options_table.h 2015-07-28 17:20:07.000000000 +0000 @@ -49,11 +49,11 @@ "to minimum/maximum bitrate. Lowering tolerance too much has an adverse effect on quality.", OFFSET(bit_rate_tolerance), AV_OPT_TYPE_INT, {.i64 = AV_CODEC_DEFAULT_BITRATE*20 }, 1, INT_MAX, V|E}, {"flags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, 0, UINT_MAX, V|A|S|E|D, "flags"}, -{"unaligned", "allow decoders to produce unaligned output", 0, AV_OPT_TYPE_CONST, { .i64 = CODEC_FLAG_UNALIGNED }, INT_MIN, INT_MAX, V | D, "flags" }, -{"mv4", "use four motion vectors per macroblock (MPEG-4)", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_4MV }, INT_MIN, INT_MAX, V|E, "flags"}, -{"qpel", "use 1/4-pel motion compensation", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_QPEL }, INT_MIN, INT_MAX, V|E, "flags"}, -{"loop", "use loop filter", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_LOOP_FILTER }, INT_MIN, INT_MAX, V|E, "flags"}, -{"qscale", "use fixed qscale", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_QSCALE }, INT_MIN, INT_MAX, 0, "flags"}, +{"unaligned", "allow decoders to produce unaligned output", 0, AV_OPT_TYPE_CONST, { .i64 = AV_CODEC_FLAG_UNALIGNED }, INT_MIN, INT_MAX, V | D, "flags" }, +{"mv4", "use four motion vectors per macroblock (MPEG-4)", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_4MV }, INT_MIN, INT_MAX, V|E, "flags"}, +{"qpel", "use 1/4-pel motion compensation", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_QPEL }, INT_MIN, INT_MAX, V|E, "flags"}, +{"loop", "use loop filter", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_LOOP_FILTER }, INT_MIN, INT_MAX, V|E, "flags"}, +{"qscale", "use fixed qscale", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_QSCALE }, INT_MIN, INT_MAX, 0, "flags"}, #if FF_API_GMC {"gmc", "use gmc", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_GMC }, INT_MIN, INT_MAX, V|E, "flags"}, #endif @@ -63,33 +63,34 @@ #if FF_API_INPUT_PRESERVED {"input_preserved", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_INPUT_PRESERVED }, INT_MIN, INT_MAX, 0, "flags"}, #endif -{"pass1", "use internal 2-pass ratecontrol in first pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"}, -{"pass2", "use internal 2-pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"}, -{"gray", "only decode/encode grayscale", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"}, +{"pass1", "use internal 2-pass ratecontrol in first pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"}, +{"pass2", "use internal 2-pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"}, +{"gray", "only decode/encode grayscale", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"}, #if FF_API_EMU_EDGE {"emu_edge", "do not draw edges", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_EMU_EDGE }, INT_MIN, INT_MAX, 0, "flags"}, #endif -{"psnr", "error[?] variables will be set during encoding", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_PSNR }, INT_MIN, INT_MAX, V|E, "flags"}, -{"truncated", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_TRUNCATED }, INT_MIN, INT_MAX, 0, "flags"}, +{"psnr", "error[?] variables will be set during encoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PSNR }, INT_MIN, INT_MAX, V|E, "flags"}, +{"truncated", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_TRUNCATED }, INT_MIN, INT_MAX, 0, "flags"}, #if FF_API_NORMALIZE_AQP {"naq", "normalize adaptive quantization", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_NORMALIZE_AQP }, INT_MIN, INT_MAX, V|E, "flags"}, #endif -{"ildct", "use interlaced DCT", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_INTERLACED_DCT }, INT_MIN, INT_MAX, V|E, "flags"}, -{"low_delay", "force low delay", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_LOW_DELAY }, INT_MIN, INT_MAX, V|D|E, "flags"}, -{"global_header", "place global headers in extradata instead of every keyframe", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_GLOBAL_HEADER }, INT_MIN, INT_MAX, V|A|E, "flags"}, -{"bitexact", "use only bitexact functions (except (I)DCT)", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_BITEXACT }, INT_MIN, INT_MAX, A|V|S|D|E, "flags"}, -{"aic", "H.263 advanced intra coding / MPEG-4 AC prediction", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_AC_PRED }, INT_MIN, INT_MAX, V|E, "flags"}, -{"ilme", "interlaced motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_INTERLACED_ME }, INT_MIN, INT_MAX, V|E, "flags"}, -{"cgop", "closed GOP", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_CLOSED_GOP }, INT_MIN, INT_MAX, V|E, "flags"}, -{"output_corrupt", "Output even potentially corrupted frames", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_OUTPUT_CORRUPT }, INT_MIN, INT_MAX, V|D, "flags"}, -{"fast", "allow non-spec-compliant speedup tricks", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_FAST }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"ignorecrop", "ignore cropping information from sps", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_IGNORE_CROP }, INT_MIN, INT_MAX, V|D, "flags2"}, -{"local_header", "place global headers at every keyframe instead of in extradata", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_LOCAL_HEADER }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"chunks", "Frame data might be split into multiple chunks", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_CHUNKS }, INT_MIN, INT_MAX, V|D, "flags2"}, -{"showall", "Show all frames before the first keyframe", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_SHOW_ALL }, INT_MIN, INT_MAX, V|D, "flags2"}, -{"export_mvs", "export motion vectors through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_EXPORT_MVS}, INT_MIN, INT_MAX, V|D, "flags2"}, -{"skip_manual", "do not skip samples and export skip information as frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_SKIP_MANUAL}, INT_MIN, INT_MAX, V|D, "flags2"}, +{"ildct", "use interlaced DCT", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_INTERLACED_DCT }, INT_MIN, INT_MAX, V|E, "flags"}, +{"low_delay", "force low delay", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_LOW_DELAY }, INT_MIN, INT_MAX, V|D|E, "flags"}, +{"global_header", "place global headers in extradata instead of every keyframe", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_GLOBAL_HEADER }, INT_MIN, INT_MAX, V|A|E, "flags"}, +{"bitexact", "use only bitexact functions (except (I)DCT)", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_BITEXACT }, INT_MIN, INT_MAX, A|V|S|D|E, "flags"}, +{"aic", "H.263 advanced intra coding / MPEG-4 AC prediction", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_AC_PRED }, INT_MIN, INT_MAX, V|E, "flags"}, +{"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"}, +{"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"}, +{"local_header", "place global headers at every keyframe instead of in extradata", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_LOCAL_HEADER }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"chunks", "Frame data might be split into multiple chunks", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_CHUNKS }, INT_MIN, INT_MAX, V|D, "flags2"}, +{"showall", "Show all frames before the first keyframe", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_SHOW_ALL }, INT_MIN, INT_MAX, V|D, "flags2"}, +{"export_mvs", "export motion vectors through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_EXPORT_MVS}, INT_MIN, INT_MAX, V|D, "flags2"}, +{"skip_manual", "do not skip samples and export skip information as frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_SKIP_MANUAL}, INT_MIN, INT_MAX, V|D, "flags2"}, +#if FF_API_MOTION_EST {"me_method", "set motion estimation method", OFFSET(me_method), AV_OPT_TYPE_INT, {.i64 = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method"}, {"zero", "zero motion estimation (fastest)", 0, AV_OPT_TYPE_CONST, {.i64 = ME_ZERO }, INT_MIN, INT_MAX, V|E, "me_method" }, {"full", "full motion estimation (slowest)", 0, AV_OPT_TYPE_CONST, {.i64 = ME_FULL }, INT_MIN, INT_MAX, V|E, "me_method" }, @@ -103,6 +104,7 @@ {"hex", "hex motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_HEX }, INT_MIN, INT_MAX, V|E, "me_method" }, {"umh", "umh motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_UMH }, INT_MIN, INT_MAX, V|E, "me_method" }, {"iter", "iter motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_ITER }, INT_MIN, INT_MAX, V|E, "me_method" }, +#endif {"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, INT_MIN, INT_MAX}, {"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E}, {"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E}, @@ -120,7 +122,9 @@ {"qdiff", "maximum difference between the quantizer scales (VBR)", OFFSET(max_qdiff), AV_OPT_TYPE_INT, {.i64 = 3 }, INT_MIN, INT_MAX, V|E}, {"bf", "set maximum number of B frames between non-B-frames", OFFSET(max_b_frames), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, -1, INT_MAX, V|E}, {"b_qfactor", "QP factor between P- and B-frames", OFFSET(b_quant_factor), AV_OPT_TYPE_FLOAT, {.dbl = 1.25 }, -FLT_MAX, FLT_MAX, V|E}, +#if FF_API_RC_STRATEGY {"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, +#endif {"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, V|E}, {"ps", "RTP payload size in bytes", OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"mv_bits", NULL, OFFSET(mv_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, @@ -253,6 +257,7 @@ {"mv", "motion vector", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_MV }, INT_MIN, INT_MAX, V|D, "debug"}, #endif {"dct_coeff", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_DCT_COEFF }, INT_MIN, INT_MAX, V|D, "debug"}, +{"green_metadata", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_GREEN_MD }, INT_MIN, INT_MAX, V|D, "debug"}, {"skip", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_SKIP }, INT_MIN, INT_MAX, V|D, "debug"}, {"startcode", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_STARTCODE }, INT_MIN, INT_MAX, V|D, "debug"}, #if FF_API_UNUSED_MEMBERS @@ -299,10 +304,14 @@ {"chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_CHROMA }, 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}, +#if FF_API_AFD {"dtg_active_format", NULL, OFFSET(dtg_active_format), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, +#endif {"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}, +#if FF_API_QUANT_BIAS {"ibias", "intra quant bias", OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E}, {"pbias", "inter quant bias", OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E}, +#endif {"global_quality", NULL, OFFSET(global_quality), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E}, {"coder", NULL, OFFSET(coder_type), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "coder"}, {"vlc", "variable length coder / Huffman coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_VLC }, INT_MIN, INT_MAX, V|E, "coder"}, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/opus_celt.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/opus_celt.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/opus_celt.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/opus_celt.c 2015-07-28 17:20:07.000000000 +0000 @@ -2209,7 +2209,7 @@ goto fail; } - s->dsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + s->dsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!s->dsp) { ret = AVERROR(ENOMEM); goto fail; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/opusdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/opusdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/opusdec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/opusdec.c 2015-08-02 17:20:02.000000000 +0000 @@ -364,12 +364,17 @@ static int opus_decode_subpacket(OpusStreamContext *s, const uint8_t *buf, int buf_size, + float **out, int out_size, int nb_samples) { int output_samples = 0; int flush_needed = 0; int i, j, ret; + s->out[0] = out[0]; + s->out[1] = out[1]; + s->out_size = out_size; + /* check if we need to flush the resampler */ if (swr_is_initialized(s->swr)) { if (buf) { @@ -447,15 +452,17 @@ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int coded_samples = 0; - int decoded_samples = 0; - int i, ret; + int decoded_samples = INT_MAX; int delayed_samples = 0; + int i, ret; + /* calculate the number of delayed samples */ for (i = 0; i < c->nb_streams; i++) { OpusStreamContext *s = &c->streams[i]; s->out[0] = s->out[1] = NULL; - delayed_samples = FFMAX(delayed_samples, s->delayed_samples); + delayed_samples = FFMAX(delayed_samples, + s->delayed_samples + av_audio_fifo_size(c->sync_buffers[i])); } /* decode the header of the first sub-packet to find out the sample count */ @@ -484,14 +491,43 @@ return ret; frame->nb_samples = 0; + memset(c->out, 0, c->nb_streams * 2 * sizeof(*c->out)); for (i = 0; i < avctx->channels; i++) { ChannelMap *map = &c->channel_maps[i]; if (!map->copy) - c->streams[map->stream_idx].out[map->channel_idx] = (float*)frame->extended_data[i]; + c->out[2 * map->stream_idx + map->channel_idx] = (float*)frame->extended_data[i]; } - for (i = 0; i < c->nb_streams; i++) - c->streams[i].out_size = frame->linesize[0]; + /* read the data from the sync buffers */ + for (i = 0; i < c->nb_streams; i++) { + float **out = c->out + 2 * i; + int sync_size = av_audio_fifo_size(c->sync_buffers[i]); + + float sync_dummy[32]; + int out_dummy = (!out[0]) | ((!out[1]) << 1); + + if (!out[0]) + out[0] = sync_dummy; + if (!out[1]) + out[1] = sync_dummy; + if (out_dummy && sync_size > FF_ARRAY_ELEMS(sync_dummy)) + return AVERROR_BUG; + + ret = av_audio_fifo_read(c->sync_buffers[i], (void**)out, sync_size); + if (ret < 0) + return ret; + + if (out_dummy & 1) + out[0] = NULL; + else + out[0] += ret; + if (out_dummy & 2) + out[1] = NULL; + else + out[1] += ret; + + c->out_size[i] = frame->linesize[0] - ret * sizeof(float); + } /* decode each sub-packet */ for (i = 0; i < c->nb_streams; i++) { @@ -512,20 +548,31 @@ s->silk_samplerate = get_silk_samplerate(s->packet.config); } - ret = opus_decode_subpacket(&c->streams[i], buf, - s->packet.data_size, coded_samples); + ret = opus_decode_subpacket(&c->streams[i], buf, s->packet.data_size, + c->out + 2 * i, c->out_size[i], coded_samples); if (ret < 0) return ret; - if (decoded_samples && ret != decoded_samples) { - av_log(avctx, AV_LOG_ERROR, "Different numbers of decoded samples " - "in a multi-channel stream\n"); - return AVERROR_INVALIDDATA; - } - decoded_samples = ret; + c->decoded_samples[i] = ret; + decoded_samples = FFMIN(decoded_samples, ret); + buf += s->packet.packet_size; buf_size -= s->packet.packet_size; } + /* buffer the extra samples */ + for (i = 0; i < c->nb_streams; i++) { + int buffer_samples = c->decoded_samples[i] - decoded_samples; + if (buffer_samples) { + float *buf[2] = { c->out[2 * i + 0] ? c->out[2 * i + 0] : (float*)frame->extended_data[0], + c->out[2 * i + 1] ? c->out[2 * i + 1] : (float*)frame->extended_data[0] }; + buf[0] += buffer_samples; + buf[1] += buffer_samples; + ret = av_audio_fifo_write(c->sync_buffers[i], (void**)buf, buffer_samples); + if (ret < 0) + return ret; + } + } + for (i = 0; i < avctx->channels; i++) { ChannelMap *map = &c->channel_maps[i]; @@ -566,6 +613,8 @@ av_audio_fifo_drain(s->celt_delay, av_audio_fifo_size(s->celt_delay)); swr_close(s->swr); + av_audio_fifo_drain(c->sync_buffers[i], av_audio_fifo_size(c->sync_buffers[i])); + ff_silk_flush(s->silk); ff_celt_flush(s->celt); } @@ -590,6 +639,16 @@ } av_freep(&c->streams); + + if (c->sync_buffers) { + for (i = 0; i < c->nb_streams; i++) + av_audio_fifo_free(c->sync_buffers[i]); + } + av_freep(&c->sync_buffers); + av_freep(&c->decoded_samples); + av_freep(&c->out); + av_freep(&c->out_size); + c->nb_streams = 0; av_freep(&c->channel_maps); @@ -617,7 +676,11 @@ /* allocate and init each independent decoder */ c->streams = av_mallocz_array(c->nb_streams, sizeof(*c->streams)); - if (!c->streams) { + c->out = av_mallocz_array(c->nb_streams, 2 * sizeof(*c->out)); + c->out_size = av_mallocz_array(c->nb_streams, sizeof(*c->out_size)); + c->sync_buffers = av_mallocz_array(c->nb_streams, sizeof(*c->sync_buffers)); + c->decoded_samples = av_mallocz_array(c->nb_streams, sizeof(*c->decoded_samples)); + if (!c->streams || !c->sync_buffers || !c->decoded_samples || !c->out || !c->out_size) { c->nb_streams = 0; ret = AVERROR(ENOMEM); goto fail; @@ -665,6 +728,13 @@ ret = AVERROR(ENOMEM); goto fail; } + + c->sync_buffers[i] = av_audio_fifo_alloc(avctx->sample_fmt, + s->output_channels, 32); + if (!c->sync_buffers[i]) { + ret = AVERROR(ENOMEM); + goto fail; + } } return 0; @@ -683,5 +753,5 @@ .close = opus_decode_close, .decode = opus_decode_packet, .flush = opus_decode_flush, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/opus.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/opus.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/opus.h 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/opus.h 2015-08-02 17:20:02.000000000 +0000 @@ -173,6 +173,16 @@ typedef struct OpusContext { OpusStreamContext *streams; + + /* current output buffers for each streams */ + float **out; + int *out_size; + /* Buffers for synchronizing the streams when they have different + * resampling delays */ + AVAudioFifo **sync_buffers; + /* number of decoded samples for each stream */ + int *decoded_samples; + int nb_streams; int nb_stereo_streams; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pafaudio.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pafaudio.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pafaudio.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pafaudio.c 2015-07-28 17:20:07.000000000 +0000 @@ -78,5 +78,5 @@ .id = AV_CODEC_ID_PAF_AUDIO, .init = paf_audio_init, .decode = paf_audio_decode, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pafvideo.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pafvideo.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pafvideo.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pafvideo.c 2015-07-28 17:20:07.000000000 +0000 @@ -393,5 +393,5 @@ .init = paf_video_init, .close = paf_video_close, .decode = paf_video_decode, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pamenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pamenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pamenc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pamenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -91,7 +91,7 @@ return -1; } - if ((ret = ff_alloc_packet2(avctx, pkt, n*h + 200)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, n*h + 200, 0)) < 0) return ret; bytestream_start = @@ -129,29 +129,22 @@ static av_cold int pam_encode_init(AVCodecContext *avctx) { - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif return 0; } -static av_cold int pam_encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - return 0; -} - AVCodec ff_pam_encoder = { .name = "pam", .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PAM, .init = pam_encode_init, - .close = pam_encode_close, .encode2 = pam_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/parser.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/parser.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/parser.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/parser.c 2015-07-28 17:20:07.000000000 +0000 @@ -134,7 +134,7 @@ int64_t pts, int64_t dts, int64_t pos) { int index, i; - uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE]; + uint8_t dummy_buf[AV_INPUT_BUFFER_PADDING_SIZE]; if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) { s->next_frame_offset = @@ -188,8 +188,8 @@ const uint8_t *buf, int buf_size, int keyframe) { if (s && s->parser->split) { - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER || - avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER) { + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER || + avctx->flags2 & AV_CODEC_FLAG2_LOCAL_HEADER) { int i = s->parser->split(avctx, buf, buf_size); buf += i; buf_size -= i; @@ -200,17 +200,17 @@ *poutbuf = (uint8_t *) buf; *poutbuf_size = buf_size; if (avctx->extradata) { - if (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)) { + if (keyframe && (avctx->flags2 & AV_CODEC_FLAG2_LOCAL_HEADER)) { int size = buf_size + avctx->extradata_size; *poutbuf_size = size; - *poutbuf = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); + *poutbuf = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE); if (!*poutbuf) return AVERROR(ENOMEM); memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); memcpy(*poutbuf + avctx->extradata_size, buf, - buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + buf_size + AV_INPUT_BUFFER_PADDING_SIZE); return 1; } } @@ -252,10 +252,10 @@ if (next == END_NOT_FOUND) { void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, *buf_size + pc->index + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!new_buffer) { - av_log(NULL, AV_LOG_ERROR, "Failed to reallocate parser buffer to %d\n", *buf_size + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); + av_log(NULL, AV_LOG_ERROR, "Failed to reallocate parser buffer to %d\n", *buf_size + pc->index + AV_INPUT_BUFFER_PADDING_SIZE); pc->index = 0; return AVERROR(ENOMEM); } @@ -272,17 +272,17 @@ if (pc->index) { void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!new_buffer) { - av_log(NULL, AV_LOG_ERROR, "Failed to reallocate parser buffer to %d\n", next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); + av_log(NULL, AV_LOG_ERROR, "Failed to reallocate parser buffer to %d\n", next + pc->index + AV_INPUT_BUFFER_PADDING_SIZE); pc->overread_index = pc->index = 0; return AVERROR(ENOMEM); } pc->buffer = new_buffer; - if (next > -FF_INPUT_BUFFER_PADDING_SIZE) + if (next > -AV_INPUT_BUFFER_PADDING_SIZE) memcpy(&pc->buffer[pc->index], *buf, - next + FF_INPUT_BUFFER_PADDING_SIZE); + next + AV_INPUT_BUFFER_PADDING_SIZE); pc->index = 0; *buf = pc->buffer; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pcm-bluray.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pcm-bluray.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pcm-bluray.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pcm-bluray.c 2015-07-28 17:20:07.000000000 +0000 @@ -307,7 +307,7 @@ .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_PCM_BLURAY, .decode = pcm_bluray_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pcm.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pcm.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pcm.c 2015-06-18 18:54:59.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pcm.c 2015-08-03 17:20:02.000000000 +0000 @@ -97,7 +97,7 @@ n = frame->nb_samples * avctx->channels; samples = (const short *)frame->data[0]; - if ((ret = ff_alloc_packet2(avctx, avpkt, n * sample_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, n * sample_size, n * sample_size)) < 0) return ret; dst = avpkt->data; @@ -501,7 +501,7 @@ .id = AV_CODEC_ID_ ## id_, \ .init = pcm_encode_init, \ .encode2 = pcm_encode_frame, \ - .capabilities = CODEC_CAP_VARIABLE_FRAME_SIZE, \ + .capabilities = AV_CODEC_CAP_VARIABLE_FRAME_SIZE, \ .sample_fmts = (const enum AVSampleFormat[]){ sample_fmt_, \ AV_SAMPLE_FMT_NONE }, \ } @@ -523,7 +523,7 @@ .priv_data_size = sizeof(PCMDecode), \ .init = pcm_decode_init, \ .decode = pcm_decode_frame, \ - .capabilities = CODEC_CAP_DR1, \ + .capabilities = AV_CODEC_CAP_DR1, \ .sample_fmts = (const enum AVSampleFormat[]){ sample_fmt_, \ AV_SAMPLE_FMT_NONE }, \ } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pcm-dvd.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pcm-dvd.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pcm-dvd.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pcm-dvd.c 2015-07-28 17:20:07.000000000 +0000 @@ -73,7 +73,7 @@ s->last_header = -1; if (avctx->debug & FF_DEBUG_PICT_INFO) - ff_dlog(avctx, "pcm_dvd_parse_header: header = %02x%02x%02x\n", + av_log(avctx, AV_LOG_DEBUG, "pcm_dvd_parse_header: header = %02x%02x%02x\n", header[0], header[1], header[2]); /* * header[0] emphasis (1), muse(1), reserved(1), frame number(5) @@ -311,7 +311,7 @@ .init = pcm_dvd_decode_init, .decode = pcm_dvd_decode_frame, .close = pcm_dvd_decode_uninit, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pcx.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pcx.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pcx.c 2015-06-18 18:54:59.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pcx.c 2015-07-28 17:20:07.000000000 +0000 @@ -143,7 +143,7 @@ ptr = p->data[0]; stride = p->linesize[0]; - scanline = av_malloc(bytes_per_scanline + FF_INPUT_BUFFER_PADDING_SIZE); + scanline = av_malloc(bytes_per_scanline + AV_INPUT_BUFFER_PADDING_SIZE); if (!scanline) return AVERROR(ENOMEM); @@ -239,5 +239,5 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PCX, .decode = pcx_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pcxenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pcxenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pcxenc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pcxenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -35,22 +35,16 @@ static av_cold int pcx_encode_init(AVCodecContext *avctx) { - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif return 0; } -static av_cold int pcx_encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - return 0; -} - /** * PCX run-length encoder * @param dst output buffer @@ -151,7 +145,7 @@ line_bytes = (line_bytes + 1) & ~1; max_pkt_size = 128 + avctx->height * 2 * line_bytes * nplanes + (pal ? 256*3 + 1 : 0); - if ((ret = ff_alloc_packet2(avctx, pkt, max_pkt_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, max_pkt_size, 0)) < 0) return ret; buf = pkt->data; buf_end = pkt->data + pkt->size; @@ -216,7 +210,6 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PCX, .init = pcx_encode_init, - .close = pcx_encode_close, .encode2 = pcx_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_RGB24, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pictordec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pictordec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pictordec.c 2015-06-18 18:54:59.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pictordec.c 2015-07-28 17:20:07.000000000 +0000 @@ -263,5 +263,5 @@ .id = AV_CODEC_ID_PICTOR, .priv_data_size = sizeof(PicContext), .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pixblockdsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pixblockdsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pixblockdsp.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pixblockdsp.c 2015-06-29 17:20:04.000000000 +0000 @@ -79,4 +79,6 @@ ff_pixblockdsp_init_ppc(c, avctx, high_bit_depth); if (ARCH_X86) ff_pixblockdsp_init_x86(c, avctx, high_bit_depth); + if (ARCH_MIPS) + ff_pixblockdsp_init_mips(c, avctx, high_bit_depth); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pixblockdsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/pixblockdsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pixblockdsp.h 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pixblockdsp.h 2015-06-29 17:20:04.000000000 +0000 @@ -42,5 +42,7 @@ unsigned high_bit_depth); void ff_pixblockdsp_init_x86(PixblockDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); +void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth); #endif /* AVCODEC_PIXBLOCKDSP_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pngdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pngdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pngdec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pngdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -542,18 +542,18 @@ return AVERROR_INVALIDDATA; } - s->width = bytestream2_get_be32(&s->gb); - s->height = bytestream2_get_be32(&s->gb); + if (s->state & PNG_IHDR) { + av_log(avctx, AV_LOG_ERROR, "Multiple IHDR\n"); + return AVERROR_INVALIDDATA; + } + + s->width = s->cur_w = bytestream2_get_be32(&s->gb); + s->height = s->cur_h = bytestream2_get_be32(&s->gb); if (av_image_check_size(s->width, s->height, 0, avctx)) { - s->width = s->height = 0; + s->cur_w = s->cur_h = s->width = s->height = 0; av_log(avctx, AV_LOG_ERROR, "Invalid image size\n"); return AVERROR_INVALIDDATA; } - if (s->cur_w == 0 && s->cur_h == 0) { - // Only set cur_w/h if update_thread_context() has not set it - s->cur_w = s->width; - s->cur_h = s->height; - } s->bit_depth = bytestream2_get_byte(&s->gb); s->color_type = bytestream2_get_byte(&s->gb); s->compression_type = bytestream2_get_byte(&s->gb); @@ -643,6 +643,11 @@ if ((ret = ff_thread_get_buffer(avctx, &s->picture, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; + if (avctx->codec_id == AV_CODEC_ID_APNG && s->last_dispose_op != APNG_DISPOSE_OP_PREVIOUS) { + ff_thread_release_buffer(avctx, &s->previous_picture); + if ((ret = ff_thread_get_buffer(avctx, &s->previous_picture, AV_GET_BUFFER_FLAG_REF)) < 0) + return ret; + } ff_thread_finish_setup(avctx); p->pict_type = AV_PICTURE_TYPE_I; @@ -815,10 +820,16 @@ uint32_t length) { uint32_t sequence_number; + int cur_w, cur_h, x_offset, y_offset, dispose_op, blend_op; if (length != 26) return AVERROR_INVALIDDATA; + if (!(s->state & PNG_IHDR)) { + av_log(avctx, AV_LOG_ERROR, "fctl before IHDR\n"); + return AVERROR_INVALIDDATA; + } + s->last_w = s->cur_w; s->last_h = s->cur_h; s->last_x_offset = s->x_offset; @@ -826,32 +837,32 @@ s->last_dispose_op = s->dispose_op; sequence_number = bytestream2_get_be32(&s->gb); - s->cur_w = bytestream2_get_be32(&s->gb); - s->cur_h = bytestream2_get_be32(&s->gb); - s->x_offset = bytestream2_get_be32(&s->gb); - s->y_offset = bytestream2_get_be32(&s->gb); + cur_w = bytestream2_get_be32(&s->gb); + cur_h = bytestream2_get_be32(&s->gb); + x_offset = bytestream2_get_be32(&s->gb); + y_offset = bytestream2_get_be32(&s->gb); bytestream2_skip(&s->gb, 4); /* delay_num (2), delay_den (2) */ - s->dispose_op = bytestream2_get_byte(&s->gb); - s->blend_op = bytestream2_get_byte(&s->gb); + dispose_op = bytestream2_get_byte(&s->gb); + blend_op = bytestream2_get_byte(&s->gb); bytestream2_skip(&s->gb, 4); /* crc */ if (sequence_number == 0 && - (s->cur_w != s->width || - s->cur_h != s->height || - s->x_offset != 0 || - s->y_offset != 0) || - s->cur_w <= 0 || s->cur_h <= 0 || - s->x_offset < 0 || s->y_offset < 0 || - s->cur_w > s->width - s->x_offset|| s->cur_h > s->height - s->y_offset) + (cur_w != s->width || + cur_h != s->height || + x_offset != 0 || + y_offset != 0) || + cur_w <= 0 || cur_h <= 0 || + x_offset < 0 || y_offset < 0 || + cur_w > s->width - x_offset|| cur_h > s->height - y_offset) return AVERROR_INVALIDDATA; - if (sequence_number == 0 && s->dispose_op == APNG_DISPOSE_OP_PREVIOUS) { + if (sequence_number == 0 && dispose_op == APNG_DISPOSE_OP_PREVIOUS) { // No previous frame to revert to for the first frame // Spec says to just treat it as a APNG_DISPOSE_OP_BACKGROUND - s->dispose_op = APNG_DISPOSE_OP_BACKGROUND; + dispose_op = APNG_DISPOSE_OP_BACKGROUND; } - if (s->dispose_op == APNG_BLEND_OP_OVER && !s->has_trns && ( + if (blend_op == APNG_BLEND_OP_OVER && !s->has_trns && ( avctx->pix_fmt == AV_PIX_FMT_RGB24 || avctx->pix_fmt == AV_PIX_FMT_RGB48BE || avctx->pix_fmt == AV_PIX_FMT_PAL8 || @@ -859,10 +870,17 @@ avctx->pix_fmt == AV_PIX_FMT_GRAY16BE || avctx->pix_fmt == AV_PIX_FMT_MONOBLACK )) { - // APNG_DISPOSE_OP_OVER is the same as APNG_DISPOSE_OP_SOURCE when there is no alpha channel - s->dispose_op = APNG_BLEND_OP_SOURCE; + // APNG_BLEND_OP_OVER is the same as APNG_BLEND_OP_SOURCE when there is no alpha channel + blend_op = APNG_BLEND_OP_SOURCE; } + s->cur_w = cur_w; + s->cur_h = cur_h; + s->x_offset = x_offset; + s->y_offset = y_offset; + s->dispose_op = dispose_op; + s->blend_op = blend_op; + return 0; } @@ -904,20 +922,20 @@ return AVERROR_PATCHWELCOME; } - // Copy the previous frame to the buffer - ff_thread_await_progress(&s->last_picture, INT_MAX, 0); - memcpy(buffer, s->last_picture.f->data[0], s->image_linesize * s->height); - // Do the disposal operation specified by the last frame on the frame - if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) { - for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; ++y) - memset(buffer + s->image_linesize * y + s->bpp * s->last_x_offset, 0, s->bpp * s->last_w); - } else if (s->last_dispose_op == APNG_DISPOSE_OP_PREVIOUS) { + if (s->last_dispose_op != APNG_DISPOSE_OP_PREVIOUS) { + ff_thread_await_progress(&s->last_picture, INT_MAX, 0); + memcpy(buffer, s->last_picture.f->data[0], s->image_linesize * s->height); + + if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) + for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; ++y) + memset(buffer + s->image_linesize * y + s->bpp * s->last_x_offset, 0, s->bpp * s->last_w); + + memcpy(s->previous_picture.f->data[0], buffer, s->image_linesize * s->height); + ff_thread_report_progress(&s->previous_picture, INT_MAX, 0); + } else { ff_thread_await_progress(&s->previous_picture, INT_MAX, 0); - for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; ++y) { - size_t row_start = s->image_linesize * y + s->bpp * s->last_x_offset; - memcpy(buffer + row_start, s->previous_picture.f->data[0] + row_start, s->bpp * s->last_w); - } + memcpy(buffer, s->previous_picture.f->data[0], s->image_linesize * s->height); } // Perform blending @@ -1193,13 +1211,9 @@ PNGDecContext *const s = avctx->priv_data; int ret; AVFrame *p; - ThreadFrame tmp; - ff_thread_release_buffer(avctx, &s->previous_picture); - tmp = s->previous_picture; - s->previous_picture = s->last_picture; - s->last_picture = s->picture; - s->picture = tmp; + ff_thread_release_buffer(avctx, &s->last_picture); + FFSWAP(ThreadFrame, s->picture, s->last_picture); p = s->picture.f; if (!(s->state & PNG_IHDR)) { @@ -1259,15 +1273,34 @@ (ret = ff_thread_ref_frame(&pdst->picture, &psrc->picture)) < 0) return ret; if (CONFIG_APNG_DECODER && dst->codec_id == AV_CODEC_ID_APNG) { + pdst->width = psrc->width; + pdst->height = psrc->height; + pdst->bit_depth = psrc->bit_depth; + pdst->color_type = psrc->color_type; + pdst->compression_type = psrc->compression_type; + pdst->interlace_type = psrc->interlace_type; + pdst->filter_type = psrc->filter_type; pdst->cur_w = psrc->cur_w; pdst->cur_h = psrc->cur_h; pdst->x_offset = psrc->x_offset; pdst->y_offset = psrc->y_offset; + pdst->has_trns = psrc->has_trns; + pdst->dispose_op = psrc->dispose_op; + memcpy(pdst->palette, psrc->palette, sizeof(pdst->palette)); + + pdst->state |= psrc->state & (PNG_IHDR | PNG_PLTE); + ff_thread_release_buffer(dst, &pdst->last_picture); - if (psrc->last_picture.f->data[0]) - return ff_thread_ref_frame(&pdst->last_picture, &psrc->last_picture); + if (psrc->last_picture.f->data[0] && + (ret = ff_thread_ref_frame(&pdst->last_picture, &psrc->last_picture)) < 0) + return ret; + + ff_thread_release_buffer(dst, &pdst->previous_picture); + if (psrc->previous_picture.f->data[0] && + (ret = ff_thread_ref_frame(&pdst->previous_picture, &psrc->previous_picture)) < 0) + return ret; } return 0; @@ -1330,7 +1363,7 @@ .decode = decode_frame_apng, .init_thread_copy = ONLY_IF_THREADS_ENABLED(png_dec_init), .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS /*| CODEC_CAP_DRAW_HORIZ_BAND*/, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/, }; #endif @@ -1346,6 +1379,6 @@ .decode = decode_frame_png, .init_thread_copy = ONLY_IF_THREADS_ENABLED(png_dec_init), .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS /*| CODEC_CAP_DRAW_HORIZ_BAND*/, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pngenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pngenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pngenc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pngenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -495,14 +495,14 @@ enc_row_size = deflateBound(&s->zstream, (avctx->width * s->bits_per_pixel + 7) >> 3); max_packet_size = - FF_MIN_BUFFER_SIZE + // headers + AV_INPUT_BUFFER_MIN_SIZE + // headers avctx->height * ( enc_row_size + 12 * (((int64_t)enc_row_size + IOBUF_SIZE - 1) / IOBUF_SIZE) // IDAT * ceil(enc_row_size / IOBUF_SIZE) ); if (max_packet_size > INT_MAX) return AVERROR(ENOMEM); - ret = ff_alloc_packet2(avctx, pkt, max_packet_size); + ret = ff_alloc_packet2(avctx, pkt, max_packet_size, 0); if (ret < 0) return ret; @@ -553,14 +553,14 @@ enc_row_size = deflateBound(&s->zstream, (avctx->width * s->bits_per_pixel + 7) >> 3); max_packet_size = - FF_MIN_BUFFER_SIZE + // headers + AV_INPUT_BUFFER_MIN_SIZE + // headers avctx->height * ( enc_row_size + (4 + 12) * (((int64_t)enc_row_size + IOBUF_SIZE - 1) / IOBUF_SIZE) // fdAT * ceil(enc_row_size / IOBUF_SIZE) ); if (max_packet_size > INT_MAX) return AVERROR(ENOMEM); - ret = ff_alloc_packet2(avctx, pkt, max_packet_size); + ret = ff_alloc_packet2(avctx, pkt, max_packet_size, 0); if (ret < 0) return ret; @@ -627,12 +627,12 @@ avctx->bits_per_coded_sample = 8; } - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif ff_huffyuvencdsp_init(&s->hdsp); @@ -649,7 +649,7 @@ s->dpm = s->dpi * 10000 / 254; } - s->is_progressive = !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT); + s->is_progressive = !!(avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT); switch (avctx->pix_fmt) { case AV_PIX_FMT_RGBA64BE: s->bit_depth = 16; @@ -713,7 +713,6 @@ PNGEncContext *s = avctx->priv_data; deflateEnd(&s->zstream); - av_frame_free(&avctx->coded_frame); return 0; } @@ -748,7 +747,7 @@ .init = png_enc_init, .close = png_enc_close, .encode2 = encode_png, - .capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY, + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB48BE, AV_PIX_FMT_RGBA64BE, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pnmdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pnmdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pnmdec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pnmdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -265,7 +265,7 @@ .id = AV_CODEC_ID_PGM, .priv_data_size = sizeof(PNMContext), .decode = pnm_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif @@ -277,7 +277,7 @@ .id = AV_CODEC_ID_PGMYUV, .priv_data_size = sizeof(PNMContext), .decode = pnm_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif @@ -289,7 +289,7 @@ .id = AV_CODEC_ID_PPM, .priv_data_size = sizeof(PNMContext), .decode = pnm_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif @@ -301,7 +301,7 @@ .id = AV_CODEC_ID_PBM, .priv_data_size = sizeof(PNMContext), .decode = pnm_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif @@ -313,6 +313,6 @@ .id = AV_CODEC_ID_PAM, .priv_data_size = sizeof(PNMContext), .decode = pnm_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pnmenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pnmenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pnmenc.c 2015-06-18 18:54:59.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pnmenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -32,7 +32,7 @@ if ((ret = ff_alloc_packet2(avctx, pkt, avpicture_get_size(avctx->pix_fmt, avctx->width, - avctx->height) + 200)) < 0) + avctx->height) + 200, 0)) < 0) return ret; bytestream_start = @@ -120,22 +120,16 @@ static av_cold int pnm_encode_init(AVCodecContext *avctx) { - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif return 0; } -static av_cold int pnm_encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - return 0; -} - #if CONFIG_PGM_ENCODER AVCodec ff_pgm_encoder = { .name = "pgm", @@ -143,7 +137,6 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PGM, .init = pnm_encode_init, - .close = pnm_encode_close, .encode2 = pnm_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_NONE @@ -158,7 +151,6 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PGMYUV, .init = pnm_encode_init, - .close = pnm_encode_close, .encode2 = pnm_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P16BE, AV_PIX_FMT_NONE @@ -173,7 +165,6 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PPM, .init = pnm_encode_init, - .close = pnm_encode_close, .encode2 = pnm_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48BE, AV_PIX_FMT_NONE @@ -188,7 +179,6 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PBM, .init = pnm_encode_init, - .close = pnm_encode_close, .encode2 = pnm_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_MONOWHITE, AV_PIX_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pnm_parser.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pnm_parser.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pnm_parser.c 2015-03-13 17:34:47.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pnm_parser.c 2015-07-28 17:20:07.000000000 +0000 @@ -55,7 +55,7 @@ goto retry; } #if 0 - if (pc->index && pc->index * 2 + FF_INPUT_BUFFER_PADDING_SIZE < pc->buffer_size && buf_size > pc->index) { + if (pc->index && pc->index * 2 + AV_INPUT_BUFFER_PADDING_SIZE < pc->buffer_size && buf_size > pc->index) { memcpy(pc->buffer + pc->index, buf, pc->index); pc->index += pc->index; buf += pc->index; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ppc/idctdsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ppc/idctdsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ppc/idctdsp.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ppc/idctdsp.c 2015-07-28 17:20:07.000000000 +0000 @@ -261,7 +261,7 @@ return; if (!high_bit_depth && avctx->lowres == 0) { - if ((avctx->idct_algo == FF_IDCT_AUTO && !(avctx->flags & CODEC_FLAG_BITEXACT)) || + if ((avctx->idct_algo == FF_IDCT_AUTO && !(avctx->flags & AV_CODEC_FLAG_BITEXACT)) || (avctx->idct_algo == FF_IDCT_ALTIVEC)) { c->idct = idct_altivec; c->idct_add = idct_add_altivec; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ppc/Makefile ffmpeg-2.7.2~trusty~ppa1/libavcodec/ppc/Makefile --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ppc/Makefile 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ppc/Makefile 2015-07-18 17:20:03.000000000 +0000 @@ -20,6 +20,7 @@ OBJS-$(CONFIG_PIXBLOCKDSP) += ppc/pixblockdsp.o OBJS-$(CONFIG_VIDEODSP) += ppc/videodsp_ppc.o OBJS-$(CONFIG_VP3DSP) += ppc/vp3dsp_altivec.o +OBJS-$(CONFIG_VP8DSP) += ppc/vp8dsp_altivec.o # decoders/encoders OBJS-$(CONFIG_LLAUDDSP) += ppc/lossless_audiodsp_altivec.o @@ -27,4 +28,3 @@ OBJS-$(CONFIG_VC1_DECODER) += ppc/vc1dsp_altivec.o OBJS-$(CONFIG_VORBIS_DECODER) += ppc/vorbisdsp_altivec.o OBJS-$(CONFIG_VP7_DECODER) += ppc/vp8dsp_altivec.o -OBJS-$(CONFIG_VP8_DECODER) += ppc/vp8dsp_altivec.o diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/proresdec2.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/proresdec2.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/proresdec2.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/proresdec2.c 2015-07-28 17:20:07.000000000 +0000 @@ -574,7 +574,7 @@ if (ret < 0) return ret; - if (!(avctx->flags & CODEC_FLAG_GRAY)) { + if (!(avctx->flags & AV_CODEC_FLAG_GRAY)) { ret = decode_slice_chroma(avctx, slice, (uint16_t*)dest_u, chroma_stride, buf + y_data_size, u_data_size, qmat_chroma_scaled, log2_chroma_blocks_per_mb); @@ -686,5 +686,5 @@ .init = decode_init, .close = decode_close, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/proresdec_lgpl.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/proresdec_lgpl.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/proresdec_lgpl.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/proresdec_lgpl.c 2015-07-28 17:20:07.000000000 +0000 @@ -780,5 +780,5 @@ .init = decode_init, .close = decode_close, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/proresenc_anatoliy.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/proresenc_anatoliy.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/proresenc_anatoliy.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/proresenc_anatoliy.c 2015-07-29 17:20:04.000000000 +0000 @@ -323,7 +323,7 @@ *y_data_size = encode_slice_plane(avctx, mb_count, dest_y, luma_stride, buf, data_size, ctx->qmat_luma[qp - 1], 0); - if (!(avctx->flags & CODEC_FLAG_GRAY)) { + if (!(avctx->flags & AV_CODEC_FLAG_GRAY)) { *u_data_size = encode_slice_plane(avctx, mb_count, dest_u, chroma_stride, buf + *y_data_size, data_size - *y_data_size, ctx->qmat_chroma[qp - 1], 1); @@ -491,10 +491,10 @@ int header_size = 148; uint8_t *buf; int pic_size, ret; - int frame_size = FFALIGN(avctx->width, 16) * FFALIGN(avctx->height, 16)*16 + 500 + FF_MIN_BUFFER_SIZE; //FIXME choose tighter limit + int frame_size = FFALIGN(avctx->width, 16) * FFALIGN(avctx->height, 16)*16 + 500 + AV_INPUT_BUFFER_MIN_SIZE; //FIXME choose tighter limit - if ((ret = ff_alloc_packet2(avctx, pkt, frame_size + FF_MIN_BUFFER_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, frame_size + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return ret; buf = pkt->data; @@ -590,19 +590,12 @@ scale_mat(QMAT_CHROMA[avctx->profile], ctx->qmat_chroma[i - 1], i); } - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - avctx->coded_frame->key_frame = 1; - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; - return 0; } static av_cold int prores_encode_close(AVCodecContext *avctx) { ProresContext* ctx = avctx->priv_data; - av_frame_free(&avctx->coded_frame); av_freep(&ctx->fill_y); return 0; @@ -618,7 +611,7 @@ .close = prores_encode_close, .encode2 = prores_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUV422P10, AV_PIX_FMT_NONE}, - .capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY, + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .profiles = profiles }; @@ -632,6 +625,6 @@ .close = prores_encode_close, .encode2 = prores_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUV422P10, AV_PIX_FMT_NONE}, - .capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY, + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .profiles = profiles }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/proresenc_kostya.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/proresenc_kostya.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/proresenc_kostya.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/proresenc_kostya.c 2015-07-28 17:20:07.000000000 +0000 @@ -199,6 +199,7 @@ int linesize, int16_t *block); FDCTDSPContext fdsp; + const AVFrame *pic; int mb_width, mb_height; int mbs_per_slice; int num_chroma_blocks, chroma_factor; @@ -745,7 +746,7 @@ return bits; } -static int find_slice_quant(AVCodecContext *avctx, const AVFrame *pic, +static int find_slice_quant(AVCodecContext *avctx, int trellis_node, int x, int y, int mbs_per_slice, ProresThreadData *td) { @@ -767,7 +768,7 @@ if (ctx->pictures_per_frame == 1) line_add = 0; else - line_add = ctx->cur_picture_idx ^ !pic->top_field_first; + line_add = ctx->cur_picture_idx ^ !ctx->pic->top_field_first; mbs = x + mbs_per_slice; for (i = 0; i < ctx->num_planes; i++) { @@ -787,9 +788,9 @@ pwidth = avctx->width >> 1; } - linesize[i] = pic->linesize[i] * ctx->pictures_per_frame; - src = (const uint16_t*)(pic->data[i] + yp * linesize[i] + - line_add * pic->linesize[i]) + xp; + linesize[i] = ctx->pic->linesize[i] * ctx->pictures_per_frame; + src = (const uint16_t *)(ctx->pic->data[i] + yp * linesize[i] + + line_add * ctx->pic->linesize[i]) + xp; if (i < 3) { get_slice_data(ctx, src, linesize[i], xp, yp, @@ -912,7 +913,7 @@ for (x = mb = 0; x < ctx->mb_width; x += mbs_per_slice, mb++) { while (ctx->mb_width - x < mbs_per_slice) mbs_per_slice >>= 1; - q = find_slice_quant(avctx, arg, + q = find_slice_quant(avctx, (mb + 1) * TRELLIS_WIDTH, x, y, mbs_per_slice, td); } @@ -940,9 +941,10 @@ int max_slice_size = (ctx->frame_size_upper_bound - 200) / (ctx->pictures_per_frame * ctx->slices_per_picture + 1); uint8_t frame_flags; + ctx->pic = pic; pkt_size = ctx->frame_size_upper_bound; - if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size + FF_MIN_BUFFER_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return ret; orig_buf = pkt->data; @@ -961,7 +963,7 @@ bytestream_put_be16 (&buf, avctx->height); frame_flags = ctx->chroma_factor << 6; - if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) + if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) frame_flags |= pic->top_field_first ? 0x04 : 0x08; bytestream_put_byte (&buf, frame_flags); @@ -1090,8 +1092,6 @@ ProresContext *ctx = avctx->priv_data; int i; - av_frame_free(&avctx->coded_frame); - if (ctx->tdata) { for (i = 0; i < avctx->thread_count; i++) av_freep(&ctx->tdata[i].nodes); @@ -1122,14 +1122,15 @@ int mps; int i, j; int min_quant, max_quant; - int interlaced = !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT); + int interlaced = !!(avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT); avctx->bits_per_raw_sample = 10; - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif ctx->fdct = prores_fdct; ctx->scantable = interlaced ? ff_prores_interlaced_scan @@ -1346,7 +1347,7 @@ .init = encode_init, .close = encode_close, .encode2 = encode_frame, - .capabilities = CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_SLICE_THREADS, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_NONE diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/psymodel.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/psymodel.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/psymodel.h 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/psymodel.h 2015-07-28 17:20:07.000000000 +0000 @@ -38,8 +38,7 @@ int bits; float energy; float threshold; - float distortion; - float perceptual_weight; + float spread; /* Energy spread over the band */ } FFPsyBand; /** @@ -67,6 +66,7 @@ int window_shape; ///< window shape (sine/KBD/whatever) int num_windows; ///< number of windows in a frame int grouping[8]; ///< window grouping (for e.g. AAC) + float clipping[8]; ///< maximum absolute normalized intensity in the given window for clip avoidance int *window_sizes; ///< sequence of window sizes inside one frame (for eg. WMA) } FFPsyWindowInfo; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pthread.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pthread.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pthread.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pthread.c 2015-07-28 17:20:07.000000000 +0000 @@ -45,18 +45,18 @@ */ static void validate_thread_parameters(AVCodecContext *avctx) { - int frame_threading_supported = (avctx->codec->capabilities & CODEC_CAP_FRAME_THREADS) - && !(avctx->flags & CODEC_FLAG_TRUNCATED) - && !(avctx->flags & CODEC_FLAG_LOW_DELAY) - && !(avctx->flags2 & CODEC_FLAG2_CHUNKS); + int frame_threading_supported = (avctx->codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) + && !(avctx->flags & AV_CODEC_FLAG_TRUNCATED) + && !(avctx->flags & AV_CODEC_FLAG_LOW_DELAY) + && !(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS); if (avctx->thread_count == 1) { avctx->active_thread_type = 0; } else if (frame_threading_supported && (avctx->thread_type & FF_THREAD_FRAME)) { avctx->active_thread_type = FF_THREAD_FRAME; - } else if (avctx->codec->capabilities & CODEC_CAP_SLICE_THREADS && + } else if (avctx->codec->capabilities & AV_CODEC_CAP_SLICE_THREADS && avctx->thread_type & FF_THREAD_SLICE) { avctx->active_thread_type = FF_THREAD_SLICE; - } else if (!(avctx->codec->capabilities & CODEC_CAP_AUTO_THREADS)) { + } else if (!(avctx->codec->capabilities & AV_CODEC_CAP_AUTO_THREADS)) { avctx->thread_count = 1; avctx->active_thread_type = 0; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/pthread_frame.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/pthread_frame.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/pthread_frame.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/pthread_frame.c 2015-07-28 17:20:07.000000000 +0000 @@ -242,7 +242,11 @@ if (for_user) { dst->delay = src->thread_count - 1; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS dst->coded_frame = src->coded_frame; +FF_ENABLE_DEPRECATION_WARNINGS +#endif } else { if (dst->codec->update_thread_context) err = dst->codec->update_thread_context(dst, src); @@ -327,7 +331,8 @@ PerThreadContext *prev_thread = fctx->prev_thread; const AVCodec *codec = p->avctx->codec; - if (!avpkt->size && !(codec->capabilities & CODEC_CAP_DELAY)) return 0; + if (!avpkt->size && !(codec->capabilities & AV_CODEC_CAP_DELAY)) + return 0; pthread_mutex_lock(&p->mutex); @@ -454,6 +459,9 @@ *got_picture_ptr = p->got_frame; picture->pkt_dts = p->avpkt.dts; + if (p->result < 0) + err = p->result; + /* * A later call with avkpt->size == 0 may loop over all threads, * including this one, searching for a frame to return before being @@ -471,6 +479,14 @@ fctx->next_finished = finished; + /* + * When no frame was found while flushing, but an error occurred in + * any thread, return it instead of 0. + * Otherwise the error can get lost. + */ + if (!avpkt->size && !*got_picture_ptr) + return err; + /* return the size of the consumed packet if no error occurred */ return (p->result >= 0) ? avpkt->size : p->result; } @@ -572,7 +588,7 @@ pthread_join(p->thread, NULL); p->thread_init=0; - if (codec->close) + if (codec->close && p->avctx) codec->close(p->avctx); release_delayed_buffers(p); @@ -590,12 +606,13 @@ av_packet_unref(&p->avpkt); av_freep(&p->released_buffers); - if (i) { + if (i && p->avctx) { av_freep(&p->avctx->priv_data); av_freep(&p->avctx->slice_offset); } - av_freep(&p->avctx->internal); + if (p->avctx) + av_freep(&p->avctx->internal); av_freep(&p->avctx); } @@ -678,6 +695,7 @@ copy->internal = av_malloc(sizeof(AVCodecInternal)); if (!copy->internal) { + copy->priv_data = NULL; err = AVERROR(ENOMEM); goto error; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ptx.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ptx.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ptx.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ptx.c 2015-07-28 17:20:07.000000000 +0000 @@ -88,5 +88,5 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PTX, .decode = ptx_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qcelpdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qcelpdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qcelpdec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qcelpdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -797,6 +797,6 @@ .id = AV_CODEC_ID_QCELP, .init = qcelp_decode_init, .decode = qcelp_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(QCELPContext), }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qdm2.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qdm2.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qdm2.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qdm2.c 2015-07-28 17:20:07.000000000 +0000 @@ -1888,5 +1888,5 @@ .init = qdm2_decode_init, .close = qdm2_decode_close, .decode = qdm2_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qdrw.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qdrw.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qdrw.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qdrw.c 2015-07-28 17:20:07.000000000 +0000 @@ -339,5 +339,5 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_QDRAW, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qpeg.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qpeg.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qpeg.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qpeg.c 2015-07-28 17:20:07.000000000 +0000 @@ -351,5 +351,5 @@ .close = decode_end, .decode = decode_frame, .flush = decode_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qpeldsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qpeldsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qpeldsp.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qpeldsp.c 2015-06-18 17:20:02.000000000 +0000 @@ -811,4 +811,6 @@ if (ARCH_X86) ff_qpeldsp_init_x86(c); + if (ARCH_MIPS) + ff_qpeldsp_init_mips(c); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qpeldsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/qpeldsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qpeldsp.h 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qpeldsp.h 2015-06-18 17:20:02.000000000 +0000 @@ -78,5 +78,6 @@ void ff_qpeldsp_init(QpelDSPContext *c); void ff_qpeldsp_init_x86(QpelDSPContext *c); +void ff_qpeldsp_init_mips(QpelDSPContext *c); #endif /* AVCODEC_QPELDSP_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsv.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsv.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsv.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsv.c 2015-07-14 17:20:02.000000000 +0000 @@ -19,7 +19,12 @@ */ #include +#include +#include +#include + +#include "libavutil/avstring.h" #include "libavutil/error.h" #include "avcodec.h" @@ -30,6 +35,10 @@ switch (codec_id) { case AV_CODEC_ID_H264: return MFX_CODEC_AVC; +#if QSV_VERSION_ATLEAST(1, 8) + case AV_CODEC_ID_HEVC: + return MFX_CODEC_HEVC; +#endif case AV_CODEC_ID_MPEG1VIDEO: case AV_CODEC_ID_MPEG2VIDEO: return MFX_CODEC_MPEG2; @@ -76,8 +85,91 @@ return AVERROR_UNKNOWN; } } - -int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session) +static int ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs) +{ + // this code is only required for Linux. It searches for a valid + // display handle. First in /dev/dri/renderD then in /dev/dri/card +#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE + // VAAPI display handle + int ret = 0; + VADisplay va_dpy = NULL; + VAStatus va_res = VA_STATUS_SUCCESS; + int major_version = 0, minor_version = 0; + int fd = -1; + char adapterpath[256]; + int adapter_num; + + qs->fd_display = -1; + qs->va_display = NULL; + + //search for valid graphics device + for (adapter_num = 0;adapter_num < 6;adapter_num++) { + + if (adapter_num<3) { + snprintf(adapterpath,sizeof(adapterpath), + "/dev/dri/renderD%d", adapter_num+128); + } else { + snprintf(adapterpath,sizeof(adapterpath), + "/dev/dri/card%d", adapter_num-3); + } + + fd = open(adapterpath, O_RDWR); + if (fd < 0) { + av_log(avctx, AV_LOG_ERROR, + "mfx init: %s fd open failed\n", adapterpath); + continue; + } + + va_dpy = vaGetDisplayDRM(fd); + if (!va_dpy) { + av_log(avctx, AV_LOG_ERROR, + "mfx init: %s vaGetDisplayDRM failed\n", adapterpath); + close(fd); + continue; + } + + va_res = vaInitialize(va_dpy, &major_version, &minor_version); + if (VA_STATUS_SUCCESS != va_res) { + av_log(avctx, AV_LOG_ERROR, + "mfx init: %s vaInitialize failed\n", adapterpath); + close(fd); + fd = -1; + continue; + } else { + av_log(avctx, AV_LOG_VERBOSE, + "mfx initialization: %s vaInitialize successful\n",adapterpath); + qs->fd_display = fd; + qs->va_display = va_dpy; + ret = MFXVideoCORE_SetHandle(qs->session, + (mfxHandleType)MFX_HANDLE_VA_DISPLAY, (mfxHDL)va_dpy); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, + "Error %d during set display handle\n", ret); + return ff_qsv_error(ret); + } + break; + } + } +#endif //AVCODEC_QSV_LINUX_SESSION_HANDLE + return 0; +} +/** + * @brief Initialize a MSDK session + * + * Media SDK is based on sessions, so this is the prerequisite + * initialization for HW acceleration. For Windows the session is + * complete and ready to use, for Linux a display handle is + * required. For releases of Media Server Studio >= 2015 R4 the + * render nodes interface is preferred (/dev/dri/renderD). + * Using Media Server Studio 2015 R4 or newer is recommended + * but the older /dev/dri/card interface is also searched + * for broader compatibility. + * + * @param avctx ffmpeg metadata for this codec context + * @param session the MSDK session used + */ +int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs, + const char *load_plugins) { mfxIMPL impl = MFX_IMPL_AUTO_ANY; mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } }; @@ -85,13 +177,17 @@ const char *desc; int ret; - ret = MFXInit(impl, &ver, session); + ret = MFXInit(impl, &ver, &qs->session); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error initializing an internal MFX session\n"); return ff_qsv_error(ret); } - MFXQueryIMPL(*session, &impl); + ret = ff_qsv_set_display_handle(avctx, qs); + if (ret < 0) + return ret; + + MFXQueryIMPL(qs->session, &impl); switch (MFX_IMPL_BASETYPE(impl)) { case MFX_IMPL_SOFTWARE: @@ -107,9 +203,67 @@ desc = "unknown"; } + if (load_plugins && *load_plugins) { + while (*load_plugins) { + mfxPluginUID uid; + int i, err = 0; + + char *plugin = av_get_token(&load_plugins, ":"); + if (!plugin) + return AVERROR(ENOMEM); + if (strlen(plugin) != 2 * sizeof(uid.Data)) { + av_log(avctx, AV_LOG_ERROR, "Invalid plugin UID length\n"); + err = AVERROR(EINVAL); + goto load_plugin_fail; + } + + for (i = 0; i < sizeof(uid.Data); i++) { + err = sscanf(plugin + 2 * i, "%2hhx", uid.Data + i); + if (err != 1) { + av_log(avctx, AV_LOG_ERROR, "Invalid plugin UID\n"); + err = AVERROR(EINVAL); + goto load_plugin_fail; + } + + } + + ret = MFXVideoUSER_Load(qs->session, &uid, 1); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Could not load the requested plugin: %s\n", + plugin); + err = ff_qsv_error(ret); + goto load_plugin_fail; + } + +load_plugin_fail: + av_freep(&plugin); + if (err < 0) + return err; + } + } + av_log(avctx, AV_LOG_VERBOSE, "Initialized an internal MFX session using %s implementation\n", desc); return 0; } + +int ff_qsv_close_internal_session(QSVSession *qs) +{ + if (qs->session) { + MFXClose(qs->session); + qs->session = NULL; + } +#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE + if (qs->va_display) { + vaTerminate(qs->va_display); + qs->va_display = NULL; + } + if (qs->fd_display > 0) { + close(qs->fd_display); + qs->fd_display = -1; + } +#endif + return 0; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvdec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvdec.c 2015-07-29 17:20:04.000000000 +0000 @@ -34,6 +34,7 @@ #include "avcodec.h" #include "internal.h" +#include "qsv.h" #include "qsv_internal.h" #include "qsvdec.h" @@ -48,58 +49,64 @@ } } -static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession session) +int ff_qsv_decode_init(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt) { - if (!session) { - if (!q->internal_session) { - int ret = ff_qsv_init_internal_session(avctx, &q->internal_session); + mfxVideoParam param = { { 0 } }; + mfxBitstream bs = { { { 0 } } }; + int ret; + + q->iopattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY; + if (!q->session) { + if (avctx->hwaccel_context) { + AVQSVContext *qsv = avctx->hwaccel_context; + + q->session = qsv->session; + q->iopattern = qsv->iopattern; + q->ext_buffers = qsv->ext_buffers; + q->nb_ext_buffers = qsv->nb_ext_buffers; + } + if (!q->session) { + ret = ff_qsv_init_internal_session(avctx, &q->internal_qs, + q->load_plugins); if (ret < 0) return ret; - } - q->session = q->internal_session; - } else { - q->session = session; + q->session = q->internal_qs.session; + } } - /* make sure the decoder is uninitialized */ - MFXVideoDECODE_Close(q->session); - - return 0; -} - -int ff_qsv_decode_init(AVCodecContext *avctx, QSVContext *q, mfxSession session) -{ - mfxVideoParam param = { { 0 } }; - int ret; + if (avpkt->size) { + bs.Data = avpkt->data; + bs.DataLength = avpkt->size; + bs.MaxLength = bs.DataLength; + bs.TimeStamp = avpkt->pts; + } else + return AVERROR_INVALIDDATA; - ret = qsv_init_session(avctx, q, session); + ret = ff_qsv_codec_id_to_mfx(avctx->codec_id); if (ret < 0) { - av_log(avctx, AV_LOG_ERROR, "Error initializing an MFX session\n"); + av_log(avctx, AV_LOG_ERROR, "Unsupported codec_id %08x\n", avctx->codec_id); return ret; } + param.mfx.CodecId = ret; - ret = ff_qsv_codec_id_to_mfx(avctx->codec_id); - if (ret < 0) - return ret; - - param.mfx.CodecId = ret; - param.mfx.CodecProfile = avctx->profile; - param.mfx.CodecLevel = avctx->level; - - param.mfx.FrameInfo.BitDepthLuma = 8; - param.mfx.FrameInfo.BitDepthChroma = 8; - param.mfx.FrameInfo.Shift = 0; - param.mfx.FrameInfo.FourCC = MFX_FOURCC_NV12; - param.mfx.FrameInfo.Width = avctx->coded_width; - param.mfx.FrameInfo.Height = avctx->coded_height; - param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420; - + ret = MFXVideoDECODE_DecodeHeader(q->session, &bs, ¶m); + if (MFX_ERR_MORE_DATA==ret) { + /* this code means that header not found so we return packet size to skip + a current packet + */ + return avpkt->size; + } else if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Decode header error %d\n", ret); + return ff_qsv_error(ret); + } param.IOPattern = q->iopattern; param.AsyncDepth = q->async_depth; param.ExtParam = q->ext_buffers; param.NumExtParam = q->nb_ext_buffers; + param.mfx.FrameInfo.BitDepthLuma = 8; + param.mfx.FrameInfo.BitDepthChroma = 8; ret = MFXVideoDECODE_Init(q->session, ¶m); if (ret < 0) { @@ -107,6 +114,31 @@ return ff_qsv_error(ret); } + avctx->pix_fmt = AV_PIX_FMT_NV12; + avctx->profile = param.mfx.CodecProfile; + avctx->level = param.mfx.CodecLevel; + avctx->coded_width = param.mfx.FrameInfo.Width; + avctx->coded_height = param.mfx.FrameInfo.Height; + avctx->width = param.mfx.FrameInfo.CropW - param.mfx.FrameInfo.CropX; + avctx->height = param.mfx.FrameInfo.CropH - param.mfx.FrameInfo.CropY; + + /* maximum decoder latency should be not exceed max DPB size for h.264 and + HEVC which is 16 for both cases. + So weare pre-allocating fifo big enough for 17 elements: + */ + if (!q->async_fifo) { + q->async_fifo = av_fifo_alloc((1 + 16) * + (sizeof(mfxSyncPoint) + sizeof(QSVFrame*))); + if (!q->async_fifo) + return AVERROR(ENOMEM); + } + + q->input_fifo = av_fifo_alloc(1024*16); + if (!q->input_fifo) + return AVERROR(ENOMEM); + + q->engine_ready = 1; + return 0; } @@ -142,7 +174,7 @@ { QSVFrame *cur = q->work_frames; while (cur) { - if (cur->surface && !cur->surface->Data.Locked) { + if (cur->surface && !cur->surface->Data.Locked && !cur->queued) { cur->surface = NULL; av_frame_unref(cur->frame); } @@ -191,70 +223,163 @@ return 0; } -static AVFrame *find_frame(QSVContext *q, mfxFrameSurface1 *surf) +static QSVFrame *find_frame(QSVContext *q, mfxFrameSurface1 *surf) { QSVFrame *cur = q->work_frames; while (cur) { if (surf == cur->surface) - return cur->frame; + return cur; cur = cur->next; } return NULL; } +/* This function uses for 'smart' releasing of consumed data + from the input bitstream fifo. + Since the input fifo mapped to mfxBitstream which does not understand + a wrapping of data over fifo end, we should also to relocate a possible + data rest to fifo begin. If rest of data is absent then we just reset fifo's + pointers to initial positions. + NOTE the case when fifo does contain unconsumed data is rare and typical + amount of such data is 1..4 bytes. +*/ +static void qsv_fifo_relocate(AVFifoBuffer *f, int bytes_to_free) +{ + int data_size; + int data_rest = 0; + + av_fifo_drain(f, bytes_to_free); + + data_size = av_fifo_size(f); + if (data_size > 0) { + if (f->buffer!=f->rptr) { + if ( (f->end - f->rptr) < data_size) { + data_rest = data_size - (f->end - f->rptr); + data_size-=data_rest; + memmove(f->buffer+data_size, f->buffer, data_rest); + } + memmove(f->buffer, f->rptr, data_size); + data_size+= data_rest; + } + } + f->rptr = f->buffer; + f->wptr = f->buffer + data_size; + f->wndx = data_size; + f->rndx = 0; +} + int ff_qsv_decode(AVCodecContext *avctx, QSVContext *q, AVFrame *frame, int *got_frame, AVPacket *avpkt) { + QSVFrame *out_frame; mfxFrameSurface1 *insurf; mfxFrameSurface1 *outsurf; mfxSyncPoint sync; mfxBitstream bs = { { { 0 } } }; int ret; + int n_out_frames; + int buffered = 0; - if (avpkt->size) { - bs.Data = avpkt->data; - bs.DataLength = avpkt->size; + if (!q->engine_ready) { + ret = ff_qsv_decode_init(avctx, q, avpkt); + if (ret) + return ret; + } + + if (avpkt->size ) { + if (av_fifo_size(q->input_fifo)) { + /* we have got rest of previous packet into buffer */ + if (av_fifo_space(q->input_fifo) < avpkt->size) { + ret = av_fifo_grow(q->input_fifo, avpkt->size); + if (ret < 0) + return ret; + } + av_fifo_generic_write(q->input_fifo, avpkt->data, avpkt->size, NULL); + bs.Data = q->input_fifo->rptr; + bs.DataLength = av_fifo_size(q->input_fifo); + buffered = 1; + } else { + bs.Data = avpkt->data; + bs.DataLength = avpkt->size; + } bs.MaxLength = bs.DataLength; bs.TimeStamp = avpkt->pts; } - do { + while (1) { ret = get_surface(avctx, q, &insurf); if (ret < 0) return ret; + do { + ret = MFXVideoDECODE_DecodeFrameAsync(q->session, avpkt->size ? &bs : NULL, + insurf, &outsurf, &sync); + if (ret != MFX_WRN_DEVICE_BUSY) + break; + av_usleep(500); + } while (1); + + if (MFX_WRN_VIDEO_PARAM_CHANGED==ret) { + /* TODO: handle here sequence header changing */ + } - ret = MFXVideoDECODE_DecodeFrameAsync(q->session, avpkt->size ? &bs : NULL, - insurf, &outsurf, &sync); - if (ret == MFX_WRN_DEVICE_BUSY) - av_usleep(1); - - } while (ret == MFX_WRN_DEVICE_BUSY || ret == MFX_ERR_MORE_SURFACE); - - if (ret != MFX_ERR_NONE && - ret != MFX_ERR_MORE_DATA && - ret != MFX_WRN_VIDEO_PARAM_CHANGED && - ret != MFX_ERR_MORE_SURFACE) { - av_log(avctx, AV_LOG_ERROR, "Error during QSV decoding.\n"); + if (sync) { + QSVFrame *out_frame = find_frame(q, outsurf); + + if (!out_frame) { + av_log(avctx, AV_LOG_ERROR, + "The returned surface does not correspond to any frame\n"); + return AVERROR_BUG; + } + + out_frame->queued = 1; + av_fifo_generic_write(q->async_fifo, &out_frame, sizeof(out_frame), NULL); + av_fifo_generic_write(q->async_fifo, &sync, sizeof(sync), NULL); + + continue; + } + if (MFX_ERR_MORE_SURFACE != ret && ret < 0) + break; + } + + /* make sure we do not enter an infinite loop if the SDK + * did not consume any data and did not return anything */ + if (!sync && !bs.DataOffset) { + av_log(avctx, AV_LOG_WARNING, "A decode call did not consume any data\n"); + bs.DataOffset = avpkt->size; + } + + if (buffered) { + qsv_fifo_relocate(q->input_fifo, bs.DataOffset); + } else if (bs.DataOffset!=avpkt->size) { + /* some data of packet was not consumed. store it to local buffer */ + av_fifo_generic_write(q->input_fifo, avpkt->data+bs.DataOffset, + avpkt->size - bs.DataOffset, NULL); + } + + if (MFX_ERR_MORE_DATA!=ret && ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Error %d during QSV decoding.\n", ret); return ff_qsv_error(ret); } + n_out_frames = av_fifo_size(q->async_fifo) / (sizeof(out_frame)+sizeof(sync)); - if (sync) { + if (n_out_frames > q->async_depth || (!avpkt->size && n_out_frames) ) { AVFrame *src_frame; + av_fifo_generic_read(q->async_fifo, &out_frame, sizeof(out_frame), NULL); + av_fifo_generic_read(q->async_fifo, &sync, sizeof(sync), NULL); + out_frame->queued = 0; + MFXVideoCORE_SyncOperation(q->session, sync, 60000); - src_frame = find_frame(q, outsurf); - if (!src_frame) { - av_log(avctx, AV_LOG_ERROR, - "The returned surface does not correspond to any frame\n"); - return AVERROR_BUG; - } + src_frame = out_frame->frame; ret = av_frame_ref(frame, src_frame); if (ret < 0) return ret; + outsurf = out_frame->surface; + frame->pkt_pts = frame->pts = outsurf->Data.TimeStamp; frame->repeat_pict = @@ -269,7 +394,7 @@ *got_frame = 1; } - return bs.DataOffset; + return avpkt->size; } int ff_qsv_decode_close(QSVContext *q) @@ -283,8 +408,18 @@ cur = q->work_frames; } - if (q->internal_session) - MFXClose(q->internal_session); + av_fifo_free(q->async_fifo); + q->async_fifo = NULL; + + av_fifo_free(q->input_fifo); + q->input_fifo = NULL; + + MFXVideoDECODE_Close(q->session); + q->session = NULL; + + ff_qsv_close_internal_session(&q->internal_qs); + + q->engine_ready = 0; return 0; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvdec.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvdec.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvdec.h 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvdec.h 2015-07-26 17:20:03.000000000 +0000 @@ -28,6 +28,7 @@ #include +#include "libavutil/fifo.h" #include "libavutil/frame.h" #include "libavutil/pixfmt.h" @@ -40,24 +41,33 @@ // the session we allocated internally, in case the caller did not provide // one - mfxSession internal_session; + QSVSession internal_qs; /** * a linked list of frames currently being used by QSV */ QSVFrame *work_frames; + AVFifoBuffer *async_fifo; + AVFifoBuffer *input_fifo; + + // this flag indicates that header parsed, + // decoder instance created and ready to general decoding + int engine_ready; + // options set by the caller int async_depth; int iopattern; + char *load_plugins; + mfxExtBuffer **ext_buffers; int nb_ext_buffers; } QSVContext; int ff_qsv_map_pixfmt(enum AVPixelFormat format); -int ff_qsv_decode_init(AVCodecContext *s, QSVContext *q, mfxSession session); +int ff_qsv_decode_init(AVCodecContext *s, QSVContext *q, AVPacket *avpkt); int ff_qsv_decode(AVCodecContext *s, QSVContext *q, AVFrame *frame, int *got_frame, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvdec_h2645.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvdec_h2645.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvdec_h2645.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvdec_h2645.c 2015-07-28 17:20:07.000000000 +0000 @@ -0,0 +1,222 @@ +/* + * Intel MediaSDK QSV based H.264 / HEVC decoder + * + * copyright (c) 2013 Luca Barbato + * copyright (c) 2015 Anton Khirnov + * + * 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 +#include + +#include + +#include "libavutil/common.h" +#include "libavutil/fifo.h" +#include "libavutil/opt.h" + +#include "avcodec.h" +#include "internal.h" +#include "qsvdec.h" + +enum LoadPlugin { + LOAD_PLUGIN_NONE, + LOAD_PLUGIN_HEVC_SW, +}; + +typedef struct QSVH2645Context { + AVClass *class; + QSVContext qsv; + + int load_plugin; + + // the filter for converting to Annex B + AVBitStreamFilterContext *bsf; + +} QSVH2645Context; + +static av_cold int qsv_decode_close(AVCodecContext *avctx) +{ + QSVH2645Context *s = avctx->priv_data; + + ff_qsv_decode_close(&s->qsv); + + av_bitstream_filter_close(s->bsf); + + return 0; +} + +static av_cold int qsv_decode_init(AVCodecContext *avctx) +{ + QSVH2645Context *s = avctx->priv_data; + int ret; + + if (avctx->codec_id == AV_CODEC_ID_HEVC && s->load_plugin != LOAD_PLUGIN_NONE) { + static const char *uid_hevcenc_sw = "15dd936825ad475ea34e35f3f54217a6"; + + if (s->qsv.load_plugins[0]) { + av_log(avctx, AV_LOG_WARNING, + "load_plugins is not empty, but load_plugin is not set to 'none'." + "The load_plugin value will be ignored.\n"); + } else { + av_freep(&s->qsv.load_plugins); + s->qsv.load_plugins = av_strdup(uid_hevcenc_sw); + if (!s->qsv.load_plugins) + return AVERROR(ENOMEM); + } + } + + if (avctx->codec_id == AV_CODEC_ID_H264) + s->bsf = av_bitstream_filter_init("h264_mp4toannexb"); + else + s->bsf = av_bitstream_filter_init("hevc_mp4toannexb"); + if (!s->bsf) { + ret = AVERROR(ENOMEM); + goto fail; + } + + return 0; +fail: + qsv_decode_close(avctx); + return ret; +} + +static int qsv_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame, AVPacket *avpkt) +{ + QSVH2645Context *s = avctx->priv_data; + AVFrame *frame = data; + int ret; + uint8_t *p_filtered = NULL; + int n_filtered = NULL; + AVPacket pkt_filtered = { 0 }; + + if (avpkt->size) { + if (avpkt->size > 3 && !avpkt->data[0] && + !avpkt->data[1] && !avpkt->data[2] && 1==avpkt->data[3]) { + /* we already have annex-b prefix */ + return ff_qsv_decode(avctx, &s->qsv, frame, got_frame, avpkt); + + } else { + /* no annex-b prefix. try to restore: */ + ret = av_bitstream_filter_filter(s->bsf, avctx, "private_spspps_buf", + &p_filtered, &n_filtered, + avpkt->data, avpkt->size, 0); + if (ret>=0) { + pkt_filtered.pts = avpkt->pts; + pkt_filtered.data = p_filtered; + pkt_filtered.size = n_filtered; + + ret = ff_qsv_decode(avctx, &s->qsv, frame, got_frame, &pkt_filtered); + + if (p_filtered != avpkt->data) + av_free(p_filtered); + return ret > 0 ? avpkt->size : ret; + } + } + } + + return ff_qsv_decode(avctx, &s->qsv, frame, got_frame, avpkt); +} + +static void qsv_decode_flush(AVCodecContext *avctx) +{ +// QSVH2645Context *s = avctx->priv_data; + /* TODO: flush qsv engine if necessary */ +} + +#define OFFSET(x) offsetof(QSVH2645Context, x) +#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM + +#if CONFIG_HEVC_QSV_DECODER +AVHWAccel ff_hevc_qsv_hwaccel = { + .name = "hevc_qsv", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_HEVC, + .pix_fmt = AV_PIX_FMT_QSV, +}; + +static const AVOption hevc_options[] = { + { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 0, INT_MAX, VD }, + + { "load_plugin", "A user plugin to load in an internal session", OFFSET(load_plugin), AV_OPT_TYPE_INT, { .i64 = LOAD_PLUGIN_HEVC_SW }, LOAD_PLUGIN_NONE, LOAD_PLUGIN_HEVC_SW, VD, "load_plugin" }, + { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_NONE }, 0, 0, VD, "load_plugin" }, + { "hevc_sw", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_HEVC_SW }, 0, 0, VD, "load_plugin" }, + + { "load_plugins", "A :-separate list of hexadecimal plugin UIDs to load in an internal session", + OFFSET(qsv.load_plugins), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, VD }, + { NULL }, +}; + +static const AVClass hevc_class = { + .class_name = "hevc_qsv", + .item_name = av_default_item_name, + .option = hevc_options, + .version = LIBAVUTIL_VERSION_INT, +}; + +AVCodec ff_hevc_qsv_decoder = { + .name = "hevc_qsv", + .long_name = NULL_IF_CONFIG_SMALL("HEVC (Intel Quick Sync Video acceleration)"), + .priv_data_size = sizeof(QSVH2645Context), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_HEVC, + .init = qsv_decode_init, + .decode = qsv_decode_frame, + .flush = qsv_decode_flush, + .close = qsv_decode_close, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1, + .priv_class = &hevc_class, +}; +#endif + +#if CONFIG_H264_QSV_DECODER +AVHWAccel ff_h264_qsv_hwaccel = { + .name = "h264_qsv", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_H264, + .pix_fmt = AV_PIX_FMT_QSV, +}; + +static const AVOption options[] = { + { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 0, INT_MAX, VD }, + { NULL }, +}; + +static const AVClass class = { + .class_name = "h264_qsv", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +AVCodec ff_h264_qsv_decoder = { + .name = "h264_qsv", + .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration)"), + .priv_data_size = sizeof(QSVH2645Context), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_H264, + .init = qsv_decode_init, + .decode = qsv_decode_frame, + .flush = qsv_decode_flush, + .close = qsv_decode_close, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1, + .priv_class = &class, +}; +#endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvdec_h264.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvdec_h264.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvdec_h264.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvdec_h264.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,314 +0,0 @@ -/* - * Intel MediaSDK QSV based H.264 decoder - * - * copyright (c) 2013 Luca Barbato - * copyright (c) 2015 Anton Khirnov - * - * 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 -#include - -#include - -#include "libavutil/common.h" -#include "libavutil/fifo.h" -#include "libavutil/opt.h" - -#include "avcodec.h" -#include "internal.h" -#include "qsv_internal.h" -#include "qsvdec.h" -#include "qsv.h" - -typedef struct QSVH264Context { - AVClass *class; - QSVContext qsv; - - // the internal parser and codec context for parsing the data - AVCodecParserContext *parser; - AVCodecContext *avctx_internal; - enum AVPixelFormat orig_pix_fmt; - - // the filter for converting to Annex B - AVBitStreamFilterContext *bsf; - - AVFifoBuffer *packet_fifo; - - AVPacket input_ref; - AVPacket pkt_filtered; - uint8_t *filtered_data; -} QSVH264Context; - -static void qsv_clear_buffers(QSVH264Context *s) -{ - AVPacket pkt; - while (av_fifo_size(s->packet_fifo) >= sizeof(pkt)) { - av_fifo_generic_read(s->packet_fifo, &pkt, sizeof(pkt), NULL); - av_packet_unref(&pkt); - } - - if (s->filtered_data != s->input_ref.data) - av_freep(&s->filtered_data); - s->filtered_data = NULL; - av_packet_unref(&s->input_ref); -} - -static av_cold int qsv_decode_close(AVCodecContext *avctx) -{ - QSVH264Context *s = avctx->priv_data; - - ff_qsv_decode_close(&s->qsv); - - qsv_clear_buffers(s); - - av_fifo_free(s->packet_fifo); - - av_bitstream_filter_close(s->bsf); - av_parser_close(s->parser); - avcodec_free_context(&s->avctx_internal); - - return 0; -} - -static av_cold int qsv_decode_init(AVCodecContext *avctx) -{ - QSVH264Context *s = avctx->priv_data; - int ret; - - s->orig_pix_fmt = AV_PIX_FMT_NONE; - - s->packet_fifo = av_fifo_alloc(sizeof(AVPacket)); - if (!s->packet_fifo) { - ret = AVERROR(ENOMEM); - goto fail; - } - - s->bsf = av_bitstream_filter_init("h264_mp4toannexb"); - if (!s->bsf) { - ret = AVERROR(ENOMEM); - goto fail; - } - - s->avctx_internal = avcodec_alloc_context3(NULL); - if (!s->avctx_internal) { - ret = AVERROR(ENOMEM); - goto fail; - } - - if (avctx->extradata) { - s->avctx_internal->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - if (!s->avctx_internal->extradata) { - ret = AVERROR(ENOMEM); - goto fail; - } - memcpy(s->avctx_internal->extradata, avctx->extradata, - avctx->extradata_size); - s->avctx_internal->extradata_size = avctx->extradata_size; - } - - s->parser = av_parser_init(AV_CODEC_ID_H264); - if (!s->parser) { - ret = AVERROR(ENOMEM); - goto fail; - } - s->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES; - - s->qsv.iopattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY; - - return 0; -fail: - qsv_decode_close(avctx); - return ret; -} - -static int qsv_process_data(AVCodecContext *avctx, AVFrame *frame, - int *got_frame, AVPacket *pkt) -{ - QSVH264Context *s = avctx->priv_data; - uint8_t *dummy_data; - int dummy_size; - int ret; - - /* we assume the packets are already split properly and want - * just the codec parameters here */ - av_parser_parse2(s->parser, s->avctx_internal, - &dummy_data, &dummy_size, - pkt->data, pkt->size, pkt->pts, pkt->dts, - pkt->pos); - - /* TODO: flush delayed frames on reinit */ - if (s->parser->format != s->orig_pix_fmt || - s->parser->coded_width != avctx->coded_width || - s->parser->coded_height != avctx->coded_height) { - mfxSession session = NULL; - - enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_QSV, - AV_PIX_FMT_NONE, - AV_PIX_FMT_NONE }; - enum AVPixelFormat qsv_format; - - qsv_format = ff_qsv_map_pixfmt(s->parser->format); - if (qsv_format < 0) { - av_log(avctx, AV_LOG_ERROR, - "Only 8-bit YUV420 streams are supported.\n"); - ret = AVERROR(ENOSYS); - goto reinit_fail; - } - - s->orig_pix_fmt = s->parser->format; - avctx->pix_fmt = pix_fmts[1] = qsv_format; - avctx->width = s->parser->width; - avctx->height = s->parser->height; - avctx->coded_width = s->parser->coded_width; - avctx->coded_height = s->parser->coded_height; - avctx->level = s->avctx_internal->level; - avctx->profile = s->avctx_internal->profile; - - ret = ff_get_format(avctx, pix_fmts); - if (ret < 0) - goto reinit_fail; - - avctx->pix_fmt = ret; - - if (avctx->hwaccel_context) { - AVQSVContext *user_ctx = avctx->hwaccel_context; - session = user_ctx->session; - s->qsv.iopattern = user_ctx->iopattern; - s->qsv.ext_buffers = user_ctx->ext_buffers; - s->qsv.nb_ext_buffers = user_ctx->nb_ext_buffers; - } - - ret = ff_qsv_decode_init(avctx, &s->qsv, session); - if (ret < 0) - goto reinit_fail; - } - - return ff_qsv_decode(avctx, &s->qsv, frame, got_frame, &s->pkt_filtered); - -reinit_fail: - s->orig_pix_fmt = s->parser->format = avctx->pix_fmt = AV_PIX_FMT_NONE; - return ret; -} - -static int qsv_decode_frame(AVCodecContext *avctx, void *data, - int *got_frame, AVPacket *avpkt) -{ - QSVH264Context *s = avctx->priv_data; - AVFrame *frame = data; - int ret; - - /* buffer the input packet */ - if (avpkt->size) { - AVPacket input_ref = { 0 }; - - if (av_fifo_space(s->packet_fifo) < sizeof(input_ref)) { - ret = av_fifo_realloc2(s->packet_fifo, - av_fifo_size(s->packet_fifo) + sizeof(input_ref)); - if (ret < 0) - return ret; - } - - ret = av_packet_ref(&input_ref, avpkt); - if (ret < 0) - return ret; - av_fifo_generic_write(s->packet_fifo, &input_ref, sizeof(input_ref), NULL); - } - - /* process buffered data */ - while (!*got_frame) { - /* prepare the input data -- convert to Annex B if needed */ - if (s->pkt_filtered.size <= 0) { - int size; - - /* no more data */ - if (av_fifo_size(s->packet_fifo) < sizeof(AVPacket)) - return avpkt->size ? avpkt->size : ff_qsv_decode(avctx, &s->qsv, frame, got_frame, avpkt); - - if (s->filtered_data != s->input_ref.data) - av_freep(&s->filtered_data); - s->filtered_data = NULL; - av_packet_unref(&s->input_ref); - - av_fifo_generic_read(s->packet_fifo, &s->input_ref, sizeof(s->input_ref), NULL); - ret = av_bitstream_filter_filter(s->bsf, avctx, NULL, - &s->filtered_data, &size, - s->input_ref.data, s->input_ref.size, 0); - if (ret < 0) { - s->filtered_data = s->input_ref.data; - size = s->input_ref.size; - } - s->pkt_filtered = s->input_ref; - s->pkt_filtered.data = s->filtered_data; - s->pkt_filtered.size = size; - } - - ret = qsv_process_data(avctx, frame, got_frame, &s->pkt_filtered); - if (ret < 0) - return ret; - - s->pkt_filtered.size -= ret; - s->pkt_filtered.data += ret; - } - - return avpkt->size; -} - -static void qsv_decode_flush(AVCodecContext *avctx) -{ - QSVH264Context *s = avctx->priv_data; - - qsv_clear_buffers(s); - s->orig_pix_fmt = AV_PIX_FMT_NONE; -} - -AVHWAccel ff_h264_qsv_hwaccel = { - .name = "h264_qsv", - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_H264, - .pix_fmt = AV_PIX_FMT_QSV, -}; - -#define OFFSET(x) offsetof(QSVH264Context, x) -#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM -static const AVOption options[] = { - { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 0, INT_MAX, VD }, - { NULL }, -}; - -static const AVClass class = { - .class_name = "h264_qsv", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; - -AVCodec ff_h264_qsv_decoder = { - .name = "h264_qsv", - .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration)"), - .priv_data_size = sizeof(QSVH264Context), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_H264, - .init = qsv_decode_init, - .decode = qsv_decode_frame, - .flush = qsv_decode_flush, - .close = qsv_decode_close, - .capabilities = CODEC_CAP_DELAY, - .priv_class = &class, -}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvdec_mpeg2.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvdec_mpeg2.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvdec_mpeg2.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvdec_mpeg2.c 2015-07-28 17:20:07.000000000 +0000 @@ -0,0 +1,95 @@ +/* + * Intel MediaSDK QSV based MPEG2 video decoder + * + * 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 +#include + +#include "libavutil/common.h" +#include "libavutil/opt.h" + +#include "avcodec.h" +#include "qsvdec.h" + +typedef struct QSVMPEG2Context { + AVClass *class; + QSVContext qsv; +} QSVMPEG2Context; + +static av_cold int qsv_decode_close(AVCodecContext *avctx) +{ + QSVMPEG2Context *s = avctx->priv_data; + + ff_qsv_decode_close(&s->qsv); + + return 0; +} + +static av_cold int qsv_decode_init(AVCodecContext *avctx) +{ + return 0; +} + +static int qsv_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame, AVPacket *avpkt) +{ + QSVMPEG2Context *s = avctx->priv_data; + AVFrame *frame = data; + + return ff_qsv_decode(avctx, &s->qsv, frame, got_frame, avpkt); +} + +static void qsv_decode_flush(AVCodecContext *avctx) +{ +} + +AVHWAccel ff_mpeg2_qsv_hwaccel = { + .name = "mpeg2_qsv", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_MPEG2VIDEO, + .pix_fmt = AV_PIX_FMT_QSV, +}; + +#define OFFSET(x) offsetof(QSVMPEG2Context, x) +#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM +static const AVOption options[] = { + { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 0, INT_MAX, VD }, + { NULL }, +}; + +static const AVClass class = { + .class_name = "mpeg2_qsv", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +AVCodec ff_mpeg2_qsv_decoder = { + .name = "mpeg2_qsv", + .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video (Intel Quick Sync Video acceleration)"), + .priv_data_size = sizeof(QSVMPEG2Context), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_MPEG2VIDEO, + .init = qsv_decode_init, + .decode = qsv_decode_frame, + .flush = qsv_decode_flush, + .close = qsv_decode_close, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1, + .priv_class = &class, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvdec_vc1.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvdec_vc1.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvdec_vc1.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvdec_vc1.c 2015-07-28 17:20:07.000000000 +0000 @@ -0,0 +1,88 @@ +/* + * Intel MediaSDK QSV based VC-1 video decoder + * + * 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 +#include + +#include "libavutil/common.h" +#include "libavutil/fifo.h" +#include "libavutil/opt.h" + +#include "avcodec.h" +#include "qsvdec.h" + +typedef struct QSVVC1Context { + AVClass *class; + QSVContext qsv; +} QSVVC1Context; + + +static av_cold int qsv_decode_close(AVCodecContext *avctx) +{ + QSVVC1Context *s = avctx->priv_data; + + ff_qsv_decode_close(&s->qsv); + + return 0; +} + +static int qsv_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame, AVPacket *avpkt) +{ + QSVVC1Context *s = avctx->priv_data; + AVFrame *frame = data; + + return ff_qsv_decode(avctx, &s->qsv, frame, got_frame, avpkt); +} + +AVHWAccel ff_vc1_qsv_hwaccel = { + .name = "vc1_qsv", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_VC1, + .pix_fmt = AV_PIX_FMT_QSV, +}; + +#define OFFSET(x) offsetof(QSVVC1Context, x) +#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM +static const AVOption options[] = { + { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 0, INT_MAX, VD }, + { NULL }, +}; + +static const AVClass class = { + .class_name = "vc1_qsv", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +AVCodec ff_vc1_qsv_decoder = { + .name = "vc1_qsv", + .long_name = NULL_IF_CONFIG_SMALL("VC-1 video (Intel Quick Sync Video acceleration)"), + .priv_data_size = sizeof(QSVVC1Context), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_VC1, + .init = NULL, + .decode = qsv_decode_frame, + .flush = NULL, + .close = qsv_decode_close, + .capabilities = AV_CODEC_CAP_DELAY, + .priv_class = &class, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvenc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvenc.c 2015-07-29 17:20:04.000000000 +0000 @@ -49,6 +49,8 @@ return AVERROR_BUG; q->param.mfx.CodecId = ret; + q->width_align = avctx->codec_id == AV_CODEC_ID_HEVC ? 32 : 16; + if (avctx->level > 0) q->param.mfx.CodecLevel = avctx->level; @@ -56,7 +58,7 @@ q->param.mfx.TargetUsage = q->preset; q->param.mfx.GopPicSize = FFMAX(0, avctx->gop_size); q->param.mfx.GopRefDist = FFMAX(-1, avctx->max_b_frames) + 1; - q->param.mfx.GopOptFlag = avctx->flags & CODEC_FLAG_CLOSED_GOP ? + q->param.mfx.GopOptFlag = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? MFX_GOP_CLOSED : 0; q->param.mfx.IdrInterval = q->idr_interval; q->param.mfx.NumSlice = avctx->slices; @@ -65,18 +67,30 @@ q->param.mfx.BufferSizeInKB = 0; q->param.mfx.FrameInfo.FourCC = MFX_FOURCC_NV12; - q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, 16); - q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, 32); q->param.mfx.FrameInfo.CropX = 0; q->param.mfx.FrameInfo.CropY = 0; q->param.mfx.FrameInfo.CropW = avctx->width; q->param.mfx.FrameInfo.CropH = avctx->height; q->param.mfx.FrameInfo.AspectRatioW = avctx->sample_aspect_ratio.num; q->param.mfx.FrameInfo.AspectRatioH = avctx->sample_aspect_ratio.den; - q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; q->param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420; q->param.mfx.FrameInfo.BitDepthLuma = 8; q->param.mfx.FrameInfo.BitDepthChroma = 8; + q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, q->width_align); + + if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { + /* A true field layout (TFF or BFF) is not important here, + it will specified later during frame encoding. But it is important + to specify is frame progressive or not because allowed heigh alignment + does depend by this. + */ + q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF; + q->height_align = 32; + } else { + q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; + q->height_align = 16; + } + q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, q->height_align); if (avctx->framerate.den > 0 && avctx->framerate.num > 0) { q->param.mfx.FrameInfo.FrameRateExtN = avctx->framerate.num; @@ -86,7 +100,7 @@ q->param.mfx.FrameInfo.FrameRateExtD = avctx->time_base.num; } - if (avctx->flags & CODEC_FLAG_QSCALE) { + if (avctx->flags & AV_CODEC_FLAG_QSCALE) { q->param.mfx.RateControlMethod = MFX_RATECONTROL_CQP; ratecontrol_desc = "constant quantization parameter (CQP)"; } else if (avctx->rc_max_rate == avctx->bit_rate) { @@ -124,15 +138,19 @@ break; } - q->extco.Header.BufferId = MFX_EXTBUFF_CODING_OPTION; - q->extco.Header.BufferSz = sizeof(q->extco); - q->extco.CAVLC = avctx->coder_type == FF_CODER_TYPE_VLC ? - MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN; + // the HEVC encoder plugin currently fails if coding options + // are provided + if (avctx->codec_id != AV_CODEC_ID_HEVC) { + q->extco.Header.BufferId = MFX_EXTBUFF_CODING_OPTION; + q->extco.Header.BufferSz = sizeof(q->extco); + q->extco.CAVLC = avctx->coder_type == FF_CODER_TYPE_VLC ? + MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN; - q->extparam[0] = (mfxExtBuffer *)&q->extco; + q->extparam[0] = (mfxExtBuffer *)&q->extco; - q->param.ExtParam = q->extparam; - q->param.NumExtParam = FF_ARRAY_ELEMS(q->extparam); + q->param.ExtParam = q->extparam; + q->param.NumExtParam = FF_ARRAY_ELEMS(q->extparam); + } return 0; } @@ -153,6 +171,7 @@ (mfxExtBuffer*)&extradata, }; + int need_pps = avctx->codec_id != AV_CODEC_ID_MPEG2VIDEO; int ret; q->param.ExtParam = ext_buffers; @@ -164,20 +183,21 @@ q->packet_size = q->param.mfx.BufferSizeInKB * 1000; - if (!extradata.SPSBufSize || !extradata.PPSBufSize) { + if (!extradata.SPSBufSize || (need_pps && !extradata.PPSBufSize)) { av_log(avctx, AV_LOG_ERROR, "No extradata returned from libmfx.\n"); return AVERROR_UNKNOWN; } - avctx->extradata = av_malloc(extradata.SPSBufSize + extradata.PPSBufSize + - FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_malloc(extradata.SPSBufSize + need_pps * extradata.PPSBufSize + + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) return AVERROR(ENOMEM); memcpy(avctx->extradata, sps_buf, extradata.SPSBufSize); - memcpy(avctx->extradata + extradata.SPSBufSize, pps_buf, extradata.PPSBufSize); - avctx->extradata_size = extradata.SPSBufSize + extradata.PPSBufSize; - memset(avctx->extradata + avctx->extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + if (need_pps) + memcpy(avctx->extradata + extradata.SPSBufSize, pps_buf, extradata.PPSBufSize); + avctx->extradata_size = extradata.SPSBufSize + need_pps * extradata.PPSBufSize; + memset(avctx->extradata + avctx->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); return 0; } @@ -189,6 +209,11 @@ q->param.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY; q->param.AsyncDepth = q->async_depth; + q->async_fifo = av_fifo_alloc((1 + q->async_depth) * + (sizeof(AVPacket) + sizeof(mfxSyncPoint) + sizeof(mfxBitstream*))); + if (!q->async_fifo) + return AVERROR(ENOMEM); + if (avctx->hwaccel_context) { AVQSVContext *qsv = avctx->hwaccel_context; @@ -197,11 +222,12 @@ } if (!q->session) { - ret = ff_qsv_init_internal_session(avctx, &q->internal_session); + ret = ff_qsv_init_internal_session(avctx, &q->internal_qs, + q->load_plugins); if (ret < 0) return ret; - q->session = q->internal_session; + q->session = q->internal_qs.session; } ret = init_video_param(avctx, q); @@ -215,7 +241,9 @@ } ret = MFXVideoENCODE_Init(q->session, &q->param); - if (ret < 0) { + if (MFX_WRN_PARTIAL_ACCELERATION==ret) { + av_log(avctx, AV_LOG_WARNING, "Encoder will work with partial HW acceleration\n"); + } else if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error initializing the encoder\n"); return ff_qsv_error(ret); } @@ -226,10 +254,6 @@ return ret; } - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - q->avctx = avctx; return 0; @@ -301,9 +325,10 @@ } /* make a copy if the input is not padded as libmfx requires */ - if (frame->height & 31 || frame->linesize[0] & 15) { - qf->frame->height = FFALIGN(frame->height, 32); - qf->frame->width = FFALIGN(frame->width, 16); + if ( frame->height & (q->height_align - 1) || + frame->linesize[0] & (q->width_align - 1)) { + qf->frame->height = FFALIGN(frame->height, q->height_align); + qf->frame->width = FFALIGN(frame->width, q->width_align); ret = ff_get_buffer(q->avctx, qf->frame, AV_GET_BUFFER_FLAG_REF); if (ret < 0) @@ -362,7 +387,8 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q, AVPacket *pkt, const AVFrame *frame, int *got_packet) { - mfxBitstream bs = { { { 0 } } }; + AVPacket new_pkt = { 0 }; + mfxBitstream *bs; mfxFrameSurface1 *surf = NULL; mfxSyncPoint sync = NULL; @@ -376,43 +402,100 @@ } } - ret = ff_alloc_packet(pkt, q->packet_size); + ret = av_new_packet(&new_pkt, q->packet_size); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error allocating the output packet\n"); return ret; } - bs.Data = pkt->data; - bs.MaxLength = pkt->size; - do { - ret = MFXVideoENCODE_EncodeFrameAsync(q->session, NULL, surf, &bs, &sync); - if (ret == MFX_WRN_DEVICE_BUSY) - av_usleep(1); - } while (ret > 0); + bs = av_mallocz(sizeof(*bs)); + if (!bs) { + av_packet_unref(&new_pkt); + return AVERROR(ENOMEM); + } + bs->Data = new_pkt.data; + bs->MaxLength = new_pkt.size; - if (ret < 0) - return (ret == MFX_ERR_MORE_DATA) ? 0 : ff_qsv_error(ret); + do { + ret = MFXVideoENCODE_EncodeFrameAsync(q->session, NULL, surf, bs, &sync); + if (ret == MFX_WRN_DEVICE_BUSY) { + av_usleep(500); + continue; + } + break; + } while ( 1 ); - if (ret == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM && frame->interlaced_frame) - print_interlace_msg(avctx, q); + if (ret < 0) { + av_packet_unref(&new_pkt); + av_freep(&bs); + if (ret == MFX_ERR_MORE_DATA) + return 0; + av_log(avctx, AV_LOG_ERROR, "EncodeFrameAsync returned %d\n", ret); + return ff_qsv_error(ret); + } + if (ret == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM) { + if (frame->interlaced_frame) + print_interlace_msg(avctx, q); + else + av_log(avctx, AV_LOG_WARNING, + "EncodeFrameAsync returned 'incompatible param' code\n"); + } if (sync) { + av_fifo_generic_write(q->async_fifo, &new_pkt, sizeof(new_pkt), NULL); + av_fifo_generic_write(q->async_fifo, &sync, sizeof(sync), NULL); + av_fifo_generic_write(q->async_fifo, &bs, sizeof(bs), NULL); + } else { + av_packet_unref(&new_pkt); + av_freep(&bs); + } + + if (!av_fifo_space(q->async_fifo) || + (!frame && av_fifo_size(q->async_fifo))) { + av_fifo_generic_read(q->async_fifo, &new_pkt, sizeof(new_pkt), NULL); + av_fifo_generic_read(q->async_fifo, &sync, sizeof(sync), NULL); + av_fifo_generic_read(q->async_fifo, &bs, sizeof(bs), NULL); + MFXVideoCORE_SyncOperation(q->session, sync, 60000); - if (bs.FrameType & MFX_FRAMETYPE_I || bs.FrameType & MFX_FRAMETYPE_xI) + new_pkt.dts = av_rescale_q(bs->DecodeTimeStamp, (AVRational){1, 90000}, avctx->time_base); + new_pkt.pts = av_rescale_q(bs->TimeStamp, (AVRational){1, 90000}, avctx->time_base); + new_pkt.size = bs->DataLength; + + if (bs->FrameType & MFX_FRAMETYPE_IDR || + bs->FrameType & MFX_FRAMETYPE_xIDR) + new_pkt.flags |= AV_PKT_FLAG_KEY; + +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + if (bs->FrameType & MFX_FRAMETYPE_I || bs->FrameType & MFX_FRAMETYPE_xI) avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; - else if (bs.FrameType & MFX_FRAMETYPE_P || bs.FrameType & MFX_FRAMETYPE_xP) + else if (bs->FrameType & MFX_FRAMETYPE_P || bs->FrameType & MFX_FRAMETYPE_xP) avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P; - else if (bs.FrameType & MFX_FRAMETYPE_B || bs.FrameType & MFX_FRAMETYPE_xB) + else if (bs->FrameType & MFX_FRAMETYPE_B || bs->FrameType & MFX_FRAMETYPE_xB) avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + av_freep(&bs); - pkt->dts = av_rescale_q(bs.DecodeTimeStamp, (AVRational){1, 90000}, avctx->time_base); - pkt->pts = av_rescale_q(bs.TimeStamp, (AVRational){1, 90000}, avctx->time_base); - pkt->size = bs.DataLength; - - if (bs.FrameType & MFX_FRAMETYPE_IDR || - bs.FrameType & MFX_FRAMETYPE_xIDR) - pkt->flags |= AV_PKT_FLAG_KEY; + if (pkt->data) { + if (pkt->size < new_pkt.size) { + av_log(avctx, AV_LOG_ERROR, "Submitted buffer not large enough: %d < %d\n", + pkt->size, new_pkt.size); + av_packet_unref(&new_pkt); + return AVERROR(EINVAL); + } + + memcpy(pkt->data, new_pkt.data, new_pkt.size); + pkt->size = new_pkt.size; + + ret = av_packet_copy_props(pkt, &new_pkt); + av_packet_unref(&new_pkt); + if (ret < 0) + return ret; + } else + *pkt = new_pkt; *got_packet = 1; } @@ -425,10 +508,9 @@ QSVFrame *cur; MFXVideoENCODE_Close(q->session); - if (q->internal_session) - MFXClose(q->internal_session); - q->session = NULL; - q->internal_session = NULL; + q->session = NULL; + + ff_qsv_close_internal_session(&q->internal_qs); cur = q->work_frames; while (cur) { @@ -438,7 +520,20 @@ cur = q->work_frames; } - av_frame_free(&avctx->coded_frame); + while (q->async_fifo && av_fifo_size(q->async_fifo)) { + AVPacket pkt; + mfxSyncPoint sync; + mfxBitstream *bs; + + av_fifo_generic_read(q->async_fifo, &pkt, sizeof(pkt), NULL); + av_fifo_generic_read(q->async_fifo, &sync, sizeof(sync), NULL); + av_fifo_generic_read(q->async_fifo, &bs, sizeof(bs), NULL); + + av_freep(&bs); + av_packet_unref(&pkt); + } + av_fifo_free(q->async_fifo); + q->async_fifo = NULL; return 0; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvenc.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvenc.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvenc.h 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvenc.h 2015-07-19 17:20:03.000000000 +0000 @@ -29,6 +29,7 @@ #include #include "libavutil/avutil.h" +#include "libavutil/fifo.h" #include "avcodec.h" #include "qsv_internal.h" @@ -39,9 +40,11 @@ QSVFrame *work_frames; mfxSession session; - mfxSession internal_session; + QSVSession internal_qs; int packet_size; + int width_align; + int height_align; mfxVideoParam param; mfxFrameAllocRequest req; @@ -49,6 +52,8 @@ mfxExtCodingOption extco; mfxExtBuffer *extparam[1]; + AVFifoBuffer *async_fifo; + // options set by the caller int async_depth; int idr_interval; @@ -56,6 +61,8 @@ int preset; int avbr_accuracy; int avbr_convergence; + + char *load_plugins; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvenc_h264.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvenc_h264.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvenc_h264.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvenc_h264.c 2015-07-28 17:20:07.000000000 +0000 @@ -76,10 +76,14 @@ { "main" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_MAIN }, INT_MIN, INT_MAX, VE, "profile" }, { "high" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_HIGH }, INT_MIN, INT_MAX, VE, "profile" }, - { "preset", NULL, OFFSET(qsv.preset), AV_OPT_TYPE_INT, { .i64 = MFX_TARGETUSAGE_BALANCED }, 0, 7, VE, "preset" }, - { "fast", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_SPEED }, INT_MIN, INT_MAX, VE, "preset" }, - { "medium", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BALANCED }, INT_MIN, INT_MAX, VE, "preset" }, - { "slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_QUALITY }, INT_MIN, INT_MAX, VE, "preset" }, + { "preset", NULL, OFFSET(qsv.preset), AV_OPT_TYPE_INT, { .i64 = MFX_TARGETUSAGE_BALANCED }, MFX_TARGETUSAGE_BEST_QUALITY, MFX_TARGETUSAGE_BEST_SPEED, VE, "preset" }, + { "veryfast", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_SPEED }, INT_MIN, INT_MAX, VE, "preset" }, + { "faster", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_6 }, INT_MIN, INT_MAX, VE, "preset" }, + { "fast", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_5 }, INT_MIN, INT_MAX, VE, "preset" }, + { "medium", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BALANCED }, INT_MIN, INT_MAX, VE, "preset" }, + { "slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_3 }, INT_MIN, INT_MAX, VE, "preset" }, + { "slower", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_2 }, INT_MIN, INT_MAX, VE, "preset" }, + { "veryslow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_QUALITY }, INT_MIN, INT_MAX, VE, "preset" }, { NULL }, }; @@ -112,7 +116,7 @@ .init = qsv_enc_init, .encode2 = qsv_enc_frame, .close = qsv_enc_close, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, AV_PIX_FMT_QSV, AV_PIX_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvenc_hevc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvenc_hevc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvenc_hevc.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvenc_hevc.c 2015-07-28 17:20:07.000000000 +0000 @@ -0,0 +1,272 @@ +/* + * Intel MediaSDK QSV based HEVC encoder + * + * 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 +#include + +#include + +#include "libavutil/common.h" +#include "libavutil/opt.h" + +#include "avcodec.h" +#include "bytestream.h" +#include "get_bits.h" +#include "hevc.h" +#include "internal.h" +#include "qsv.h" +#include "qsv_internal.h" +#include "qsvenc.h" + +enum LoadPlugin { + LOAD_PLUGIN_NONE, + LOAD_PLUGIN_HEVC_SW, + LOAD_PLUGIN_HEVC_HW, +}; + +typedef struct QSVHEVCEncContext { + AVClass *class; + QSVEncContext qsv; + int load_plugin; +} QSVHEVCEncContext; + +static int generate_fake_vps(QSVEncContext *q, AVCodecContext *avctx) +{ + GetByteContext gbc; + PutByteContext pbc; + + GetBitContext gb; + HEVCNAL sps_nal = { NULL }; + HEVCSPS sps = { 0 }; + HEVCVPS vps = { 0 }; + uint8_t vps_buf[128], vps_rbsp_buf[128]; + uint8_t *new_extradata; + unsigned int sps_id; + int ret, i, type, vps_size; + + if (!avctx->extradata_size) { + av_log(avctx, AV_LOG_ERROR, "No extradata returned from libmfx\n"); + return AVERROR_UNKNOWN; + } + + /* parse the SPS */ + ret = ff_hevc_extract_rbsp(NULL, avctx->extradata + 4, avctx->extradata_size - 4, &sps_nal); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Error unescaping the SPS buffer\n"); + return ret; + } + + ret = init_get_bits8(&gb, sps_nal.data, sps_nal.size); + if (ret < 0) { + av_freep(&sps_nal.rbsp_buffer); + return ret; + } + + get_bits(&gb, 1); + type = get_bits(&gb, 6); + if (type != NAL_SPS) { + av_log(avctx, AV_LOG_ERROR, "Unexpected NAL type in the extradata: %d\n", + type); + av_freep(&sps_nal.rbsp_buffer); + return AVERROR_INVALIDDATA; + } + get_bits(&gb, 9); + + ret = ff_hevc_parse_sps(&sps, &gb, &sps_id, 0, NULL, avctx); + av_freep(&sps_nal.rbsp_buffer); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Error parsing the SPS\n"); + return ret; + } + + /* generate the VPS */ + vps.vps_max_layers = 1; + vps.vps_max_sub_layers = sps.max_sub_layers; + memcpy(&vps.ptl, &sps.ptl, sizeof(vps.ptl)); + vps.vps_sub_layer_ordering_info_present_flag = 1; + for (i = 0; i < MAX_SUB_LAYERS; i++) { + vps.vps_max_dec_pic_buffering[i] = sps.temporal_layer[i].max_dec_pic_buffering; + vps.vps_num_reorder_pics[i] = sps.temporal_layer[i].num_reorder_pics; + vps.vps_max_latency_increase[i] = sps.temporal_layer[i].max_latency_increase; + } + + vps.vps_num_layer_sets = 1; + vps.vps_timing_info_present_flag = sps.vui.vui_timing_info_present_flag; + vps.vps_num_units_in_tick = sps.vui.vui_num_units_in_tick; + vps.vps_time_scale = sps.vui.vui_time_scale; + vps.vps_poc_proportional_to_timing_flag = sps.vui.vui_poc_proportional_to_timing_flag; + vps.vps_num_ticks_poc_diff_one = sps.vui.vui_num_ticks_poc_diff_one_minus1 + 1; + + /* generate the encoded RBSP form of the VPS */ + ret = ff_hevc_encode_nal_vps(&vps, sps.vps_id, vps_rbsp_buf, sizeof(vps_rbsp_buf)); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Error writing the VPS\n"); + return ret; + } + + /* escape and add the startcode */ + bytestream2_init(&gbc, vps_rbsp_buf, ret); + bytestream2_init_writer(&pbc, vps_buf, sizeof(vps_buf)); + + bytestream2_put_be32(&pbc, 1); // startcode + bytestream2_put_byte(&pbc, NAL_VPS << 1); // NAL + bytestream2_put_byte(&pbc, 1); // header + + while (bytestream2_get_bytes_left(&gbc)) { + uint32_t b = bytestream2_peek_be24(&gbc); + if (b <= 3) { + bytestream2_put_be24(&pbc, 3); + bytestream2_skip(&gbc, 2); + } else + bytestream2_put_byte(&pbc, bytestream2_get_byte(&gbc)); + } + + vps_size = bytestream2_tell_p(&pbc); + new_extradata = av_mallocz(vps_size + avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); + if (!new_extradata) + return AVERROR(ENOMEM); + memcpy(new_extradata, vps_buf, vps_size); + memcpy(new_extradata + vps_size, avctx->extradata, avctx->extradata_size); + + av_freep(&avctx->extradata); + avctx->extradata = new_extradata; + avctx->extradata_size += vps_size; + + return 0; +} + +static av_cold int qsv_enc_init(AVCodecContext *avctx) +{ + QSVHEVCEncContext *q = avctx->priv_data; + int ret; + + if (q->load_plugin != LOAD_PLUGIN_NONE) { + static const char *uid_hevcenc_sw = "2fca99749fdb49aeb121a5b63ef568f7"; + static const char *uid_hevcenc_hw = "6fadc791a0c2eb479ab6dcd5ea9da347"; + + if (q->qsv.load_plugins[0]) { + av_log(avctx, AV_LOG_WARNING, + "load_plugins is not empty, but load_plugin is not set to 'none'." + "The load_plugin value will be ignored.\n"); + } else { + av_freep(&q->qsv.load_plugins); + + if (q->load_plugin == LOAD_PLUGIN_HEVC_SW) + q->qsv.load_plugins = av_strdup(uid_hevcenc_sw); + else + q->qsv.load_plugins = av_strdup(uid_hevcenc_hw); + + if (!q->qsv.load_plugins) + return AVERROR(ENOMEM); + } + } + + ret = ff_qsv_enc_init(avctx, &q->qsv); + if (ret < 0) + return ret; + + ret = generate_fake_vps(&q->qsv, avctx); + if (ret < 0) { + ff_qsv_enc_close(avctx, &q->qsv); + return ret; + } + + return 0; +} + +static int qsv_enc_frame(AVCodecContext *avctx, AVPacket *pkt, + const AVFrame *frame, int *got_packet) +{ + QSVHEVCEncContext *q = avctx->priv_data; + + return ff_qsv_encode(avctx, &q->qsv, pkt, frame, got_packet); +} + +static av_cold int qsv_enc_close(AVCodecContext *avctx) +{ + QSVHEVCEncContext *q = avctx->priv_data; + + return ff_qsv_enc_close(avctx, &q->qsv); +} + +#define OFFSET(x) offsetof(QSVHEVCEncContext, x) +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "async_depth", "Maximum processing parallelism", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 0, INT_MAX, VE }, + { "avbr_accuracy", "Accuracy of the AVBR ratecontrol", OFFSET(qsv.avbr_accuracy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, + { "avbr_convergence", "Convergence of the AVBR ratecontrol", OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, + + { "load_plugin", "A user plugin to load in an internal session", OFFSET(load_plugin), AV_OPT_TYPE_INT, { .i64 = LOAD_PLUGIN_HEVC_SW }, LOAD_PLUGIN_NONE, LOAD_PLUGIN_HEVC_HW, VE, "load_plugin" }, + { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_NONE }, 0, 0, VE, "load_plugin" }, + { "hevc_sw", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_HEVC_SW }, 0, 0, VE, "load_plugin" }, + { "hevc_hw", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_HEVC_HW }, 0, 0, VE, "load_plugin" }, + + { "load_plugins", "A :-separate list of hexadecimal plugin UIDs to load in an internal session", + OFFSET(qsv.load_plugins), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, VE }, + + { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" }, + { "unknown", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, VE, "profile" }, + { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAIN }, INT_MIN, INT_MAX, VE, "profile" }, + { "main10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAIN10 }, INT_MIN, INT_MAX, VE, "profile" }, + { "mainsp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAINSP }, INT_MIN, INT_MAX, VE, "profile" }, + + { "preset", NULL, OFFSET(qsv.preset), AV_OPT_TYPE_INT, { .i64 = MFX_TARGETUSAGE_BALANCED }, 0, 7, VE, "preset" }, + { "fast", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_SPEED }, INT_MIN, INT_MAX, VE, "preset" }, + { "medium", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BALANCED }, INT_MIN, INT_MAX, VE, "preset" }, + { "slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_QUALITY }, INT_MIN, INT_MAX, VE, "preset" }, + + { NULL }, +}; + +static const AVClass class = { + .class_name = "hevc_qsv encoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const AVCodecDefault qsv_enc_defaults[] = { + { "b", "1M" }, + { "refs", "0" }, + // same as the x264 default + { "g", "250" }, + { "bf", "3" }, + + { "flags", "+cgop" }, + { NULL }, +}; + +AVCodec ff_hevc_qsv_encoder = { + .name = "hevc_qsv", + .long_name = NULL_IF_CONFIG_SMALL("HEVC (Intel Quick Sync Video acceleration)"), + .priv_data_size = sizeof(QSVHEVCEncContext), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_HEVC, + .init = qsv_enc_init, + .encode2 = qsv_enc_frame, + .close = qsv_enc_close, + .capabilities = AV_CODEC_CAP_DELAY, + .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, + AV_PIX_FMT_QSV, + AV_PIX_FMT_NONE }, + .priv_class = &class, + .defaults = qsv_enc_defaults, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvenc_mpeg2.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvenc_mpeg2.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsvenc_mpeg2.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsvenc_mpeg2.c 2015-07-28 17:20:07.000000000 +0000 @@ -0,0 +1,117 @@ +/* + * Intel MediaSDK QSV based MPEG-2 encoder + * + * 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 +#include + +#include + +#include "libavutil/common.h" +#include "libavutil/opt.h" + +#include "avcodec.h" +#include "internal.h" +#include "qsv.h" +#include "qsv_internal.h" +#include "qsvenc.h" + +typedef struct QSVMpeg2EncContext { + AVClass *class; + QSVEncContext qsv; +} QSVMpeg2EncContext; + +static av_cold int qsv_enc_init(AVCodecContext *avctx) +{ + QSVMpeg2EncContext *q = avctx->priv_data; + + return ff_qsv_enc_init(avctx, &q->qsv); +} + +static int qsv_enc_frame(AVCodecContext *avctx, AVPacket *pkt, + const AVFrame *frame, int *got_packet) +{ + QSVMpeg2EncContext *q = avctx->priv_data; + + return ff_qsv_encode(avctx, &q->qsv, pkt, frame, got_packet); +} + +static av_cold int qsv_enc_close(AVCodecContext *avctx) +{ + QSVMpeg2EncContext *q = avctx->priv_data; + + return ff_qsv_enc_close(avctx, &q->qsv); +} + +#define OFFSET(x) offsetof(QSVMpeg2EncContext, x) +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "async_depth", "Maximum processing parallelism", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 0, INT_MAX, VE }, + { "avbr_accuracy", "Accuracy of the AVBR ratecontrol", OFFSET(qsv.avbr_accuracy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, + { "avbr_convergence", "Convergence of the AVBR ratecontrol", OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, + + { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" }, + { "unknown", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, VE, "profile" }, + { "simple", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_MPEG2_SIMPLE }, INT_MIN, INT_MAX, VE, "profile" }, + { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_MPEG2_MAIN }, INT_MIN, INT_MAX, VE, "profile" }, + { "high", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_MPEG2_HIGH }, INT_MIN, INT_MAX, VE, "profile" }, + + { "preset", NULL, OFFSET(qsv.preset), AV_OPT_TYPE_INT, { .i64 = MFX_TARGETUSAGE_BALANCED }, 0, 7, VE, "preset" }, + { "fast", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_SPEED }, INT_MIN, INT_MAX, VE, "preset" }, + { "medium", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BALANCED }, INT_MIN, INT_MAX, VE, "preset" }, + { "slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_QUALITY }, INT_MIN, INT_MAX, VE, "preset" }, + + { NULL }, +}; + +static const AVClass class = { + .class_name = "mpeg2_qsv encoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const AVCodecDefault qsv_enc_defaults[] = { + { "b", "1M" }, + { "refs", "0" }, + // same as the x264 default + { "g", "250" }, + { "bf", "3" }, + + { "flags", "+cgop" }, + { NULL }, +}; + +AVCodec ff_mpeg2_qsv_encoder = { + .name = "mpeg2_qsv", + .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video (Intel Quick Sync Video acceleration)"), + .priv_data_size = sizeof(QSVMpeg2EncContext), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_MPEG2VIDEO, + .init = qsv_enc_init, + .encode2 = qsv_enc_frame, + .close = qsv_enc_close, + .capabilities = AV_CODEC_CAP_DELAY, + .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, + AV_PIX_FMT_QSV, + AV_PIX_FMT_NONE }, + .priv_class = &class, + .defaults = qsv_enc_defaults, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsv_internal.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsv_internal.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qsv_internal.h 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qsv_internal.h 2015-07-19 17:20:03.000000000 +0000 @@ -21,24 +21,53 @@ #ifndef AVCODEC_QSV_INTERNAL_H #define AVCODEC_QSV_INTERNAL_H +#if CONFIG_VAAPI +#define AVCODEC_QSV_LINUX_SESSION_HANDLE +#endif //CONFIG_VAAPI + +#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE +#include +#include +#if HAVE_UNISTD_H +#include +#endif +#include +#include +#include +#endif + #include #include "libavutil/frame.h" #define QSV_VERSION_MAJOR 1 -#define QSV_VERSION_MINOR 1 +#define QSV_VERSION_MINOR 9 #define ASYNC_DEPTH_DEFAULT 4 // internal parallelism +#define QSV_VERSION_ATLEAST(MAJOR, MINOR) \ + (MFX_VERSION_MAJOR > (MAJOR) || \ + MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR)) + typedef struct QSVFrame { AVFrame *frame; mfxFrameSurface1 *surface; mfxFrameSurface1 surface_internal; + int queued; + struct QSVFrame *next; } QSVFrame; +typedef struct QSVSession { + mfxSession session; +#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE + int fd_display; + VADisplay va_display; +#endif +} QSVSession; + /** * Convert a libmfx error code into a ffmpeg error code. */ @@ -46,6 +75,8 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id); -int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session); +int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs, + const char *load_plugins); +int ff_qsv_close_internal_session(QSVSession *qs); #endif /* AVCODEC_QSV_INTERNAL_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qtrle.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qtrle.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qtrle.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qtrle.c 2015-07-28 17:20:07.000000000 +0000 @@ -523,5 +523,5 @@ .init = qtrle_decode_init, .close = qtrle_decode_end, .decode = qtrle_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/qtrleenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/qtrleenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/qtrleenc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/qtrleenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -58,14 +58,15 @@ * Will contain at ith position the number of consecutive pixels equal to the previous * frame starting from pixel i */ uint8_t* skip_table; + + /** Encoded frame is a key frame */ + int key_frame; } QtrleEncContext; static av_cold int qtrle_encode_end(AVCodecContext *avctx) { QtrleEncContext *s = avctx->priv_data; - av_frame_free(&avctx->coded_frame); - avpicture_free(&s->previous_frame); av_free(s->rlecode_table); av_free(s->length_table); @@ -125,12 +126,6 @@ + s->avctx->height*2 /* skip code+rle end */ + s->logical_width/MAX_RLE_BULK + 1 /* rle codes */; - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) { - qtrle_encode_end(avctx); - return AVERROR(ENOMEM); - } - return 0; } @@ -219,7 +214,7 @@ } } - if (!s->avctx->coded_frame->key_frame && !memcmp(this_line, prev_line, s->pixel_size)) + if (!s->key_frame && !memcmp(this_line, prev_line, s->pixel_size)) skipcount = FFMIN(skipcount + 1, MAX_RLE_SKIP); else skipcount = 0; @@ -330,7 +325,7 @@ int end_line = s->avctx->height; uint8_t *orig_buf = buf; - if (!s->avctx->coded_frame->key_frame) { + if (!s->key_frame) { unsigned line_size = s->logical_width * s->pixel_size; for (start_line = 0; start_line < s->avctx->height; start_line++) if (memcmp(p->data[0] + start_line*p->linesize[0], @@ -368,20 +363,20 @@ const AVFrame *pict, int *got_packet) { QtrleEncContext * const s = avctx->priv_data; - AVFrame * const p = avctx->coded_frame; + enum AVPictureType pict_type; int ret; - if ((ret = ff_alloc_packet2(avctx, pkt, s->max_buf_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, s->max_buf_size, 0)) < 0) return ret; if (avctx->gop_size == 0 || (s->avctx->frame_number % avctx->gop_size) == 0) { /* I-Frame */ - p->pict_type = AV_PICTURE_TYPE_I; - p->key_frame = 1; + pict_type = AV_PICTURE_TYPE_I; + s->key_frame = 1; } else { /* P-Frame */ - p->pict_type = AV_PICTURE_TYPE_P; - p->key_frame = 0; + pict_type = AV_PICTURE_TYPE_P; + s->key_frame = 0; } pkt->size = encode_frame(s, pict, pkt->data); @@ -390,7 +385,14 @@ av_picture_copy(&s->previous_frame, (const AVPicture *)pict, avctx->pix_fmt, avctx->width, avctx->height); - if (p->key_frame) +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->key_frame = s->key_frame; + avctx->coded_frame->pict_type = pict_type; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + if (s->key_frame) pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/r210dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/r210dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/r210dec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/r210dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -103,7 +103,7 @@ .id = AV_CODEC_ID_R210, .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif #if CONFIG_R10K_DECODER @@ -114,7 +114,7 @@ .id = AV_CODEC_ID_R10K, .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif #if CONFIG_AVRP_DECODER @@ -125,6 +125,6 @@ .id = AV_CODEC_ID_AVRP, .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/r210enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/r210enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/r210enc.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/r210enc.c 2015-07-31 17:20:05.000000000 +0000 @@ -24,16 +24,6 @@ #include "internal.h" #include "bytestream.h" -static av_cold int encode_init(AVCodecContext *avctx) -{ - avctx->coded_frame = av_frame_alloc(); - - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - - return 0; -} - static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic, int *got_packet) { @@ -44,11 +34,9 @@ uint8_t *src_line; uint8_t *dst; - if ((ret = ff_alloc_packet2(avctx, pkt, 4 * aligned_width * avctx->height)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, 4 * aligned_width * avctx->height, 0)) < 0) return ret; - avctx->coded_frame->key_frame = 1; - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; src_line = pic->data[0]; dst = pkt->data; @@ -78,12 +66,6 @@ return 0; } -static av_cold int encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - - return 0; -} #if CONFIG_R210_ENCODER AVCodec ff_r210_encoder = { @@ -91,10 +73,9 @@ .long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 10-bit"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_R210, - .init = encode_init, .encode2 = encode_frame, - .close = encode_close, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB48, AV_PIX_FMT_NONE }, + .capabilities = AV_CODEC_CAP_INTRA_ONLY, }; #endif #if CONFIG_R10K_ENCODER @@ -103,10 +84,9 @@ .long_name = NULL_IF_CONFIG_SMALL("AJA Kona 10-bit RGB Codec"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_R10K, - .init = encode_init, .encode2 = encode_frame, - .close = encode_close, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB48, AV_PIX_FMT_NONE }, + .capabilities = AV_CODEC_CAP_INTRA_ONLY, }; #endif #if CONFIG_AVRP_ENCODER @@ -115,9 +95,8 @@ .long_name = NULL_IF_CONFIG_SMALL("Avid 1:1 10-bit RGB Packer"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_AVRP, - .init = encode_init, .encode2 = encode_frame, - .close = encode_close, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB48, AV_PIX_FMT_NONE }, + .capabilities = AV_CODEC_CAP_INTRA_ONLY, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ra144dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ra144dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ra144dec.c 2015-06-19 20:44:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ra144dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -134,5 +134,5 @@ .priv_data_size = sizeof(RA144Context), .init = ra144_decode_init, .decode = ra144_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ra144enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ra144enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ra144enc.c 2015-06-19 20:44:41.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ra144enc.c 2015-07-28 17:20:07.000000000 +0000 @@ -447,7 +447,7 @@ if (ractx->last_frame) return 0; - if ((ret = ff_alloc_packet2(avctx, avpkt, FRAME_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, FRAME_SIZE, 0)) < 0) return ret; /** @@ -551,7 +551,7 @@ .init = ra144_encode_init, .encode2 = ra144_encode_frame, .close = ra144_encode_close, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_SMALL_LAST_FRAME, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .supported_samplerates = (const int[]){ 8000, 0 }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ra288.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ra288.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ra288.c 2015-06-19 20:44:41.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ra288.c 2015-07-28 17:20:07.000000000 +0000 @@ -81,7 +81,7 @@ return AVERROR_PATCHWELCOME; } - ractx->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + ractx->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!ractx->fdsp) return AVERROR(ENOMEM); @@ -247,5 +247,5 @@ .init = ra288_decode_init, .decode = ra288_decode_frame, .close = ra288_decode_close, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ralf.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ralf.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ralf.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ralf.c 2015-07-28 17:20:07.000000000 +0000 @@ -530,7 +530,7 @@ .close = decode_close, .decode = decode_frame, .flush = decode_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ratecontrol.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ratecontrol.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ratecontrol.c 2015-06-19 20:44:41.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ratecontrol.c 2015-07-28 17:20:07.000000000 +0000 @@ -26,6 +26,8 @@ */ #include "libavutil/attributes.h" +#include "libavutil/internal.h" + #include "avcodec.h" #include "internal.h" #include "ratecontrol.h" @@ -144,6 +146,13 @@ return res; } +#if FF_API_RC_STRATEGY +FF_DISABLE_DEPRECATION_WARNINGS + if (!s->rc_strategy) + s->rc_strategy = s->avctx->rc_strategy; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + for (i = 0; i < 5; i++) { rcc->pred[i].coeff = FF_QP2LAMBDA * 7.0; rcc->pred[i].count = 1.0; @@ -161,7 +170,7 @@ if (!rcc->buffer_index) rcc->buffer_index = s->avctx->rc_buffer_size * 3 / 4; - if (s->avctx->flags & CODEC_FLAG_PASS2) { + if (s->avctx->flags & AV_CODEC_FLAG_PASS2) { int i; char *p; @@ -229,7 +238,7 @@ } // FIXME maybe move to end - if ((s->avctx->flags & CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID) { + if ((s->avctx->flags & AV_CODEC_FLAG_PASS2) && s->rc_strategy == 1) { #if CONFIG_LIBXVID return ff_xvid_rate_control_init(s); #else @@ -240,7 +249,7 @@ } } - if (!(s->avctx->flags & CODEC_FLAG_PASS2)) { + if (!(s->avctx->flags & AV_CODEC_FLAG_PASS2)) { rcc->short_term_qsum = 0.001; rcc->short_term_qcount = 0.001; @@ -309,7 +318,7 @@ av_freep(&rcc->entry); #if CONFIG_LIBXVID - if ((s->avctx->flags & CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID) + if ((s->avctx->flags & AV_CODEC_FLAG_PASS2) && s->rc_strategy == 1) ff_xvid_rate_control_uninit(s); #endif } @@ -762,8 +771,7 @@ emms_c(); #if CONFIG_LIBXVID - if ((s->avctx->flags & CODEC_FLAG_PASS2) && - s->avctx->rc_strategy == FF_RC_STRATEGY_XVID) + if ((s->avctx->flags & AV_CODEC_FLAG_PASS2) && s->rc_strategy == 1) return ff_xvid_rate_estimate_qscale(s, dry_run); #endif @@ -782,7 +790,7 @@ s->frame_bits - s->stuffing_bits); } - if (s->avctx->flags & CODEC_FLAG_PASS2) { + if (s->avctx->flags & AV_CODEC_FLAG_PASS2) { av_assert0(picture_number >= 0); if (picture_number >= rcc->num_entries) { av_log(s, AV_LOG_ERROR, "Input is longer than 2-pass log file\n"); @@ -816,7 +824,7 @@ var = pict_type == AV_PICTURE_TYPE_I ? pic->mb_var_sum : pic->mc_mb_var_sum; short_term_q = 0; /* avoid warning */ - if (s->avctx->flags & CODEC_FLAG_PASS2) { + if (s->avctx->flags & AV_CODEC_FLAG_PASS2) { if (pict_type != AV_PICTURE_TYPE_I) av_assert0(pict_type == rce->new_pict_type); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/rawdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/rawdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/rawdec.c 2015-06-19 20:44:41.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/rawdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -372,5 +372,5 @@ .close = raw_close_decoder, .decode = raw_decode, .priv_class = &rawdec_class, - .capabilities = CODEC_CAP_PARAM_CHANGE, + .capabilities = AV_CODEC_CAP_PARAM_CHANGE, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/rawenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/rawenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/rawenc.c 2015-06-19 20:44:41.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/rawenc.c 2015-08-03 17:20:02.000000000 +0000 @@ -35,11 +35,11 @@ { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; +FF_ENABLE_DEPRECATION_WARNINGS +#endif avctx->bits_per_coded_sample = av_get_bits_per_pixel(desc); if(!avctx->codec_tag) avctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt); @@ -54,7 +54,7 @@ if (ret < 0) return ret; - if ((ret = ff_alloc_packet2(avctx, pkt, ret)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, ret, ret)) < 0) return ret; if ((ret = avpicture_layout((const AVPicture *)frame, avctx->pix_fmt, avctx->width, avctx->height, pkt->data, pkt->size)) < 0) @@ -71,18 +71,11 @@ return 0; } -static av_cold int raw_encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - return 0; -} - AVCodec ff_rawvideo_encoder = { .name = "rawvideo", .long_name = NULL_IF_CONFIG_SMALL("raw video"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_RAWVIDEO, .init = raw_encode_init, - .close = raw_encode_close, .encode2 = raw_encode, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/remove_extradata_bsf.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/remove_extradata_bsf.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/remove_extradata_bsf.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/remove_extradata_bsf.c 2015-07-28 17:20:07.000000000 +0000 @@ -33,7 +33,8 @@ s= bsfc->parser; if(s && s->parser->split){ - if( (((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) || (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)) && cmd=='a') + if( (((avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) || + (avctx->flags2 & AV_CODEC_FLAG2_LOCAL_HEADER)) && cmd == 'a') ||(!keyframe && cmd=='k') ||(cmd=='e' || !cmd) ){ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/rl2.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/rl2.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/rl2.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/rl2.c 2015-07-28 17:20:07.000000000 +0000 @@ -222,5 +222,5 @@ .init = rl2_decode_init, .close = rl2_decode_end, .decode = rl2_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/roqaudioenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/roqaudioenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/roqaudioenc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/roqaudioenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -160,7 +160,7 @@ else data_size = avctx->channels * avctx->frame_size; - if ((ret = ff_alloc_packet2(avctx, avpkt, ROQ_HEADER_SIZE + data_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, ROQ_HEADER_SIZE + data_size, 0)) < 0) return ret; out = avpkt->data; @@ -198,7 +198,7 @@ .init = roq_dpcm_encode_init, .encode2 = roq_dpcm_encode_frame, .close = roq_dpcm_encode_close, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/roqvideodec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/roqvideodec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/roqvideodec.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/roqvideodec.c 2015-07-28 17:20:07.000000000 +0000 @@ -244,5 +244,5 @@ .init = roq_decode_init, .close = roq_decode_end, .decode = roq_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/roqvideoenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/roqvideoenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/roqvideoenc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/roqvideoenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -960,9 +960,6 @@ reconstruct_and_encode_image(enc, tempData, enc->width, enc->height, enc->width*enc->height/64); - av_frame_unref(enc->avctx->coded_frame); - av_frame_ref(enc->avctx->coded_frame, enc->current_frame); - /* Rotate frame history */ FFSWAP(AVFrame *, enc->current_frame, enc->last_frame); FFSWAP(motion_vect *, enc->last_motion4, enc->this_motion4); @@ -982,7 +979,6 @@ av_frame_free(&enc->current_frame); av_frame_free(&enc->last_frame); - av_frame_free(&enc->avctx->coded_frame); av_freep(&enc->tmpData); av_freep(&enc->this_motion4); @@ -1023,8 +1019,7 @@ enc->last_frame = av_frame_alloc(); enc->current_frame = av_frame_alloc(); - avctx->coded_frame = av_frame_alloc(); - if (!enc->last_frame || !enc->current_frame || !avctx->coded_frame) { + if (!enc->last_frame || !enc->current_frame) { roq_encode_end(avctx); return AVERROR(ENOMEM); } @@ -1095,7 +1090,7 @@ /* 138 bits max per 8x8 block + * 256 codebooks*(6 bytes 2x2 + 4 bytes 4x4) + 8 bytes frame header */ size = ((enc->width * enc->height / 64) * 138 + 7) / 8 + 256 * (6 + 4) + 8; - if ((ret = ff_alloc_packet2(avctx, pkt, size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0) return ret; enc->out_buf = pkt->data; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/rpza.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/rpza.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/rpza.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/rpza.c 2015-07-28 17:20:07.000000000 +0000 @@ -280,5 +280,5 @@ .init = rpza_decode_init, .close = rpza_decode_end, .decode = rpza_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv10.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv10.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv10.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv10.c 2015-07-28 17:20:07.000000000 +0000 @@ -32,12 +32,14 @@ #include "avcodec.h" #include "error_resilience.h" #include "h263.h" +#include "h263data.h" #include "internal.h" #include "mpeg_er.h" #include "mpegutils.h" #include "mpegvideo.h" #include "mpeg4video.h" #include "mpegvideodata.h" +#include "rv10.h" #define RV_GET_MAJOR_VER(x) ((x) >> 28) #define RV_GET_MINOR_VER(x) (((x) >> 20) & 0xFF) @@ -795,7 +797,7 @@ .init = rv10_decode_init, .close = rv10_decode_end, .decode = rv10_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .max_lowres = 3, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, @@ -812,7 +814,7 @@ .init = rv10_decode_init, .close = rv10_decode_end, .decode = rv10_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .flush = ff_mpeg_flush, .max_lowres = 3, .pix_fmts = (const enum AVPixelFormat[]) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv10enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv10enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv10enc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv10enc.c 2015-06-13 17:20:02.000000000 +0000 @@ -27,6 +27,7 @@ #include "mpegvideo.h" #include "put_bits.h" +#include "rv10.h" int ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number) { @@ -62,7 +63,12 @@ return 0; } -FF_MPV_GENERIC_CLASS(rv10) +static const AVClass rv10_class = { + .class_name = "rv10 encoder", + .item_name = av_default_item_name, + .option = ff_mpv_generic_options, + .version = LIBAVUTIL_VERSION_INT, +}; AVCodec ff_rv10_encoder = { .name = "rv10", diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv10.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv10.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv10.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv10.h 2015-06-13 17:20:02.000000000 +0000 @@ -0,0 +1,33 @@ +/* + * RV10/RV20 decoder + * + * 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 + */ + +#ifndef AVCODEC_RV10_H +#define AVCODEC_RV10_H + +#include + +#include "mpegvideo.h" + +int ff_rv_decode_dc(MpegEncContext *s, int n); + +int ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number); +void ff_rv20_encode_picture_header(MpegEncContext *s, int picture_number); + +#endif /* AVCODEC_RV10_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv20enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv20enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv20enc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv20enc.c 2015-06-13 17:20:02.000000000 +0000 @@ -28,7 +28,9 @@ #include "mpegvideo.h" #include "mpegvideodata.h" #include "h263.h" +#include "h263data.h" #include "put_bits.h" +#include "rv10.h" void ff_rv20_encode_picture_header(MpegEncContext *s, int picture_number){ put_bits(&s->pb, 2, s->pict_type); //I 0 vs. 1 ? @@ -58,7 +60,12 @@ } } -FF_MPV_GENERIC_CLASS(rv20) +static const AVClass rv20_class = { + .class_name = "rv20 encoder", + .item_name = av_default_item_name, + .option = ff_mpv_generic_options, + .version = LIBAVUTIL_VERSION_INT, +}; AVCodec ff_rv20_encoder = { .name = "rv20", diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv30.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv30.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv30.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv30.c 2015-07-28 17:20:07.000000000 +0000 @@ -291,8 +291,8 @@ .init = rv30_decode_init, .close = ff_rv34_decode_end, .decode = ff_rv34_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | - CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_FRAME_THREADS, .flush = ff_mpeg_flush, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv34.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv34.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv34.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv34.c 2015-07-18 17:20:03.000000000 +0000 @@ -1534,7 +1534,14 @@ if (avctx->internal->is_copy) { r->tmp_b_block_base = NULL; + r->cbp_chroma = NULL; + r->cbp_luma = NULL; + r->deblock_coefs = NULL; + r->intra_types_hist = NULL; + r->mb_type = NULL; + ff_mpv_idct_init(&r->s); + if ((err = ff_mpv_common_init(&r->s)) < 0) return err; if ((err = rv34_decoder_alloc(r)) < 0) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv40.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv40.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/rv40.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/rv40.c 2015-07-28 17:20:07.000000000 +0000 @@ -574,8 +574,8 @@ .init = rv40_decode_init, .close = ff_rv34_decode_end, .decode = ff_rv34_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | - CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_FRAME_THREADS, .flush = ff_mpeg_flush, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/s302m.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/s302m.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/s302m.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/s302m.c 2015-07-28 17:20:07.000000000 +0000 @@ -85,10 +85,6 @@ case 8: avctx->channel_layout = AV_CH_LAYOUT_5POINT1_BACK | AV_CH_LAYOUT_STEREO_DOWNMIX; } - avctx->bit_rate = 48000 * avctx->channels * (avctx->bits_per_raw_sample + 4) + - 32 * (48000 / (buf_size * 8 / - (avctx->channels * - (avctx->bits_per_raw_sample + 4)))); return frame_size; } @@ -117,6 +113,8 @@ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; + avctx->bit_rate = 48000 * avctx->channels * (avctx->bits_per_raw_sample + 4) + + 32 * 48000 / frame->nb_samples; buf_size = (frame->nb_samples * avctx->channels / 2) * block_size; if (avctx->bits_per_raw_sample == 24) { @@ -227,6 +225,6 @@ .id = AV_CODEC_ID_S302M, .priv_data_size = sizeof(S302Context), .decode = s302m_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .priv_class = &s302m_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/s302menc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/s302menc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/s302menc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/s302menc.c 2015-07-28 17:20:07.000000000 +0000 @@ -78,7 +78,7 @@ uint8_t *o; PutBitContext pb; - if ((ret = ff_alloc_packet2(avctx, avpkt, buf_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, buf_size, 0)) < 0) return ret; o = avpkt->data; @@ -173,6 +173,6 @@ .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, - .capabilities = CODEC_CAP_VARIABLE_FRAME_SIZE | CODEC_CAP_EXPERIMENTAL, + .capabilities = AV_CODEC_CAP_VARIABLE_FRAME_SIZE | AV_CODEC_CAP_EXPERIMENTAL, .supported_samplerates = (const int[]) { 48000, 0 }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/s3tc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/s3tc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/s3tc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/s3tc.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -/* - * S3 Texture Compression (S3TC) decoding functions - * Copyright (c) 2007 by Ivo van Poorten - * - * see also: http://wiki.multimedia.cx/index.php?title=S3TC - * - * 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 "avcodec.h" -#include "bytestream.h" -#include "s3tc.h" - -static inline void dxt1_decode_pixels(GetByteContext *gb, uint32_t *d, - unsigned int w, unsigned int h, - unsigned int qstride, unsigned int flag, - uint64_t alpha) { - unsigned int x, y, c0, c1, a = (!flag * 255u) << 24; - unsigned int rb0, rb1, rb2, rb3, g0, g1, g2, g3; - uint32_t colors[4], pixels; - - c0 = bytestream2_get_le16(gb); - c1 = bytestream2_get_le16(gb); - - rb0 = (c0<<3 | c0<<8) & 0xf800f8; - rb1 = (c1<<3 | c1<<8) & 0xf800f8; - rb0 += (rb0>>5) & 0x070007; - rb1 += (rb1>>5) & 0x070007; - g0 = (c0 <<5) & 0x00fc00; - g1 = (c1 <<5) & 0x00fc00; - g0 += (g0 >>6) & 0x000300; - g1 += (g1 >>6) & 0x000300; - - colors[0] = rb0 + g0 + a; - colors[1] = rb1 + g1 + a; - - if (c0 > c1 || flag) { - rb2 = (((2*rb0+rb1) * 21) >> 6) & 0xff00ff; - rb3 = (((2*rb1+rb0) * 21) >> 6) & 0xff00ff; - g2 = (((2*g0 +g1 ) * 21) >> 6) & 0x00ff00; - g3 = (((2*g1 +g0 ) * 21) >> 6) & 0x00ff00; - colors[3] = rb3 + g3 + a; - } else { - rb2 = ((rb0+rb1) >> 1) & 0xff00ff; - g2 = ((g0 +g1 ) >> 1) & 0x00ff00; - colors[3] = 0; - } - - colors[2] = rb2 + g2 + a; - - pixels = bytestream2_get_le32(gb); - for (y=0; y> 4; - d[x] = a + colors[pixels&3]; - pixels >>= 2; - alpha >>= 4; - } - for (; x<4; x++) { - pixels >>= 2; - alpha >>= 4; - } - d += qstride; - } -} - -void ff_decode_dxt1(GetByteContext *gb, uint8_t *dst, - const unsigned int w, const unsigned int h, - const unsigned int stride) { - unsigned int x, y, qstride = stride/4; - uint32_t *d = (uint32_t *) dst; - - for (y=0; y < h; y += 4, d += stride-w) - for (x = 0; x < w; d += FFMIN(4, w-x), x += 4) - dxt1_decode_pixels(gb, d, FFMIN(4, w-x), FFMIN(4, h-y), qstride, 0, 0LL); -} - -void ff_decode_dxt3(GetByteContext *gb, uint8_t *dst, - const unsigned int w, const unsigned int h, - const unsigned int stride) { - unsigned int x, y, qstride = stride/4; - uint32_t *d = (uint32_t *) dst; - - for (y=0; y < h; y += 4, d += stride-w) - for (x = 0; x < w; d += FFMIN(4, w-x), x += 4) - dxt1_decode_pixels(gb, d, FFMIN(4, w-x), FFMIN(4, h-y), qstride, 1, bytestream2_get_le64(gb)); -} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/s3tc.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/s3tc.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/s3tc.h 2015-03-13 17:34:47.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/s3tc.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -/* - * S3 Texture Compression (S3TC) decoding functions - * Copyright (c) 2007 by Ivo van Poorten - * - * 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 - */ - -#ifndef AVCODEC_S3TC_H -#define AVCODEC_S3TC_H - -#include - -#include "bytestream.h" - -#define FF_S3TC_DXT1 0x31545844 -#define FF_S3TC_DXT3 0x33545844 - -/** - * Decode DXT1 encoded data to RGB32 - * @param gb GetByteContext - * @param dst destination buffer - * @param w width of output image - * @param h height of output image - * @param stride line size of output image - */ -void ff_decode_dxt1(GetByteContext *gb, uint8_t *dst, - const unsigned int w, const unsigned int h, - const unsigned int stride); -/** - * Decode DXT3 encoded data to RGB32 - * @param gb GetByteContext - * @param dst destination buffer - * @param w width of output image - * @param h height of output image - * @param stride line size of output image - */ -void ff_decode_dxt3(GetByteContext *gb, uint8_t *dst, - const unsigned int w, const unsigned int h, - const unsigned int stride); - -#endif /* AVCODEC_S3TC_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sanm.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sanm.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sanm.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sanm.c 2015-07-28 17:20:07.000000000 +0000 @@ -457,6 +457,7 @@ ctx->frm0_size = ctx->frm1_size = ctx->frm2_size = 0; + init_sizes(ctx, 0, 0); } static av_cold int init_buffers(SANMVideoContext *ctx) @@ -1524,5 +1525,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sbrdsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sbrdsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sbrdsp.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sbrdsp.c 2015-07-20 17:20:03.000000000 +0000 @@ -20,20 +20,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#define USE_FIXED 0 + +#include "aac.h" #include "config.h" #include "libavutil/attributes.h" #include "libavutil/intfloat.h" #include "sbrdsp.h" -static void sbr_sum64x5_c(float *z) -{ - int k; - for (k = 0; k < 64; k++) { - float f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256]; - z[k] = f; - } -} - static float sbr_sum_square_c(float (*x)[2], int n) { float sum0 = 0.0f, sum1 = 0.0f; @@ -101,16 +95,6 @@ } } -static void sbr_qmf_deint_bfly_c(float *v, const float *src0, const float *src1) -{ - int i; - for (i = 0; i < 64; i++) { - v[ i] = src0[i] - src1[63 - i]; - v[127 - i] = src0[i] + src1[63 - i]; - } -} - - #if 0 /* This code is slower because it multiplies memory accesses. * It is left for educational purposes and because it may offer @@ -238,58 +222,4 @@ } } -static void sbr_hf_apply_noise_0(float (*Y)[2], const float *s_m, - const float *q_filt, int noise, - int kx, int m_max) -{ - sbr_hf_apply_noise(Y, s_m, q_filt, noise, 1.0, 0.0, m_max); -} - -static void sbr_hf_apply_noise_1(float (*Y)[2], const float *s_m, - const float *q_filt, int noise, - int kx, int m_max) -{ - float phi_sign = 1 - 2 * (kx & 1); - sbr_hf_apply_noise(Y, s_m, q_filt, noise, 0.0, phi_sign, m_max); -} - -static void sbr_hf_apply_noise_2(float (*Y)[2], const float *s_m, - const float *q_filt, int noise, - int kx, int m_max) -{ - sbr_hf_apply_noise(Y, s_m, q_filt, noise, -1.0, 0.0, m_max); -} - -static void sbr_hf_apply_noise_3(float (*Y)[2], const float *s_m, - const float *q_filt, int noise, - int kx, int m_max) -{ - float phi_sign = 1 - 2 * (kx & 1); - sbr_hf_apply_noise(Y, s_m, q_filt, noise, 0.0, -phi_sign, m_max); -} - -av_cold void ff_sbrdsp_init(SBRDSPContext *s) -{ - s->sum64x5 = sbr_sum64x5_c; - s->sum_square = sbr_sum_square_c; - s->neg_odd_64 = sbr_neg_odd_64_c; - s->qmf_pre_shuffle = sbr_qmf_pre_shuffle_c; - s->qmf_post_shuffle = sbr_qmf_post_shuffle_c; - s->qmf_deint_neg = sbr_qmf_deint_neg_c; - s->qmf_deint_bfly = sbr_qmf_deint_bfly_c; - s->autocorrelate = sbr_autocorrelate_c; - s->hf_gen = sbr_hf_gen_c; - s->hf_g_filt = sbr_hf_g_filt_c; - - s->hf_apply_noise[0] = sbr_hf_apply_noise_0; - s->hf_apply_noise[1] = sbr_hf_apply_noise_1; - s->hf_apply_noise[2] = sbr_hf_apply_noise_2; - s->hf_apply_noise[3] = sbr_hf_apply_noise_3; - - if (ARCH_ARM) - ff_sbrdsp_init_arm(s); - if (ARCH_X86) - ff_sbrdsp_init_x86(s); - if (ARCH_MIPS) - ff_sbrdsp_init_mips(s); -} +#include "sbrdsp_template.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sbrdsp_fixed.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sbrdsp_fixed.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sbrdsp_fixed.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sbrdsp_fixed.c 2015-07-20 17:20:03.000000000 +0000 @@ -0,0 +1,286 @@ +/* + * AAC Spectral Band Replication decoding functions + * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) + * Copyright (c) 2009-2010 Alex Converse + * + * 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 + * + * Note: Rounding-to-nearest used unless otherwise stated + * + */ + +#define USE_FIXED 1 + +#include "aac.h" +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/intfloat.h" +#include "sbrdsp.h" + +static SoftFloat sbr_sum_square_c(int (*x)[2], int n) +{ + SoftFloat ret; + int64_t accu = 0; + int i, nz, round; + + for (i = 0; i < n; i += 2) { + accu += (int64_t)x[i + 0][0] * x[i + 0][0]; + accu += (int64_t)x[i + 0][1] * x[i + 0][1]; + accu += (int64_t)x[i + 1][0] * x[i + 1][0]; + accu += (int64_t)x[i + 1][1] * x[i + 1][1]; + } + + i = (int)(accu >> 32); + if (i == 0) { + nz = 1; + } else { + nz = 0; + while (FFABS(i) < 0x40000000) { + i <<= 1; + nz++; + } + nz = 32 - nz; + } + + round = 1 << (nz-1); + i = (int)((accu + round) >> nz); + i >>= 1; + ret = av_int2sf(i, 15 - nz); + + return ret; +} + +static void sbr_neg_odd_64_c(int *x) +{ + int i; + for (i = 1; i < 64; i += 2) + x[i] = -x[i]; +} + +static void sbr_qmf_pre_shuffle_c(int *z) +{ + int k; + z[64] = z[0]; + z[65] = z[1]; + for (k = 1; k < 32; k++) { + z[64+2*k ] = -z[64 - k]; + z[64+2*k+1] = z[ k + 1]; + } +} + +static void sbr_qmf_post_shuffle_c(int W[32][2], const int *z) +{ + int k; + for (k = 0; k < 32; k++) { + W[k][0] = -z[63-k]; + W[k][1] = z[k]; + } +} + +static void sbr_qmf_deint_neg_c(int *v, const int *src) +{ + int i; + for (i = 0; i < 32; i++) { + v[ i] = ( src[63 - 2*i ] + 0x10) >> 5; + v[63 - i] = (-src[63 - 2*i - 1] + 0x10) >> 5; + } +} + +static av_always_inline SoftFloat autocorr_calc(int64_t accu) +{ + int nz, mant, expo, round; + int i = (int)(accu >> 32); + if (i == 0) { + nz = 1; + } else { + nz = 0; + while (FFABS(i) < 0x40000000) { + i <<= 1; + nz++; + } + nz = 32-nz; + } + + round = 1 << (nz-1); + mant = (int)((accu + round) >> nz); + mant = (mant + 0x40)>>7; + mant <<= 6; + expo = nz + 15; + return av_int2sf(mant, 30 - expo); +} + +static av_always_inline void autocorrelate(const int x[40][2], SoftFloat phi[3][2][2], int lag) +{ + int i; + int64_t real_sum, imag_sum; + int64_t accu_re = 0, accu_im = 0; + + if (lag) { + for (i = 1; i < 38; i++) { + accu_re += (int64_t)x[i][0] * x[i+lag][0]; + accu_re += (int64_t)x[i][1] * x[i+lag][1]; + accu_im += (int64_t)x[i][0] * x[i+lag][1]; + accu_im -= (int64_t)x[i][1] * x[i+lag][0]; + } + + real_sum = accu_re; + imag_sum = accu_im; + + accu_re += (int64_t)x[ 0][0] * x[lag][0]; + accu_re += (int64_t)x[ 0][1] * x[lag][1]; + accu_im += (int64_t)x[ 0][0] * x[lag][1]; + accu_im -= (int64_t)x[ 0][1] * x[lag][0]; + + phi[2-lag][1][0] = autocorr_calc(accu_re); + phi[2-lag][1][1] = autocorr_calc(accu_im); + + if (lag == 1) { + accu_re = real_sum; + accu_im = imag_sum; + accu_re += (int64_t)x[38][0] * x[39][0]; + accu_re += (int64_t)x[38][1] * x[39][1]; + accu_im += (int64_t)x[38][0] * x[39][1]; + accu_im -= (int64_t)x[38][1] * x[39][0]; + + phi[0][0][0] = autocorr_calc(accu_re); + phi[0][0][1] = autocorr_calc(accu_im); + } + } else { + for (i = 1; i < 38; i++) { + accu_re += (int64_t)x[i][0] * x[i][0]; + accu_re += (int64_t)x[i][1] * x[i][1]; + } + real_sum = accu_re; + accu_re += (int64_t)x[ 0][0] * x[ 0][0]; + accu_re += (int64_t)x[ 0][1] * x[ 0][1]; + + phi[2][1][0] = autocorr_calc(accu_re); + + accu_re = real_sum; + accu_re += (int64_t)x[38][0] * x[38][0]; + accu_re += (int64_t)x[38][1] * x[38][1]; + + phi[1][0][0] = autocorr_calc(accu_re); + } +} + +static void sbr_autocorrelate_c(const int x[40][2], SoftFloat phi[3][2][2]) +{ + autocorrelate(x, phi, 0); + autocorrelate(x, phi, 1); + autocorrelate(x, phi, 2); +} + +static void sbr_hf_gen_c(int (*X_high)[2], const int (*X_low)[2], + const int alpha0[2], const int alpha1[2], + int bw, int start, int end) +{ + int alpha[4]; + int i; + int64_t accu; + + accu = (int64_t)alpha0[0] * bw; + alpha[2] = (int)((accu + 0x40000000) >> 31); + accu = (int64_t)alpha0[1] * bw; + alpha[3] = (int)((accu + 0x40000000) >> 31); + accu = (int64_t)bw * bw; + bw = (int)((accu + 0x40000000) >> 31); + accu = (int64_t)alpha1[0] * bw; + alpha[0] = (int)((accu + 0x40000000) >> 31); + accu = (int64_t)alpha1[1] * bw; + alpha[1] = (int)((accu + 0x40000000) >> 31); + + for (i = start; i < end; i++) { + accu = (int64_t)X_low[i][0] * 0x20000000; + accu += (int64_t)X_low[i - 2][0] * alpha[0]; + accu -= (int64_t)X_low[i - 2][1] * alpha[1]; + accu += (int64_t)X_low[i - 1][0] * alpha[2]; + accu -= (int64_t)X_low[i - 1][1] * alpha[3]; + X_high[i][0] = (int)((accu + 0x10000000) >> 29); + + accu = (int64_t)X_low[i][1] * 0x20000000; + accu += (int64_t)X_low[i - 2][1] * alpha[0]; + accu += (int64_t)X_low[i - 2][0] * alpha[1]; + accu += (int64_t)X_low[i - 1][1] * alpha[2]; + accu += (int64_t)X_low[i - 1][0] * alpha[3]; + X_high[i][1] = (int)((accu + 0x10000000) >> 29); + } +} + +static void sbr_hf_g_filt_c(int (*Y)[2], const int (*X_high)[40][2], + const SoftFloat *g_filt, int m_max, intptr_t ixh) +{ + int m, r; + int64_t accu; + + for (m = 0; m < m_max; m++) { + r = 1 << (22-g_filt[m].exp); + accu = (int64_t)X_high[m][ixh][0] * ((g_filt[m].mant + 0x40)>>7); + Y[m][0] = (int)((accu + r) >> (23-g_filt[m].exp)); + + accu = (int64_t)X_high[m][ixh][1] * ((g_filt[m].mant + 0x40)>>7); + Y[m][1] = (int)((accu + r) >> (23-g_filt[m].exp)); + } +} + +static av_always_inline void sbr_hf_apply_noise(int (*Y)[2], + const SoftFloat *s_m, + const SoftFloat *q_filt, + int noise, + int phi_sign0, + int phi_sign1, + int m_max) +{ + int m; + + for (m = 0; m < m_max; m++) { + int y0 = Y[m][0]; + int y1 = Y[m][1]; + noise = (noise + 1) & 0x1ff; + if (s_m[m].mant) { + int shift, round; + + shift = 22 - s_m[m].exp; + if (shift < 30) { + round = 1 << (shift-1); + y0 += (s_m[m].mant * phi_sign0 + round) >> shift; + y1 += (s_m[m].mant * phi_sign1 + round) >> shift; + } + } else { + int shift, round, tmp; + int64_t accu; + + shift = 22 - q_filt[m].exp; + if (shift < 30) { + round = 1 << (shift-1); + + accu = (int64_t)q_filt[m].mant * ff_sbr_noise_table_fixed[noise][0]; + tmp = (int)((accu + 0x40000000) >> 31); + y0 += (tmp + round) >> shift; + + accu = (int64_t)q_filt[m].mant * ff_sbr_noise_table_fixed[noise][1]; + tmp = (int)((accu + 0x40000000) >> 31); + y1 += (tmp + round) >> shift; + } + } + Y[m][0] = y0; + Y[m][1] = y1; + phi_sign1 = -phi_sign1; + } +} + +#include "sbrdsp_template.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sbrdsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/sbrdsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sbrdsp.h 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sbrdsp.h 2015-07-20 17:20:03.000000000 +0000 @@ -22,29 +22,31 @@ #define AVCODEC_SBRDSP_H #include +#include "aac_defines.h" +#include "libavutil/softfloat.h" typedef struct SBRDSPContext { - void (*sum64x5)(float *z); - float (*sum_square)(float (*x)[2], int n); - void (*neg_odd_64)(float *x); - void (*qmf_pre_shuffle)(float *z); - void (*qmf_post_shuffle)(float W[32][2], const float *z); - void (*qmf_deint_neg)(float *v, const float *src); - void (*qmf_deint_bfly)(float *v, const float *src0, const float *src1); - void (*autocorrelate)(const float x[40][2], float phi[3][2][2]); - void (*hf_gen)(float (*X_high)[2], const float (*X_low)[2], - const float alpha0[2], const float alpha1[2], - float bw, int start, int end); - void (*hf_g_filt)(float (*Y)[2], const float (*X_high)[40][2], - const float *g_filt, int m_max, intptr_t ixh); - void (*hf_apply_noise[4])(float (*Y)[2], const float *s_m, - const float *q_filt, int noise, + void (*sum64x5)(INTFLOAT *z); + AAC_FLOAT (*sum_square)(INTFLOAT (*x)[2], int n); + void (*neg_odd_64)(INTFLOAT *x); + void (*qmf_pre_shuffle)(INTFLOAT *z); + void (*qmf_post_shuffle)(INTFLOAT W[32][2], const INTFLOAT *z); + void (*qmf_deint_neg)(INTFLOAT *v, const INTFLOAT *src); + void (*qmf_deint_bfly)(INTFLOAT *v, const INTFLOAT *src0, const INTFLOAT *src1); + void (*autocorrelate)(const INTFLOAT x[40][2], AAC_FLOAT phi[3][2][2]); + void (*hf_gen)(INTFLOAT (*X_high)[2], const INTFLOAT (*X_low)[2], + const INTFLOAT alpha0[2], const INTFLOAT alpha1[2], + INTFLOAT bw, int start, int end); + void (*hf_g_filt)(INTFLOAT (*Y)[2], const INTFLOAT (*X_high)[40][2], + const AAC_FLOAT *g_filt, int m_max, intptr_t ixh); + void (*hf_apply_noise[4])(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m, + const AAC_FLOAT *q_filt, int noise, int kx, int m_max); } SBRDSPContext; -extern const float ff_sbr_noise_table[][2]; +extern const INTFLOAT AAC_RENAME(ff_sbr_noise_table)[][2]; -void ff_sbrdsp_init(SBRDSPContext *s); +void AAC_RENAME(ff_sbrdsp_init)(SBRDSPContext *s); void ff_sbrdsp_init_arm(SBRDSPContext *s); void ff_sbrdsp_init_x86(SBRDSPContext *s); void ff_sbrdsp_init_mips(SBRDSPContext *s); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sbrdsp_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sbrdsp_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sbrdsp_template.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sbrdsp_template.c 2015-07-20 17:20:03.000000000 +0000 @@ -0,0 +1,97 @@ +/* + * AAC Spectral Band Replication decoding functions + * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) + * Copyright (c) 2009-2010 Alex Converse + * + * 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 + */ + +static void sbr_sum64x5_c(INTFLOAT *z) +{ + int k; + for (k = 0; k < 64; k++) { + INTFLOAT f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256]; + z[k] = f; + } +} + +static void sbr_qmf_deint_bfly_c(INTFLOAT *v, const INTFLOAT *src0, const INTFLOAT *src1) +{ + int i; + for (i = 0; i < 64; i++) { + v[ i] = AAC_SRA_R((src0[i] - src1[63 - i]), 5); + v[127 - i] = AAC_SRA_R((src0[i] + src1[63 - i]), 5); + } +} + +static void sbr_hf_apply_noise_0(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m, + const AAC_FLOAT *q_filt, int noise, + int kx, int m_max) +{ + sbr_hf_apply_noise(Y, s_m, q_filt, noise, (INTFLOAT)1.0, (INTFLOAT)0.0, m_max); +} + +static void sbr_hf_apply_noise_1(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m, + const AAC_FLOAT *q_filt, int noise, + int kx, int m_max) +{ + INTFLOAT phi_sign = 1 - 2 * (kx & 1); + sbr_hf_apply_noise(Y, s_m, q_filt, noise, (INTFLOAT)0.0, phi_sign, m_max); +} + +static void sbr_hf_apply_noise_2(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m, + const AAC_FLOAT *q_filt, int noise, + int kx, int m_max) +{ + sbr_hf_apply_noise(Y, s_m, q_filt, noise, (INTFLOAT)-1.0, (INTFLOAT)0.0, m_max); +} + +static void sbr_hf_apply_noise_3(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m, + const AAC_FLOAT *q_filt, int noise, + int kx, int m_max) +{ + INTFLOAT phi_sign = 1 - 2 * (kx & 1); + sbr_hf_apply_noise(Y, s_m, q_filt, noise, (INTFLOAT)0.0, -phi_sign, m_max); +} + +av_cold void AAC_RENAME(ff_sbrdsp_init)(SBRDSPContext *s) +{ + s->sum64x5 = sbr_sum64x5_c; + s->sum_square = sbr_sum_square_c; + s->neg_odd_64 = sbr_neg_odd_64_c; + s->qmf_pre_shuffle = sbr_qmf_pre_shuffle_c; + s->qmf_post_shuffle = sbr_qmf_post_shuffle_c; + s->qmf_deint_neg = sbr_qmf_deint_neg_c; + s->qmf_deint_bfly = sbr_qmf_deint_bfly_c; + s->autocorrelate = sbr_autocorrelate_c; + s->hf_gen = sbr_hf_gen_c; + s->hf_g_filt = sbr_hf_g_filt_c; + + s->hf_apply_noise[0] = sbr_hf_apply_noise_0; + s->hf_apply_noise[1] = sbr_hf_apply_noise_1; + s->hf_apply_noise[2] = sbr_hf_apply_noise_2; + s->hf_apply_noise[3] = sbr_hf_apply_noise_3; + +#if !USE_FIXED + if (ARCH_ARM) + ff_sbrdsp_init_arm(s); + if (ARCH_X86) + ff_sbrdsp_init_x86(s); + if (ARCH_MIPS) + ff_sbrdsp_init_mips(s); +#endif /* !USE_FIXED */ +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sbr.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/sbr.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sbr.h 2015-03-15 02:46:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sbr.h 2015-07-20 17:20:03.000000000 +0000 @@ -66,9 +66,9 @@ */ unsigned bs_frame_class; unsigned bs_add_harmonic_flag; - unsigned bs_num_env; + AAC_SIGNE bs_num_env; uint8_t bs_freq_res[7]; - unsigned bs_num_noise; + AAC_SIGNE bs_num_noise; uint8_t bs_df_env[5]; uint8_t bs_df_noise[2]; uint8_t bs_invf_mode[2][5]; @@ -80,25 +80,25 @@ * @name State variables * @{ */ - DECLARE_ALIGNED(32, float, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE]; - DECLARE_ALIGNED(32, float, analysis_filterbank_samples) [1312]; + DECLARE_ALIGNED(32, INTFLOAT, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE]; + DECLARE_ALIGNED(32, INTFLOAT, analysis_filterbank_samples) [1312]; int synthesis_filterbank_samples_offset; ///l_APrev and l_A int e_a[2]; ///Chirp factors - float bw_array[5]; + INTFLOAT bw_array[5]; ///QMF values of the original signal - float W[2][32][32][2]; + INTFLOAT W[2][32][32][2]; ///QMF output of the HF adjustor int Ypos; - DECLARE_ALIGNED(16, float, Y)[2][38][64][2]; - DECLARE_ALIGNED(16, float, g_temp)[42][48]; - float q_temp[42][48]; + DECLARE_ALIGNED(16, INTFLOAT, Y)[2][38][64][2]; + DECLARE_ALIGNED(16, AAC_FLOAT, g_temp)[42][48]; + AAC_FLOAT q_temp[42][48]; uint8_t s_indexmapped[8][48]; ///Envelope scalefactors - float env_facs[6][48]; + AAC_FLOAT env_facs[6][48]; ///Noise scalefactors - float noise_facs[3][5]; + AAC_FLOAT noise_facs[3][5]; ///Envelope time borders uint8_t t_env[8]; ///Envelope time border of the last envelope of the previous frame @@ -117,18 +117,18 @@ */ typedef struct AACSBRContext { int (*sbr_lf_gen)(AACContext *ac, SpectralBandReplication *sbr, - float X_low[32][40][2], const float W[2][32][32][2], + INTFLOAT X_low[32][40][2], const INTFLOAT W[2][32][32][2], int buf_idx); - void (*sbr_hf_assemble)(float Y1[38][64][2], - const float X_high[64][40][2], + void (*sbr_hf_assemble)(INTFLOAT Y1[38][64][2], + const INTFLOAT X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data, const int e_a[2]); - int (*sbr_x_gen)(SpectralBandReplication *sbr, float X[2][38][64], - const float Y0[38][64][2], const float Y1[38][64][2], - const float X_low[32][40][2], int ch); + int (*sbr_x_gen)(SpectralBandReplication *sbr, INTFLOAT X[2][38][64], + const INTFLOAT Y0[38][64][2], const INTFLOAT Y1[38][64][2], + const INTFLOAT X_low[32][40][2], int ch); void (*sbr_hf_inverse_filter)(SBRDSPContext *dsp, - float (*alpha0)[2], float (*alpha1)[2], - const float X_low[32][40][2], int k0); + INTFLOAT (*alpha0)[2], INTFLOAT (*alpha1)[2], + const INTFLOAT X_low[32][40][2], int k0); } AACSBRContext; /** @@ -137,6 +137,7 @@ struct SpectralBandReplication { int sample_rate; int start; + int id_aac; int reset; SpectrumParameters spectrum_params; int bs_amp_res_header; @@ -150,23 +151,23 @@ unsigned bs_smoothing_mode; /** @} */ unsigned bs_coupling; - unsigned k[5]; ///< k0, k1, k2 + AAC_SIGNE k[5]; ///< k0, k1, k2 ///kx', and kx respectively, kx is the first QMF subband where SBR is used. ///kx' is its value from the previous frame - unsigned kx[2]; + AAC_SIGNE kx[2]; ///M' and M respectively, M is the number of QMF subbands that use SBR. - unsigned m[2]; + AAC_SIGNE m[2]; unsigned kx_and_m_pushed; ///The number of frequency bands in f_master - unsigned n_master; + AAC_SIGNE n_master; SBRData data[2]; PSContext ps; ///N_Low and N_High respectively, the number of frequency bands for low and high resolution - unsigned n[2]; + AAC_SIGNE n[2]; ///Number of noise floor bands - unsigned n_q; + AAC_SIGNE n_q; ///Number of limiter bands - unsigned n_lim; + AAC_SIGNE n_lim; ///The master QMF frequency grouping uint16_t f_master[49]; ///Frequency borders for low resolution SBR @@ -177,33 +178,33 @@ uint16_t f_tablenoise[6]; ///Frequency borders for the limiter uint16_t f_tablelim[30]; - unsigned num_patches; + AAC_SIGNE num_patches; uint8_t patch_num_subbands[6]; uint8_t patch_start_subband[6]; ///QMF low frequency input to the HF generator - DECLARE_ALIGNED(16, float, X_low)[32][40][2]; + DECLARE_ALIGNED(16, INTFLOAT, X_low)[32][40][2]; ///QMF output of the HF generator - DECLARE_ALIGNED(16, float, X_high)[64][40][2]; + DECLARE_ALIGNED(16, INTFLOAT, X_high)[64][40][2]; ///QMF values of the reconstructed signal - DECLARE_ALIGNED(16, float, X)[2][2][38][64]; + DECLARE_ALIGNED(16, INTFLOAT, X)[2][2][38][64]; ///Zeroth coefficient used to filter the subband signals - DECLARE_ALIGNED(16, float, alpha0)[64][2]; + DECLARE_ALIGNED(16, INTFLOAT, alpha0)[64][2]; ///First coefficient used to filter the subband signals - DECLARE_ALIGNED(16, float, alpha1)[64][2]; + DECLARE_ALIGNED(16, INTFLOAT, alpha1)[64][2]; ///Dequantized envelope scalefactors, remapped - float e_origmapped[7][48]; + AAC_FLOAT e_origmapped[7][48]; ///Dequantized noise scalefactors, remapped - float q_mapped[7][48]; + AAC_FLOAT q_mapped[7][48]; ///Sinusoidal presence, remapped uint8_t s_mapped[7][48]; ///Estimated envelope - float e_curr[7][48]; + AAC_FLOAT e_curr[7][48]; ///Amplitude adjusted noise scalefactors - float q_m[7][48]; + AAC_FLOAT q_m[7][48]; ///Sinusoidal levels - float s_m[7][48]; - float gain[7][48]; - DECLARE_ALIGNED(32, float, qmf_filter_scratch)[5][64]; + AAC_FLOAT s_m[7][48]; + AAC_FLOAT gain[7][48]; + DECLARE_ALIGNED(32, INTFLOAT, qmf_filter_scratch)[5][64]; FFTContext mdct_ana; FFTContext mdct; SBRDSPContext dsp; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sgidec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sgidec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sgidec.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sgidec.c 2015-07-28 17:20:07.000000000 +0000 @@ -296,5 +296,5 @@ .priv_data_size = sizeof(SgiState), .decode = decode_frame, .init = sgi_decode_init, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sgienc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sgienc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sgienc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sgienc.c 2015-07-28 17:20:07.000000000 +0000 @@ -37,10 +37,6 @@ return AVERROR_INVALIDDATA; } - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - return 0; } @@ -54,8 +50,12 @@ unsigned int bytes_per_channel, pixmax, put_be; unsigned char *end_buf; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif width = avctx->width; height = avctx->height; @@ -114,7 +114,7 @@ else // assume ff_rl_encode() produces at most 2x size of input length += tablesize * 2 + depth * height * (2 * width + 1); - if ((ret = ff_alloc_packet2(avctx, pkt, bytes_per_channel * length)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, bytes_per_channel * length, 0)) < 0) return ret; buf = pkt->data; end_buf = pkt->data + pkt->size; @@ -206,12 +206,6 @@ return 0; } -static av_cold int encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - return 0; -} - AVCodec ff_sgi_encoder = { .name = "sgi", .long_name = NULL_IF_CONFIG_SMALL("SGI image"), @@ -219,7 +213,6 @@ .id = AV_CODEC_ID_SGI, .init = encode_init, .encode2 = encode_frame, - .close = encode_close, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB48LE, AV_PIX_FMT_RGB48BE, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sgirledec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sgirledec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sgirledec.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sgirledec.c 2015-07-28 17:20:07.000000000 +0000 @@ -156,5 +156,5 @@ .init = sgirle_decode_init, .close = sgirle_decode_end, .decode = sgirle_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/shorten.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/shorten.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/shorten.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/shorten.c 2015-07-28 17:20:07.000000000 +0000 @@ -431,7 +431,7 @@ void *tmp_ptr; s->max_framesize = 8192; // should hopefully be enough for the first header tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, - s->max_framesize + FF_INPUT_BUFFER_PADDING_SIZE); + s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE); if (!tmp_ptr) { av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n"); return AVERROR(ENOMEM); @@ -445,7 +445,7 @@ buf_size = FFMIN(buf_size, s->max_framesize - s->bitstream_size); input_buf_size = buf_size; - if (s->bitstream_index + s->bitstream_size + buf_size + FF_INPUT_BUFFER_PADDING_SIZE > + if (s->bitstream_index + s->bitstream_size + buf_size + AV_INPUT_BUFFER_PADDING_SIZE > s->allocated_bitstream_size) { memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size); @@ -466,7 +466,8 @@ } } /* init and position bitstream reader */ - init_get_bits(&s->gb, buf, buf_size * 8); + if ((ret = init_get_bits8(&s->gb, buf, buf_size)) < 0) + return ret; skip_bits(&s->gb, s->bitindex); /* process header or next subblock */ @@ -679,7 +680,7 @@ .init = shorten_decode_init, .close = shorten_decode_close, .decode = shorten_decode_frame, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin.c 2014-12-01 00:21:44.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin.c 2015-07-09 17:20:03.000000000 +0000 @@ -16,5 +16,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#define USE_FIXED 0 #include "sinewin.h" #include "sinewin_tablegen.h" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin_fixed.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin_fixed.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin_fixed.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin_fixed.c 2015-07-09 17:20:03.000000000 +0000 @@ -0,0 +1,21 @@ +/* + * 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 + */ + +#define USE_FIXED 1 +#include "sinewin.h" +#include "sinewin_tablegen.h" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin_fixed_tablegen.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin_fixed_tablegen.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin_fixed_tablegen.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin_fixed_tablegen.c 2015-07-09 17:20:03.000000000 +0000 @@ -0,0 +1,24 @@ +/* + * Generate a header file for hardcoded sine windows + * + * Copyright (c) 2009 Reimar Döffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#define USE_FIXED 1 +#include "sinewin_tablegen_template.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin.h 2015-03-13 17:34:47.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin.h 2015-07-23 17:20:03.000000000 +0000 @@ -23,6 +23,7 @@ #include "config.h" #include "libavutil/mem.h" +#include "libavcodec/aac_defines.h" #if CONFIG_HARDCODED_TABLES # define SINETABLE_CONST const @@ -30,20 +31,24 @@ # define SINETABLE_CONST #endif +#ifndef USE_FIXED +#define USE_FIXED 0 +#endif + #define SINETABLE(size) \ - SINETABLE_CONST DECLARE_ALIGNED(32, float, ff_sine_##size)[size] + SINETABLE_CONST DECLARE_ALIGNED(32, INTFLOAT, AAC_RENAME(ff_sine_##size))[size] /** * Generate a sine window. * @param window pointer to half window * @param n size of half window */ -void ff_sine_window_init(float *window, int n); +void AAC_RENAME(ff_sine_window_init)(INTFLOAT *window, int n); /** * initialize the specified entry of ff_sine_windows */ -void ff_init_ff_sine_windows(int index); +void AAC_RENAME(ff_init_ff_sine_windows)(int index); extern SINETABLE( 32); extern SINETABLE( 64); @@ -55,6 +60,6 @@ extern SINETABLE(4096); extern SINETABLE(8192); -extern SINETABLE_CONST float * const ff_sine_windows[14]; +extern SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[14]; #endif /* AVCODEC_SINEWIN_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin_tablegen.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin_tablegen.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin_tablegen.c 2015-03-13 17:34:47.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin_tablegen.c 2015-07-09 17:20:03.000000000 +0000 @@ -20,27 +20,5 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#define CONFIG_HARDCODED_TABLES 0 -#define SINETABLE_CONST -#define SINETABLE(size) \ - float ff_sine_##size[size] -#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) -#include "sinewin_tablegen.h" -#include "tableprint.h" - -int main(void) -{ - int i; - - write_fileheader(); - - for (i = 5; i <= 13; i++) { - ff_init_ff_sine_windows(i); - printf("SINETABLE(%4i) = {\n", 1 << i); - write_float_array(ff_sine_windows[i], 1 << i); - printf("};\n"); - } - - return 0; -} +#define USE_FIXED 0 +#include "sinewin_tablegen_template.c" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin_tablegen.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin_tablegen.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin_tablegen.h 2015-03-13 17:34:47.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin_tablegen.h 2015-07-23 17:20:03.000000000 +0000 @@ -27,6 +27,7 @@ // do not use libavutil/libm.h since this is compiled both // for the host and the target and config.h is only valid for the target #include +#include "libavcodec/aac_defines.h" #include "libavutil/attributes.h" #include "libavutil/common.h" @@ -41,26 +42,37 @@ SINETABLE(4096); SINETABLE(8192); #else +#if USE_FIXED +#include "libavcodec/sinewin_fixed_tables.h" +#else #include "libavcodec/sinewin_tables.h" #endif +#endif + +#if USE_FIXED +#define SIN_FIX(a) (int)floor((a) * 0x80000000 + 0.5) +#else +#define SIN_FIX(a) a +#endif -SINETABLE_CONST float * const ff_sine_windows[] = { +SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[] = { NULL, NULL, NULL, NULL, NULL, // unused - ff_sine_32 , ff_sine_64 , - ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048, ff_sine_4096, ff_sine_8192 + AAC_RENAME(ff_sine_32) , AAC_RENAME(ff_sine_64), AAC_RENAME(ff_sine_128), + AAC_RENAME(ff_sine_256), AAC_RENAME(ff_sine_512), AAC_RENAME(ff_sine_1024), + AAC_RENAME(ff_sine_2048), AAC_RENAME(ff_sine_4096), AAC_RENAME(ff_sine_8192) }; // Generate a sine window. -av_cold void ff_sine_window_init(float *window, int n) { +av_cold void AAC_RENAME(ff_sine_window_init)(INTFLOAT *window, int n) { int i; for(i = 0; i < n; i++) - window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n))); + window[i] = SIN_FIX(sinf((i + 0.5) * (M_PI / (2.0 * n)))); } -av_cold void ff_init_ff_sine_windows(int index) { - assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows)); +av_cold void AAC_RENAME(ff_init_ff_sine_windows)(int index) { + assert(index >= 0 && index < FF_ARRAY_ELEMS(AAC_RENAME(ff_sine_windows))); #if !CONFIG_HARDCODED_TABLES - ff_sine_window_init(ff_sine_windows[index], 1 << index); + AAC_RENAME(ff_sine_window_init)(AAC_RENAME(ff_sine_windows)[index], 1 << index); #endif } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin_tablegen_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin_tablegen_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sinewin_tablegen_template.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sinewin_tablegen_template.c 2015-07-23 17:20:03.000000000 +0000 @@ -0,0 +1,54 @@ +/* + * Generate a header file for hardcoded sine windows + * + * Copyright (c) 2009 Reimar Döffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "libavcodec/aac_defines.h" +#define CONFIG_HARDCODED_TABLES 0 + +#if USE_FIXED +#define WRITE_FUNC write_int32_t_array +#else +#define WRITE_FUNC write_float_array +#endif + +#define SINETABLE_CONST +#define SINETABLE(size) \ + INTFLOAT AAC_RENAME(ff_sine_##size)[size] +#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) +#include "sinewin_tablegen.h" +#include "tableprint.h" + +int main(void) +{ + int i; + + write_fileheader(); + + for (i = 5; i <= 13; i++) { + AAC_RENAME(ff_init_ff_sine_windows)(i); + printf("SINETABLE(%4i) = {\n", 1 << i); + WRITE_FUNC(AAC_RENAME(ff_sine_windows)[i], 1 << i); + printf("};\n"); + } + + return 0; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sipr.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sipr.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sipr.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sipr.c 2015-07-28 17:20:07.000000000 +0000 @@ -570,5 +570,5 @@ .priv_data_size = sizeof(SiprContext), .init = sipr_decoder_init, .decode = sipr_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/smacker.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/smacker.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/smacker.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/smacker.c 2015-07-28 17:20:07.000000000 +0000 @@ -813,7 +813,7 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; AVCodec ff_smackaud_decoder = { @@ -823,5 +823,5 @@ .id = AV_CODEC_ID_SMACKAUDIO, .init = smka_decode_init, .decode = smka_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/smc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/smc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/smc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/smc.c 2015-07-28 17:20:07.000000000 +0000 @@ -472,5 +472,5 @@ .init = smc_decode_init, .close = smc_decode_end, .decode = smc_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/smvjpegdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/smvjpegdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/smvjpegdec.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/smvjpegdec.c 2015-06-13 17:20:02.000000000 +0000 @@ -164,7 +164,9 @@ return AVERROR(EINVAL); desc = av_pix_fmt_desc_get(s->avctx->pix_fmt); - if (desc && mjpeg_data->height % (s->frames_per_jpeg << desc->log2_chroma_h)) { + av_assert0(desc); + + if (mjpeg_data->height % (s->frames_per_jpeg << desc->log2_chroma_h)) { av_log(avctx, AV_LOG_ERROR, "Invalid height\n"); return AVERROR_INVALIDDATA; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/snappy.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/snappy.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/snappy.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/snappy.c 2015-07-17 17:20:02.000000000 +0000 @@ -0,0 +1,183 @@ +/* + * Snappy decompression algorithm + * Copyright (c) 2015 Luca Barbato + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mem.h" + +#include "bytestream.h" +#include "snappy.h" + +enum { + SNAPPY_LITERAL, + SNAPPY_COPY_1, + SNAPPY_COPY_2, + SNAPPY_COPY_4, +}; + +static int64_t bytestream2_get_levarint(GetByteContext *gb) +{ + uint64_t val = 0; + int shift = 0; + int tmp; + + do { + tmp = bytestream2_get_byte(gb); + val |= (tmp & 127) << shift; + shift += 7; + } while (tmp & 128); + + return val; +} + +static int snappy_literal(GetByteContext *gb, uint8_t *p, int size, int val) +{ + unsigned int len = 1; + + switch (val) { + case 63: + len += bytestream2_get_le32(gb); + break; + case 62: + len += bytestream2_get_le24(gb); + break; + case 61: + len += bytestream2_get_le16(gb); + break; + case 60: + len += bytestream2_get_byte(gb); + break; + default: // val < 60 + len += val; + } + + if (size < len) + return AVERROR_INVALIDDATA; + + bytestream2_get_buffer(gb, p, len); + + return len; +} + +static int snappy_copy(uint8_t *start, uint8_t *p, int size, + unsigned int off, int len) +{ + uint8_t *q; + int i; + if (off > p - start || size < len) + return AVERROR_INVALIDDATA; + + q = p - off; + + for (i = 0; i < len; i++) + p[i] = q[i]; + + return len; +} + +static int snappy_copy1(GetByteContext *gb, uint8_t *start, uint8_t *p, + int size, int val) +{ + int len = 4 + (val & 0x7); + unsigned int off = bytestream2_get_byte(gb) | (val & 0x38) << 5; + + return snappy_copy(start, p, size, off, len); +} + +static int snappy_copy2(GetByteContext *gb, uint8_t *start, uint8_t *p, + int size, int val) +{ + int len = 1 + val; + unsigned int off = bytestream2_get_le16(gb); + + return snappy_copy(start, p, size, off, len); +} + +static int snappy_copy4(GetByteContext *gb, uint8_t *start, uint8_t *p, + int size, int val) +{ + int len = 1 + val; + unsigned int off = bytestream2_get_le32(gb); + + return snappy_copy(start, p, size, off, len); +} + +static int64_t decode_len(GetByteContext *gb) +{ + int64_t len = bytestream2_get_levarint(gb); + + if (len < 0 || len > UINT_MAX) + return AVERROR_INVALIDDATA; + + return len; +} + +int64_t ff_snappy_peek_uncompressed_length(GetByteContext *gb) +{ + int pos = bytestream2_get_bytes_left(gb); + int64_t len = decode_len(gb); + + bytestream2_seek(gb, -pos, SEEK_END); + + return len; +} + +int ff_snappy_uncompress(GetByteContext *gb, uint8_t *buf, int64_t *size) +{ + int64_t len = decode_len(gb); + int ret = 0; + uint8_t *p; + + if (len < 0) + return len; + + if (len > *size) + return AVERROR_BUFFER_TOO_SMALL; + + *size = len; + p = buf; + + while (bytestream2_get_bytes_left(gb) > 0) { + uint8_t s = bytestream2_get_byte(gb); + int val = s >> 2; + + switch (s & 0x03) { + case SNAPPY_LITERAL: + ret = snappy_literal(gb, p, len, val); + break; + case SNAPPY_COPY_1: + ret = snappy_copy1(gb, buf, p, len, val); + break; + case SNAPPY_COPY_2: + ret = snappy_copy2(gb, buf, p, len, val); + break; + case SNAPPY_COPY_4: + ret = snappy_copy4(gb, buf, p, len, val); + break; + } + + if (ret < 0) + return ret; + + p += ret; + len -= ret; + } + + return 0; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/snappy.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/snappy.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/snappy.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/snappy.h 2015-07-17 17:20:02.000000000 +0000 @@ -0,0 +1,60 @@ +/* + * Snappy module + * Copyright (c) Luca Barbato + * + * 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 + */ + +/** + * @file + * Snappy decompression + * + * Snappy is a compression/decompression algorithm that does not aim for + * maximum compression, but rather for very high speeds and reasonable + * compression. + * + * http://en.wikipedia.org/wiki/Snappy_%28software%29 + */ + +#ifndef AVCODEC_SNAPPY_H +#define AVCODEC_SNAPPY_H + +#include + +#include "bytestream.h" + +/** + * Get the uncompressed length of an input buffer compressed using the Snappy + * algorithm. The GetByteContext is not advanced. + * + * @param gb input GetByteContext. + * @return A positive length on success, AVERROR otherwise. + */ + int64_t ff_snappy_peek_uncompressed_length(GetByteContext *gb); + +/** + * Decompress an input buffer using Snappy algorithm. + * + * @param gb input GetByteContext. + * @param buf input buffer pointer. + * @param size input/output on input, the size of buffer, on output, the size + * of the uncompressed data. + * @return 0 if success, AVERROR otherwise. + */ +int ff_snappy_uncompress(GetByteContext *gb, uint8_t *buf, int64_t *size); + +#endif /* AVCODEC_SNAPPY_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/snowdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/snowdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/snowdec.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/snowdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -477,7 +477,7 @@ ); av_assert0(!s->avmv); - if (s->avctx->flags2 & CODEC_FLAG2_EXPORT_MVS) { + if (s->avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MVS) { s->avmv = av_malloc_array(s->b_width * s->b_height, sizeof(AVMotionVector) << (s->block_max_depth*2)); } s->avmv_index = 0; @@ -642,7 +642,7 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/, + .capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/snowenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/snowenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/snowenc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/snowenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -39,7 +39,7 @@ int i; if(avctx->prediction_method == DWT_97 - && (avctx->flags & CODEC_FLAG_QSCALE) + && (avctx->flags & AV_CODEC_FLAG_QSCALE) && avctx->global_quality == 0){ av_log(avctx, AV_LOG_ERROR, "The 9/7 wavelet is incompatible with lossless mode.\n"); return -1; @@ -47,8 +47,8 @@ s->spatial_decomposition_type= avctx->prediction_method; //FIXME add decorrelator type r transform_type - s->mv_scale = (avctx->flags & CODEC_FLAG_QPEL) ? 2 : 4; - s->block_max_depth= (avctx->flags & CODEC_FLAG_4MV ) ? 1 : 0; + s->mv_scale = (avctx->flags & AV_CODEC_FLAG_QPEL) ? 2 : 4; + s->block_max_depth= (avctx->flags & AV_CODEC_FLAG_4MV ) ? 1 : 0; for(plane_index=0; plane_index<3; plane_index++){ s->plane[plane_index].diag_mc= 1; @@ -83,18 +83,18 @@ s->max_ref_frames = av_clip(avctx->refs, 1, MAX_REF_FRAMES); - if(avctx->flags&CODEC_FLAG_PASS1){ + if(avctx->flags&AV_CODEC_FLAG_PASS1){ if(!avctx->stats_out) avctx->stats_out = av_mallocz(256); if (!avctx->stats_out) return AVERROR(ENOMEM); } - if((avctx->flags&CODEC_FLAG_PASS2) || !(avctx->flags&CODEC_FLAG_QSCALE)){ + if((avctx->flags&AV_CODEC_FLAG_PASS2) || !(avctx->flags&CODEC_FLAG_QSCALE)){ if(ff_rate_control_init(&s->m) < 0) return -1; } - s->pass1_rc= !(avctx->flags & (CODEC_FLAG_QSCALE|CODEC_FLAG_PASS2)); + s->pass1_rc= !(avctx->flags & (AV_CODEC_FLAG_QSCALE|CODEC_FLAG_PASS2)); switch(avctx->pix_fmt){ case AV_PIX_FMT_YUV444P: @@ -122,8 +122,7 @@ ff_set_cmp(&s->mecc, s->mecc.me_sub_cmp, s->avctx->me_sub_cmp); s->input_picture = av_frame_alloc(); - avctx->coded_frame = av_frame_alloc(); - if (!s->input_picture || !avctx->coded_frame) + if (!s->input_picture) return AVERROR(ENOMEM); if ((ret = ff_snow_get_buffer(s, s->input_picture)) < 0) @@ -242,7 +241,7 @@ s->input_picture->data[2] + ((x*block_w)>>s->chroma_h_shift) + ((y*uvstride*block_w)>>s->chroma_v_shift)}; int P[10][2]; int16_t last_mv[3][2]; - int qpel= !!(s->avctx->flags & CODEC_FLAG_QPEL); //unused + int qpel= !!(s->avctx->flags & AV_CODEC_FLAG_QPEL); //unused const int shift= 1+qpel; MotionEstContext *c= &s->m.me; int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref); @@ -1556,7 +1555,7 @@ uint8_t rc_header_bak[sizeof(s->header_state)]; uint8_t rc_block_bak[sizeof(s->block_state)]; - if ((ret = ff_alloc_packet2(avctx, pkt, s->b_width*s->b_height*MB_SIZE*MB_SIZE*3 + FF_MIN_BUFFER_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, s->b_width*s->b_height*MB_SIZE*MB_SIZE*3 + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return ret; ff_init_range_encoder(c, pkt->data, pkt->size); @@ -1579,10 +1578,10 @@ s->new_picture = pict; s->m.picture_number= avctx->frame_number; - if(avctx->flags&CODEC_FLAG_PASS2){ + if(avctx->flags&AV_CODEC_FLAG_PASS2){ s->m.pict_type = pic->pict_type = s->m.rc_context.entry[avctx->frame_number].new_pict_type; s->keyframe = pic->pict_type == AV_PICTURE_TYPE_I; - if(!(avctx->flags&CODEC_FLAG_QSCALE)) { + if(!(avctx->flags&AV_CODEC_FLAG_QSCALE)) { pic->quality = ff_rate_estimate_qscale(&s->m, 0); if (pic->quality < 0) return -1; @@ -1598,7 +1597,7 @@ s->qlog = qscale2qlog(pic->quality); s->lambda = pic->quality * 3/2; } - if (s->qlog < 0 || (!pic->quality && (avctx->flags & CODEC_FLAG_QSCALE))) { + if (s->qlog < 0 || (!pic->quality && (avctx->flags & AV_CODEC_FLAG_QSCALE))) { s->qlog= LOSSLESS_QLOG; s->lambda = 0; }//else keep previous frame's qlog until after motion estimation @@ -1654,7 +1653,7 @@ s->m.me_method= s->avctx->me_method; s->m.me.scene_change_score=0; s->m.me.dia_size = avctx->dia_size; - s->m.quarter_sample= (s->avctx->flags & CODEC_FLAG_QPEL)!=0; + s->m.quarter_sample= (s->avctx->flags & AV_CODEC_FLAG_QPEL)!=0; s->m.out_format= FMT_H263; s->m.unrestricted_mv= 1; @@ -1723,7 +1722,7 @@ if( plane_index==0 && pic->pict_type == AV_PICTURE_TYPE_P - && !(avctx->flags&CODEC_FLAG_PASS2) + && !(avctx->flags&AV_CODEC_FLAG_PASS2) && s->m.me.scene_change_score > s->avctx->scenechange_threshold){ ff_init_range_encoder(c, pkt->data, pkt->size); ff_build_rac_states(c, (1LL<<32)/20, 256-8); @@ -1809,7 +1808,7 @@ predict_plane(s, s->spatial_idwt_buffer, plane_index, 1); } } - if(s->avctx->flags&CODEC_FLAG_PSNR){ + if(s->avctx->flags&AV_CODEC_FLAG_PSNR){ int64_t error= 0; if(pict->data[plane_index]) //FIXME gray hack @@ -1841,7 +1840,7 @@ if(s->pass1_rc) if (ff_rate_estimate_qscale(&s->m, 0) < 0) return -1; - if(avctx->flags&CODEC_FLAG_PASS1) + if(avctx->flags&AV_CODEC_FLAG_PASS1) ff_write_pass1_stats(&s->m); s->m.last_pict_type = s->m.pict_type; avctx->frame_bits = s->m.frame_bits; @@ -1851,8 +1850,13 @@ emms_c(); + ff_side_data_set_encoder_stats(pkt, s->current_picture->quality, + s->current_picture->error, + (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? 4 : 0, + s->current_picture->pict_type); + pkt->size = ff_rac_terminate(c); - if (avctx->coded_frame->key_frame) + if (s->current_picture->key_frame) pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; @@ -1866,7 +1870,6 @@ ff_snow_common_end(s); ff_rate_control_uninit(&s->m); av_frame_free(&s->input_picture); - av_frame_free(&avctx->coded_frame); av_freep(&avctx->stats_out); return 0; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/snow.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/snow.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/snow.h 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/snow.h 2015-07-10 17:20:03.000000000 +0000 @@ -304,6 +304,8 @@ BlockNode *lb= lt+b_stride; BlockNode *rb= lb+1; uint8_t *block[4]; + // When src_stride is large enough, it is possible to interleave the blocks. + // Otherwise the blocks are written sequentially in the tmp buffer. int tmp_step= src_stride >= 7*MB_SIZE ? MB_SIZE : MB_SIZE*src_stride; uint8_t *tmp = s->scratchbuf; uint8_t *ptmp; @@ -347,8 +349,6 @@ if(b_w<=0 || b_h<=0) return; - av_assert2(src_stride > 2*MB_SIZE + 5); - if(!sliced && offset_dst) dst += src_x + src_y*dst_stride; dst8+= src_x + src_y*src_stride; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sonic.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sonic.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sonic.c 2015-06-18 18:55:40.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sonic.c 2015-07-28 17:20:07.000000000 +0000 @@ -727,7 +727,7 @@ const short *samples = (const int16_t*)frame->data[0]; uint8_t state[32]; - if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size * 5 + 1000)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size * 5 + 1000, 0)) < 0) return ret; ff_init_range_encoder(&c, avpkt->data, avpkt->size); @@ -1081,7 +1081,7 @@ .init = sonic_decode_init, .close = sonic_decode_close, .decode = sonic_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_EXPERIMENTAL, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, }; #endif /* CONFIG_SONIC_DECODER */ @@ -1095,7 +1095,7 @@ .init = sonic_encode_init, .encode2 = sonic_encode_frame, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, - .capabilities = CODEC_CAP_EXPERIMENTAL, + .capabilities = AV_CODEC_CAP_EXPERIMENTAL, .close = sonic_encode_close, }; #endif @@ -1110,7 +1110,7 @@ .init = sonic_encode_init, .encode2 = sonic_encode_frame, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, - .capabilities = CODEC_CAP_EXPERIMENTAL, + .capabilities = AV_CODEC_CAP_EXPERIMENTAL, .close = sonic_encode_close, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sp5xdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sp5xdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sp5xdec.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sp5xdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -104,7 +104,7 @@ .init = ff_mjpeg_decode_init, .close = ff_mjpeg_decode_end, .decode = sp5x_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .max_lowres = 3, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; @@ -120,6 +120,7 @@ .close = ff_mjpeg_decode_end, .decode = sp5x_decode_frame, .max_lowres = 3, + .capabilities = AV_CODEC_CAP_DR1, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/startcode.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/startcode.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/startcode.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/startcode.c 2015-07-28 17:20:07.000000000 +0000 @@ -33,7 +33,7 @@ int i = 0; #if HAVE_FAST_UNALIGNED /* we check i < size instead of i + 3 / 7 because it is - * simpler and there must be FF_INPUT_BUFFER_PADDING_SIZE + * simpler and there must be AV_INPUT_BUFFER_PADDING_SIZE * bytes at the end. */ #if HAVE_FAST_64BIT diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sunrast.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sunrast.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sunrast.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sunrast.c 2015-07-28 17:20:07.000000000 +0000 @@ -211,5 +211,5 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_SUNRAST, .decode = sunrast_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/sunrastenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/sunrastenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/sunrastenc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/sunrastenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -181,7 +181,7 @@ SUNRASTContext *s = avctx->priv_data; int ret; - if ((ret = ff_alloc_packet2(avctx, avpkt, s->size)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, s->size, 0)) < 0) return ret; bytestream2_init_writer(&s->p, avpkt->data, avpkt->size); @@ -199,12 +199,6 @@ return 0; } -static av_cold int sunrast_encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - return 0; -} - static const AVCodecDefault sunrast_defaults[] = { { "coder", "rle" }, { NULL }, @@ -217,7 +211,6 @@ .id = AV_CODEC_ID_SUNRAST, .priv_data_size = sizeof(SUNRASTContext), .init = sunrast_encode_init, - .close = sunrast_encode_close, .encode2 = sunrast_encode_frame, .defaults = sunrast_defaults, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/svq1dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/svq1dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/svq1dec.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/svq1dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -685,7 +685,7 @@ width = FFALIGN(s->width, 16); height = FFALIGN(s->height, 16); } else { - if (avctx->flags & CODEC_FLAG_GRAY) + if (avctx->flags & AV_CODEC_FLAG_GRAY) break; width = FFALIGN(s->width / 4, 16); height = FFALIGN(s->height / 4, 16); @@ -839,7 +839,7 @@ .init = svq1_decode_init, .close = svq1_decode_end, .decode = svq1_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = svq1_flush, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV410P, AV_PIX_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/svq1enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/svq1enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/svq1enc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/svq1enc.c 2015-07-28 17:20:07.000000000 +0000 @@ -246,14 +246,13 @@ unsigned char *decoded_plane, int width, int height, int src_stride, int stride) { - const AVFrame *f = s->avctx->coded_frame; int x, y; int i; int block_width, block_height; int level; int threshold[6]; uint8_t *src = s->scratchbuf + stride * 32; - const int lambda = (f->quality * f->quality) >> + const int lambda = (s->quality * s->quality) >> (2 * FF_LAMBDA_SHIFT); /* figure out the acceptable level thresholds in advance */ @@ -264,7 +263,7 @@ block_width = (width + 15) / 16; block_height = (height + 15) / 16; - if (f->pict_type == AV_PICTURE_TYPE_P) { + if (s->pict_type == AV_PICTURE_TYPE_P) { s->m.avctx = s->avctx; s->m.current_picture_ptr = &s->m.current_picture; s->m.last_picture_ptr = &s->m.last_picture; @@ -280,12 +279,25 @@ s->m.mb_stride = s->m.mb_width + 1; s->m.b8_stride = 2 * s->m.mb_width + 1; s->m.f_code = 1; - s->m.pict_type = f->pict_type; + s->m.pict_type = s->pict_type; +#if FF_API_MOTION_EST +FF_DISABLE_DEPRECATION_WARNINGS s->m.me_method = s->avctx->me_method; + if (s->motion_est == FF_ME_EPZS) { + if (s->avctx->me_method == ME_ZERO) + s->motion_est = FF_ME_ZERO; + else if (s->avctx->me_method == ME_EPZS) + s->motion_est = FF_ME_EPZS; + else if (s->avctx->me_method == ME_X1) + s->motion_est = FF_ME_XONE; + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + s->m.motion_est = s->motion_est; s->m.me.scene_change_score = 0; // s->m.out_format = FMT_H263; // s->m.unrestricted_mv = 1; - s->m.lambda = f->quality; + s->m.lambda = s->quality; s->m.qscale = s->m.lambda * 139 + FF_LAMBDA_SCALE * 64 >> FF_LAMBDA_SHIFT + 7; @@ -378,13 +390,13 @@ s->m.mb_x = x; init_block_index(&s->m); - if (f->pict_type == AV_PICTURE_TYPE_I || + if (s->pict_type == AV_PICTURE_TYPE_I || (s->m.mb_type[x + y * s->m.mb_stride] & CANDIDATE_MB_TYPE_INTRA)) { for (i = 0; i < 6; i++) init_put_bits(&s->reorder_pb[i], reorder_buffer[0][i], 7 * 32); - if (f->pict_type == AV_PICTURE_TYPE_P) { + if (s->pict_type == AV_PICTURE_TYPE_P) { const uint8_t *vlc = ff_svq1_block_type_vlc[SVQ1_BLOCK_INTRA]; put_bits(&s->reorder_pb[5], vlc[1], vlc[0]); score[0] = vlc[1] * lambda; @@ -400,7 +412,7 @@ best = 0; - if (f->pict_type == AV_PICTURE_TYPE_P) { + if (s->pict_type == AV_PICTURE_TYPE_P) { const uint8_t *vlc = ff_svq1_block_type_vlc[SVQ1_BLOCK_INTER]; int mx, my, pred_x, pred_y, dxy; int16_t *motion_ptr; @@ -505,7 +517,6 @@ av_frame_free(&s->current_picture); av_frame_free(&s->last_picture); - av_frame_free(&avctx->coded_frame); return 0; } @@ -519,10 +530,9 @@ ff_me_cmp_init(&s->mecc, avctx); ff_mpegvideoencdsp_init(&s->m.mpvencdsp, avctx); - avctx->coded_frame = av_frame_alloc(); s->current_picture = av_frame_alloc(); s->last_picture = av_frame_alloc(); - if (!avctx->coded_frame || !s->current_picture || !s->last_picture) { + if (!s->current_picture || !s->last_picture) { svq1_encode_end(avctx); return AVERROR(ENOMEM); } @@ -576,11 +586,10 @@ const AVFrame *pict, int *got_packet) { SVQ1EncContext *const s = avctx->priv_data; - AVFrame *const p = avctx->coded_frame; int i, ret; if ((ret = ff_alloc_packet2(avctx, pkt, s->y_block_width * s->y_block_height * - MAX_MB_BYTES*3 + FF_MIN_BUFFER_SIZE)) < 0) + MAX_MB_BYTES*3 + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return ret; if (avctx->pix_fmt != AV_PIX_FMT_YUV410P) { @@ -608,12 +617,22 @@ init_put_bits(&s->pb, pkt->data, pkt->size); - p->pict_type = avctx->gop_size && avctx->frame_number % avctx->gop_size ? - AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; - p->key_frame = p->pict_type == AV_PICTURE_TYPE_I; - p->quality = pict->quality; + if (avctx->gop_size && (avctx->frame_number % avctx->gop_size)) + s->pict_type = AV_PICTURE_TYPE_P; + else + s->pict_type = AV_PICTURE_TYPE_I; + s->quality = pict->quality; + +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->pict_type = s->pict_type; + avctx->coded_frame->key_frame = s->pict_type == AV_PICTURE_TYPE_I; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + ff_side_data_set_encoder_stats(pkt, pict->quality, NULL, 0, s->pict_type); - svq1_write_header(s, p->pict_type); + svq1_write_header(s, s->pict_type); for (i = 0; i < 3; i++) if (svq1_encode_plane(s, i, pict->data[i], @@ -639,19 +658,38 @@ flush_put_bits(&s->pb); pkt->size = put_bits_count(&s->pb) / 8; - if (p->pict_type == AV_PICTURE_TYPE_I) + if (s->pict_type == AV_PICTURE_TYPE_I) pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; return 0; } +#define OFFSET(x) offsetof(struct SVQ1EncContext, x) +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "motion-est", "Motion estimation algorithm", OFFSET(motion_est), AV_OPT_TYPE_INT, { .i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, VE, "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" }, + { "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion-est" }, + + { NULL }, +}; + +static const AVClass svq1enc_class = { + .class_name = "svq1enc", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_svq1_encoder = { .name = "svq1", .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_SVQ1, .priv_data_size = sizeof(SVQ1EncContext), + .priv_class = &svq1enc_class, .init = svq1_encode_init, .encode2 = svq1_encode_frame, .close = svq1_encode_end, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/svq1enc.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/svq1enc.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/svq1enc.h 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/svq1enc.h 2015-07-28 17:20:07.000000000 +0000 @@ -44,6 +44,10 @@ PutBitContext pb; GetBitContext gb; + /* Some compression statistics */ + enum AVPictureType pict_type; + int quality; + /* why ooh why this sick breadth first order, * everything is slower and more complex */ PutBitContext reorder_pb[6]; @@ -70,6 +74,8 @@ uint8_t *scratchbuf; + int motion_est; + int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2, intptr_t size); } SVQ1EncContext; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/svq3.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/svq3.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/svq3.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/svq3.c 2015-07-28 17:20:07.000000000 +0000 @@ -339,7 +339,7 @@ : s->hdsp.put_pixels_tab)[blocksize][dxy](dest, src, sl->linesize, height); - if (!(h->flags & CODEC_FLAG_GRAY)) { + if (!(h->flags & AV_CODEC_FLAG_GRAY)) { mx = mx + (mx < (int) x) >> 1; my = my + (my < (int) y) >> 1; width = width >> 1; @@ -1414,9 +1414,9 @@ .init = svq3_decode_init, .close = svq3_decode_end, .decode = svq3_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | - CODEC_CAP_DR1 | - CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | + AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_DELAY, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NONE}, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/tableprint.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/tableprint.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/tableprint.h 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/tableprint.h 2015-07-09 17:20:03.000000000 +0000 @@ -64,6 +64,7 @@ void write_uint8_t_array (const uint8_t *, int); void write_uint16_t_array (const uint16_t *, int); void write_uint32_t_array (const uint32_t *, int); +void write_int32_t_array (const int32_t *, int); void write_float_array (const float *, int); void write_int8_t_2d_array (const void *, int, int); void write_uint8_t_2d_array (const void *, int, int); @@ -116,6 +117,7 @@ WRITE_1D_FUNC(uint16_t, "0x%08"PRIx16, 7) WRITE_1D_FUNC(int16_t, "%5"PRIi16, 7) WRITE_1D_FUNC(uint32_t, "0x%08"PRIx32, 7) +WRITE_1D_FUNC(int32_t, "0x%08"PRIx32, 7) WRITE_1D_FUNC(float, "%.18e", 3) WRITE_2D_FUNC(int8_t) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/takdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/takdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/takdec.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/takdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -947,7 +947,7 @@ .decode = tak_decode_frame, .init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S32P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/targa.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/targa.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/targa.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/targa.c 2015-07-28 17:20:07.000000000 +0000 @@ -303,5 +303,5 @@ .id = AV_CODEC_ID_TARGA, .priv_data_size = sizeof(TargaContext), .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/targaenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/targaenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/targaenc.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/targaenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -85,7 +85,7 @@ return AVERROR(EINVAL); } picsize = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); - if ((ret = ff_alloc_packet2(avctx, pkt, picsize + 45)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, picsize + 45, 0)) < 0) return ret; /* zero out the header and only set applicable fields */ @@ -172,29 +172,22 @@ static av_cold int targa_encode_init(AVCodecContext *avctx) { - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->key_frame = 1; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; +FF_ENABLE_DEPRECATION_WARNINGS +#endif return 0; } -static av_cold int targa_encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - return 0; -} - AVCodec ff_targa_encoder = { .name = "targa", .long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_TARGA, .init = targa_encode_init, - .close = targa_encode_close, .encode2 = targa_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24, AV_PIX_FMT_BGRA, AV_PIX_FMT_RGB555LE, AV_PIX_FMT_GRAY8, AV_PIX_FMT_PAL8, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/targa_y216dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/targa_y216dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/targa_y216dec.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/targa_y216dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -79,5 +79,5 @@ .id = AV_CODEC_ID_TARGA_Y216, .init = y216_decode_init, .decode = y216_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/tdsc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/tdsc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/tdsc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/tdsc.c 2015-07-28 17:20:07.000000000 +0000 @@ -621,7 +621,7 @@ .decode = tdsc_decode_frame, .close = tdsc_close, .priv_data_size = sizeof(TDSCContext), - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/texturedsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/texturedsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/texturedsp.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/texturedsp.c 2015-07-26 17:20:03.000000000 +0000 @@ -0,0 +1,610 @@ +/* + * Texture block decompression + * Copyright (C) 2009 Benjamin Dobell, Glass Echidna + * Copyright (C) 2012 Matthäus G. "Anteru" Chajdas (http://anteru.net) + * Copyright (C) 2015 Vittorio Giovara + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include +#include + +#include "libavutil/attributes.h" +#include "libavutil/common.h" +#include "libavutil/intreadwrite.h" + +#include "texturedsp.h" + +#define RGBA(r, g, b, a) ((r) | ((g) << 8) | ((b) << 16) | ((a) << 24)) + +static av_always_inline void extract_color(uint32_t colors[4], + uint16_t color0, + uint16_t color1, + int dxtn, int alpha) +{ + int tmp; + uint8_t r0, g0, b0, r1, g1, b1; + uint8_t a = dxtn ? 0 : 255; + + tmp = (color0 >> 11) * 255 + 16; + r0 = (uint8_t) ((tmp / 32 + tmp) / 32); + tmp = ((color0 & 0x07E0) >> 5) * 255 + 32; + g0 = (uint8_t) ((tmp / 64 + tmp) / 64); + tmp = (color0 & 0x001F) * 255 + 16; + b0 = (uint8_t) ((tmp / 32 + tmp) / 32); + + tmp = (color1 >> 11) * 255 + 16; + r1 = (uint8_t) ((tmp / 32 + tmp) / 32); + tmp = ((color1 & 0x07E0) >> 5) * 255 + 32; + g1 = (uint8_t) ((tmp / 64 + tmp) / 64); + tmp = (color1 & 0x001F) * 255 + 16; + b1 = (uint8_t) ((tmp / 32 + tmp) / 32); + + if (dxtn || color0 > color1) { + colors[0] = RGBA(r0, g0, b0, a); + colors[1] = RGBA(r1, g1, b1, a); + colors[2] = RGBA((2 * r0 + r1) / 3, + (2 * g0 + g1) / 3, + (2 * b0 + b1) / 3, + a); + colors[3] = RGBA((2 * r1 + r0) / 3, + (2 * g1 + g0) / 3, + (2 * b1 + b0) / 3, + a); + } else { + colors[0] = RGBA(r0, g0, b0, a); + colors[1] = RGBA(r1, g1, b1, a); + colors[2] = RGBA((r0 + r1) / 2, + (g0 + g1) / 2, + (b0 + b1) / 2, + a); + colors[3] = RGBA(0, 0, 0, alpha); + } +} + +static inline void dxt1_block_internal(uint8_t *dst, ptrdiff_t stride, + const uint8_t *block, uint8_t alpha) +{ + int x, y; + uint32_t colors[4]; + uint16_t color0 = AV_RL16(block + 0); + uint16_t color1 = AV_RL16(block + 2); + uint32_t code = AV_RL32(block + 4); + + extract_color(colors, color0, color1, 0, alpha); + + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + uint32_t pixel = colors[code & 3]; + code >>= 2; + AV_WL32(dst + x * 4, pixel); + } + dst += stride; + } +} + +/** + * Decompress one block of a DXT1 texture and store the resulting + * RGBA pixels in 'dst'. Alpha component is fully opaque. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to decompress. + * @return how much texture data has been consumed. + */ +static int dxt1_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + dxt1_block_internal(dst, stride, block, 255); + + return 8; +} + +/** + * Decompress one block of a DXT1 with 1-bit alpha texture and store + * the resulting RGBA pixels in 'dst'. Alpha is either fully opaque or + * fully transparent. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to decompress. + * @return how much texture data has been consumed. + */ +static int dxt1a_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + dxt1_block_internal(dst, stride, block, 0); + + return 8; +} + +static inline void dxt3_block_internal(uint8_t *dst, ptrdiff_t stride, + const uint8_t *block) +{ + int x, y; + uint32_t colors[4]; + uint16_t color0 = AV_RL16(block + 8); + uint16_t color1 = AV_RL16(block + 10); + uint32_t code = AV_RL32(block + 12); + + extract_color(colors, color0, color1, 1, 0); + + for (y = 0; y < 4; y++) { + const uint16_t alpha_code = AV_RL16(block + 2 * y); + uint8_t alpha_values[4]; + + alpha_values[0] = ((alpha_code >> 0) & 0x0F) * 17; + alpha_values[1] = ((alpha_code >> 4) & 0x0F) * 17; + alpha_values[2] = ((alpha_code >> 8) & 0x0F) * 17; + alpha_values[3] = ((alpha_code >> 12) & 0x0F) * 17; + + for (x = 0; x < 4; x++) { + uint8_t alpha = alpha_values[x]; + uint32_t pixel = colors[code & 3] | (alpha << 24); + code >>= 2; + + AV_WL32(dst + x * 4, pixel); + } + dst += stride; + } +} + +/** Convert a premultiplied alpha pixel to a straigth alpha pixel. */ +static av_always_inline void premult2straight(uint8_t *src) +{ + int r = src[0]; + int g = src[1]; + int b = src[2]; + int a = src[3]; /* unchanged */ + + src[0] = (uint8_t) r * a / 255; + src[1] = (uint8_t) g * a / 255; + src[2] = (uint8_t) b * a / 255; +} + +/** + * Decompress one block of a DXT2 texture and store the resulting + * RGBA pixels in 'dst'. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to decompress. + * @return how much texture data has been consumed. + */ +static int dxt2_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + int x, y; + + dxt3_block_internal(dst, stride, block); + + /* This format is DXT3, but returns premultiplied alpha. It needs to be + * converted because it's what lavc outputs (and swscale expects). */ + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + premult2straight(dst + x * 4 + y * stride); + + return 16; +} + +/** + * Decompress one block of a DXT3 texture and store the resulting + * RGBA pixels in 'dst'. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to decompress. + * @return how much texture data has been consumed. + */ +static int dxt3_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + dxt3_block_internal(dst, stride, block); + + return 16; +} + +/** + * Decompress a BC 16x3 index block stored as + * h g f e + * d c b a + * p o n m + * l k j i + * + * Bits packed as + * | h | g | f | e | d | c | b | a | // Entry + * |765 432 107 654 321 076 543 210| // Bit + * |0000000000111111111112222222222| // Byte + * + * into 16 8-bit indices. + */ +static void decompress_indices(uint8_t *dst, const uint8_t *src) +{ + int block, i; + + for (block = 0; block < 2; block++) { + int tmp = AV_RL24(src); + + /* Unpack 8x3 bit from last 3 byte block */ + for (i = 0; i < 8; i++) + dst[i] = (tmp >> (i * 3)) & 0x7; + + src += 3; + dst += 8; + } +} + +static inline void dxt5_block_internal(uint8_t *dst, ptrdiff_t stride, + const uint8_t *block) +{ + int x, y; + uint32_t colors[4]; + uint8_t alpha_indices[16]; + uint16_t color0 = AV_RL16(block + 8); + uint16_t color1 = AV_RL16(block + 10); + uint32_t code = AV_RL32(block + 12); + uint8_t alpha0 = *(block); + uint8_t alpha1 = *(block + 1); + + decompress_indices(alpha_indices, block + 2); + + extract_color(colors, color0, color1, 1, 0); + + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + int alpha_code = alpha_indices[x + y * 4]; + uint32_t pixel; + uint8_t alpha; + + if (alpha_code == 0) { + alpha = alpha0; + } else if (alpha_code == 1) { + alpha = alpha1; + } else { + if (alpha0 > alpha1) { + alpha = (uint8_t) (((8 - alpha_code) * alpha0 + + (alpha_code - 1) * alpha1) / 7); + } else { + if (alpha_code == 6) { + alpha = 0; + } else if (alpha_code == 7) { + alpha = 255; + } else { + alpha = (uint8_t) (((6 - alpha_code) * alpha0 + + (alpha_code - 1) * alpha1) / 5); + } + } + } + pixel = colors[code & 3] | (alpha << 24); + code >>= 2; + AV_WL32(dst + x * 4, pixel); + } + dst += stride; + } +} + +/** + * Decompress one block of a DXT4 texture and store the resulting + * RGBA pixels in 'dst'. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to decompress. + * @return how much texture data has been consumed. + */ +static int dxt4_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + int x, y; + + dxt5_block_internal(dst, stride, block); + + /* This format is DXT5, but returns premultiplied alpha. It needs to be + * converted because it's what lavc outputs (and swscale expects). */ + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + premult2straight(dst + x * 4 + y * stride); + + return 16; +} + +/** + * Decompress one block of a DXT5 texture and store the resulting + * RGBA pixels in 'dst'. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to decompress. + * @return how much texture data has been consumed. + */ +static int dxt5_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + dxt5_block_internal(dst, stride, block); + + return 16; +} + +/** + * Convert a YCoCg buffer to RGBA. + * + * @param src input buffer. + * @param scaled variant with scaled chroma components and opaque alpha. + */ +static av_always_inline void ycocg2rgba(uint8_t *src, int scaled) +{ + int r = src[0]; + int g = src[1]; + int b = src[2]; + int a = src[3]; + + int s = scaled ? (b >> 3) + 1 : 1; + int y = a; + int co = (r - 128) / s; + int cg = (g - 128) / s; + + src[0] = av_clip_uint8(y + co - cg); + src[1] = av_clip_uint8(y + cg); + src[2] = av_clip_uint8(y - co - cg); + src[3] = scaled ? 255 : b; +} + +/** + * Decompress one block of a DXT5 texture with classic YCoCg and store + * the resulting RGBA pixels in 'dst'. Alpha component is fully opaque. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to decompress. + * @return how much texture data has been consumed. + */ +static int dxt5y_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + int x, y; + + /* This format is basically DXT5, with luma stored in alpha. + * Run a normal decompress and then reorder the components. */ + dxt5_block_internal(dst, stride, block); + + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + ycocg2rgba(dst + x * 4 + y * stride, 0); + + return 16; +} + +/** + * Decompress one block of a DXT5 texture with scaled YCoCg and store + * the resulting RGBA pixels in 'dst'. Alpha component is fully opaque. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to decompress. + * @return how much texture data has been consumed. + */ +static int dxt5ys_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + int x, y; + + /* This format is basically DXT5, with luma stored in alpha. + * Run a normal decompress and then reorder the components. */ + dxt5_block_internal(dst, stride, block); + + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + ycocg2rgba(dst + x * 4 + y * stride, 1); + + return 16; +} + +static inline void rgtc_block_internal(uint8_t *dst, ptrdiff_t stride, + const uint8_t *block, + const int *color_tab) +{ + uint8_t indices[16]; + int x, y; + + decompress_indices(indices, block + 2); + + /* Only one or two channels are stored at most, since it only used to + * compress specular (black and white) or normal (red and green) maps. + * Although the standard says to zero out unused components, many + * implementations fill all of them with the same value. */ + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + int i = indices[x + y * 4]; + /* Interval expansion from [-1 1] or [0 1] to [0 255]. */ + int c = color_tab[i]; + uint32_t pixel = RGBA(c, c, c, 255U); + AV_WL32(dst + x * 4 + y * stride, pixel); + } + } +} + +static inline void rgtc1_block_internal(uint8_t *dst, ptrdiff_t stride, + const uint8_t *block, int sign) +{ + int color_table[8]; + int r0, r1; + + if (sign) { + /* signed data is in [-128 127] so just offset it to unsigned + * and it can be treated exactly the same */ + r0 = ((int8_t) block[0]) + 128; + r1 = ((int8_t) block[1]) + 128; + } else { + r0 = block[0]; + r1 = block[1]; + } + + color_table[0] = r0; + color_table[1] = r1; + + if (r0 > r1) { + /* 6 interpolated color values */ + color_table[2] = (6 * r0 + 1 * r1) / 7; // bit code 010 + color_table[3] = (5 * r0 + 2 * r1) / 7; // bit code 011 + color_table[4] = (4 * r0 + 3 * r1) / 7; // bit code 100 + color_table[5] = (3 * r0 + 4 * r1) / 7; // bit code 101 + color_table[6] = (2 * r0 + 5 * r1) / 7; // bit code 110 + color_table[7] = (1 * r0 + 6 * r1) / 7; // bit code 111 + } else { + /* 4 interpolated color values */ + color_table[2] = (4 * r0 + 1 * r1) / 5; // bit code 010 + color_table[3] = (3 * r0 + 2 * r1) / 5; // bit code 011 + color_table[4] = (2 * r0 + 3 * r1) / 5; // bit code 100 + color_table[5] = (1 * r0 + 4 * r1) / 5; // bit code 101 + color_table[6] = 0; /* min range */ // bit code 110 + color_table[7] = 255; /* max range */ // bit code 111 + } + + rgtc_block_internal(dst, stride, block, color_table); +} + +/** + * Decompress one block of a RGRC1 texture with signed components + * and store the resulting RGBA pixels in 'dst'. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to decompress. + * @return how much texture data has been consumed. + */ +static int rgtc1s_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + rgtc1_block_internal(dst, stride, block, 1); + + return 8; +} + +/** + * Decompress one block of a RGRC1 texture with unsigned components + * and store the resulting RGBA pixels in 'dst'. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to decompress. + * @return how much texture data has been consumed. + */ +static int rgtc1u_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + rgtc1_block_internal(dst, stride, block, 0); + + return 8; +} + +static inline void rgtc2_block_internal(uint8_t *dst, ptrdiff_t stride, + const uint8_t *block, int sign) +{ + /* 4x4 block containing 4 component pixels. */ + uint8_t c0[4 * 4 * 4]; + uint8_t c1[4 * 4 * 4]; + int x, y; + + /* Decompress the two channels separately and interleave them afterwards. */ + rgtc1_block_internal(c0, 16, block, sign); + rgtc1_block_internal(c1, 16, block + 8, sign); + + /* B is rebuilt exactly like a normal map. */ + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + uint8_t *p = dst + x * 4 + y * stride; + int r = c0[x * 4 + y * 16]; + int g = c1[x * 4 + y * 16]; + int b = 127; + + int d = (255 * 255 - r * r - g * g) / 2; + if (d > 0) + b = rint(sqrtf(d)); + + p[0] = r; + p[1] = g; + p[2] = b; + p[3] = 255; + } + } +} + +/** + * Decompress one block of a RGRC2 texture with signed components + * and store the resulting RGBA pixels in 'dst'. Alpha is fully opaque. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to decompress. + * @return how much texture data has been consumed. + */ +static int rgtc2s_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + rgtc2_block_internal(dst, stride, block, 1); + + return 16; +} + +/** + * Decompress one block of a RGRC2 texture with unsigned components + * and store the resulting RGBA pixels in 'dst'. Alpha is fully opaque. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to decompress. + * @return how much texture data has been consumed. + */ +static int rgtc2u_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + rgtc2_block_internal(dst, stride, block, 0); + + return 16; +} + +/** + * Decompress one block of a 3Dc texture with unsigned components + * and store the resulting RGBA pixels in 'dst'. Alpha is fully opaque. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to decompress. + * @return how much texture data has been consumed. + */ +static int dxn3dc_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + int x, y; + rgtc2_block_internal(dst, stride, block, 0); + + /* This is the 3Dc variant of RGTC2, with swapped R and G. */ + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + uint8_t *p = dst + x * 4 + y * stride; + FFSWAP(uint8_t, p[0], p[1]); + } + } + + return 16; +} + +av_cold void ff_texturedsp_init(TextureDSPContext *c) +{ + c->dxt1_block = dxt1_block; + c->dxt1a_block = dxt1a_block; + c->dxt2_block = dxt2_block; + c->dxt3_block = dxt3_block; + c->dxt4_block = dxt4_block; + c->dxt5_block = dxt5_block; + c->dxt5y_block = dxt5y_block; + c->dxt5ys_block = dxt5ys_block; + c->rgtc1s_block = rgtc1s_block; + c->rgtc1u_block = rgtc1u_block; + c->rgtc2s_block = rgtc2s_block; + c->rgtc2u_block = rgtc2u_block; + c->dxn3dc_block = dxn3dc_block; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/texturedspenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/texturedspenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/texturedspenc.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/texturedspenc.c 2015-06-25 17:20:03.000000000 +0000 @@ -0,0 +1,659 @@ +/* + * Texture block compression + * Copyright (C) 2015 Vittorio Giovara + * Based on public domain code by Fabian Giesen, Sean Barrett and Yann Collet. + * + * This file is part of FFmpeg + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include +#include + +#include "libavutil/attributes.h" +#include "libavutil/common.h" +#include "libavutil/intreadwrite.h" + +#include "texturedsp.h" + +const static uint8_t expand5[32] = { + 0, 8, 16, 24, 33, 41, 49, 57, 66, 74, 82, 90, + 99, 107, 115, 123, 132, 140, 148, 156, 165, 173, 181, 189, + 198, 206, 214, 222, 231, 239, 247, 255, +}; + +const static uint8_t expand6[64] = { + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, + 48, 52, 56, 60, 65, 69, 73, 77, 81, 85, 89, 93, + 97, 101, 105, 109, 113, 117, 121, 125, 130, 134, 138, 142, + 146, 150, 154, 158, 162, 166, 170, 174, 178, 182, 186, 190, + 195, 199, 203, 207, 211, 215, 219, 223, 227, 231, 235, 239, + 243, 247, 251, 255, +}; + +const static uint8_t match5[256][2] = { + { 0, 0 }, { 0, 0 }, { 0, 1 }, { 0, 1 }, { 1, 0 }, { 1, 0 }, + { 1, 0 }, { 1, 1 }, { 1, 1 }, { 2, 0 }, { 2, 0 }, { 0, 4 }, + { 2, 1 }, { 2, 1 }, { 2, 1 }, { 3, 0 }, { 3, 0 }, { 3, 0 }, + { 3, 1 }, { 1, 5 }, { 3, 2 }, { 3, 2 }, { 4, 0 }, { 4, 0 }, + { 4, 1 }, { 4, 1 }, { 4, 2 }, { 4, 2 }, { 4, 2 }, { 3, 5 }, + { 5, 1 }, { 5, 1 }, { 5, 2 }, { 4, 4 }, { 5, 3 }, { 5, 3 }, + { 5, 3 }, { 6, 2 }, { 6, 2 }, { 6, 2 }, { 6, 3 }, { 5, 5 }, + { 6, 4 }, { 6, 4 }, { 4, 8 }, { 7, 3 }, { 7, 3 }, { 7, 3 }, + { 7, 4 }, { 7, 4 }, { 7, 4 }, { 7, 5 }, { 5, 9 }, { 7, 6 }, + { 7, 6 }, { 8, 4 }, { 8, 4 }, { 8, 5 }, { 8, 5 }, { 8, 6 }, + { 8, 6 }, { 8, 6 }, { 7, 9 }, { 9, 5 }, { 9, 5 }, { 9, 6 }, + { 8, 8 }, { 9, 7 }, { 9, 7 }, { 9, 7 }, { 10, 6 }, { 10, 6 }, + { 10, 6 }, { 10, 7 }, { 9, 9 }, { 10, 8 }, { 10, 8 }, { 8, 12 }, + { 11, 7 }, { 11, 7 }, { 11, 7 }, { 11, 8 }, { 11, 8 }, { 11, 8 }, + { 11, 9 }, { 9, 13 }, { 11, 10 }, { 11, 10 }, { 12, 8 }, { 12, 8 }, + { 12, 9 }, { 12, 9 }, { 12, 10 }, { 12, 10 }, { 12, 10 }, { 11, 13 }, + { 13, 9 }, { 13, 9 }, { 13, 10 }, { 12, 12 }, { 13, 11 }, { 13, 11 }, + { 13, 11 }, { 14, 10 }, { 14, 10 }, { 14, 10 }, { 14, 11 }, { 13, 13 }, + { 14, 12 }, { 14, 12 }, { 12, 16 }, { 15, 11 }, { 15, 11 }, { 15, 11 }, + { 15, 12 }, { 15, 12 }, { 15, 12 }, { 15, 13 }, { 13, 17 }, { 15, 14 }, + { 15, 14 }, { 16, 12 }, { 16, 12 }, { 16, 13 }, { 16, 13 }, { 16, 14 }, + { 16, 14 }, { 16, 14 }, { 15, 17 }, { 17, 13 }, { 17, 13 }, { 17, 14 }, + { 16, 16 }, { 17, 15 }, { 17, 15 }, { 17, 15 }, { 18, 14 }, { 18, 14 }, + { 18, 14 }, { 18, 15 }, { 17, 17 }, { 18, 16 }, { 18, 16 }, { 16, 20 }, + { 19, 15 }, { 19, 15 }, { 19, 15 }, { 19, 16 }, { 19, 16 }, { 19, 16 }, + { 19, 17 }, { 17, 21 }, { 19, 18 }, { 19, 18 }, { 20, 16 }, { 20, 16 }, + { 20, 17 }, { 20, 17 }, { 20, 18 }, { 20, 18 }, { 20, 18 }, { 19, 21 }, + { 21, 17 }, { 21, 17 }, { 21, 18 }, { 20, 20 }, { 21, 19 }, { 21, 19 }, + { 21, 19 }, { 22, 18 }, { 22, 18 }, { 22, 18 }, { 22, 19 }, { 21, 21 }, + { 22, 20 }, { 22, 20 }, { 20, 24 }, { 23, 19 }, { 23, 19 }, { 23, 19 }, + { 23, 20 }, { 23, 20 }, { 23, 20 }, { 23, 21 }, { 21, 25 }, { 23, 22 }, + { 23, 22 }, { 24, 20 }, { 24, 20 }, { 24, 21 }, { 24, 21 }, { 24, 22 }, + { 24, 22 }, { 24, 22 }, { 23, 25 }, { 25, 21 }, { 25, 21 }, { 25, 22 }, + { 24, 24 }, { 25, 23 }, { 25, 23 }, { 25, 23 }, { 26, 22 }, { 26, 22 }, + { 26, 22 }, { 26, 23 }, { 25, 25 }, { 26, 24 }, { 26, 24 }, { 24, 28 }, + { 27, 23 }, { 27, 23 }, { 27, 23 }, { 27, 24 }, { 27, 24 }, { 27, 24 }, + { 27, 25 }, { 25, 29 }, { 27, 26 }, { 27, 26 }, { 28, 24 }, { 28, 24 }, + { 28, 25 }, { 28, 25 }, { 28, 26 }, { 28, 26 }, { 28, 26 }, { 27, 29 }, + { 29, 25 }, { 29, 25 }, { 29, 26 }, { 28, 28 }, { 29, 27 }, { 29, 27 }, + { 29, 27 }, { 30, 26 }, { 30, 26 }, { 30, 26 }, { 30, 27 }, { 29, 29 }, + { 30, 28 }, { 30, 28 }, { 30, 28 }, { 31, 27 }, { 31, 27 }, { 31, 27 }, + { 31, 28 }, { 31, 28 }, { 31, 28 }, { 31, 29 }, { 31, 29 }, { 31, 30 }, + { 31, 30 }, { 31, 30 }, { 31, 31 }, { 31, 31 }, +}; + +const static uint8_t match6[256][2] = { + { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 0 }, { 1, 1 }, { 2, 0 }, + { 2, 1 }, { 3, 0 }, { 3, 0 }, { 3, 1 }, { 4, 0 }, { 4, 0 }, + { 4, 1 }, { 5, 0 }, { 5, 1 }, { 6, 0 }, { 6, 0 }, { 6, 1 }, + { 7, 0 }, { 7, 0 }, { 7, 1 }, { 8, 0 }, { 8, 1 }, { 8, 1 }, + { 8, 2 }, { 9, 1 }, { 9, 2 }, { 9, 2 }, { 9, 3 }, { 10, 2 }, + { 10, 3 }, { 10, 3 }, { 10, 4 }, { 11, 3 }, { 11, 4 }, { 11, 4 }, + { 11, 5 }, { 12, 4 }, { 12, 5 }, { 12, 5 }, { 12, 6 }, { 13, 5 }, + { 13, 6 }, { 8, 16 }, { 13, 7 }, { 14, 6 }, { 14, 7 }, { 9, 17 }, + { 14, 8 }, { 15, 7 }, { 15, 8 }, { 11, 16 }, { 15, 9 }, { 15, 10 }, + { 16, 8 }, { 16, 9 }, { 16, 10 }, { 15, 13 }, { 17, 9 }, { 17, 10 }, + { 17, 11 }, { 15, 16 }, { 18, 10 }, { 18, 11 }, { 18, 12 }, { 16, 16 }, + { 19, 11 }, { 19, 12 }, { 19, 13 }, { 17, 17 }, { 20, 12 }, { 20, 13 }, + { 20, 14 }, { 19, 16 }, { 21, 13 }, { 21, 14 }, { 21, 15 }, { 20, 17 }, + { 22, 14 }, { 22, 15 }, { 25, 10 }, { 22, 16 }, { 23, 15 }, { 23, 16 }, + { 26, 11 }, { 23, 17 }, { 24, 16 }, { 24, 17 }, { 27, 12 }, { 24, 18 }, + { 25, 17 }, { 25, 18 }, { 28, 13 }, { 25, 19 }, { 26, 18 }, { 26, 19 }, + { 29, 14 }, { 26, 20 }, { 27, 19 }, { 27, 20 }, { 30, 15 }, { 27, 21 }, + { 28, 20 }, { 28, 21 }, { 28, 21 }, { 28, 22 }, { 29, 21 }, { 29, 22 }, + { 24, 32 }, { 29, 23 }, { 30, 22 }, { 30, 23 }, { 25, 33 }, { 30, 24 }, + { 31, 23 }, { 31, 24 }, { 27, 32 }, { 31, 25 }, { 31, 26 }, { 32, 24 }, + { 32, 25 }, { 32, 26 }, { 31, 29 }, { 33, 25 }, { 33, 26 }, { 33, 27 }, + { 31, 32 }, { 34, 26 }, { 34, 27 }, { 34, 28 }, { 32, 32 }, { 35, 27 }, + { 35, 28 }, { 35, 29 }, { 33, 33 }, { 36, 28 }, { 36, 29 }, { 36, 30 }, + { 35, 32 }, { 37, 29 }, { 37, 30 }, { 37, 31 }, { 36, 33 }, { 38, 30 }, + { 38, 31 }, { 41, 26 }, { 38, 32 }, { 39, 31 }, { 39, 32 }, { 42, 27 }, + { 39, 33 }, { 40, 32 }, { 40, 33 }, { 43, 28 }, { 40, 34 }, { 41, 33 }, + { 41, 34 }, { 44, 29 }, { 41, 35 }, { 42, 34 }, { 42, 35 }, { 45, 30 }, + { 42, 36 }, { 43, 35 }, { 43, 36 }, { 46, 31 }, { 43, 37 }, { 44, 36 }, + { 44, 37 }, { 44, 37 }, { 44, 38 }, { 45, 37 }, { 45, 38 }, { 40, 48 }, + { 45, 39 }, { 46, 38 }, { 46, 39 }, { 41, 49 }, { 46, 40 }, { 47, 39 }, + { 47, 40 }, { 43, 48 }, { 47, 41 }, { 47, 42 }, { 48, 40 }, { 48, 41 }, + { 48, 42 }, { 47, 45 }, { 49, 41 }, { 49, 42 }, { 49, 43 }, { 47, 48 }, + { 50, 42 }, { 50, 43 }, { 50, 44 }, { 48, 48 }, { 51, 43 }, { 51, 44 }, + { 51, 45 }, { 49, 49 }, { 52, 44 }, { 52, 45 }, { 52, 46 }, { 51, 48 }, + { 53, 45 }, { 53, 46 }, { 53, 47 }, { 52, 49 }, { 54, 46 }, { 54, 47 }, + { 57, 42 }, { 54, 48 }, { 55, 47 }, { 55, 48 }, { 58, 43 }, { 55, 49 }, + { 56, 48 }, { 56, 49 }, { 59, 44 }, { 56, 50 }, { 57, 49 }, { 57, 50 }, + { 60, 45 }, { 57, 51 }, { 58, 50 }, { 58, 51 }, { 61, 46 }, { 58, 52 }, + { 59, 51 }, { 59, 52 }, { 62, 47 }, { 59, 53 }, { 60, 52 }, { 60, 53 }, + { 60, 53 }, { 60, 54 }, { 61, 53 }, { 61, 54 }, { 61, 54 }, { 61, 55 }, + { 62, 54 }, { 62, 55 }, { 62, 55 }, { 62, 56 }, { 63, 55 }, { 63, 56 }, + { 63, 56 }, { 63, 57 }, { 63, 58 }, { 63, 59 }, { 63, 59 }, { 63, 60 }, + { 63, 61 }, { 63, 62 }, { 63, 62 }, { 63, 63 }, +}; + +/* Multiplication over 8 bit emulation */ +#define mul8(a, b) (((a) * (b) + 128 + (((a) * (b) + 128) >> 8)) >> 8) + +/* Conversion from rgb24 to rgb565 */ +#define rgb2rgb565(r, g, b) \ + ((mul8(r, 31) << 11) | (mul8(g, 63) << 5) | (mul8(b, 31) << 0)) + +/* Linear interpolation at 1/3 point between a and b */ +#define lerp13(a, b) ((2 * (a) + (b)) / 3) + +/* Linear interpolation on an RGB pixel */ +static inline void lerp13rgb(uint8_t *out, uint8_t *p1, uint8_t *p2) +{ + out[0] = lerp13(p1[0], p2[0]); + out[1] = lerp13(p1[1], p2[1]); + out[2] = lerp13(p1[2], p2[2]); +} + +/* Conversion from rgb565 to rgb24 */ +static inline void rgb5652rgb(uint8_t *out, uint16_t v) +{ + int rv = (v & 0xf800) >> 11; + int gv = (v & 0x07e0) >> 5; + int bv = (v & 0x001f) >> 0; + + out[0] = expand5[rv]; + out[1] = expand6[gv]; + out[2] = expand5[bv]; + out[3] = 0; +} + +/* Color matching function */ +static unsigned int match_colors(const uint8_t *block, ptrdiff_t stride, + uint16_t c0, uint16_t c1) +{ + uint32_t mask = 0; + int dirr, dirg, dirb; + int dots[16]; + int stops[4]; + int x, y, k = 0; + int c0_point, half_point, c3_point; + uint8_t color[16]; + const int indexMap[8] = { + 0 << 30, 2 << 30, 0 << 30, 2 << 30, + 3 << 30, 3 << 30, 1 << 30, 1 << 30, + }; + + /* Fill color and compute direction for each component */ + rgb5652rgb(color + 0, c0); + rgb5652rgb(color + 4, c1); + lerp13rgb(color + 8, color + 0, color + 4); + lerp13rgb(color + 12, color + 4, color + 0); + + dirr = color[0 * 4 + 0] - color[1 * 4 + 0]; + dirg = color[0 * 4 + 1] - color[1 * 4 + 1]; + dirb = color[0 * 4 + 2] - color[1 * 4 + 2]; + + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) + dots[k++] = block[0 + x * 4 + y * stride] * dirr + + block[1 + x * 4 + y * stride] * dirg + + block[2 + x * 4 + y * stride] * dirb; + + stops[y] = color[0 + y * 4] * dirr + + color[1 + y * 4] * dirg + + color[2 + y * 4] * dirb; + } + + /* Think of the colors as arranged on a line; project point onto that line, + * then choose next color out of available ones. we compute the crossover + * points for 'best color in top half'/'best in bottom half' and then + * the same inside that subinterval. + * + * Relying on this 1d approximation isn't always optimal in terms of + * euclidean distance, but it's very close and a lot faster. + * + * http://cbloomrants.blogspot.com/2008/12/12-08-08-dxtc-summary.html */ + c0_point = (stops[1] + stops[3]) >> 1; + half_point = (stops[3] + stops[2]) >> 1; + c3_point = (stops[2] + stops[0]) >> 1; + + for (x = 0; x < 16; x++) { + int dot = dots[x]; + int bits = (dot < half_point ? 4 : 0) | + (dot < c0_point ? 2 : 0) | + (dot < c3_point ? 1 : 0); + + mask >>= 2; + mask |= indexMap[bits]; + } + + return mask; +} + +/* Color optimization function */ +static void optimize_colors(const uint8_t *block, ptrdiff_t stride, + uint16_t *pmax16, uint16_t *pmin16) +{ + const uint8_t *minp; + const uint8_t *maxp; + const int iter_power = 4; + double magn; + int v_r, v_g, v_b; + float covf[6], vfr, vfg, vfb; + int mind, maxd; + int cov[6] = { 0 }; + int mu[3], min[3], max[3]; + int ch, iter, x, y; + + /* Determine color distribution */ + for (ch = 0; ch < 3; ch++) { + const uint8_t *bp = &block[ch]; + int muv, minv, maxv; + + muv = minv = maxv = bp[0]; + for (y = 0; y < 4; y++) { + for (x = 4; x < 4; x += 4) { + muv += bp[x * 4 + y * stride]; + if (bp[x] < minv) + minv = bp[x * 4 + y * stride]; + else if (bp[x] > maxv) + maxv = bp[x * 4 + y * stride]; + } + } + + mu[ch] = (muv + 8) >> 4; + min[ch] = minv; + max[ch] = maxv; + } + + /* Determine covariance matrix */ + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + int r = block[x * 4 + stride * y + 0] - mu[0]; + int g = block[x * 4 + stride * y + 1] - mu[1]; + int b = block[x * 4 + stride * y + 2] - mu[2]; + + cov[0] += r * r; + cov[1] += r * g; + cov[2] += r * b; + cov[3] += g * g; + cov[4] += g * b; + cov[5] += b * b; + } + } + + /* Convert covariance matrix to float, find principal axis via power iter */ + for (x = 0; x < 6; x++) + covf[x] = cov[x] / 255.0f; + + vfr = (float) (max[0] - min[0]); + vfg = (float) (max[1] - min[1]); + vfb = (float) (max[2] - min[2]); + + for (iter = 0; iter < iter_power; iter++) { + float r = vfr * covf[0] + vfg * covf[1] + vfb * covf[2]; + float g = vfr * covf[1] + vfg * covf[3] + vfb * covf[4]; + float b = vfr * covf[2] + vfg * covf[4] + vfb * covf[5]; + + vfr = r; + vfg = g; + vfb = b; + } + + magn = fabs(vfr); + if (fabs(vfg) > magn) + magn = fabs(vfg); + if (fabs(vfb) > magn) + magn = fabs(vfb); + + /* if magnitudo is too small, default to luminance */ + if (magn < 4.0f) { + /* JPEG YCbCr luma coefs, scaled by 1000 */ + v_r = 299; + v_g = 587; + v_b = 114; + } else { + magn = 512.0 / magn; + v_r = (int) (vfr * magn); + v_g = (int) (vfg * magn); + v_b = (int) (vfb * magn); + } + + /* Pick colors at extreme points */ + mind = maxd = block[0] * v_r + block[1] * v_g + block[2] * v_b; + minp = maxp = block; + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + int dot = block[x * 4 + y * stride + 0] * v_r + + block[x * 4 + y * stride + 1] * v_g + + block[x * 4 + y * stride + 2] * v_b; + + if (dot < mind) { + mind = dot; + minp = block + x * 4 + y * stride; + } else if (dot > maxd) { + maxd = dot; + maxp = block + x * 4 + y * stride; + } + } + } + + *pmax16 = rgb2rgb565(maxp[0], maxp[1], maxp[2]); + *pmin16 = rgb2rgb565(minp[0], minp[1], minp[2]); +} + +/* Try to optimize colors to suit block contents better, by solving + * a least squares system via normal equations + Cramer's rule. */ +static int refine_colors(const uint8_t *block, ptrdiff_t stride, + uint16_t *pmax16, uint16_t *pmin16, uint32_t mask) +{ + uint32_t cm = mask; + uint16_t oldMin = *pmin16; + uint16_t oldMax = *pmax16; + uint16_t min16, max16; + int x, y; + + /* Additional magic to save a lot of multiplies in the accumulating loop. + * The tables contain precomputed products of weights for least squares + * system, accumulated inside one 32-bit register */ + const int w1tab[4] = { 3, 0, 2, 1 }; + const int prods[4] = { 0x090000, 0x000900, 0x040102, 0x010402 }; + + /* Check if all pixels have the same index */ + if ((mask ^ (mask << 2)) < 4) { + /* If so, linear system would be singular; solve using optimal + * single-color match on average color. */ + int r = 8, g = 8, b = 8; + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + r += block[0 + x * 4 + y * stride]; + g += block[1 + x * 4 + y * stride]; + b += block[2 + x * 4 + y * stride]; + } + } + + r >>= 4; + g >>= 4; + b >>= 4; + + max16 = (match5[r][0] << 11) | (match6[g][0] << 5) | match5[b][0]; + min16 = (match5[r][1] << 11) | (match6[g][1] << 5) | match5[b][1]; + } else { + float fr, fg, fb; + int at1_r = 0, at1_g = 0, at1_b = 0; + int at2_r = 0, at2_g = 0, at2_b = 0; + int akku = 0; + int xx, xy, yy; + + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + int step = cm & 3; + int w1 = w1tab[step]; + int r = block[0 + x * 4 + y * stride]; + int g = block[1 + x * 4 + y * stride]; + int b = block[2 + x * 4 + y * stride]; + + akku += prods[step]; + at1_r += w1 * r; + at1_g += w1 * g; + at1_b += w1 * b; + at2_r += r; + at2_g += g; + at2_b += b; + + cm >>= 2; + } + } + + at2_r = 3 * at2_r - at1_r; + at2_g = 3 * at2_g - at1_g; + at2_b = 3 * at2_b - at1_b; + + /* Extract solutions and decide solvability */ + xx = akku >> 16; + yy = (akku >> 8) & 0xFF; + xy = (akku >> 0) & 0xFF; + + fr = 3.0f * 31.0f / 255.0f / (xx * yy - xy * xy); + fg = fr * 63.0f / 31.0f; + fb = fr; + + /* Solve */ + max16 = av_clip_uintp2((at1_r * yy - at2_r * xy) * fr + 0.5f, 5) << 11; + max16 |= av_clip_uintp2((at1_g * yy - at2_g * xy) * fg + 0.5f, 6) << 5; + max16 |= av_clip_uintp2((at1_b * yy - at2_b * xy) * fb + 0.5f, 5) << 0; + + min16 = av_clip_uintp2((at2_r * xx - at1_r * xy) * fr + 0.5f, 5) << 11; + min16 |= av_clip_uintp2((at2_g * xx - at1_g * xy) * fg + 0.5f, 6) << 5; + min16 |= av_clip_uintp2((at2_b * xx - at1_b * xy) * fb + 0.5f, 5) << 0; + } + + *pmin16 = min16; + *pmax16 = max16; + return oldMin != min16 || oldMax != max16; +} + +/* Check if input block is a constant color */ +static int constant_color(const uint8_t *block, ptrdiff_t stride) +{ + int x, y; + uint32_t first = AV_RL32(block); + + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + if (first != AV_RL32(block + x * 4 + y * stride)) + return 0; + return 1; +} + +/* Main color compression function */ +static void compress_color(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + uint32_t mask; + uint16_t max16, min16; + int constant = constant_color(block, stride); + + /* Constant color will load values from tables */ + if (constant) { + int r = block[0]; + int g = block[1]; + int b = block[2]; + mask = 0xAAAAAAAA; + max16 = (match5[r][0] << 11) | (match6[g][0] << 5) | match5[b][0]; + min16 = (match5[r][1] << 11) | (match6[g][1] << 5) | match5[b][1]; + } else { + int refine; + + /* Otherwise find pca and map along principal axis */ + optimize_colors(block, stride, &max16, &min16); + if (max16 != min16) + mask = match_colors(block, stride, max16, min16); + else + mask = 0; + + /* One pass refinement */ + refine = refine_colors(block, stride, &max16, &min16, mask); + if (refine) { + if (max16 != min16) + mask = match_colors(block, stride, max16, min16); + else + mask = 0; + } + } + + /* Finally write the color block */ + if (max16 < min16) { + FFSWAP(uint16_t, min16, max16); + mask ^= 0x55555555; + } + + AV_WL16(dst + 0, max16); + AV_WL16(dst + 2, min16); + AV_WL32(dst + 4, mask); +} + +/* Alpha compression function */ +static void compress_alpha(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + int x, y; + int dist, bias, dist4, dist2; + int mn, mx; + int bits = 0; + int mask = 0; + + memset(dst, 0, 8); + + /* Find min/max color */ + mn = mx = block[3]; + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + int val = block[3 + x * 4 + y * stride]; + if (val < mn) + mn = val; + else if (val > mx) + mx = val; + } + } + + /* Encode them */ + dst[0] = (uint8_t) mx; + dst[1] = (uint8_t) mn; + dst += 2; + + /* Mono-alpha shortcut */ + if (mn == mx) + return; + + /* Determine bias and emit color indices. + * Given the choice of mx/mn, these indices are optimal: + * fgiesen.wordpress.com/2009/12/15/dxt5-alpha-block-index-determination */ + dist = mx - mn; + + dist4 = dist * 4; + dist2 = dist * 2; + if (dist < 8) + bias = dist - 1 - mn * 7; + else + bias = dist / 2 + 2 - mn * 7; + + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + int alp = block[3 + x * 4 + y * stride] * 7 + bias; + int ind, tmp; + + /* This is a "linear scale" lerp factor between 0 (val=min) + * and 7 (val=max) to select index. */ + tmp = (alp >= dist4) ? -1 : 0; + ind = tmp & 4; + alp -= dist4 & tmp; + tmp = (alp >= dist2) ? -1 : 0; + ind += tmp & 2; + alp -= dist2 & tmp; + ind += (alp >= dist); + + /* Turn linear scale into DXT index (0/1 are extreme points) */ + ind = -ind & 7; + ind ^= (2 > ind); + + /* Write index */ + mask |= ind << bits; + bits += 3; + if (bits >= 8) { + *dst++ = mask; + mask >>= 8; + bits -= 8; + } + } + } +} + +/** + * Convert a RGBA buffer to unscaled YCoCg. + * Scale is usually introduced to avoid banding over a certain range of colors, + * but this version of the algorithm does not introduce it as much as other + * implementations, allowing for a simpler and faster conversion. + */ +static void rgba2ycocg(uint8_t *dst, const uint8_t *pixel) +{ + int r = pixel[0]; + int g = (pixel[1] + 1) >> 1; + int b = pixel[2]; + int t = (2 + r + b) >> 2; + + int y = av_clip_uint8(g + t); + int co = av_clip_uint8(128 + ((r - b + 1) >> 1)); + int cg = av_clip_uint8(128 + g - t); + + dst[0] = (uint8_t) co; + dst[1] = (uint8_t) cg; + dst[2] = 0; + dst[3] = (uint8_t) y; +} + +/** + * Compress one block of RGBA pixels in a DXT1 texture and store the + * resulting bytes in 'dst'. Alpha is not preserved. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to compress. + * @return how much texture data has been written. + */ +static int dxt1_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + compress_color(dst, stride, block); + + return 8; +} + +/** + * Compress one block of RGBA pixels in a DXT5 texture and store the + * resulting bytes in 'dst'. Alpha is preserved. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to compress. + * @return how much texture data has been written. + */ +static int dxt5_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + compress_alpha(dst, stride, block); + compress_color(dst + 8, stride, block); + + return 16; +} + +/** + * Compress one block of RGBA pixels in a DXT5-YCoCg texture and store the + * resulting bytes in 'dst'. Alpha is not preserved. + * + * @param dst output buffer. + * @param stride scanline in bytes. + * @param block block to compress. + * @return how much texture data has been written. + */ +static int dxt5ys_block(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) +{ + int x, y; + uint8_t reorder[64]; + + /* Reorder the components and then run a normal DXT5 compression. */ + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + rgba2ycocg(reorder + x * 4 + y * 16, block + x * 4 + y * stride); + + compress_alpha(dst + 0, 16, reorder); + compress_color(dst + 8, 16, reorder); + + return 16; +} + +av_cold void ff_texturedspenc_init(TextureDSPContext *c) +{ + c->dxt1_block = dxt1_block; + c->dxt5_block = dxt5_block; + c->dxt5ys_block = dxt5ys_block; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/texturedsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/texturedsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/texturedsp.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/texturedsp.h 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,64 @@ +/* + * Texture block module + * Copyright (C) 2015 Vittorio Giovara + * + * 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 + */ + +/** + * @file + * Texture block (4x4) module + * + * References: + * https://www.opengl.org/wiki/S3_Texture_Compression + * https://www.opengl.org/wiki/Red_Green_Texture_Compression + * https://msdn.microsoft.com/en-us/library/bb694531%28v=vs.85%29.aspx + * + * All functions return how much data has been written or read. + * + * Pixel input or output format is always AV_PIX_FMT_RGBA. + */ + +#ifndef AVCODEC_TEXTUREDSP_H +#define AVCODEC_TEXTUREDSP_H + +#include +#include + +#define TEXTURE_BLOCK_W 4 +#define TEXTURE_BLOCK_H 4 + +typedef struct TextureDSPContext { + int (*dxt1_block) (uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + int (*dxt1a_block) (uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + int (*dxt2_block) (uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + int (*dxt3_block) (uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + int (*dxt4_block) (uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + int (*dxt5_block) (uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + int (*dxt5y_block) (uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + int (*dxt5ys_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + int (*rgtc1s_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + int (*rgtc1u_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + int (*rgtc2s_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + int (*rgtc2u_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block); + int (*dxn3dc_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block); +} TextureDSPContext; + +void ff_texturedsp_init(TextureDSPContext *c); +void ff_texturedspenc_init(TextureDSPContext *c); + +#endif /* AVCODEC_TEXTUREDSP_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/tiertexseqv.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/tiertexseqv.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/tiertexseqv.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/tiertexseqv.c 2015-07-28 17:20:07.000000000 +0000 @@ -265,5 +265,5 @@ .init = seqvideo_decode_init, .close = seqvideo_decode_end, .decode = seqvideo_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/tiff.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/tiff.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/tiff.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/tiff.c 2015-07-28 17:20:07.000000000 +0000 @@ -453,7 +453,7 @@ int i, ret = 0; int line; uint8_t *src2 = av_malloc((unsigned)size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!src2) { av_log(s->avctx, AV_LOG_ERROR, @@ -471,7 +471,7 @@ for (i = 0; i < size; i++) src2[i] = ff_reverse[src[i]]; } - memset(src2 + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(src2 + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride, s->compr, s->fax_opts); if (s->bpp < 8 && s->avctx->pix_fmt == AV_PIX_FMT_PAL8) @@ -1388,5 +1388,5 @@ .close = tiff_end, .decode = decode_frame, .init_thread_copy = ONLY_IF_THREADS_ENABLED(tiff_init), - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/tiffenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/tiffenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/tiffenc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/tiffenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -329,9 +329,9 @@ bytes_per_row = (((s->width - 1) / s->subsampling[0] + 1) * s->bpp * s->subsampling[0] * s->subsampling[1] + 7) >> 3; packet_size = avctx->height * bytes_per_row * 2 + - avctx->height * 4 + FF_MIN_BUFFER_SIZE; + avctx->height * 4 + AV_INPUT_BUFFER_MIN_SIZE; - if ((ret = ff_alloc_packet2(avctx, pkt, packet_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, packet_size, 0)) < 0) return ret; ptr = pkt->data; s->buf_start = pkt->data; @@ -475,7 +475,7 @@ ADD_ENTRY(s, TIFF_YRES, TIFF_RATIONAL, 1, res); ADD_ENTRY1(s, TIFF_RES_UNIT, TIFF_SHORT, 2); - if (!(avctx->flags & CODEC_FLAG_BITEXACT)) + if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) ADD_ENTRY(s, TIFF_SOFTWARE_NAME, TIFF_STRING, strlen(LIBAVCODEC_IDENT) + 1, LIBAVCODEC_IDENT); @@ -521,13 +521,12 @@ static av_cold int encode_init(AVCodecContext *avctx) { TiffEncoderContext *s = avctx->priv_data; - - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif s->avctx = avctx; return 0; @@ -537,7 +536,6 @@ { TiffEncoderContext *s = avctx->priv_data; - av_frame_free(&avctx->coded_frame); av_freep(&s->strip_sizes); av_freep(&s->strip_offsets); av_freep(&s->yuv_line); @@ -574,7 +572,7 @@ .priv_data_size = sizeof(TiffEncoderContext), .init = encode_init, .close = encode_close, - .capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY, + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .encode2 = encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48LE, AV_PIX_FMT_PAL8, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/tmv.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/tmv.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/tmv.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/tmv.c 2015-07-28 17:20:07.000000000 +0000 @@ -93,5 +93,5 @@ .id = AV_CODEC_ID_TMV, .init = tmv_decode_init, .decode = tmv_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/truemotion1.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/truemotion1.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/truemotion1.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/truemotion1.c 2015-07-28 17:20:07.000000000 +0000 @@ -912,5 +912,5 @@ .init = truemotion1_decode_init, .close = truemotion1_decode_end, .decode = truemotion1_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/truemotion2.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/truemotion2.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/truemotion2.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/truemotion2.c 2015-07-28 17:20:07.000000000 +0000 @@ -1023,5 +1023,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/truespeech.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/truespeech.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/truespeech.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/truespeech.c 2015-07-28 17:20:07.000000000 +0000 @@ -362,5 +362,5 @@ .priv_data_size = sizeof(TSContext), .init = truespeech_decode_init, .decode = truespeech_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/tscc2.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/tscc2.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/tscc2.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/tscc2.c 2015-07-28 17:20:07.000000000 +0000 @@ -384,5 +384,5 @@ .init = tscc2_decode_init, .close = tscc2_decode_end, .decode = tscc2_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/tscc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/tscc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/tscc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/tscc.c 2015-07-28 17:20:07.000000000 +0000 @@ -184,5 +184,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/tta.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/tta.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/tta.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/tta.c 2015-07-28 17:20:07.000000000 +0000 @@ -425,6 +425,6 @@ .close = tta_decode_close, .decode = tta_decode_frame, .init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy), - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .priv_class = &tta_decoder_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ttaenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ttaenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ttaenc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ttaenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -116,7 +116,7 @@ PutBitContext pb; int ret, i, out_bytes, cur_chan = 0, res = 0, samples = 0; - if ((ret = ff_alloc_packet2(avctx, avpkt, frame->nb_samples * 2 * avctx->channels * s->bps)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, frame->nb_samples * 2 * avctx->channels * s->bps, 0)) < 0) return ret; init_put_bits(&pb, avpkt->data, avpkt->size); @@ -224,7 +224,7 @@ .init = tta_encode_init, .close = tta_encode_close, .encode2 = tta_encode_frame, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_LOSSLESS, + .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_LOSSLESS, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/twinvq.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/twinvq.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/twinvq.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/twinvq.c 2015-07-28 17:20:07.000000000 +0000 @@ -789,7 +789,7 @@ return AVERROR_INVALIDDATA; } - tctx->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + tctx->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!tctx->fdsp) { ff_twinvq_decode_close(avctx); return AVERROR(ENOMEM); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/twinvqdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/twinvqdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/twinvqdec.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/twinvqdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -422,7 +422,7 @@ .init = twinvq_decode_init, .close = ff_twinvq_decode_close, .decode = ff_twinvq_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/txd.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/txd.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/txd.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/txd.c 2015-07-28 17:20:07.000000000 +0000 @@ -26,18 +26,25 @@ #include "bytestream.h" #include "avcodec.h" #include "internal.h" -#include "s3tc.h" +#include "texturedsp.h" + +#define TXD_DXT1 0x31545844 +#define TXD_DXT3 0x33545844 static int txd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { GetByteContext gb; + TextureDSPContext dxtc; AVFrame * const p = data; unsigned int version, w, h, d3d_format, depth, stride, flags; unsigned int y, v; uint8_t *ptr; uint32_t *pal; + int i, j; int ret; + ff_texturedsp_init(&dxtc); + bytestream2_init(&gb, avpkt->data, avpkt->size); version = bytestream2_get_le32(&gb); bytestream2_skip(&gb, 72); @@ -57,7 +64,7 @@ if (depth == 8) { avctx->pix_fmt = AV_PIX_FMT_PAL8; } else if (depth == 16 || depth == 32) { - avctx->pix_fmt = AV_PIX_FMT_RGB32; + avctx->pix_fmt = AV_PIX_FMT_RGBA; } else { av_log(avctx, AV_LOG_ERROR, "depth of %i is unsupported\n", depth); return AVERROR_PATCHWELCOME; @@ -66,6 +73,9 @@ if ((ret = ff_set_dimensions(avctx, w, h)) < 0) return ret; + avctx->coded_width = FFALIGN(w, 4); + avctx->coded_height = FFALIGN(h, 4); + if ((ret = ff_get_buffer(avctx, p, 0)) < 0) return ret; @@ -93,15 +103,27 @@ case 0: if (!(flags & 1)) goto unsupported; - case FF_S3TC_DXT1: + case TXD_DXT1: if (bytestream2_get_bytes_left(&gb) < FF_CEIL_RSHIFT(w, 2) * FF_CEIL_RSHIFT(h, 2) * 8) return AVERROR_INVALIDDATA; - ff_decode_dxt1(&gb, ptr, w, h, stride); + for (j = 0; j < avctx->height; j += 4) { + for (i = 0; i < avctx->width; i += 4) { + uint8_t *p = ptr + i * 4 + j * stride; + int step = dxtc.dxt1_block(p, stride, gb.buffer); + bytestream2_skip(&gb, step); + } + } break; - case FF_S3TC_DXT3: + case TXD_DXT3: if (bytestream2_get_bytes_left(&gb) < FF_CEIL_RSHIFT(w, 2) * FF_CEIL_RSHIFT(h, 2) * 16) return AVERROR_INVALIDDATA; - ff_decode_dxt3(&gb, ptr, w, h, stride); + for (j = 0; j < avctx->height; j += 4) { + for (i = 0; i < avctx->width; i += 4) { + uint8_t *p = ptr + i * 4 + j * stride; + int step = dxtc.dxt3_block(p, stride, gb.buffer); + bytestream2_skip(&gb, step); + } + } break; default: goto unsupported; @@ -137,5 +159,5 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_TXD, .decode = txd_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ulti.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ulti.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ulti.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ulti.c 2015-07-28 17:20:07.000000000 +0000 @@ -424,5 +424,5 @@ .init = ulti_decode_init, .close = ulti_decode_end, .decode = ulti_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/utils.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/utils.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/utils.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/utils.c 2015-07-29 17:20:04.000000000 +0000 @@ -36,6 +36,7 @@ #include "libavutil/frame.h" #include "libavutil/internal.h" #include "libavutil/mathematics.h" +#include "libavutil/mem_internal.h" #include "libavutil/pixdesc.h" #include "libavutil/imgutils.h" #include "libavutil/samplefmt.h" @@ -122,42 +123,28 @@ static void *codec_mutex; static void *avformat_mutex; -static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc) -{ - void **p = ptr; - if (min_size <= *size && *p) - return 0; - min_size = FFMAX(17 * min_size / 16 + 32, min_size); - av_free(*p); - *p = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size); - if (!*p) - min_size = 0; - *size = min_size; - return 1; -} - void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) { uint8_t **p = ptr; - if (min_size > SIZE_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { + if (min_size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE) { av_freep(p); *size = 0; return; } - if (!ff_fast_malloc(p, size, min_size + FF_INPUT_BUFFER_PADDING_SIZE, 1)) - memset(*p + min_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + if (!ff_fast_malloc(p, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE, 1)) + memset(*p + min_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); } void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size) { uint8_t **p = ptr; - if (min_size > SIZE_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { + if (min_size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE) { av_freep(p); *size = 0; return; } - if (!ff_fast_malloc(p, size, min_size + FF_INPUT_BUFFER_PADDING_SIZE, 1)) - memset(*p, 0, min_size + FF_INPUT_BUFFER_PADDING_SIZE); + if (!ff_fast_malloc(p, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE, 1)) + memset(*p, 0, min_size + AV_INPUT_BUFFER_PADDING_SIZE); } /* encoder management */ @@ -428,11 +415,18 @@ *width = FFALIGN(*width, w_align); *height = FFALIGN(*height, h_align); - if (s->codec_id == AV_CODEC_ID_H264 || s->lowres) + if (s->codec_id == AV_CODEC_ID_H264 || s->lowres) { // some of the optimized chroma MC reads one line too much // which is also done in mpeg decoders with lowres > 0 *height += 2; + // H.264 uses edge emulation for out of frame motion vectors, for this + // it requires a temporary area large enough to hold a 21x21 block, + // increasing witdth ensure that the temporary area is large enough, + // the next rounded up width is 32 + *width = FFMAX(*width, 32); + } + for (i = 0; i < 4; i++) linesize_align[i] = STRIDE_ALIGN; } @@ -739,6 +733,18 @@ } } +static int add_metadata_from_side_data(AVPacket *avpkt, AVFrame *frame) +{ + int size; + const uint8_t *side_metadata; + + AVDictionary **frame_md = avpriv_frame_get_metadatap(frame); + + side_metadata = av_packet_get_side_data(avpkt, + AV_PKT_DATA_STRINGS_METADATA, &size); + return av_packet_unpack_dictionary(side_metadata, size, frame_md); +} + int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) { AVPacket *pkt = avctx->internal->pkt; @@ -772,6 +778,7 @@ memcpy(frame_sd->data, packet_sd, size); } } + add_metadata_from_side_data(pkt, frame); } else { frame->pkt_pts = AV_NOPTS_VALUE; av_frame_set_pkt_pos (frame, -1); @@ -892,8 +899,6 @@ ret = ff_decode_frame_props(avctx, frame); if (ret < 0) return ret; - if ((ret = ff_init_buffer_info(avctx, frame)) < 0) - return ret; if (hwaccel) { if (hwaccel->alloc_frame) { @@ -1176,6 +1181,13 @@ return AVERROR(ENOENT); } + if (hwa->capabilities & HWACCEL_CODEC_CAP_EXPERIMENTAL && + avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { + av_log(avctx, AV_LOG_WARNING, "Ignoring experimental hwaccel: %s\n", + hwa->name); + return AVERROR_PATCHWELCOME; + } + if (hwa->priv_data_size) { avctx->internal->hwaccel_priv_data = av_mallocz(hwa->priv_data_size); if (!avctx->internal->hwaccel_priv_data) @@ -1231,7 +1243,7 @@ if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) break; - if (avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) + if (avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) break; if (!setup_hwaccel(avctx, ret, desc->name)) @@ -1281,6 +1293,11 @@ MAKE_ACCESSORS(AVCodecContext, codec, int, seek_preroll) MAKE_ACCESSORS(AVCodecContext, codec, uint16_t*, chroma_intra_matrix) +unsigned av_codec_get_codec_properties(const AVCodecContext *codec) +{ + return codec->properties; +} + int av_codec_get_max_lowres(const AVCodec *codec) { return codec->max_lowres; @@ -1454,7 +1471,7 @@ avctx->frame_number = 0; avctx->codec_descriptor = avcodec_descriptor_get(avctx->codec_id); - if (avctx->codec->capabilities & CODEC_CAP_EXPERIMENTAL && + if ((avctx->codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) && avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { const char *codec_string = av_codec_is_encoder(codec) ? "encoder" : "decoder"; AVCodec *codec2; @@ -1463,7 +1480,7 @@ "add '-strict %d' if you want to use it.\n", codec_string, codec->name, FF_COMPLIANCE_EXPERIMENTAL); codec2 = av_codec_is_encoder(codec) ? avcodec_find_encoder(codec->id) : avcodec_find_decoder(codec->id); - if (!(codec2->capabilities & CODEC_CAP_EXPERIMENTAL)) + if (!(codec2->capabilities & AV_CODEC_CAP_EXPERIMENTAL)) av_log(avctx, AV_LOG_ERROR, "Alternatively use the non experimental %s '%s'.\n", codec_string, codec2->name); ret = AVERROR_EXPERIMENTAL; @@ -1494,7 +1511,7 @@ goto free_and_end; } } - if (!HAVE_THREADS && !(codec->capabilities & CODEC_CAP_AUTO_THREADS)) + if (!HAVE_THREADS && !(codec->capabilities & AV_CODEC_CAP_AUTO_THREADS)) avctx->thread_count = 1; if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) { @@ -1512,6 +1529,15 @@ if (av_codec_is_encoder(avctx->codec)) { int i; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame = av_frame_alloc(); + if (!avctx->coded_frame) { + ret = AVERROR(ENOMEM); + goto free_and_end; + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (avctx->codec->sample_fmts) { for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) { if (avctx->sample_fmt == avctx->codec->sample_fmts[i]) @@ -1564,6 +1590,12 @@ goto free_and_end; } } + if (avctx->sample_rate < 0) { + av_log(avctx, AV_LOG_ERROR, "Specified sample rate %d is not supported\n", + avctx->sample_rate); + ret = AVERROR(EINVAL); + goto free_and_end; + } if (avctx->codec->channel_layouts) { if (!avctx->channel_layout) { av_log(avctx, AV_LOG_WARNING, "Channel layout not specified\n"); @@ -1594,6 +1626,12 @@ } else if (avctx->channel_layout) { avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout); } + if (avctx->channels < 0) { + av_log(avctx, AV_LOG_ERROR, "Specified number of channels %d is not supported\n", + avctx->channels); + ret = AVERROR(EINVAL); + goto free_and_end; + } if(avctx->codec_type == AVMEDIA_TYPE_VIDEO) { if (avctx->width <= 0 || avctx->height <= 0) { av_log(avctx, AV_LOG_ERROR, "dimensions not set\n"); @@ -1615,7 +1653,7 @@ avctx->pts_correction_last_pts = avctx->pts_correction_last_dts = INT64_MIN; - if ( !CONFIG_GRAY && avctx->flags & CODEC_FLAG_GRAY + if ( !CONFIG_GRAY && avctx->flags & AV_CODEC_FLAG_GRAY && avctx->codec_descriptor->type == AVMEDIA_TYPE_VIDEO) av_log(avctx, AV_LOG_WARNING, "gray decoding requested but not enabled at configuration time\n"); @@ -1722,6 +1760,12 @@ av_opt_free(avctx->priv_data); av_opt_free(avctx); +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + av_frame_free(&avctx->coded_frame); +FF_ENABLE_DEPRECATION_WARNINGS +#endif + av_dict_free(&tmp); av_freep(&avctx->priv_data); if (avctx->internal) { @@ -1733,19 +1777,19 @@ goto end; } -int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size) +int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size) { if (avpkt->size < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid negative user packet size %d\n", avpkt->size); return AVERROR(EINVAL); } - if (size < 0 || size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { + if (size < 0 || size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) { av_log(avctx, AV_LOG_ERROR, "Invalid minimum required packet size %"PRId64" (max allowed is %d)\n", - size, INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE); + size, INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE); return AVERROR(EINVAL); } - if (avctx) { + if (avctx && 2*min_size < size) { // FIXME The factor needs to be finetuned av_assert0(!avpkt->data || avpkt->data != avctx->internal->byte_buffer); if (!avpkt->data || avpkt->size < size) { av_fast_padded_malloc(&avctx->internal->byte_buffer, &avctx->internal->byte_buffer_size, size); @@ -1791,7 +1835,7 @@ int ff_alloc_packet(AVPacket *avpkt, int size) { - return ff_alloc_packet2(NULL, avpkt, size); + return ff_alloc_packet2(NULL, avpkt, size, 0); } /** @@ -1847,7 +1891,7 @@ *got_packet_ptr = 0; - if (!(avctx->codec->capabilities & CODEC_CAP_DELAY) && !frame) { + if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) { av_free_packet(avpkt); av_init_packet(avpkt); return 0; @@ -1882,13 +1926,13 @@ /* check for valid frame size */ if (frame) { - if (avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) { + if (avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME) { if (frame->nb_samples > avctx->frame_size) { av_log(avctx, AV_LOG_ERROR, "more samples than frame size (avcodec_encode_audio2)\n"); ret = AVERROR(EINVAL); goto end; } - } else if (!(avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) { + } else if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) { if (frame->nb_samples < avctx->frame_size && !avctx->internal->last_audio_frame) { ret = pad_last_frame(avctx, &padded_frame, frame); @@ -1910,7 +1954,7 @@ ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr); if (!ret) { if (*got_packet_ptr) { - if (!(avctx->codec->capabilities & CODEC_CAP_DELAY)) { + if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) { if (avpkt->pts == AV_NOPTS_VALUE) avpkt->pts = frame->pts; if (!avpkt->duration) @@ -1948,7 +1992,7 @@ if (!ret) { if (needs_realloc && avpkt->data) { - ret = av_buffer_realloc(&avpkt->buf, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE); + ret = av_buffer_realloc(&avpkt->buf, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE); if (ret >= 0) avpkt->data = avpkt->buf->data; } @@ -2046,10 +2090,15 @@ got_packet = 0; ret = avcodec_encode_audio2(avctx, &pkt, frame, &got_packet); +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS if (!ret && got_packet && avctx->coded_frame) { avctx->coded_frame->pts = pkt.pts; avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY); } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + /* free any side data since we cannot return it */ av_packet_free_side_data(&pkt); @@ -2069,7 +2118,7 @@ AVPacket pkt; int ret, got_packet = 0; - if (buf_size < FF_MIN_BUFFER_SIZE) { + if (buf_size < AV_INPUT_BUFFER_MIN_SIZE) { av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n"); return -1; } @@ -2079,10 +2128,16 @@ pkt.size = buf_size; ret = avcodec_encode_video2(avctx, &pkt, pict, &got_packet); +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS if (!ret && got_packet && avctx->coded_frame) { avctx->coded_frame->pts = pkt.pts; avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY); + if (avctx->codec->capabilities & AV_CODEC_CAP_INTRA_ONLY) + avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif /* free any side data since we cannot return it */ if (pkt.side_data_elems > 0) { @@ -2113,10 +2168,10 @@ avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME)) return ff_thread_video_encode_frame(avctx, avpkt, frame, got_packet_ptr); - if ((avctx->flags&CODEC_FLAG_PASS1) && avctx->stats_out) + if ((avctx->flags&AV_CODEC_FLAG_PASS1) && avctx->stats_out) avctx->stats_out[0] = '\0'; - if (!(avctx->codec->capabilities & CODEC_CAP_DELAY) && !frame) { + if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) { av_free_packet(avpkt); av_init_packet(avpkt); avpkt->size = 0; @@ -2163,11 +2218,11 @@ if (!ret) { if (!*got_packet_ptr) avpkt->size = 0; - else if (!(avctx->codec->capabilities & CODEC_CAP_DELAY)) + else if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) avpkt->pts = avpkt->dts = frame->pts; if (needs_realloc && avpkt->data) { - ret = av_buffer_realloc(&avpkt->buf, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE); + ret = av_buffer_realloc(&avpkt->buf, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE); if (ret >= 0) avpkt->data = avpkt->buf->data; } @@ -2177,8 +2232,6 @@ if (ret < 0 || !*got_packet_ptr) av_free_packet(avpkt); - else - av_packet_merge_side_data(avpkt); emms_c(); return ret; @@ -2239,12 +2292,13 @@ int size = 0, ret; const uint8_t *data; uint32_t flags; + int64_t val; data = av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, &size); if (!data) return 0; - if (!(avctx->codec->capabilities & CODEC_CAP_PARAM_CHANGE)) { + if (!(avctx->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE)) { av_log(avctx, AV_LOG_ERROR, "This decoder does not support parameter " "changes, but PARAM_CHANGE side data was sent to it.\n"); return AVERROR(EINVAL); @@ -2259,7 +2313,12 @@ if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) { if (size < 4) goto fail; - avctx->channels = bytestream_get_le32(&data); + val = bytestream_get_le32(&data); + if (val <= 0 || val > INT_MAX) { + av_log(avctx, AV_LOG_ERROR, "Invalid channel count"); + return AVERROR_INVALIDDATA; + } + avctx->channels = val; size -= 4; } if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) { @@ -2271,7 +2330,12 @@ if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) { if (size < 4) goto fail; - avctx->sample_rate = bytestream_get_le32(&data); + val = bytestream_get_le32(&data); + if (val <= 0 || val > INT_MAX) { + av_log(avctx, AV_LOG_ERROR, "Invalid sample rate"); + return AVERROR_INVALIDDATA; + } + avctx->sample_rate = val; size -= 4; } if (flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) { @@ -2291,18 +2355,6 @@ return AVERROR_INVALIDDATA; } -static int add_metadata_from_side_data(AVCodecContext *avctx, AVFrame *frame) -{ - int size; - const uint8_t *side_metadata; - - AVDictionary **frame_md = avpriv_frame_get_metadatap(frame); - - side_metadata = av_packet_get_side_data(avctx->internal->pkt, - AV_PKT_DATA_STRINGS_METADATA, &size); - return av_packet_unpack_dictionary(side_metadata, size, frame_md); -} - static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame) { int ret; @@ -2371,7 +2423,8 @@ av_frame_unref(picture); - if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) { + if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size || + (avctx->active_thread_type & FF_THREAD_FRAME)) { int did_split = av_packet_split_side_data(&tmp); ret = apply_param_change(avctx, &tmp); if (ret < 0) { @@ -2394,14 +2447,13 @@ } //FIXME these should be under if(!avctx->has_b_frames) /* get_buffer is supposed to set frame parameters */ - if (!(avctx->codec->capabilities & CODEC_CAP_DR1)) { + if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) { if (!picture->sample_aspect_ratio.num) picture->sample_aspect_ratio = avctx->sample_aspect_ratio; if (!picture->width) picture->width = avctx->width; if (!picture->height) picture->height = avctx->height; if (picture->format == AV_PIX_FMT_NONE) picture->format = avctx->pix_fmt; } } - add_metadata_from_side_data(avctx, picture); fail: emms_c(); //needed to avoid an emms_c() call before every return; @@ -2452,6 +2504,8 @@ if (!frame) return AVERROR(ENOMEM); +#if FF_API_GET_BUFFER +FF_DISABLE_DEPRECATION_WARNINGS if (avctx->get_buffer != avcodec_default_get_buffer) { av_log(avctx, AV_LOG_ERROR, "Custom get_buffer() for use with" "avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n"); @@ -2460,6 +2514,8 @@ avctx->get_buffer = avcodec_default_get_buffer; avctx->release_buffer = avcodec_default_release_buffer; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif ret = avcodec_decode_audio4(avctx, frame, &got_frame, avpkt); @@ -2518,7 +2574,7 @@ av_frame_unref(frame); - if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) { + if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) { uint8_t *side; int side_size; uint32_t discard_padding = 0; @@ -2543,7 +2599,6 @@ frame->pkt_dts = avpkt->dts; } if (ret >= 0 && *got_frame_ptr) { - add_metadata_from_side_data(avctx, frame); avctx->frame_number++; av_frame_set_best_effort_timestamp(frame, guess_correct_pts(avctx, @@ -2569,7 +2624,7 @@ discard_reason = AV_RL8(side + 9); } if (avctx->internal->skip_samples && *got_frame_ptr && - !(avctx->flags2 & CODEC_FLAG2_SKIP_MANUAL)) { + !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) { if(frame->nb_samples <= avctx->internal->skip_samples){ *got_frame_ptr = 0; avctx->internal->skip_samples -= frame->nb_samples; @@ -2599,7 +2654,7 @@ } if (discard_padding > 0 && discard_padding <= frame->nb_samples && *got_frame_ptr && - !(avctx->flags2 & CODEC_FLAG2_SKIP_MANUAL)) { + !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) { if (discard_padding == frame->nb_samples) { *got_frame_ptr = 0; } else { @@ -2618,7 +2673,7 @@ } } - if ((avctx->flags2 & CODEC_FLAG2_SKIP_MANUAL) && *got_frame_ptr) { + if ((avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL) && *got_frame_ptr) { AVFrameSideData *fside = av_frame_new_side_data(frame, AV_FRAME_DATA_SKIP_SAMPLES, 10); if (fside) { AV_WL32(fside->data, avctx->internal->skip_samples); @@ -2671,7 +2726,7 @@ inb = inpkt->data; inl = inpkt->size; - if (inl >= INT_MAX / UTF8_MAX_BYTES - FF_INPUT_BUFFER_PADDING_SIZE) { + if (inl >= INT_MAX / UTF8_MAX_BYTES - AV_INPUT_BUFFER_PADDING_SIZE) { av_log(avctx, AV_LOG_ERROR, "Subtitles packet is too big for recoding\n"); ret = AVERROR(ENOMEM); goto end; @@ -2747,7 +2802,7 @@ *got_sub_ptr = 0; get_subtitle_defaults(sub); - if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) { + if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size) { AVPacket pkt_recoded; AVPacket tmp = *avpkt; int did_split = av_packet_split_side_data(&tmp); @@ -2760,7 +2815,7 @@ * remaining bytes should have already been filled with zeros by the * original packet allocation anyway. */ memset(tmp.data + tmp.size, 0, - FFMIN(avpkt->size - tmp.size, FF_INPUT_BUFFER_PADDING_SIZE)); + FFMIN(avpkt->size - tmp.size, AV_INPUT_BUFFER_PADDING_SIZE)); } pkt_recoded = tmp; @@ -2856,7 +2911,6 @@ ff_thread_free(avctx); if (avctx->codec && avctx->codec->close) avctx->codec->close(avctx); - avctx->coded_frame = NULL; avctx->internal->byte_buffer_size = 0; av_freep(&avctx->internal->byte_buffer); av_frame_free(&avctx->internal->to_free); @@ -2875,8 +2929,14 @@ av_opt_free(avctx->priv_data); av_opt_free(avctx); av_freep(&avctx->priv_data); - if (av_codec_is_encoder(avctx->codec)) + if (av_codec_is_encoder(avctx->codec)) { av_freep(&avctx->extradata); +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + av_frame_free(&avctx->coded_frame); +FF_ENABLE_DEPRECATION_WARNINGS +#endif + } avctx->codec = NULL; avctx->active_thread_type = 0; @@ -2893,6 +2953,7 @@ case AV_CODEC_ID_OPUS_DEPRECATED : return AV_CODEC_ID_OPUS; case AV_CODEC_ID_TAK_DEPRECATED : return AV_CODEC_ID_TAK; case AV_CODEC_ID_PAF_AUDIO_DEPRECATED : return AV_CODEC_ID_PAF_AUDIO; + case AV_CODEC_ID_PCM_S16BE_PLANAR_DEPRECATED : return AV_CODEC_ID_PCM_S16BE_PLANAR; case AV_CODEC_ID_PCM_S24LE_PLANAR_DEPRECATED : return AV_CODEC_ID_PCM_S24LE_PLANAR; case AV_CODEC_ID_PCM_S32LE_PLANAR_DEPRECATED : return AV_CODEC_ID_PCM_S32LE_PLANAR; case AV_CODEC_ID_ADPCM_VIMA_DEPRECATED : return AV_CODEC_ID_ADPCM_VIMA; @@ -2919,7 +2980,7 @@ while (p) { if ((encoder ? av_codec_is_encoder(p) : av_codec_is_decoder(p)) && p->id == id) { - if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) { + if (p->capabilities & AV_CODEC_CAP_EXPERIMENTAL && !experimental) { experimental = p; } else return p; @@ -3131,6 +3192,13 @@ if (encode) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", q=%d-%d", enc->qmin, enc->qmax); + } else { + if (enc->properties & FF_CODEC_PROPERTY_CLOSED_CAPTIONS) + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ", Closed Captions"); + if (enc->properties & FF_CODEC_PROPERTY_LOSSLESS) + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ", lossless"); } break; case AVMEDIA_TYPE_AUDIO: @@ -3168,10 +3236,10 @@ return; } if (encode) { - if (enc->flags & CODEC_FLAG_PASS1) + if (enc->flags & AV_CODEC_FLAG_PASS1) snprintf(buf + strlen(buf), buf_size - strlen(buf), ", pass 1"); - if (enc->flags & CODEC_FLAG_PASS2) + if (enc->flags & AV_CODEC_FLAG_PASS2) snprintf(buf + strlen(buf), buf_size - strlen(buf), ", pass 2"); } @@ -3430,6 +3498,11 @@ return (frame_bytes - 4) * 2 / ch; case AV_CODEC_ID_ADPCM_IMA_AMV: return (frame_bytes - 8) * 2 / ch; + case AV_CODEC_ID_ADPCM_THP: + case AV_CODEC_ID_ADPCM_THP_LE: + if (avctx->extradata) + return frame_bytes * 14 / (8 * ch); + break; case AV_CODEC_ID_ADPCM_XA: return (frame_bytes / 128) * 224 / ch; case AV_CODEC_ID_INTERPLAY_DPCM: @@ -3798,7 +3871,7 @@ /* Note: the string is NUL terminated (so extradata can be read as a * string), but the ending character is not accounted in the size (in * binary formats you are likely not supposed to mux that character). When - * extradata is copied, it is also padded with FF_INPUT_BUFFER_PADDING_SIZE + * extradata is copied, it is also padded with AV_INPUT_BUFFER_PADDING_SIZE * zeros. */ avctx->extradata_size = buf->len; return 0; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/utvideodec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/utvideodec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/utvideodec.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/utvideodec.c 2015-07-28 17:20:07.000000000 +0000 @@ -143,7 +143,7 @@ memcpy(c->slice_bits, src + slice_data_start + c->slices * 4, slice_size); - memset(c->slice_bits + slice_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(c->slice_bits + slice_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); c->bdsp.bswap_buf((uint32_t *) c->slice_bits, (uint32_t *) c->slice_bits, (slice_data_end - slice_data_start + 3) >> 2); @@ -385,7 +385,7 @@ } av_fast_malloc(&c->slice_bits, &c->slice_bits_size, - max_slice_size + FF_INPUT_BUFFER_PADDING_SIZE); + max_slice_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!c->slice_bits) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); @@ -559,5 +559,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/utvideoenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/utvideoenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/utvideoenc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/utvideoenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -48,7 +48,6 @@ UtvideoContext *c = avctx->priv_data; int i; - av_frame_free(&avctx->coded_frame); av_freep(&c->slice_bits); for (i = 0; i < 4; i++) av_freep(&c->slice_buffer[i]); @@ -154,19 +153,11 @@ return AVERROR(EINVAL); } - avctx->coded_frame = av_frame_alloc(); - - if (!avctx->coded_frame) { - av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n"); - utvideo_encode_close(avctx); - return AVERROR(ENOMEM); - } - /* extradata size is 4 * 32bit */ avctx->extradata_size = 16; avctx->extradata = av_mallocz(avctx->extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { av_log(avctx, AV_LOG_ERROR, "Could not allocate extradata.\n"); @@ -176,7 +167,7 @@ for (i = 0; i < c->planes; i++) { c->slice_buffer[i] = av_malloc(c->slice_stride * (avctx->height + 2) + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!c->slice_buffer[i]) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 1.\n"); utvideo_encode_close(avctx); @@ -545,7 +536,7 @@ /* Allocate a new packet if needed, and set it to the pointer dst */ ret = ff_alloc_packet2(avctx, pkt, (256 + 4 * c->slices + width * height) * - c->planes + 4); + c->planes + 4, 0); if (ret < 0) return ret; @@ -622,8 +613,12 @@ * At least currently Ut Video is IDR only. * Set flags accordingly. */ +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->key_frame = 1; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; +FF_ENABLE_DEPRECATION_WARNINGS +#endif pkt->size = bytestream2_tell_p(&pb); pkt->flags |= AV_PKT_FLAG_KEY; @@ -643,7 +638,7 @@ .init = utvideo_encode_init, .encode2 = utvideo_encode_frame, .close = utvideo_encode_close, - .capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY, + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/v210dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/v210dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/v210dec.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/v210dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -180,6 +180,6 @@ .priv_data_size = sizeof(V210DecContext), .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .priv_class = &v210dec_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/v210enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/v210enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/v210enc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/v210enc.c 2015-08-03 17:20:02.000000000 +0000 @@ -91,11 +91,11 @@ return AVERROR(EINVAL); } - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; +FF_ENABLE_DEPRECATION_WARNINGS +#endif s->pack_line_8 = v210_planar_pack_8_c; s->pack_line_10 = v210_planar_pack_10_c; @@ -116,7 +116,7 @@ int h, w, ret; uint8_t *dst; - ret = ff_alloc_packet(pkt, avctx->height * stride); + ret = ff_alloc_packet2(avctx, pkt, avctx->height * stride, avctx->height * stride); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); return ret; @@ -213,13 +213,6 @@ return 0; } -static av_cold int encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - - return 0; -} - AVCodec ff_v210_encoder = { .name = "v210", .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), @@ -228,6 +221,5 @@ .priv_data_size = sizeof(V210EncContext), .init = encode_init, .encode2 = encode_frame, - .close = encode_close, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/v210x.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/v210x.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/v210x.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/v210x.c 2015-07-28 17:20:07.000000000 +0000 @@ -127,5 +127,5 @@ .id = AV_CODEC_ID_V210X, .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/v308dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/v308dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/v308dec.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/v308dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -79,5 +79,5 @@ .id = AV_CODEC_ID_V308, .init = v308_decode_init, .decode = v308_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/v308enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/v308enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/v308enc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/v308enc.c 2015-07-30 17:20:02.000000000 +0000 @@ -31,13 +31,6 @@ return AVERROR_INVALIDDATA; } - avctx->coded_frame = av_frame_alloc(); - - if (!avctx->coded_frame) { - av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n"); - return AVERROR(ENOMEM); - } - return 0; } @@ -48,13 +41,10 @@ uint8_t *y, *u, *v; int i, j, ret; - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 3)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 3, 0)) < 0) return ret; dst = pkt->data; - avctx->coded_frame->key_frame = 1; - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; - y = pic->data[0]; u = pic->data[1]; v = pic->data[2]; @@ -77,8 +67,6 @@ static av_cold int v308_encode_close(AVCodecContext *avctx) { - av_frame_free(&avctx->coded_frame); - return 0; } @@ -91,4 +79,5 @@ .encode2 = v308_encode_frame, .close = v308_encode_close, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE }, + .capabilities = AV_CODEC_CAP_INTRA_ONLY, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/v408dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/v408dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/v408dec.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/v408dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -87,7 +87,7 @@ .id = AV_CODEC_ID_AYUV, .init = v408_decode_init, .decode = v408_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif #if CONFIG_V408_DECODER @@ -98,6 +98,6 @@ .id = AV_CODEC_ID_V408, .init = v408_decode_init, .decode = v408_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/v408enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/v408enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/v408enc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/v408enc.c 2015-07-30 17:20:02.000000000 +0000 @@ -26,12 +26,6 @@ static av_cold int v408_encode_init(AVCodecContext *avctx) { - avctx->coded_frame = av_frame_alloc(); - - if (!avctx->coded_frame) { - av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n"); - return AVERROR(ENOMEM); - } return 0; } @@ -43,13 +37,10 @@ uint8_t *y, *u, *v, *a; int i, j, ret; - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 4)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 4, 0)) < 0) return ret; dst = pkt->data; - avctx->coded_frame->key_frame = 1; - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; - y = pic->data[0]; u = pic->data[1]; v = pic->data[2]; @@ -82,8 +73,6 @@ static av_cold int v408_encode_close(AVCodecContext *avctx) { - av_frame_free(&avctx->coded_frame); - return 0; } @@ -97,6 +86,7 @@ .encode2 = v408_encode_frame, .close = v408_encode_close, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVA444P, AV_PIX_FMT_NONE }, + .capabilities = AV_CODEC_CAP_INTRA_ONLY, }; #endif #if CONFIG_V408_ENCODER @@ -109,5 +99,6 @@ .encode2 = v408_encode_frame, .close = v408_encode_close, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVA444P, AV_PIX_FMT_NONE }, + .capabilities = AV_CODEC_CAP_INTRA_ONLY, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/v410dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/v410dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/v410dec.c 2015-06-18 18:55:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/v410dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -94,5 +94,5 @@ .id = AV_CODEC_ID_V410, .init = v410_decode_init, .decode = v410_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/v410enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/v410enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/v410enc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/v410enc.c 2015-07-28 17:20:07.000000000 +0000 @@ -32,13 +32,6 @@ return AVERROR_INVALIDDATA; } - avctx->coded_frame = av_frame_alloc(); - - if (!avctx->coded_frame) { - av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n"); - return AVERROR(ENOMEM); - } - return 0; } @@ -50,12 +43,17 @@ uint32_t val; int i, j, ret; - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 4)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 4, + avctx->width * avctx->height * 4)) < 0) return ret; dst = pkt->data; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->key_frame = 1; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; +FF_ENABLE_DEPRECATION_WARNINGS +#endif y = (uint16_t *)pic->data[0]; u = (uint16_t *)pic->data[1]; @@ -79,13 +77,6 @@ return 0; } -static av_cold int v410_encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - - return 0; -} - AVCodec ff_v410_encoder = { .name = "v410", .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"), @@ -93,6 +84,5 @@ .id = AV_CODEC_ID_V410, .init = v410_encode_init, .encode2 = v410_encode_frame, - .close = v410_encode_close, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P10, AV_PIX_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vaapi_h264.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vaapi_h264.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vaapi_h264.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vaapi_h264.c 2015-06-23 17:20:03.000000000 +0000 @@ -162,7 +162,8 @@ unsigned int i, n = 0; for (i = 0; i < ref_count; i++) if (ref_list[i].reference) - fill_vaapi_pic(&RefPicList[n++], ref_list[i].parent, 0); + fill_vaapi_pic(&RefPicList[n++], ref_list[i].parent, + ref_list[i].reference); for (; n < 32; n++) init_vaapi_pic(&RefPicList[n]); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vb.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vb.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vb.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vb.c 2015-07-28 17:20:07.000000000 +0000 @@ -279,5 +279,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vble.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vble.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vble.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vble.c 2015-07-28 17:20:07.000000000 +0000 @@ -155,7 +155,7 @@ vble_restore_plane(ctx, pic, &gb, 0, offset, avctx->width, avctx->height); /* Chroma */ - if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) { + if (!(ctx->avctx->flags & AV_CODEC_FLAG_GRAY)) { offset += avctx->width * avctx->height; vble_restore_plane(ctx, pic, &gb, 1, offset, width_uv, height_uv); @@ -210,5 +210,5 @@ .init = vble_decode_init, .close = vble_decode_close, .decode = vble_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vc1_block.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vc1_block.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vc1_block.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vc1_block.c 2015-07-28 17:20:07.000000000 +0000 @@ -99,7 +99,7 @@ s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][3], s->dest[0] - v_dist * s->linesize - 8, stride_y); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][4], s->dest[1] - 8 * s->uvlinesize - 8, s->uvlinesize); @@ -126,7 +126,7 @@ s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][3], s->dest[0] - v_dist * s->linesize + 8, stride_y); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][4], s->dest[1] - 8 * s->uvlinesize, s->uvlinesize); @@ -1327,7 +1327,7 @@ vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i & 4) ? v->codingset2 : v->codingset); - if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & CODEC_FLAG_GRAY)) + if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY)) continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); if (v->rangeredfrm) @@ -1348,7 +1348,7 @@ } else if (val) { pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize, - CONFIG_GRAY && (i & 4) && (s->avctx->flags & CODEC_FLAG_GRAY), &block_tt); + CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt); block_cbp |= pat << (i << 2); if (!v->ttmbf && ttmb < 8) ttmb = -1; @@ -1438,7 +1438,7 @@ vc1_decode_intra_block(v, s->block[i], i, is_coded[i], mquant, (i & 4) ? v->codingset2 : v->codingset); - if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & CODEC_FLAG_GRAY)) + if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY)) continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); if (v->rangeredfrm) @@ -1460,7 +1460,7 @@ pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize, - CONFIG_GRAY && (i & 4) && (s->avctx->flags & CODEC_FLAG_GRAY), + CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt); block_cbp |= pat << (i << 2); if (!v->ttmbf && ttmb < 8) @@ -1586,7 +1586,7 @@ vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i & 4) ? v->codingset2 : v->codingset); - if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & CODEC_FLAG_GRAY)) + if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY)) continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); if (i < 4) { @@ -1673,7 +1673,7 @@ pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : (s->linesize << fieldtx), - CONFIG_GRAY && (i & 4) && (s->avctx->flags & CODEC_FLAG_GRAY), &block_tt); + CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt); block_cbp |= pat << (i << 2); if (!v->ttmbf && ttmb < 8) ttmb = -1; @@ -1752,7 +1752,7 @@ vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i & 4) ? v->codingset2 : v->codingset); - if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & CODEC_FLAG_GRAY)) + if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY)) continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); @@ -1806,7 +1806,7 @@ pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize, - CONFIG_GRAY && (i & 4) && (s->avctx->flags & CODEC_FLAG_GRAY), + CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt); block_cbp |= pat << (i << 2); if (!v->ttmbf && ttmb < 8) @@ -1953,7 +1953,7 @@ vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i & 4) ? v->codingset2 : v->codingset); - if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & CODEC_FLAG_GRAY)) + if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY)) continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); if (v->rangeredfrm) @@ -1967,7 +1967,7 @@ vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize, - CONFIG_GRAY && (i & 4) && (s->avctx->flags & CODEC_FLAG_GRAY), NULL); + CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), NULL); if (!v->ttmbf && ttmb < 8) ttmb = -1; first_block = 0; @@ -2028,7 +2028,7 @@ vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i & 4) ? v->codingset2 : v->codingset); - if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & CODEC_FLAG_GRAY)) + if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY)) continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); if (v->rangeredfrm) @@ -2126,7 +2126,7 @@ vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize, - CONFIG_GRAY && (i & 4) && (s->avctx->flags & CODEC_FLAG_GRAY), NULL); + CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), NULL); if (!v->ttmbf && ttmb < 8) ttmb = -1; first_block = 0; @@ -2251,7 +2251,7 @@ vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i & 4) ? v->codingset2 : v->codingset); - if (CONFIG_GRAY && i > 3 && (s->avctx->flags & CODEC_FLAG_GRAY)) + if (CONFIG_GRAY && i > 3 && (s->avctx->flags & AV_CODEC_FLAG_GRAY)) continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); if (i < 4) { @@ -2417,7 +2417,7 @@ pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : (s->linesize << fieldtx), - CONFIG_GRAY && (i & 4) && (s->avctx->flags & CODEC_FLAG_GRAY), &block_tt); + CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt); block_cbp |= pat << (i << 2); if (!v->ttmbf && ttmb < 8) ttmb = -1; @@ -2560,7 +2560,7 @@ vc1_decode_i_block(v, s->block[k], k, val, (k < 4) ? v->codingset : v->codingset2); - if (CONFIG_GRAY && k > 3 && (s->avctx->flags & CODEC_FLAG_GRAY)) + if (CONFIG_GRAY && k > 3 && (s->avctx->flags & AV_CODEC_FLAG_GRAY)) continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[k]); if (v->pq >= 9 && v->overlap) { @@ -2584,7 +2584,7 @@ if (s->mb_x) { v->vc1dsp.vc1_h_overlap(s->dest[0], s->linesize); v->vc1dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { v->vc1dsp.vc1_h_overlap(s->dest[1], s->uvlinesize); v->vc1dsp.vc1_h_overlap(s->dest[2], s->uvlinesize); } @@ -2594,7 +2594,7 @@ if (!s->first_slice_line) { v->vc1dsp.vc1_v_overlap(s->dest[0], s->linesize); v->vc1dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { v->vc1dsp.vc1_v_overlap(s->dest[1], s->uvlinesize); v->vc1dsp.vc1_v_overlap(s->dest[2], s->uvlinesize); } @@ -2723,7 +2723,7 @@ vc1_decode_i_block_adv(v, block[k], k, val, (k < 4) ? v->codingset : v->codingset2, mquant); - if (CONFIG_GRAY && k > 3 && (s->avctx->flags & CODEC_FLAG_GRAY)) + if (CONFIG_GRAY && k > 3 && (s->avctx->flags & AV_CODEC_FLAG_GRAY)) continue; v->vc1dsp.vc1_inv_trans_8x8(block[k]); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vc1dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vc1dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vc1dec.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vc1dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -191,7 +191,7 @@ } alpha = av_clip_uint16(sd->coefs[1][6]); - for (plane = 0; plane < (CONFIG_GRAY && s->avctx->flags & CODEC_FLAG_GRAY ? 1 : 3); plane++) { + for (plane = 0; plane < (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY ? 1 : 3); plane++) { int width = v->output_width>>!!plane; for (row = 0; row < v->output_height>>!!plane; row++) { @@ -312,7 +312,7 @@ wrong but it looks better than doing nothing. */ if (f && f->data[0]) - for (plane = 0; plane < (CONFIG_GRAY && s->avctx->flags & CODEC_FLAG_GRAY ? 1 : 3); plane++) + for (plane = 0; plane < (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY ? 1 : 3); plane++) for (i = 0; i < v->sprite_height>>!!plane; i++) memset(f->data[plane] + i * f->linesize[plane], plane ? 128 : 0, f->linesize[plane]); @@ -428,7 +428,7 @@ if (!avctx->extradata_size || !avctx->extradata) return -1; - if (!CONFIG_GRAY || !(avctx->flags & CODEC_FLAG_GRAY)) + if (!CONFIG_GRAY || !(avctx->flags & AV_CODEC_FLAG_GRAY)) avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts); else { avctx->pix_fmt = AV_PIX_FMT_GRAY8; @@ -469,7 +469,7 @@ count = avctx->extradata_size*8 - get_bits_count(&gb); if (count > 0) { av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n", - count, get_bits(&gb, count)); + count, get_bits_long(&gb, FFMIN(count, 32))); } else if (count < 0) { av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count); } @@ -486,7 +486,7 @@ return -1; } - buf2 = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + buf2 = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!buf2) return AVERROR(ENOMEM); @@ -630,7 +630,7 @@ v->second_field = 0; - if(s->avctx->flags & CODEC_FLAG_LOW_DELAY) + if(s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) s->low_delay = 1; /* no supplementary picture */ @@ -647,7 +647,7 @@ return buf_size; } - if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) { + if (s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) { if (v->profile < PROFILE_ADVANCED) avctx->pix_fmt = AV_PIX_FMT_VDPAU_WMV3; else @@ -657,7 +657,7 @@ //for advanced profile we may need to parse and unescape data if (avctx->codec_id == AV_CODEC_ID_VC1 || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) { int buf_size2 = 0; - buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + buf2 = av_mallocz(buf_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!buf2) return AVERROR(ENOMEM); @@ -673,20 +673,20 @@ switch (AV_RB32(start)) { case VC1_CODE_FRAME: if (avctx->hwaccel || - s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) + s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) buf_start = start; buf_size2 = vc1_unescape_buffer(start + 4, size, buf2); break; case VC1_CODE_FIELD: { int buf_size3; if (avctx->hwaccel || - s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) + s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) buf_start_second_field = start; tmp = av_realloc_array(slices, sizeof(*slices), (n_slices+1)); if (!tmp) goto err; slices = tmp; - slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + slices[n_slices].buf = av_mallocz(buf_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!slices[n_slices].buf) goto err; buf_size3 = vc1_unescape_buffer(start + 4, size, @@ -711,7 +711,7 @@ if (!tmp) goto err; slices = tmp; - slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + slices[n_slices].buf = av_mallocz(buf_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!slices[n_slices].buf) goto err; buf_size3 = vc1_unescape_buffer(start + 4, size, @@ -734,13 +734,13 @@ goto err; } else { // found field marker, unescape second field if (avctx->hwaccel || - s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) + s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) buf_start_second_field = divider; tmp = av_realloc_array(slices, sizeof(*slices), (n_slices+1)); if (!tmp) goto err; slices = tmp; - slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + slices[n_slices].buf = av_mallocz(buf_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!slices[n_slices].buf) goto err; buf_size3 = vc1_unescape_buffer(divider + 4, buf + buf_size - divider - 4, slices[n_slices].buf); @@ -874,7 +874,7 @@ s->me.qpel_avg = s->qdsp.avg_qpel_pixels_tab; if ((CONFIG_VC1_VDPAU_DECODER) - &&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) { + &&s->avctx->codec->capabilities&AV_CODEC_CAP_HWACCEL_VDPAU) { if (v->field_mode && buf_start_second_field) { ff_vdpau_vc1_decode_picture(s, buf_start, buf_start_second_field - buf_start); ff_vdpau_vc1_decode_picture(s, buf_start_second_field, (buf + buf_size) - buf_start_second_field); @@ -1098,7 +1098,7 @@ .close = ff_vc1_decode_end, .decode = vc1_decode_frame, .flush = ff_mpeg_flush, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .pix_fmts = vc1_hwaccel_pixfmt_list_420, .profiles = NULL_IF_CONFIG_SMALL(profiles) }; @@ -1114,7 +1114,7 @@ .close = ff_vc1_decode_end, .decode = vc1_decode_frame, .flush = ff_mpeg_flush, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .pix_fmts = vc1_hwaccel_pixfmt_list_420, .profiles = NULL_IF_CONFIG_SMALL(profiles) }; @@ -1130,7 +1130,7 @@ .init = vc1_decode_init, .close = ff_vc1_decode_end, .decode = vc1_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HWACCEL_VDPAU, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_VDPAU_WMV3, AV_PIX_FMT_NONE }, .profiles = NULL_IF_CONFIG_SMALL(profiles) }; @@ -1146,7 +1146,7 @@ .init = vc1_decode_init, .close = ff_vc1_decode_end, .decode = vc1_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HWACCEL_VDPAU, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_VDPAU_VC1, AV_PIX_FMT_NONE }, .profiles = NULL_IF_CONFIG_SMALL(profiles) }; @@ -1162,7 +1162,7 @@ .init = vc1_decode_init, .close = ff_vc1_decode_end, .decode = vc1_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = vc1_sprite_flush, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, @@ -1181,7 +1181,7 @@ .init = vc1_decode_init, .close = ff_vc1_decode_end, .decode = vc1_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = vc1_sprite_flush, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vc1_loopfilter.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vc1_loopfilter.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vc1_loopfilter.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vc1_loopfilter.c 2015-07-28 17:20:07.000000000 +0000 @@ -40,7 +40,7 @@ if (s->mb_x) v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize, s->linesize, pq); v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize + 8, s->linesize, pq); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) for (j = 0; j < 2; j++) { v->vc1dsp.vc1_v_loop_filter8(s->dest[j + 1], s->uvlinesize, pq); if (s->mb_x) @@ -52,7 +52,7 @@ if (s->mb_y == s->end_mb_y - 1) { if (s->mb_x) { v->vc1dsp.vc1_h_loop_filter16(s->dest[0], s->linesize, pq); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { v->vc1dsp.vc1_h_loop_filter8(s->dest[1], s->uvlinesize, pq); v->vc1dsp.vc1_h_loop_filter8(s->dest[2], s->uvlinesize, pq); } @@ -76,7 +76,7 @@ if (s->mb_x >= 2) v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize - 16, s->linesize, pq); v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize - 8, s->linesize, pq); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) for (j = 0; j < 2; j++) { v->vc1dsp.vc1_v_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize - 8, s->uvlinesize, pq); if (s->mb_x >= 2) { @@ -94,7 +94,7 @@ if (s->mb_x) v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize, s->linesize, pq); v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize + 8, s->linesize, pq); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) for (j = 0; j < 2; j++) { v->vc1dsp.vc1_v_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize, s->uvlinesize, pq); if (s->mb_x >= 2) { @@ -110,7 +110,7 @@ if (s->mb_x >= 2) v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize - 16, s->linesize, pq); v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize - 8, s->linesize, pq); - if (s->mb_x >= 2 && (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY))) { + if (s->mb_x >= 2 && (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY))) { for (j = 0; j < 2; j++) { v->vc1dsp.vc1_h_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize - 8, s->uvlinesize, pq); } @@ -121,7 +121,7 @@ if (s->mb_x) v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize, s->linesize, pq); v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize + 8, s->linesize, pq); - if (s->mb_x && (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY))) { + if (s->mb_x && (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY))) { for (j = 0; j < 2; j++) { v->vc1dsp.vc1_h_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize, s->uvlinesize, pq); } @@ -155,7 +155,7 @@ v->block[v->cur_blk_idx][0]); v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][3], v->block[v->cur_blk_idx][2]); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][4], v->block[v->cur_blk_idx][4]); v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][5], @@ -174,7 +174,7 @@ v->block[v->cur_blk_idx][0]); v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][3], v->block[v->cur_blk_idx][1]); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][4], v->block[v->cur_blk_idx][4]); v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][5], @@ -194,7 +194,7 @@ v->block[v->left_blk_idx][0]); v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][3], v->block[v->left_blk_idx][1]); - if (!CONFIG_GRAY || !(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][4], v->block[v->left_blk_idx][4]); v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][5], @@ -336,7 +336,7 @@ { MpegEncContext *s = &v->s; int i; - int block_count = CONFIG_GRAY && (s->avctx->flags & CODEC_FLAG_GRAY) ? 4 : 6; + int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6; for (i = 0; i < block_count; i++) { vc1_apply_p_v_loop_filter(v, i); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vc1_mc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vc1_mc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vc1_mc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vc1_mc.c 2015-07-28 17:20:07.000000000 +0000 @@ -270,7 +270,7 @@ } /* for grayscale we should not try to read from unknown area */ - if (CONFIG_GRAY && s->avctx->flags & CODEC_FLAG_GRAY) { + if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) { srcU = s->sc.edge_emu_buffer + 18 * s->linesize; srcV = s->sc.edge_emu_buffer + 18 * s->linesize; } @@ -332,7 +332,7 @@ s->hdsp.put_no_rnd_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16); } - if (CONFIG_GRAY && s->avctx->flags & CODEC_FLAG_GRAY) + if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) return; /* Chroma MC always uses qpel bilinear */ uvmx = (uvmx & 3) << 1; @@ -518,7 +518,7 @@ if (!v->field_mode && !v->s.last_picture.f->data[0]) return; - if (CONFIG_GRAY && s->avctx->flags & CODEC_FLAG_GRAY) + if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) return; /* calculate chroma MV vector from four luma MVs */ @@ -655,7 +655,7 @@ int use_ic; uint8_t (*lutuv)[256]; - if (CONFIG_GRAY && s->avctx->flags & CODEC_FLAG_GRAY) + if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) return; for (i = 0; i < 4; i++) { @@ -801,7 +801,7 @@ } /* for grayscale we should not try to read from unknown area */ - if (CONFIG_GRAY && s->avctx->flags & CODEC_FLAG_GRAY) { + if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) { srcU = s->sc.edge_emu_buffer + 18 * s->linesize; srcV = s->sc.edge_emu_buffer + 18 * s->linesize; } @@ -865,7 +865,7 @@ s->hdsp.avg_no_rnd_pixels_tab[dxy](s->dest[0], srcY, s->linesize, 16); } - if (CONFIG_GRAY && s->avctx->flags & CODEC_FLAG_GRAY) + if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) return; /* Chroma MC always uses qpel blilinear */ uvmx = (uvmx & 3) << 1; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vcr1.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vcr1.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vcr1.c 2015-06-18 18:55:01.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vcr1.c 2015-07-28 17:20:07.000000000 +0000 @@ -129,5 +129,5 @@ .priv_data_size = sizeof(VCR1Context), .init = vcr1_decode_init, .decode = vcr1_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vda.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vda.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vda.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vda.c 2015-08-03 17:20:02.000000000 +0000 @@ -21,7 +21,7 @@ #include "libavutil/mem.h" #include "vda.h" -#include "vda_internal.h" +#include "vda_vt_internal.h" #if CONFIG_H264_VDA_HWACCEL AVVDAContext *av_vda_alloc_context(void) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vda_h264.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vda_h264.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vda_h264.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vda_h264.c 2015-08-03 17:20:02.000000000 +0000 @@ -32,20 +32,7 @@ CVPixelBufferRef cv_buffer; }; #include "internal.h" -#include "vda_internal.h" - -typedef struct VDAContext { - // The current bitstream buffer. - uint8_t *bitstream; - - // The current size of the bitstream. - int bitstream_size; - - // The reference size used for fast reallocation. - int allocated_size; - - CVImageBufferRef frame; -} VDAContext; +#include "vda_vt_internal.h" /* Decoder callback that adds the vda frame to the queue in display order. */ static void vda_decoder_callback(void *vda_hw_ctx, @@ -68,7 +55,7 @@ vda_ctx->cv_buffer = CVPixelBufferRetain(image_buffer); } -static int vda_sync_decode(VDAContext *ctx, struct vda_context *vda_ctx) +static int vda_sync_decode(VTContext *ctx, struct vda_context *vda_ctx) { OSStatus status; CFDataRef coded_frame; @@ -93,7 +80,7 @@ av_unused const uint8_t *buffer, av_unused uint32_t size) { - VDAContext *vda = avctx->internal->hwaccel_priv_data; + VTContext *vda = avctx->internal->hwaccel_priv_data; struct vda_context *vda_ctx = avctx->hwaccel_context; if (!vda_ctx->decoder) @@ -108,7 +95,7 @@ const uint8_t *buffer, uint32_t size) { - VDAContext *vda = avctx->internal->hwaccel_priv_data; + VTContext *vda = avctx->internal->hwaccel_priv_data; struct vda_context *vda_ctx = avctx->hwaccel_context; void *tmp; @@ -141,7 +128,7 @@ static int vda_old_h264_end_frame(AVCodecContext *avctx) { H264Context *h = avctx->priv_data; - VDAContext *vda = avctx->internal->hwaccel_priv_data; + VTContext *vda = avctx->internal->hwaccel_priv_data; struct vda_context *vda_ctx = avctx->hwaccel_context; AVFrame *frame = h->cur_pic_ptr->f; struct vda_buffer *context; @@ -271,17 +258,6 @@ return status; } -static int vda_h264_uninit(AVCodecContext *avctx) -{ - VDAContext *vda = avctx->internal->hwaccel_priv_data; - if (vda) { - av_freep(&vda->bitstream); - if (vda->frame) - CVPixelBufferRelease(vda->frame); - } - return 0; -} - AVHWAccel ff_h264_vda_old_hwaccel = { .name = "h264_vda", .type = AVMEDIA_TYPE_VIDEO, @@ -290,8 +266,8 @@ .start_frame = vda_old_h264_start_frame, .decode_slice = vda_old_h264_decode_slice, .end_frame = vda_old_h264_end_frame, - .uninit = vda_h264_uninit, - .priv_data_size = sizeof(VDAContext), + .uninit = ff_videotoolbox_uninit, + .priv_data_size = sizeof(VTContext), }; void ff_vda_output_callback(void *opaque, @@ -301,7 +277,7 @@ CVImageBufferRef image_buffer) { AVCodecContext *ctx = opaque; - VDAContext *vda = ctx->internal->hwaccel_priv_data; + VTContext *vda = ctx->internal->hwaccel_priv_data; if (vda->frame) { @@ -315,65 +291,10 @@ vda->frame = CVPixelBufferRetain(image_buffer); } -static int vda_h264_start_frame(AVCodecContext *avctx, - const uint8_t *buffer, - uint32_t size) -{ - VDAContext *vda = avctx->internal->hwaccel_priv_data; - H264Context *h = avctx->priv_data; - - if (h->is_avc == 1) { - void *tmp; - vda->bitstream_size = 0; - tmp = av_fast_realloc(vda->bitstream, - &vda->allocated_size, - size); - vda->bitstream = tmp; - memcpy(vda->bitstream, buffer, size); - vda->bitstream_size = size; - } else { - vda->bitstream_size = 0; - } - return 0; -} - -static int vda_h264_decode_slice(AVCodecContext *avctx, - const uint8_t *buffer, - uint32_t size) -{ - VDAContext *vda = avctx->internal->hwaccel_priv_data; - H264Context *h = avctx->priv_data; - void *tmp; - - if (h->is_avc == 1) - return 0; - - tmp = av_fast_realloc(vda->bitstream, - &vda->allocated_size, - vda->bitstream_size + size + 4); - if (!tmp) - return AVERROR(ENOMEM); - - vda->bitstream = tmp; - - AV_WB32(vda->bitstream + vda->bitstream_size, size); - memcpy(vda->bitstream + vda->bitstream_size + 4, buffer, size); - - vda->bitstream_size += size + 4; - - return 0; -} - -static void release_buffer(void *opaque, uint8_t *data) -{ - CVImageBufferRef frame = (CVImageBufferRef)data; - CVPixelBufferRelease(frame); -} - static int vda_h264_end_frame(AVCodecContext *avctx) { H264Context *h = avctx->priv_data; - VDAContext *vda = avctx->internal->hwaccel_priv_data; + VTContext *vda = avctx->internal->hwaccel_priv_data; AVVDAContext *vda_ctx = avctx->hwaccel_context; AVFrame *frame = h->cur_pic_ptr->f; uint32_t flush_flags = 1 << 0; ///< kVDADecoderFlush_emitFrames @@ -403,19 +324,7 @@ return AVERROR_UNKNOWN; } - av_buffer_unref(&frame->buf[0]); - - frame->buf[0] = av_buffer_create((uint8_t*)vda->frame, - sizeof(vda->frame), - release_buffer, NULL, - AV_BUFFER_FLAG_READONLY); - if (!frame->buf) - return AVERROR(ENOMEM); - - frame->data[3] = (uint8_t*)vda->frame; - vda->frame = NULL; - - return 0; + return ff_videotoolbox_buffer_create(vda, frame); } int ff_vda_default_init(AVCodecContext *avctx) @@ -434,26 +343,7 @@ // kCVPixelFormatType_420YpCbCr8Planar; - /* Each VCL NAL in the bitstream sent to the decoder - * is preceded by a 4 bytes length header. - * Change the avcC atom header if needed, to signal headers of 4 bytes. */ - if (avctx->extradata_size >= 4 && (avctx->extradata[4] & 0x03) != 0x03) { - uint8_t *rw_extradata; - - if (!(rw_extradata = av_malloc(avctx->extradata_size))) - return AVERROR(ENOMEM); - - memcpy(rw_extradata, avctx->extradata, avctx->extradata_size); - - rw_extradata[4] |= 0x03; - - avc_data = CFDataCreate(kCFAllocatorDefault, rw_extradata, avctx->extradata_size); - - av_freep(&rw_extradata); - } else { - avc_data = CFDataCreate(kCFAllocatorDefault, - avctx->extradata, avctx->extradata_size); - } + avc_data = ff_videotoolbox_avcc_extradata_create(avctx); config_info = CFDictionaryCreateMutable(kCFAllocatorDefault, 4, @@ -521,27 +411,15 @@ } } -static int vda_h264_alloc_frame(AVCodecContext *avctx, AVFrame *frame) -{ - frame->width = avctx->width; - frame->height = avctx->height; - frame->format = avctx->pix_fmt; - frame->buf[0] = av_buffer_alloc(1); - - if (!frame->buf[0]) - return AVERROR(ENOMEM); - return 0; -} - AVHWAccel ff_h264_vda_hwaccel = { .name = "h264_vda", .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_H264, .pix_fmt = AV_PIX_FMT_VDA, - .alloc_frame = vda_h264_alloc_frame, - .start_frame = vda_h264_start_frame, - .decode_slice = vda_h264_decode_slice, + .alloc_frame = ff_videotoolbox_alloc_frame, + .start_frame = ff_videotoolbox_h264_start_frame, + .decode_slice = ff_videotoolbox_h264_decode_slice, .end_frame = vda_h264_end_frame, - .uninit = vda_h264_uninit, - .priv_data_size = sizeof(VDAContext), + .uninit = ff_videotoolbox_uninit, + .priv_data_size = sizeof(VTContext), }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vda_h264_dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vda_h264_dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vda_h264_dec.c 2015-06-18 18:55:01.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vda_h264_dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -267,7 +267,7 @@ .init = vdadec_init, .close = vdadec_close, .decode = vdadec_decode, - .capabilities = CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_DELAY, .flush = vdadec_flush, .long_name = NULL_IF_CONFIG_SMALL("H.264 (VDA acceleration)"), }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vda_internal.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/vda_internal.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vda_internal.h 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vda_internal.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/* - * 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 - */ - -#ifndef AVCODEC_VDA_INTERNAL_H -#define AVCODEC_VDA_INTERNAL_H - -#include "vda.h" - -void ff_vda_output_callback(void *vda_hw_ctx, - CFDictionaryRef user_info, - OSStatus status, - uint32_t infoFlags, - CVImageBufferRef image_buffer); - -int ff_vda_default_init(AVCodecContext *avctx); -void ff_vda_default_free(AVCodecContext *avctx); - -#endif /* AVCODEC_VDA_INTERNAL_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vda_vt_internal.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/vda_vt_internal.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vda_vt_internal.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vda_vt_internal.h 2015-08-03 17:20:02.000000000 +0000 @@ -0,0 +1,55 @@ +/* + * 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 + */ + +#ifndef AVCODEC_VDA_VT_INTERNAL_H +#define AVCODEC_VDA_VT_INTERNAL_H + +void ff_vda_output_callback(void *vda_hw_ctx, + CFDictionaryRef user_info, + OSStatus status, + uint32_t infoFlags, + CVImageBufferRef image_buffer); + +int ff_vda_default_init(AVCodecContext *avctx); +void ff_vda_default_free(AVCodecContext *avctx); + +typedef struct VTContext { + // The current bitstream buffer. + uint8_t *bitstream; + + // The current size of the bitstream. + int bitstream_size; + + // The reference size used for fast reallocation. + int allocated_size; + + // The core video buffer + CVImageBufferRef frame; +} VTContext; + +int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame); +int ff_videotoolbox_uninit(AVCodecContext *avctx); +int ff_videotoolbox_buffer_create(VTContext *vtctx, AVFrame *frame); +int ff_videotoolbox_h264_start_frame(AVCodecContext *avctx, + const uint8_t *buffer, + uint32_t size); +int ff_videotoolbox_h264_decode_slice(AVCodecContext *avctx, + const uint8_t *buffer, + uint32_t size); +CFDataRef ff_videotoolbox_avcc_extradata_create(AVCodecContext *avctx); +#endif /* AVCODEC_VDA_VT_INTERNAL_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vdpau_hevc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vdpau_hevc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vdpau_hevc.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vdpau_hevc.c 2015-08-04 17:20:03.000000000 +0000 @@ -0,0 +1,437 @@ +/* + * MPEG-H Part 2 / HEVC / H.265 HW decode acceleration through VDPAU + * + * Copyright (c) 2013 Philip Langdale + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * 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 + +#include "avcodec.h" +#include "internal.h" +#include "hevc.h" +#include "vdpau.h" +#include "vdpau_internal.h" + +static int vdpau_hevc_start_frame(AVCodecContext *avctx, + const uint8_t *buffer, uint32_t size) +{ + HEVCContext *h = avctx->priv_data; + HEVCFrame *pic = h->ref; + struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; + + VdpPictureInfoHEVC *info = &pic_ctx->info.hevc; + + const HEVCSPS *sps = h->ps.sps; + const HEVCPPS *pps = h->ps.pps; + const SliceHeader *sh = &h->sh; + const ScalingList *sl = pps->scaling_list_data_present_flag ? + &pps->scaling_list : &sps->scaling_list; + + /* init VdpPictureInfoHEVC */ + + /* SPS */ + info->chroma_format_idc = sps->chroma_format_idc; + info->separate_colour_plane_flag = sps->separate_colour_plane_flag; + info->pic_width_in_luma_samples = sps->width; + info->pic_height_in_luma_samples = sps->height; + info->bit_depth_luma_minus8 = sps->bit_depth - 8; + info->bit_depth_chroma_minus8 = sps->bit_depth - 8; + info->log2_max_pic_order_cnt_lsb_minus4 = sps->log2_max_poc_lsb - 4; + /** Provides the value corresponding to the nuh_temporal_id of the frame + to be decoded. */ + info->sps_max_dec_pic_buffering_minus1 = sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering - 1; + info->log2_min_luma_coding_block_size_minus3 = sps->log2_min_cb_size - 3; + info->log2_diff_max_min_luma_coding_block_size = sps->log2_diff_max_min_coding_block_size; + info->log2_min_transform_block_size_minus2 = sps->log2_min_tb_size - 2; + info->log2_diff_max_min_transform_block_size = sps->log2_max_trafo_size - sps->log2_min_tb_size; + info->max_transform_hierarchy_depth_inter = sps->max_transform_hierarchy_depth_inter; + info->max_transform_hierarchy_depth_intra = sps->max_transform_hierarchy_depth_intra; + info->scaling_list_enabled_flag = sps->scaling_list_enable_flag; + /** Scaling lists, in diagonal order, to be used for this frame. */ + for (size_t i = 0; i < 6; i++) { + for (size_t j = 0; j < 16; j++) { + /** Scaling List for 4x4 quantization matrix, + indexed as ScalingList4x4[matrixId][i]. */ + uint8_t pos = 4 * ff_hevc_diag_scan4x4_y[j] + ff_hevc_diag_scan4x4_x[j]; + info->ScalingList4x4[i][j] = sl->sl[0][i][pos]; + } + for (size_t j = 0; j < 64; j++) { + uint8_t pos = 8 * ff_hevc_diag_scan8x8_y[j] + ff_hevc_diag_scan8x8_x[j]; + /** Scaling List for 8x8 quantization matrix, + indexed as ScalingList8x8[matrixId][i]. */ + info->ScalingList8x8[i][j] = sl->sl[1][i][pos]; + /** Scaling List for 16x16 quantization matrix, + indexed as ScalingList16x16[matrixId][i]. */ + info->ScalingList16x16[i][j] = sl->sl[2][i][pos]; + if (i < 2) { + /** Scaling List for 32x32 quantization matrix, + indexed as ScalingList32x32[matrixId][i]. */ + info->ScalingList32x32[i][j] = sl->sl[3][i * 3][pos]; + } + } + /** Scaling List DC Coefficients for 16x16, + indexed as ScalingListDCCoeff16x16[matrixId]. */ + info->ScalingListDCCoeff16x16[i] = sl->sl_dc[0][i]; + if (i < 2) { + /** Scaling List DC Coefficients for 32x32, + indexed as ScalingListDCCoeff32x32[matrixId]. */ + info->ScalingListDCCoeff32x32[i] = sl->sl_dc[1][i * 3]; + } + } + info->amp_enabled_flag = sps->amp_enabled_flag; + info->sample_adaptive_offset_enabled_flag = sps->sao_enabled; + info->pcm_enabled_flag = sps->pcm_enabled_flag; + if (info->pcm_enabled_flag) { + /** Only needs to be set if pcm_enabled_flag is set. Ignored otherwise. */ + info->pcm_sample_bit_depth_luma_minus1 = sps->pcm.bit_depth - 1; + /** Only needs to be set if pcm_enabled_flag is set. Ignored otherwise. */ + info->pcm_sample_bit_depth_chroma_minus1 = sps->pcm.bit_depth_chroma - 1; + /** Only needs to be set if pcm_enabled_flag is set. Ignored otherwise. */ + info->log2_min_pcm_luma_coding_block_size_minus3 = sps->pcm.log2_min_pcm_cb_size - 3; + /** Only needs to be set if pcm_enabled_flag is set. Ignored otherwise. */ + info->log2_diff_max_min_pcm_luma_coding_block_size = sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size; + /** Only needs to be set if pcm_enabled_flag is set. Ignored otherwise. */ + info->pcm_loop_filter_disabled_flag = sps->pcm.loop_filter_disable_flag; + } + /** Per spec, when zero, assume short_term_ref_pic_set_sps_flag + is also zero. */ + info->num_short_term_ref_pic_sets = sps->nb_st_rps; + info->long_term_ref_pics_present_flag = sps->long_term_ref_pics_present_flag; + /** Only needed if long_term_ref_pics_present_flag is set. Ignored + otherwise. */ + info->num_long_term_ref_pics_sps = sps->num_long_term_ref_pics_sps; + info->sps_temporal_mvp_enabled_flag = sps->sps_temporal_mvp_enabled_flag; + info->strong_intra_smoothing_enabled_flag = sps->sps_strong_intra_smoothing_enable_flag; + /** @} */ + + /** \name HEVC Picture Parameter Set + * + * Copies of the HEVC Picture Parameter Set bitstream fields. + * @{ */ + info->dependent_slice_segments_enabled_flag = pps->dependent_slice_segments_enabled_flag; + info->output_flag_present_flag = pps->output_flag_present_flag; + info->num_extra_slice_header_bits = pps->num_extra_slice_header_bits; + info->sign_data_hiding_enabled_flag = pps->sign_data_hiding_flag; + info->cabac_init_present_flag = pps->cabac_init_present_flag; + info->num_ref_idx_l0_default_active_minus1 = pps->num_ref_idx_l0_default_active - 1; + info->num_ref_idx_l1_default_active_minus1 = pps->num_ref_idx_l1_default_active - 1; + info->init_qp_minus26 = pps->pic_init_qp_minus26; + info->constrained_intra_pred_flag = pps->constrained_intra_pred_flag; + info->transform_skip_enabled_flag = pps->transform_skip_enabled_flag; + info->cu_qp_delta_enabled_flag = pps->cu_qp_delta_enabled_flag; + /** Only needed if cu_qp_delta_enabled_flag is set. Ignored otherwise. */ + info->diff_cu_qp_delta_depth = pps->diff_cu_qp_delta_depth; + info->pps_cb_qp_offset = pps->cb_qp_offset; + info->pps_cr_qp_offset = pps->cr_qp_offset; + info->pps_slice_chroma_qp_offsets_present_flag = pps->pic_slice_level_chroma_qp_offsets_present_flag; + info->weighted_pred_flag = pps->weighted_pred_flag; + info->weighted_bipred_flag = pps->weighted_bipred_flag; + info->transquant_bypass_enabled_flag = pps->transquant_bypass_enable_flag; + info->tiles_enabled_flag = pps->tiles_enabled_flag; + info->entropy_coding_sync_enabled_flag = pps->entropy_coding_sync_enabled_flag; + if (info->tiles_enabled_flag) { + /** Only valid if tiles_enabled_flag is set. Ignored otherwise. */ + info->num_tile_columns_minus1 = pps->num_tile_columns - 1; + /** Only valid if tiles_enabled_flag is set. Ignored otherwise. */ + info->num_tile_rows_minus1 = pps->num_tile_rows - 1; + /** Only valid if tiles_enabled_flag is set. Ignored otherwise. */ + info->uniform_spacing_flag = pps->uniform_spacing_flag; + /** Only need to set 0..num_tile_columns_minus1. The struct + definition reserves up to the maximum of 20. Invalid values are + ignored. */ + for (ssize_t i = 0; i < pps->num_tile_columns; i++) { + info->column_width_minus1[i] = pps->column_width[i] - 1; + } + /** Only need to set 0..num_tile_rows_minus1. The struct + definition reserves up to the maximum of 22. Invalid values are + ignored.*/ + for (ssize_t i = 0; i < pps->num_tile_rows; i++) { + info->row_height_minus1[i] = pps->row_height[i] - 1; + } + /** Only needed if tiles_enabled_flag is set. Invalid values are + ignored. */ + info->loop_filter_across_tiles_enabled_flag = pps->loop_filter_across_tiles_enabled_flag; + } + info->pps_loop_filter_across_slices_enabled_flag = pps->seq_loop_filter_across_slices_enabled_flag; + info->deblocking_filter_control_present_flag = pps->deblocking_filter_control_present_flag; + /** Only valid if deblocking_filter_control_present_flag is set. Ignored + otherwise. */ + info->deblocking_filter_override_enabled_flag = pps->deblocking_filter_override_enabled_flag; + /** Only valid if deblocking_filter_control_present_flag is set. Ignored + otherwise. */ + info->pps_deblocking_filter_disabled_flag = pps->disable_dbf; + /** Only valid if deblocking_filter_control_present_flag is set and + pps_deblocking_filter_disabled_flag is not set. Ignored otherwise.*/ + info->pps_beta_offset_div2 = pps->beta_offset / 2; + /** Only valid if deblocking_filter_control_present_flag is set and + pps_deblocking_filter_disabled_flag is not set. Ignored otherwise. */ + info->pps_tc_offset_div2 = pps->tc_offset / 2; + info->lists_modification_present_flag = pps->lists_modification_present_flag; + info->log2_parallel_merge_level_minus2 = pps->log2_parallel_merge_level - 2; + info->slice_segment_header_extension_present_flag = pps->slice_header_extension_present_flag; + + /** \name HEVC Slice Segment Header + * + * Copies of the HEVC Slice Segment Header bitstream fields and calculated + * values detailed in the specification. + * @{ */ + /** Set to 1 if nal_unit_type is equal to IDR_W_RADL or IDR_N_LP. + Set to zero otherwise. */ + info->IDRPicFlag = IS_IDR(h); + /** Set to 1 if nal_unit_type in the range of BLA_W_LP to + RSV_IRAP_VCL23, inclusive. Set to zero otherwise.*/ + info->RAPPicFlag = IS_IRAP(h); + /** See section 7.4.7.1 of the specification. */ + info->CurrRpsIdx = sps->nb_st_rps; + if (sh->short_term_ref_pic_set_sps_flag == 1) { + for (size_t i = 0; i < sps->nb_st_rps; i++) { + if (sh->short_term_rps == &sps->st_rps[i]) { + info->CurrRpsIdx = i; + break; + } + } + } + /** See section 7.4.7.2 of the specification. */ + info->NumPocTotalCurr = ff_hevc_frame_nb_refs(h); + if (sh->short_term_ref_pic_set_sps_flag == 0 && sh->short_term_rps) { + /** Corresponds to specification field, NumDeltaPocs[RefRpsIdx]. + Only applicable when short_term_ref_pic_set_sps_flag == 0. + Implementations will ignore this value in other cases. See 7.4.8. */ + info->NumDeltaPocsOfRefRpsIdx = sh->short_term_rps->rps_idx_num_delta_pocs; + } + /** Section 7.6.3.1 of the H.265/HEVC Specification defines the syntax of + the slice_segment_header. This header contains information that + some VDPAU implementations may choose to skip. The VDPAU API + requires client applications to track the number of bits used in the + slice header for structures associated with short term and long term + reference pictures. First, VDPAU requires the number of bits used by + the short_term_ref_pic_set array in the slice_segment_header. */ + info->NumShortTermPictureSliceHeaderBits = sh->short_term_ref_pic_set_size; + /** Second, VDPAU requires the number of bits used for long term reference + pictures in the slice_segment_header. This is equal to the number + of bits used for the contents of the block beginning with + "if(long_term_ref_pics_present_flag)". */ + info->NumLongTermPictureSliceHeaderBits = sh->long_term_ref_pic_set_size; + /** @} */ + + /** Slice Decoding Process - Picture Order Count */ + /** The value of PicOrderCntVal of the picture in the access unit + containing the SEI message. The picture being decoded. */ + info->CurrPicOrderCntVal = h->poc; + + /** Slice Decoding Process - Reference Picture Sets */ + for (size_t i = 0; i < 16; i++) { + info->RefPics[i] = VDP_INVALID_HANDLE; + info->PicOrderCntVal[i] = 0; + info->IsLongTerm[i] = 0; + } + for (size_t i = 0, j = 0; i < FF_ARRAY_ELEMS(h->DPB); i++) { + const HEVCFrame *frame = &h->DPB[i]; + if (frame != h->ref && (frame->flags & (HEVC_FRAME_FLAG_LONG_REF | + HEVC_FRAME_FLAG_SHORT_REF))) { + if (j > 16) { + av_log(avctx, AV_LOG_WARNING, + "VDPAU only supports up to 16 references in the DPB. " + "This frame may not be decoded correctly.\n"); + break; + } + /** Array of video reference surfaces. + Set any unused positions to VDP_INVALID_HANDLE. */ + info->RefPics[j] = ff_vdpau_get_surface_id(frame->frame); + /** Array of picture order counts. These correspond to positions + in the RefPics array. */ + info->PicOrderCntVal[j] = frame->poc; + /** Array used to specify whether a particular RefPic is + a long term reference. A value of "1" indicates a long-term + reference. */ + // XXX: Setting this caused glitches in the nvidia implementation + // Always setting it to zero, produces correct results + //info->IsLongTerm[j] = frame->flags & HEVC_FRAME_FLAG_LONG_REF; + info->IsLongTerm[j] = 0; + j++; + } + } + /** Copy of specification field, see Section 8.3.2 of the + H.265/HEVC Specification. */ + info->NumPocStCurrBefore = h->rps[ST_CURR_BEF].nb_refs; + if (info->NumPocStCurrBefore > 8) { + av_log(avctx, AV_LOG_WARNING, + "VDPAU only supports up to 8 references in StCurrBefore. " + "This frame may not be decoded correctly.\n"); + info->NumPocStCurrBefore = 8; + } + /** Copy of specification field, see Section 8.3.2 of the + H.265/HEVC Specification. */ + info->NumPocStCurrAfter = h->rps[ST_CURR_AFT].nb_refs; + if (info->NumPocStCurrAfter > 8) { + av_log(avctx, AV_LOG_WARNING, + "VDPAU only supports up to 8 references in StCurrAfter. " + "This frame may not be decoded correctly.\n"); + info->NumPocStCurrAfter = 8; + } + /** Copy of specification field, see Section 8.3.2 of the + H.265/HEVC Specification. */ + info->NumPocLtCurr = h->rps[LT_CURR].nb_refs; + if (info->NumPocLtCurr > 8) { + av_log(avctx, AV_LOG_WARNING, + "VDPAU only supports up to 8 references in LtCurr. " + "This frame may not be decoded correctly.\n"); + info->NumPocLtCurr = 8; + } + /** Reference Picture Set list, one of the short-term RPS. These + correspond to positions in the RefPics array. */ + for (ssize_t i = 0, j = 0; i < h->rps[ST_CURR_BEF].nb_refs; i++) { + HEVCFrame *frame = h->rps[ST_CURR_BEF].ref[i]; + if (frame) { + uint8_t found = 0; + uintptr_t id = ff_vdpau_get_surface_id(frame->frame); + for (size_t k = 0; k < 16; k++) { + if (id == info->RefPics[k]) { + info->RefPicSetStCurrBefore[j] = k; + j++; + found = 1; + break; + } + } + if (!found) { + av_log(avctx, AV_LOG_WARNING, "missing surface: %p\n", + (void *)id); + } + } else { + av_log(avctx, AV_LOG_WARNING, "missing STR Before frame: %zd\n", i); + } + } + /** Reference Picture Set list, one of the short-term RPS. These + correspond to positions in the RefPics array. */ + for (ssize_t i = 0, j = 0; i < h->rps[ST_CURR_AFT].nb_refs; i++) { + HEVCFrame *frame = h->rps[ST_CURR_AFT].ref[i]; + if (frame) { + uint8_t found = 0; + uintptr_t id = ff_vdpau_get_surface_id(frame->frame); + for (size_t k = 0; k < 16; k++) { + if (id == info->RefPics[k]) { + info->RefPicSetStCurrAfter[j] = k; + j++; + found = 1; + break; + } + } + if (!found) { + av_log(avctx, AV_LOG_WARNING, "missing surface: %p\n", + (void *)id); + } + } else { + av_log(avctx, AV_LOG_WARNING, "missing STR After frame: %zd\n", i); + } + } + /** Reference Picture Set list, one of the long-term RPS. These + correspond to positions in the RefPics array. */ + for (ssize_t i = 0, j = 0; i < h->rps[LT_CURR].nb_refs; i++) { + HEVCFrame *frame = h->rps[LT_CURR].ref[i]; + if (frame) { + uint8_t found = 0; + uintptr_t id = ff_vdpau_get_surface_id(frame->frame); + for (size_t k = 0; k < 16; k++) { + if (id == info->RefPics[k]) { + info->RefPicSetLtCurr[j] = k; + j++; + found = 1; + break; + } + } + if (!found) { + av_log(avctx, AV_LOG_WARNING, "missing surface: %p\n", + (void *)id); + } + } else { + av_log(avctx, AV_LOG_WARNING, "missing LTR frame: %zd\n", i); + } + } + + return ff_vdpau_common_start_frame(pic_ctx, buffer, size); +} + +static const uint8_t start_code_prefix[3] = { 0x00, 0x00, 0x01 }; + +static int vdpau_hevc_decode_slice(AVCodecContext *avctx, + const uint8_t *buffer, uint32_t size) +{ + HEVCContext *h = avctx->priv_data; + struct vdpau_picture_context *pic_ctx = h->ref->hwaccel_picture_private; + int val; + + val = ff_vdpau_add_buffer(pic_ctx, start_code_prefix, 3); + if (val) + return val; + + val = ff_vdpau_add_buffer(pic_ctx, buffer, size); + if (val) + return val; + + return 0; +} + +static int vdpau_hevc_end_frame(AVCodecContext *avctx) +{ + HEVCContext *h = avctx->priv_data; + struct vdpau_picture_context *pic_ctx = h->ref->hwaccel_picture_private; + int val; + + val = ff_vdpau_common_end_frame(avctx, h->ref->frame, pic_ctx); + if (val < 0) + return val; + + return 0; +} + +static int vdpau_hevc_init(AVCodecContext *avctx) +{ + VdpDecoderProfile profile; + uint32_t level = avctx->level; + + switch (avctx->profile) { + case FF_PROFILE_HEVC_MAIN: + profile = VDP_DECODER_PROFILE_HEVC_MAIN; + break; + case FF_PROFILE_HEVC_MAIN_10: + profile = VDP_DECODER_PROFILE_HEVC_MAIN_10; + break; + case FF_PROFILE_HEVC_MAIN_STILL_PICTURE: + profile = VDP_DECODER_PROFILE_HEVC_MAIN_STILL; + break; + default: + return AVERROR(ENOTSUP); + } + + return ff_vdpau_common_init(avctx, profile, level); +} + +AVHWAccel ff_hevc_vdpau_hwaccel = { + .name = "hevc_vdpau", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_HEVC, + .pix_fmt = AV_PIX_FMT_VDPAU, + .start_frame = vdpau_hevc_start_frame, + .end_frame = vdpau_hevc_end_frame, + .decode_slice = vdpau_hevc_decode_slice, + .frame_priv_data_size = sizeof(struct vdpau_picture_context), + .init = vdpau_hevc_init, + .uninit = ff_vdpau_common_uninit, + .priv_data_size = sizeof(VDPAUContext), +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vdpau_internal.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/vdpau_internal.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vdpau_internal.h 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vdpau_internal.h 2015-06-26 17:20:02.000000000 +0000 @@ -50,6 +50,9 @@ #ifdef VDP_DECODER_PROFILE_H264_HIGH_444_PREDICTIVE VdpPictureInfoH264Predictive h264_predictive; #endif +#ifdef VDP_DECODER_PROFILE_HEVC_MAIN + VdpPictureInfoHEVC hevc; +#endif }; #include "vdpau.h" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/version.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/version.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/version.h 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/version.h 2015-08-03 17:20:02.000000000 +0000 @@ -29,7 +29,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 56 -#define LIBAVCODEC_VERSION_MINOR 41 +#define LIBAVCODEC_VERSION_MINOR 57 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ @@ -190,5 +190,20 @@ #ifndef FF_API_STREAM_CODEC_TAG #define FF_API_STREAM_CODEC_TAG (LIBAVCODEC_VERSION_MAJOR < 59) #endif +#ifndef FF_API_QUANT_BIAS +#define FF_API_QUANT_BIAS (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_RC_STRATEGY +#define FF_API_RC_STRATEGY (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_CODED_FRAME +#define FF_API_CODED_FRAME (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_MOTION_EST +#define FF_API_MOTION_EST (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_WITHOUT_PREFIX +#define FF_API_WITHOUT_PREFIX (LIBAVCODEC_VERSION_MAJOR < 59) +#endif #endif /* AVCODEC_VERSION_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/videodsp_template.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/videodsp_template.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/videodsp_template.c 2015-06-18 18:55:01.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/videodsp_template.c 2015-07-08 17:20:04.000000000 +0000 @@ -32,6 +32,8 @@ if (!w || !h) return; + av_assert2(block_w * sizeof(pixel) <= FFABS(buf_linesize)); + if (src_y >= h) { src -= src_y * src_linesize; src += (h - 1) * src_linesize; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/videotoolbox.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/videotoolbox.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/videotoolbox.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/videotoolbox.c 2015-08-03 17:20:02.000000000 +0000 @@ -0,0 +1,690 @@ +/* + * Videotoolbox hardware acceleration + * + * copyright (c) 2012 Sebastien Zwickert + * + * 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 "config.h" +#if CONFIG_VIDEOTOOLBOX +# include "videotoolbox.h" +#else +# include "vda.h" +#endif +#include "vda_vt_internal.h" +#include "libavutil/avutil.h" +#include "bytestream.h" +#include "h264.h" +#include "mpegvideo.h" + +#ifndef kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder +# define kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder CFSTR("EnableHardwareAcceleratedVideoDecoder") +#endif + +#define VIDEOTOOLBOX_ESDS_EXTRADATA_PADDING 12 + +static void videotoolbox_buffer_release(void *opaque, uint8_t *data) +{ + CVPixelBufferRef cv_buffer = (CVImageBufferRef)data; + CVPixelBufferRelease(cv_buffer); +} + +static int videotoolbox_buffer_copy(VTContext *vtctx, + const uint8_t *buffer, + uint32_t size) +{ + void *tmp; + + tmp = av_fast_realloc(vtctx->bitstream, + &vtctx->allocated_size, + size); + + if (!tmp) + return AVERROR(ENOMEM); + + vtctx->bitstream = tmp; + memcpy(vtctx->bitstream, buffer, size); + vtctx->bitstream_size = size; + + return 0; +} + +int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame) +{ + frame->width = avctx->width; + frame->height = avctx->height; + frame->format = avctx->pix_fmt; + frame->buf[0] = av_buffer_alloc(1); + + if (!frame->buf[0]) + return AVERROR(ENOMEM); + + return 0; +} + +CFDataRef ff_videotoolbox_avcc_extradata_create(AVCodecContext *avctx) +{ + CFDataRef data = NULL; + + /* Each VCL NAL in the bitstream sent to the decoder + * is preceded by a 4 bytes length header. + * Change the avcC atom header if needed, to signal headers of 4 bytes. */ + if (avctx->extradata_size >= 4 && (avctx->extradata[4] & 0x03) != 0x03) { + uint8_t *rw_extradata = av_memdup(avctx->extradata, avctx->extradata_size); + + if (!rw_extradata) + return NULL; + + rw_extradata[4] |= 0x03; + + data = CFDataCreate(kCFAllocatorDefault, rw_extradata, avctx->extradata_size); + + av_freep(&rw_extradata); + } else { + data = CFDataCreate(kCFAllocatorDefault, avctx->extradata, avctx->extradata_size); + } + + return data; +} + +int ff_videotoolbox_buffer_create(VTContext *vtctx, AVFrame *frame) +{ + av_buffer_unref(&frame->buf[0]); + + frame->buf[0] = av_buffer_create((uint8_t*)vtctx->frame, + sizeof(vtctx->frame), + videotoolbox_buffer_release, + NULL, + AV_BUFFER_FLAG_READONLY); + if (!frame->buf[0]) { + return AVERROR(ENOMEM); + } + + frame->data[3] = (uint8_t*)vtctx->frame; + vtctx->frame = NULL; + + return 0; +} + +int ff_videotoolbox_h264_start_frame(AVCodecContext *avctx, + const uint8_t *buffer, + uint32_t size) +{ + VTContext *vtctx = avctx->internal->hwaccel_priv_data; + H264Context *h = avctx->priv_data; + + vtctx->bitstream_size = 0; + + if (h->is_avc == 1) { + return videotoolbox_buffer_copy(vtctx, buffer, size); + } + + return 0; +} + +int ff_videotoolbox_h264_decode_slice(AVCodecContext *avctx, + const uint8_t *buffer, + uint32_t size) +{ + VTContext *vtctx = avctx->internal->hwaccel_priv_data; + H264Context *h = avctx->priv_data; + void *tmp; + + if (h->is_avc == 1) + return 0; + + tmp = av_fast_realloc(vtctx->bitstream, + &vtctx->allocated_size, + vtctx->bitstream_size+size+4); + if (!tmp) + return AVERROR(ENOMEM); + + vtctx->bitstream = tmp; + + AV_WB32(vtctx->bitstream + vtctx->bitstream_size, size); + memcpy(vtctx->bitstream + vtctx->bitstream_size + 4, buffer, size); + + vtctx->bitstream_size += size + 4; + + return 0; +} + +int ff_videotoolbox_uninit(AVCodecContext *avctx) +{ + VTContext *vtctx = avctx->internal->hwaccel_priv_data; + if (vtctx) { + av_freep(&vtctx->bitstream); + if (vtctx->frame) + CVPixelBufferRelease(vtctx->frame); + } + + return 0; +} + +#if CONFIG_VIDEOTOOLBOX +static void videotoolbox_write_mp4_descr_length(PutByteContext *pb, int length) +{ + int i; + uint8_t b; + + for (i = 3; i >= 0; i--) { + b = (length >> (i * 7)) & 0x7F; + if (i != 0) + b |= 0x80; + + bytestream2_put_byteu(pb, b); + } +} + +static CFDataRef videotoolbox_esds_extradata_create(AVCodecContext *avctx) +{ + CFDataRef data; + uint8_t *rw_extradata; + PutByteContext pb; + int full_size = 3 + 5 + 13 + 5 + avctx->extradata_size + 3; + // ES_DescrTag data + DecoderConfigDescrTag + data + DecSpecificInfoTag + size + SLConfigDescriptor + int config_size = 13 + 5 + avctx->extradata_size; + int s; + + if (!(rw_extradata = av_mallocz(full_size + VIDEOTOOLBOX_ESDS_EXTRADATA_PADDING))) + return NULL; + + bytestream2_init_writer(&pb, rw_extradata, full_size + VIDEOTOOLBOX_ESDS_EXTRADATA_PADDING); + bytestream2_put_byteu(&pb, 0); // version + bytestream2_put_ne24(&pb, 0); // flags + + // elementary stream descriptor + bytestream2_put_byteu(&pb, 0x03); // ES_DescrTag + videotoolbox_write_mp4_descr_length(&pb, full_size); + bytestream2_put_ne16(&pb, 0); // esid + bytestream2_put_byteu(&pb, 0); // stream priority (0-32) + + // decoder configuration descriptor + bytestream2_put_byteu(&pb, 0x04); // DecoderConfigDescrTag + videotoolbox_write_mp4_descr_length(&pb, config_size); + bytestream2_put_byteu(&pb, 32); // object type indication. 32 = AV_CODEC_ID_MPEG4 + bytestream2_put_byteu(&pb, 0x11); // stream type + bytestream2_put_ne24(&pb, 0); // buffer size + bytestream2_put_ne32(&pb, 0); // max bitrate + bytestream2_put_ne32(&pb, 0); // avg bitrate + + // decoder specific descriptor + bytestream2_put_byteu(&pb, 0x05); ///< DecSpecificInfoTag + videotoolbox_write_mp4_descr_length(&pb, avctx->extradata_size); + + bytestream2_put_buffer(&pb, avctx->extradata, avctx->extradata_size); + + // SLConfigDescriptor + bytestream2_put_byteu(&pb, 0x06); // SLConfigDescrTag + bytestream2_put_byteu(&pb, 0x01); // length + bytestream2_put_byteu(&pb, 0x02); // + + s = bytestream2_size_p(&pb); + + data = CFDataCreate(kCFAllocatorDefault, rw_extradata, s); + + av_freep(&rw_extradata); + return data; +} + +static CMSampleBufferRef videotoolbox_sample_buffer_create(CMFormatDescriptionRef fmt_desc, + void *buffer, + int size) +{ + OSStatus status; + CMBlockBufferRef block_buf; + CMSampleBufferRef sample_buf; + + block_buf = NULL; + sample_buf = NULL; + + status = CMBlockBufferCreateWithMemoryBlock(kCFAllocatorDefault,// structureAllocator + buffer, // memoryBlock + size, // blockLength + kCFAllocatorNull, // blockAllocator + NULL, // customBlockSource + 0, // offsetToData + size, // dataLength + 0, // flags + &block_buf); + + if (!status) { + status = CMSampleBufferCreate(kCFAllocatorDefault, // allocator + block_buf, // dataBuffer + TRUE, // dataReady + 0, // makeDataReadyCallback + 0, // makeDataReadyRefcon + fmt_desc, // formatDescription + 1, // numSamples + 0, // numSampleTimingEntries + NULL, // sampleTimingArray + 0, // numSampleSizeEntries + NULL, // sampleSizeArray + &sample_buf); + } + + if (block_buf) + CFRelease(block_buf); + + return sample_buf; +} + +static void videotoolbox_decoder_callback(void *opaque, + void *sourceFrameRefCon, + OSStatus status, + VTDecodeInfoFlags flags, + CVImageBufferRef image_buffer, + CMTime pts, + CMTime duration) +{ + AVCodecContext *avctx = opaque; + VTContext *vtctx = avctx->internal->hwaccel_priv_data; + + if (vtctx->frame) { + CVPixelBufferRelease(vtctx->frame); + vtctx->frame = NULL; + } + + if (!image_buffer) { + av_log(NULL, AV_LOG_DEBUG, "vt decoder cb: output image buffer is null\n"); + return; + } + + vtctx->frame = CVPixelBufferRetain(image_buffer); +} + +static OSStatus videotoolbox_session_decode_frame(AVCodecContext *avctx) +{ + OSStatus status; + CMSampleBufferRef sample_buf; + AVVideotoolboxContext *videotoolbox = avctx->hwaccel_context; + VTContext *vtctx = avctx->internal->hwaccel_priv_data; + + sample_buf = videotoolbox_sample_buffer_create(videotoolbox->cm_fmt_desc, + vtctx->bitstream, + vtctx->bitstream_size); + + if (!sample_buf) + return -1; + + status = VTDecompressionSessionDecodeFrame(videotoolbox->session, + sample_buf, + 0, // decodeFlags + NULL, // sourceFrameRefCon + 0); // infoFlagsOut + if (status == noErr) + status = VTDecompressionSessionWaitForAsynchronousFrames(videotoolbox->session); + + CFRelease(sample_buf); + + return status; +} + +static int videotoolbox_common_end_frame(AVCodecContext *avctx, AVFrame *frame) +{ + int status; + AVVideotoolboxContext *videotoolbox = avctx->hwaccel_context; + VTContext *vtctx = avctx->internal->hwaccel_priv_data; + + if (!videotoolbox->session || !vtctx->bitstream) + return AVERROR_INVALIDDATA; + + status = videotoolbox_session_decode_frame(avctx); + + if (status) { + av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status); + return AVERROR_UNKNOWN; + } + + if (!vtctx->frame) + return AVERROR_UNKNOWN; + + return ff_videotoolbox_buffer_create(vtctx, frame); +} + +static int videotoolbox_h264_end_frame(AVCodecContext *avctx) +{ + H264Context *h = avctx->priv_data; + AVFrame *frame = h->cur_pic_ptr->f; + + return videotoolbox_common_end_frame(avctx, frame); +} + +static int videotoolbox_mpeg_start_frame(AVCodecContext *avctx, + const uint8_t *buffer, + uint32_t size) +{ + VTContext *vtctx = avctx->internal->hwaccel_priv_data; + + return videotoolbox_buffer_copy(vtctx, buffer, size); +} + +static int videotoolbox_mpeg_decode_slice(AVCodecContext *avctx, + const uint8_t *buffer, + uint32_t size) +{ + return 0; +} + +static int videotoolbox_mpeg_end_frame(AVCodecContext *avctx) +{ + MpegEncContext *s = avctx->priv_data; + AVFrame *frame = s->current_picture_ptr->f; + + return videotoolbox_common_end_frame(avctx, frame); +} + +static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec_type, + AVCodecContext *avctx) +{ + CFMutableDictionaryRef config_info = CFDictionaryCreateMutable(kCFAllocatorDefault, + 1, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + + CFDictionarySetValue(config_info, + kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder, + kCFBooleanTrue); + + if (avctx->extradata_size) { + CFMutableDictionaryRef avc_info; + CFDataRef data = NULL; + + avc_info = CFDictionaryCreateMutable(kCFAllocatorDefault, + 1, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + + switch (codec_type) { + case kCMVideoCodecType_MPEG4Video : + data = videotoolbox_esds_extradata_create(avctx); + if (data) + CFDictionarySetValue(avc_info, CFSTR("esds"), data); + break; + case kCMVideoCodecType_H264 : + data = ff_videotoolbox_avcc_extradata_create(avctx); + if (data) + CFDictionarySetValue(avc_info, CFSTR("avcC"), data); + break; + default: + break; + } + + CFDictionarySetValue(config_info, + kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms, + avc_info); + + if (data) + CFRelease(data); + + CFRelease(avc_info); + } + return config_info; +} + +static CFDictionaryRef videotoolbox_buffer_attributes_create(int width, + int height, + OSType pix_fmt) +{ + CFMutableDictionaryRef buffer_attributes; + CFMutableDictionaryRef io_surface_properties; + CFNumberRef cv_pix_fmt; + CFNumberRef w; + CFNumberRef h; + + w = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &width); + h = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &height); + cv_pix_fmt = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &pix_fmt); + + buffer_attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, + 4, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + io_surface_properties = CFDictionaryCreateMutable(kCFAllocatorDefault, + 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + + CFDictionarySetValue(buffer_attributes, kCVPixelBufferPixelFormatTypeKey, cv_pix_fmt); + CFDictionarySetValue(buffer_attributes, kCVPixelBufferIOSurfacePropertiesKey, io_surface_properties); + CFDictionarySetValue(buffer_attributes, kCVPixelBufferWidthKey, w); + CFDictionarySetValue(buffer_attributes, kCVPixelBufferHeightKey, h); + + CFRelease(io_surface_properties); + CFRelease(cv_pix_fmt); + CFRelease(w); + CFRelease(h); + + return buffer_attributes; +} + +static CMVideoFormatDescriptionRef videotoolbox_format_desc_create(CMVideoCodecType codec_type, + CFDictionaryRef decoder_spec, + int width, + int height) +{ + CMFormatDescriptionRef cm_fmt_desc; + OSStatus status; + + status = CMVideoFormatDescriptionCreate(kCFAllocatorDefault, + codec_type, + width, + height, + decoder_spec, // Dictionary of extension + &cm_fmt_desc); + + if (status) + return NULL; + + return cm_fmt_desc; +} + +static int videotoolbox_default_init(AVCodecContext *avctx) +{ + AVVideotoolboxContext *videotoolbox = avctx->hwaccel_context; + OSStatus status; + VTDecompressionOutputCallbackRecord decoder_cb; + CFDictionaryRef decoder_spec; + CFDictionaryRef buf_attr; + int32_t pix_fmt; + + if (!videotoolbox) { + av_log(avctx, AV_LOG_ERROR, "hwaccel context is not set\n"); + return -1; + } + + switch( avctx->codec_id ) { + case AV_CODEC_ID_H263 : + videotoolbox->cm_codec_type = kCMVideoCodecType_H263; + break; + case AV_CODEC_ID_H264 : + videotoolbox->cm_codec_type = kCMVideoCodecType_H264; + break; + case AV_CODEC_ID_MPEG1VIDEO : + videotoolbox->cm_codec_type = kCMVideoCodecType_MPEG1Video; + break; + case AV_CODEC_ID_MPEG2VIDEO : + videotoolbox->cm_codec_type = kCMVideoCodecType_MPEG2Video; + break; + case AV_CODEC_ID_MPEG4 : + videotoolbox->cm_codec_type = kCMVideoCodecType_MPEG4Video; + break; + default : + break; + } + + pix_fmt = videotoolbox->cv_pix_fmt_type; + + decoder_spec = videotoolbox_decoder_config_create(videotoolbox->cm_codec_type, avctx); + + videotoolbox->cm_fmt_desc = videotoolbox_format_desc_create(videotoolbox->cm_codec_type, + decoder_spec, + avctx->width, + avctx->height); + if (!videotoolbox->cm_fmt_desc) { + if (decoder_spec) + CFRelease(decoder_spec); + + av_log(avctx, AV_LOG_ERROR, "format description creation failed\n"); + return -1; + } + + buf_attr = videotoolbox_buffer_attributes_create(avctx->width, + avctx->height, + videotoolbox->cv_pix_fmt_type); + + decoder_cb.decompressionOutputCallback = videotoolbox_decoder_callback; + decoder_cb.decompressionOutputRefCon = avctx; + + status = VTDecompressionSessionCreate(NULL, // allocator + videotoolbox->cm_fmt_desc, // videoFormatDescription + decoder_spec, // videoDecoderSpecification + buf_attr, // destinationImageBufferAttributes + &decoder_cb, // outputCallback + &videotoolbox->session); // decompressionSessionOut + + if (decoder_spec) + CFRelease(decoder_spec); + if (buf_attr) + CFRelease(buf_attr); + + switch (status) { + case kVTVideoDecoderNotAvailableNowErr: + case kVTVideoDecoderUnsupportedDataFormatErr: + return AVERROR(ENOSYS); + case kVTVideoDecoderMalfunctionErr: + return AVERROR(EINVAL); + case kVTVideoDecoderBadDataErr : + return AVERROR_INVALIDDATA; + case 0: + return 0; + default: + return AVERROR_UNKNOWN; + } +} + +static void videotoolbox_default_free(AVCodecContext *avctx) +{ + AVVideotoolboxContext *videotoolbox = avctx->hwaccel_context; + + if (videotoolbox) { + if (videotoolbox->cm_fmt_desc) + CFRelease(videotoolbox->cm_fmt_desc); + + if (videotoolbox->session) + VTDecompressionSessionInvalidate(videotoolbox->session); + } +} + +AVHWAccel ff_h263_videotoolbox_hwaccel = { + .name = "h263_videotoolbox", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_H263, + .pix_fmt = AV_PIX_FMT_VIDEOTOOLBOX, + .alloc_frame = ff_videotoolbox_alloc_frame, + .start_frame = videotoolbox_mpeg_start_frame, + .decode_slice = videotoolbox_mpeg_decode_slice, + .end_frame = videotoolbox_mpeg_end_frame, + .uninit = ff_videotoolbox_uninit, + .priv_data_size = sizeof(VTContext), +}; + +AVHWAccel ff_h264_videotoolbox_hwaccel = { + .name = "h264_videotoolbox", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_H264, + .pix_fmt = AV_PIX_FMT_VIDEOTOOLBOX, + .alloc_frame = ff_videotoolbox_alloc_frame, + .start_frame = ff_videotoolbox_h264_start_frame, + .decode_slice = ff_videotoolbox_h264_decode_slice, + .end_frame = videotoolbox_h264_end_frame, + .uninit = ff_videotoolbox_uninit, + .priv_data_size = sizeof(VTContext), +}; + +AVHWAccel ff_mpeg1_videotoolbox_hwaccel = { + .name = "mpeg1_videotoolbox", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_MPEG1VIDEO, + .pix_fmt = AV_PIX_FMT_VIDEOTOOLBOX, + .alloc_frame = ff_videotoolbox_alloc_frame, + .start_frame = videotoolbox_mpeg_start_frame, + .decode_slice = videotoolbox_mpeg_decode_slice, + .end_frame = videotoolbox_mpeg_end_frame, + .uninit = ff_videotoolbox_uninit, + .priv_data_size = sizeof(VTContext), +}; + +AVHWAccel ff_mpeg2_videotoolbox_hwaccel = { + .name = "mpeg2_videotoolbox", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_MPEG2VIDEO, + .pix_fmt = AV_PIX_FMT_VIDEOTOOLBOX, + .alloc_frame = ff_videotoolbox_alloc_frame, + .start_frame = videotoolbox_mpeg_start_frame, + .decode_slice = videotoolbox_mpeg_decode_slice, + .end_frame = videotoolbox_mpeg_end_frame, + .uninit = ff_videotoolbox_uninit, + .priv_data_size = sizeof(VTContext), +}; + +AVHWAccel ff_mpeg4_videotoolbox_hwaccel = { + .name = "mpeg4_videotoolbox", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_MPEG4, + .pix_fmt = AV_PIX_FMT_VIDEOTOOLBOX, + .alloc_frame = ff_videotoolbox_alloc_frame, + .start_frame = videotoolbox_mpeg_start_frame, + .decode_slice = videotoolbox_mpeg_decode_slice, + .end_frame = videotoolbox_mpeg_end_frame, + .uninit = ff_videotoolbox_uninit, + .priv_data_size = sizeof(VTContext), +}; + +AVVideotoolboxContext *av_videotoolbox_alloc_context(void) +{ + AVVideotoolboxContext *ret = av_mallocz(sizeof(*ret)); + + if (ret) { + ret->output_callback = videotoolbox_decoder_callback; + ret->cv_pix_fmt_type = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; + } + + return ret; +} + +int av_videotoolbox_default_init(AVCodecContext *avctx) +{ + return av_videotoolbox_default_init2(avctx, NULL); +} + +int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext *vtctx) +{ + avctx->hwaccel_context = vtctx ?: av_videotoolbox_alloc_context(); + if (!avctx->hwaccel_context) + return AVERROR(ENOMEM); + return videotoolbox_default_init(avctx); +} + +void av_videotoolbox_default_free(AVCodecContext *avctx) +{ + + videotoolbox_default_free(avctx); + av_freep(&avctx->hwaccel_context); +} +#endif /* CONFIG_VIDEOTOOLBOX */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/videotoolbox.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/videotoolbox.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/videotoolbox.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/videotoolbox.h 2015-08-03 17:20:02.000000000 +0000 @@ -0,0 +1,126 @@ +/* + * Videotoolbox hardware acceleration + * + * copyright (c) 2012 Sebastien Zwickert + * + * 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 + */ + +#ifndef AVCODEC_VIDEOTOOLBOX_H +#define AVCODEC_VIDEOTOOLBOX_H + +/** + * @file + * @ingroup lavc_codec_hwaccel_videotoolbox + * Public libavcodec Videotoolbox header. + */ + +#include + +#define Picture QuickdrawPicture +#include +#undef Picture + +#include "libavcodec/avcodec.h" + +/** + * This struct holds all the information that needs to be passed + * between the caller and libavcodec for initializing Videotoolbox decoding. + * Its size is not a part of the public ABI, it must be allocated with + * av_videotoolbox_alloc_context() and freed with av_free(). + */ +typedef struct AVVideotoolboxContext { + /** + * Videotoolbox decompression session object. + * Created and freed the caller. + */ + VTDecompressionSessionRef session; + + /** + * The output callback that must be passed to the session. + * Set by av_videottoolbox_default_init() + */ + VTDecompressionOutputCallback output_callback; + + /** + * CVPixelBuffer Format Type that Videotoolbox will use for decoded frames. + * set by the caller. + */ + OSType cv_pix_fmt_type; + + /** + * CoreMedia Format Description that Videotoolbox will use to create the decompression session. + * Set by the caller. + */ + CMVideoFormatDescriptionRef cm_fmt_desc; + + /** + * CoreMedia codec type that Videotoolbox will use to create the decompression session. + * Set by the caller. + */ + int cm_codec_type; +} AVVideotoolboxContext; + +/** + * Allocate and initialize a Videotoolbox context. + * + * This function should be called from the get_format() callback when the caller + * selects the AV_PIX_FMT_VIDETOOLBOX format. The caller must then create + * the decoder object (using the output callback provided by libavcodec) that + * will be used for Videotoolbox-accelerated decoding. + * + * When decoding with Videotoolbox is finished, the caller must destroy the decoder + * object and free the Videotoolbox context using av_free(). + * + * @return the newly allocated context or NULL on failure + */ +AVVideotoolboxContext *av_videotoolbox_alloc_context(void); + +/** + * This is a convenience function that creates and sets up the Videotoolbox context using + * an internal implementation. + * + * @param avctx the corresponding codec context + * + * @return >= 0 on success, a negative AVERROR code on failure + */ +int av_videotoolbox_default_init(AVCodecContext *avctx); + +/** + * This is a convenience function that creates and sets up the Videotoolbox context using + * an internal implementation. + * + * @param avctx the corresponding codec context + * @param vtctx the Videotoolbox context to use + * + * @return >= 0 on success, a negative AVERROR code on failure + */ +int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext *vtctx); + +/** + * This function must be called to free the Videotoolbox context initialized with + * av_videotoolbox_default_init(). + * + * @param avctx the corresponding codec context + */ +void av_videotoolbox_default_free(AVCodecContext *avctx); + +/** + * @} + */ + +#endif /* AVCODEC_VIDEOTOOLBOX_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vima.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vima.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vima.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vima.c 2015-07-28 17:20:07.000000000 +0000 @@ -214,7 +214,7 @@ .id = AV_CODEC_ID_ADPCM_VIMA, .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #if FF_API_VIMA_DECODER @@ -225,6 +225,6 @@ .id = AV_CODEC_ID_ADPCM_VIMA, .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vmdaudio.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vmdaudio.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vmdaudio.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vmdaudio.c 2015-07-28 17:20:07.000000000 +0000 @@ -231,5 +231,5 @@ .priv_data_size = sizeof(VmdAudioContext), .init = vmdaudio_decode_init, .decode = vmdaudio_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vmdvideo.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vmdvideo.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vmdvideo.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vmdvideo.c 2015-07-28 17:20:07.000000000 +0000 @@ -471,5 +471,5 @@ .init = vmdvideo_decode_init, .close = vmdvideo_decode_end, .decode = vmdvideo_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vmnc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vmnc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vmnc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vmnc.c 2015-07-28 17:20:07.000000000 +0000 @@ -577,5 +577,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vorbisdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vorbisdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vorbisdec.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vorbisdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -998,7 +998,7 @@ ff_mdct_init(&vc->mdct[0], bl0, 1, -1.0); ff_mdct_init(&vc->mdct[1], bl1, 1, -1.0); - vc->fdsp = avpriv_float_dsp_alloc(vc->avctx->flags & CODEC_FLAG_BITEXACT); + vc->fdsp = avpriv_float_dsp_alloc(vc->avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!vc->fdsp) return AVERROR(ENOMEM); @@ -1846,7 +1846,7 @@ .close = vorbis_decode_close, .decode = vorbis_decode_frame, .flush = vorbis_decode_flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .channel_layouts = ff_vorbis_channel_layouts, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vorbisenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vorbisenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vorbisenc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vorbisenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -1033,7 +1033,7 @@ return 0; samples = 1 << (venc->log2_blocksize[0] - 1); - if ((ret = ff_alloc_packet2(avctx, avpkt, 8192)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, 8192, 0)) < 0) return ret; init_put_bits(&pb, avpkt->data, avpkt->size); @@ -1178,7 +1178,7 @@ goto error; avctx->bit_rate = 0; - if (avctx->flags & CODEC_FLAG_QSCALE) + if (avctx->flags & AV_CODEC_FLAG_QSCALE) venc->quality = avctx->global_quality / (float)FF_QP2LAMBDA; else venc->quality = 8; @@ -1205,7 +1205,7 @@ .init = vorbis_encode_init, .encode2 = vorbis_encode_frame, .close = vorbis_encode_close, - .capabilities = CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_EXPERIMENTAL, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp3.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp3.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp3.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp3.c 2015-07-28 17:20:07.000000000 +0000 @@ -1095,7 +1095,7 @@ return residual_eob_run; /* reverse prediction of the C-plane DC coefficients */ - if (!(s->avctx->flags & CODEC_FLAG_GRAY)) { + if (!(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { reverse_dc_prediction(s, s->fragment_start[1], s->fragment_width[1], s->fragment_height[1]); reverse_dc_prediction(s, s->fragment_start[2], @@ -1518,7 +1518,7 @@ if (!s->flipped_image) stride = -stride; - if (CONFIG_GRAY && plane && (s->avctx->flags & CODEC_FLAG_GRAY)) + if (CONFIG_GRAY && plane && (s->avctx->flags & AV_CODEC_FLAG_GRAY)) continue; /* for each superblock row in the slice (both of them)... */ @@ -1738,7 +1738,7 @@ if (avctx->codec_id != AV_CODEC_ID_THEORA) avctx->pix_fmt = AV_PIX_FMT_YUV420P; avctx->chroma_sample_location = AVCHROMA_LOC_CENTER; - ff_hpeldsp_init(&s->hdsp, avctx->flags | CODEC_FLAG_BITEXACT); + ff_hpeldsp_init(&s->hdsp, avctx->flags | AV_CODEC_FLAG_BITEXACT); ff_videodsp_init(&s->vdsp, 8); ff_vp3dsp_init(&s->vp3dsp, avctx->flags); @@ -1947,6 +1947,8 @@ } if (s != s1) { + if (!s->current_frame.f) + return AVERROR(ENOMEM); // init tables if the first frame hasn't been decoded if (!s->current_frame.f->data[0]) { int y_fragment_count, c_fragment_count; @@ -2324,7 +2326,7 @@ ret = ff_set_dimensions(avctx, s->width, s->height); if (ret < 0) return ret; - if (!(avctx->flags2 & CODEC_FLAG2_IGNORE_CROP)) { + if (!(avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP)) { avctx->width = visible_width; avctx->height = visible_height; // translate offsets from theora axis ([0,0] lower left) @@ -2332,7 +2334,7 @@ s->offset_x = offset_x; s->offset_y = s->height - visible_height - offset_y; - if ((s->offset_x & 0x1F) && !(avctx->flags & CODEC_FLAG_UNALIGNED)) { + if ((s->offset_x & 0x1F) && !(avctx->flags & AV_CODEC_FLAG_UNALIGNED)) { s->offset_x &= ~0x1F; if (!s->offset_x_warned) { s->offset_x_warned = 1; @@ -2542,8 +2544,8 @@ .init = theora_decode_init, .close = vp3_decode_end, .decode = vp3_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | - CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DRAW_HORIZ_BAND | + AV_CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context) @@ -2559,8 +2561,8 @@ .init = vp3_decode_init, .close = vp3_decode_end, .decode = vp3_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | - CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DRAW_HORIZ_BAND | + AV_CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context), diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp5.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp5.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp5.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp5.c 2015-07-28 17:20:07.000000000 +0000 @@ -290,5 +290,5 @@ .init = vp5_decode_init, .close = ff_vp56_free, .decode = ff_vp56_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp6.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp6.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp6.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp6.c 2015-07-28 17:20:07.000000000 +0000 @@ -679,7 +679,7 @@ .init = vp6_decode_init, .close = vp6_decode_free, .decode = ff_vp56_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; /* flash version, not flipped upside-down */ @@ -692,7 +692,7 @@ .init = vp6_decode_init, .close = vp6_decode_free, .decode = ff_vp56_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; /* flash version, not flipped upside-down, with alpha channel */ @@ -705,5 +705,5 @@ .init = vp6_decode_init, .close = vp6_decode_free, .decode = ff_vp56_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp8.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp8.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp8.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp8.c 2015-07-28 17:20:07.000000000 +0000 @@ -639,6 +639,11 @@ int width = s->avctx->width; int height = s->avctx->height; + if (buf_size < 3) { + av_log(s->avctx, AV_LOG_ERROR, "Insufficent data (%d) for header\n", buf_size); + return AVERROR_INVALIDDATA; + } + s->keyframe = !(buf[0] & 1); s->profile = (buf[0]>>1) & 7; s->invisible = !(buf[0] & 0x10); @@ -2689,6 +2694,9 @@ VP8Context *s = avctx->priv_data; int i; + if (!s) + return 0; + vp8_decode_flush_impl(avctx, 1); for (i = 0; i < FF_ARRAY_ELEMS(s->frames); i++) av_frame_free(&s->frames[i].tf.f); @@ -2819,7 +2827,7 @@ .init = vp7_decode_init, .close = ff_vp8_decode_free, .decode = vp7_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .flush = vp8_decode_flush, }; #endif /* CONFIG_VP7_DECODER */ @@ -2834,7 +2842,8 @@ .init = ff_vp8_decode_init, .close = ff_vp8_decode_free, .decode = ff_vp8_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_SLICE_THREADS, .flush = vp8_decode_flush, .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp8_decode_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp8_decode_update_thread_context), diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp8dsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp8dsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp8dsp.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp8dsp.c 2015-08-04 17:20:03.000000000 +0000 @@ -735,5 +735,7 @@ ff_vp8dsp_init_arm(dsp); if (ARCH_X86) ff_vp8dsp_init_x86(dsp); + if (ARCH_MIPS) + ff_vp8dsp_init_mips(dsp); } #endif /* CONFIG_VP8_DECODER */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp8dsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp8dsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp8dsp.h 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp8dsp.h 2015-08-04 17:20:03.000000000 +0000 @@ -98,6 +98,7 @@ void ff_vp8dsp_init(VP8DSPContext *c); void ff_vp8dsp_init_arm(VP8DSPContext *c); void ff_vp8dsp_init_x86(VP8DSPContext *c); +void ff_vp8dsp_init_mips(VP8DSPContext *c); #define IS_VP7 1 #define IS_VP8 0 diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp9.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp9.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp9.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp9.c 2015-07-28 17:20:07.000000000 +0000 @@ -425,7 +425,7 @@ // differential forward probability updates static int update_prob(VP56RangeCoder *c, int p) { - static const int inv_map_table[254] = { + static const int 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, @@ -444,7 +444,7 @@ 207, 208, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, - 252, 253, + 252, 253, 253, }; int d; @@ -474,6 +474,7 @@ if (d >= 65) d = (d << 1) - 65 + vp8_rac_get(c); d += 64; + av_assert2(d < FF_ARRAY_ELEMS(inv_map_table)); } return p <= 128 ? 1 + inv_recenter_nonneg(inv_map_table[d], p - 1) : @@ -594,7 +595,7 @@ av_log(ctx, AV_LOG_ERROR, "Invalid sync code\n"); return AVERROR_INVALIDDATA; } - if (ctx->profile == 1) { + if (ctx->profile >= 1) { if ((fmt = read_colorspace_details(ctx)) < 0) return fmt; } else { @@ -732,6 +733,8 @@ s->uvac_qdelta = get_bits1(&s->gb) ? get_sbits_inv(&s->gb, 4) : 0; s->lossless = s->yac_qi == 0 && s->ydc_qdelta == 0 && s->uvdc_qdelta == 0 && s->uvac_qdelta == 0; + if (s->lossless) + ctx->properties |= FF_CODEC_PROPERTY_LOSSLESS; /* segmentation header info */ s->segmentation.ignore_refmap = 0; @@ -4355,7 +4358,7 @@ .init = vp9_decode_init, .close = vp9_decode_free, .decode = vp9_decode_frame, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .flush = vp9_decode_flush, .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp9_decode_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp9_decode_update_thread_context), diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp9dsp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp9dsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp9dsp.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp9dsp.c 2015-07-16 17:20:02.000000000 +0000 @@ -37,4 +37,5 @@ } if (ARCH_X86) ff_vp9dsp_init_x86(dsp, bpp); + if (ARCH_MIPS) ff_vp9dsp_init_mips(dsp, bpp); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp9dsp.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp9dsp.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vp9dsp.h 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vp9dsp.h 2015-07-16 17:20:02.000000000 +0000 @@ -127,5 +127,6 @@ void ff_vp9dsp_init_12(VP9DSPContext *dsp); void ff_vp9dsp_init_x86(VP9DSPContext *dsp, int bpp); +void ff_vp9dsp_init_mips(VP9DSPContext *dsp, int bpp); #endif /* AVCODEC_VP9DSP_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/vqavideo.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/vqavideo.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/vqavideo.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/vqavideo.c 2015-07-28 17:20:07.000000000 +0000 @@ -650,5 +650,5 @@ .init = vqa_decode_init, .close = vqa_decode_end, .decode = vqa_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/wavpack.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/wavpack.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/wavpack.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/wavpack.c 2015-07-28 17:20:07.000000000 +0000 @@ -155,7 +155,7 @@ if (t >= 2) { if (get_bits_left(gb) < t - 1) goto error; - t = get_bits(gb, t - 1) | (1 << (t - 1)); + t = get_bits_long(gb, t - 1) | (1 << (t - 1)); } else { if (get_bits_left(gb) < 0) goto error; @@ -186,7 +186,7 @@ } else { if (get_bits_left(gb) < t2 - 1) goto error; - t += get_bits(gb, t2 - 1) | (1 << (t2 - 1)); + t += get_bits_long(gb, t2 - 1) | (1 << (t2 - 1)); } } @@ -271,7 +271,7 @@ if (s->got_extra_bits && get_bits_left(&s->gb_extra_bits) >= s->extra_bits) { - S |= get_bits(&s->gb_extra_bits, s->extra_bits); + S |= get_bits_long(&s->gb_extra_bits, s->extra_bits); *crc = *crc * 9 + (S & 0xffff) * 3 + ((unsigned)S >> 16); } } @@ -299,7 +299,7 @@ const int max_bits = 1 + 23 + 8 + 1; const int left_bits = get_bits_left(&s->gb_extra_bits); - if (left_bits + 8 * FF_INPUT_BUFFER_PADDING_SIZE < max_bits) + if (left_bits + 8 * AV_INPUT_BUFFER_PADDING_SIZE < max_bits) return 0.0; } @@ -835,7 +835,11 @@ continue; } bytestream2_get_buffer(&gb, val, 4); - if (val[0]) { + if (val[0] > 32) { + av_log(avctx, AV_LOG_ERROR, + "Invalid INT32INFO, extra_bits = %d (> 32)\n", val[0]); + continue; + } else if (val[0]) { s->extra_bits = val[0]; } else if (val[1]) { s->shift = val[1]; @@ -1121,5 +1125,5 @@ .decode = wavpack_decode_frame, .flush = wavpack_decode_flush, .init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy), - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/wavpackenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/wavpackenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/wavpackenc.c 2015-06-19 20:44:45.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/wavpackenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -2879,7 +2879,7 @@ buf_size = s->block_samples * avctx->channels * 8 + 200 /* for headers */; - if ((ret = ff_alloc_packet2(avctx, avpkt, buf_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, buf_size, 0)) < 0) return ret; buf = avpkt->data; @@ -2982,7 +2982,7 @@ .init = wavpack_encode_init, .encode2 = wavpack_encode_frame, .close = wavpack_encode_close, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME, + .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S32P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/webp.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/webp.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/webp.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/webp.c 2015-07-28 17:20:07.000000000 +0000 @@ -1387,7 +1387,7 @@ } av_dict_free(&s->exif_metadata); - while (bytestream2_get_bytes_left(&gb) > 0) { + while (bytestream2_get_bytes_left(&gb) > 8) { char chunk_str[5] = { 0 }; chunk_type = bytestream2_get_le32(&gb); @@ -1417,6 +1417,7 @@ chunk_size, 0); if (ret < 0) return ret; + avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS; } bytestream2_skip(&gb, chunk_size); break; @@ -1539,5 +1540,5 @@ .priv_data_size = sizeof(WebPContext), .decode = webp_decode_frame, .close = webp_decode_close, - .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/wma.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/wma.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/wma.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/wma.c 2015-07-28 17:20:07.000000000 +0000 @@ -338,7 +338,7 @@ #endif /* TRACE */ } - s->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!s->fdsp) return AVERROR(ENOMEM); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmadec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmadec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmadec.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmadec.c 2015-07-28 17:20:07.000000000 +0000 @@ -854,7 +854,7 @@ *q++ = get_bits (&s->gb, 8); len --; } - memset(q, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(q, 0, AV_INPUT_BUFFER_PADDING_SIZE); s->last_superframe_len += 8*buf_size - 8; // s->reset_block_lengths = 1; //XXX is this needed ? @@ -893,7 +893,7 @@ } if (len > 0) *q++ = (get_bits) (&s->gb, len) << (8 - len); - memset(q, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(q, 0, AV_INPUT_BUFFER_PADDING_SIZE); /* XXX: bit_offset bits into last frame */ init_get_bits(&s->gb, s->last_superframe, @@ -977,7 +977,7 @@ .close = ff_wma_end, .decode = wma_decode_superframe, .flush = flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; @@ -993,7 +993,7 @@ .close = ff_wma_end, .decode = wma_decode_superframe, .flush = flush, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmaenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmaenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmaenc.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmaenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -377,7 +377,7 @@ } } - if ((ret = ff_alloc_packet2(avctx, avpkt, 2 * MAX_CODED_SUPERFRAME_SIZE)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, 2 * MAX_CODED_SUPERFRAME_SIZE, 0)) < 0) return ret; total_gain = 128; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/wma.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/wma.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/wma.h 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/wma.h 2015-07-28 17:20:07.000000000 +0000 @@ -120,7 +120,7 @@ /* output buffer for one frame and the last for IMDCT windowing */ DECLARE_ALIGNED(32, float, frame_out)[MAX_CHANNELS][BLOCK_MAX_SIZE * 2]; /* last frame info */ - uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; /* padding added */ + uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; /* padding added */ int last_bitoffset; int last_superframe_len; float noise_table[NOISE_TAB_SIZE]; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmalosslessdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmalosslessdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmalosslessdec.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmalosslessdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -72,7 +72,7 @@ AVCodecContext *avctx; AVFrame *frame; LLAudDSPContext dsp; ///< accelerated DSP functions - uint8_t frame_data[MAX_FRAMESIZE + FF_INPUT_BUFFER_PADDING_SIZE]; ///< compressed frame data + uint8_t frame_data[MAX_FRAMESIZE + AV_INPUT_BUFFER_PADDING_SIZE]; ///< compressed frame data PutBitContext pb; ///< context for filling the frame_data buffer /* frame size dependent frame information (set during initialization) */ @@ -488,7 +488,7 @@ if ((1 << cbits) < s->cdlms[c][i].scaling + 1) cbits++; - s->cdlms[c][i].bitsend = get_bits(&s->gb, cbits) + 2; + s->cdlms[c][i].bitsend = (cbits ? get_bits(&s->gb, cbits) : 0) + 2; shift_l = 32 - s->cdlms[c][i].bitsend; shift_r = 32 - s->cdlms[c][i].scaling - 2; for (j = 0; j < s->cdlms[c][i].coefsend; j++) @@ -1005,6 +1005,7 @@ if ((ret = ff_get_buffer(s->avctx, s->frame, 0)) < 0) { /* return an error if no frame could be decoded at all */ s->packet_loss = 1; + s->frame->nb_samples = 0; return ret; } for (i = 0; i < s->num_channels; i++) { @@ -1298,7 +1299,7 @@ .close = decode_close, .decode = decode_packet, .flush = flush, - .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1 | CODEC_CAP_DELAY, + .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmaprodec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmaprodec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmaprodec.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmaprodec.c 2015-07-28 17:20:07.000000000 +0000 @@ -173,7 +173,7 @@ AVCodecContext* avctx; ///< codec context for av_log AVFloatDSPContext *fdsp; uint8_t frame_data[MAX_FRAMESIZE + - FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data + AV_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data PutBitContext pb; ///< context for filling the frame_data buffer FFTContext mdct_ctx[WMAPRO_BLOCK_SIZES]; ///< MDCT context per block size DECLARE_ALIGNED(32, float, tmp)[WMAPRO_BLOCK_MAX_SIZE]; ///< IMDCT output buffer @@ -288,7 +288,7 @@ } s->avctx = avctx; - s->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT); + s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!s->fdsp) return AVERROR(ENOMEM); @@ -1666,7 +1666,7 @@ .init = decode_init, .close = decode_end, .decode = decode_packet, - .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1, .flush = flush, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmavoice.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmavoice.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmavoice.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmavoice.c 2015-07-28 17:20:07.000000000 +0000 @@ -203,7 +203,7 @@ ///< to #wmavoice_decode_packet() (since ///< they're part of the previous superframe) - uint8_t sframe_cache[SFRAME_CACHE_MAXSIZE + FF_INPUT_BUFFER_PADDING_SIZE]; + uint8_t sframe_cache[SFRAME_CACHE_MAXSIZE + AV_INPUT_BUFFER_PADDING_SIZE]; ///< cache for superframe data split over ///< multiple packets int sframe_cache_size; ///< set to >0 if we have data from an @@ -1982,7 +1982,14 @@ *got_frame_ptr) { cnt += s->spillover_nbits; s->skip_bits_next = cnt & 7; - return cnt >> 3; + res = cnt >> 3; + if (res > avpkt->size) { + av_log(ctx, AV_LOG_ERROR, + "Trying to skip %d bytes in packet of size %d\n", + res, avpkt->size); + return AVERROR_INVALIDDATA; + } + return res; } else skip_bits_long (gb, s->spillover_nbits - cnt + get_bits_count(gb)); // resync @@ -2001,7 +2008,14 @@ } else if (*got_frame_ptr) { int cnt = get_bits_count(gb); s->skip_bits_next = cnt & 7; - return cnt >> 3; + res = cnt >> 3; + if (res > avpkt->size) { + av_log(ctx, AV_LOG_ERROR, + "Trying to skip %d bytes in packet of size %d\n", + res, avpkt->size); + return AVERROR_INVALIDDATA; + } + return res; } else if ((s->sframe_cache_size = pos) > 0) { /* rewind bit reader to start of last (incomplete) superframe... */ init_get_bits(gb, avpkt->data, size << 3); @@ -2070,6 +2084,6 @@ .init_static_data = wmavoice_init_static_data, .close = wmavoice_decode_end, .decode = wmavoice_decode_packet, - .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1, .flush = wmavoice_flush, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmv2.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmv2.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmv2.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmv2.c 2015-07-28 17:20:07.000000000 +0000 @@ -89,7 +89,7 @@ wmv2_add_block(w, block1[2], dest_y + 8 * s->linesize, s->linesize, 2); wmv2_add_block(w, block1[3], dest_y + 8 + 8 * s->linesize, s->linesize, 3); - if (s->avctx->flags & CODEC_FLAG_GRAY) + if (s->avctx->flags & AV_CODEC_FLAG_GRAY) return; wmv2_add_block(w, block1[4], dest_cb, s->uvlinesize, 4); @@ -141,7 +141,7 @@ w->wdsp.put_mspel_pixels_tab[dxy](dest_y + 8 * linesize, ptr + 8 * linesize, linesize); w->wdsp.put_mspel_pixels_tab[dxy](dest_y + 8 + 8 * linesize, ptr + 8 + 8 * linesize, linesize); - if (s->avctx->flags & CODEC_FLAG_GRAY) + if (s->avctx->flags & AV_CODEC_FLAG_GRAY) return; dxy = 0; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmv2dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmv2dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmv2dec.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmv2dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -482,7 +482,7 @@ .init = wmv2_decode_init, .close = wmv2_decode_end, .decode = ff_h263_decode_frame, - .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmv2enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmv2enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/wmv2enc.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/wmv2enc.c 2015-07-28 17:20:07.000000000 +0000 @@ -62,9 +62,10 @@ ff_wmv2_common_init(w); avctx->extradata_size = 4; - avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) return AVERROR(ENOMEM); + encode_ext_header(w); return 0; @@ -213,7 +214,12 @@ s->p_tex_bits += get_bits_diff(s); } -FF_MPV_GENERIC_CLASS(wmv2) +static const AVClass wmv2_class = { + .class_name = "wmv2 encoder", + .item_name = av_default_item_name, + .option = ff_mpv_generic_options, + .version = LIBAVUTIL_VERSION_INT, +}; AVCodec ff_wmv2_encoder = { .name = "wmv2", @@ -221,6 +227,7 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_WMV2, .priv_data_size = sizeof(Wmv2Context), + .priv_class = &wmv2_class, .init = wmv2_encode_init, .encode2 = ff_mpv_encode_picture, .close = ff_mpv_encode_end, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/wnv1.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/wnv1.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/wnv1.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/wnv1.c 2015-07-28 17:20:07.000000000 +0000 @@ -73,12 +73,12 @@ return AVERROR_INVALIDDATA; } - rbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + rbuf = av_malloc(buf_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!rbuf) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); return AVERROR(ENOMEM); } - memset(rbuf + buf_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(rbuf + buf_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); if ((ret = ff_get_buffer(avctx, p, 0)) < 0) { av_free(rbuf); @@ -155,5 +155,5 @@ .priv_data_size = sizeof(WNV1Context), .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/ws-snd1.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/ws-snd1.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/ws-snd1.c 2015-06-18 18:55:01.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/ws-snd1.c 2015-07-28 17:20:07.000000000 +0000 @@ -177,5 +177,5 @@ .id = AV_CODEC_ID_WESTWOOD_SND1, .init = ws_snd_decode_init, .decode = ws_snd_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/aacpsdsp.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/aacpsdsp.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/aacpsdsp.asm 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/aacpsdsp.asm 2015-07-31 17:20:05.000000000 +0000 @@ -0,0 +1,215 @@ +;****************************************************************************** +;* SIMD optimized MPEG-4 Parametric Stereo decoding functions +;* +;* Copyright (C) 2015 James Almer +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "libavutil/x86/x86util.asm" + +SECTION_RODATA + +ps_p1m1p1m1: dd 0, 0x80000000, 0, 0x80000000 + +SECTION_TEXT + +;************************************************************************* +;void ff_ps_add_squares_(float *dst, const float (*src)[2], int n); +;************************************************************************* +%macro PS_ADD_SQUARES 1 +cglobal ps_add_squares, 3, 3, %1, dst, src, n +.loop: + movaps m0, [srcq] + movaps m1, [srcq+mmsize] + mulps m0, m0 + mulps m1, m1 +%if cpuflag(sse3) + haddps m0, m1 +%else + movaps m3, m0 + movaps m4, m1 + shufps m3, m3, q0301 + shufps m4, m4, q0301 + addps m0, m3 + addps m1, m4 + shufps m0, m1, q2020 +%endif + addps m0, [dstq] + movaps [dstq], m0 + add dstq, mmsize + add srcq, mmsize*2 + sub nd, mmsize/4 + jg .loop + REP_RET +%endmacro + +INIT_XMM sse +PS_ADD_SQUARES 3 +INIT_XMM sse3 +PS_ADD_SQUARES 5 + +;******************************************************************* +;void ff_ps_mul_pair_single_sse(float (*dst)[2], float (*src0)[2], +; float *src1, int n); +;******************************************************************* +INIT_XMM sse +cglobal ps_mul_pair_single, 4, 5, 4, dst, src1, src2, n + xor r4q, r4q + +.loop: + movu m0, [src1q+r4q] + movu m1, [src1q+r4q+mmsize] + mova m2, [src2q] + mova m3, m2 + unpcklps m2, m2 + unpckhps m3, m3 + mulps m0, m2 + mulps m1, m3 + mova [dstq+r4q], m0 + mova [dstq+r4q+mmsize], m1 + add src2q, mmsize + add r4q, mmsize*2 + sub nd, mmsize/4 + jg .loop + REP_RET + +;*********************************************************************** +;void ff_ps_stereo_interpolate_sse3(float (*l)[2], float (*r)[2], +; float h[2][4], float h_step[2][4], +; int len); +;*********************************************************************** +INIT_XMM sse3 +cglobal ps_stereo_interpolate, 5, 5, 6, l, r, h, h_step, n + movaps m0, [hq] + movaps m1, [h_stepq] + cmp nd, 0 + jle .ret + shl nd, 3 + add lq, nq + add rq, nq + neg nq + +align 16 +.loop: + addps m0, m1 + movddup m2, [lq+nq] + movddup m3, [rq+nq] + movaps m4, m0 + movaps m5, m0 + unpcklps m4, m4 + unpckhps m5, m5 + mulps m2, m4 + mulps m3, m5 + addps m2, m3 + movsd [lq+nq], m2 + movhps [rq+nq], m2 + add nq, 8 + jl .loop +.ret: + REP_RET + +;******************************************************************* +;void ff_ps_hybrid_analysis_(float (*out)[2], float (*in)[2], +; const float (*filter)[8][2], +; int stride, int n); +;******************************************************************* +%macro PS_HYBRID_ANALYSIS_LOOP 3 + movu %1, [inq+mmsize*%3] + movu m1, [inq+mmsize*(5-%3)+8] +%if cpuflag(sse3) + pshufd %2, %1, q2301 + pshufd m4, m1, q0123 + pshufd m1, m1, q1032 + pshufd m2, [filterq+nq+mmsize*%3], q2301 + addsubps %2, m4 + addsubps %1, m1 +%else + mova m2, [filterq+nq+mmsize*%3] + mova %2, %1 + mova m4, m1 + shufps %2, %2, q2301 + shufps m4, m4, q0123 + shufps m1, m1, q1032 + shufps m2, m2, q2301 + xorps m4, m7 + xorps m1, m7 + subps %2, m4 + subps %1, m1 +%endif + mulps %2, m2 + mulps %1, m2 +%if %3 + addps m3, %2 + addps m0, %1 +%endif +%endmacro + +%macro PS_HYBRID_ANALYSIS 0 +cglobal ps_hybrid_analysis, 5, 5, 8, out, in, filter, stride, n +%if cpuflag(sse3) +%define MOVH movsd +%else +%define MOVH movlps +%endif + shl strided, 3 + shl nd, 6 + add filterq, nq + neg nq + mova m7, [ps_p1m1p1m1] + +align 16 +.loop: + PS_HYBRID_ANALYSIS_LOOP m0, m3, 0 + PS_HYBRID_ANALYSIS_LOOP m5, m6, 1 + PS_HYBRID_ANALYSIS_LOOP m5, m6, 2 + +%if cpuflag(sse3) + pshufd m3, m3, q2301 + xorps m0, m7 + hsubps m3, m0 + pshufd m1, m3, q0020 + pshufd m3, m3, q0031 + addps m1, m3 + movsd m2, [inq+6*8] +%else + mova m1, m3 + mova m2, m0 + shufps m1, m1, q2301 + shufps m2, m2, q2301 + subps m1, m3 + addps m2, m0 + unpcklps m3, m1, m2 + unpckhps m1, m2 + addps m1, m3 + movu m2, [inq+6*8] ; faster than movlps and no risk of overread +%endif + movss m3, [filterq+nq+8*6] + SPLATD m3 + mulps m2, m3 + addps m1, m2 + MOVH [outq], m1 + add outq, strideq + add nq, 64 + jl .loop + REP_RET +%endmacro + +INIT_XMM sse +PS_HYBRID_ANALYSIS +INIT_XMM sse3 +PS_HYBRID_ANALYSIS diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/aacpsdsp_init.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/aacpsdsp_init.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/aacpsdsp_init.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/aacpsdsp_init.c 2015-07-31 17:20:05.000000000 +0000 @@ -0,0 +1,55 @@ +/* + * SIMD optimized MPEG-4 Parametric Stereo decoding functions + * + * 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 "config.h" + +#include "libavutil/x86/cpu.h" +#include "libavutil/attributes.h" +#include "libavcodec/aacpsdsp.h" + +void ff_ps_add_squares_sse (float *dst, const float (*src)[2], int n); +void ff_ps_add_squares_sse3 (float *dst, const float (*src)[2], int n); +void ff_ps_mul_pair_single_sse (float (*dst)[2], float (*src0)[2], + float *src1, int n); +void ff_ps_hybrid_analysis_sse (float (*out)[2], float (*in)[2], + const float (*filter)[8][2], + int stride, int n); +void ff_ps_hybrid_analysis_sse3(float (*out)[2], float (*in)[2], + const float (*filter)[8][2], + int stride, int n); +void ff_ps_stereo_interpolate_sse3(float (*l)[2], float (*r)[2], + float h[2][4], float h_step[2][4], + int len); + +av_cold void ff_psdsp_init_x86(PSDSPContext *s) +{ + int cpu_flags = av_get_cpu_flags(); + + if (EXTERNAL_SSE(cpu_flags)) { + s->add_squares = ff_ps_add_squares_sse; + s->mul_pair_single = ff_ps_mul_pair_single_sse; + s->hybrid_analysis = ff_ps_hybrid_analysis_sse; + } + if (EXTERNAL_SSE3(cpu_flags)) { + s->add_squares = ff_ps_add_squares_sse3; + s->stereo_interpolate[0] = ff_ps_stereo_interpolate_sse3; + s->hybrid_analysis = ff_ps_hybrid_analysis_sse3; + } +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/blockdsp.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/blockdsp.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/blockdsp.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/blockdsp.asm 2015-07-26 17:20:03.000000000 +0000 @@ -64,7 +64,7 @@ add blocksq, 768 mov lenq, -768 ZERO m0, m0 -.loop +.loop: mova [blocksq+lenq+mmsize*0], m0 mova [blocksq+lenq+mmsize*1], m0 mova [blocksq+lenq+mmsize*2], m0 diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/bswapdsp.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/bswapdsp.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/bswapdsp.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/bswapdsp.asm 2015-07-18 17:20:03.000000000 +0000 @@ -32,8 +32,8 @@ ; %1 = aligned/unaligned %macro BSWAP_LOOPS 1 - mov r3, r2 - sar r2, 3 + mov r3d, r2d + sar r2d, 3 jz .left4_%1 .loop8_%1: mov%1 m0, [r1 + 0] @@ -61,11 +61,11 @@ %endif add r0, 32 add r1, 32 - dec r2 + dec r2d jnz .loop8_%1 .left4_%1: - mov r2, r3 - and r3, 4 + mov r2d, r3d + test r3d, 4 jz .left mov%1 m0, [r1] %if cpuflag(ssse3) @@ -95,7 +95,7 @@ mov r3, r1 %endif or r3, r0 - and r3, 15 + test r3, 15 jz .start_align BSWAP_LOOPS u jmp .left @@ -103,8 +103,7 @@ BSWAP_LOOPS a .left: %if cpuflag(ssse3) - mov r3, r2 - and r2, 2 + test r2d, 2 jz .left1 movq m0, [r1] pshufb m0, m2 @@ -112,13 +111,13 @@ add r1, 8 add r0, 8 .left1: - and r3, 1 + test r2d, 1 jz .end mov r2d, [r1] bswap r2d mov [r0], r2d %else - and r2, 3 + and r2d, 3 jz .end .loop2: mov r3d, [r1] @@ -126,7 +125,7 @@ mov [r0], r3d add r1, 4 add r0, 4 - dec r2 + dec r2d jnz .loop2 %endif .end: diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/dcadsp.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/dcadsp.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/dcadsp.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/dcadsp.asm 2015-07-26 17:20:03.000000000 +0000 @@ -333,7 +333,7 @@ %if ARCH_X86_32 mov buf2, synth_buf2mp %endif -.mainloop +.mainloop: ; m1 = a m2 = b m3 = c m4 = d SETZERO m3 SETZERO m4 diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/dct32.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/dct32.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/dct32.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/dct32.asm 2015-08-02 17:20:02.000000000 +0000 @@ -488,5 +488,6 @@ INIT_XMM sse DCT32_FUNC %endif + INIT_XMM sse2 DCT32_FUNC diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/dct_init.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/dct_init.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/dct_init.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/dct_init.c 2015-08-02 17:20:02.000000000 +0000 @@ -30,8 +30,10 @@ { int cpu_flags = av_get_cpu_flags(); - if (ARCH_X86_32 && EXTERNAL_SSE(cpu_flags)) +#if ARCH_X86_32 + if (EXTERNAL_SSE(cpu_flags)) s->dct32 = ff_dct32_float_sse; +#endif if (EXTERNAL_SSE2(cpu_flags)) s->dct32 = ff_dct32_float_sse2; if (EXTERNAL_AVX_FAST(cpu_flags)) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/diracdsp_yasm.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/diracdsp_yasm.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/diracdsp_yasm.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/diracdsp_yasm.asm 2015-07-26 17:20:03.000000000 +0000 @@ -149,7 +149,7 @@ %define hd r5mp %endif -.loopy +.loopy: lea src2q, [srcq+src_strideq*2] lea dst2q, [dstq+dst_strideq] .loopx: diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/flacdsp.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/flacdsp.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/flacdsp.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/flacdsp.asm 2015-08-04 17:20:03.000000000 +0000 @@ -25,6 +25,15 @@ SECTION .text +%macro PMACSDQL 5 +%if cpuflag(xop) + pmacsdql %1, %2, %3, %1 +%else + pmuldq %2, %3 + paddq %1, %2 +%endif +%endmacro + %macro LPC_32 1 INIT_XMM %1 cglobal flac_lpc_32, 5,6,5, decoded, coeffs, pred_order, qlevel, len, j diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/h264_qpel_10bit.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/h264_qpel_10bit.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/h264_qpel_10bit.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/h264_qpel_10bit.asm 2015-07-26 17:20:03.000000000 +0000 @@ -386,7 +386,7 @@ ; void ff_h264_qpel_mc02(uint8_t *dst, uint8_t *src, int stride) ;----------------------------------------------------------------------------- %macro V_FILT 10 -v_filt%9_%10_10 +v_filt%9_%10_10: add r4, r2 .no_addr4: FILT_V m0, m1, m2, m3, m4, m5, m6, m7 diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/h264_qpel.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/h264_qpel.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/h264_qpel.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/h264_qpel.c 2015-06-13 17:20:02.000000000 +0000 @@ -23,8 +23,8 @@ #include "libavutil/cpu.h" #include "libavutil/x86/asm.h" #include "libavutil/x86/cpu.h" +#include "libavcodec/h264.h" #include "libavcodec/h264qpel.h" -#include "libavcodec/mpegvideo.h" #include "libavcodec/pixels.h" #include "fpel.h" diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/h264_weight.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/h264_weight.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/h264_weight.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/h264_weight.asm 2015-07-26 17:20:03.000000000 +0000 @@ -136,15 +136,15 @@ or off_regd, 1 add r4, 1 cmp r6d, 128 - je .nonnormal + je .nonnormal cmp r5, 128 - jne .normal -.nonnormal + jne .normal +.nonnormal: sar r5, 1 sar r6, 1 sar off_regd, 1 sub r4, 1 -.normal +.normal: %if cpuflag(ssse3) movd m4, r5d movd m0, r6d diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/hevc_mc.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/hevc_mc.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/hevc_mc.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/hevc_mc.asm 2015-07-26 17:20:03.000000000 +0000 @@ -683,7 +683,7 @@ %macro HEVC_PEL_PIXELS 2 cglobal hevc_put_hevc_pel_pixels%1_%2, 4, 4, 3, dst, src, srcstride,height pxor m2, m2 -.loop +.loop: SIMPLE_LOAD %1, %2, srcq, m0 MC_PIXEL_COMPUTE %1, %2, 1 PEL_10STORE%1 dstq, m0, m1 @@ -693,7 +693,7 @@ %macro HEVC_UNI_PEL_PIXELS 2 cglobal hevc_put_hevc_uni_pel_pixels%1_%2, 5, 5, 2, dst, dststride, src, srcstride,height -.loop +.loop: SIMPLE_LOAD %1, %2, srcq, m0 PEL_%2STORE%1 dstq, m0, m1 add dstq, dststrideq ; dst += dststride @@ -707,7 +707,7 @@ cglobal hevc_put_hevc_bi_pel_pixels%1_%2, 6, 6, 6, dst, dststride, src, srcstride, src2, height pxor m2, m2 movdqa m5, [pw_bi_%2] -.loop +.loop: SIMPLE_LOAD %1, %2, srcq, m0 SIMPLE_BILOAD %1, src2q, m3, m4 MC_PIXEL_COMPUTE %1, %2, 1 @@ -739,7 +739,7 @@ cglobal hevc_put_hevc_epel_h%1_%2, 5, 6, XMM_REGS, dst, src, srcstride, height, mx, rfilter %assign %%stride ((%2 + 7)/8) EPEL_FILTER %2, mx, m4, m5, rfilter -.loop +.loop: EPEL_LOAD %2, srcq-%%stride, %%stride, %1 EPEL_COMPUTE %2, %1, m4, m5, 1 PEL_10STORE%1 dstq, m0, m1 @@ -750,7 +750,7 @@ %assign %%stride ((%2 + 7)/8) movdqa m6, [pw_%2] EPEL_FILTER %2, mx, m4, m5, rfilter -.loop +.loop: EPEL_LOAD %2, srcq-%%stride, %%stride, %1 EPEL_COMPUTE %2, %1, m4, m5 UNI_COMPUTE %1, %2, m0, m1, m6 @@ -764,7 +764,7 @@ cglobal hevc_put_hevc_bi_epel_h%1_%2, 7, 8, XMM_REGS, dst, dststride, src, srcstride, src2, height, mx, rfilter movdqa m6, [pw_bi_%2] EPEL_FILTER %2, mx, m4, m5, rfilter -.loop +.loop: EPEL_LOAD %2, srcq-%%stride, %%stride, %1 EPEL_COMPUTE %2, %1, m4, m5, 1 SIMPLE_BILOAD %1, src2q, m2, m3 @@ -788,7 +788,7 @@ sub srcq, srcstrideq EPEL_FILTER %2, my, m4, m5, r3src lea r3srcq, [srcstrideq*3] -.loop +.loop: EPEL_LOAD %2, srcq, srcstride, %1 EPEL_COMPUTE %2, %1, m4, m5, 1 PEL_10STORE%1 dstq, m0, m1 @@ -801,7 +801,7 @@ sub srcq, srcstrideq EPEL_FILTER %2, my, m4, m5, r3src lea r3srcq, [srcstrideq*3] -.loop +.loop: EPEL_LOAD %2, srcq, srcstride, %1 EPEL_COMPUTE %2, %1, m4, m5 UNI_COMPUTE %1, %2, m0, m1, m6 @@ -819,7 +819,7 @@ sub srcq, srcstrideq EPEL_FILTER %2, my, m4, m5, r3src lea r3srcq, [srcstrideq*3] -.loop +.loop: EPEL_LOAD %2, srcq, srcstride, %1 EPEL_COMPUTE %2, %1, m4, m5, 1 SIMPLE_BILOAD %1, src2q, m2, m3 @@ -866,7 +866,7 @@ %endif SWAP m6, m0 add srcq, srcstrideq -.loop +.loop: EPEL_LOAD %2, srcq-%%stride, %%stride, %1 EPEL_COMPUTE %2, %1, m14, m15 %if (%1 > 8 && (%2 == 8)) @@ -932,7 +932,7 @@ %endif SWAP m6, m0 add srcq, srcstrideq -.loop +.loop: EPEL_LOAD %2, srcq-%%stride, %%stride, %1 EPEL_COMPUTE %2, %1, m14, m15 %if (%1 > 8 && (%2 == 8)) @@ -996,7 +996,7 @@ %endif SWAP m6, m0 add srcq, srcstrideq -.loop +.loop: EPEL_LOAD %2, srcq-%%stride, %%stride, %1 EPEL_COMPUTE %2, %1, m14, m15 %if (%1 > 8 && (%2 == 8)) @@ -1054,7 +1054,7 @@ %macro HEVC_PUT_HEVC_QPEL 2 cglobal hevc_put_hevc_qpel_h%1_%2, 5, 6, 16, dst, src, srcstride, height, mx, rfilter QPEL_FILTER %2, mx -.loop +.loop: QPEL_H_LOAD %2, srcq, %1, 10 QPEL_COMPUTE %1, %2, 1 %if %2 > 8 @@ -1067,7 +1067,7 @@ cglobal hevc_put_hevc_uni_qpel_h%1_%2, 6, 7, 16 , dst, dststride, src, srcstride, height, mx, rfilter mova m9, [pw_%2] QPEL_FILTER %2, mx -.loop +.loop: QPEL_H_LOAD %2, srcq, %1, 10 QPEL_COMPUTE %1, %2 %if %2 > 8 @@ -1084,7 +1084,7 @@ cglobal hevc_put_hevc_bi_qpel_h%1_%2, 7, 8, 16 , dst, dststride, src, srcstride, src2, height, mx, rfilter movdqa m9, [pw_bi_%2] QPEL_FILTER %2, mx -.loop +.loop: QPEL_H_LOAD %2, srcq, %1, 10 QPEL_COMPUTE %1, %2, 1 %if %2 > 8 @@ -1111,7 +1111,7 @@ movifnidn myd, mym lea r3srcq, [srcstrideq*3] QPEL_FILTER %2, my -.loop +.loop: QPEL_V_LOAD %2, srcq, srcstride, %1, r7 QPEL_COMPUTE %1, %2, 1 %if %2 > 8 @@ -1126,7 +1126,7 @@ movdqa m9, [pw_%2] lea r3srcq, [srcstrideq*3] QPEL_FILTER %2, my -.loop +.loop: QPEL_V_LOAD %2, srcq, srcstride, %1, r8 QPEL_COMPUTE %1, %2 %if %2 > 8 @@ -1145,7 +1145,7 @@ movdqa m9, [pw_bi_%2] lea r3srcq, [srcstrideq*3] QPEL_FILTER %2, my -.loop +.loop: QPEL_V_LOAD %2, srcq, srcstride, %1, r9 QPEL_COMPUTE %1, %2, 1 %if %2 > 8 @@ -1209,7 +1209,7 @@ QPEL_HV_COMPUTE %1, %2, mx, ackssdw SWAP m14, m0 add srcq, srcstrideq -.loop +.loop: QPEL_H_LOAD %2, srcq, %1, 15 QPEL_HV_COMPUTE %1, %2, mx, ackssdw SWAP m15, m0 @@ -1285,7 +1285,7 @@ QPEL_HV_COMPUTE %1, %2, mx, ackssdw SWAP m14, m0 add srcq, srcstrideq -.loop +.loop: QPEL_H_LOAD %2, srcq, %1, 15 QPEL_HV_COMPUTE %1, %2, mx, ackssdw SWAP m15, m0 @@ -1366,7 +1366,7 @@ QPEL_HV_COMPUTE %1, %2, mx, ackssdw SWAP m14, m0 add srcq, srcstrideq -.loop +.loop: QPEL_H_LOAD %2, srcq, %1, 15 QPEL_HV_COMPUTE %1, %2, mx, ackssdw SWAP m15, m0 @@ -1444,7 +1444,7 @@ %if WIN64 || ARCH_X86_32 mov SHIFT, heightm %endif -.loop +.loop: SIMPLE_LOAD %1, 10, srcq, m0 %if %1 <= 4 punpcklwd m0, m1 @@ -1513,7 +1513,7 @@ %endif pslld m4, m0 -.loop +.loop: SIMPLE_LOAD %1, 10, srcq, m0 SIMPLE_LOAD %1, 10, src2q, m8 %if %1 <= 4 diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/hevc_sao.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/hevc_sao.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/hevc_sao.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/hevc_sao.asm 2015-07-28 17:20:07.000000000 +0000 @@ -39,7 +39,7 @@ SECTION_TEXT %define MAX_PB_SIZE 64 -%define PADDING_SIZE 32 ; FF_INPUT_BUFFER_PADDING_SIZE +%define PADDING_SIZE 32 ; AV_INPUT_BUFFER_PADDING_SIZE ;****************************************************************************** ;SAO Band Filter @@ -141,7 +141,7 @@ HEVC_SAO_BAND_FILTER_INIT 8 align 16 -.loop +.loop: %if %1 == 8 movq m8, [srcq] punpcklbw m8, m14 @@ -191,7 +191,7 @@ HEVC_SAO_BAND_FILTER_INIT %1 align 16 -.loop +.loop: %if %2 == 8 movu m8, [srcq] HEVC_SAO_BAND_FILTER_COMPUTE %1, m9, m8 @@ -528,7 +528,7 @@ %endif align 16 -.loop +.loop: %if %2 == 8 mova m1, [srcq] diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/hpeldsp_init.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/hpeldsp_init.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/hpeldsp_init.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/hpeldsp_init.c 2015-07-28 17:20:07.000000000 +0000 @@ -230,7 +230,7 @@ c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_mmxext; c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_mmxext; - if (!(flags & CODEC_FLAG_BITEXACT)) { + if (!(flags & AV_CODEC_FLAG_BITEXACT)) { c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmxext; c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmxext; c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_mmxext; @@ -240,7 +240,7 @@ c->avg_pixels_tab[1][3] = ff_avg_approx_pixels8_xy2_mmxext; } - if (CONFIG_VP3_DECODER && flags & CODEC_FLAG_BITEXACT) { + if (CONFIG_VP3_DECODER && flags & AV_CODEC_FLAG_BITEXACT) { c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_mmxext; c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_mmxext; } @@ -266,7 +266,7 @@ c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_3dnow; c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_3dnow; - if (!(flags & CODEC_FLAG_BITEXACT)){ + if (!(flags & AV_CODEC_FLAG_BITEXACT)){ c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow; c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow; c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_3dnow; @@ -276,7 +276,7 @@ c->avg_pixels_tab[1][3] = ff_avg_approx_pixels8_xy2_3dnow; } - if (CONFIG_VP3_DECODER && flags & CODEC_FLAG_BITEXACT) { + if (CONFIG_VP3_DECODER && flags & AV_CODEC_FLAG_BITEXACT) { c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_3dnow; c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_3dnow; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/huffyuvdsp.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/huffyuvdsp.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/huffyuvdsp.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/huffyuvdsp.asm 2015-07-26 17:20:03.000000000 +0000 @@ -196,7 +196,7 @@ add dstq, wq add srcq, wq neg wq -.3 +.3: mov sizeb, [srcq + wq] add [dstq + wq], sizeb inc wq diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/jpeg2000dsp.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/jpeg2000dsp.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/jpeg2000dsp.asm 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/jpeg2000dsp.asm 2015-07-26 17:20:03.000000000 +0000 @@ -0,0 +1,144 @@ +;****************************************************************************** +;* SIMD-optimized JPEG2000 DSP functions +;* Copyright (c) 2014 Nicolas Bertrand +;* Copyright (c) 2015 James Almer +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "libavutil/x86/x86util.asm" + +SECTION_RODATA 32 + +pf_ict0: times 8 dd 1.402 +pf_ict1: times 8 dd 0.34413 +pf_ict2: times 8 dd 0.71414 +pf_ict3: times 8 dd 1.772 + +SECTION .text + +;*********************************************************************** +; ff_ict_float_(float *src0, float *src1, float *src2, int csize) +;*********************************************************************** +%macro ICT_FLOAT 1 +cglobal ict_float, 4, 4, %1, src0, src1, src2, csize + shl csized, 2 + add src0q, csizeq + add src1q, csizeq + add src2q, csizeq + neg csizeq + movaps m6, [pf_ict0] + movaps m7, [pf_ict1] + %define ICT0 m6 + %define ICT1 m7 + +%if ARCH_X86_64 + movaps m8, [pf_ict2] + %define ICT2 m8 +%if cpuflag(avx) + movaps m3, [pf_ict3] + %define ICT3 m3 +%else + movaps m9, [pf_ict3] + %define ICT3 m9 +%endif + +%else ; ARCH_X86_32 + %define ICT2 [pf_ict2] +%if cpuflag(avx) + movaps m3, [pf_ict3] + %define ICT3 m3 +%else + %define ICT3 [pf_ict3] +%endif + +%endif ; ARCH + +align 16 +.loop: + movaps m0, [src0q+csizeq] + movaps m1, [src1q+csizeq] + movaps m2, [src2q+csizeq] + +%if cpuflag(avx) + mulps m5, m1, ICT1 + mulps m4, m2, ICT0 + mulps m1, m1, ICT3 + mulps m2, m2, ICT2 + subps m5, m0, m5 +%else ; sse + movaps m3, m1 + movaps m4, m2 + movaps m5, m0 + mulps m3, ICT1 + mulps m4, ICT0 + mulps m1, ICT3 + mulps m2, ICT2 + subps m5, m3 +%endif + addps m4, m4, m0 + addps m0, m0, m1 + subps m5, m5, m2 + + movaps [src0q+csizeq], m4 + movaps [src2q+csizeq], m0 + movaps [src1q+csizeq], m5 + add csizeq, mmsize + jl .loop + REP_RET +%endmacro + +INIT_XMM sse +ICT_FLOAT 10 +INIT_YMM avx +ICT_FLOAT 9 + +;*************************************************************************** +; ff_rct_int_(int32_t *src0, int32_t *src1, int32_t *src2, int csize) +;*************************************************************************** +%macro RCT_INT 0 +cglobal rct_int, 4, 4, 4, src0, src1, src2, csize + shl csized, 2 + add src0q, csizeq + add src1q, csizeq + add src2q, csizeq + neg csizeq + +align 16 +.loop: + mova m1, [src1q+csizeq] + mova m2, [src2q+csizeq] + mova m0, [src0q+csizeq] + paddd m3, m1, m2 + psrad m3, 2 + psubd m0, m3 + paddd m1, m0 + paddd m2, m0 + mova [src1q+csizeq], m0 + mova [src2q+csizeq], m1 + mova [src0q+csizeq], m2 + add csizeq, mmsize + jl .loop + REP_RET +%endmacro + +INIT_XMM sse2 +RCT_INT +%if HAVE_AVX2_EXTERNAL +INIT_YMM avx2 +RCT_INT +%endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/jpeg2000dsp_init.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/jpeg2000dsp_init.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/jpeg2000dsp_init.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/jpeg2000dsp_init.c 2015-06-14 17:20:02.000000000 +0000 @@ -0,0 +1,50 @@ +/* + * SIMD optimized JPEG 2000 DSP functions + * Copyright (c) 2015 James Almer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/x86/cpu.h" +#include "libavcodec/jpeg2000dsp.h" + +void ff_ict_float_sse(void *src0, void *src1, void *src2, int csize); +void ff_ict_float_avx(void *src0, void *src1, void *src2, int csize); +void ff_rct_int_sse2 (void *src0, void *src1, void *src2, int csize); +void ff_rct_int_avx2 (void *src0, void *src1, void *src2, int csize); + +av_cold void ff_jpeg2000dsp_init_x86(Jpeg2000DSPContext *c) +{ + int cpu_flags = av_get_cpu_flags(); + if (EXTERNAL_SSE(cpu_flags)) { + c->mct_decode[FF_DWT97] = ff_ict_float_sse; + } + + if (EXTERNAL_SSE2(cpu_flags)) { + c->mct_decode[FF_DWT53] = ff_rct_int_sse2; + } + + if (EXTERNAL_AVX_FAST(cpu_flags)) { + c->mct_decode[FF_DWT97] = ff_ict_float_avx; + } + + if (EXTERNAL_AVX2(cpu_flags)) { + c->mct_decode[FF_DWT53] = ff_rct_int_avx2; + } +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/Makefile ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/Makefile --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/Makefile 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/Makefile 2015-07-31 17:20:05.000000000 +0000 @@ -31,12 +31,15 @@ x86/mpegvideoencdsp_init.o OBJS-$(CONFIG_PIXBLOCKDSP) += x86/pixblockdsp_init.o OBJS-$(CONFIG_QPELDSP) += x86/qpeldsp_init.o +OBJS-$(CONFIG_RV34DSP) += x86/rv34dsp_init.o OBJS-$(CONFIG_VIDEODSP) += x86/videodsp_init.o OBJS-$(CONFIG_VP3DSP) += x86/vp3dsp_init.o +OBJS-$(CONFIG_VP8DSP) += x86/vp8dsp_init.o OBJS-$(CONFIG_XMM_CLOBBER_TEST) += x86/w64xmmtest.o # decoders/encoders -OBJS-$(CONFIG_AAC_DECODER) += x86/sbrdsp_init.o +OBJS-$(CONFIG_AAC_DECODER) += x86/aacpsdsp_init.o \ + x86/sbrdsp_init.o OBJS-$(CONFIG_ADPCM_G722_DECODER) += x86/g722dsp_init.o OBJS-$(CONFIG_ADPCM_G722_ENCODER) += x86/g722dsp_init.o OBJS-$(CONFIG_APNG_DECODER) += x86/pngdsp_init.o @@ -44,14 +47,13 @@ OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp_init.o OBJS-$(CONFIG_DNXHD_ENCODER) += x86/dnxhdenc_init.o OBJS-$(CONFIG_HEVC_DECODER) += x86/hevcdsp_init.o +OBJS-$(CONFIG_JPEG2000_DECODER) += x86/jpeg2000dsp_init.o OBJS-$(CONFIG_MLP_DECODER) += x86/mlpdsp_init.o OBJS-$(CONFIG_MPEG4_DECODER) += x86/xvididct_init.o OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp_init.o OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp_init.o OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp_init.o -OBJS-$(CONFIG_RV30_DECODER) += x86/rv34dsp_init.o -OBJS-$(CONFIG_RV40_DECODER) += x86/rv34dsp_init.o \ - x86/rv40dsp_init.o +OBJS-$(CONFIG_RV40_DECODER) += x86/rv40dsp_init.o OBJS-$(CONFIG_SVQ1_ENCODER) += x86/svq1enc_init.o OBJS-$(CONFIG_TRUEHD_DECODER) += x86/mlpdsp_init.o OBJS-$(CONFIG_TTA_DECODER) += x86/ttadsp_init.o @@ -60,8 +62,6 @@ OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_init.o OBJS-$(CONFIG_VORBIS_DECODER) += x86/vorbisdsp_init.o OBJS-$(CONFIG_VP6_DECODER) += x86/vp6dsp_init.o -OBJS-$(CONFIG_VP7_DECODER) += x86/vp8dsp_init.o -OBJS-$(CONFIG_VP8_DECODER) += x86/vp8dsp_init.o OBJS-$(CONFIG_VP9_DECODER) += x86/vp9dsp_init.o OBJS-$(CONFIG_WEBP_DECODER) += x86/vp8dsp_init.o @@ -124,11 +124,15 @@ YASM-OBJS-$(CONFIG_QPELDSP) += x86/qpeldsp.o \ x86/fpel.o \ x86/qpel.o +YASM-OBJS-$(CONFIG_RV34DSP) += x86/rv34dsp.o YASM-OBJS-$(CONFIG_VIDEODSP) += x86/videodsp.o YASM-OBJS-$(CONFIG_VP3DSP) += x86/vp3dsp.o +YASM-OBJS-$(CONFIG_VP8DSP) += x86/vp8dsp.o \ + x86/vp8dsp_loopfilter.o # decoders/encoders -YASM-OBJS-$(CONFIG_AAC_DECODER) += x86/sbrdsp.o +YASM-OBJS-$(CONFIG_AAC_DECODER) += x86/aacpsdsp.o \ + x86/sbrdsp.o YASM-OBJS-$(CONFIG_ADPCM_G722_DECODER) += x86/g722dsp.o YASM-OBJS-$(CONFIG_ADPCM_G722_ENCODER) += x86/g722dsp.o YASM-OBJS-$(CONFIG_APNG_DECODER) += x86/pngdsp.o @@ -138,14 +142,13 @@ x86/hevc_idct.o \ x86/hevc_res_add.o \ x86/hevc_sao.o +YASM-OBJS-$(CONFIG_JPEG2000_DECODER) += x86/jpeg2000dsp.o YASM-OBJS-$(CONFIG_MLP_DECODER) += x86/mlpdsp.o YASM-OBJS-$(CONFIG_MPEG4_DECODER) += x86/xvididct.o YASM-OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp.o YASM-OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp.o YASM-OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp.o -YASM-OBJS-$(CONFIG_RV30_DECODER) += x86/rv34dsp.o -YASM-OBJS-$(CONFIG_RV40_DECODER) += x86/rv34dsp.o \ - x86/rv40dsp.o +YASM-OBJS-$(CONFIG_RV40_DECODER) += x86/rv40dsp.o YASM-OBJS-$(CONFIG_SVQ1_ENCODER) += x86/svq1enc.o YASM-OBJS-$(CONFIG_TRUEHD_DECODER) += x86/mlpdsp.o YASM-OBJS-$(CONFIG_TTA_DECODER) += x86/ttadsp.o @@ -154,10 +157,6 @@ YASM-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp.o YASM-OBJS-$(CONFIG_VORBIS_DECODER) += x86/vorbisdsp.o YASM-OBJS-$(CONFIG_VP6_DECODER) += x86/vp6dsp.o -YASM-OBJS-$(CONFIG_VP7_DECODER) += x86/vp8dsp.o \ - x86/vp8dsp_loopfilter.o -YASM-OBJS-$(CONFIG_VP8_DECODER) += x86/vp8dsp.o \ - x86/vp8dsp_loopfilter.o YASM-OBJS-$(CONFIG_VP9_DECODER) += x86/vp9intrapred.o \ x86/vp9itxfm.o \ x86/vp9lpf.o \ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/me_cmp.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/me_cmp.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/me_cmp.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/me_cmp.asm 2015-07-26 17:20:03.000000000 +0000 @@ -794,7 +794,7 @@ %endif sub hd, 2 -.loop +.loop: lea pix1q, [pix1q + 2*lsizeq] %if %1 == mmsize mova m1, [pix1q] @@ -875,7 +875,7 @@ %endif sub hd, 2 -.loop +.loop: lea pix1q, [pix1q + 2*lsizeq] lea pix2q, [pix2q + 2*lsizeq] mova m2, [pix1q] diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/me_cmp_init.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/me_cmp_init.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/me_cmp_init.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/me_cmp_init.c 2015-07-28 17:20:07.000000000 +0000 @@ -573,7 +573,7 @@ c->vsad[4] = vsad_intra16_mmx; - if (!(avctx->flags & CODEC_FLAG_BITEXACT)) { + if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) { c->vsad[0] = vsad16_mmx; } } @@ -610,7 +610,7 @@ c->vsad[4] = ff_vsad_intra16_mmxext; c->vsad[5] = ff_vsad_intra8_mmxext; - if (!(avctx->flags & CODEC_FLAG_BITEXACT)) { + if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) { c->pix_abs[0][3] = ff_sad16_approx_xy2_mmxext; c->pix_abs[1][3] = ff_sad8_approx_xy2_mmxext; @@ -634,7 +634,7 @@ c->pix_abs[0][2] = ff_sad16_y2_sse2; c->vsad[4] = ff_vsad_intra16_sse2; - if (!(avctx->flags & CODEC_FLAG_BITEXACT)) { + if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) { c->pix_abs[0][3] = ff_sad16_approx_xy2_sse2; c->vsad[0] = ff_vsad16_approx_sse2; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/mpegvideo.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/mpegvideo.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/mpegvideo.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/mpegvideo.c 2015-07-28 17:20:07.000000000 +0000 @@ -454,7 +454,7 @@ s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_mmx; s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_mmx; s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_mmx; - if (!(s->avctx->flags & CODEC_FLAG_BITEXACT)) + if (!(s->avctx->flags & AV_CODEC_FLAG_BITEXACT)) s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_mmx; s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_mmx; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/mpegvideoencdsp_init.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/mpegvideoencdsp_init.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/mpegvideoencdsp_init.c 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/mpegvideoencdsp_init.c 2015-07-28 17:20:07.000000000 +0000 @@ -242,7 +242,7 @@ #if HAVE_INLINE_ASM if (INLINE_MMX(cpu_flags)) { - if (!(avctx->flags & CODEC_FLAG_BITEXACT)) { + if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) { c->try_8x8basis = try_8x8basis_mmx; } c->add_8x8basis = add_8x8basis_mmx; @@ -253,7 +253,7 @@ } if (INLINE_AMD3DNOW(cpu_flags)) { - if (!(avctx->flags & CODEC_FLAG_BITEXACT)) { + if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) { c->try_8x8basis = try_8x8basis_3dnow; } c->add_8x8basis = add_8x8basis_3dnow; @@ -261,7 +261,7 @@ #if HAVE_SSSE3_INLINE if (INLINE_SSSE3(cpu_flags)) { - if (!(avctx->flags & CODEC_FLAG_BITEXACT)) { + if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) { c->try_8x8basis = try_8x8basis_ssse3; } c->add_8x8basis = add_8x8basis_ssse3; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/svq1enc.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/svq1enc.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/svq1enc.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/svq1enc.asm 2015-07-26 17:20:03.000000000 +0000 @@ -26,7 +26,7 @@ %macro SSD_INT8_VS_INT16 0 cglobal ssd_int8_vs_int16, 3, 3, 3, pix1, pix2, size pxor m0, m0 -.loop +.loop: sub sizeq, 8 movq m1, [pix1q + sizeq] mova m2, [pix2q + sizeq*2] diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/v210.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/v210.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/v210.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/v210.asm 2015-07-26 17:20:03.000000000 +0000 @@ -45,7 +45,7 @@ mova m4, [v210_mask] mova m5, [v210_luma_shuf] mova m6, [v210_chroma_shuf] -.loop +.loop: %ifidn %1, unaligned movu m0, [r0] %else diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/v210enc.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/v210enc.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/v210enc.asm 2015-06-19 20:44:46.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/v210enc.asm 2015-07-26 17:20:03.000000000 +0000 @@ -60,7 +60,7 @@ mova m2, [v210_enc_min_10] mova m3, [v210_enc_max_10] -.loop +.loop: movu m0, [yq+2*widthq] CLIPW m0, m2, m3 @@ -102,7 +102,7 @@ mova m5, [v210_enc_max_8] pxor m6, m6 -.loop +.loop: movu m1, [yq+2*widthq] CLIPUB m1, m4, m5 diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/videodsp_init.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/videodsp_init.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/videodsp_init.c 2015-06-19 20:44:48.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/videodsp_init.c 2015-07-08 17:20:04.000000000 +0000 @@ -162,6 +162,8 @@ if (!w || !h) return; + av_assert2(block_w <= FFABS(dst_stride)); + if (src_y >= h) { src -= src_y*src_stride; src_y_add = h - 1; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/vp3dsp.asm ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/vp3dsp.asm --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/vp3dsp.asm 2015-06-19 20:44:49.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/vp3dsp.asm 2015-07-26 17:20:03.000000000 +0000 @@ -167,7 +167,7 @@ cglobal put_vp_no_rnd_pixels8_l2, 5, 6, 0, dst, src1, src2, stride, h, stride3 mova m6, [pb_FE] lea stride3q,[strideq+strideq*2] -.loop +.loop: mova m0, [src1q] mova m1, [src2q] mova m2, [src1q+strideq] diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/vp3dsp_init.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/vp3dsp_init.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/x86/vp3dsp_init.c 2015-06-19 20:44:49.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/x86/vp3dsp_init.c 2015-07-28 17:20:07.000000000 +0000 @@ -59,7 +59,7 @@ if (EXTERNAL_MMXEXT(cpu_flags)) { c->idct_dc_add = ff_vp3_idct_dc_add_mmxext; - if (!(flags & CODEC_FLAG_BITEXACT)) { + if (!(flags & AV_CODEC_FLAG_BITEXACT)) { c->v_loop_filter = ff_vp3_v_loop_filter_mmxext; c->h_loop_filter = ff_vp3_h_loop_filter_mmxext; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/xan.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/xan.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/xan.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/xan.c 2015-07-28 17:20:07.000000000 +0000 @@ -644,5 +644,5 @@ .init = xan_decode_init, .close = xan_decode_end, .decode = xan_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/xbmdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/xbmdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/xbmdec.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/xbmdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -133,5 +133,5 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_XBM, .decode = xbm_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/xbmenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/xbmenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/xbmenc.c 2015-06-18 18:55:01.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/xbmenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -32,7 +32,7 @@ linesize = (avctx->width + 7) / 8; size = avctx->height * (linesize * 7 + 2) + 110; - if ((ret = ff_alloc_packet2(avctx, pkt, size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0) return ret; buf = pkt->data; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/xfaceenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/xfaceenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/xfaceenc.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/xfaceenc.c 2015-08-02 17:20:02.000000000 +0000 @@ -124,16 +124,6 @@ } } -static av_cold int xface_encode_init(AVCodecContext *avctx) -{ - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; - - return 0; -} - static void push_integer(BigInt *b, const ProbRange *prange) { uint8_t r; @@ -205,7 +195,7 @@ intbuf[i++] = r + XFACE_FIRST_PRINT; } - if ((ret = ff_alloc_packet2(avctx, pkt, i+2)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, i+2, 0)) < 0) return ret; /* revert the number, and close the buffer */ @@ -221,21 +211,13 @@ return 0; } -static av_cold int xface_encode_close(AVCodecContext *avctx) -{ - av_frame_free(&avctx->coded_frame); - - return 0; -} - AVCodec ff_xface_encoder = { .name = "xface", .long_name = NULL_IF_CONFIG_SMALL("X-face image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_XFACE, .priv_data_size = sizeof(XFaceContext), - .init = xface_encode_init, - .close = xface_encode_close, .encode2 = xface_encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MONOWHITE, AV_PIX_FMT_NONE }, + .capabilities = AV_CODEC_CAP_INTRA_ONLY, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/xl.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/xl.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/xl.c 2015-06-18 18:55:01.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/xl.c 2015-07-28 17:20:07.000000000 +0000 @@ -134,5 +134,5 @@ .id = AV_CODEC_ID_VIXL, .init = decode_init, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/xvididct.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/xvididct.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/xvididct.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/xvididct.c 2015-07-21 17:20:03.000000000 +0000 @@ -348,6 +348,8 @@ if (ARCH_X86) ff_xvid_idct_init_x86(c, avctx, high_bit_depth); + if (ARCH_MIPS) + ff_xvid_idct_init_mips(c, avctx, high_bit_depth); ff_init_scantable_permutation(c->idct_permutation, c->perm_type); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/xvididct.h ffmpeg-2.7.2~trusty~ppa1/libavcodec/xvididct.h --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/xvididct.h 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/xvididct.h 2015-07-21 17:20:03.000000000 +0000 @@ -30,5 +30,7 @@ void ff_xvid_idct_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); +void ff_xvid_idct_init_mips(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth); #endif /* AVCODEC_XVIDIDCT_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/xwddec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/xwddec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/xwddec.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/xwddec.c 2015-07-28 17:20:07.000000000 +0000 @@ -249,5 +249,5 @@ .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_XWD, .decode = xwd_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/xwdenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/xwdenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/xwdenc.c 2015-06-18 18:55:01.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/xwdenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -146,7 +146,7 @@ header_size = XWD_HEADER_SIZE + WINDOW_NAME_SIZE; out_size = header_size + ncolors * XWD_CMAP_SIZE + avctx->height * lsize; - if ((ret = ff_alloc_packet2(avctx, pkt, out_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, out_size, 0)) < 0) return ret; buf = pkt->data; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/xxan.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/xxan.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/xxan.c 2015-06-18 18:55:01.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/xxan.c 2015-07-28 17:20:07.000000000 +0000 @@ -447,5 +447,5 @@ .init = xan_decode_init, .close = xan_decode_end, .decode = xan_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/y41pdec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/y41pdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/y41pdec.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/y41pdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -88,5 +88,5 @@ .id = AV_CODEC_ID_Y41P, .init = y41p_decode_init, .decode = y41p_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/y41penc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/y41penc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/y41penc.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/y41penc.c 2015-07-30 17:20:02.000000000 +0000 @@ -30,14 +30,8 @@ return AVERROR_INVALIDDATA; } - avctx->coded_frame = av_frame_alloc(); avctx->bits_per_coded_sample = 12; - if (!avctx->coded_frame) { - av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n"); - return AVERROR(ENOMEM); - } - return 0; } @@ -48,11 +42,9 @@ uint8_t *y, *u, *v; int i, j, ret; - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 1.5)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 1.5, 0)) < 0) return ret; - avctx->coded_frame->key_frame = 1; - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; dst = pkt->data; for (i = avctx->height - 1; i >= 0; i--) { @@ -84,8 +76,6 @@ static av_cold int y41p_encode_close(AVCodecContext *avctx) { - av_frame_free(&avctx->coded_frame); - return 0; } @@ -99,4 +89,5 @@ .close = y41p_encode_close, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P, AV_PIX_FMT_NONE }, + .capabilities = AV_CODEC_CAP_INTRA_ONLY, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/yuv4dec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/yuv4dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/yuv4dec.c 2015-06-18 18:55:01.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/yuv4dec.c 2015-07-28 17:20:07.000000000 +0000 @@ -80,5 +80,5 @@ .id = AV_CODEC_ID_YUV4, .init = yuv4_decode_init, .decode = yuv4_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/yuv4enc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/yuv4enc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/yuv4enc.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/yuv4enc.c 2015-07-30 17:20:02.000000000 +0000 @@ -25,13 +25,6 @@ static av_cold int yuv4_encode_init(AVCodecContext *avctx) { - avctx->coded_frame = av_frame_alloc(); - - if (!avctx->coded_frame) { - av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n"); - return AVERROR(ENOMEM); - } - return 0; } @@ -42,13 +35,10 @@ uint8_t *y, *u, *v; int i, j, ret; - if ((ret = ff_alloc_packet2(avctx, pkt, 6 * (avctx->width + 1 >> 1) * (avctx->height + 1 >> 1))) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, 6 * (avctx->width + 1 >> 1) * (avctx->height + 1 >> 1), 0)) < 0) return ret; dst = pkt->data; - avctx->coded_frame->key_frame = 1; - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; - y = pic->data[0]; u = pic->data[1]; v = pic->data[2]; @@ -74,8 +64,6 @@ static av_cold int yuv4_encode_close(AVCodecContext *avctx) { - av_frame_free(&avctx->coded_frame); - return 0; } @@ -88,4 +76,5 @@ .encode2 = yuv4_encode_frame, .close = yuv4_encode_close, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .capabilities = AV_CODEC_CAP_INTRA_ONLY, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/zerocodec.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/zerocodec.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/zerocodec.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/zerocodec.c 2015-07-28 17:20:07.000000000 +0000 @@ -148,5 +148,5 @@ .init = zerocodec_decode_init, .decode = zerocodec_decode_frame, .close = zerocodec_decode_close, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/zmbv.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/zmbv.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/zmbv.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/zmbv.c 2015-07-28 17:20:07.000000000 +0000 @@ -634,5 +634,5 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_DR1, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavcodec/zmbvenc.c ffmpeg-2.7.2~trusty~ppa1/libavcodec/zmbvenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavcodec/zmbvenc.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavcodec/zmbvenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -133,8 +133,12 @@ c->curfrm++; if(c->curfrm == c->keyint) c->curfrm = 0; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; avctx->coded_frame->key_frame = keyframe; +FF_ENABLE_DEPRECATION_WARNINGS +#endif chpal = !keyframe && memcmp(p->data[1], c->pal2, 1024); palptr = (uint32_t*)p->data[1]; @@ -227,7 +231,7 @@ } pkt_size = c->zstream.total_out + 1 + 6*keyframe; - if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, 0)) < 0) return ret; buf = pkt->data; @@ -259,8 +263,6 @@ deflateEnd(&c->zstream); av_freep(&c->prev); - av_frame_free(&avctx->coded_frame); - return 0; } @@ -324,12 +326,6 @@ return -1; } - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) { - encode_end(avctx); - return AVERROR(ENOMEM); - } - return 0; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavdevice/decklink_common.h ffmpeg-2.7.2~trusty~ppa1/libavdevice/decklink_common.h --- ffmpeg-2.7.1~trusty~ppa1/libavdevice/decklink_common.h 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavdevice/decklink_common.h 2015-07-28 17:20:07.000000000 +0000 @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "decklink_common_c.h" class decklink_output_callback; @@ -82,7 +84,11 @@ typedef enum { DIRECTION_IN, DIRECTION_OUT} decklink_direction_t; #ifdef _WIN32 +#if BLACKMAGIC_DECKLINK_API_VERSION < 0x0a040000 typedef unsigned long buffercount_type; +#else +typedef unsigned int buffercount_type; +#endif IDeckLinkIterator *CreateDeckLinkIteratorInstance(void); #else typedef uint32_t buffercount_type; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavdevice/dshow.c ffmpeg-2.7.2~trusty~ppa1/libavdevice/dshow.c --- ffmpeg-2.7.1~trusty~ppa1/libavdevice/dshow.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavdevice/dshow.c 2015-07-28 17:20:07.000000000 +0000 @@ -975,7 +975,7 @@ codec->codec_id = AV_CODEC_ID_RAWVIDEO; if (bih->biCompression == BI_RGB || bih->biCompression == BI_BITFIELDS) { codec->bits_per_coded_sample = bih->biBitCount; - codec->extradata = av_malloc(9 + FF_INPUT_BUFFER_PADDING_SIZE); + codec->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE); if (codec->extradata) { codec->extradata_size = 9; memcpy(codec->extradata, "BottomUp", 9); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavdevice/dshow_pin.c ffmpeg-2.7.2~trusty~ppa1/libavdevice/dshow_pin.c --- ffmpeg-2.7.1~trusty~ppa1/libavdevice/dshow_pin.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavdevice/dshow_pin.c 2015-07-31 17:20:05.000000000 +0000 @@ -303,14 +303,18 @@ libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset); enum dshowDeviceType devtype = pin->filter->type; void *priv_data; + AVFormatContext *s; uint8_t *buf; int buf_size; /* todo should be a long? */ int index; int64_t curtime; int64_t orig_curtime; + int64_t graphtime; const char *devtypename = (devtype == VideoDevice) ? "video" : "audio"; IReferenceClock *clock = pin->filter->clock; int64_t dummy; + struct dshow_ctx *ctx; + dshowdebug("libAVMemInputPin_Receive(%p)\n", this); @@ -319,6 +323,7 @@ IMediaSample_GetTime(sample, &orig_curtime, &dummy); orig_curtime += pin->filter->start_time; + IReferenceClock_GetTime(clock, &graphtime); if (devtype == VideoDevice) { /* PTS from video devices is unreliable. */ IReferenceClock_GetTime(clock, &curtime); @@ -338,10 +343,13 @@ buf_size = IMediaSample_GetActualDataLength(sample); IMediaSample_GetPointer(sample, &buf); priv_data = pin->filter->priv_data; + s = priv_data; + ctx = s->priv_data; index = pin->filter->stream_index; - av_log(NULL, AV_LOG_VERBOSE, "dshow passing through packet of type %s size %6d timestamp %"PRId64" orig timestamp %"PRId64"\n", - devtypename, buf_size, curtime, orig_curtime); + av_log(NULL, AV_LOG_VERBOSE, "dshow passing through packet of type %s size %8d " + "timestamp %"PRId64" orig timestamp %"PRId64" graph timestamp %"PRId64" diff %"PRId64" %s\n", + devtypename, buf_size, curtime, orig_curtime, graphtime, graphtime - orig_curtime, ctx->device_name[devtype]); pin->filter->callback(priv_data, index, buf, buf_size, curtime, devtype); return S_OK; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavdevice/fbdev_common.c ffmpeg-2.7.2~trusty~ppa1/libavdevice/fbdev_common.c --- ffmpeg-2.7.1~trusty~ppa1/libavdevice/fbdev_common.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavdevice/fbdev_common.c 2015-07-11 17:20:02.000000000 +0000 @@ -42,7 +42,7 @@ { 32, 3, 2, 8, 0, AV_PIX_FMT_ABGR }, { 24, 0, 8, 16, 0, AV_PIX_FMT_RGB24 }, { 24, 16, 8, 0, 0, AV_PIX_FMT_BGR24 }, - { 16, 11, 5, 0, 16, AV_PIX_FMT_RGB565 }, + { 16, 11, 5, 0, 0, AV_PIX_FMT_RGB565 }, }; enum AVPixelFormat ff_get_pixfmt_from_fb_varinfo(struct fb_var_screeninfo *varinfo) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavdevice/iec61883.c ffmpeg-2.7.2~trusty~ppa1/libavdevice/iec61883.c --- ffmpeg-2.7.1~trusty~ppa1/libavdevice/iec61883.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavdevice/iec61883.c 2015-06-13 17:20:02.000000000 +0000 @@ -271,7 +271,7 @@ } if (dv->device_guid) { - if (sscanf(dv->device_guid, "%llx", (long long unsigned int *)&guid) != 1) { + if (sscanf(dv->device_guid, "%"SCNu64, &guid) != 1) { av_log(context, AV_LOG_INFO, "Invalid dvguid parameter: %s\n", dv->device_guid); goto fail; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavdevice/openal-dec.c ffmpeg-2.7.2~trusty~ppa1/libavdevice/openal-dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavdevice/openal-dec.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavdevice/openal-dec.c 2015-06-11 17:20:04.000000000 +0000 @@ -60,9 +60,9 @@ * @param al_fmt the AL_FORMAT value to find information about. * @return A pointer to a structure containing information about the AL_FORMAT value. */ -static inline al_format_info* get_al_format_info(ALCenum al_fmt) +static const inline al_format_info* get_al_format_info(ALCenum al_fmt) { - static al_format_info info_table[] = { + static const al_format_info info_table[] = { [AL_FORMAT_MONO8-LOWEST_AL_FORMAT] = {AL_FORMAT_MONO8, AV_CODEC_ID_PCM_U8, 1}, [AL_FORMAT_MONO16-LOWEST_AL_FORMAT] = {AL_FORMAT_MONO16, AV_NE (AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE), 1}, [AL_FORMAT_STEREO8-LOWEST_AL_FORMAT] = {AL_FORMAT_STEREO8, AV_CODEC_ID_PCM_U8, 2}, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavdevice/v4l2.c ffmpeg-2.7.2~trusty~ppa1/libavdevice/v4l2.c --- ffmpeg-2.7.1~trusty~ppa1/libavdevice/v4l2.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavdevice/v4l2.c 2015-08-04 17:20:03.000000000 +0000 @@ -966,7 +966,7 @@ st->codec->codec_tag = avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt); else if (codec_id == AV_CODEC_ID_H264) { - st->need_parsing = AVSTREAM_PARSE_HEADERS; + st->need_parsing = AVSTREAM_PARSE_FULL_ONCE; } if (desired_format == V4L2_PIX_FMT_YVU420) st->codec->codec_tag = MKTAG('Y', 'V', '1', '2'); @@ -987,7 +987,11 @@ static int v4l2_read_packet(AVFormatContext *ctx, AVPacket *pkt) { struct video_data *s = ctx->priv_data; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS AVFrame *frame = ctx->streams[0]->codec->coded_frame; +FF_ENABLE_DEPRECATION_WARNINGS +#endif int res; av_init_packet(pkt); @@ -995,10 +999,14 @@ return res; } +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS if (frame && s->interlaced) { frame->interlaced_frame = 1; frame->top_field_first = s->top_field_first; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif return pkt->size; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavdevice/vfwcap.c ffmpeg-2.7.2~trusty~ppa1/libavdevice/vfwcap.c --- ffmpeg-2.7.1~trusty~ppa1/libavdevice/vfwcap.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavdevice/vfwcap.c 2015-07-28 17:20:07.000000000 +0000 @@ -396,7 +396,7 @@ codec->codec_id = AV_CODEC_ID_RAWVIDEO; if(biCompression == BI_RGB) { codec->bits_per_coded_sample = biBitCount; - codec->extradata = av_malloc(9 + FF_INPUT_BUFFER_PADDING_SIZE); + codec->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE); if (codec->extradata) { codec->extradata_size = 9; memcpy(codec->extradata, "BottomUp", 9); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavdevice/xcbgrab.c ffmpeg-2.7.2~trusty~ppa1/libavdevice/xcbgrab.c --- ffmpeg-2.7.1~trusty~ppa1/libavdevice/xcbgrab.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavdevice/xcbgrab.c 2015-07-28 17:20:07.000000000 +0000 @@ -231,7 +231,7 @@ xcb_shm_get_image_reply_t *img; xcb_drawable_t drawable = c->screen->root; uint8_t *data; - int size = c->frame_size + FF_INPUT_BUFFER_PADDING_SIZE; + int size = c->frame_size + AV_INPUT_BUFFER_PADDING_SIZE; int id = shmget(IPC_PRIVATE, size, IPC_CREAT | 0777); xcb_generic_error_t *e = NULL; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_afade.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_afade.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_afade.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_afade.c 2015-07-28 17:20:07.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Paul B Mahol + * Copyright (c) 2013-2015 Paul B Mahol * * This file is part of FFmpeg. * @@ -23,6 +23,7 @@ * fade audio filter */ +#include "libavutil/audio_fifo.h" #include "libavutil/opt.h" #include "audio.h" #include "avfilter.h" @@ -31,62 +32,31 @@ typedef struct { const AVClass *class; int type; - int curve; + int curve, curve2; int nb_samples; int64_t start_sample; int64_t duration; int64_t start_time; + int overlap; + int cf0_eof; + int crossfade_is_over; + AVAudioFifo *fifo[2]; + int64_t pts; void (*fade_samples)(uint8_t **dst, uint8_t * const *src, int nb_samples, int channels, int direction, int64_t start, int range, int curve); + void (*crossfade_samples)(uint8_t **dst, uint8_t * const *cf0, + uint8_t * const *cf1, + int nb_samples, int channels, + int curve0, int curve1); } AudioFadeContext; -enum CurveType { TRI, QSIN, ESIN, HSIN, LOG, PAR, QUA, CUB, SQU, CBR }; +enum CurveType { TRI, QSIN, ESIN, HSIN, LOG, IPAR, QUA, CUB, SQU, CBR, PAR, EXP, IQSIN, IHSIN, DESE, DESI, NB_CURVES }; #define OFFSET(x) offsetof(AudioFadeContext, x) #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM -static const AVOption afade_options[] = { - { "type", "set the fade direction", OFFSET(type), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FLAGS, "type" }, - { "t", "set the fade direction", OFFSET(type), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FLAGS, "type" }, - { "in", "fade-in", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, "type" }, - { "out", "fade-out", 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, "type" }, - { "start_sample", "set number of first sample to start fading", OFFSET(start_sample), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, FLAGS }, - { "ss", "set number of first sample to start fading", OFFSET(start_sample), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, FLAGS }, - { "nb_samples", "set number of samples for fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 44100}, 1, INT32_MAX, FLAGS }, - { "ns", "set number of samples for fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 44100}, 1, INT32_MAX, FLAGS }, - { "start_time", "set time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS }, - { "st", "set time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS }, - { "duration", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS }, - { "d", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS }, - { "curve", "set fade curve type", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, TRI, CBR, FLAGS, "curve" }, - { "c", "set fade curve type", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, TRI, CBR, FLAGS, "curve" }, - { "tri", "linear slope", 0, AV_OPT_TYPE_CONST, {.i64 = TRI }, 0, 0, FLAGS, "curve" }, - { "qsin", "quarter of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = QSIN }, 0, 0, FLAGS, "curve" }, - { "esin", "exponential sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = ESIN }, 0, 0, FLAGS, "curve" }, - { "hsin", "half of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = HSIN }, 0, 0, FLAGS, "curve" }, - { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64 = LOG }, 0, 0, FLAGS, "curve" }, - { "par", "inverted parabola", 0, AV_OPT_TYPE_CONST, {.i64 = PAR }, 0, 0, FLAGS, "curve" }, - { "qua", "quadratic", 0, AV_OPT_TYPE_CONST, {.i64 = QUA }, 0, 0, FLAGS, "curve" }, - { "cub", "cubic", 0, AV_OPT_TYPE_CONST, {.i64 = CUB }, 0, 0, FLAGS, "curve" }, - { "squ", "square root", 0, AV_OPT_TYPE_CONST, {.i64 = SQU }, 0, 0, FLAGS, "curve" }, - { "cbr", "cubic root", 0, AV_OPT_TYPE_CONST, {.i64 = CBR }, 0, 0, FLAGS, "curve" }, - { NULL } -}; - -AVFILTER_DEFINE_CLASS(afade); - -static av_cold int init(AVFilterContext *ctx) -{ - AudioFadeContext *s = ctx->priv; - - if (INT64_MAX - s->nb_samples < s->start_sample) - return AVERROR(EINVAL); - - return 0; -} - static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats; @@ -124,22 +94,34 @@ { double gain; - gain = FFMAX(0.0, FFMIN(1.0, 1.0 * index / range)); + gain = av_clipd(1.0 * index / range, 0, 1.0); switch (curve) { case QSIN: gain = sin(gain * M_PI / 2.0); break; + case IQSIN: + gain = 0.636943 * asin(gain); + break; case ESIN: gain = 1.0 - cos(M_PI / 4.0 * (pow(2.0*gain - 1, 3) + 1)); break; case HSIN: gain = (1.0 - cos(gain * M_PI)) / 2.0; break; - case LOG: + case IHSIN: + gain = 0.318471 * acos(1 - 2 * gain); + break; + case EXP: gain = pow(0.1, (1 - gain) * 5.0); break; + case LOG: + gain = av_clipd(0.0868589 * log(100000 * gain), 0, 1.0); + break; case PAR: + gain = 1 - sqrt(1 - gain); + break; + case IPAR: gain = (1 - (1 - gain) * (1 - gain)); break; case QUA: @@ -154,6 +136,12 @@ case CBR: gain = cbrt(gain); break; + case DESE: + gain = gain <= 0.5 ? pow(2 * gain, 1/3.) / 2: 1 - pow(2 * (1 - gain), 1/3.) / 2; + break; + case DESI: + gain = gain <= 0.5 ? pow(2 * gain, 3) / 2: 1 - pow(2 * (1 - gain), 3) / 2; + break; } return gain; @@ -203,12 +191,12 @@ FADE(s16, int16_t) FADE(s32, int32_t) -static int config_input(AVFilterLink *inlink) +static int config_output(AVFilterLink *outlink) { - AVFilterContext *ctx = inlink->dst; + AVFilterContext *ctx = outlink->src; AudioFadeContext *s = ctx->priv; - switch (inlink->format) { + switch (outlink->format) { case AV_SAMPLE_FMT_DBL: s->fade_samples = fade_samples_dbl; break; case AV_SAMPLE_FMT_DBLP: s->fade_samples = fade_samples_dblp; break; case AV_SAMPLE_FMT_FLT: s->fade_samples = fade_samples_flt; break; @@ -220,9 +208,57 @@ } if (s->duration) - s->nb_samples = av_rescale(s->duration, inlink->sample_rate, AV_TIME_BASE); + s->nb_samples = av_rescale(s->duration, outlink->sample_rate, AV_TIME_BASE); if (s->start_time) - s->start_sample = av_rescale(s->start_time, inlink->sample_rate, AV_TIME_BASE); + s->start_sample = av_rescale(s->start_time, outlink->sample_rate, AV_TIME_BASE); + + return 0; +} + +#if CONFIG_AFADE_FILTER + +static const AVOption afade_options[] = { + { "type", "set the fade direction", OFFSET(type), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FLAGS, "type" }, + { "t", "set the fade direction", OFFSET(type), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FLAGS, "type" }, + { "in", "fade-in", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, "type" }, + { "out", "fade-out", 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, "type" }, + { "start_sample", "set number of first sample to start fading", OFFSET(start_sample), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, FLAGS }, + { "ss", "set number of first sample to start fading", OFFSET(start_sample), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, FLAGS }, + { "nb_samples", "set number of samples for fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 44100}, 1, INT32_MAX, FLAGS }, + { "ns", "set number of samples for fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 44100}, 1, INT32_MAX, FLAGS }, + { "start_time", "set time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS }, + { "st", "set time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS }, + { "duration", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS }, + { "d", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS }, + { "curve", "set fade curve type", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve" }, + { "c", "set fade curve type", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve" }, + { "tri", "linear slope", 0, AV_OPT_TYPE_CONST, {.i64 = TRI }, 0, 0, FLAGS, "curve" }, + { "qsin", "quarter of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = QSIN }, 0, 0, FLAGS, "curve" }, + { "esin", "exponential sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = ESIN }, 0, 0, FLAGS, "curve" }, + { "hsin", "half of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = HSIN }, 0, 0, FLAGS, "curve" }, + { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64 = LOG }, 0, 0, FLAGS, "curve" }, + { "ipar", "inverted parabola", 0, AV_OPT_TYPE_CONST, {.i64 = IPAR }, 0, 0, FLAGS, "curve" }, + { "qua", "quadratic", 0, AV_OPT_TYPE_CONST, {.i64 = QUA }, 0, 0, FLAGS, "curve" }, + { "cub", "cubic", 0, AV_OPT_TYPE_CONST, {.i64 = CUB }, 0, 0, FLAGS, "curve" }, + { "squ", "square root", 0, AV_OPT_TYPE_CONST, {.i64 = SQU }, 0, 0, FLAGS, "curve" }, + { "cbr", "cubic root", 0, AV_OPT_TYPE_CONST, {.i64 = CBR }, 0, 0, FLAGS, "curve" }, + { "par", "parabola", 0, AV_OPT_TYPE_CONST, {.i64 = PAR }, 0, 0, FLAGS, "curve" }, + { "exp", "exponential", 0, AV_OPT_TYPE_CONST, {.i64 = EXP }, 0, 0, FLAGS, "curve" }, + { "iqsin", "inverted quarter of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = IQSIN}, 0, 0, FLAGS, "curve" }, + { "ihsin", "inverted half of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = IHSIN}, 0, 0, FLAGS, "curve" }, + { "dese", "double-exponential seat", 0, AV_OPT_TYPE_CONST, {.i64 = DESE }, 0, 0, FLAGS, "curve" }, + { "desi", "double-exponential sigmoid", 0, AV_OPT_TYPE_CONST, {.i64 = DESI }, 0, 0, FLAGS, "curve" }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(afade); + +static av_cold int init(AVFilterContext *ctx) +{ + AudioFadeContext *s = ctx->priv; + + if (INT64_MAX - s->nb_samples < s->start_sample) + return AVERROR(EINVAL); return 0; } @@ -277,15 +313,15 @@ .name = "default", .type = AVMEDIA_TYPE_AUDIO, .filter_frame = filter_frame, - .config_props = config_input, }, { NULL } }; static const AVFilterPad avfilter_af_afade_outputs[] = { { - .name = "default", - .type = AVMEDIA_TYPE_AUDIO, + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .config_props = config_output, }, { NULL } }; @@ -301,3 +337,344 @@ .priv_class = &afade_class, .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, }; + +#endif /* CONFIG_AFADE_FILTER */ + +#if CONFIG_ACROSSFADE_FILTER + +static const AVOption acrossfade_options[] = { + { "nb_samples", "set number of samples for cross fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 44100}, 1, INT32_MAX/10, FLAGS }, + { "ns", "set number of samples for cross fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 44100}, 1, INT32_MAX/10, FLAGS }, + { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, 60, FLAGS }, + { "d", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, 60, FLAGS }, + { "overlap", "overlap 1st stream end with 2nd stream start", OFFSET(overlap), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 1, FLAGS }, + { "o", "overlap 1st stream end with 2nd stream start", OFFSET(overlap), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 1, FLAGS }, + { "curve1", "set fade curve type for 1st stream", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve1" }, + { "c1", "set fade curve type for 1st stream", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve1" }, + { "tri", "linear slope", 0, AV_OPT_TYPE_CONST, {.i64 = TRI }, 0, 0, FLAGS, "curve1" }, + { "qsin", "quarter of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = QSIN }, 0, 0, FLAGS, "curve1" }, + { "esin", "exponential sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = ESIN }, 0, 0, FLAGS, "curve1" }, + { "hsin", "half of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = HSIN }, 0, 0, FLAGS, "curve1" }, + { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64 = LOG }, 0, 0, FLAGS, "curve1" }, + { "ipar", "inverted parabola", 0, AV_OPT_TYPE_CONST, {.i64 = IPAR }, 0, 0, FLAGS, "curve1" }, + { "qua", "quadratic", 0, AV_OPT_TYPE_CONST, {.i64 = QUA }, 0, 0, FLAGS, "curve1" }, + { "cub", "cubic", 0, AV_OPT_TYPE_CONST, {.i64 = CUB }, 0, 0, FLAGS, "curve1" }, + { "squ", "square root", 0, AV_OPT_TYPE_CONST, {.i64 = SQU }, 0, 0, FLAGS, "curve1" }, + { "cbr", "cubic root", 0, AV_OPT_TYPE_CONST, {.i64 = CBR }, 0, 0, FLAGS, "curve1" }, + { "par", "parabola", 0, AV_OPT_TYPE_CONST, {.i64 = PAR }, 0, 0, FLAGS, "curve1" }, + { "exp", "exponential", 0, AV_OPT_TYPE_CONST, {.i64 = EXP }, 0, 0, FLAGS, "curve1" }, + { "iqsin", "inverted quarter of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = IQSIN}, 0, 0, FLAGS, "curve1" }, + { "ihsin", "inverted half of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = IHSIN}, 0, 0, FLAGS, "curve1" }, + { "dese", "double-exponential seat", 0, AV_OPT_TYPE_CONST, {.i64 = DESE }, 0, 0, FLAGS, "curve1" }, + { "desi", "double-exponential sigmoid", 0, AV_OPT_TYPE_CONST, {.i64 = DESI }, 0, 0, FLAGS, "curve1" }, + { "curve2", "set fade curve type for 2nd stream", OFFSET(curve2), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve2" }, + { "c2", "set fade curve type for 2nd stream", OFFSET(curve2), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve2" }, + { "tri", "linear slope", 0, AV_OPT_TYPE_CONST, {.i64 = TRI }, 0, 0, FLAGS, "curve2" }, + { "qsin", "quarter of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = QSIN }, 0, 0, FLAGS, "curve2" }, + { "esin", "exponential sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = ESIN }, 0, 0, FLAGS, "curve2" }, + { "hsin", "half of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = HSIN }, 0, 0, FLAGS, "curve2" }, + { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64 = LOG }, 0, 0, FLAGS, "curve2" }, + { "ipar", "inverted parabola", 0, AV_OPT_TYPE_CONST, {.i64 = IPAR }, 0, 0, FLAGS, "curve2" }, + { "qua", "quadratic", 0, AV_OPT_TYPE_CONST, {.i64 = QUA }, 0, 0, FLAGS, "curve2" }, + { "cub", "cubic", 0, AV_OPT_TYPE_CONST, {.i64 = CUB }, 0, 0, FLAGS, "curve2" }, + { "squ", "square root", 0, AV_OPT_TYPE_CONST, {.i64 = SQU }, 0, 0, FLAGS, "curve2" }, + { "cbr", "cubic root", 0, AV_OPT_TYPE_CONST, {.i64 = CBR }, 0, 0, FLAGS, "curve2" }, + { "par", "parabola", 0, AV_OPT_TYPE_CONST, {.i64 = PAR }, 0, 0, FLAGS, "curve2" }, + { "exp", "exponential", 0, AV_OPT_TYPE_CONST, {.i64 = EXP }, 0, 0, FLAGS, "curve2" }, + { "iqsin", "inverted quarter of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = IQSIN}, 0, 0, FLAGS, "curve2" }, + { "ihsin", "inverted half of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = IHSIN}, 0, 0, FLAGS, "curve2" }, + { "dese", "double-exponential seat", 0, AV_OPT_TYPE_CONST, {.i64 = DESE }, 0, 0, FLAGS, "curve2" }, + { "desi", "double-exponential sigmoid", 0, AV_OPT_TYPE_CONST, {.i64 = DESI }, 0, 0, FLAGS, "curve2" }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(acrossfade); + +#define CROSSFADE_PLANAR(name, type) \ +static void crossfade_samples_## name ##p(uint8_t **dst, uint8_t * const *cf0, \ + uint8_t * const *cf1, \ + int nb_samples, int channels, \ + int curve0, int curve1) \ +{ \ + int i, c; \ + \ + for (i = 0; i < nb_samples; i++) { \ + double gain0 = fade_gain(curve0, nb_samples - 1 - i, nb_samples); \ + double gain1 = fade_gain(curve1, i, nb_samples); \ + for (c = 0; c < channels; c++) { \ + type *d = (type *)dst[c]; \ + const type *s0 = (type *)cf0[c]; \ + const type *s1 = (type *)cf1[c]; \ + \ + d[i] = s0[i] * gain0 + s1[i] * gain1; \ + } \ + } \ +} + +#define CROSSFADE(name, type) \ +static void crossfade_samples_## name (uint8_t **dst, uint8_t * const *cf0, \ + uint8_t * const *cf1, \ + int nb_samples, int channels, \ + int curve0, int curve1) \ +{ \ + type *d = (type *)dst[0]; \ + const type *s0 = (type *)cf0[0]; \ + const type *s1 = (type *)cf1[0]; \ + int i, c, k = 0; \ + \ + for (i = 0; i < nb_samples; i++) { \ + double gain0 = fade_gain(curve0, nb_samples - 1 - i, nb_samples); \ + double gain1 = fade_gain(curve1, i, nb_samples); \ + for (c = 0; c < channels; c++, k++) \ + d[k] = s0[k] * gain0 + s1[k] * gain1; \ + } \ +} + +CROSSFADE_PLANAR(dbl, double) +CROSSFADE_PLANAR(flt, float) +CROSSFADE_PLANAR(s16, int16_t) +CROSSFADE_PLANAR(s32, int32_t) + +CROSSFADE(dbl, double) +CROSSFADE(flt, float) +CROSSFADE(s16, int16_t) +CROSSFADE(s32, int32_t) + +static int acrossfade_filter_frame(AVFilterLink *inlink, AVFrame *in) +{ + AVFilterContext *ctx = inlink->dst; + AudioFadeContext *s = ctx->priv; + AVFilterLink *outlink = ctx->outputs[0]; + AVFrame *out, *cf[2] = { NULL }; + int ret = 0, nb_samples; + + if (s->crossfade_is_over) { + in->pts = s->pts; + s->pts += av_rescale_q(in->nb_samples, + (AVRational){ 1, outlink->sample_rate }, outlink->time_base); + return ff_filter_frame(outlink, in); + } else if (inlink == ctx->inputs[0]) { + av_audio_fifo_write(s->fifo[0], (void **)in->extended_data, in->nb_samples); + + nb_samples = av_audio_fifo_size(s->fifo[0]) - s->nb_samples; + if (nb_samples > 0) { + out = ff_get_audio_buffer(outlink, nb_samples); + if (!out) { + ret = AVERROR(ENOMEM); + goto fail; + } + av_audio_fifo_read(s->fifo[0], (void **)out->extended_data, nb_samples); + out->pts = s->pts; + s->pts += av_rescale_q(nb_samples, + (AVRational){ 1, outlink->sample_rate }, outlink->time_base); + ret = ff_filter_frame(outlink, out); + } + } else if (av_audio_fifo_size(s->fifo[1]) < s->nb_samples) { + if (!s->overlap && av_audio_fifo_size(s->fifo[0]) > 0) { + nb_samples = av_audio_fifo_size(s->fifo[0]); + + cf[0] = ff_get_audio_buffer(outlink, nb_samples); + out = ff_get_audio_buffer(outlink, nb_samples); + if (!out || !cf[0]) { + ret = AVERROR(ENOMEM); + goto fail; + } + av_audio_fifo_read(s->fifo[0], (void **)cf[0]->extended_data, nb_samples); + + s->fade_samples(out->extended_data, cf[0]->extended_data, nb_samples, + outlink->channels, -1, nb_samples - 1, nb_samples, s->curve); + out->pts = s->pts; + s->pts += av_rescale_q(nb_samples, + (AVRational){ 1, outlink->sample_rate }, outlink->time_base); + ret = ff_filter_frame(outlink, out); + if (ret < 0) + goto fail; + } + + av_audio_fifo_write(s->fifo[1], (void **)in->extended_data, in->nb_samples); + } else if (av_audio_fifo_size(s->fifo[1]) >= s->nb_samples) { + if (s->overlap) { + cf[0] = ff_get_audio_buffer(outlink, s->nb_samples); + cf[1] = ff_get_audio_buffer(outlink, s->nb_samples); + out = ff_get_audio_buffer(outlink, s->nb_samples); + if (!out || !cf[0] || !cf[1]) { + av_frame_free(&out); + ret = AVERROR(ENOMEM); + goto fail; + } + + av_audio_fifo_read(s->fifo[0], (void **)cf[0]->extended_data, s->nb_samples); + av_audio_fifo_read(s->fifo[1], (void **)cf[1]->extended_data, s->nb_samples); + + s->crossfade_samples(out->extended_data, cf[0]->extended_data, + cf[1]->extended_data, + s->nb_samples, av_frame_get_channels(in), + s->curve, s->curve2); + out->pts = s->pts; + s->pts += av_rescale_q(s->nb_samples, + (AVRational){ 1, outlink->sample_rate }, outlink->time_base); + ret = ff_filter_frame(outlink, out); + if (ret < 0) + goto fail; + } else { + out = ff_get_audio_buffer(outlink, s->nb_samples); + cf[1] = ff_get_audio_buffer(outlink, s->nb_samples); + if (!out || !cf[1]) { + ret = AVERROR(ENOMEM); + av_frame_free(&out); + goto fail; + } + + av_audio_fifo_read(s->fifo[1], (void **)cf[1]->extended_data, s->nb_samples); + + s->fade_samples(out->extended_data, cf[1]->extended_data, s->nb_samples, + outlink->channels, 1, 0, s->nb_samples, s->curve2); + out->pts = s->pts; + s->pts += av_rescale_q(s->nb_samples, + (AVRational){ 1, outlink->sample_rate }, outlink->time_base); + ret = ff_filter_frame(outlink, out); + if (ret < 0) + goto fail; + } + + nb_samples = av_audio_fifo_size(s->fifo[1]); + if (nb_samples > 0) { + out = ff_get_audio_buffer(outlink, nb_samples); + if (!out) { + ret = AVERROR(ENOMEM); + goto fail; + } + + av_audio_fifo_read(s->fifo[1], (void **)out->extended_data, nb_samples); + out->pts = s->pts; + s->pts += av_rescale_q(nb_samples, + (AVRational){ 1, outlink->sample_rate }, outlink->time_base); + ret = ff_filter_frame(outlink, out); + } + s->crossfade_is_over = 1; + } + +fail: + av_frame_free(&in); + av_frame_free(&cf[0]); + av_frame_free(&cf[1]); + return ret; +} + +static int acrossfade_request_frame(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + AudioFadeContext *s = ctx->priv; + int ret = 0; + + if (!s->cf0_eof) { + AVFilterLink *cf0 = ctx->inputs[0]; + ret = ff_request_frame(cf0); + if (ret < 0 && ret != AVERROR_EOF) + return ret; + if (ret == AVERROR_EOF) { + s->cf0_eof = 1; + ret = 0; + } + } else { + AVFilterLink *cf1 = ctx->inputs[1]; + int nb_samples = av_audio_fifo_size(s->fifo[1]); + + ret = ff_request_frame(cf1); + if (ret == AVERROR_EOF && nb_samples > 0) { + AVFrame *out = ff_get_audio_buffer(outlink, nb_samples); + if (!out) + return AVERROR(ENOMEM); + + av_audio_fifo_read(s->fifo[1], (void **)out->extended_data, nb_samples); + ret = ff_filter_frame(outlink, out); + } + } + + return ret; +} + +static int acrossfade_config_output(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + AudioFadeContext *s = ctx->priv; + + if (ctx->inputs[0]->sample_rate != ctx->inputs[1]->sample_rate) { + av_log(ctx, AV_LOG_ERROR, + "Inputs must have the same sample rate " + "%d for in0 vs %d for in1\n", + ctx->inputs[0]->sample_rate, ctx->inputs[1]->sample_rate); + return AVERROR(EINVAL); + } + + outlink->sample_rate = ctx->inputs[0]->sample_rate; + outlink->time_base = ctx->inputs[0]->time_base; + outlink->channel_layout = ctx->inputs[0]->channel_layout; + outlink->channels = ctx->inputs[0]->channels; + outlink->flags |= FF_LINK_FLAG_REQUEST_LOOP; + + switch (outlink->format) { + case AV_SAMPLE_FMT_DBL: s->crossfade_samples = crossfade_samples_dbl; break; + case AV_SAMPLE_FMT_DBLP: s->crossfade_samples = crossfade_samples_dblp; break; + case AV_SAMPLE_FMT_FLT: s->crossfade_samples = crossfade_samples_flt; break; + case AV_SAMPLE_FMT_FLTP: s->crossfade_samples = crossfade_samples_fltp; break; + case AV_SAMPLE_FMT_S16: s->crossfade_samples = crossfade_samples_s16; break; + case AV_SAMPLE_FMT_S16P: s->crossfade_samples = crossfade_samples_s16p; break; + case AV_SAMPLE_FMT_S32: s->crossfade_samples = crossfade_samples_s32; break; + case AV_SAMPLE_FMT_S32P: s->crossfade_samples = crossfade_samples_s32p; break; + } + + config_output(outlink); + + s->fifo[0] = av_audio_fifo_alloc(outlink->format, outlink->channels, s->nb_samples); + s->fifo[1] = av_audio_fifo_alloc(outlink->format, outlink->channels, s->nb_samples); + if (!s->fifo[0] || !s->fifo[1]) + return AVERROR(ENOMEM); + + return 0; +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + AudioFadeContext *s = ctx->priv; + + av_audio_fifo_free(s->fifo[0]); + av_audio_fifo_free(s->fifo[1]); +} + +static const AVFilterPad avfilter_af_acrossfade_inputs[] = { + { + .name = "crossfade0", + .type = AVMEDIA_TYPE_AUDIO, + .filter_frame = acrossfade_filter_frame, + }, + { + .name = "crossfade1", + .type = AVMEDIA_TYPE_AUDIO, + .filter_frame = acrossfade_filter_frame, + }, + { NULL } +}; + +static const AVFilterPad avfilter_af_acrossfade_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .request_frame = acrossfade_request_frame, + .config_props = acrossfade_config_output, + }, + { NULL } +}; + +AVFilter ff_af_acrossfade = { + .name = "acrossfade", + .description = NULL_IF_CONFIG_SMALL("Cross fade two input audio streams."), + .query_formats = query_formats, + .priv_size = sizeof(AudioFadeContext), + .uninit = uninit, + .priv_class = &acrossfade_class, + .inputs = avfilter_af_acrossfade_inputs, + .outputs = avfilter_af_acrossfade_outputs, +}; + +#endif /* CONFIG_ACROSSFADE_FILTER */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_amerge.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_amerge.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_amerge.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_amerge.c 2015-07-20 17:20:03.000000000 +0000 @@ -32,7 +32,7 @@ #include "bufferqueue.h" #include "internal.h" -#define SWR_CH_MAX 32 +#define SWR_CH_MAX 64 typedef struct { const AVClass *class; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_aresample.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_aresample.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_aresample.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_aresample.c 2015-07-18 17:20:03.000000000 +0000 @@ -87,15 +87,24 @@ AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; - AVFilterFormats *in_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO); - AVFilterFormats *out_formats; - AVFilterFormats *in_samplerates = ff_all_samplerates(); - AVFilterFormats *out_samplerates; - AVFilterChannelLayouts *in_layouts = ff_all_channel_counts(); - AVFilterChannelLayouts *out_layouts; + AVFilterFormats *in_formats, *out_formats; + AVFilterFormats *in_samplerates, *out_samplerates; + AVFilterChannelLayouts *in_layouts, *out_layouts; + + in_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO); + if (!in_formats) + return AVERROR(ENOMEM); ff_formats_ref (in_formats, &inlink->out_formats); + + in_samplerates = ff_all_samplerates(); + if (!in_samplerates) + return AVERROR(ENOMEM); ff_formats_ref (in_samplerates, &inlink->out_samplerates); + + in_layouts = ff_all_channel_counts(); + if (!in_layouts) + return AVERROR(ENOMEM); ff_channel_layouts_ref(in_layouts, &inlink->out_channel_layouts); if(out_rate > 0) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_astats.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_astats.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_astats.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_astats.c 2015-07-20 17:20:03.000000000 +0000 @@ -33,6 +33,9 @@ double min, max; double min_run, max_run; double min_runs, max_runs; + double min_diff, max_diff; + double diff1_sum; + uint64_t mask; uint64_t min_count, max_count; uint64_t nb_samples; } ChannelStats; @@ -44,6 +47,9 @@ uint64_t tc_samples; double time_constant; double mult; + int metadata; + int reset_count; + int nb_frames; } AudioStatsContext; #define OFFSET(x) offsetof(AudioStatsContext, x) @@ -51,6 +57,8 @@ static const AVOption astats_options[] = { { "length", "set the window length", OFFSET(time_constant), AV_OPT_TYPE_DOUBLE, {.dbl=.05}, .01, 10, FLAGS }, + { "metadata", "inject metadata in the filtergraph", OFFSET(metadata), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS }, + { "reset", "recalculate stats after this many frames", OFFSET(reset_count), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS }, { NULL } }; @@ -86,10 +94,24 @@ return ff_set_common_samplerates(ctx, formats); } +static void reset_stats(AudioStatsContext *s) +{ + int c; + + memset(s->chstats, 0, sizeof(*s->chstats)); + + for (c = 0; c < s->nb_channels; c++) { + ChannelStats *p = &s->chstats[c]; + + p->min = p->min_sigma_x2 = DBL_MAX; + p->max = p->max_sigma_x2 = DBL_MIN; + p->min_diff = p->max_diff = -1; + } +} + static int config_output(AVFilterLink *outlink) { AudioStatsContext *s = outlink->src->priv; - int c; s->chstats = av_calloc(sizeof(*s->chstats), outlink->channels); if (!s->chstats) @@ -98,16 +120,20 @@ s->mult = exp((-1 / s->time_constant / outlink->sample_rate)); s->tc_samples = 5 * s->time_constant * outlink->sample_rate + .5; - for (c = 0; c < s->nb_channels; c++) { - ChannelStats *p = &s->chstats[c]; - - p->min = p->min_sigma_x2 = DBL_MAX; - p->max = p->max_sigma_x2 = DBL_MIN; - } + reset_stats(s); return 0; } +static unsigned bit_depth(uint64_t mask) +{ + unsigned result = 64; + + for (; result && !(mask & 1); --result, mask >>= 1); + + return result; +} + static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d) { if (d < p->min) { @@ -137,7 +163,11 @@ p->sigma_x += d; p->sigma_x2 += d * d; p->avg_sigma_x2 = p->avg_sigma_x2 * s->mult + (1.0 - s->mult) * d * d; + p->min_diff = FFMIN(p->min_diff == -1 ? DBL_MAX : p->min_diff, FFABS(d - (p->min_diff == -1 ? DBL_MAX : p->last))); + p->max_diff = FFMAX(p->max_diff, FFABS(d - (p->max_diff == -1 ? d : p->last))); + p->diff1_sum += FFABS(d - p->last); p->last = d; + p->mask |= llrint(d * (UINT64_C(1) << 63)); if (p->nb_samples >= s->tc_samples) { p->max_sigma_x2 = FFMAX(p->max_sigma_x2, p->avg_sigma_x2); @@ -146,9 +176,95 @@ p->nb_samples++; } +static void set_meta(AVDictionary **metadata, int chan, const char *key, + const char *fmt, double val) +{ + uint8_t value[128]; + uint8_t key2[128]; + + snprintf(value, sizeof(value), fmt, val); + if (chan) + snprintf(key2, sizeof(key2), "lavfi.astats.%d.%s", chan, key); + else + snprintf(key2, sizeof(key2), "lavfi.astats.%s", key); + av_dict_set(metadata, key2, value, 0); +} + +#define LINEAR_TO_DB(x) (log10(x) * 20) + +static void set_metadata(AudioStatsContext *s, AVDictionary **metadata) +{ + uint64_t mask = 0, min_count = 0, max_count = 0, nb_samples = 0; + double min_runs = 0, max_runs = 0, + min = DBL_MAX, max = DBL_MIN, min_diff = DBL_MAX, max_diff = 0, + max_sigma_x = 0, + diff1_sum = 0, + sigma_x = 0, + sigma_x2 = 0, + min_sigma_x2 = DBL_MAX, + max_sigma_x2 = DBL_MIN; + int c; + + for (c = 0; c < s->nb_channels; c++) { + ChannelStats *p = &s->chstats[c]; + + if (p->nb_samples < s->tc_samples) + p->min_sigma_x2 = p->max_sigma_x2 = p->sigma_x2 / p->nb_samples; + + min = FFMIN(min, p->min); + max = FFMAX(max, p->max); + min_diff = FFMIN(min_diff, p->min_diff); + max_diff = FFMAX(max_diff, p->max_diff); + diff1_sum += p->diff1_sum, + min_sigma_x2 = FFMIN(min_sigma_x2, p->min_sigma_x2); + max_sigma_x2 = FFMAX(max_sigma_x2, p->max_sigma_x2); + sigma_x += p->sigma_x; + sigma_x2 += p->sigma_x2; + min_count += p->min_count; + max_count += p->max_count; + min_runs += p->min_runs; + max_runs += p->max_runs; + mask |= p->mask; + nb_samples += p->nb_samples; + if (fabs(p->sigma_x) > fabs(max_sigma_x)) + max_sigma_x = p->sigma_x; + + set_meta(metadata, c + 1, "DC_offset", "%f", p->sigma_x / p->nb_samples); + set_meta(metadata, c + 1, "Min_level", "%f", p->min); + set_meta(metadata, c + 1, "Max_level", "%f", p->max); + set_meta(metadata, c + 1, "Min_difference", "%f", p->min_diff); + set_meta(metadata, c + 1, "Max_difference", "%f", p->max_diff); + set_meta(metadata, c + 1, "Mean_difference", "%f", p->diff1_sum / (p->nb_samples - 1)); + set_meta(metadata, c + 1, "Peak_level", "%f", LINEAR_TO_DB(FFMAX(-p->min, p->max))); + set_meta(metadata, c + 1, "RMS_level", "%f", LINEAR_TO_DB(sqrt(p->sigma_x2 / p->nb_samples))); + set_meta(metadata, c + 1, "RMS_peak", "%f", LINEAR_TO_DB(sqrt(p->max_sigma_x2))); + set_meta(metadata, c + 1, "RMS_trough", "%f", LINEAR_TO_DB(sqrt(p->min_sigma_x2))); + set_meta(metadata, c + 1, "Crest_factor", "%f", p->sigma_x2 ? FFMAX(-p->min, p->max) / sqrt(p->sigma_x2 / p->nb_samples) : 1); + set_meta(metadata, c + 1, "Flat_factor", "%f", LINEAR_TO_DB((p->min_runs + p->max_runs) / (p->min_count + p->max_count))); + set_meta(metadata, c + 1, "Peak_count", "%f", (float)(p->min_count + p->max_count)); + set_meta(metadata, c + 1, "Bit_depth", "%f", bit_depth(p->mask)); + } + + set_meta(metadata, 0, "Overall.DC_offset", "%f", max_sigma_x / (nb_samples / s->nb_channels)); + set_meta(metadata, 0, "Overall.Min_level", "%f", min); + set_meta(metadata, 0, "Overall.Max_level", "%f", max); + set_meta(metadata, 0, "Overall.Min_difference", "%f", min_diff); + set_meta(metadata, 0, "Overall.Max_difference", "%f", max_diff); + set_meta(metadata, 0, "Overall.Mean_difference", "%f", diff1_sum / (nb_samples - s->nb_channels)); + set_meta(metadata, 0, "Overall.Peak_level", "%f", LINEAR_TO_DB(FFMAX(-min, max))); + set_meta(metadata, 0, "Overall.RMS_level", "%f", LINEAR_TO_DB(sqrt(sigma_x2 / nb_samples))); + set_meta(metadata, 0, "Overall.RMS_peak", "%f", LINEAR_TO_DB(sqrt(max_sigma_x2))); + set_meta(metadata, 0, "Overall.RMS_trough", "%f", LINEAR_TO_DB(sqrt(min_sigma_x2))); + set_meta(metadata, 0, "Overall.Flat_factor", "%f", LINEAR_TO_DB((min_runs + max_runs) / (min_count + max_count))); + set_meta(metadata, 0, "Overall.Peak_count", "%f", (float)(min_count + max_count) / (double)s->nb_channels); + set_meta(metadata, 0, "Overall.Bit_depth", "%f", bit_depth(mask)); + set_meta(metadata, 0, "Overall.Number_of_samples", "%f", nb_samples / s->nb_channels); +} + static int filter_frame(AVFilterLink *inlink, AVFrame *buf) { AudioStatsContext *s = inlink->dst->priv; + AVDictionary **metadata = avpriv_frame_get_metadatap(buf); const int channels = s->nb_channels; const double *src; int i, c; @@ -173,18 +289,28 @@ break; } + if (s->metadata) + set_metadata(s, metadata); + + if (s->reset_count > 0) { + s->nb_frames++; + if (s->nb_frames >= s->reset_count) { + reset_stats(s); + s->nb_frames = 0; + } + } + return ff_filter_frame(inlink->dst->outputs[0], buf); } -#define LINEAR_TO_DB(x) (log10(x) * 20) - static void print_stats(AVFilterContext *ctx) { AudioStatsContext *s = ctx->priv; - uint64_t min_count = 0, max_count = 0, nb_samples = 0; + uint64_t mask = 0, min_count = 0, max_count = 0, nb_samples = 0; double min_runs = 0, max_runs = 0, - min = DBL_MAX, max = DBL_MIN, + min = DBL_MAX, max = DBL_MIN, min_diff = DBL_MAX, max_diff = 0, max_sigma_x = 0, + diff1_sum = 0, sigma_x = 0, sigma_x2 = 0, min_sigma_x2 = DBL_MAX, @@ -199,6 +325,9 @@ min = FFMIN(min, p->min); max = FFMAX(max, p->max); + min_diff = FFMIN(min_diff, p->min_diff); + max_diff = FFMAX(max_diff, p->max_diff); + diff1_sum += p->diff1_sum, min_sigma_x2 = FFMIN(min_sigma_x2, p->min_sigma_x2); max_sigma_x2 = FFMAX(max_sigma_x2, p->max_sigma_x2); sigma_x += p->sigma_x; @@ -207,6 +336,7 @@ max_count += p->max_count; min_runs += p->min_runs; max_runs += p->max_runs; + mask |= p->mask; nb_samples += p->nb_samples; if (fabs(p->sigma_x) > fabs(max_sigma_x)) max_sigma_x = p->sigma_x; @@ -215,6 +345,9 @@ av_log(ctx, AV_LOG_INFO, "DC offset: %f\n", p->sigma_x / p->nb_samples); av_log(ctx, AV_LOG_INFO, "Min level: %f\n", p->min); av_log(ctx, AV_LOG_INFO, "Max level: %f\n", p->max); + av_log(ctx, AV_LOG_INFO, "Min difference: %f\n", p->min_diff); + av_log(ctx, AV_LOG_INFO, "Max difference: %f\n", p->max_diff); + av_log(ctx, AV_LOG_INFO, "Mean difference: %f\n", p->diff1_sum / (p->nb_samples - 1)); av_log(ctx, AV_LOG_INFO, "Peak level dB: %f\n", LINEAR_TO_DB(FFMAX(-p->min, p->max))); av_log(ctx, AV_LOG_INFO, "RMS level dB: %f\n", LINEAR_TO_DB(sqrt(p->sigma_x2 / p->nb_samples))); av_log(ctx, AV_LOG_INFO, "RMS peak dB: %f\n", LINEAR_TO_DB(sqrt(p->max_sigma_x2))); @@ -223,12 +356,16 @@ av_log(ctx, AV_LOG_INFO, "Crest factor: %f\n", p->sigma_x2 ? FFMAX(-p->min, p->max) / sqrt(p->sigma_x2 / p->nb_samples) : 1); av_log(ctx, AV_LOG_INFO, "Flat factor: %f\n", LINEAR_TO_DB((p->min_runs + p->max_runs) / (p->min_count + p->max_count))); av_log(ctx, AV_LOG_INFO, "Peak count: %"PRId64"\n", p->min_count + p->max_count); + av_log(ctx, AV_LOG_INFO, "Bit depth: %u\n", bit_depth(p->mask)); } av_log(ctx, AV_LOG_INFO, "Overall\n"); av_log(ctx, AV_LOG_INFO, "DC offset: %f\n", max_sigma_x / (nb_samples / s->nb_channels)); av_log(ctx, AV_LOG_INFO, "Min level: %f\n", min); av_log(ctx, AV_LOG_INFO, "Max level: %f\n", max); + av_log(ctx, AV_LOG_INFO, "Min difference: %f\n", min_diff); + av_log(ctx, AV_LOG_INFO, "Max difference: %f\n", max_diff); + av_log(ctx, AV_LOG_INFO, "Mean difference: %f\n", diff1_sum / (nb_samples - s->nb_channels)); av_log(ctx, AV_LOG_INFO, "Peak level dB: %f\n", LINEAR_TO_DB(FFMAX(-min, max))); av_log(ctx, AV_LOG_INFO, "RMS level dB: %f\n", LINEAR_TO_DB(sqrt(sigma_x2 / nb_samples))); av_log(ctx, AV_LOG_INFO, "RMS peak dB: %f\n", LINEAR_TO_DB(sqrt(max_sigma_x2))); @@ -236,6 +373,7 @@ av_log(ctx, AV_LOG_INFO, "RMS trough dB: %f\n", LINEAR_TO_DB(sqrt(min_sigma_x2))); av_log(ctx, AV_LOG_INFO, "Flat factor: %f\n", LINEAR_TO_DB((min_runs + max_runs) / (min_count + max_count))); av_log(ctx, AV_LOG_INFO, "Peak count: %f\n", (min_count + max_count) / (double)s->nb_channels); + av_log(ctx, AV_LOG_INFO, "Bit depth: %u\n", bit_depth(mask)); av_log(ctx, AV_LOG_INFO, "Number of samples: %"PRId64"\n", nb_samples / s->nb_channels); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_bs2b.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_bs2b.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_bs2b.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_bs2b.c 2015-07-03 17:20:03.000000000 +0000 @@ -47,7 +47,7 @@ #define OFFSET(x) offsetof(Bs2bContext, x) #define A AV_OPT_FLAG_AUDIO_PARAM -static const AVOption options[] = { +static const AVOption bs2b_options[] = { { "profile", "Apply a pre-defined crossfeed level", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = BS2B_DEFAULT_CLEVEL }, 0, INT_MAX, A, "profile" }, { "default", "default profile", 0, AV_OPT_TYPE_CONST, { .i64 = BS2B_DEFAULT_CLEVEL }, 0, 0, A, "profile" }, @@ -60,12 +60,7 @@ { NULL }, }; -static const AVClass bs2b_class = { - .class_name = "bs2b filter", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; +AVFILTER_DEFINE_CLASS(bs2b); static av_cold int init(AVFilterContext *ctx) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_channelmap.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_channelmap.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_channelmap.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_channelmap.c 2015-07-23 17:20:03.000000000 +0000 @@ -57,7 +57,6 @@ #define MAX_CH 64 typedef struct ChannelMapContext { const AVClass *class; - AVFilterChannelLayouts *channel_layouts; char *mapping_str; char *channel_layout_str; uint64_t output_layout; @@ -275,8 +274,6 @@ return AVERROR(EINVAL); } - ff_add_channel_layout(&s->channel_layouts, s->output_layout); - if (mode == MAP_PAIR_INT_STR || mode == MAP_PAIR_STR_STR) { for (i = 0; i < s->nch; i++) { s->map[i].out_channel_idx = av_get_channel_layout_channel_index( @@ -291,6 +288,9 @@ { ChannelMapContext *s = ctx->priv; AVFilterChannelLayouts *layouts; + AVFilterChannelLayouts *channel_layouts = NULL; + + ff_add_channel_layout(&channel_layouts, s->output_layout); ff_set_common_formats(ctx, ff_planar_sample_fmts()); ff_set_common_samplerates(ctx, ff_all_samplerates()); @@ -300,7 +300,7 @@ return AVERROR(ENOMEM); ff_channel_layouts_ref(layouts, &ctx->inputs[0]->out_channel_layouts); - ff_channel_layouts_ref(s->channel_layouts, &ctx->outputs[0]->in_channel_layouts); + ff_channel_layouts_ref(channel_layouts, &ctx->outputs[0]->in_channel_layouts); return 0; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_compand.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_compand.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_compand.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_compand.c 2015-07-17 17:20:02.000000000 +0000 @@ -398,6 +398,11 @@ return AVERROR(EINVAL); } + for (i = nb_decays; i < channels; i++) { + s->channels[i].attack = s->channels[nb_decays - 1].attack; + s->channels[i].decay = s->channels[nb_decays - 1].decay; + } + #define S(x) s->segments[2 * ((x) + 1)] p = s->points; for (i = 0, new_nb_items = 0; i < nb_points; i++) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_dynaudnorm.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_dynaudnorm.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_dynaudnorm.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_dynaudnorm.c 2015-07-18 17:20:03.000000000 +0000 @@ -0,0 +1,740 @@ +/* + * Dynamic Audio Normalizer + * Copyright (c) 2015 LoRd_MuldeR . Some rights reserved. + * + * 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 + */ + +/** + * @file + * Dynamic Audio Normalizer + */ + +#include + +#include "libavutil/avassert.h" +#include "libavutil/opt.h" + +#define FF_BUFQUEUE_SIZE 302 +#include "libavfilter/bufferqueue.h" + +#include "audio.h" +#include "avfilter.h" +#include "internal.h" + +typedef struct cqueue { + double *elements; + int size; + int nb_elements; + int first; +} cqueue; + +typedef struct DynamicAudioNormalizerContext { + const AVClass *class; + + struct FFBufQueue queue; + + int frame_len; + int frame_len_msec; + int filter_size; + int dc_correction; + int channels_coupled; + int alt_boundary_mode; + + double peak_value; + double max_amplification; + double target_rms; + double compress_factor; + double *prev_amplification_factor; + double *dc_correction_value; + double *compress_threshold; + double *fade_factors[2]; + double *weights; + + int channels; + int delay; + + cqueue **gain_history_original; + cqueue **gain_history_minimum; + cqueue **gain_history_smoothed; +} DynamicAudioNormalizerContext; + +#define OFFSET(x) offsetof(DynamicAudioNormalizerContext, x) +#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption dynaudnorm_options[] = { + { "f", "set the frame length in msec", OFFSET(frame_len_msec), AV_OPT_TYPE_INT, {.i64 = 500}, 10, 8000, FLAGS }, + { "g", "set the filter size", OFFSET(filter_size), AV_OPT_TYPE_INT, {.i64 = 31}, 3, 301, FLAGS }, + { "p", "set the peak value", OFFSET(peak_value), AV_OPT_TYPE_DOUBLE, {.dbl = 0.95}, 0.0, 1.0, FLAGS }, + { "m", "set the max amplification", OFFSET(max_amplification), AV_OPT_TYPE_DOUBLE, {.dbl = 10.0}, 1.0, 100.0, FLAGS }, + { "r", "set the target RMS", OFFSET(target_rms), AV_OPT_TYPE_DOUBLE, {.dbl = 0.0}, 0.0, 1.0, FLAGS }, + { "n", "enable channel coupling", OFFSET(channels_coupled), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, FLAGS }, + { "c", "enable DC correction", OFFSET(dc_correction), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, FLAGS }, + { "b", "enable alternative boundary mode", OFFSET(alt_boundary_mode), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, FLAGS }, + { "s", "set the compress factor", OFFSET(compress_factor), AV_OPT_TYPE_DOUBLE, {.dbl = 0.0}, 0.0, 30.0, FLAGS }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(dynaudnorm); + +static av_cold int init(AVFilterContext *ctx) +{ + DynamicAudioNormalizerContext *s = ctx->priv; + + if (!(s->filter_size & 1)) { + av_log(ctx, AV_LOG_ERROR, "filter size %d is invalid. Must be an odd value.\n", s->filter_size); + return AVERROR(EINVAL); + } + + return 0; +} + +static int query_formats(AVFilterContext *ctx) +{ + AVFilterFormats *formats; + AVFilterChannelLayouts *layouts; + static const enum AVSampleFormat sample_fmts[] = { + AV_SAMPLE_FMT_DBLP, + AV_SAMPLE_FMT_NONE + }; + int ret; + + layouts = ff_all_channel_layouts(); + if (!layouts) + return AVERROR(ENOMEM); + ret = ff_set_common_channel_layouts(ctx, layouts); + if (ret < 0) + return ret; + + formats = ff_make_format_list(sample_fmts); + if (!formats) + return AVERROR(ENOMEM); + ret = ff_set_common_formats(ctx, formats); + if (ret < 0) + return ret; + + formats = ff_all_samplerates(); + if (!formats) + return AVERROR(ENOMEM); + return ff_set_common_samplerates(ctx, formats); +} + +static inline int frame_size(int sample_rate, int frame_len_msec) +{ + const int frame_size = round((double)sample_rate * (frame_len_msec / 1000.0)); + return frame_size + (frame_size % 2); +} + +static void precalculate_fade_factors(double *fade_factors[2], int frame_len) +{ + const double step_size = 1.0 / frame_len; + int pos; + + for (pos = 0; pos < frame_len; pos++) { + fade_factors[0][pos] = 1.0 - (step_size * (pos + 1.0)); + fade_factors[1][pos] = 1.0 - fade_factors[0][pos]; + } +} + +static cqueue *cqueue_create(int size) +{ + cqueue *q; + + q = av_malloc(sizeof(cqueue)); + if (!q) + return NULL; + + q->size = size; + q->nb_elements = 0; + q->first = 0; + + q->elements = av_malloc(sizeof(double) * size); + if (!q->elements) { + av_free(q); + return NULL; + } + + return q; +} + +static void cqueue_free(cqueue *q) +{ + av_free(q->elements); + av_free(q); +} + +static int cqueue_size(cqueue *q) +{ + return q->nb_elements; +} + +static int cqueue_empty(cqueue *q) +{ + return !q->nb_elements; +} + +static int cqueue_enqueue(cqueue *q, double element) +{ + int i; + + av_assert2(q->nb_elements |= q->size); + + i = (q->first + q->nb_elements) % q->size; + q->elements[i] = element; + q->nb_elements++; + + return 0; +} + +static double cqueue_peek(cqueue *q, int index) +{ + av_assert2(index < q->nb_elements); + return q->elements[(q->first + index) % q->size]; +} + +static int cqueue_dequeue(cqueue *q, double *element) +{ + av_assert2(!cqueue_empty(q)); + + *element = q->elements[q->first]; + q->first = (q->first + 1) % q->size; + q->nb_elements--; + + return 0; +} + +static int cqueue_pop(cqueue *q) +{ + av_assert2(!cqueue_empty(q)); + + q->first = (q->first + 1) % q->size; + q->nb_elements--; + + return 0; +} + +static const double s_pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679; + +static void init_gaussian_filter(DynamicAudioNormalizerContext *s) +{ + double total_weight = 0.0; + const double sigma = (((s->filter_size / 2.0) - 1.0) / 3.0) + (1.0 / 3.0); + double adjust; + int i; + + // Pre-compute constants + const int offset = s->filter_size / 2; + const double c1 = 1.0 / (sigma * sqrt(2.0 * s_pi)); + const double c2 = 2.0 * pow(sigma, 2.0); + + // Compute weights + for (i = 0; i < s->filter_size; i++) { + const int x = i - offset; + + s->weights[i] = c1 * exp(-(pow(x, 2.0) / c2)); + total_weight += s->weights[i]; + } + + // Adjust weights + adjust = 1.0 / total_weight; + for (i = 0; i < s->filter_size; i++) { + s->weights[i] *= adjust; + } +} + +static int config_input(AVFilterLink *inlink) +{ + AVFilterContext *ctx = inlink->dst; + DynamicAudioNormalizerContext *s = ctx->priv; + int c; + + s->frame_len = + inlink->min_samples = + inlink->max_samples = + inlink->partial_buf_size = frame_size(inlink->sample_rate, s->frame_len_msec); + av_log(ctx, AV_LOG_DEBUG, "frame len %d\n", s->frame_len); + + s->fade_factors[0] = av_malloc(s->frame_len * sizeof(*s->fade_factors[0])); + s->fade_factors[1] = av_malloc(s->frame_len * sizeof(*s->fade_factors[1])); + + s->prev_amplification_factor = av_malloc(inlink->channels * sizeof(*s->prev_amplification_factor)); + s->dc_correction_value = av_calloc(inlink->channels, sizeof(*s->dc_correction_value)); + s->compress_threshold = av_calloc(inlink->channels, sizeof(*s->compress_threshold)); + s->gain_history_original = av_calloc(inlink->channels, sizeof(*s->gain_history_original)); + s->gain_history_minimum = av_calloc(inlink->channels, sizeof(*s->gain_history_minimum)); + s->gain_history_smoothed = av_calloc(inlink->channels, sizeof(*s->gain_history_smoothed)); + s->weights = av_malloc(s->filter_size * sizeof(*s->weights)); + if (!s->prev_amplification_factor || !s->dc_correction_value || + !s->compress_threshold || !s->fade_factors[0] || !s->fade_factors[1] || + !s->gain_history_original || !s->gain_history_minimum || + !s->gain_history_smoothed || !s->weights) + return AVERROR(ENOMEM); + + for (c = 0; c < inlink->channels; c++) { + s->prev_amplification_factor[c] = 1.0; + + s->gain_history_original[c] = cqueue_create(s->filter_size); + s->gain_history_minimum[c] = cqueue_create(s->filter_size); + s->gain_history_smoothed[c] = cqueue_create(s->filter_size); + + if (!s->gain_history_original[c] || !s->gain_history_minimum[c] || + !s->gain_history_smoothed[c]) + return AVERROR(ENOMEM); + } + + precalculate_fade_factors(s->fade_factors, s->frame_len); + init_gaussian_filter(s); + + s->channels = inlink->channels; + s->delay = s->filter_size; + + return 0; +} + +static int config_output(AVFilterLink *outlink) +{ + outlink->flags |= FF_LINK_FLAG_REQUEST_LOOP; + return 0; +} + +static inline double fade(double prev, double next, int pos, + double *fade_factors[2]) +{ + return fade_factors[0][pos] * prev + fade_factors[1][pos] * next; +} + +static inline double pow2(const double value) +{ + return value * value; +} + +static inline double bound(const double threshold, const double val) +{ + const double CONST = 0.8862269254527580136490837416705725913987747280611935; //sqrt(PI) / 2.0 + return erf(CONST * (val / threshold)) * threshold; +} + +static double find_peak_magnitude(AVFrame *frame, int channel) +{ + double max = DBL_EPSILON; + int c, i; + + if (channel == -1) { + for (c = 0; c < av_frame_get_channels(frame); c++) { + double *data_ptr = (double *)frame->extended_data[c]; + + for (i = 0; i < frame->nb_samples; i++) + max = FFMAX(max, fabs(data_ptr[i])); + } + } else { + double *data_ptr = (double *)frame->extended_data[channel]; + + for (i = 0; i < frame->nb_samples; i++) + max = FFMAX(max, fabs(data_ptr[i])); + } + + return max; +} + +static double compute_frame_rms(AVFrame *frame, int channel) +{ + double rms_value = 0.0; + int c, i; + + if (channel == -1) { + for (c = 0; c < av_frame_get_channels(frame); c++) { + const double *data_ptr = (double *)frame->extended_data[c]; + + for (i = 0; i < frame->nb_samples; i++) { + rms_value += pow2(data_ptr[i]); + } + } + + rms_value /= frame->nb_samples * av_frame_get_channels(frame); + } else { + const double *data_ptr = (double *)frame->extended_data[channel]; + for (i = 0; i < frame->nb_samples; i++) { + rms_value += pow2(data_ptr[i]); + } + + rms_value /= frame->nb_samples; + } + + return FFMAX(sqrt(rms_value), DBL_EPSILON); +} + +static double get_max_local_gain(DynamicAudioNormalizerContext *s, AVFrame *frame, + int channel) +{ + const double maximum_gain = s->peak_value / find_peak_magnitude(frame, channel); + const double rms_gain = s->target_rms > DBL_EPSILON ? (s->target_rms / compute_frame_rms(frame, channel)) : DBL_MAX; + return bound(s->max_amplification, FFMIN(maximum_gain, rms_gain)); +} + +static double minimum_filter(cqueue *q) +{ + double min = DBL_MAX; + int i; + + for (i = 0; i < cqueue_size(q); i++) { + min = FFMIN(min, cqueue_peek(q, i)); + } + + return min; +} + +static double gaussian_filter(DynamicAudioNormalizerContext *s, cqueue *q) +{ + double result = 0.0; + int i; + + for (i = 0; i < cqueue_size(q); i++) { + result += cqueue_peek(q, i) * s->weights[i]; + } + + return result; +} + +static void update_gain_history(DynamicAudioNormalizerContext *s, int channel, + double current_gain_factor) +{ + if (cqueue_empty(s->gain_history_original[channel]) || + cqueue_empty(s->gain_history_minimum[channel])) { + const int pre_fill_size = s->filter_size / 2; + + s->prev_amplification_factor[channel] = s->alt_boundary_mode ? current_gain_factor : 1.0; + + while (cqueue_size(s->gain_history_original[channel]) < pre_fill_size) { + cqueue_enqueue(s->gain_history_original[channel], s->alt_boundary_mode ? current_gain_factor : 1.0); + } + + while (cqueue_size(s->gain_history_minimum[channel]) < pre_fill_size) { + cqueue_enqueue(s->gain_history_minimum[channel], s->alt_boundary_mode ? current_gain_factor : 1.0); + } + } + + cqueue_enqueue(s->gain_history_original[channel], current_gain_factor); + + while (cqueue_size(s->gain_history_original[channel]) >= s->filter_size) { + double minimum; + av_assert0(cqueue_size(s->gain_history_original[channel]) == s->filter_size); + minimum = minimum_filter(s->gain_history_original[channel]); + + cqueue_enqueue(s->gain_history_minimum[channel], minimum); + + cqueue_pop(s->gain_history_original[channel]); + } + + while (cqueue_size(s->gain_history_minimum[channel]) >= s->filter_size) { + double smoothed; + av_assert0(cqueue_size(s->gain_history_minimum[channel]) == s->filter_size); + smoothed = gaussian_filter(s, s->gain_history_minimum[channel]); + + cqueue_enqueue(s->gain_history_smoothed[channel], smoothed); + + cqueue_pop(s->gain_history_minimum[channel]); + } +} + +static inline double update_value(double new, double old, double aggressiveness) +{ + av_assert0((aggressiveness >= 0.0) && (aggressiveness <= 1.0)); + return aggressiveness * new + (1.0 - aggressiveness) * old; +} + +static void perform_dc_correction(DynamicAudioNormalizerContext *s, AVFrame *frame) +{ + const double diff = 1.0 / frame->nb_samples; + int is_first_frame = cqueue_empty(s->gain_history_original[0]); + int c, i; + + for (c = 0; c < s->channels; c++) { + double *dst_ptr = (double *)frame->extended_data[c]; + double current_average_value = 0.0; + double prev_value; + + for (i = 0; i < frame->nb_samples; i++) + current_average_value += dst_ptr[i] * diff; + + prev_value = is_first_frame ? current_average_value : s->dc_correction_value[c]; + s->dc_correction_value[c] = is_first_frame ? current_average_value : update_value(current_average_value, s->dc_correction_value[c], 0.1); + + for (i = 0; i < frame->nb_samples; i++) { + dst_ptr[i] -= fade(prev_value, s->dc_correction_value[c], i, s->fade_factors); + } + } +} + +static double setup_compress_thresh(double threshold) +{ + if ((threshold > DBL_EPSILON) && (threshold < (1.0 - DBL_EPSILON))) { + double current_threshold = threshold; + double step_size = 1.0; + + while (step_size > DBL_EPSILON) { + while ((current_threshold + step_size > current_threshold) && + (bound(current_threshold + step_size, 1.0) <= threshold)) { + current_threshold += step_size; + } + + step_size /= 2.0; + } + + return current_threshold; + } else { + return threshold; + } +} + +static double compute_frame_std_dev(DynamicAudioNormalizerContext *s, + AVFrame *frame, int channel) +{ + double variance = 0.0; + int i, c; + + if (channel == -1) { + for (c = 0; c < s->channels; c++) { + const double *data_ptr = (double *)frame->extended_data[c]; + + for (i = 0; i < frame->nb_samples; i++) { + variance += pow2(data_ptr[i]); // Assume that MEAN is *zero* + } + } + variance /= (s->channels * frame->nb_samples) - 1; + } else { + const double *data_ptr = (double *)frame->extended_data[channel]; + + for (i = 0; i < frame->nb_samples; i++) { + variance += pow2(data_ptr[i]); // Assume that MEAN is *zero* + } + variance /= frame->nb_samples - 1; + } + + return FFMAX(sqrt(variance), DBL_EPSILON); +} + +static void perform_compression(DynamicAudioNormalizerContext *s, AVFrame *frame) +{ + int is_first_frame = cqueue_empty(s->gain_history_original[0]); + int c, i; + + if (s->channels_coupled) { + const double standard_deviation = compute_frame_std_dev(s, frame, -1); + const double current_threshold = FFMIN(1.0, s->compress_factor * standard_deviation); + + const double prev_value = is_first_frame ? current_threshold : s->compress_threshold[0]; + double prev_actual_thresh, curr_actual_thresh; + s->compress_threshold[0] = is_first_frame ? current_threshold : update_value(current_threshold, s->compress_threshold[0], (1.0/3.0)); + + prev_actual_thresh = setup_compress_thresh(prev_value); + curr_actual_thresh = setup_compress_thresh(s->compress_threshold[0]); + + for (c = 0; c < s->channels; c++) { + double *const dst_ptr = (double *)frame->extended_data[c]; + for (i = 0; i < frame->nb_samples; i++) { + const double localThresh = fade(prev_actual_thresh, curr_actual_thresh, i, s->fade_factors); + dst_ptr[i] = copysign(bound(localThresh, fabs(dst_ptr[i])), dst_ptr[i]); + } + } + } else { + for (c = 0; c < s->channels; c++) { + const double standard_deviation = compute_frame_std_dev(s, frame, c); + const double current_threshold = setup_compress_thresh(FFMIN(1.0, s->compress_factor * standard_deviation)); + + const double prev_value = is_first_frame ? current_threshold : s->compress_threshold[c]; + double prev_actual_thresh, curr_actual_thresh; + double *dst_ptr; + s->compress_threshold[c] = is_first_frame ? current_threshold : update_value(current_threshold, s->compress_threshold[c], 1.0/3.0); + + prev_actual_thresh = setup_compress_thresh(prev_value); + curr_actual_thresh = setup_compress_thresh(s->compress_threshold[c]); + + dst_ptr = (double *)frame->extended_data[c]; + for (i = 0; i < frame->nb_samples; i++) { + const double localThresh = fade(prev_actual_thresh, curr_actual_thresh, i, s->fade_factors); + dst_ptr[i] = copysign(bound(localThresh, fabs(dst_ptr[i])), dst_ptr[i]); + } + } + } +} + +static void analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame) +{ + if (s->dc_correction) { + perform_dc_correction(s, frame); + } + + if (s->compress_factor > DBL_EPSILON) { + perform_compression(s, frame); + } + + if (s->channels_coupled) { + const double current_gain_factor = get_max_local_gain(s, frame, -1); + int c; + + for (c = 0; c < s->channels; c++) + update_gain_history(s, c, current_gain_factor); + } else { + int c; + + for (c = 0; c < s->channels; c++) + update_gain_history(s, c, get_max_local_gain(s, frame, c)); + } +} + +static void amplify_frame(DynamicAudioNormalizerContext *s, AVFrame *frame) +{ + int c, i; + + for (c = 0; c < s->channels; c++) { + double *dst_ptr = (double *)frame->extended_data[c]; + double current_amplification_factor; + + cqueue_dequeue(s->gain_history_smoothed[c], ¤t_amplification_factor); + + for (i = 0; i < frame->nb_samples; i++) { + const double amplification_factor = fade(s->prev_amplification_factor[c], + current_amplification_factor, i, + s->fade_factors); + + dst_ptr[i] *= amplification_factor; + + if (fabs(dst_ptr[i]) > s->peak_value) + dst_ptr[i] = copysign(s->peak_value, dst_ptr[i]); + } + + s->prev_amplification_factor[c] = current_amplification_factor; + } +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ + AVFilterContext *ctx = inlink->dst; + DynamicAudioNormalizerContext *s = ctx->priv; + AVFilterLink *outlink = inlink->dst->outputs[0]; + int ret = 0; + + if (!cqueue_empty(s->gain_history_smoothed[0])) { + AVFrame *out = ff_bufqueue_get(&s->queue); + + amplify_frame(s, out); + ret = ff_filter_frame(outlink, out); + } + + analyze_frame(s, in); + ff_bufqueue_add(ctx, &s->queue, in); + + return ret; +} + +static int flush_buffer(DynamicAudioNormalizerContext *s, AVFilterLink *inlink, + AVFilterLink *outlink) +{ + AVFrame *out = ff_get_audio_buffer(outlink, s->frame_len); + int c, i; + + if (!out) + return AVERROR(ENOMEM); + + for (c = 0; c < s->channels; c++) { + double *dst_ptr = (double *)out->extended_data[c]; + + for (i = 0; i < out->nb_samples; i++) { + dst_ptr[i] = s->alt_boundary_mode ? DBL_EPSILON : ((s->target_rms > DBL_EPSILON) ? FFMIN(s->peak_value, s->target_rms) : s->peak_value); + if (s->dc_correction) { + dst_ptr[i] *= ((i % 2) == 1) ? -1 : 1; + dst_ptr[i] += s->dc_correction_value[c]; + } + } + } + + s->delay--; + return filter_frame(inlink, out); +} + +static int request_frame(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + DynamicAudioNormalizerContext *s = ctx->priv; + int ret = 0; + + ret = ff_request_frame(ctx->inputs[0]); + + if (ret == AVERROR_EOF && !ctx->is_disabled && s->delay) + ret = flush_buffer(s, ctx->inputs[0], outlink); + + return ret; +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + DynamicAudioNormalizerContext *s = ctx->priv; + int c; + + av_freep(&s->prev_amplification_factor); + av_freep(&s->dc_correction_value); + av_freep(&s->compress_threshold); + av_freep(&s->fade_factors[0]); + av_freep(&s->fade_factors[1]); + + for (c = 0; c < s->channels; c++) { + cqueue_free(s->gain_history_original[c]); + cqueue_free(s->gain_history_minimum[c]); + cqueue_free(s->gain_history_smoothed[c]); + } + + av_freep(&s->gain_history_original); + av_freep(&s->gain_history_minimum); + av_freep(&s->gain_history_smoothed); + + av_freep(&s->weights); + + ff_bufqueue_discard_all(&s->queue); +} + +static const AVFilterPad avfilter_af_dynaudnorm_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .filter_frame = filter_frame, + .config_props = config_input, + .needs_writable = 1, + }, + { NULL } +}; + +static const AVFilterPad avfilter_af_dynaudnorm_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .config_props = config_output, + .request_frame = request_frame, + }, + { NULL } +}; + +AVFilter ff_af_dynaudnorm = { + .name = "dynaudnorm", + .description = NULL_IF_CONFIG_SMALL("Dynamic Audio Normalizer."), + .query_formats = query_formats, + .priv_size = sizeof(DynamicAudioNormalizerContext), + .init = init, + .uninit = uninit, + .inputs = avfilter_af_dynaudnorm_inputs, + .outputs = avfilter_af_dynaudnorm_outputs, + .priv_class = &dynaudnorm_class, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_pan.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_pan.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_pan.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_pan.c 2015-07-17 17:20:02.000000000 +0000 @@ -37,7 +37,7 @@ #include "formats.h" #include "internal.h" -#define MAX_CHANNELS 63 +#define MAX_CHANNELS 64 typedef struct PanContext { const AVClass *class; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_resample.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_resample.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_resample.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_resample.c 2015-07-19 17:20:03.000000000 +0000 @@ -40,6 +40,7 @@ AVAudioResampleContext *avr; AVDictionary *options; + int resampling; int64_t next_pts; int64_t next_in_pts; @@ -117,6 +118,8 @@ char buf1[64], buf2[64]; int ret; + int64_t resampling_forced; + if (s->avr) { avresample_close(s->avr); avresample_free(&s->avr); @@ -155,9 +158,15 @@ if ((ret = avresample_open(s->avr)) < 0) return ret; - outlink->time_base = (AVRational){ 1, outlink->sample_rate }; - s->next_pts = AV_NOPTS_VALUE; - s->next_in_pts = AV_NOPTS_VALUE; + av_opt_get_int(s->avr, "force_resampling", 0, &resampling_forced); + s->resampling = resampling_forced || (inlink->sample_rate != outlink->sample_rate); + + if (s->resampling) { + outlink->time_base = (AVRational){ 1, outlink->sample_rate }; + s->next_pts = AV_NOPTS_VALUE; + s->next_in_pts = AV_NOPTS_VALUE; + } else + outlink->time_base = inlink->time_base; av_get_channel_layout_string(buf1, sizeof(buf1), -1, inlink ->channel_layout); @@ -201,6 +210,7 @@ return (ret == 0) ? AVERROR_EOF : ret; } + frame->nb_samples = ret; frame->pts = s->next_pts; return ff_filter_frame(outlink, frame); } @@ -239,7 +249,7 @@ av_assert0(!avresample_available(s->avr)); - if (s->next_pts == AV_NOPTS_VALUE) { + if (s->resampling && s->next_pts == AV_NOPTS_VALUE) { if (in->pts == AV_NOPTS_VALUE) { av_log(ctx, AV_LOG_WARNING, "First timestamp is missing, " "assuming 0.\n"); @@ -258,22 +268,25 @@ goto fail; } - out->sample_rate = outlink->sample_rate; - /* Only convert in->pts if there is a discontinuous jump. - This ensures that out->pts tracks the number of samples actually - output by the resampler in the absence of such a jump. - Otherwise, the rounding in av_rescale_q() and av_rescale() - causes off-by-1 errors. */ - if (in->pts != AV_NOPTS_VALUE && in->pts != s->next_in_pts) { - out->pts = av_rescale_q(in->pts, inlink->time_base, - outlink->time_base) - - av_rescale(delay, outlink->sample_rate, - inlink->sample_rate); - } else - out->pts = s->next_pts; + if (s->resampling) { + out->sample_rate = outlink->sample_rate; + /* Only convert in->pts if there is a discontinuous jump. + This ensures that out->pts tracks the number of samples actually + output by the resampler in the absence of such a jump. + Otherwise, the rounding in av_rescale_q() and av_rescale() + causes off-by-1 errors. */ + if (in->pts != AV_NOPTS_VALUE && in->pts != s->next_in_pts) { + out->pts = av_rescale_q(in->pts, inlink->time_base, + outlink->time_base) - + av_rescale(delay, outlink->sample_rate, + inlink->sample_rate); + } else + out->pts = s->next_pts; - s->next_pts = out->pts + out->nb_samples; - s->next_in_pts = in->pts + in->nb_samples; + s->next_pts = out->pts + out->nb_samples; + s->next_in_pts = in->pts + in->nb_samples; + } else + out->pts = in->pts; ret = ff_filter_frame(outlink, out); s->got_output = 1; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_sidechaincompress.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_sidechaincompress.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/af_sidechaincompress.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/af_sidechaincompress.c 2015-07-26 17:20:03.000000000 +0000 @@ -0,0 +1,338 @@ +/* + * Copyright (C) 2001-2010 Krzysztof Foltman, Markus Schmidt, Thor Harald Johansen and others + * Copyright (c) 2015 Paul B Mahol + * + * 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 + */ + +/** + * @file + * Sidechain compressor filter + */ + +#include "libavutil/avassert.h" +#include "libavutil/channel_layout.h" +#include "libavutil/common.h" +#include "libavutil/opt.h" + +#include "audio.h" +#include "avfilter.h" +#include "formats.h" +#include "internal.h" + +typedef struct SidechainCompressContext { + const AVClass *class; + + double attack, attack_coeff; + double release, release_coeff; + double lin_slope; + double ratio; + double threshold; + double makeup; + double thres; + double knee; + double knee_start; + double knee_stop; + double lin_knee_start; + double compressed_knee_stop; + int link; + int detection; + + AVFrame *input_frame[2]; +} SidechainCompressContext; + +#define OFFSET(x) offsetof(SidechainCompressContext, x) +#define A AV_OPT_FLAG_AUDIO_PARAM +#define F AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption sidechaincompress_options[] = { + { "threshold", "set threshold", OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0.125}, 0.000976563, 1, A|F }, + { "ratio", "set ratio", OFFSET(ratio), AV_OPT_TYPE_DOUBLE, {.dbl=2}, 1, 20, A|F }, + { "attack", "set attack", OFFSET(attack), AV_OPT_TYPE_DOUBLE, {.dbl=20}, 0.01, 2000, A|F }, + { "release", "set release", OFFSET(release), AV_OPT_TYPE_DOUBLE, {.dbl=250}, 0.01, 9000, A|F }, + { "makeup", "set make up gain", OFFSET(makeup), AV_OPT_TYPE_DOUBLE, {.dbl=2}, 1, 64, A|F }, + { "knee", "set knee", OFFSET(knee), AV_OPT_TYPE_DOUBLE, {.dbl=2.82843}, 1, 8, A|F }, + { "link", "set link type", OFFSET(link), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, A|F, "link" }, + { "average", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F, "link" }, + { "maximum", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F, "link" }, + { "detection", "set detection", OFFSET(detection), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, A|F, "detection" }, + { "peak", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F, "detection" }, + { "rms", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F, "detection" }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(sidechaincompress); + +static av_cold int init(AVFilterContext *ctx) +{ + SidechainCompressContext *s = ctx->priv; + + s->thres = log(s->threshold); + s->lin_knee_start = s->threshold / sqrt(s->knee); + s->knee_start = log(s->lin_knee_start); + s->knee_stop = log(s->threshold * sqrt(s->knee)); + s->compressed_knee_stop = (s->knee_stop - s->thres) / s->ratio + s->thres; + + return 0; +} + +static inline float hermite_interpolation(float x, float x0, float x1, + float p0, float p1, + float m0, float m1) +{ + float width = x1 - x0; + float t = (x - x0) / width; + float t2, t3; + float ct0, ct1, ct2, ct3; + + m0 *= width; + m1 *= width; + + t2 = t*t; + t3 = t2*t; + ct0 = p0; + ct1 = m0; + + ct2 = -3 * p0 - 2 * m0 + 3 * p1 - m1; + ct3 = 2 * p0 + m0 - 2 * p1 + m1; + + return ct3 * t3 + ct2 * t2 + ct1 * t + ct0; +} + +// A fake infinity value (because real infinity may break some hosts) +#define FAKE_INFINITY (65536.0 * 65536.0) + +// Check for infinity (with appropriate-ish tolerance) +#define IS_FAKE_INFINITY(value) (fabs(value-FAKE_INFINITY) < 1.0) + +static double output_gain(double lin_slope, double ratio, double thres, + double knee, double knee_start, double knee_stop, + double compressed_knee_stop, int detection) +{ + double slope = log(lin_slope); + double gain = 0.0; + double delta = 0.0; + + if (detection) + slope *= 0.5; + + if (IS_FAKE_INFINITY(ratio)) { + gain = thres; + delta = 0.0; + } else { + gain = (slope - thres) / ratio + thres; + delta = 1.0 / ratio; + } + + if (knee > 1.0 && slope < knee_stop) + gain = hermite_interpolation(slope, knee_start, knee_stop, + knee_start, compressed_knee_stop, + 1.0, delta); + + return exp(gain - slope); +} + +static int filter_frame(AVFilterLink *link, AVFrame *frame) +{ + AVFilterContext *ctx = link->dst; + SidechainCompressContext *s = ctx->priv; + AVFilterLink *sclink = ctx->inputs[1]; + AVFilterLink *outlink = ctx->outputs[0]; + const double makeup = s->makeup; + const double *scsrc; + double *sample; + int nb_samples; + int ret, i, c; + + for (i = 0; i < 2; i++) + if (link == ctx->inputs[i]) + break; + av_assert0(!s->input_frame[i]); + s->input_frame[i] = frame; + + if (!s->input_frame[0] || !s->input_frame[1]) + return 0; + + nb_samples = FFMIN(s->input_frame[0]->nb_samples, + s->input_frame[1]->nb_samples); + + sample = (double *)s->input_frame[0]->data[0]; + scsrc = (const double *)s->input_frame[1]->data[0]; + + for (i = 0; i < nb_samples; i++) { + double abs_sample, gain = 1.0; + + abs_sample = FFABS(scsrc[0]); + + if (s->link == 1) { + for (c = 1; c < sclink->channels; c++) + abs_sample = FFMAX(FFABS(scsrc[c]), abs_sample); + } else { + for (c = 1; c < sclink->channels; c++) + abs_sample += FFABS(scsrc[c]); + + abs_sample /= sclink->channels; + } + + if (s->detection) + abs_sample *= abs_sample; + + s->lin_slope += (abs_sample - s->lin_slope) * (abs_sample > s->lin_slope ? s->attack_coeff : s->release_coeff); + + if (s->lin_slope > 0.0 && s->lin_slope > s->lin_knee_start) + gain = output_gain(s->lin_slope, s->ratio, s->thres, s->knee, + s->knee_start, s->knee_stop, + s->compressed_knee_stop, s->detection); + + for (c = 0; c < outlink->channels; c++) + sample[c] *= gain * makeup; + + sample += outlink->channels; + scsrc += sclink->channels; + } + + ret = ff_filter_frame(outlink, s->input_frame[0]); + + s->input_frame[0] = NULL; + av_frame_free(&s->input_frame[1]); + + return ret; +} + +static int request_frame(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + SidechainCompressContext *s = ctx->priv; + int i, ret; + + /* get a frame on each input */ + for (i = 0; i < 2; i++) { + AVFilterLink *inlink = ctx->inputs[i]; + if (!s->input_frame[i] && + (ret = ff_request_frame(inlink)) < 0) + return ret; + + /* request the same number of samples on all inputs */ + if (i == 0) + ctx->inputs[1]->request_samples = s->input_frame[0]->nb_samples; + } + + return 0; +} + +static int query_formats(AVFilterContext *ctx) +{ + AVFilterFormats *formats; + AVFilterChannelLayouts *layouts = NULL; + static const enum AVSampleFormat sample_fmts[] = { + AV_SAMPLE_FMT_DBL, + AV_SAMPLE_FMT_NONE + }; + int ret, i; + + if (!ctx->inputs[0]->in_channel_layouts || + !ctx->inputs[0]->in_channel_layouts->nb_channel_layouts) { + av_log(ctx, AV_LOG_WARNING, + "No channel layout for input 1\n"); + return AVERROR(EAGAIN); + } + + ff_add_channel_layout(&layouts, ctx->inputs[0]->in_channel_layouts->channel_layouts[0]); + if (!layouts) + return AVERROR(ENOMEM); + ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts); + + for (i = 0; i < 2; i++) { + layouts = ff_all_channel_layouts(); + if (!layouts) + return AVERROR(ENOMEM); + ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts); + } + + formats = ff_make_format_list(sample_fmts); + if (!formats) + return AVERROR(ENOMEM); + ret = ff_set_common_formats(ctx, formats); + if (ret < 0) + return ret; + + formats = ff_all_samplerates(); + if (!formats) + return AVERROR(ENOMEM); + return ff_set_common_samplerates(ctx, formats); +} + +static int config_output(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + SidechainCompressContext *s = ctx->priv; + + if (ctx->inputs[0]->sample_rate != ctx->inputs[1]->sample_rate) { + av_log(ctx, AV_LOG_ERROR, + "Inputs must have the same sample rate " + "%d for in0 vs %d for in1\n", + ctx->inputs[0]->sample_rate, ctx->inputs[1]->sample_rate); + return AVERROR(EINVAL); + } + + outlink->sample_rate = ctx->inputs[0]->sample_rate; + outlink->time_base = ctx->inputs[0]->time_base; + outlink->channel_layout = ctx->inputs[0]->channel_layout; + outlink->channels = ctx->inputs[0]->channels; + + s->attack_coeff = FFMIN(1.f, 1.f / (s->attack * outlink->sample_rate / 4000.f)); + s->release_coeff = FFMIN(1.f, 1.f / (s->release * outlink->sample_rate / 4000.f)); + + return 0; +} + +static const AVFilterPad sidechaincompress_inputs[] = { + { + .name = "main", + .type = AVMEDIA_TYPE_AUDIO, + .filter_frame = filter_frame, + .needs_writable = 1, + .needs_fifo = 1, + },{ + .name = "sidechain", + .type = AVMEDIA_TYPE_AUDIO, + .filter_frame = filter_frame, + .needs_fifo = 1, + }, + { NULL } +}; + +static const AVFilterPad sidechaincompress_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .config_props = config_output, + .request_frame = request_frame, + }, + { NULL } +}; + +AVFilter ff_af_sidechaincompress = { + .name = "sidechaincompress", + .description = NULL_IF_CONFIG_SMALL("Sidechain compressor."), + .priv_size = sizeof(SidechainCompressContext), + .priv_class = &sidechaincompress_class, + .init = init, + .query_formats = query_formats, + .inputs = sidechaincompress_inputs, + .outputs = sidechaincompress_outputs, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/allfilters.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/allfilters.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/allfilters.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/allfilters.c 2015-08-02 17:20:02.000000000 +0000 @@ -45,6 +45,7 @@ return; initialized = 1; + REGISTER_FILTER(ACROSSFADE, acrossfade, af); REGISTER_FILTER(ADELAY, adelay, af); REGISTER_FILTER(AECHO, aecho, af); REGISTER_FILTER(AEVAL, aeval, af); @@ -59,6 +60,7 @@ REGISTER_FILTER(APERMS, aperms, af); REGISTER_FILTER(APHASER, aphaser, af); REGISTER_FILTER(ARESAMPLE, aresample, af); + REGISTER_FILTER(AREVERSE, areverse, af); REGISTER_FILTER(ASELECT, aselect, af); REGISTER_FILTER(ASENDCMD, asendcmd, af); REGISTER_FILTER(ASETNSAMPLES, asetnsamples, af); @@ -83,6 +85,7 @@ REGISTER_FILTER(CHORUS, chorus, af); REGISTER_FILTER(COMPAND, compand, af); REGISTER_FILTER(DCSHIFT, dcshift, af); + REGISTER_FILTER(DYNAUDNORM, dynaudnorm, af); REGISTER_FILTER(EARWAX, earwax, af); REGISTER_FILTER(EBUR128, ebur128, af); REGISTER_FILTER(EQUALIZER, equalizer, af); @@ -94,6 +97,7 @@ REGISTER_FILTER(PAN, pan, af); REGISTER_FILTER(REPLAYGAIN, replaygain, af); REGISTER_FILTER(RESAMPLE, resample, af); + REGISTER_FILTER(SIDECHAINCOMPRESS, sidechaincompress, af); REGISTER_FILTER(SILENCEDETECT, silencedetect, af); REGISTER_FILTER(SILENCEREMOVE, silenceremove, af); REGISTER_FILTER(TREBLE, treble, af); @@ -109,6 +113,7 @@ REGISTER_FILTER(ALPHAEXTRACT, alphaextract, vf); REGISTER_FILTER(ALPHAMERGE, alphamerge, vf); + REGISTER_FILTER(ATADENOISE, atadenoise, vf); REGISTER_FILTER(ASS, ass, vf); REGISTER_FILTER(BBOX, bbox, vf); REGISTER_FILTER(BLACKDETECT, blackdetect, vf); @@ -118,6 +123,7 @@ REGISTER_FILTER(CODECVIEW, codecview, vf); REGISTER_FILTER(COLORBALANCE, colorbalance, vf); REGISTER_FILTER(COLORCHANNELMIXER, colorchannelmixer, vf); + REGISTER_FILTER(COLORKEY, colorkey, vf); REGISTER_FILTER(COLORLEVELS, colorlevels, vf); REGISTER_FILTER(COLORMATRIX, colormatrix, vf); REGISTER_FILTER(COPY, copy, vf); @@ -126,17 +132,22 @@ REGISTER_FILTER(CROPDETECT, cropdetect, vf); REGISTER_FILTER(CURVES, curves, vf); REGISTER_FILTER(DCTDNOIZ, dctdnoiz, vf); + REGISTER_FILTER(DEBAND, deband, vf); REGISTER_FILTER(DECIMATE, decimate, vf); + REGISTER_FILTER(DEFLATE, deflate, vf); REGISTER_FILTER(DEJUDDER, dejudder, vf); REGISTER_FILTER(DELOGO, delogo, vf); REGISTER_FILTER(DESHAKE, deshake, vf); REGISTER_FILTER(DETELECINE, detelecine, vf); + REGISTER_FILTER(DILATION, dilation, vf); REGISTER_FILTER(DRAWBOX, drawbox, vf); + REGISTER_FILTER(DRAWGRAPH, drawgraph, vf); REGISTER_FILTER(DRAWGRID, drawgrid, vf); REGISTER_FILTER(DRAWTEXT, drawtext, vf); REGISTER_FILTER(EDGEDETECT, edgedetect, vf); REGISTER_FILTER(ELBG, elbg, vf); REGISTER_FILTER(EQ, eq, vf); + REGISTER_FILTER(EROSION, erosion, vf); REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); REGISTER_FILTER(FADE, fade, vf); REGISTER_FILTER(FFTFILT, fftfilt, vf); @@ -161,6 +172,7 @@ REGISTER_FILTER(HUE, hue, vf); REGISTER_FILTER(IDET, idet, vf); REGISTER_FILTER(IL, il, vf); + REGISTER_FILTER(INFLATE, inflate, vf); REGISTER_FILTER(INTERLACE, interlace, vf); REGISTER_FILTER(INTERLEAVE, interleave, vf); REGISTER_FILTER(KERNDEINT, kerndeint, vf); @@ -191,8 +203,11 @@ REGISTER_FILTER(PSNR, psnr, vf); REGISTER_FILTER(PULLUP, pullup, vf); REGISTER_FILTER(QP, qp, vf); + REGISTER_FILTER(RANDOM, random, vf); + REGISTER_FILTER(REMOVEGRAIN, removegrain, vf); REGISTER_FILTER(REMOVELOGO, removelogo, vf); REGISTER_FILTER(REPEATFIELDS, repeatfields, vf); + REGISTER_FILTER(REVERSE, reverse, vf); REGISTER_FILTER(ROTATE, rotate, vf); REGISTER_FILTER(SAB, sab, vf); REGISTER_FILTER(SCALE, scale, vf); @@ -211,6 +226,7 @@ REGISTER_FILTER(SMARTBLUR, smartblur, vf); REGISTER_FILTER(SPLIT, split, vf); REGISTER_FILTER(SPP, spp, vf); + REGISTER_FILTER(SSIM, ssim, vf); REGISTER_FILTER(STEREO3D, stereo3d, vf); REGISTER_FILTER(SUBTITLES, subtitles, vf); REGISTER_FILTER(SUPER2XSAI, super2xsai, vf); @@ -234,6 +250,7 @@ REGISTER_FILTER(ZMQ, zmq, vf); REGISTER_FILTER(ZOOMPAN, zoompan, vf); + REGISTER_FILTER(ALLYUV, allyuv, vsrc); REGISTER_FILTER(CELLAUTO, cellauto, vsrc); REGISTER_FILTER(COLOR, color, vsrc); REGISTER_FILTER(FREI0R, frei0r_src, vsrc); @@ -250,10 +267,12 @@ REGISTER_FILTER(NULLSINK, nullsink, vsink); /* multimedia filters */ + REGISTER_FILTER(ADRAWGRAPH, adrawgraph, avf); REGISTER_FILTER(AVECTORSCOPE, avectorscope, avf); REGISTER_FILTER(CONCAT, concat, avf); REGISTER_FILTER(SHOWCQT, showcqt, avf); REGISTER_FILTER(SHOWSPECTRUM, showspectrum, avf); + REGISTER_FILTER(SHOWVOLUME, showvolume, avf); REGISTER_FILTER(SHOWWAVES, showwaves, avf); REGISTER_FILTER(SHOWWAVESPIC, showwavespic, avf); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/avf_showspectrum.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/avf_showspectrum.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/avf_showspectrum.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/avf_showspectrum.c 2015-08-04 17:20:03.000000000 +0000 @@ -321,167 +321,165 @@ s->rdft_data[ch][n] = p[n] * s->window_func_lut[n]; } - /* TODO reindent */ + /* run RDFT on each samples set */ + for (ch = 0; ch < s->nb_display_channels; ch++) + av_rdft_calc(s->rdft, s->rdft_data[ch]); - /* run RDFT on each samples set */ - for (ch = 0; ch < s->nb_display_channels; ch++) - av_rdft_calc(s->rdft, s->rdft_data[ch]); - - /* fill a new spectrum column */ + /* fill a new spectrum column */ #define RE(y, ch) s->rdft_data[ch][2 * (y) + 0] #define IM(y, ch) s->rdft_data[ch][2 * (y) + 1] #define MAGNITUDE(y, ch) hypot(RE(y, ch), IM(y, ch)) - /* initialize buffer for combining to black */ - for (y = 0; y < outlink->h; y++) { - s->combine_buffer[3 * y ] = 0; - s->combine_buffer[3 * y + 1] = 127.5; - s->combine_buffer[3 * y + 2] = 127.5; - } + /* initialize buffer for combining to black */ + for (y = 0; y < outlink->h; y++) { + s->combine_buffer[3 * y ] = 0; + s->combine_buffer[3 * y + 1] = 127.5; + s->combine_buffer[3 * y + 2] = 127.5; + } - for (ch = 0; ch < s->nb_display_channels; ch++) { - float yf, uf, vf; + for (ch = 0; ch < s->nb_display_channels; ch++) { + float yf, uf, vf; - /* decide color range */ - switch (s->mode) { - case COMBINED: - // reduce range by channel count - yf = 256.0f / s->nb_display_channels; - switch (s->color_mode) { - case INTENSITY: - uf = yf; - vf = yf; - break; - case CHANNEL: - /* adjust saturation for mixed UV coloring */ - /* this factor is correct for infinite channels, an approximation otherwise */ - uf = yf * M_PI; - vf = yf * M_PI; - break; - default: - av_assert0(0); - } + /* decide color range */ + switch (s->mode) { + case COMBINED: + // reduce range by channel count + yf = 256.0f / s->nb_display_channels; + switch (s->color_mode) { + case INTENSITY: + uf = yf; + vf = yf; break; - case SEPARATE: - // full range - yf = 256.0f; - uf = 256.0f; - vf = 256.0f; + case CHANNEL: + /* adjust saturation for mixed UV coloring */ + /* this factor is correct for infinite channels, an approximation otherwise */ + uf = yf * M_PI; + vf = yf * M_PI; break; default: av_assert0(0); } + break; + case SEPARATE: + // full range + yf = 256.0f; + uf = 256.0f; + vf = 256.0f; + break; + default: + av_assert0(0); + } - if (s->color_mode == CHANNEL) { - if (s->nb_display_channels > 1) { - uf *= 0.5 * sin((2 * M_PI * ch) / s->nb_display_channels); - vf *= 0.5 * cos((2 * M_PI * ch) / s->nb_display_channels); - } else { - uf = 0.0f; - vf = 0.0f; - } + if (s->color_mode == CHANNEL) { + if (s->nb_display_channels > 1) { + uf *= 0.5 * sin((2 * M_PI * ch) / s->nb_display_channels); + vf *= 0.5 * cos((2 * M_PI * ch) / s->nb_display_channels); + } else { + uf = 0.0f; + vf = 0.0f; } - uf *= s->saturation; - vf *= s->saturation; + } + uf *= s->saturation; + vf *= s->saturation; - /* draw the channel */ - for (y = 0; y < h; y++) { - int row = (s->mode == COMBINED) ? y : ch * h + y; - float *out = &s->combine_buffer[3 * row]; - - /* get magnitude */ - float a = w * MAGNITUDE(y, ch); - - /* apply scale */ - switch (s->scale) { - case LINEAR: - break; - case SQRT: - a = sqrt(a); - break; - case CBRT: - a = cbrt(a); - break; - case LOG: - a = 1 - log(FFMAX(FFMIN(1, a), 1e-6)) / log(1e-6); // zero = -120dBFS - break; - default: - av_assert0(0); - } + /* draw the channel */ + for (y = 0; y < h; y++) { + int row = (s->mode == COMBINED) ? y : ch * h + y; + float *out = &s->combine_buffer[3 * row]; + + /* get magnitude */ + float a = w * MAGNITUDE(y, ch); + + /* apply scale */ + switch (s->scale) { + case LINEAR: + break; + case SQRT: + a = sqrt(a); + break; + case CBRT: + a = cbrt(a); + break; + case LOG: + a = 1 - log(FFMAX(FFMIN(1, a), 1e-6)) / log(1e-6); // zero = -120dBFS + break; + default: + av_assert0(0); + } - if (s->color_mode == INTENSITY) { - float y, u, v; - int i; - - for (i = 1; i < sizeof(intensity_color_table) / sizeof(*intensity_color_table) - 1; i++) - if (intensity_color_table[i].a >= a) - break; - // i now is the first item >= the color - // now we know to interpolate between item i - 1 and i - if (a <= intensity_color_table[i - 1].a) { - y = intensity_color_table[i - 1].y; - u = intensity_color_table[i - 1].u; - v = intensity_color_table[i - 1].v; - } else if (a >= intensity_color_table[i].a) { - y = intensity_color_table[i].y; - u = intensity_color_table[i].u; - v = intensity_color_table[i].v; - } else { - float start = intensity_color_table[i - 1].a; - float end = intensity_color_table[i].a; - float lerpfrac = (a - start) / (end - start); - y = intensity_color_table[i - 1].y * (1.0f - lerpfrac) - + intensity_color_table[i].y * lerpfrac; - u = intensity_color_table[i - 1].u * (1.0f - lerpfrac) - + intensity_color_table[i].u * lerpfrac; - v = intensity_color_table[i - 1].v * (1.0f - lerpfrac) - + intensity_color_table[i].v * lerpfrac; - } - - out[0] += y * yf; - out[1] += u * uf; - out[2] += v * vf; + if (s->color_mode == INTENSITY) { + float y, u, v; + int i; + + for (i = 1; i < sizeof(intensity_color_table) / sizeof(*intensity_color_table) - 1; i++) + if (intensity_color_table[i].a >= a) + break; + // i now is the first item >= the color + // now we know to interpolate between item i - 1 and i + if (a <= intensity_color_table[i - 1].a) { + y = intensity_color_table[i - 1].y; + u = intensity_color_table[i - 1].u; + v = intensity_color_table[i - 1].v; + } else if (a >= intensity_color_table[i].a) { + y = intensity_color_table[i].y; + u = intensity_color_table[i].u; + v = intensity_color_table[i].v; } else { - out[0] += a * yf; - out[1] += a * uf; - out[2] += a * vf; + float start = intensity_color_table[i - 1].a; + float end = intensity_color_table[i].a; + float lerpfrac = (a - start) / (end - start); + y = intensity_color_table[i - 1].y * (1.0f - lerpfrac) + + intensity_color_table[i].y * lerpfrac; + u = intensity_color_table[i - 1].u * (1.0f - lerpfrac) + + intensity_color_table[i].u * lerpfrac; + v = intensity_color_table[i - 1].v * (1.0f - lerpfrac) + + intensity_color_table[i].v * lerpfrac; } - } - } - /* copy to output */ - if (s->sliding == SCROLL) { - for (plane = 0; plane < 3; plane++) { - for (y = 0; y < outlink->h; y++) { - uint8_t *p = outpicref->data[plane] + - y * outpicref->linesize[plane]; - memmove(p, p + 1, outlink->w - 1); - } + out[0] += y * yf; + out[1] += u * uf; + out[2] += v * vf; + } else { + out[0] += a * yf; + out[1] += a * uf; + out[2] += a * vf; } - s->xpos = outlink->w - 1; } + } + + /* copy to output */ + if (s->sliding == SCROLL) { for (plane = 0; plane < 3; plane++) { - uint8_t *p = outpicref->data[plane] + - (outlink->h - 1) * outpicref->linesize[plane] + - s->xpos; for (y = 0; y < outlink->h; y++) { - *p = rint(FFMAX(0, FFMIN(s->combine_buffer[3 * y + plane], 255))); - p -= outpicref->linesize[plane]; + uint8_t *p = outpicref->data[plane] + + y * outpicref->linesize[plane]; + memmove(p, p + 1, outlink->w - 1); } } + s->xpos = outlink->w - 1; + } + for (plane = 0; plane < 3; plane++) { + uint8_t *p = outpicref->data[plane] + + (outlink->h - 1) * outpicref->linesize[plane] + + s->xpos; + for (y = 0; y < outlink->h; y++) { + *p = rint(FFMAX(0, FFMIN(s->combine_buffer[3 * y + plane], 255))); + p -= outpicref->linesize[plane]; + } + } - if (s->sliding != FULLFRAME || s->xpos == 0) - outpicref->pts = insamples->pts; + if (s->sliding != FULLFRAME || s->xpos == 0) + outpicref->pts = insamples->pts; - s->xpos++; - if (s->xpos >= outlink->w) - s->xpos = 0; - if (s->sliding != FULLFRAME || s->xpos == 0) { - s->req_fullfilled = 1; - ret = ff_filter_frame(outlink, av_frame_clone(s->outpicref)); - if (ret < 0) - return ret; - } + s->xpos++; + if (s->xpos >= outlink->w) + s->xpos = 0; + if (s->sliding != FULLFRAME || s->xpos == 0) { + s->req_fullfilled = 1; + ret = ff_filter_frame(outlink, av_frame_clone(s->outpicref)); + if (ret < 0) + return ret; + } return win_size; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/avf_showvolume.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/avf_showvolume.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/avf_showvolume.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/avf_showvolume.c 2015-08-02 17:20:02.000000000 +0000 @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2015 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/channel_layout.h" +#include "libavutil/eval.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/opt.h" +#include "libavutil/parseutils.h" +#include "libavutil/xga_font_data.h" +#include "avfilter.h" +#include "formats.h" +#include "audio.h" +#include "video.h" +#include "internal.h" + +typedef struct ShowVolumeContext { + const AVClass *class; + int w, h; + int f, b; + AVRational frame_rate; + char *color; + + AVFrame *out; + AVExpr *c_expr; + int draw_text; +} ShowVolumeContext; + +#define OFFSET(x) offsetof(ShowVolumeContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM + +static const AVOption showvolume_options[] = { + { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, 0, FLAGS }, + { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, 0, FLAGS }, + { "b", "set border width", OFFSET(b), AV_OPT_TYPE_INT, {.i64=1}, 0, 5, FLAGS }, + { "w", "set channel width", OFFSET(w), AV_OPT_TYPE_INT, {.i64=400}, 40, 1080, FLAGS }, + { "h", "set channel height", OFFSET(h), AV_OPT_TYPE_INT, {.i64=20}, 1, 100, FLAGS }, + { "f", "set fade", OFFSET(f), AV_OPT_TYPE_INT, {.i64=20}, 1, 255, FLAGS }, + { "c", "set volume color expression", OFFSET(color), AV_OPT_TYPE_STRING, {.str="if(gte(VOLUME,-2), if(gte(VOLUME,-1),0xff0000ff, 0xff00ffff),0xff00ff00)"}, 0, 0, FLAGS }, + { "t", "display channel names", OFFSET(draw_text), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(showvolume); + +static const char *const var_names[] = { "VOLUME", "CHANNEL", NULL }; +enum { VAR_VOLUME, VAR_CHANNEL, VAR_VARS_NB }; + +static av_cold int init(AVFilterContext *ctx) +{ + ShowVolumeContext *s = ctx->priv; + int ret; + + if (s->color) { + ret = av_expr_parse(&s->c_expr, s->color, var_names, + NULL, NULL, NULL, NULL, 0, ctx); + if (ret < 0) + return ret; + } + + return 0; +} + +static int query_formats(AVFilterContext *ctx) +{ + AVFilterFormats *formats = NULL; + AVFilterChannelLayouts *layouts = NULL; + AVFilterLink *inlink = ctx->inputs[0]; + AVFilterLink *outlink = ctx->outputs[0]; + static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }; + static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE }; + + formats = ff_make_format_list(sample_fmts); + if (!formats) + return AVERROR(ENOMEM); + ff_formats_ref(formats, &inlink->out_formats); + + layouts = ff_all_channel_layouts(); + if (!layouts) + return AVERROR(ENOMEM); + ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts); + + formats = ff_all_samplerates(); + if (!formats) + return AVERROR(ENOMEM); + ff_formats_ref(formats, &inlink->out_samplerates); + + formats = ff_make_format_list(pix_fmts); + if (!formats) + return AVERROR(ENOMEM); + ff_formats_ref(formats, &outlink->in_formats); + + return 0; +} + +static int config_input(AVFilterLink *inlink) +{ + AVFilterContext *ctx = inlink->dst; + ShowVolumeContext *s = ctx->priv; + int nb_samples; + + nb_samples = FFMAX(1024, ((double)inlink->sample_rate / av_q2d(s->frame_rate)) + 0.5); + inlink->partial_buf_size = + inlink->min_samples = + inlink->max_samples = nb_samples; + + return 0; +} + +static int config_output(AVFilterLink *outlink) +{ + ShowVolumeContext *s = outlink->src->priv; + AVFilterLink *inlink = outlink->src->inputs[0]; + + outlink->w = s->w; + outlink->h = s->h * inlink->channels + (inlink->channels - 1) * s->b; + outlink->sample_aspect_ratio = (AVRational){1,1}; + outlink->frame_rate = s->frame_rate; + + return 0; +} + +static void drawtext(AVFrame *pic, int x, int y, const char *txt) +{ + const uint8_t *font; + int font_height; + int i; + + font = avpriv_cga_font, font_height = 8; + + for (i = 0; txt[i]; i++) { + int char_y, mask; + uint8_t *p = pic->data[0] + y*pic->linesize[0] + (x + i*8)*4; + + for (char_y = 0; char_y < font_height; char_y++) { + for (mask = 0x80; mask; mask >>= 1) { + if (font[txt[i] * font_height + char_y] & mask) + AV_WN32(p, ~AV_RN32(p)); + p += 4; + } + p += pic->linesize[0] - 8*4; + } + } +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) +{ + AVFilterContext *ctx = inlink->dst; + AVFilterLink *outlink = ctx->outputs[0]; + ShowVolumeContext *s = ctx->priv; + int c, i, j, k; + double values[VAR_VARS_NB]; + + if (!s->out || s->out->width != outlink->w || + s->out->height != outlink->h) { + av_frame_free(&s->out); + s->out = ff_get_video_buffer(outlink, outlink->w, outlink->h); + if (!s->out) { + av_frame_free(&insamples); + return AVERROR(ENOMEM); + } + + for (i = 0; i < outlink->h; i++) + memset(s->out->data[0] + i * s->out->linesize[0], 0, outlink->w * 4); + } + s->out->pts = insamples->pts; + + for (j = 0; j < outlink->h; j++) { + uint8_t *dst = s->out->data[0] + j * s->out->linesize[0]; + for (k = 0; k < s->w; k++) { + dst[k * 4 + 0] = FFMAX(dst[k * 4 + 0] - s->f, 0); + dst[k * 4 + 1] = FFMAX(dst[k * 4 + 1] - s->f, 0); + dst[k * 4 + 2] = FFMAX(dst[k * 4 + 2] - s->f, 0); + dst[k * 4 + 3] = FFMAX(dst[k * 4 + 3] - s->f, 0); + } + } + + for (c = 0; c < inlink->channels; c++) { + float *src = (float *)insamples->extended_data[c]; + float max = 0; + uint32_t color; + + for (i = 0; i < insamples->nb_samples; i++) + max = FFMAX(max, src[i]); + + max = av_clipf(max, 0, 1); + values[VAR_VOLUME] = 20.0 * log(max) / M_LN10; + values[VAR_CHANNEL] = c; + color = av_expr_eval(s->c_expr, values, NULL); + + for (j = 0; j < s->h; j++) { + uint8_t *dst = s->out->data[0] + (c * s->h + c * s->b + j) * s->out->linesize[0]; + + for (k = 0; k < s->w * max; k++) + AV_WN32A(dst + k * 4, color); + } + + if (s->h >= 8 && s->draw_text) + drawtext(s->out, 2, c * (s->h + s->b) + (s->h - 8) / 2, + av_get_channel_name(av_channel_layout_extract_channel(insamples->channel_layout, c))); + } + + av_frame_free(&insamples); + + return ff_filter_frame(outlink, av_frame_clone(s->out)); +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + ShowVolumeContext *s = ctx->priv; + + av_frame_free(&s->out); + av_expr_free(s->c_expr); +} + +static const AVFilterPad showvolume_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .config_props = config_input, + .filter_frame = filter_frame, + }, + { NULL } +}; + +static const AVFilterPad showvolume_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_output, + }, + { NULL } +}; + +AVFilter ff_avf_showvolume = { + .name = "showvolume", + .description = NULL_IF_CONFIG_SMALL("Convert input audio volume to video output."), + .init = init, + .uninit = uninit, + .query_formats = query_formats, + .priv_size = sizeof(ShowVolumeContext), + .inputs = showvolume_inputs, + .outputs = showvolume_outputs, + .priv_class = &showvolume_class, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/drawutils.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/drawutils.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/drawutils.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/drawutils.c 2015-06-14 17:20:02.000000000 +0000 @@ -21,6 +21,7 @@ #include +#include "libavutil/avassert.h" #include "libavutil/avutil.h" #include "libavutil/colorspace.h" #include "libavutil/mem.h" @@ -66,7 +67,11 @@ uint8_t rgba_map[4] = {0}; int i; const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(pix_fmt); - int hsub = pix_desc->log2_chroma_w; + int hsub; + + av_assert0(pix_desc); + + hsub = pix_desc->log2_chroma_w; *is_packed_rgba = ff_fill_rgba_map(rgba_map, pix_fmt) >= 0; @@ -160,7 +165,7 @@ unsigned i, nb_planes = 0; int pixelstep[MAX_PLANES] = { 0 }; - if (!desc->name) + if (!desc || !desc->name) return AVERROR(EINVAL); if (desc->flags & ~(AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL | AV_PIX_FMT_FLAG_ALPHA)) return AVERROR(ENOSYS); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/f_drawgraph.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/f_drawgraph.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/f_drawgraph.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/f_drawgraph.c 2015-08-02 17:20:02.000000000 +0000 @@ -0,0 +1,347 @@ +/* + * Copyright (c) 2015 Paul B Mahol + * + * 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 "float.h" + +#include "libavutil/eval.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/opt.h" +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "video.h" + +typedef struct DrawGraphContext { + const AVClass *class; + + char *key[4]; + float min, max; + char *fg_str[4]; + AVExpr *fg_expr[4]; + uint8_t bg[4]; + int mode; + int slide; + int w, h; + + AVFrame *out; + int x; + int prev_y[4]; + int first; +} DrawGraphContext; + +#define OFFSET(x) offsetof(DrawGraphContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption drawgraph_options[] = { + { "m1", "set 1st metadata key", OFFSET(key[0]), AV_OPT_TYPE_STRING, {.str=""}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "fg1", "set 1st foreground color expression", OFFSET(fg_str[0]), AV_OPT_TYPE_STRING, {.str="0xffff0000"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "m2", "set 2nd metadata key", OFFSET(key[1]), AV_OPT_TYPE_STRING, {.str=""}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "fg2", "set 2nd foreground color expression", OFFSET(fg_str[1]), AV_OPT_TYPE_STRING, {.str="0xff00ff00"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "m3", "set 3rd metadata key", OFFSET(key[2]), AV_OPT_TYPE_STRING, {.str=""}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "fg3", "set 3rd foreground color expression", OFFSET(fg_str[2]), AV_OPT_TYPE_STRING, {.str="0xffff00ff"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "m4", "set 4th metadata key", OFFSET(key[3]), AV_OPT_TYPE_STRING, {.str=""}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "fg4", "set 4th foreground color expression", OFFSET(fg_str[3]), AV_OPT_TYPE_STRING, {.str="0xffffff00"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "bg", "set background color", OFFSET(bg), AV_OPT_TYPE_COLOR, {.str="white"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "min", "set minimal value", OFFSET(min), AV_OPT_TYPE_FLOAT, {.dbl=-1.}, INT_MIN, INT_MAX, FLAGS }, + { "max", "set maximal value", OFFSET(max), AV_OPT_TYPE_FLOAT, {.dbl=1.}, INT_MIN, INT_MAX, FLAGS }, + { "mode", "set graph mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=2}, 0, 2, FLAGS, "mode" }, + {"bar", "draw bars", OFFSET(mode), AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "mode"}, + {"dot", "draw dots", OFFSET(mode), AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "mode"}, + {"line", "draw lines", OFFSET(mode), AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "mode"}, + { "slide", "set slide mode", OFFSET(slide), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "slide" }, + {"frame", "draw new frames", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "slide"}, + {"replace", "replace old columns with new", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "slide"}, + {"scroll", "scroll from right to left", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "slide"}, + { "size", "set graph size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="900x256"}, 0, 0, FLAGS }, + { "s", "set graph size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="900x256"}, 0, 0, FLAGS }, + { NULL } +}; + +static const char *const var_names[] = { "MAX", "MIN", "VAL", NULL }; +enum { VAR_MAX, VAR_MIN, VAR_VAL, VAR_VARS_NB }; + +static av_cold int init(AVFilterContext *ctx) +{ + DrawGraphContext *s = ctx->priv; + int ret, i; + + if (s->max <= s->min) { + av_log(ctx, AV_LOG_ERROR, "max is same or lower than min\n"); + return AVERROR(EINVAL); + } + + for (i = 0; i < 4; i++) { + if (s->fg_str[i]) { + ret = av_expr_parse(&s->fg_expr[i], s->fg_str[i], var_names, + NULL, NULL, NULL, NULL, 0, ctx); + + if (ret < 0) + return ret; + } + } + + s->first = 1; + + return 0; +} + +static int query_formats(AVFilterContext *ctx) +{ + AVFilterLink *outlink = ctx->outputs[0]; + static const enum AVPixelFormat pix_fmts[] = { + AV_PIX_FMT_RGBA, + AV_PIX_FMT_NONE + }; + + AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts); + if (!fmts_list) + return AVERROR(ENOMEM); + ff_formats_ref(fmts_list, &outlink->in_formats); + + return 0; +} + +static void clear_image(DrawGraphContext *s, AVFrame *out, AVFilterLink *outlink) +{ + int i, j; + int bg = AV_RN32(s->bg); + + for (i = 0; i < out->height; i++) + for (j = 0; j < out->width; j++) + AV_WN32(out->data[0] + i * out->linesize[0] + j * 4, bg); +} + +static inline void draw_dot(int fg, int x, int y, AVFrame *out) +{ + AV_WN32(out->data[0] + y * out->linesize[0] + x * 4, fg); +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ + AVFilterContext *ctx = inlink->dst; + DrawGraphContext *s = ctx->priv; + AVFilterLink *outlink = ctx->outputs[0]; + AVDictionary *metadata; + AVDictionaryEntry *e; + AVFrame *out = s->out; + int i; + + if (!s->out || s->out->width != outlink->w || + s->out->height != outlink->h) { + av_frame_free(&s->out); + s->out = ff_get_video_buffer(outlink, outlink->w, outlink->h); + out = s->out; + if (!s->out) { + av_frame_free(&in); + return AVERROR(ENOMEM); + } + + clear_image(s, out, outlink); + } + av_frame_copy_props(out, in); + + metadata = av_frame_get_metadata(in); + + for (i = 0; i < 4; i++) { + double values[VAR_VARS_NB]; + int j, y, x, old; + uint32_t fg, bg; + float vf; + + e = av_dict_get(metadata, s->key[i], NULL, 0); + if (!e || !e->value) + continue; + + if (sscanf(e->value, "%f", &vf) != 1) + continue; + + vf = av_clipf(vf, s->min, s->max); + + values[VAR_MIN] = s->min; + values[VAR_MAX] = s->max; + values[VAR_VAL] = vf; + + fg = av_expr_eval(s->fg_expr[i], values, NULL); + bg = AV_RN32(s->bg); + + if (i == 0 && s->x >= outlink->w) { + if (s->slide == 0 || s->slide == 1) + s->x = 0; + + if (s->slide == 2) { + s->x = outlink->w - 1; + for (j = 0; j < outlink->h; j++) { + memmove(out->data[0] + j * out->linesize[0] , + out->data[0] + j * out->linesize[0] + 4, + (outlink->w - 1) * 4); + } + } else if (s->slide == 0) { + clear_image(s, out, outlink); + } + } + + x = s->x; + y = (outlink->h - 1) * (1 - ((vf - s->min) / (s->max - s->min))); + + switch (s->mode) { + case 0: + if (i == 0 && (s->slide == 1 || s->slide == 2)) + for (j = 0; j < outlink->h; j++) + draw_dot(bg, x, j, out); + + old = AV_RN32(out->data[0] + y * out->linesize[0] + x * 4); + for (j = y; j < outlink->h; j++) { + if (old != bg && + (AV_RN32(out->data[0] + j * out->linesize[0] + x * 4) != old) || + AV_RN32(out->data[0] + FFMIN(j+1, outlink->h - 1) * out->linesize[0] + x * 4) != old) { + draw_dot(fg, x, j, out); + break; + } + draw_dot(fg, x, j, out); + } + break; + case 1: + if (i == 0 && (s->slide == 1 || s->slide == 2)) + for (j = 0; j < outlink->h; j++) + draw_dot(bg, x, j, out); + draw_dot(fg, x, y, out); + break; + case 2: + if (s->first) { + s->first = 0; + s->prev_y[i] = y; + } + + if (i == 0 && (s->slide == 1 || s->slide == 2)) { + for (j = 0; j < y; j++) + draw_dot(bg, x, j, out); + for (j = outlink->h - 1; j > y; j--) + draw_dot(bg, x, j, out); + } + if (y <= s->prev_y[i]) { + for (j = y; j <= s->prev_y[i]; j++) + draw_dot(fg, x, j, out); + } else { + for (j = s->prev_y[i]; j <= y; j++) + draw_dot(fg, x, j, out); + } + s->prev_y[i] = y; + break; + } + } + + s->x++; + + av_frame_free(&in); + return ff_filter_frame(outlink, av_frame_clone(s->out)); +} + +static int config_output(AVFilterLink *outlink) +{ + DrawGraphContext *s = outlink->src->priv; + + outlink->w = s->w; + outlink->h = s->h; + outlink->sample_aspect_ratio = (AVRational){1,1}; + + return 0; +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + DrawGraphContext *s = ctx->priv; + int i; + + for (i = 0; i < 4; i++) + av_expr_free(s->fg_expr[i]); + av_frame_free(&s->out); +} + +#if CONFIG_DRAWGRAPH_FILTER + +AVFILTER_DEFINE_CLASS(drawgraph); + +static const AVFilterPad drawgraph_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = filter_frame, + }, + { NULL } +}; + +static const AVFilterPad drawgraph_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_output, + }, + { NULL } +}; + +AVFilter ff_vf_drawgraph = { + .name = "drawgraph", + .description = NULL_IF_CONFIG_SMALL("Draw a graph using input video metadata."), + .priv_size = sizeof(DrawGraphContext), + .priv_class = &drawgraph_class, + .query_formats = query_formats, + .init = init, + .uninit = uninit, + .inputs = drawgraph_inputs, + .outputs = drawgraph_outputs, +}; + +#endif // CONFIG_DRAWGRAPH_FILTER + +#if CONFIG_ADRAWGRAPH_FILTER + +#define adrawgraph_options drawgraph_options +AVFILTER_DEFINE_CLASS(adrawgraph); + +static const AVFilterPad adrawgraph_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .filter_frame = filter_frame, + }, + { NULL } +}; + +static const AVFilterPad adrawgraph_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_output, + }, + { NULL } +}; + +AVFilter ff_avf_adrawgraph = { + .name = "adrawgraph", + .description = NULL_IF_CONFIG_SMALL("Draw a graph using input audio metadata."), + .priv_size = sizeof(DrawGraphContext), + .priv_class = &adrawgraph_class, + .query_formats = query_formats, + .init = init, + .uninit = uninit, + .inputs = adrawgraph_inputs, + .outputs = adrawgraph_outputs, +}; +#endif // CONFIG_ADRAWGRAPH_FILTER diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/formats.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/formats.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/formats.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/formats.c 2015-06-21 17:20:02.000000000 +0000 @@ -637,23 +637,20 @@ void *log_ctx) { char *tail; - int64_t chlayout, count; + int64_t chlayout; - if (nret) { - count = strtol(arg, &tail, 10); - if (*tail == 'c' && !tail[1] && count > 0 && count < 63) { - *nret = count; - *ret = 0; - return 0; - } - } chlayout = av_get_channel_layout(arg); if (chlayout == 0) { chlayout = strtol(arg, &tail, 10); - if (*tail || chlayout == 0) { + if (!(*tail == '\0' || *tail == 'c' && *(tail + 1) == '\0') || chlayout <= 0 || chlayout > 63) { av_log(log_ctx, AV_LOG_ERROR, "Invalid channel layout '%s'\n", arg); return AVERROR(EINVAL); } + if (nret) { + *nret = chlayout; + *ret = 0; + return 0; + } } *ret = chlayout; if (nret) @@ -669,12 +666,41 @@ { const int64_t *cl; char buf[512]; + int i; + const char *teststrings[] ={ + "blah", + "1", + "2", + "-1", + "60", + "65", + "1c", + "2c", + "-1c", + "60c", + "65c", + "5.1", + "stereo", + "1+1+1+1", + "1c+1c+1c+1c", + "2c+1c", + "0x3", + }; for (cl = avfilter_all_channel_layouts; *cl != -1; cl++) { av_get_channel_layout_string(buf, sizeof(buf), -1, *cl); printf("%s\n", buf); } + for ( i = 0; ipriv; + + s->pts = av_fast_realloc(NULL, &s->pts_size, + DEFAULT_LENGTH * sizeof(*(s->pts))); + if (!s->pts) + return AVERROR(ENOMEM); + + s->frames = av_fast_realloc(NULL, &s->frames_size, + DEFAULT_LENGTH * sizeof(*(s->frames))); + if (!s->frames) { + av_freep(&s->pts); + return AVERROR(ENOMEM); + } + + return 0; +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + ReverseContext *s = ctx->priv; + + av_freep(&s->pts); + av_freep(&s->frames); +} + +static int config_output(AVFilterLink *outlink) +{ + outlink->flags |= FF_LINK_FLAG_REQUEST_LOOP; + return 0; +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ + AVFilterContext *ctx = inlink->dst; + ReverseContext *s = ctx->priv; + void *ptr; + + if (s->nb_frames + 1 > s->pts_size / sizeof(*(s->pts))) { + ptr = av_fast_realloc(s->pts, &s->pts_size, s->pts_size * 2); + if (!ptr) + return AVERROR(ENOMEM); + s->pts = ptr; + } + + if (s->nb_frames + 1 > s->frames_size / sizeof(*(s->frames))) { + ptr = av_fast_realloc(s->frames, &s->frames_size, s->frames_size * 2); + if (!ptr) + return AVERROR(ENOMEM); + s->frames = ptr; + } + + s->frames[s->nb_frames] = in; + s->pts[s->nb_frames] = in->pts; + s->nb_frames++; + + return 0; +} + +#if CONFIG_REVERSE_FILTER + +static int request_frame(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + ReverseContext *s = ctx->priv; + int ret; + + ret = ff_request_frame(ctx->inputs[0]); + + if (ret == AVERROR_EOF && s->nb_frames > 0) { + AVFrame *out = s->frames[s->nb_frames - 1]; + out->pts = s->pts[s->flush_idx++]; + ret = ff_filter_frame(outlink, out); + s->nb_frames--; + } + + return ret; +} + +static const AVFilterPad reverse_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = filter_frame, + }, + { NULL } +}; + +static const AVFilterPad reverse_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .request_frame = request_frame, + .config_props = config_output, + }, + { NULL } +}; + +AVFilter ff_vf_reverse = { + .name = "reverse", + .description = NULL_IF_CONFIG_SMALL("Reverse a clip."), + .priv_size = sizeof(ReverseContext), + .init = init, + .uninit = uninit, + .inputs = reverse_inputs, + .outputs = reverse_outputs, +}; + +#endif /* CONFIG_REVERSE_FILTER */ + +#if CONFIG_AREVERSE_FILTER + +static int query_formats(AVFilterContext *ctx) +{ + AVFilterFormats *formats; + AVFilterChannelLayouts *layouts; + int ret; + + layouts = ff_all_channel_layouts(); + if (!layouts) + return AVERROR(ENOMEM); + ret = ff_set_common_channel_layouts(ctx, layouts); + if (ret < 0) + return ret; + + ret = ff_set_common_formats(ctx, ff_planar_sample_fmts()); + if (ret < 0) + return ret; + + formats = ff_all_samplerates(); + if (!formats) + return AVERROR(ENOMEM); + return ff_set_common_samplerates(ctx, formats); +} + +static int areverse_request_frame(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + ReverseContext *s = ctx->priv; + int ret, p, i, j; + + ret = ff_request_frame(ctx->inputs[0]); + + if (ret == AVERROR_EOF && s->nb_frames > 0) { + AVFrame *out = s->frames[s->nb_frames - 1]; + out->pts = s->pts[s->flush_idx++]; + + for (p = 0; p < outlink->channels; p++) { + switch (outlink->format) { + case AV_SAMPLE_FMT_U8P: { + uint8_t *dst = (uint8_t *)out->extended_data[p]; + for (i = 0, j = out->nb_samples - 1; i < j; i++, j--) + FFSWAP(uint8_t, dst[i], dst[j]); + } + break; + case AV_SAMPLE_FMT_S16P: { + int16_t *dst = (int16_t *)out->extended_data[p]; + for (i = 0, j = out->nb_samples - 1; i < j; i++, j--) + FFSWAP(int16_t, dst[i], dst[j]); + } + break; + case AV_SAMPLE_FMT_S32P: { + int32_t *dst = (int32_t *)out->extended_data[p]; + for (i = 0, j = out->nb_samples - 1; i < j; i++, j--) + FFSWAP(int32_t, dst[i], dst[j]); + } + break; + case AV_SAMPLE_FMT_FLTP: { + float *dst = (float *)out->extended_data[p]; + for (i = 0, j = out->nb_samples - 1; i < j; i++, j--) + FFSWAP(float, dst[i], dst[j]); + } + break; + case AV_SAMPLE_FMT_DBLP: { + double *dst = (double *)out->extended_data[p]; + for (i = 0, j = out->nb_samples - 1; i < j; i++, j--) + FFSWAP(double, dst[i], dst[j]); + } + break; + } + } + + ret = ff_filter_frame(outlink, out); + s->nb_frames--; + } + + return ret; +} + +static const AVFilterPad areverse_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .filter_frame = filter_frame, + .needs_writable = 1, + }, + { NULL } +}; + +static const AVFilterPad areverse_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .request_frame = areverse_request_frame, + .config_props = config_output, + }, + { NULL } +}; + +AVFilter ff_af_areverse = { + .name = "areverse", + .description = NULL_IF_CONFIG_SMALL("Reverse an audio clip."), + .query_formats = query_formats, + .priv_size = sizeof(ReverseContext), + .init = init, + .uninit = uninit, + .inputs = areverse_inputs, + .outputs = areverse_outputs, +}; + +#endif /* CONFIG_AREVERSE_FILTER */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/internal.h ffmpeg-2.7.2~trusty~ppa1/libavfilter/internal.h --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/internal.h 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/internal.h 2015-07-15 17:20:03.000000000 +0000 @@ -305,8 +305,27 @@ /** * Request an input frame from the filter at the other end of the link. * + * The input filter may pass the request on to its inputs, fulfill the + * request from an internal buffer or any other means specific to its function. + * + * When the end of a stream is reached AVERROR_EOF is returned and no further + * frames are returned after that. + * + * When a filter is unable to output a frame for example due to its sources + * being unable to do so or because it depends on external means pushing data + * into it then AVERROR(EAGAIN) is returned. + * It is important that a AVERROR(EAGAIN) return is returned all the way to the + * caller (generally eventually a user application) as this step may (but does + * not have to be) necessary to provide the input with the next frame. + * + * If a request is successful then the filter_frame() function will be called + * at least once before ff_request_frame() returns + * * @param link the input link * @return zero on success + * AVERROR_EOF on end of file + * AVERROR(EAGAIN) if the previous filter cannot output a frame + * currently and can neither guarantee that EOF has been reached. */ int ff_request_frame(AVFilterLink *link); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/Makefile ffmpeg-2.7.2~trusty~ppa1/libavfilter/Makefile --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/Makefile 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/Makefile 2015-08-02 17:20:02.000000000 +0000 @@ -29,6 +29,7 @@ OBJS-$(CONFIG_AVCODEC) += avcodec.o +OBJS-$(CONFIG_ACROSSFADE_FILTER) += af_afade.o OBJS-$(CONFIG_ADELAY_FILTER) += af_adelay.o OBJS-$(CONFIG_AECHO_FILTER) += af_aecho.o OBJS-$(CONFIG_AEVAL_FILTER) += aeval.o @@ -43,6 +44,7 @@ OBJS-$(CONFIG_APERMS_FILTER) += f_perms.o OBJS-$(CONFIG_APHASER_FILTER) += af_aphaser.o generate_wave_table.o OBJS-$(CONFIG_ARESAMPLE_FILTER) += af_aresample.o +OBJS-$(CONFIG_AREVERSE_FILTER) += f_reverse.o OBJS-$(CONFIG_ASELECT_FILTER) += f_select.o OBJS-$(CONFIG_ASENDCMD_FILTER) += f_sendcmd.o OBJS-$(CONFIG_ASETNSAMPLES_FILTER) += af_asetnsamples.o @@ -67,6 +69,7 @@ OBJS-$(CONFIG_CHORUS_FILTER) += af_chorus.o generate_wave_table.o OBJS-$(CONFIG_COMPAND_FILTER) += af_compand.o OBJS-$(CONFIG_DCSHIFT_FILTER) += af_dcshift.o +OBJS-$(CONFIG_DYNAUDNORM_FILTER) += af_dynaudnorm.o OBJS-$(CONFIG_EARWAX_FILTER) += af_earwax.o OBJS-$(CONFIG_EBUR128_FILTER) += f_ebur128.o OBJS-$(CONFIG_EQUALIZER_FILTER) += af_biquads.o @@ -78,6 +81,7 @@ OBJS-$(CONFIG_PAN_FILTER) += af_pan.o OBJS-$(CONFIG_REPLAYGAIN_FILTER) += af_replaygain.o OBJS-$(CONFIG_RESAMPLE_FILTER) += af_resample.o +OBJS-$(CONFIG_SIDECHAINCOMPRESS_FILTER) += af_sidechaincompress.o OBJS-$(CONFIG_SILENCEDETECT_FILTER) += af_silencedetect.o OBJS-$(CONFIG_SILENCEREMOVE_FILTER) += af_silenceremove.o OBJS-$(CONFIG_TREBLE_FILTER) += af_biquads.o @@ -94,6 +98,7 @@ OBJS-$(CONFIG_ASS_FILTER) += vf_subtitles.o OBJS-$(CONFIG_ALPHAEXTRACT_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_ALPHAMERGE_FILTER) += vf_alphamerge.o +OBJS-$(CONFIG_ATADENOISE_FILTER) += vf_atadenoise.o OBJS-$(CONFIG_BBOX_FILTER) += bbox.o vf_bbox.o OBJS-$(CONFIG_BLACKDETECT_FILTER) += vf_blackdetect.o OBJS-$(CONFIG_BLACKFRAME_FILTER) += vf_blackframe.o @@ -102,6 +107,7 @@ OBJS-$(CONFIG_CODECVIEW_FILTER) += vf_codecview.o OBJS-$(CONFIG_COLORBALANCE_FILTER) += vf_colorbalance.o OBJS-$(CONFIG_COLORCHANNELMIXER_FILTER) += vf_colorchannelmixer.o +OBJS-$(CONFIG_COLORKEY_FILTER) += vf_colorkey.o OBJS-$(CONFIG_COLORLEVELS_FILTER) += vf_colorlevels.o OBJS-$(CONFIG_COLORMATRIX_FILTER) += vf_colormatrix.o OBJS-$(CONFIG_COPY_FILTER) += vf_copy.o @@ -110,17 +116,22 @@ OBJS-$(CONFIG_CROPDETECT_FILTER) += vf_cropdetect.o OBJS-$(CONFIG_CURVES_FILTER) += vf_curves.o OBJS-$(CONFIG_DCTDNOIZ_FILTER) += vf_dctdnoiz.o +OBJS-$(CONFIG_DEBAND_FILTER) += vf_deband.o OBJS-$(CONFIG_DECIMATE_FILTER) += vf_decimate.o +OBJS-$(CONFIG_DEFLATE_FILTER) += vf_neighbor.o OBJS-$(CONFIG_DEJUDDER_FILTER) += vf_dejudder.o OBJS-$(CONFIG_DELOGO_FILTER) += vf_delogo.o OBJS-$(CONFIG_DESHAKE_FILTER) += vf_deshake.o OBJS-$(CONFIG_DETELECINE_FILTER) += vf_detelecine.o +OBJS-$(CONFIG_DILATION_FILTER) += vf_neighbor.o OBJS-$(CONFIG_DRAWBOX_FILTER) += vf_drawbox.o +OBJS-$(CONFIG_DRAWGRAPH_FILTER) += f_drawgraph.o OBJS-$(CONFIG_DRAWGRID_FILTER) += vf_drawbox.o OBJS-$(CONFIG_DRAWTEXT_FILTER) += vf_drawtext.o OBJS-$(CONFIG_ELBG_FILTER) += vf_elbg.o OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o +OBJS-$(CONFIG_EROSION_FILTER) += vf_neighbor.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o OBJS-$(CONFIG_FFTFILT_FILTER) += vf_fftfilt.o @@ -129,9 +140,9 @@ OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o OBJS-$(CONFIG_FIND_RECT_FILTER) += vf_find_rect.o lavfutils.o OBJS-$(CONFIG_FORMAT_FILTER) += vf_format.o -OBJS-$(CONFIG_FRAMESTEP_FILTER) += vf_framestep.o OBJS-$(CONFIG_FPS_FILTER) += vf_fps.o OBJS-$(CONFIG_FRAMEPACK_FILTER) += vf_framepack.o +OBJS-$(CONFIG_FRAMESTEP_FILTER) += vf_framestep.o OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o OBJS-$(CONFIG_FSPP_FILTER) += vf_fspp.o OBJS-$(CONFIG_GEQ_FILTER) += vf_geq.o @@ -145,6 +156,7 @@ OBJS-$(CONFIG_HUE_FILTER) += vf_hue.o OBJS-$(CONFIG_IDET_FILTER) += vf_idet.o OBJS-$(CONFIG_IL_FILTER) += vf_il.o +OBJS-$(CONFIG_INFLATE_FILTER) += vf_neighbor.o OBJS-$(CONFIG_INTERLACE_FILTER) += vf_interlace.o OBJS-$(CONFIG_INTERLEAVE_FILTER) += f_interleave.o OBJS-$(CONFIG_KERNDEINT_FILTER) += vf_kerndeint.o @@ -176,8 +188,11 @@ OBJS-$(CONFIG_PSNR_FILTER) += vf_psnr.o dualinput.o framesync.o OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o OBJS-$(CONFIG_QP_FILTER) += vf_qp.o +OBJS-$(CONFIG_RANDOM_FILTER) += vf_random.o +OBJS-$(CONFIG_REMOVEGRAIN_FILTER) += vf_removegrain.o OBJS-$(CONFIG_REMOVELOGO_FILTER) += bbox.o lswsutils.o lavfutils.o vf_removelogo.o OBJS-$(CONFIG_REPEATFIELDS_FILTER) += vf_repeatfields.o +OBJS-$(CONFIG_REVERSE_FILTER) += f_reverse.o OBJS-$(CONFIG_ROTATE_FILTER) += vf_rotate.o OBJS-$(CONFIG_SEPARATEFIELDS_FILTER) += vf_separatefields.o OBJS-$(CONFIG_SAB_FILTER) += vf_sab.o @@ -196,6 +211,7 @@ OBJS-$(CONFIG_SMARTBLUR_FILTER) += vf_smartblur.o OBJS-$(CONFIG_SPLIT_FILTER) += split.o OBJS-$(CONFIG_SPP_FILTER) += vf_spp.o +OBJS-$(CONFIG_SSIM_FILTER) += vf_ssim.o dualinput.o framesync.o OBJS-$(CONFIG_STEREO3D_FILTER) += vf_stereo3d.o OBJS-$(CONFIG_SUBTITLES_FILTER) += vf_subtitles.o OBJS-$(CONFIG_SUPER2XSAI_FILTER) += vf_super2xsai.o @@ -219,6 +235,7 @@ OBJS-$(CONFIG_ZMQ_FILTER) += f_zmq.o OBJS-$(CONFIG_ZOOMPAN_FILTER) += vf_zoompan.o +OBJS-$(CONFIG_ALLYUV_FILTER) += vsrc_testsrc.o OBJS-$(CONFIG_CELLAUTO_FILTER) += vsrc_cellauto.o OBJS-$(CONFIG_COLOR_FILTER) += vsrc_testsrc.o OBJS-$(CONFIG_FREI0R_SRC_FILTER) += vf_frei0r.o @@ -235,10 +252,12 @@ OBJS-$(CONFIG_NULLSINK_FILTER) += vsink_nullsink.o # multimedia filters +OBJS-$(CONFIG_ADRAWGRAPH_FILTER) += f_drawgraph.o OBJS-$(CONFIG_AVECTORSCOPE_FILTER) += avf_avectorscope.o OBJS-$(CONFIG_CONCAT_FILTER) += avf_concat.o OBJS-$(CONFIG_SHOWCQT_FILTER) += avf_showcqt.o OBJS-$(CONFIG_SHOWSPECTRUM_FILTER) += avf_showspectrum.o +OBJS-$(CONFIG_SHOWVOLUME_FILTER) += avf_showvolume.o OBJS-$(CONFIG_SHOWWAVES_FILTER) += avf_showwaves.o OBJS-$(CONFIG_SHOWWAVESPIC_FILTER) += avf_showwaves.o diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/psnr.h ffmpeg-2.7.2~trusty~ppa1/libavfilter/psnr.h --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/psnr.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/psnr.h 2015-07-14 17:20:02.000000000 +0000 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015 Ronald S. Bultje + * + * 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 + */ + +#ifndef LIBAVFILTER_PSNR_H +#define LIBAVFILTER_PSNR_H + +#include +#include + +typedef struct PSNRDSPContext { + uint64_t (*sse_line)(const uint8_t *buf, const uint8_t *ref, int w); +} PSNRDSPContext; + +void ff_psnr_init_x86(PSNRDSPContext *dsp, int bpp); + +#endif /* LIBAVFILTER_PSNR_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/removegrain.h ffmpeg-2.7.2~trusty~ppa1/libavfilter/removegrain.h --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/removegrain.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/removegrain.h 2015-07-15 17:20:03.000000000 +0000 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 Paul B Mahol + * Copyright (c) 2015 James Darnley + * + * 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 "avfilter.h" + +typedef struct RemoveGrainContext { + const AVClass *class; + + int mode[4]; + + int nb_planes; + int planewidth[4]; + int planeheight[4]; + int skip_even; + int skip_odd; + + int (*rg[4])(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8); + + void (*fl[4])(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +} RemoveGrainContext; + +void ff_removegrain_init_x86(RemoveGrainContext *rg); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/ssim.h ffmpeg-2.7.2~trusty~ppa1/libavfilter/ssim.h --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/ssim.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/ssim.h 2015-07-14 17:20:02.000000000 +0000 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015 Ronald S. Bultje + * + * 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 + */ + +#ifndef LIBAVFILTER_SSIM_H +#define LIBAVFILTER_SSIM_H + +#include +#include + +typedef struct SSIMDSPContext { + void (*ssim_4x4_line)(const uint8_t *buf, ptrdiff_t buf_stride, + const uint8_t *ref, ptrdiff_t ref_stride, + int (*sums)[4], int w); + float (*ssim_end_line)(const int (*sum0)[4], const int (*sum1)[4], int w); +} SSIMDSPContext; + +void ff_ssim_init_x86(SSIMDSPContext *dsp); + +#endif /* LIBAVFILTER_SSIM_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/version.h ffmpeg-2.7.2~trusty~ppa1/libavfilter/version.h --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/version.h 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/version.h 2015-08-02 17:20:02.000000000 +0000 @@ -30,8 +30,8 @@ #include "libavutil/version.h" #define LIBAVFILTER_VERSION_MAJOR 5 -#define LIBAVFILTER_VERSION_MINOR 16 -#define LIBAVFILTER_VERSION_MICRO 101 +#define LIBAVFILTER_VERSION_MINOR 32 +#define LIBAVFILTER_VERSION_MICRO 100 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_atadenoise.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_atadenoise.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_atadenoise.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_atadenoise.c 2015-08-02 17:20:02.000000000 +0000 @@ -0,0 +1,417 @@ +/* + * Copyright (c) 2015 Paul B Mahol + * + * 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 + */ + +/** + * @file + * Adaptive Temporal Averaging Denoiser, + * based on paper "Video Denoising Based on Adaptive Temporal Averaging" by + * David BartovÄak and Miroslav Vrankić + */ + +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "avfilter.h" + +#define FF_BUFQUEUE_SIZE 129 +#include "bufferqueue.h" + +#include "formats.h" +#include "internal.h" +#include "video.h" + +#define SIZE FF_BUFQUEUE_SIZE + +typedef struct ATADenoiseContext { + const AVClass *class; + + float fthra[4], fthrb[4]; + int thra[4], thrb[4]; + + int nb_planes; + int planewidth[4]; + int planeheight[4]; + + struct FFBufQueue q; + void *data[4][SIZE]; + int linesize[4][SIZE]; + int size, mid; + int available; + + int (*filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); +} ATADenoiseContext; + +#define OFFSET(x) offsetof(ATADenoiseContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption atadenoise_options[] = { + { "0a", "set threshold A for 1st plane", OFFSET(fthra[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0, 0.3, FLAGS }, + { "0b", "set threshold B for 1st plane", OFFSET(fthrb[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.04}, 0, 5.0, FLAGS }, + { "1a", "set threshold A for 2nd plane", OFFSET(fthra[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0, 0.3, FLAGS }, + { "1b", "set threshold B for 2nd plane", OFFSET(fthrb[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.04}, 0, 5.0, FLAGS }, + { "2a", "set threshold A for 3rd plane", OFFSET(fthra[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0, 0.3, FLAGS }, + { "2b", "set threshold B for 3rd plane", OFFSET(fthrb[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.04}, 0, 5.0, FLAGS }, + { "s", "set how many frames to use", OFFSET(size), AV_OPT_TYPE_INT, {.i64=33}, 5, SIZE, FLAGS }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(atadenoise); + +static int query_formats(AVFilterContext *ctx) +{ + static const enum AVPixelFormat pixel_fmts[] = { + AV_PIX_FMT_GRAY8, + AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P, + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, + AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P, + AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, + AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P, + AV_PIX_FMT_YUVJ411P, + AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9, + AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, + AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16, + AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, + AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16, + AV_PIX_FMT_NONE + }; + AVFilterFormats *formats = ff_make_format_list(pixel_fmts); + if (!formats) + return AVERROR(ENOMEM); + return ff_set_common_formats(ctx, formats); +} + +static av_cold int init(AVFilterContext *ctx) +{ + ATADenoiseContext *s = ctx->priv; + + if (!(s->size & 1)) { + av_log(ctx, AV_LOG_ERROR, "size %d is invalid. Must be an odd value.\n", s->size); + return AVERROR(EINVAL); + } + s->mid = s->size / 2 + 1; + + return 0; +} + +typedef struct ThreadData { + AVFrame *in, *out; +} ThreadData; + +static int filter_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) +{ + ATADenoiseContext *s = ctx->priv; + ThreadData *td = arg; + AVFrame *in = td->in; + AVFrame *out = td->out; + const int size = s->size; + const int mid = s->mid; + int p, x, y, i, j; + + for (p = 0; p < s->nb_planes; p++) { + const int h = s->planeheight[p]; + const int w = s->planewidth[p]; + const int slice_start = (h * jobnr) / nb_jobs; + const int slice_end = (h * (jobnr+1)) / nb_jobs; + const uint8_t *src = in->data[p] + slice_start * in->linesize[p]; + uint8_t *dst = out->data[p] + slice_start * out->linesize[p]; + const int thra = s->thra[p]; + const int thrb = s->thrb[p]; + const uint8_t **data = (const uint8_t **)s->data[p]; + const int *linesize = (const int *)s->linesize[p]; + const uint8_t *srcf[SIZE]; + + for (i = 0; i < size; i++) + srcf[i] = data[i] + slice_start * linesize[i]; + + for (y = slice_start; y < slice_end; y++) { + for (x = 0; x < w; x++) { + const int srcx = src[x]; + unsigned lsumdiff = 0, rsumdiff = 0; + unsigned ldiff, rdiff; + unsigned sum = srcx; + int l = 0, r = 0; + int srcjx, srcix; + + for (j = mid - 1, i = mid + 1; j >= 0 && i < size; j--, i++) { + srcjx = srcf[j][x]; + + ldiff = FFABS(srcx - srcjx); + lsumdiff += ldiff; + if (ldiff > thra || + lsumdiff > thrb) + break; + l++; + sum += srcjx; + + srcix = srcf[i][x]; + + rdiff = FFABS(srcx - srcix); + rsumdiff += rdiff; + if (rdiff > thra || + rsumdiff > thrb) + break; + r++; + sum += srcix; + } + + dst[x] = sum / (r + l + 1); + } + + dst += out->linesize[p]; + src += in->linesize[p]; + + for (i = 0; i < size; i++) + srcf[i] += linesize[i]; + } + } + + return 0; +} + +static int filter_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) +{ + ATADenoiseContext *s = ctx->priv; + ThreadData *td = arg; + AVFrame *in = td->in; + AVFrame *out = td->out; + const int size = s->size; + const int mid = s->mid; + int p, x, y, i, j; + + for (p = 0; p < s->nb_planes; p++) { + const int h = s->planeheight[p]; + const int w = s->planewidth[p]; + const int slice_start = (h * jobnr) / nb_jobs; + const int slice_end = (h * (jobnr+1)) / nb_jobs; + const uint16_t *src = (uint16_t *)(in->data[p] + slice_start * in->linesize[p]); + uint16_t *dst = (uint16_t *)(out->data[p] + slice_start * out->linesize[p]); + const int thra = s->thra[p]; + const int thrb = s->thrb[p]; + const uint8_t **data = (const uint8_t **)s->data[p]; + const int *linesize = (const int *)s->linesize[p]; + const uint16_t *srcf[SIZE]; + + for (i = 0; i < s->size; i++) + srcf[i] = (const uint16_t *)(data[i] + slice_start * linesize[i]); + + for (y = slice_start; y < slice_end; y++) { + for (x = 0; x < w; x++) { + const int srcx = src[x]; + unsigned lsumdiff = 0, rsumdiff = 0; + unsigned ldiff, rdiff; + unsigned sum = srcx; + int l = 0, r = 0; + int srcjx, srcix; + + for (j = mid - 1, i = mid + 1; j >= 0 && i < size; j--, i++) { + srcjx = srcf[j][x]; + + ldiff = FFABS(srcx - srcjx); + lsumdiff += ldiff; + if (ldiff > thra || + lsumdiff > thrb) + break; + l++; + sum += srcjx; + + srcix = srcf[i][x]; + + rdiff = FFABS(srcx - srcix); + rsumdiff += rdiff; + if (rdiff > thra || + rsumdiff > thrb) + break; + r++; + sum += srcix; + } + + dst[x] = sum / (r + l + 1); + } + + dst += out->linesize[p] / 2; + src += in->linesize[p] / 2; + + for (i = 0; i < size; i++) + srcf[i] += linesize[i] / 2; + } + } + + return 0; +} + +static int config_input(AVFilterLink *inlink) +{ + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); + AVFilterContext *ctx = inlink->dst; + ATADenoiseContext *s = ctx->priv; + int depth; + + s->nb_planes = desc->nb_components; + + s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h); + s->planeheight[0] = s->planeheight[3] = inlink->h; + s->planewidth[1] = s->planewidth[2] = FF_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w); + s->planewidth[0] = s->planewidth[3] = inlink->w; + + depth = desc->comp[0].depth_minus1 + 1; + if (depth == 8) + s->filter_slice = filter_slice8; + else + s->filter_slice = filter_slice16; + + s->thra[0] = s->fthra[0] * (1 << depth) - 1; + s->thra[1] = s->fthra[1] * (1 << depth) - 1; + s->thra[2] = s->fthra[2] * (1 << depth) - 1; + s->thrb[0] = s->fthrb[0] * (1 << depth) - 1; + s->thrb[1] = s->fthrb[1] * (1 << depth) - 1; + s->thrb[2] = s->fthrb[2] * (1 << depth) - 1; + + return 0; +} + +static int config_output(AVFilterLink *outlink) +{ + outlink->flags |= FF_LINK_FLAG_REQUEST_LOOP; + return 0; +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *buf) +{ + AVFilterContext *ctx = inlink->dst; + AVFilterLink *outlink = ctx->outputs[0]; + ATADenoiseContext *s = ctx->priv; + AVFrame *out, *in; + int i; + + if (s->q.available != s->size) { + if (s->q.available < s->mid) { + out = ff_get_video_buffer(outlink, outlink->w, outlink->h); + for (i = 0; i < s->mid; i++) + ff_bufqueue_add(ctx, &s->q, av_frame_clone(out)); + av_frame_free(&out); + } + if (s->q.available < s->size) { + ff_bufqueue_add(ctx, &s->q, buf); + s->available++; + } + return 0; + } + + in = ff_bufqueue_peek(&s->q, s->mid); + + if (!ctx->is_disabled) { + ThreadData td; + + out = ff_get_video_buffer(outlink, outlink->w, outlink->h); + if (!out) { + av_frame_free(&buf); + return AVERROR(ENOMEM); + } + + for (i = 0; i < s->size; i++) { + AVFrame *frame = ff_bufqueue_peek(&s->q, i); + + s->data[0][i] = frame->data[0]; + s->data[1][i] = frame->data[1]; + s->data[2][i] = frame->data[2]; + s->linesize[0][i] = frame->linesize[0]; + s->linesize[1][i] = frame->linesize[1]; + s->linesize[2][i] = frame->linesize[2]; + } + + td.in = in; td.out = out; + ctx->internal->execute(ctx, s->filter_slice, &td, NULL, + FFMIN3(s->planeheight[1], + s->planeheight[2], + ctx->graph->nb_threads)); + av_frame_copy_props(out, in); + } else { + out = av_frame_clone(in); + if (!out) { + av_frame_free(&buf); + return AVERROR(ENOMEM); + } + } + + in = ff_bufqueue_get(&s->q); + av_frame_free(&in); + ff_bufqueue_add(ctx, &s->q, buf); + + return ff_filter_frame(outlink, out); +} + +static int request_frame(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + ATADenoiseContext *s = ctx->priv; + int ret = 0; + + ret = ff_request_frame(ctx->inputs[0]); + + if (ret == AVERROR_EOF && !ctx->is_disabled && s->available) { + AVFrame *buf = ff_get_video_buffer(outlink, outlink->w, outlink->h); + if (!buf) + return AVERROR(ENOMEM); + + ret = filter_frame(ctx->inputs[0], buf); + s->available--; + } + + return ret; +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + ATADenoiseContext *s = ctx->priv; + + ff_bufqueue_discard_all(&s->q); +} + +static const AVFilterPad inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = filter_frame, + .config_props = config_input, + }, + { NULL } +}; + +static const AVFilterPad outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .request_frame = request_frame, + .config_props = config_output, + }, + { NULL } +}; + +AVFilter ff_vf_atadenoise = { + .name = "atadenoise", + .description = NULL_IF_CONFIG_SMALL("Apply an Adaptive Temporal Averaging Denoiser."), + .priv_size = sizeof(ATADenoiseContext), + .priv_class = &atadenoise_class, + .init = init, + .uninit = uninit, + .query_formats = query_formats, + .inputs = inputs, + .outputs = outputs, + .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_blend.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_blend.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_blend.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_blend.c 2015-07-19 17:20:03.000000000 +0000 @@ -169,24 +169,50 @@ av_image_copy_plane(dst, dst_linesize, top, top_linesize, width, end - start); } -#define DEFINE_BLEND(name, expr) \ -static void blend_## name(const uint8_t *top, int top_linesize, \ - const uint8_t *bottom, int bottom_linesize, \ - uint8_t *dst, int dst_linesize, \ - int width, int start, int end, \ - FilterParams *param, double *values) \ -{ \ - double opacity = param->opacity; \ - int i, j; \ - \ - for (i = start; i < end; i++) { \ - for (j = 0; j < width; j++) { \ - dst[j] = top[j] + ((expr) - top[j]) * opacity; \ - } \ - dst += dst_linesize; \ - top += top_linesize; \ - bottom += bottom_linesize; \ - } \ +#define DEFINE_BLEND8(name, expr) \ +static void blend_## name##_8bit(const uint8_t *top, int top_linesize, \ + const uint8_t *bottom, int bottom_linesize, \ + uint8_t *dst, int dst_linesize, \ + int width, int start, int end, \ + FilterParams *param, double *values) \ +{ \ + double opacity = param->opacity; \ + int i, j; \ + \ + for (i = start; i < end; i++) { \ + for (j = 0; j < width; j++) { \ + dst[j] = top[j] + ((expr) - top[j]) * opacity; \ + } \ + dst += dst_linesize; \ + top += top_linesize; \ + bottom += bottom_linesize; \ + } \ +} + +#define DEFINE_BLEND16(name, expr) \ +static void blend_## name##_16bit(const uint8_t *_top, int top_linesize, \ + const uint8_t *_bottom, int bottom_linesize, \ + uint8_t *_dst, int dst_linesize, \ + int width, int start, int end, \ + FilterParams *param, double *values) \ +{ \ + const uint16_t *top = (uint16_t*)_top; \ + const uint16_t *bottom = (uint16_t*)_bottom; \ + uint16_t *dst = (uint16_t*)_dst; \ + double opacity = param->opacity; \ + int i, j; \ + dst_linesize /= 2; \ + top_linesize /= 2; \ + bottom_linesize /= 2; \ + \ + for (i = start; i < end; i++) { \ + for (j = 0; j < width; j++) { \ + dst[j] = top[j] + ((expr) - top[j]) * opacity; \ + } \ + dst += dst_linesize; \ + top += top_linesize; \ + bottom += bottom_linesize; \ + } \ } #define A top[j] @@ -197,57 +223,105 @@ #define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, 255 - ((255 - (b)) << 8) / (a))) #define DODGE(a, b) (((a) == 255) ? (a) : FFMIN(255, (((b) << 8) / (255 - (a))))) -DEFINE_BLEND(addition, FFMIN(255, A + B)) -DEFINE_BLEND(average, (A + B) / 2) -DEFINE_BLEND(subtract, FFMAX(0, A - B)) -DEFINE_BLEND(multiply, MULTIPLY(1, A, B)) -DEFINE_BLEND(negation, 255 - FFABS(255 - A - B)) -DEFINE_BLEND(difference, FFABS(A - B)) -DEFINE_BLEND(difference128, av_clip_uint8(128 + A - B)) -DEFINE_BLEND(screen, SCREEN(1, A, B)) -DEFINE_BLEND(overlay, (A < 128) ? MULTIPLY(2, A, B) : SCREEN(2, A, B)) -DEFINE_BLEND(hardlight, (B < 128) ? MULTIPLY(2, B, A) : SCREEN(2, B, A)) -DEFINE_BLEND(hardmix, (A < (255 - B)) ? 0: 255) -DEFINE_BLEND(darken, FFMIN(A, B)) -DEFINE_BLEND(lighten, FFMAX(A, B)) -DEFINE_BLEND(divide, av_clip_uint8(((float)A / ((float)B) * 255))) -DEFINE_BLEND(dodge, DODGE(A, B)) -DEFINE_BLEND(burn, BURN(A, B)) -DEFINE_BLEND(softlight, (A > 127) ? B + (255 - B) * (A - 127.5) / 127.5 * (0.5 - FFABS(B - 127.5) / 255): B - B * ((127.5 - A) / 127.5) * (0.5 - FFABS(B - 127.5)/255)) -DEFINE_BLEND(exclusion, A + B - 2 * A * B / 255) -DEFINE_BLEND(pinlight, (B < 128) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 128))) -DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 255) -DEFINE_BLEND(reflect, (B == 255) ? B : FFMIN(255, (A * A / (255 - B)))) -DEFINE_BLEND(glow, (A == 255) ? A : FFMIN(255, (B * B / (255 - A)))) -DEFINE_BLEND(and, A & B) -DEFINE_BLEND(or, A | B) -DEFINE_BLEND(xor, A ^ B) -DEFINE_BLEND(vividlight, (A < 128) ? BURN(2 * A, B) : DODGE(2 * (A - 128), B)) -DEFINE_BLEND(linearlight,av_clip_uint8((B < 128) ? B + 2 * A - 255 : B + 2 * (A - 128))) - -static void blend_expr(const uint8_t *top, int top_linesize, - const uint8_t *bottom, int bottom_linesize, - uint8_t *dst, int dst_linesize, - int width, int start, int end, - FilterParams *param, double *values) -{ - AVExpr *e = param->e; - int y, x; - - for (y = start; y < end; y++) { - values[VAR_Y] = y; - for (x = 0; x < width; x++) { - values[VAR_X] = x; - values[VAR_TOP] = values[VAR_A] = top[x]; - values[VAR_BOTTOM] = values[VAR_B] = bottom[x]; - dst[x] = av_expr_eval(e, values, NULL); - } - dst += dst_linesize; - top += top_linesize; - bottom += bottom_linesize; - } +DEFINE_BLEND8(addition, FFMIN(255, A + B)) +DEFINE_BLEND8(average, (A + B) / 2) +DEFINE_BLEND8(subtract, FFMAX(0, A - B)) +DEFINE_BLEND8(multiply, MULTIPLY(1, A, B)) +DEFINE_BLEND8(negation, 255 - FFABS(255 - A - B)) +DEFINE_BLEND8(difference, FFABS(A - B)) +DEFINE_BLEND8(difference128, av_clip_uint8(128 + A - B)) +DEFINE_BLEND8(screen, SCREEN(1, A, B)) +DEFINE_BLEND8(overlay, (A < 128) ? MULTIPLY(2, A, B) : SCREEN(2, A, B)) +DEFINE_BLEND8(hardlight, (B < 128) ? MULTIPLY(2, B, A) : SCREEN(2, B, A)) +DEFINE_BLEND8(hardmix, (A < (255 - B)) ? 0: 255) +DEFINE_BLEND8(darken, FFMIN(A, B)) +DEFINE_BLEND8(lighten, FFMAX(A, B)) +DEFINE_BLEND8(divide, av_clip_uint8(((float)A / ((float)B) * 255))) +DEFINE_BLEND8(dodge, DODGE(A, B)) +DEFINE_BLEND8(burn, BURN(A, B)) +DEFINE_BLEND8(softlight, (A > 127) ? B + (255 - B) * (A - 127.5) / 127.5 * (0.5 - FFABS(B - 127.5) / 255): B - B * ((127.5 - A) / 127.5) * (0.5 - FFABS(B - 127.5)/255)) +DEFINE_BLEND8(exclusion, A + B - 2 * A * B / 255) +DEFINE_BLEND8(pinlight, (B < 128) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 128))) +DEFINE_BLEND8(phoenix, FFMIN(A, B) - FFMAX(A, B) + 255) +DEFINE_BLEND8(reflect, (B == 255) ? B : FFMIN(255, (A * A / (255 - B)))) +DEFINE_BLEND8(glow, (A == 255) ? A : FFMIN(255, (B * B / (255 - A)))) +DEFINE_BLEND8(and, A & B) +DEFINE_BLEND8(or, A | B) +DEFINE_BLEND8(xor, A ^ B) +DEFINE_BLEND8(vividlight, (A < 128) ? BURN(2 * A, B) : DODGE(2 * (A - 128), B)) +DEFINE_BLEND8(linearlight,av_clip_uint8((B < 128) ? B + 2 * A - 255 : B + 2 * (A - 128))) + +#undef MULTIPLY +#undef SCREEN +#undef BURN +#undef DODGE + +#define MULTIPLY(x, a, b) ((x) * (((a) * (b)) / 65535)) +#define SCREEN(x, a, b) (65535 - (x) * ((65535 - (a)) * (65535 - (b)) / 65535)) +#define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, 65535 - ((65535 - (b)) << 16) / (a))) +#define DODGE(a, b) (((a) == 65535) ? (a) : FFMIN(65535, (((b) << 16) / (65535 - (a))))) + +DEFINE_BLEND16(addition, FFMIN(65535, A + B)) +DEFINE_BLEND16(average, (A + B) / 2) +DEFINE_BLEND16(subtract, FFMAX(0, A - B)) +DEFINE_BLEND16(multiply, MULTIPLY(1, A, B)) +DEFINE_BLEND16(negation, 65535 - FFABS(65535 - A - B)) +DEFINE_BLEND16(difference, FFABS(A - B)) +DEFINE_BLEND16(difference128, av_clip_uint16(32768 + A - B)) +DEFINE_BLEND16(screen, SCREEN(1, A, B)) +DEFINE_BLEND16(overlay, (A < 32768) ? MULTIPLY(2, A, B) : SCREEN(2, A, B)) +DEFINE_BLEND16(hardlight, (B < 32768) ? MULTIPLY(2, B, A) : SCREEN(2, B, A)) +DEFINE_BLEND16(hardmix, (A < (65535 - B)) ? 0: 65535) +DEFINE_BLEND16(darken, FFMIN(A, B)) +DEFINE_BLEND16(lighten, FFMAX(A, B)) +DEFINE_BLEND16(divide, av_clip_uint16(((float)A / ((float)B) * 65535))) +DEFINE_BLEND16(dodge, DODGE(A, B)) +DEFINE_BLEND16(burn, BURN(A, B)) +DEFINE_BLEND16(softlight, (A > 32767) ? B + (65535 - B) * (A - 32767.5) / 32767.5 * (0.5 - FFABS(B - 32767.5) / 65535): B - B * ((32767.5 - A) / 32767.5) * (0.5 - FFABS(B - 32767.5)/65535)) +DEFINE_BLEND16(exclusion, A + B - 2 * A * B / 65535) +DEFINE_BLEND16(pinlight, (B < 32768) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 32768))) +DEFINE_BLEND16(phoenix, FFMIN(A, B) - FFMAX(A, B) + 65535) +DEFINE_BLEND16(reflect, (B == 65535) ? B : FFMIN(65535, (A * A / (65535 - B)))) +DEFINE_BLEND16(glow, (A == 65535) ? A : FFMIN(65535, (B * B / (65535 - A)))) +DEFINE_BLEND16(and, A & B) +DEFINE_BLEND16(or, A | B) +DEFINE_BLEND16(xor, A ^ B) +DEFINE_BLEND16(vividlight, (A < 32768) ? BURN(2 * A, B) : DODGE(2 * (A - 32768), B)) +DEFINE_BLEND16(linearlight,av_clip_uint16((B < 32768) ? B + 2 * A - 65535 : B + 2 * (A - 32768))) + +#define DEFINE_BLEND_EXPR(type, name, div) \ +static void blend_expr_## name(const uint8_t *_top, int top_linesize, \ + const uint8_t *_bottom, int bottom_linesize, \ + uint8_t *_dst, int dst_linesize, \ + int width, int start, int end, \ + FilterParams *param, double *values) \ +{ \ + const type *top = (type*)_top; \ + const type *bottom = (type*)_bottom; \ + type *dst = (type*)_dst; \ + AVExpr *e = param->e; \ + int y, x; \ + dst_linesize /= div; \ + top_linesize /= div; \ + bottom_linesize /= div; \ + \ + for (y = start; y < end; y++) { \ + values[VAR_Y] = y; \ + for (x = 0; x < width; x++) { \ + values[VAR_X] = x; \ + values[VAR_TOP] = values[VAR_A] = top[x]; \ + values[VAR_BOTTOM] = values[VAR_B] = bottom[x]; \ + dst[x] = av_expr_eval(e, values, NULL); \ + } \ + dst += dst_linesize; \ + top += top_linesize; \ + bottom += bottom_linesize; \ + } \ } +DEFINE_BLEND_EXPR(uint8_t, 8bit, 1) +DEFINE_BLEND_EXPR(uint16_t, 16bit, 2) + static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) { ThreadData *td = arg; @@ -311,63 +385,9 @@ static av_cold int init(AVFilterContext *ctx) { BlendContext *b = ctx->priv; - int ret, plane; b->tblend = !strcmp(ctx->filter->name, "tblend"); - for (plane = 0; plane < FF_ARRAY_ELEMS(b->params); plane++) { - FilterParams *param = &b->params[plane]; - - if (b->all_mode >= 0) - param->mode = b->all_mode; - if (b->all_opacity < 1) - param->opacity = b->all_opacity; - - switch (param->mode) { - case BLEND_ADDITION: param->blend = blend_addition; break; - case BLEND_AND: param->blend = blend_and; break; - case BLEND_AVERAGE: param->blend = blend_average; break; - case BLEND_BURN: param->blend = blend_burn; break; - case BLEND_DARKEN: param->blend = blend_darken; break; - case BLEND_DIFFERENCE: param->blend = blend_difference; break; - case BLEND_DIFFERENCE128: param->blend = blend_difference128; break; - case BLEND_DIVIDE: param->blend = blend_divide; break; - case BLEND_DODGE: param->blend = blend_dodge; break; - case BLEND_EXCLUSION: param->blend = blend_exclusion; break; - case BLEND_GLOW: param->blend = blend_glow; break; - case BLEND_HARDLIGHT: param->blend = blend_hardlight; break; - case BLEND_HARDMIX: param->blend = blend_hardmix; break; - case BLEND_LIGHTEN: param->blend = blend_lighten; break; - case BLEND_LINEARLIGHT:param->blend = blend_linearlight;break; - case BLEND_MULTIPLY: param->blend = blend_multiply; break; - case BLEND_NEGATION: param->blend = blend_negation; break; - case BLEND_NORMAL: param->blend = blend_normal; break; - case BLEND_OR: param->blend = blend_or; break; - case BLEND_OVERLAY: param->blend = blend_overlay; break; - case BLEND_PHOENIX: param->blend = blend_phoenix; break; - case BLEND_PINLIGHT: param->blend = blend_pinlight; break; - case BLEND_REFLECT: param->blend = blend_reflect; break; - case BLEND_SCREEN: param->blend = blend_screen; break; - case BLEND_SOFTLIGHT: param->blend = blend_softlight; break; - case BLEND_SUBTRACT: param->blend = blend_subtract; break; - case BLEND_VIVIDLIGHT: param->blend = blend_vividlight; break; - case BLEND_XOR: param->blend = blend_xor; break; - } - - if (b->all_expr && !param->expr_str) { - param->expr_str = av_strdup(b->all_expr); - if (!param->expr_str) - return AVERROR(ENOMEM); - } - if (param->expr_str) { - ret = av_expr_parse(¶m->e, param->expr_str, var_names, - NULL, NULL, NULL, NULL, 0, ctx); - if (ret < 0) - return ret; - param->blend = blend_expr; - } - } - b->dinput.process = blend_frame; return 0; } @@ -378,7 +398,11 @@ AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ422P,AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, - AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE + AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GRAY8, + AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16, + AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16, + AV_PIX_FMT_GBRP16, AV_PIX_FMT_GRAY16, + AV_PIX_FMT_NONE }; AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts); @@ -399,35 +423,36 @@ av_expr_free(b->params[i].e); } -#if CONFIG_BLEND_FILTER - static int config_output(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; AVFilterLink *toplink = ctx->inputs[TOP]; - AVFilterLink *bottomlink = ctx->inputs[BOTTOM]; BlendContext *b = ctx->priv; const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(toplink->format); - int ret; + int ret, plane, is_16bit; - if (toplink->format != bottomlink->format) { - av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); - return AVERROR(EINVAL); - } - if (toplink->w != bottomlink->w || - toplink->h != bottomlink->h || - toplink->sample_aspect_ratio.num != bottomlink->sample_aspect_ratio.num || - toplink->sample_aspect_ratio.den != bottomlink->sample_aspect_ratio.den) { - av_log(ctx, AV_LOG_ERROR, "First input link %s parameters " - "(size %dx%d, SAR %d:%d) do not match the corresponding " - "second input link %s parameters (%dx%d, SAR %d:%d)\n", - ctx->input_pads[TOP].name, toplink->w, toplink->h, - toplink->sample_aspect_ratio.num, - toplink->sample_aspect_ratio.den, - ctx->input_pads[BOTTOM].name, bottomlink->w, bottomlink->h, - bottomlink->sample_aspect_ratio.num, - bottomlink->sample_aspect_ratio.den); - return AVERROR(EINVAL); + if (!b->tblend) { + AVFilterLink *bottomlink = ctx->inputs[BOTTOM]; + + if (toplink->format != bottomlink->format) { + av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); + return AVERROR(EINVAL); + } + if (toplink->w != bottomlink->w || + toplink->h != bottomlink->h || + toplink->sample_aspect_ratio.num != bottomlink->sample_aspect_ratio.num || + toplink->sample_aspect_ratio.den != bottomlink->sample_aspect_ratio.den) { + av_log(ctx, AV_LOG_ERROR, "First input link %s parameters " + "(size %dx%d, SAR %d:%d) do not match the corresponding " + "second input link %s parameters (%dx%d, SAR %d:%d)\n", + ctx->input_pads[TOP].name, toplink->w, toplink->h, + toplink->sample_aspect_ratio.num, + toplink->sample_aspect_ratio.den, + ctx->input_pads[BOTTOM].name, bottomlink->w, bottomlink->h, + bottomlink->sample_aspect_ratio.num, + bottomlink->sample_aspect_ratio.den); + return AVERROR(EINVAL); + } } outlink->w = toplink->w; @@ -438,14 +463,73 @@ b->hsub = pix_desc->log2_chroma_w; b->vsub = pix_desc->log2_chroma_h; + + is_16bit = pix_desc->comp[0].depth_minus1 == 15; b->nb_planes = av_pix_fmt_count_planes(toplink->format); - if ((ret = ff_dualinput_init(ctx, &b->dinput)) < 0) - return ret; + if (b->tblend) + outlink->flags |= FF_LINK_FLAG_REQUEST_LOOP; + else if ((ret = ff_dualinput_init(ctx, &b->dinput)) < 0) + return ret; + + for (plane = 0; plane < FF_ARRAY_ELEMS(b->params); plane++) { + FilterParams *param = &b->params[plane]; + + if (b->all_mode >= 0) + param->mode = b->all_mode; + if (b->all_opacity < 1) + param->opacity = b->all_opacity; + + switch (param->mode) { + case BLEND_ADDITION: param->blend = is_16bit ? blend_addition_16bit : blend_addition_8bit; break; + case BLEND_AND: param->blend = is_16bit ? blend_and_16bit : blend_and_8bit; break; + case BLEND_AVERAGE: param->blend = is_16bit ? blend_average_16bit : blend_average_8bit; break; + case BLEND_BURN: param->blend = is_16bit ? blend_burn_16bit : blend_burn_8bit; break; + case BLEND_DARKEN: param->blend = is_16bit ? blend_darken_16bit : blend_darken_8bit; break; + case BLEND_DIFFERENCE: param->blend = is_16bit ? blend_difference_16bit : blend_difference_8bit; break; + case BLEND_DIFFERENCE128: param->blend = is_16bit ? blend_difference128_16bit: blend_difference128_8bit; break; + case BLEND_DIVIDE: param->blend = is_16bit ? blend_divide_16bit : blend_divide_8bit; break; + case BLEND_DODGE: param->blend = is_16bit ? blend_dodge_16bit : blend_dodge_8bit; break; + case BLEND_EXCLUSION: param->blend = is_16bit ? blend_exclusion_16bit : blend_exclusion_8bit; break; + case BLEND_GLOW: param->blend = is_16bit ? blend_glow_16bit : blend_glow_8bit; break; + case BLEND_HARDLIGHT: param->blend = is_16bit ? blend_hardlight_16bit : blend_hardlight_8bit; break; + case BLEND_HARDMIX: param->blend = is_16bit ? blend_hardmix_16bit : blend_hardmix_8bit; break; + case BLEND_LIGHTEN: param->blend = is_16bit ? blend_lighten_16bit : blend_lighten_8bit; break; + case BLEND_LINEARLIGHT:param->blend = is_16bit ? blend_linearlight_16bit: blend_linearlight_8bit;break; + case BLEND_MULTIPLY: param->blend = is_16bit ? blend_multiply_16bit : blend_multiply_8bit; break; + case BLEND_NEGATION: param->blend = is_16bit ? blend_negation_16bit : blend_negation_8bit; break; + case BLEND_NORMAL: param->blend = blend_normal; break; + case BLEND_OR: param->blend = is_16bit ? blend_or_16bit : blend_or_8bit; break; + case BLEND_OVERLAY: param->blend = is_16bit ? blend_overlay_16bit : blend_overlay_8bit; break; + case BLEND_PHOENIX: param->blend = is_16bit ? blend_phoenix_16bit : blend_phoenix_8bit; break; + case BLEND_PINLIGHT: param->blend = is_16bit ? blend_pinlight_16bit : blend_pinlight_8bit; break; + case BLEND_REFLECT: param->blend = is_16bit ? blend_reflect_16bit : blend_reflect_8bit; break; + case BLEND_SCREEN: param->blend = is_16bit ? blend_screen_16bit : blend_screen_8bit; break; + case BLEND_SOFTLIGHT: param->blend = is_16bit ? blend_softlight_16bit : blend_softlight_8bit; break; + case BLEND_SUBTRACT: param->blend = is_16bit ? blend_subtract_16bit : blend_subtract_8bit; break; + case BLEND_VIVIDLIGHT: param->blend = is_16bit ? blend_vividlight_16bit : blend_vividlight_8bit; break; + case BLEND_XOR: param->blend = is_16bit ? blend_xor_16bit : blend_xor_8bit; break; + } + + if (b->all_expr && !param->expr_str) { + param->expr_str = av_strdup(b->all_expr); + if (!param->expr_str) + return AVERROR(ENOMEM); + } + if (param->expr_str) { + ret = av_expr_parse(¶m->e, param->expr_str, var_names, + NULL, NULL, NULL, NULL, 0, ctx); + if (ret < 0) + return ret; + param->blend = is_16bit? blend_expr_16bit : blend_expr_8bit; + } + } return 0; } +#if CONFIG_BLEND_FILTER + static int request_frame(AVFilterLink *outlink) { BlendContext *b = outlink->src->priv; @@ -498,21 +582,6 @@ #if CONFIG_TBLEND_FILTER -static int tblend_config_output(AVFilterLink *outlink) -{ - AVFilterContext *ctx = outlink->src; - AVFilterLink *inlink = ctx->inputs[0]; - BlendContext *b = ctx->priv; - const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format); - - b->hsub = pix_desc->log2_chroma_w; - b->vsub = pix_desc->log2_chroma_h; - b->nb_planes = av_pix_fmt_count_planes(inlink->format); - outlink->flags |= FF_LINK_FLAG_REQUEST_LOOP; - - return 0; -} - static int tblend_filter_frame(AVFilterLink *inlink, AVFrame *frame) { BlendContext *b = inlink->dst->priv; @@ -548,7 +617,7 @@ { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .config_props = tblend_config_output, + .config_props = config_output, }, { NULL } }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_colorkey.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_colorkey.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_colorkey.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_colorkey.c 2015-06-14 17:20:02.000000000 +0000 @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2015 Timo Rothenpieler + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/opt.h" +#include "libavutil/imgutils.h" +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "video.h" + +typedef struct ColorkeyContext { + const AVClass *class; + + /* color offsets rgba */ + int co[4]; + + uint8_t colorkey_rgba[4]; + float similarity; + float blend; +} ColorkeyContext; + +static uint8_t do_colorkey_pixel(ColorkeyContext *ctx, uint8_t r, uint8_t g, uint8_t b) +{ + int dr = (int)r - ctx->colorkey_rgba[0]; + int dg = (int)g - ctx->colorkey_rgba[1]; + int db = (int)b - ctx->colorkey_rgba[2]; + + double diff = sqrt((dr * dr + dg * dg + db * db) / (255.0 * 255.0)); + + if (ctx->blend > 0.0001) { + return av_clipd((diff - ctx->similarity) / ctx->blend, 0.0, 1.0) * 255.0; + } else { + return (diff > ctx->similarity) ? 255 : 0; + } +} + +static int do_colorkey_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs) +{ + AVFrame *frame = arg; + + const int slice_start = (frame->height * jobnr) / nb_jobs; + const int slice_end = (frame->height * (jobnr + 1)) / nb_jobs; + + ColorkeyContext *ctx = avctx->priv; + + int o, x, y; + + for (y = slice_start; y < slice_end; ++y) { + for (x = 0; x < frame->width; ++x) { + o = frame->linesize[0] * y + x * 4; + + frame->data[0][o + ctx->co[3]] = + do_colorkey_pixel(ctx, + frame->data[0][o + ctx->co[0]], + frame->data[0][o + ctx->co[1]], + frame->data[0][o + ctx->co[2]]); + } + } + + return 0; +} + +static int filter_frame(AVFilterLink *link, AVFrame *frame) +{ + AVFilterContext *avctx = link->dst; + int res; + + if (res = av_frame_make_writable(frame)) + return res; + + if (res = avctx->internal->execute(avctx, do_colorkey_slice, frame, NULL, FFMIN(frame->height, avctx->graph->nb_threads))) + return res; + + return ff_filter_frame(avctx->outputs[0], frame); +} + +static av_cold int config_output(AVFilterLink *outlink) +{ + AVFilterContext *avctx = outlink->src; + ColorkeyContext *ctx = avctx->priv; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format); + int i; + + outlink->w = avctx->inputs[0]->w; + outlink->h = avctx->inputs[0]->h; + outlink->time_base = avctx->inputs[0]->time_base; + + for (i = 0; i < 4; ++i) + ctx->co[i] = desc->comp[i].offset_plus1 - 1; + + return 0; +} + +static av_cold int query_formats(AVFilterContext *avctx) +{ + static const enum AVPixelFormat pixel_fmts[] = { + AV_PIX_FMT_ARGB, + AV_PIX_FMT_RGBA, + AV_PIX_FMT_ABGR, + AV_PIX_FMT_BGRA, + AV_PIX_FMT_NONE + }; + + AVFilterFormats *formats = NULL; + + formats = ff_make_format_list(pixel_fmts); + if (!formats) + return AVERROR(ENOMEM); + + return ff_set_common_formats(avctx, formats); +} + +static const AVFilterPad colorkey_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = filter_frame, + }, + { NULL } +}; + +static const AVFilterPad colorkey_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_output, + }, + { NULL } +}; + +#define OFFSET(x) offsetof(ColorkeyContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM + +static const AVOption colorkey_options[] = { + { "color", "set the colorkey key color", OFFSET(colorkey_rgba), AV_OPT_TYPE_COLOR, { .str = "black" }, CHAR_MIN, CHAR_MAX, FLAGS }, + { "similarity", "set the colorkey similarity value", OFFSET(similarity), AV_OPT_TYPE_FLOAT, { .dbl = 0.01 }, 0.01, 1.0, FLAGS }, + { "blend", "set the colorkey key blend value", OFFSET(blend), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, 0.0, 1.0, FLAGS }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(colorkey); + +AVFilter ff_vf_colorkey = { + .name = "colorkey", + .description = NULL_IF_CONFIG_SMALL("colorkey filter"), + .priv_size = sizeof(ColorkeyContext), + .priv_class = &colorkey_class, + .query_formats = query_formats, + .inputs = colorkey_inputs, + .outputs = colorkey_outputs, + .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_colormatrix.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_colormatrix.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_colormatrix.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_colormatrix.c 2015-07-08 17:20:04.000000000 +0000 @@ -230,6 +230,53 @@ return 0; } +static int process_slice_yuv444p(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) +{ + const ThreadData *td = arg; + const AVFrame *src = td->src; + AVFrame *dst = td->dst; + const int height = src->height; + const int width = src->width; + const int slice_start = (height * jobnr ) / nb_jobs; + const int slice_end = (height * (jobnr+1)) / nb_jobs; + const int src_pitchY = src->linesize[0]; + const int src_pitchUV = src->linesize[1]; + const unsigned char *srcpU = src->data[1] + slice_start * src_pitchUV; + const unsigned char *srcpV = src->data[2] + slice_start * src_pitchUV; + const unsigned char *srcpY = src->data[0] + slice_start * src_pitchY; + const int dst_pitchY = dst->linesize[0]; + const int dst_pitchUV = dst->linesize[1]; + unsigned char *dstpU = dst->data[1] + slice_start * dst_pitchUV; + unsigned char *dstpV = dst->data[2] + slice_start * dst_pitchUV; + unsigned char *dstpY = dst->data[0] + slice_start * dst_pitchY; + const int c2 = td->c2; + const int c3 = td->c3; + const int c4 = td->c4; + const int c5 = td->c5; + const int c6 = td->c6; + const int c7 = td->c7; + int x, y; + + for (y = slice_start; y < slice_end; y++) { + for (x = 0; x < width; x++) { + const int u = srcpU[x] - 128; + const int v = srcpV[x] - 128; + const int uvval = c2 * u + c3 * v + 1081344; + dstpY[x] = CB((65536 * (srcpY[x] - 16) + uvval) >> 16); + dstpU[x] = CB((c4 * u + c5 * v + 8421376) >> 16); + dstpV[x] = CB((c6 * u + c7 * v + 8421376) >> 16); + } + srcpY += src_pitchY; + dstpY += dst_pitchY; + srcpU += src_pitchUV; + srcpV += src_pitchUV; + dstpU += dst_pitchUV; + dstpV += dst_pitchUV; + } + + return 0; +} + static int process_slice_yuv422p(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) { const ThreadData *td = arg; @@ -350,6 +397,7 @@ static int query_formats(AVFilterContext *ctx) { static const enum AVPixelFormat pix_fmts[] = { + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_UYVY422, @@ -411,7 +459,10 @@ td.c6 = color->yuv_convert[color->mode][2][1]; td.c7 = color->yuv_convert[color->mode][2][2]; - if (in->format == AV_PIX_FMT_YUV422P) + if (in->format == AV_PIX_FMT_YUV444P) + ctx->internal->execute(ctx, process_slice_yuv444p, &td, NULL, + FFMIN(in->height, ctx->graph->nb_threads)); + else if (in->format == AV_PIX_FMT_YUV422P) ctx->internal->execute(ctx, process_slice_yuv422p, &td, NULL, FFMIN(in->height, ctx->graph->nb_threads)); else if (in->format == AV_PIX_FMT_YUV420P) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_cover_rect.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_cover_rect.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_cover_rect.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_cover_rect.c 2015-07-03 17:20:03.000000000 +0000 @@ -53,13 +53,7 @@ { NULL } }; -static const AVClass cover_rect_class = { - .class_name = "cover_rect", - .item_name = av_default_item_name, - .option = cover_rect_options, - .version = LIBAVUTIL_VERSION_INT, - .category = AV_CLASS_CATEGORY_FILTER, -}; +AVFILTER_DEFINE_CLASS(cover_rect); static int query_formats(AVFilterContext *ctx) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_crop.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_crop.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_crop.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_crop.c 2015-07-22 17:20:04.000000000 +0000 @@ -296,6 +296,42 @@ return ff_filter_frame(link->dst->outputs[0], frame); } +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, + char *res, int res_len, int flags) +{ + CropContext *s = ctx->priv; + int ret; + + if ( !strcmp(cmd, "out_w") || !strcmp(cmd, "w") + || !strcmp(cmd, "out_h") || !strcmp(cmd, "h") + || !strcmp(cmd, "x") || !strcmp(cmd, "y")) { + + int old_x = s->x; + int old_y = s->y; + int old_w = s->w; + int old_h = s->h; + + AVFilterLink *outlink = ctx->outputs[0]; + AVFilterLink *inlink = ctx->inputs[0]; + + av_opt_set(s, cmd, args, 0); + + if ((ret = config_input(inlink)) < 0) { + s->x = old_x; + s->y = old_y; + s->w = old_w; + s->h = old_h; + return ret; + } + + ret = config_output(outlink); + + } else + ret = AVERROR(ENOSYS); + + return ret; +} + #define OFFSET(x) offsetof(CropContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM @@ -332,12 +368,13 @@ }; AVFilter ff_vf_crop = { - .name = "crop", - .description = NULL_IF_CONFIG_SMALL("Crop the input video."), - .priv_size = sizeof(CropContext), - .priv_class = &crop_class, - .query_formats = query_formats, - .uninit = uninit, - .inputs = avfilter_vf_crop_inputs, - .outputs = avfilter_vf_crop_outputs, + .name = "crop", + .description = NULL_IF_CONFIG_SMALL("Crop the input video."), + .priv_size = sizeof(CropContext), + .priv_class = &crop_class, + .query_formats = query_formats, + .uninit = uninit, + .inputs = avfilter_vf_crop_inputs, + .outputs = avfilter_vf_crop_outputs, + .process_command = process_command, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_deband.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_deband.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_deband.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_deband.c 2015-08-02 17:20:02.000000000 +0000 @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2015 Niklas Haas + * Copyright (c) 2015 Paul B Mahol + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "avfilter.h" +#include "internal.h" +#include "video.h" + +typedef struct DebandContext { + const AVClass *class; + + float threshold[4]; + int range; + int blur; + float direction; + + int nb_components; + int planewidth[4]; + int planeheight[4]; + int thr[4]; + + int *x_pos; + int *y_pos; + + int (*deband)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); +} DebandContext; + +#define OFFSET(x) offsetof(DebandContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM + +static const AVOption deband_options[] = { + { "1thr", "set 1st plane threshold", OFFSET(threshold[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0.00003, 0.5, FLAGS }, + { "2thr", "set 2nd plane threshold", OFFSET(threshold[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0.00003, 0.5, FLAGS }, + { "3thr", "set 3rd plane threshold", OFFSET(threshold[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0.00003, 0.5, FLAGS }, + { "4thr", "set 4th plane threshold", OFFSET(threshold[3]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0.00003, 0.5, FLAGS }, + { "range", "set range", OFFSET(range), AV_OPT_TYPE_INT, {.i64=16}, INT_MIN, INT_MAX, FLAGS }, + { "r", "set range", OFFSET(range), AV_OPT_TYPE_INT, {.i64=16}, INT_MIN, INT_MAX, FLAGS }, + { "direction", "set direction", OFFSET(direction), AV_OPT_TYPE_FLOAT, {.dbl=2*M_PI},-2*M_PI, 2*M_PI, FLAGS }, + { "d", "set direction", OFFSET(direction), AV_OPT_TYPE_FLOAT, {.dbl=2*M_PI},-2*M_PI, 2*M_PI, FLAGS }, + { "blur", "enable blur", OFFSET(blur), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(deband); + +static int query_formats(AVFilterContext *ctx) +{ + static const enum AVPixelFormat pix_fmts[] = { + AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16, + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, + AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV440P, + AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P, + AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUVJ440P, + AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P, + AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9, + AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA444P9, + AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10, + AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12, + AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14, + AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, + AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, + AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, + AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRAP16, + AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16, + AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16, + AV_PIX_FMT_NONE + }; + AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts); + if (!fmts_list) + return AVERROR(ENOMEM); + + return ff_set_common_formats(ctx, fmts_list); +} + +static float frand(int x, int y) +{ + const float r = sinf(x * 12.9898 + y * 78.233) * 43758.545; + + return r - floorf(r); +} + +static int inline get_avg(int ref0, int ref1, int ref2, int ref3) +{ + return (ref0 + ref1 + ref2 + ref3) / 4; +} + +typedef struct ThreadData { + AVFrame *in, *out; +} ThreadData; + +static int deband_8_c(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) +{ + DebandContext *s = ctx->priv; + ThreadData *td = arg; + AVFrame *in = td->in; + AVFrame *out = td->out; + int x, y, p; + + for (p = 0; p < s->nb_components; p++) { + const uint8_t *src_ptr = (const uint8_t *)in->data[p]; + uint8_t *dst_ptr = (uint8_t *)out->data[p]; + const int dst_linesize = out->linesize[p]; + const int src_linesize = in->linesize[p]; + const int thr = s->thr[p]; + const int start = (s->planeheight[p] * jobnr ) / nb_jobs; + const int end = (s->planeheight[p] * (jobnr+1)) / nb_jobs; + const int w = s->planewidth[p] - 1; + const int h = s->planeheight[p] - 1; + + for (y = start; y < end; y++) { + const int pos = y * s->planeheight[0]; + + for (x = 0; x < s->planewidth[p]; x++) { + const int x_pos = s->x_pos[pos + x]; + const int y_pos = s->y_pos[pos + x]; + const int ref0 = src_ptr[av_clip(y + y_pos, 0, h) * src_linesize + av_clip(x + x_pos, 0, w)]; + const int ref1 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x + x_pos, 0, w)]; + const int ref2 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)]; + const int ref3 = src_ptr[av_clip(y + y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)]; + const int src0 = src_ptr[y * src_linesize + x]; + + if (s->blur) { + const int avg = get_avg(ref0, ref1, ref2, ref3); + const int diff = FFABS(src0 - avg); + + dst_ptr[y * dst_linesize + x] = diff < thr ? avg : src0; + } else { + dst_ptr[y * dst_linesize + x] = (FFABS(src0 - ref0) < thr) && + (FFABS(src0 - ref1) < thr) && + (FFABS(src0 - ref2) < thr) && + (FFABS(src0 - ref3) < thr) ? get_avg(ref0, ref1, ref2, ref3) : src0; + } + } + } + } + + return 0; +} + +static int deband_16_c(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) +{ + DebandContext *s = ctx->priv; + ThreadData *td = arg; + AVFrame *in = td->in; + AVFrame *out = td->out; + int x, y, p; + + for (p = 0; p < s->nb_components; p++) { + const uint16_t *src_ptr = (const uint16_t *)in->data[p]; + uint16_t *dst_ptr = (uint16_t *)out->data[p]; + const int dst_linesize = out->linesize[p] / 2; + const int src_linesize = in->linesize[p] / 2; + const int thr = s->thr[p]; + const int start = (s->planeheight[p] * jobnr ) / nb_jobs; + const int end = (s->planeheight[p] * (jobnr+1)) / nb_jobs; + const int w = s->planewidth[p] - 1; + const int h = s->planeheight[p] - 1; + + for (y = start; y < end; y++) { + const int pos = y * s->planeheight[0]; + + for (x = 0; x < s->planewidth[p]; x++) { + const int x_pos = s->x_pos[pos + x]; + const int y_pos = s->y_pos[pos + x]; + const int ref0 = src_ptr[av_clip(y + y_pos, 0, h) * src_linesize + av_clip(x + x_pos, 0, w)]; + const int ref1 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x + x_pos, 0, w)]; + const int ref2 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)]; + const int ref3 = src_ptr[av_clip(y + y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)]; + const int src0 = src_ptr[y * src_linesize + x]; + + if (s->blur) { + const int avg = get_avg(ref0, ref1, ref2, ref3); + const int diff = FFABS(src0 - avg); + + dst_ptr[y * dst_linesize + x] = diff < thr ? avg : src0; + } else { + dst_ptr[y * dst_linesize + x] = (FFABS(src0 - ref0) < thr) && + (FFABS(src0 - ref1) < thr) && + (FFABS(src0 - ref2) < thr) && + (FFABS(src0 - ref3) < thr) ? get_avg(ref0, ref1, ref2, ref3) : src0; + } + } + } + } + + return 0; +} + +static int config_input(AVFilterLink *inlink) +{ + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); + AVFilterContext *ctx = inlink->dst; + DebandContext *s = ctx->priv; + const float direction = s->direction; + const int range = s->range; + int x, y; + + s->nb_components = desc->nb_components; + + s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h); + s->planeheight[0] = s->planeheight[3] = inlink->h; + s->planewidth[1] = s->planewidth[2] = FF_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w); + s->planewidth[0] = s->planewidth[3] = inlink->w; + + s->deband = desc->comp[0].depth_minus1 > 7 ? deband_16_c : deband_8_c; + + s->thr[0] = ((1 << (desc->comp[0].depth_minus1 + 1)) - 1) * s->threshold[0]; + s->thr[1] = ((1 << (desc->comp[1].depth_minus1 + 1)) - 1) * s->threshold[1]; + s->thr[2] = ((1 << (desc->comp[2].depth_minus1 + 1)) - 1) * s->threshold[2]; + s->thr[3] = ((1 << (desc->comp[3].depth_minus1 + 1)) - 1) * s->threshold[3]; + + s->x_pos = av_malloc(s->planewidth[0] * s->planeheight[0] * sizeof(*s->x_pos)); + s->y_pos = av_malloc(s->planewidth[0] * s->planeheight[0] * sizeof(*s->y_pos)); + if (!s->x_pos || !s->y_pos) + return AVERROR(ENOMEM); + + for (y = 0; y < s->planeheight[0]; y++) { + for (x = 0; x < s->planewidth[0]; x++) { + const float r = frand(x, y); + const float dir = direction < 0 ? -direction : r * direction; + const int dist = range < 0 ? -range : r * range; + + s->x_pos[y * s->planeheight[0] + x] = cosf(dir) * dist; + s->y_pos[y * s->planeheight[0] + x] = sinf(dir) * dist; + } + } + + return 0; +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ + AVFilterContext *ctx = inlink->dst; + AVFilterLink *outlink = ctx->outputs[0]; + DebandContext *s = ctx->priv; + AVFrame *out; + ThreadData td; + + out = ff_get_video_buffer(outlink, outlink->w, outlink->h); + if (!out) { + av_frame_free(&in); + return AVERROR(ENOMEM); + } + av_frame_copy_props(out, in); + + td.in = in; td.out = out; + ctx->internal->execute(ctx, s->deband, &td, NULL, FFMIN3(s->planeheight[1], + s->planeheight[2], + ctx->graph->nb_threads)); + + av_frame_free(&in); + return ff_filter_frame(outlink, out); +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + DebandContext *s = ctx->priv; + + av_freep(&s->x_pos); + av_freep(&s->y_pos); +} + +static const AVFilterPad avfilter_vf_deband_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_input, + .filter_frame = filter_frame, + }, + { NULL } +}; + +static const AVFilterPad avfilter_vf_deband_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + }, + { NULL } +}; + +AVFilter ff_vf_deband = { + .name = "deband", + .description = NULL_IF_CONFIG_SMALL("Debands video."), + .priv_size = sizeof(DebandContext), + .priv_class = &deband_class, + .uninit = uninit, + .query_formats = query_formats, + .inputs = avfilter_vf_deband_inputs, + .outputs = avfilter_vf_deband_outputs, + .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_eq.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_eq.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_eq.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_eq.c 2015-07-16 17:20:02.000000000 +0000 @@ -98,7 +98,7 @@ { if (param->contrast == 1.0 && param->brightness == 0.0 && param->gamma == 1.0) param->adjust = NULL; - else if (param->gamma == 1.0) + else if (param->gamma == 1.0 && fabs(param->contrast) < 7.9) param->adjust = eq->process; else param->adjust = apply_lut; @@ -106,7 +106,7 @@ static void set_contrast(EQContext *eq) { - eq->contrast = av_clipf(av_expr_eval(eq->contrast_pexpr, eq->var_values, eq), -2.0, 2.0); + eq->contrast = av_clipf(av_expr_eval(eq->contrast_pexpr, eq->var_values, eq), -1000.0, 1000.0); eq->param[0].contrast = eq->contrast; eq->param[0].lut_clean = 0; check_values(&eq->param[0], eq); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_extractplanes.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_extractplanes.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_extractplanes.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_extractplanes.c 2015-07-02 17:20:03.000000000 +0000 @@ -39,7 +39,7 @@ int requested_planes; int map[4]; int linesize[4]; - int is_packed_rgb; + int is_packed; int depth; int step; } ExtractPlanesContext; @@ -70,6 +70,7 @@ AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P, + AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUV420P16LE, AV_PIX_FMT_YUVA420P16LE, AV_PIX_FMT_YUV420P16BE, AV_PIX_FMT_YUVA420P16BE, @@ -78,6 +79,7 @@ AV_PIX_FMT_YUV444P16LE, AV_PIX_FMT_YUVA444P16LE, AV_PIX_FMT_YUV444P16BE, AV_PIX_FMT_YUVA444P16BE, AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY8A, + AV_PIX_FMT_YA16LE, AV_PIX_FMT_YA16BE, AV_PIX_FMT_GRAY16LE, AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24, AV_PIX_FMT_RGBA, AV_PIX_FMT_BGRA, @@ -152,7 +154,8 @@ s->depth = (desc->comp[0].depth_minus1 + 1) >> 3; s->step = av_get_padded_bits_per_pixel(desc) >> 3; - s->is_packed_rgb = !(desc->flags & AV_PIX_FMT_FLAG_PLANAR); + s->is_packed = !(desc->flags & AV_PIX_FMT_FLAG_PLANAR) && + (desc->nb_components > 1); if (desc->flags & AV_PIX_FMT_FLAG_RGB) { ff_fill_rgba_map(rgba_map, inlink->format); for (i = 0; i < 4; i++) @@ -224,7 +227,7 @@ } av_frame_copy_props(out, frame); - if (s->is_packed_rgb) { + if (s->is_packed) { extract_from_packed(out->data[0], out->linesize[0], frame->data[0], frame->linesize[0], outlink->w, outlink->h, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_find_rect.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_find_rect.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_find_rect.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_find_rect.c 2015-07-03 17:20:03.000000000 +0000 @@ -45,7 +45,7 @@ #define OFFSET(x) offsetof(FOCContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM -static const AVOption foc_options[] = { +static const AVOption find_rect_options[] = { { "object", "object bitmap filename", OFFSET(obj_filename), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = FLAGS }, { "threshold", "set threshold", OFFSET(threshold), AV_OPT_TYPE_FLOAT, {.dbl = 0.5}, 0, 1.0, FLAGS }, { "mipmaps", "set mipmaps", OFFSET(mipmaps), AV_OPT_TYPE_INT, {.i64 = 3}, 1, MAX_MIPMAPS, FLAGS }, @@ -56,13 +56,7 @@ { NULL } }; -static const AVClass foc_class = { - .class_name = "find_rect", - .item_name = av_default_item_name, - .option = foc_options, - .version = LIBAVUTIL_VERSION_INT, - .category = AV_CLASS_CATEGORY_FILTER, -}; +AVFILTER_DEFINE_CLASS(find_rect); static int query_formats(AVFilterContext *ctx) { @@ -307,5 +301,5 @@ .query_formats = query_formats, .inputs = foc_inputs, .outputs = foc_outputs, - .priv_class = &foc_class, + .priv_class = &find_rect_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_framepack.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_framepack.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_framepack.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_framepack.c 2015-07-03 17:20:03.000000000 +0000 @@ -315,7 +315,7 @@ #define OFFSET(x) offsetof(FramepackContext, x) #define V AV_OPT_FLAG_VIDEO_PARAM -static const AVOption options[] = { +static const AVOption framepack_options[] = { { "format", "Frame pack output format", OFFSET(format), AV_OPT_TYPE_INT, { .i64 = AV_STEREO3D_SIDEBYSIDE }, 0, INT_MAX, .flags = V, .unit = "format" }, { "sbs", "Views are packed next to each other", 0, AV_OPT_TYPE_CONST, @@ -331,12 +331,7 @@ { NULL }, }; -static const AVClass framepack_class = { - .class_name = "framepack", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; +AVFILTER_DEFINE_CLASS(framepack); static const AVFilterPad framepack_inputs[] = { { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_geq.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_geq.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_geq.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_geq.c 2015-06-14 17:20:02.000000000 +0000 @@ -26,6 +26,7 @@ * ported by Clément BÅ“sch for FFmpeg. */ +#include "libavutil/avassert.h" #include "libavutil/avstring.h" #include "libavutil/eval.h" #include "libavutil/opt.h" @@ -192,6 +193,8 @@ GEQContext *geq = inlink->dst->priv; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); + av_assert0(desc); + geq->hsub = desc->log2_chroma_w; geq->vsub = desc->log2_chroma_h; geq->planes = desc->nb_components; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_lut3d.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_lut3d.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_lut3d.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_lut3d.c 2015-06-14 17:20:02.000000000 +0000 @@ -707,6 +707,8 @@ LUT3DContext *lut3d = ctx->priv; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); + av_assert0(desc); + lut3d->clut_is16bit = 0; switch (inlink->format) { case AV_PIX_FMT_RGB48: diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_lut.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_lut.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_lut.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_lut.c 2015-07-03 17:20:03.000000000 +0000 @@ -25,6 +25,7 @@ */ #include "libavutil/attributes.h" +#include "libavutil/bswap.h" #include "libavutil/common.h" #include "libavutil/eval.h" #include "libavutil/opt.h" @@ -59,12 +60,13 @@ typedef struct LutContext { const AVClass *class; - uint8_t lut[4][256]; ///< lookup table for each component + uint16_t lut[4][256 * 256]; ///< lookup table for each component char *comp_expr_str[4]; AVExpr *comp_expr[4]; int hsub, vsub; double var_values[VAR_VARS_NB]; int is_rgb, is_yuv; + int is_16bit; int step; int negate_alpha; /* only used by negate */ } LutContext; @@ -112,7 +114,13 @@ AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV440P, \ AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P, \ AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P, \ - AV_PIX_FMT_YUVJ440P + AV_PIX_FMT_YUVJ440P, \ + AV_PIX_FMT_YUV444P9LE, AV_PIX_FMT_YUV422P9LE, AV_PIX_FMT_YUV420P9LE, \ + AV_PIX_FMT_YUV444P10LE, AV_PIX_FMT_YUV422P10LE, AV_PIX_FMT_YUV420P10LE, AV_PIX_FMT_YUV440P10LE, \ + AV_PIX_FMT_YUV444P12LE, AV_PIX_FMT_YUV422P12LE, AV_PIX_FMT_YUV420P12LE, AV_PIX_FMT_YUV440P12LE, \ + AV_PIX_FMT_YUV444P14LE, AV_PIX_FMT_YUV422P14LE, AV_PIX_FMT_YUV420P14LE, \ + AV_PIX_FMT_YUV444P16LE, AV_PIX_FMT_YUV422P16LE, AV_PIX_FMT_YUV420P16LE, \ + AV_PIX_FMT_YUVA444P16LE, AV_PIX_FMT_YUVA422P16LE, AV_PIX_FMT_YUVA420P16LE #define RGB_FORMATS \ AV_PIX_FMT_ARGB, AV_PIX_FMT_RGBA, \ @@ -205,6 +213,7 @@ s->var_values[VAR_W] = inlink->w; s->var_values[VAR_H] = inlink->h; + s->is_16bit = desc->comp[0].depth_minus1 > 7; switch (inlink->format) { case AV_PIX_FMT_YUV410P: @@ -216,10 +225,40 @@ case AV_PIX_FMT_YUVA420P: case AV_PIX_FMT_YUVA422P: case AV_PIX_FMT_YUVA444P: - min[Y] = min[U] = min[V] = 16; - max[Y] = 235; - max[U] = max[V] = 240; - min[A] = 0; max[A] = 255; + case AV_PIX_FMT_YUV420P9LE: + case AV_PIX_FMT_YUV422P9LE: + case AV_PIX_FMT_YUV444P9LE: + case AV_PIX_FMT_YUVA420P9LE: + case AV_PIX_FMT_YUVA422P9LE: + case AV_PIX_FMT_YUVA444P9LE: + case AV_PIX_FMT_YUV420P10LE: + case AV_PIX_FMT_YUV422P10LE: + case AV_PIX_FMT_YUV440P10LE: + case AV_PIX_FMT_YUV444P10LE: + case AV_PIX_FMT_YUVA420P10LE: + case AV_PIX_FMT_YUVA422P10LE: + case AV_PIX_FMT_YUVA444P10LE: + case AV_PIX_FMT_YUV420P12LE: + case AV_PIX_FMT_YUV422P12LE: + case AV_PIX_FMT_YUV440P12LE: + case AV_PIX_FMT_YUV444P12LE: + case AV_PIX_FMT_YUV420P14LE: + case AV_PIX_FMT_YUV422P14LE: + case AV_PIX_FMT_YUV444P14LE: + case AV_PIX_FMT_YUV420P16LE: + case AV_PIX_FMT_YUV422P16LE: + case AV_PIX_FMT_YUV444P16LE: + case AV_PIX_FMT_YUVA420P16LE: + case AV_PIX_FMT_YUVA422P16LE: + case AV_PIX_FMT_YUVA444P16LE: + min[Y] = 16 * (1 << (desc->comp[0].depth_minus1 - 7)); + min[U] = 16 * (1 << (desc->comp[1].depth_minus1 - 7)); + min[V] = 16 * (1 << (desc->comp[2].depth_minus1 - 7)); + min[A] = 0; + max[Y] = 235 * (1 << (desc->comp[0].depth_minus1 - 7)); + max[U] = 240 * (1 << (desc->comp[1].depth_minus1 - 7)); + max[V] = 240 * (1 << (desc->comp[2].depth_minus1 - 7)); + max[A] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1; break; default: min[0] = min[1] = min[2] = min[3] = 0; @@ -255,7 +294,7 @@ s->var_values[VAR_MAXVAL] = max[color]; s->var_values[VAR_MINVAL] = min[color]; - for (val = 0; val < 256; val++) { + for (val = 0; val < (1 << (desc->comp[0].depth_minus1 + 1)); val++) { s->var_values[VAR_VAL] = val; s->var_values[VAR_CLIPVAL] = av_clip(val, min[color], max[color]); s->var_values[VAR_NEGVAL] = @@ -283,7 +322,6 @@ LutContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out; - uint8_t *inrow, *outrow, *inrow0, *outrow0; int i, j, plane, direct = 0; if (av_frame_is_writable(in)) { @@ -300,9 +338,10 @@ if (s->is_rgb) { /* packed */ + uint8_t *inrow, *outrow, *inrow0, *outrow0; const int w = inlink->w; const int h = in->height; - const uint8_t (*tab)[256] = (const uint8_t (*)[256])s->lut; + const uint16_t (*tab)[256*256] = (const uint16_t (*)[256*256])s->lut; const int in_linesize = in->linesize[0]; const int out_linesize = out->linesize[0]; const int step = s->step; @@ -326,14 +365,44 @@ inrow0 += in_linesize; outrow0 += out_linesize; } + } else if (s->is_16bit) { + // planar yuv >8 bit depth + uint16_t *inrow, *outrow; + + for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane]; plane++) { + int vsub = plane == 1 || plane == 2 ? s->vsub : 0; + int hsub = plane == 1 || plane == 2 ? s->hsub : 0; + int h = FF_CEIL_RSHIFT(inlink->h, vsub); + int w = FF_CEIL_RSHIFT(inlink->w, hsub); + const uint16_t *tab = s->lut[plane]; + const int in_linesize = in->linesize[plane] / 2; + const int out_linesize = out->linesize[plane] / 2; + + inrow = (uint16_t *)in ->data[plane]; + outrow = (uint16_t *)out->data[plane]; + + for (i = 0; i < h; i++) { + for (j = 0; j < w; j++) { +#if HAVE_BIGENDIAN + outrow[j] = av_bswap16(tab[av_bswap16(inrow[j])]); +#else + outrow[j] = tab[inrow[j]]; +#endif + } + inrow += in_linesize; + outrow += out_linesize; + } + } } else { - /* planar */ + /* planar 8bit depth */ + uint8_t *inrow, *outrow; + for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane]; plane++) { int vsub = plane == 1 || plane == 2 ? s->vsub : 0; int hsub = plane == 1 || plane == 2 ? s->hsub : 0; int h = FF_CEIL_RSHIFT(inlink->h, vsub); int w = FF_CEIL_RSHIFT(inlink->w, hsub); - const uint8_t *tab = s->lut[plane]; + const uint16_t *tab = s->lut[plane]; const int in_linesize = in->linesize[plane]; const int out_linesize = out->linesize[plane]; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_mcdeint.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_mcdeint.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_mcdeint.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_mcdeint.c 2015-07-28 17:20:07.000000000 +0000 @@ -120,7 +120,7 @@ enc_ctx->gop_size = INT_MAX; enc_ctx->max_b_frames = 0; enc_ctx->pix_fmt = AV_PIX_FMT_YUV420P; - enc_ctx->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_LOW_DELAY; + enc_ctx->flags = AV_CODEC_FLAG_QSCALE | CODEC_FLAG_LOW_DELAY; enc_ctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; enc_ctx->global_quality = 1; enc_ctx->me_cmp = enc_ctx->me_sub_cmp = FF_CMP_SAD; @@ -134,10 +134,10 @@ case MODE_SLOW: enc_ctx->me_method = ME_ITER; case MODE_MEDIUM: - enc_ctx->flags |= CODEC_FLAG_4MV; + enc_ctx->flags |= AV_CODEC_FLAG_4MV; enc_ctx->dia_size = 2; case MODE_FAST: - enc_ctx->flags |= CODEC_FLAG_QPEL; + enc_ctx->flags |= AV_CODEC_FLAG_QPEL; } ret = avcodec_open2(enc_ctx, enc, &opts); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_mpdecimate.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_mpdecimate.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_mpdecimate.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_mpdecimate.c 2015-07-03 17:20:03.000000000 +0000 @@ -168,9 +168,6 @@ AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVA420P, - AV_PIX_FMT_GRAY8A, - AV_PIX_FMT_YA8, - AV_PIX_FMT_GBRP, AV_PIX_FMT_YUVA444P, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_neighbor.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_neighbor.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_neighbor.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_neighbor.c 2015-07-16 17:20:02.000000000 +0000 @@ -0,0 +1,324 @@ +/* + * Copyright (c) 2012-2013 Oka Motofumi (chikuzen.mo at gmail dot com) + * Copyright (c) 2015 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/imgutils.h" +#include "libavutil/pixdesc.h" +#include "libavutil/opt.h" +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "video.h" + +typedef struct NContext { + const AVClass *class; + int planeheight[4]; + int planewidth[4]; + int nb_planes; + int threshold[4]; + int coordinates; + uint8_t *buffer; + + void (*filter)(uint8_t *dst, const uint8_t *p1, int width, + int threshold, const uint8_t *coordinates[], int coord); +} NContext; + +static int query_formats(AVFilterContext *ctx) +{ + static const enum AVPixelFormat pix_fmts[] = { + AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA420P, + AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ422P,AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ411P, + AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, + AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE + }; + + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); + return 0; +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + NContext *s = ctx->priv; + + av_freep(&s->buffer); +} + +static inline void line_copy8(uint8_t *line, const uint8_t *srcp, int width, int mergin) +{ + int i; + + memcpy(line, srcp, width); + + for (i = mergin; i > 0; i--) { + line[-i] = line[i]; + line[width - 1 + i] = line[width - 1 - i]; + } +} + +static void erosion(uint8_t *dst, const uint8_t *p1, int width, + int threshold, const uint8_t *coordinates[], int coord) +{ + int x, i; + + for (x = 0; x < width; x++) { + int min = p1[x]; + int limit = FFMAX(min - threshold, 0); + + for (i = 0; i < 8; i++) { + if (coord & (1 << i)) { + min = FFMIN(min, *(coordinates[i] + x)); + } + min = FFMAX(min, limit); + } + + dst[x] = min; + } +} + +static void dilation(uint8_t *dst, const uint8_t *p1, int width, + int threshold, const uint8_t *coordinates[], int coord) +{ + int x, i; + + for (x = 0; x < width; x++) { + int max = p1[x]; + int limit = FFMIN(max + threshold, 255); + + for (i = 0; i < 8; i++) { + if (coord & (1 << i)) { + max = FFMAX(max, *(coordinates[i] + x)); + } + max = FFMIN(max, limit); + } + + dst[x] = max; + } +} + +static void deflate(uint8_t *dst, const uint8_t *p1, int width, + int threshold, const uint8_t *coordinates[], int coord) +{ + int x, i; + + for (x = 0; x < width; x++) { + int sum = 0; + int limit = FFMAX(p1[x] - threshold, 0); + + for (i = 0; i < 8; sum += *(coordinates[i++] + x)); + + dst[x] = FFMAX(FFMIN(sum / 8, p1[x]), limit); + } +} + +static void inflate(uint8_t *dst, const uint8_t *p1, int width, + int threshold, const uint8_t *coordinates[], int coord) +{ + int x, i; + + for (x = 0; x < width; x++) { + int sum = 0; + int limit = FFMIN(p1[x] + threshold, 255); + + for (i = 0; i < 8; sum += *(coordinates[i++] + x)); + + dst[x] = FFMIN(FFMAX(sum / 8, p1[x]), limit); + } +} + +static int config_input(AVFilterLink *inlink) +{ + AVFilterContext *ctx = inlink->dst; + NContext *s = ctx->priv; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); + int ret; + + if ((ret = av_image_fill_linesizes(s->planewidth, inlink->format, inlink->w)) < 0) + return ret; + + s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h); + s->planeheight[0] = s->planeheight[3] = inlink->h; + + s->nb_planes = av_pix_fmt_count_planes(inlink->format); + s->buffer = av_malloc(3 * (s->planewidth[0] + 32)); + if (!s->buffer) + return AVERROR(ENOMEM); + + if (!strcmp(ctx->filter->name, "erosion")) + s->filter = erosion; + else if (!strcmp(ctx->filter->name, "dilation")) + s->filter = dilation; + else if (!strcmp(ctx->filter->name, "deflate")) + s->filter = deflate; + else if (!strcmp(ctx->filter->name, "inflate")) + s->filter = inflate; + + return 0; +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ + AVFilterContext *ctx = inlink->dst; + AVFilterLink *outlink = ctx->outputs[0]; + NContext *s = ctx->priv; + AVFrame *out; + int plane, y; + + out = ff_get_video_buffer(outlink, outlink->w, outlink->h); + if (!out) { + av_frame_free(&in); + return AVERROR(ENOMEM); + } + av_frame_copy_props(out, in); + + for (plane = 0; plane < s->nb_planes; plane++) { + const int threshold = s->threshold[plane]; + + if (threshold) { + const uint8_t *src = in->data[plane]; + uint8_t *dst = out->data[plane]; + int stride = in->linesize[plane]; + int height = s->planeheight[plane]; + int width = s->planewidth[plane]; + uint8_t *p0 = s->buffer + 16; + uint8_t *p1 = p0 + s->planewidth[0]; + uint8_t *p2 = p1 + s->planewidth[0]; + uint8_t *orig = p0, *end = p2; + + line_copy8(p0, src + stride, width, 1); + line_copy8(p1, src, width, 1); + + for (y = 0; y < height; y++) { + const uint8_t *coordinates[] = { p0 - 1, p0, p0 + 1, + p1 - 1, p1 + 1, + p2 - 1, p2, p2 + 1}; + src += stride * (y < height - 1 ? 1 : -1); + line_copy8(p2, src, width, 1); + + s->filter(dst, p1, width, threshold, coordinates, s->coordinates); + + p0 = p1; + p1 = p2; + p2 = (p2 == end) ? orig: p2 + s->planewidth[0]; + dst += out->linesize[plane]; + } + } else { + av_image_copy_plane(out->data[plane], out->linesize[plane], + in->data[plane], in->linesize[plane], + s->planewidth[plane], s->planeheight[plane]); + } + } + + av_frame_free(&in); + return ff_filter_frame(outlink, out); +} + +static const AVFilterPad neighbor_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = filter_frame, + .config_props = config_input, + }, + { NULL } +}; + +static const AVFilterPad neighbor_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + }, + { NULL } +}; + +#define OFFSET(x) offsetof(NContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM + +#define DEFINE_NEIGHBOR_FILTER(name_, description_) \ +AVFILTER_DEFINE_CLASS(name_); \ + \ +AVFilter ff_vf_##name_ = { \ + .name = #name_, \ + .description = NULL_IF_CONFIG_SMALL(description_), \ + .priv_size = sizeof(NContext), \ + .priv_class = &name_##_class, \ + .uninit = uninit, \ + .query_formats = query_formats, \ + .inputs = neighbor_inputs, \ + .outputs = neighbor_outputs, \ + .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, \ +} + +#if CONFIG_EROSION_FILTER + +static const AVOption erosion_options[] = { + { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "coordinates", "set coordinates", OFFSET(coordinates), AV_OPT_TYPE_INT, {.i64=255}, 0, 255, FLAGS }, + { NULL } +}; + +DEFINE_NEIGHBOR_FILTER(erosion, "Apply erosion effect"); + +#endif /* CONFIG_EROSION_FILTER */ + +#if CONFIG_DILATION_FILTER + +static const AVOption dilation_options[] = { + { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "coordinates", "set coordinates", OFFSET(coordinates), AV_OPT_TYPE_INT, {.i64=255}, 0, 255, FLAGS }, + { NULL } +}; + +DEFINE_NEIGHBOR_FILTER(dilation, "Apply dilation effect"); + +#endif /* CONFIG_DILATION_FILTER */ + +#if CONFIG_DEFLATE_FILTER + +static const AVOption deflate_options[] = { + { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { NULL } +}; + +DEFINE_NEIGHBOR_FILTER(deflate, "Apply deflate effect"); + +#endif /* CONFIG_DEFLATE_FILTER */ + +#if CONFIG_INFLATE_FILTER + +static const AVOption inflate_options[] = { + { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, + { NULL } +}; + +DEFINE_NEIGHBOR_FILTER(inflate, "Apply inflate effect"); + +#endif /* CONFIG_INFLATE_FILTER */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_psnr.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_psnr.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_psnr.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_psnr.c 2015-07-30 17:20:02.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Roger Pau Monné + * Copyright (c) 2011 Roger Pau Monné * Copyright (c) 2011 Stefano Sabatini * Copyright (c) 2013 Paul B Mahol * @@ -25,6 +25,7 @@ * Caculate the PSNR between two input videos. */ +#include "libavutil/avstring.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" @@ -32,12 +33,13 @@ #include "drawutils.h" #include "formats.h" #include "internal.h" +#include "psnr.h" #include "video.h" typedef struct PSNRContext { const AVClass *class; FFDualInputContext dinput; - double mse, min_mse, max_mse; + double mse, min_mse, max_mse, mse_comp[4]; uint64_t nb_frames; FILE *stats_file; char *stats_file_str; @@ -48,11 +50,8 @@ int nb_components; int planewidth[4]; int planeheight[4]; - - void (*compute_mse)(struct PSNRContext *s, - const uint8_t *m[4], const int ml[4], - const uint8_t *r[4], const int rl[4], - int w, int h, double mse[4]); + double planeweight[4]; + PSNRDSPContext dsp; } PSNRContext; #define OFFSET(x) offsetof(PSNRContext, x) @@ -76,55 +75,48 @@ return 10.0 * log(pow2(max) / (mse / nb_frames)) / log(10.0); } -static inline -void compute_images_mse(PSNRContext *s, - const uint8_t *main_data[4], const int main_linesizes[4], - const uint8_t *ref_data[4], const int ref_linesizes[4], - int w, int h, double mse[4]) +static uint64_t sse_line_8bit(const uint8_t *main_line, const uint8_t *ref_line, int outw) { - int i, c, j; + int j; + unsigned m2 = 0; - for (c = 0; c < s->nb_components; c++) { - const int outw = s->planewidth[c]; - const int outh = s->planeheight[c]; - const uint8_t *main_line = main_data[c]; - const uint8_t *ref_line = ref_data[c]; - const int ref_linesize = ref_linesizes[c]; - const int main_linesize = main_linesizes[c]; - uint64_t m = 0; + for (j = 0; j < outw; j++) + m2 += pow2(main_line[j] - ref_line[j]); - for (i = 0; i < outh; i++) { - int m2 = 0; - for (j = 0; j < outw; j++) - m2 += pow2(main_line[j] - ref_line[j]); - m += m2; - ref_line += ref_linesize; - main_line += main_linesize; - } - mse[c] = m / (double)(outw * outh); - } + return m2; +} + +static uint64_t sse_line_16bit(const uint8_t *_main_line, const uint8_t *_ref_line, int outw) +{ + int j; + uint64_t m2 = 0; + const uint16_t *main_line = (const uint16_t *) _main_line; + const uint16_t *ref_line = (const uint16_t *) _ref_line; + + for (j = 0; j < outw; j++) + m2 += pow2(main_line[j] - ref_line[j]); + + return m2; } static inline -void compute_images_mse_16bit(PSNRContext *s, +void compute_images_mse(PSNRContext *s, const uint8_t *main_data[4], const int main_linesizes[4], const uint8_t *ref_data[4], const int ref_linesizes[4], int w, int h, double mse[4]) { - int i, c, j; + int i, c; for (c = 0; c < s->nb_components; c++) { const int outw = s->planewidth[c]; const int outh = s->planeheight[c]; - const uint16_t *main_line = (uint16_t *)main_data[c]; - const uint16_t *ref_line = (uint16_t *)ref_data[c]; - const int ref_linesize = ref_linesizes[c] / 2; - const int main_linesize = main_linesizes[c] / 2; + const uint8_t *main_line = main_data[c]; + const uint8_t *ref_line = ref_data[c]; + const int ref_linesize = ref_linesizes[c]; + const int main_linesize = main_linesizes[c]; uint64_t m = 0; - for (i = 0; i < outh; i++) { - for (j = 0; j < outw; j++) - m += pow2(main_line[j] - ref_line[j]); + m += s->dsp.sse_line(main_line, ref_line, outw); ref_line += ref_linesize; main_line += main_linesize; } @@ -153,27 +145,28 @@ int j, c; AVDictionary **metadata = avpriv_frame_get_metadatap(main); - s->compute_mse(s, (const uint8_t **)main->data, main->linesize, - (const uint8_t **)ref->data, ref->linesize, - main->width, main->height, comp_mse); + compute_images_mse(s, (const uint8_t **)main->data, main->linesize, + (const uint8_t **)ref->data, ref->linesize, + main->width, main->height, comp_mse); for (j = 0; j < s->nb_components; j++) - mse += comp_mse[j]; - mse /= s->nb_components; + mse += comp_mse[j] * s->planeweight[j]; s->min_mse = FFMIN(s->min_mse, mse); s->max_mse = FFMAX(s->max_mse, mse); s->mse += mse; + for (j = 0; j < s->nb_components; j++) + s->mse_comp[j] += comp_mse[j]; s->nb_frames++; for (j = 0; j < s->nb_components; j++) { c = s->is_rgb ? s->rgba_map[j] : j; set_meta(metadata, "lavfi.psnr.mse.", s->comps[j], comp_mse[c]); - set_meta(metadata, "lavfi.psnr.mse_avg", 0, mse); set_meta(metadata, "lavfi.psnr.psnr.", s->comps[j], get_psnr(comp_mse[c], 1, s->max[c])); - set_meta(metadata, "lavfi.psnr.psnr_avg", 0, get_psnr(mse, 1, s->average_max)); } + set_meta(metadata, "lavfi.psnr.mse_avg", 0, mse); + set_meta(metadata, "lavfi.psnr.psnr_avg", 0, get_psnr(mse, 1, s->average_max)); if (s->stats_file) { fprintf(s->stats_file, "n:%"PRId64" mse_avg:%0.2f ", s->nb_frames, mse); @@ -243,6 +236,7 @@ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); AVFilterContext *ctx = inlink->dst; PSNRContext *s = ctx->priv; + unsigned sum; int j; s->nb_components = desc->nb_components; @@ -256,33 +250,10 @@ return AVERROR(EINVAL); } - switch (inlink->format) { - case AV_PIX_FMT_GRAY8: - case AV_PIX_FMT_GRAY16: - case AV_PIX_FMT_GBRP: - case AV_PIX_FMT_GBRP9: - case AV_PIX_FMT_GBRP10: - case AV_PIX_FMT_GBRP12: - case AV_PIX_FMT_GBRP14: - case AV_PIX_FMT_GBRP16: - case AV_PIX_FMT_GBRAP: - case AV_PIX_FMT_GBRAP16: - case AV_PIX_FMT_YUVJ411P: - case AV_PIX_FMT_YUVJ420P: - case AV_PIX_FMT_YUVJ422P: - case AV_PIX_FMT_YUVJ440P: - case AV_PIX_FMT_YUVJ444P: - s->max[0] = (1 << (desc->comp[0].depth_minus1 + 1)) - 1; - s->max[1] = (1 << (desc->comp[1].depth_minus1 + 1)) - 1; - s->max[2] = (1 << (desc->comp[2].depth_minus1 + 1)) - 1; - s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1; - break; - default: - s->max[0] = 235 * (1 << (desc->comp[0].depth_minus1 - 7)); - s->max[1] = 240 * (1 << (desc->comp[1].depth_minus1 - 7)); - s->max[2] = 240 * (1 << (desc->comp[2].depth_minus1 - 7)); - s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1; - } + s->max[0] = (1 << (desc->comp[0].depth_minus1 + 1)) - 1; + s->max[1] = (1 << (desc->comp[1].depth_minus1 + 1)) - 1; + s->max[2] = (1 << (desc->comp[2].depth_minus1 + 1)) - 1; + s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1; s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0; s->comps[0] = s->is_rgb ? 'r' : 'y' ; @@ -290,16 +261,21 @@ s->comps[2] = s->is_rgb ? 'b' : 'v' ; s->comps[3] = 'a'; - for (j = 0; j < s->nb_components; j++) - s->average_max += s->max[j]; - s->average_max /= s->nb_components; - s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h); s->planeheight[0] = s->planeheight[3] = inlink->h; s->planewidth[1] = s->planewidth[2] = FF_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w); s->planewidth[0] = s->planewidth[3] = inlink->w; + sum = 0; + for (j = 0; j < s->nb_components; j++) + sum += s->planeheight[j] * s->planewidth[j]; + for (j = 0; j < s->nb_components; j++) { + s->planeweight[j] = (double) s->planeheight[j] * s->planewidth[j] / sum; + s->average_max += s->max[j] * s->planeweight[j]; + } - s->compute_mse = desc->comp[0].depth_minus1 > 7 ? compute_images_mse_16bit : compute_images_mse; + s->dsp.sse_line = desc->comp[0].depth_minus1 > 7 ? sse_line_16bit : sse_line_8bit; + if (ARCH_X86) + ff_psnr_init_x86(&s->dsp, desc->comp[0].depth_minus1 + 1); return 0; } @@ -339,7 +315,17 @@ PSNRContext *s = ctx->priv; if (s->nb_frames > 0) { - av_log(ctx, AV_LOG_INFO, "PSNR average:%0.2f min:%0.2f max:%0.2f\n", + int j; + char buf[256]; + + buf[0] = 0; + for (j = 0; j < s->nb_components; j++) { + int c = s->is_rgb ? s->rgba_map[j] : j; + av_strlcatf(buf, sizeof(buf), " %c:%0.2f", s->comps[j], + get_psnr(s->mse_comp[c], s->nb_frames, s->max[c])); + } + av_log(ctx, AV_LOG_INFO, "PSNR%s average:%0.2f min:%0.2f max:%0.2f\n", + buf, get_psnr(s->mse, s->nb_frames, s->average_max), get_psnr(s->max_mse, 1, s->average_max), get_psnr(s->min_mse, 1, s->average_max)); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_random.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_random.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_random.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_random.c 2015-07-20 17:20:03.000000000 +0000 @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2015 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/lfg.h" +#include "libavutil/opt.h" +#include "libavutil/random_seed.h" +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "video.h" + +#define MAX_FRAMES 512 + +typedef struct RandomContext { + const AVClass *class; + + AVLFG lfg; + int nb_frames; + int64_t random_seed; + int nb_frames_filled; + AVFrame *frames[MAX_FRAMES]; + int64_t pts[MAX_FRAMES]; + int flush_idx; +} RandomContext; + +#define OFFSET(x) offsetof(RandomContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption random_options[] = { + { "frames", "set number of frames in cache", OFFSET(nb_frames), AV_OPT_TYPE_INT, {.i64=30}, 2, MAX_FRAMES, FLAGS }, + { "seed", "set the seed", OFFSET(random_seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT32_MAX, FLAGS }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(random); + +static av_cold int init(AVFilterContext *ctx) +{ + RandomContext *s = ctx->priv; + uint32_t seed; + + if (s->random_seed < 0) + s->random_seed = av_get_random_seed(); + seed = s->random_seed; + av_lfg_init(&s->lfg, seed); + + return 0; +} + +static int config_output(AVFilterLink *outlink) +{ + outlink->flags |= FF_LINK_FLAG_REQUEST_LOOP; + return 0; +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ + AVFilterContext *ctx = inlink->dst; + RandomContext *s = ctx->priv; + AVFilterLink *outlink = ctx->outputs[0]; + AVFrame *out; + int idx; + + if (s->nb_frames_filled < s->nb_frames) { + s->frames[s->nb_frames_filled] = in; + s->pts[s->nb_frames_filled++] = in->pts; + return 0; + } + + idx = av_lfg_get(&s->lfg) % s->nb_frames; + + out = s->frames[idx]; + out->pts = s->pts[0]; + memmove(&s->pts[0], &s->pts[1], (s->nb_frames - 1) * sizeof(s->pts[0])); + s->frames[idx] = in; + s->pts[s->nb_frames - 1] = in->pts; + + return ff_filter_frame(outlink, out); +} + +static int request_frame(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + RandomContext *s = ctx->priv; + int ret; + + ret = ff_request_frame(ctx->inputs[0]); + + if (ret == AVERROR_EOF && !ctx->is_disabled && s->nb_frames > 0) { + AVFrame *out = s->frames[s->nb_frames - 1]; + out->pts = s->pts[s->flush_idx++]; + ret = ff_filter_frame(outlink, out); + s->frames[s->nb_frames - 1] = NULL; + s->nb_frames--; + } + + return ret; +} + +static const AVFilterPad random_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = filter_frame, + }, + { NULL } +}; + +static const AVFilterPad random_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .request_frame = request_frame, + .config_props = config_output, + }, + { NULL } +}; + +AVFilter ff_vf_random = { + .name = "random", + .description = NULL_IF_CONFIG_SMALL("Return random frames."), + .priv_size = sizeof(RandomContext), + .priv_class = &random_class, + .init = init, + .inputs = random_inputs, + .outputs = random_outputs, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_removegrain.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_removegrain.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_removegrain.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_removegrain.c 2015-07-15 17:20:03.000000000 +0000 @@ -0,0 +1,660 @@ +/* + * Copyright (c) 2012 Laurent de Soras + * Copyright (c) 2013 Fredrik Mellbin + * Copyright (c) 2015 Paul B Mahol + * Copyright (c) 2015 James Darnley + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/imgutils.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "removegrain.h" +#include "video.h" + +#define OFFSET(x) offsetof(RemoveGrainContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM + +static const AVOption removegrain_options[] = { + { "m0", "set mode for 1st plane", OFFSET(mode[0]), AV_OPT_TYPE_INT, {.i64=0}, 0, 24, FLAGS }, + { "m1", "set mode for 2nd plane", OFFSET(mode[1]), AV_OPT_TYPE_INT, {.i64=0}, 0, 24, FLAGS }, + { "m2", "set mode for 3rd plane", OFFSET(mode[2]), AV_OPT_TYPE_INT, {.i64=0}, 0, 24, FLAGS }, + { "m3", "set mode for 4th plane", OFFSET(mode[3]), AV_OPT_TYPE_INT, {.i64=0}, 0, 24, FLAGS }, + {NULL} +}; + +AVFILTER_DEFINE_CLASS(removegrain); + +static int query_formats(AVFilterContext *ctx) +{ + static const enum AVPixelFormat pix_fmts[] = { + AV_PIX_FMT_GRAY8, + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, + AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P, + AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, + AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, + AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P, + AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, + AV_PIX_FMT_NONE + }; + + AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts); + if (!fmts_list) + return AVERROR(ENOMEM); + return ff_set_common_formats(ctx, fmts_list); +} + +#define REMOVE_GRAIN_SORT_AXIS \ + const int ma1 = FFMAX(a1, a8); \ + const int mi1 = FFMIN(a1, a8); \ + const int ma2 = FFMAX(a2, a7); \ + const int mi2 = FFMIN(a2, a7); \ + const int ma3 = FFMAX(a3, a6); \ + const int mi3 = FFMIN(a3, a6); \ + const int ma4 = FFMAX(a4, a5); \ + const int mi4 = FFMIN(a4, a5); + +static int mode01(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + const int mi = FFMIN(FFMIN(FFMIN(a1, a2), FFMIN(a3, a4)), FFMIN(FFMIN(a5, a6), FFMIN(a7, a8))); + const int ma = FFMAX(FFMAX(FFMAX(a1, a2), FFMAX(a3, a4)), FFMAX(FFMAX(a5, a6), FFMAX(a7, a8))); + + return av_clip(c, mi, ma); +} + +static int cmp_int(const void *p1, const void *p2) +{ + int left = *(const int *)p1; + int right = *(const int *)p2; + + return ((left > right) - (left < right)); +} + +static int mode02(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + int a[8] = { a1, a2, a3, a4, a5, a6, a7, a8 }; + + qsort(&a, 8, sizeof(a[0]), cmp_int); + + return av_clip(c, a[2 - 1 ], a[7 - 1]); +} + +static int mode03(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + int a[8] = { a1, a2, a3, a4, a5, a6, a7, a8 }; + + qsort(&a, 8, sizeof(a[0]), cmp_int); + + return av_clip(c, a[3 - 1 ], a[6 - 1]); +} + +static int mode04(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + int a[8] = { a1, a2, a3, a4, a5, a6, a7, a8 }; + + qsort(&a, 8, sizeof(a[0]), cmp_int); + + return av_clip(c, a[4 - 1 ], a[5 - 1]); +} + +static int mode05(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + REMOVE_GRAIN_SORT_AXIS + + const int c1 = FFABS(c - av_clip(c, mi1, ma1)); + const int c2 = FFABS(c - av_clip(c, mi2, ma2)); + const int c3 = FFABS(c - av_clip(c, mi3, ma3)); + const int c4 = FFABS(c - av_clip(c, mi4, ma4)); + + const int mindiff = FFMIN(FFMIN(c1, c2), FFMIN(c3, c4)); + + /* When adding SIMD notice the return order here: 4, 2, 3, 1. */ + if (mindiff == c4) { + return av_clip(c, mi4, ma4); + } else if (mindiff == c2) { + return av_clip(c, mi2, ma2); + } else if (mindiff == c3) { + return av_clip(c, mi3, ma3); + } + + return av_clip(c, mi1, ma1); +} + +static int mode06(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + REMOVE_GRAIN_SORT_AXIS + + const int d1 = ma1 - mi1; + const int d2 = ma2 - mi2; + const int d3 = ma3 - mi3; + const int d4 = ma4 - mi4; + + const int cli1 = av_clip(c, mi1, ma1); + const int cli2 = av_clip(c, mi2, ma2); + const int cli3 = av_clip(c, mi3, ma3); + const int cli4 = av_clip(c, mi4, ma4); + + const int c1 = av_clip_uint16((FFABS(c - cli1) << 1) + d1); + const int c2 = av_clip_uint16((FFABS(c - cli2) << 1) + d2); + const int c3 = av_clip_uint16((FFABS(c - cli3) << 1) + d3); + const int c4 = av_clip_uint16((FFABS(c - cli4) << 1) + d4); + + const int mindiff = FFMIN(FFMIN(c1, c2), FFMIN(c3, c4)); + + if (mindiff == c4) { + return cli4; + } else if (mindiff == c2) { + return cli2; + } else if (mindiff == c3) { + return cli3; + } + + return cli1; +} + +static int mode07(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + REMOVE_GRAIN_SORT_AXIS + + const int d1 = ma1 - mi1; + const int d2 = ma2 - mi2; + const int d3 = ma3 - mi3; + const int d4 = ma4 - mi4; + + const int cli1 = av_clip(c, mi1, ma1); + const int cli2 = av_clip(c, mi2, ma2); + const int cli3 = av_clip(c, mi3, ma3); + const int cli4 = av_clip(c, mi4, ma4); + + const int c1 = FFABS(c - cli1) + d1; + const int c2 = FFABS(c - cli2) + d2; + const int c3 = FFABS(c - cli3) + d3; + const int c4 = FFABS(c - cli4) + d4; + + const int mindiff = FFMIN(FFMIN(c1, c2), FFMIN(c3, c4)); + + if (mindiff == c4) { + return cli4; + } else if (mindiff == c2) { + return cli2; + } else if (mindiff == c3) { + return cli3; + } + + return cli1; +} + +static int mode08(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + REMOVE_GRAIN_SORT_AXIS + + const int d1 = ma1 - mi1; + const int d2 = ma2 - mi2; + const int d3 = ma3 - mi3; + const int d4 = ma4 - mi4; + + const int cli1 = av_clip(c, mi1, ma1); + const int cli2 = av_clip(c, mi2, ma2); + const int cli3 = av_clip(c, mi3, ma3); + const int cli4 = av_clip(c, mi4, ma4); + + const int c1 = av_clip_uint16(FFABS(c - cli1) + (d1 << 1)); + const int c2 = av_clip_uint16(FFABS(c - cli2) + (d2 << 1)); + const int c3 = av_clip_uint16(FFABS(c - cli3) + (d3 << 1)); + const int c4 = av_clip_uint16(FFABS(c - cli4) + (d4 << 1)); + + const int mindiff = FFMIN(FFMIN(c1, c2), FFMIN(c3, c4)); + + if (mindiff == c4) { + return cli4; + } else if (mindiff == c2) { + return cli2; + } else if (mindiff == c3) { + return cli3; + } + + return cli1; +} + +static int mode09(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + REMOVE_GRAIN_SORT_AXIS + + const int d1 = ma1 - mi1; + const int d2 = ma2 - mi2; + const int d3 = ma3 - mi3; + const int d4 = ma4 - mi4; + + const int mindiff = FFMIN(FFMIN(d1, d2), FFMIN(d3, d4)); + + if (mindiff == d4) { + return av_clip(c, mi4, ma4); + } else if (mindiff == d2) { + return av_clip(c, mi2, ma2); + } else if (mindiff == d3) { + return av_clip(c, mi3, ma3); + } + + return av_clip(c, mi1, ma1); +} + +static int mode10(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + const int d1 = FFABS(c - a1); + const int d2 = FFABS(c - a2); + const int d3 = FFABS(c - a3); + const int d4 = FFABS(c - a4); + const int d5 = FFABS(c - a5); + const int d6 = FFABS(c - a6); + const int d7 = FFABS(c - a7); + const int d8 = FFABS(c - a8); + + const int mindiff = FFMIN(FFMIN(FFMIN(d1, d2), FFMIN(d3, d4)), + FFMIN(FFMIN(d5, d6), FFMIN(d7, d8))); + + if (mindiff == d7) return a7; + if (mindiff == d8) return a8; + if (mindiff == d6) return a6; + if (mindiff == d2) return a2; + if (mindiff == d3) return a3; + if (mindiff == d1) return a1; + if (mindiff == d5) return a5; + + return a4; +} + +static int mode1112(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + const int sum = 4 * c + 2 * (a2 + a4 + a5 + a7) + a1 + a3 + a6 + a8; + const int val = (sum + 8) >> 4; + + return val; +} + +static int mode1314(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + const int d1 = FFABS(a1 - a8); + const int d2 = FFABS(a2 - a7); + const int d3 = FFABS(a3 - a6); + + const int mindiff = FFMIN(FFMIN(d1, d2), d3); + + if (mindiff == d2) { + return (a2 + a7 + 1) >> 1; + } + if (mindiff == d3) { + return (a3 + a6 + 1) >> 1; + } + + return (a1 + a8 + 1) >> 1; +} + +static int mode1516(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + const int d1 = FFABS(a1 - a8); + const int d2 = FFABS(a2 - a7); + const int d3 = FFABS(a3 - a6); + + const int mindiff = FFMIN(FFMIN(d1, d2), d3); + const int average = (2 * (a2 + a7) + a1 + a3 + a6 + a8 + 4) >> 3; + + if (mindiff == d2) { + return av_clip(average, FFMIN(a2, a7), FFMAX(a2, a7)); + } + if (mindiff == d3) { + return av_clip(average, FFMIN(a3, a6), FFMAX(a3, a6)); + } + + return av_clip(average, FFMIN(a1, a8), FFMAX(a1, a8)); +} + +static int mode17(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + REMOVE_GRAIN_SORT_AXIS + + const int l = FFMAX(FFMAX(mi1, mi2), FFMAX(mi3, mi4)); + const int u = FFMIN(FFMIN(ma1, ma2), FFMIN(ma3, ma4)); + + return av_clip(c, FFMIN(l, u), FFMAX(l, u)); +} + +static int mode18(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + const int d1 = FFMAX(FFABS(c - a1), FFABS(c - a8)); + const int d2 = FFMAX(FFABS(c - a2), FFABS(c - a7)); + const int d3 = FFMAX(FFABS(c - a3), FFABS(c - a6)); + const int d4 = FFMAX(FFABS(c - a4), FFABS(c - a5)); + + const int mindiff = FFMIN(FFMIN(d1, d2), FFMIN(d3, d4)); + + if (mindiff == d4) { + return av_clip(c, FFMIN(a4, a5), FFMAX(a4, a5)); + } + if (mindiff == d2) { + return av_clip(c, FFMIN(a2, a7), FFMAX(a2, a7)); + } + if (mindiff == d3) { + return av_clip(c, FFMIN(a3, a6), FFMAX(a3, a6)); + } + + return av_clip(c, FFMIN(a1, a8), FFMAX(a1, a8)); +} + +static int mode19(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + const int sum = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8; + const int val = (sum + 4) >> 3; + + return val; +} + +static int mode20(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + const int sum = a1 + a2 + a3 + a4 + c + a5 + a6 + a7 + a8; + const int val = (sum + 4) / 9; + + return val; +} + +static int mode21(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + const int l1l = (a1 + a8) >> 1; + const int l2l = (a2 + a7) >> 1; + const int l3l = (a3 + a6) >> 1; + const int l4l = (a4 + a5) >> 1; + + const int l1h = (a1 + a8 + 1) >> 1; + const int l2h = (a2 + a7 + 1) >> 1; + const int l3h = (a3 + a6 + 1) >> 1; + const int l4h = (a4 + a5 + 1) >> 1; + + const int mi = FFMIN(FFMIN(l1l, l2l), FFMIN(l3l, l4l)); + const int ma = FFMAX(FFMAX(l1h, l2h), FFMAX(l3h, l4h)); + + return av_clip(c, mi, ma); +} + +static int mode22(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + const int l1 = (a1 + a8 + 1) >> 1; + const int l2 = (a2 + a7 + 1) >> 1; + const int l3 = (a3 + a6 + 1) >> 1; + const int l4 = (a4 + a5 + 1) >> 1; + + const int mi = FFMIN(FFMIN(l1, l2), FFMIN(l3, l4)); + const int ma = FFMAX(FFMAX(l1, l2), FFMAX(l3, l4)); + + return av_clip(c, mi, ma); +} + +static int mode23(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + REMOVE_GRAIN_SORT_AXIS + + const int linediff1 = ma1 - mi1; + const int linediff2 = ma2 - mi2; + const int linediff3 = ma3 - mi3; + const int linediff4 = ma4 - mi4; + + const int u1 = FFMIN(c - ma1, linediff1); + const int u2 = FFMIN(c - ma2, linediff2); + const int u3 = FFMIN(c - ma3, linediff3); + const int u4 = FFMIN(c - ma4, linediff4); + const int u = FFMAX(FFMAX(FFMAX(u1, u2), FFMAX(u3, u4)), 0); + + const int d1 = FFMIN(mi1 - c, linediff1); + const int d2 = FFMIN(mi2 - c, linediff2); + const int d3 = FFMIN(mi3 - c, linediff3); + const int d4 = FFMIN(mi4 - c, linediff4); + const int d = FFMAX(FFMAX(FFMAX(d1, d2), FFMAX(d3, d4)), 0); + + return c - u + d; // This probably will never overflow. +} + +static int mode24(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) +{ + REMOVE_GRAIN_SORT_AXIS + + const int linediff1 = ma1 - mi1; + const int linediff2 = ma2 - mi2; + const int linediff3 = ma3 - mi3; + const int linediff4 = ma4 - mi4; + + const int tu1 = c - ma1; + const int tu2 = c - ma2; + const int tu3 = c - ma3; + const int tu4 = c - ma4; + + const int u1 = FFMIN(tu1, linediff1 - tu1); + const int u2 = FFMIN(tu2, linediff2 - tu2); + const int u3 = FFMIN(tu3, linediff3 - tu3); + const int u4 = FFMIN(tu4, linediff4 - tu4); + const int u = FFMAX(FFMAX(FFMAX(u1, u2), FFMAX(u3, u4)), 0); + + const int td1 = mi1 - c; + const int td2 = mi2 - c; + const int td3 = mi3 - c; + const int td4 = mi4 - c; + + const int d1 = FFMIN(td1, linediff1 - td1); + const int d2 = FFMIN(td2, linediff2 - td2); + const int d3 = FFMIN(td3, linediff3 - td3); + const int d4 = FFMIN(td4, linediff4 - td4); + const int d = FFMAX(FFMAX(FFMAX(d1, d2), FFMAX(d3, d4)), 0); + + return c - u + d; // This probably will never overflow. +} + +static int config_input(AVFilterLink *inlink) +{ + RemoveGrainContext *s = inlink->dst->priv; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); + int i; + + s->nb_planes = av_pix_fmt_count_planes(inlink->format); + + s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h); + s->planeheight[0] = s->planeheight[3] = inlink->h; + s->planewidth[1] = s->planewidth[2] = FF_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w); + s->planewidth[0] = s->planewidth[3] = inlink->w; + + for (i = 0; i < s->nb_planes; i++) { + switch (s->mode[i]) { + case 1: s->rg[i] = mode01; break; + case 2: s->rg[i] = mode02; break; + case 3: s->rg[i] = mode03; break; + case 4: s->rg[i] = mode04; break; + case 5: s->rg[i] = mode05; break; + case 6: s->rg[i] = mode06; break; + case 7: s->rg[i] = mode07; break; + case 8: s->rg[i] = mode08; break; + case 9: s->rg[i] = mode09; break; + case 10: s->rg[i] = mode10; break; + case 11: s->rg[i] = mode1112; break; + case 12: s->rg[i] = mode1112; break; + case 13: s->skip_odd = 1; + s->rg[i] = mode1314; break; + case 14: s->skip_even = 1; + s->rg[i] = mode1314; break; + case 15: s->skip_odd = 1; + s->rg[i] = mode1516; break; + case 16: s->skip_even = 1; + s->rg[i] = mode1516; break; + case 17: s->rg[i] = mode17; break; + case 18: s->rg[i] = mode18; break; + case 19: s->rg[i] = mode19; break; + case 20: s->rg[i] = mode20; break; + case 21: s->rg[i] = mode21; break; + case 22: s->rg[i] = mode22; break; + case 23: s->rg[i] = mode23; break; + case 24: s->rg[i] = mode24; break; + } + } + + if (ARCH_X86) + ff_removegrain_init_x86(s); + + return 0; +} + +typedef struct ThreadData { + AVFrame *in, *out; + int plane; +} ThreadData; + +static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) +{ + RemoveGrainContext *s = ctx->priv; + ThreadData *td = arg; + AVFrame *in = td->in; + AVFrame *out = td->out; + const int i = td->plane; + const int height = s->planeheight[i]; + const int om = in->linesize[i] - 1; + const int o0 = in->linesize[i] ; + const int op = in->linesize[i] + 1; + int start = (height * jobnr ) / nb_jobs; + int end = (height * (jobnr+1)) / nb_jobs; + int x, y; + + start = FFMAX(1, start); + end = FFMIN(height-1, end); + for (y = start; y < end; y++) { + uint8_t *dst = out->data[i]; + uint8_t *src = in->data[i]; + + src = in->data[i] + y * in->linesize[i]; + dst = out->data[i] + y * out->linesize[i]; + + if (s->skip_even && !(y & 1)) { + memcpy(dst, src, s->planewidth[i]); + continue; + } + if (s->skip_odd && y & 1) { + memcpy(dst, src, s->planewidth[i]); + continue; + } + + *dst++ = *src++; + + if (s->fl[i]) { + int w_asm = (s->planewidth[i] - 2) & ~15; + + s->fl[i](dst, src, in->linesize[i], w_asm); + + x = 1 + w_asm; + dst += w_asm; + src += w_asm; + } else + x = 1; + + for (; x < s->planewidth[i] - 1; x++) { + const int a1 = src[-op]; + const int a2 = src[-o0]; + const int a3 = src[-om]; + const int a4 = src[-1 ]; + const int c = src[ 0 ]; + const int a5 = src[ 1 ]; + const int a6 = src[ om]; + const int a7 = src[ o0]; + const int a8 = src[ op]; + + const int res = s->rg[i](c, a1, a2, a3, a4, a5, a6, a7, a8); + + *dst = res; + dst++, src++; + } + dst[0] = src[0]; + } + + return 0; +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ + AVFilterContext *ctx = inlink->dst; + AVFilterLink *outlink = ctx->outputs[0]; + RemoveGrainContext *s = ctx->priv; + ThreadData td; + AVFrame *out; + int i; + + out = ff_get_video_buffer(outlink, outlink->w, outlink->h); + if (!out) { + av_frame_free(&in); + return AVERROR(ENOMEM); + } + av_frame_copy_props(out, in); + + for (i = 0; i < s->nb_planes; i++) { + uint8_t *dst = out->data[i]; + uint8_t *src = in->data[i]; + + if (s->mode[i] == 0) { + av_image_copy_plane(dst, out->linesize[i], + src, in->linesize[i], + s->planewidth[i], s->planeheight[i]); + continue; + } + + memcpy(dst, src, s->planewidth[i]); + + td.in = in; td.out = out; td.plane = i; + ctx->internal->execute(ctx, filter_slice, &td, NULL, + FFMIN(s->planeheight[i], ctx->graph->nb_threads)); + + src = in->data[i] + (s->planeheight[i] - 1) * in->linesize[i]; + dst = out->data[i] + (s->planeheight[i] - 1) * out->linesize[i]; + memcpy(dst, src, s->planewidth[i]); + } + + av_frame_free(&in); + return ff_filter_frame(outlink, out); +} + +static const AVFilterPad removegrain_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = filter_frame, + .config_props = config_input, + }, + { NULL } +}; + +static const AVFilterPad removegrain_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + }, + { NULL } +}; + +AVFilter ff_vf_removegrain = { + .name = "removegrain", + .description = NULL_IF_CONFIG_SMALL("Remove grain."), + .priv_size = sizeof(RemoveGrainContext), + .query_formats = query_formats, + .inputs = removegrain_inputs, + .outputs = removegrain_outputs, + .priv_class = &removegrain_class, + .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_scale.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_scale.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_scale.c 2015-06-19 20:44:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_scale.c 2015-07-21 17:20:03.000000000 +0000 @@ -544,6 +544,30 @@ return ff_filter_frame(outlink, out); } +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, + char *res, int res_len, int flags) +{ + ScaleContext *scale = ctx->priv; + int ret; + + if ( !strcmp(cmd, "width") || !strcmp(cmd, "w") + || !strcmp(cmd, "height") || !strcmp(cmd, "h")) { + + int old_w = scale->w; + int old_h = scale->h; + AVFilterLink *outlink = ctx->outputs[0]; + + av_opt_set(scale, cmd, args, 0); + if ((ret = config_props(outlink)) < 0) { + scale->w = old_w; + scale->h = old_h; + } + } else + ret = AVERROR(ENOSYS); + + return ret; +} + static const AVClass *child_class_next(const AVClass *prev) { return prev ? NULL : sws_get_class(); @@ -610,13 +634,14 @@ }; AVFilter ff_vf_scale = { - .name = "scale", - .description = NULL_IF_CONFIG_SMALL("Scale the input video size and/or convert the image format."), - .init_dict = init_dict, - .uninit = uninit, - .query_formats = query_formats, - .priv_size = sizeof(ScaleContext), - .priv_class = &scale_class, - .inputs = avfilter_vf_scale_inputs, - .outputs = avfilter_vf_scale_outputs, + .name = "scale", + .description = NULL_IF_CONFIG_SMALL("Scale the input video size and/or convert the image format."), + .init_dict = init_dict, + .uninit = uninit, + .query_formats = query_formats, + .priv_size = sizeof(ScaleContext), + .priv_class = &scale_class, + .inputs = avfilter_vf_scale_inputs, + .outputs = avfilter_vf_scale_outputs, + .process_command = process_command, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_shuffleplanes.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_shuffleplanes.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_shuffleplanes.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_shuffleplanes.c 2015-07-03 17:20:03.000000000 +0000 @@ -134,12 +134,7 @@ { NULL }, }; -static const AVClass shuffleplanes_class = { - .class_name = "shuffleplanes", - .item_name = av_default_item_name, - .option = shuffleplanes_options, - .version = LIBAVUTIL_VERSION_INT, -}; +AVFILTER_DEFINE_CLASS(shuffleplanes); static const AVFilterPad shuffleplanes_inputs[] = { { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_smartblur.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_smartblur.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_smartblur.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_smartblur.c 2015-07-16 17:20:02.000000000 +0000 @@ -84,34 +84,34 @@ static av_cold int init(AVFilterContext *ctx) { - SmartblurContext *sblur = ctx->priv; + SmartblurContext *s = ctx->priv; /* make chroma default to luma values, if not explicitly set */ - if (sblur->chroma.radius < RADIUS_MIN) - sblur->chroma.radius = sblur->luma.radius; - if (sblur->chroma.strength < STRENGTH_MIN) - sblur->chroma.strength = sblur->luma.strength; - if (sblur->chroma.threshold < THRESHOLD_MIN) - sblur->chroma.threshold = sblur->luma.threshold; + if (s->chroma.radius < RADIUS_MIN) + s->chroma.radius = s->luma.radius; + if (s->chroma.strength < STRENGTH_MIN) + s->chroma.strength = s->luma.strength; + if (s->chroma.threshold < THRESHOLD_MIN) + s->chroma.threshold = s->luma.threshold; - sblur->luma.quality = sblur->chroma.quality = 3.0; - sblur->sws_flags = SWS_BICUBIC; + s->luma.quality = s->chroma.quality = 3.0; + s->sws_flags = SWS_BICUBIC; av_log(ctx, AV_LOG_VERBOSE, "luma_radius:%f luma_strength:%f luma_threshold:%d " "chroma_radius:%f chroma_strength:%f chroma_threshold:%d\n", - sblur->luma.radius, sblur->luma.strength, sblur->luma.threshold, - sblur->chroma.radius, sblur->chroma.strength, sblur->chroma.threshold); + s->luma.radius, s->luma.strength, s->luma.threshold, + s->chroma.radius, s->chroma.strength, s->chroma.threshold); return 0; } static av_cold void uninit(AVFilterContext *ctx) { - SmartblurContext *sblur = ctx->priv; + SmartblurContext *s = ctx->priv; - sws_freeContext(sblur->luma.filter_context); - sws_freeContext(sblur->chroma.filter_context); + sws_freeContext(s->luma.filter_context); + sws_freeContext(s->chroma.filter_context); } static int query_formats(AVFilterContext *ctx) @@ -159,17 +159,17 @@ static int config_props(AVFilterLink *inlink) { - SmartblurContext *sblur = inlink->dst->priv; + SmartblurContext *s = inlink->dst->priv; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); - sblur->hsub = desc->log2_chroma_w; - sblur->vsub = desc->log2_chroma_h; + s->hsub = desc->log2_chroma_w; + s->vsub = desc->log2_chroma_h; - alloc_sws_context(&sblur->luma, inlink->w, inlink->h, sblur->sws_flags); - alloc_sws_context(&sblur->chroma, - FF_CEIL_RSHIFT(inlink->w, sblur->hsub), - FF_CEIL_RSHIFT(inlink->h, sblur->vsub), - sblur->sws_flags); + alloc_sws_context(&s->luma, inlink->w, inlink->h, s->sws_flags); + alloc_sws_context(&s->chroma, + FF_CEIL_RSHIFT(inlink->w, s->hsub), + FF_CEIL_RSHIFT(inlink->h, s->vsub), + s->sws_flags); return 0; } @@ -240,11 +240,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) { - SmartblurContext *sblur = inlink->dst->priv; + SmartblurContext *s = inlink->dst->priv; AVFilterLink *outlink = inlink->dst->outputs[0]; AVFrame *outpic; - int cw = FF_CEIL_RSHIFT(inlink->w, sblur->hsub); - int ch = FF_CEIL_RSHIFT(inlink->h, sblur->vsub); + int cw = FF_CEIL_RSHIFT(inlink->w, s->hsub); + int ch = FF_CEIL_RSHIFT(inlink->h, s->vsub); outpic = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!outpic) { @@ -255,18 +255,18 @@ blur(outpic->data[0], outpic->linesize[0], inpic->data[0], inpic->linesize[0], - inlink->w, inlink->h, sblur->luma.threshold, - sblur->luma.filter_context); + inlink->w, inlink->h, s->luma.threshold, + s->luma.filter_context); if (inpic->data[2]) { blur(outpic->data[1], outpic->linesize[1], inpic->data[1], inpic->linesize[1], - cw, ch, sblur->chroma.threshold, - sblur->chroma.filter_context); + cw, ch, s->chroma.threshold, + s->chroma.filter_context); blur(outpic->data[2], outpic->linesize[2], inpic->data[2], inpic->linesize[2], - cw, ch, sblur->chroma.threshold, - sblur->chroma.filter_context); + cw, ch, s->chroma.threshold, + s->chroma.filter_context); } av_frame_free(&inpic); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_ssim.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_ssim.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_ssim.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_ssim.c 2015-07-14 17:20:02.000000000 +0000 @@ -0,0 +1,397 @@ +/* + * Copyright (c) 2003-2013 Loren Merritt + * Copyright (c) 2015 Paul B Mahol + * + * 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 + */ + +/* Computes the Structural Similarity Metric between two video streams. + * original algorithm: + * Z. Wang, A. C. Bovik, H. R. Sheikh and E. P. Simoncelli, + * "Image quality assessment: From error visibility to structural similarity," + * IEEE Transactions on Image Processing, vol. 13, no. 4, pp. 600-612, Apr. 2004. + * + * To improve speed, this implementation uses the standard approximation of + * overlapped 8x8 block sums, rather than the original gaussian weights. + */ + +/* + * @file + * Caculate the SSIM between two input videos. + */ + +#include "libavutil/avstring.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "avfilter.h" +#include "dualinput.h" +#include "drawutils.h" +#include "formats.h" +#include "internal.h" +#include "ssim.h" +#include "video.h" + +typedef struct SSIMContext { + const AVClass *class; + FFDualInputContext dinput; + FILE *stats_file; + char *stats_file_str; + int nb_components; + uint64_t nb_frames; + double ssim[4], ssim_total; + char comps[4]; + float coefs[4]; + uint8_t rgba_map[4]; + int planewidth[4]; + int planeheight[4]; + int *temp; + int is_rgb; + SSIMDSPContext dsp; +} SSIMContext; + +#define OFFSET(x) offsetof(SSIMContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM + +static const AVOption ssim_options[] = { + {"stats_file", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, + {"f", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(ssim); + +static void set_meta(AVDictionary **metadata, const char *key, char comp, float d) +{ + char value[128]; + snprintf(value, sizeof(value), "%0.2f", d); + if (comp) { + char key2[128]; + snprintf(key2, sizeof(key2), "%s%c", key, comp); + av_dict_set(metadata, key2, value, 0); + } else { + av_dict_set(metadata, key, value, 0); + } +} + +static void ssim_4x4xn(const uint8_t *main, ptrdiff_t main_stride, + const uint8_t *ref, ptrdiff_t ref_stride, + int (*sums)[4], int width) +{ + int x, y, z; + + for (z = 0; z < width; z++) { + uint32_t s1 = 0, s2 = 0, ss = 0, s12 = 0; + + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + int a = main[x + y * main_stride]; + int b = ref[x + y * ref_stride]; + + s1 += a; + s2 += b; + ss += a*a; + ss += b*b; + s12 += a*b; + } + } + + sums[z][0] = s1; + sums[z][1] = s2; + sums[z][2] = ss; + sums[z][3] = s12; + main += 4; + ref += 4; + } +} + +static float ssim_end1(int s1, int s2, int ss, int s12) +{ + static const int ssim_c1 = (int)(.01*.01*255*255*64 + .5); + static const int ssim_c2 = (int)(.03*.03*255*255*64*63 + .5); + + int fs1 = s1; + int fs2 = s2; + int fss = ss; + int fs12 = s12; + int vars = fss * 64 - fs1 * fs1 - fs2 * fs2; + int covar = fs12 * 64 - fs1 * fs2; + + return (float)(2 * fs1 * fs2 + ssim_c1) * (float)(2 * covar + ssim_c2) + / ((float)(fs1 * fs1 + fs2 * fs2 + ssim_c1) * (float)(vars + ssim_c2)); +} + +static float ssim_endn(const int (*sum0)[4], const int (*sum1)[4], int width) +{ + float ssim = 0.0; + int i; + + for (i = 0; i < width; i++) + ssim += ssim_end1(sum0[i][0] + sum0[i + 1][0] + sum1[i][0] + sum1[i + 1][0], + sum0[i][1] + sum0[i + 1][1] + sum1[i][1] + sum1[i + 1][1], + sum0[i][2] + sum0[i + 1][2] + sum1[i][2] + sum1[i + 1][2], + sum0[i][3] + sum0[i + 1][3] + sum1[i][3] + sum1[i + 1][3]); + return ssim; +} + +static float ssim_plane(SSIMDSPContext *dsp, + uint8_t *main, int main_stride, + uint8_t *ref, int ref_stride, + int width, int height, void *temp) +{ + int z = 0, y; + float ssim = 0.0; + int (*sum0)[4] = temp; + int (*sum1)[4] = sum0 + (width >> 2) + 3; + + width >>= 2; + height >>= 2; + + for (y = 1; y < height; y++) { + for (; z <= y; z++) { + FFSWAP(void*, sum0, sum1); + dsp->ssim_4x4_line(&main[4 * z * main_stride], main_stride, + &ref[4 * z * ref_stride], ref_stride, + sum0, width); + } + + ssim += dsp->ssim_end_line((const int (*)[4])sum0, (const int (*)[4])sum1, width - 1); + } + + return ssim / ((height - 1) * (width - 1)); +} + +static double ssim_db(double ssim, double weight) +{ + return 10 * (log(weight) / log(10) - log(weight - ssim) / log(10)); +} + +static AVFrame *do_ssim(AVFilterContext *ctx, AVFrame *main, + const AVFrame *ref) +{ + AVDictionary **metadata = avpriv_frame_get_metadatap(main); + SSIMContext *s = ctx->priv; + float c[4], ssimv = 0.0; + int i; + + s->nb_frames++; + + for (i = 0; i < s->nb_components; i++) { + c[i] = ssim_plane(&s->dsp, main->data[i], main->linesize[i], + ref->data[i], ref->linesize[i], + s->planewidth[i], s->planeheight[i], s->temp); + ssimv += s->coefs[i] * c[i]; + s->ssim[i] += c[i]; + } + for (i = 0; i < s->nb_components; i++) { + int cidx = s->is_rgb ? s->rgba_map[i] : i; + set_meta(metadata, "lavfi.ssim.", s->comps[i], c[cidx]); + } + s->ssim_total += ssimv; + + set_meta(metadata, "lavfi.ssim.All", 0, ssimv); + set_meta(metadata, "lavfi.ssim.dB", 0, ssim_db(ssimv, 1.0)); + + if (s->stats_file) { + fprintf(s->stats_file, "n:%"PRId64" ", s->nb_frames); + + for (i = 0; i < s->nb_components; i++) { + int cidx = s->is_rgb ? s->rgba_map[i] : i; + fprintf(s->stats_file, "%c:%f ", s->comps[i], c[cidx]); + } + + fprintf(s->stats_file, "All:%f (%f)\n", ssimv, ssim_db(ssimv, 1.0)); + } + + return main; +} + +static av_cold int init(AVFilterContext *ctx) +{ + SSIMContext *s = ctx->priv; + + if (s->stats_file_str) { + s->stats_file = fopen(s->stats_file_str, "w"); + if (!s->stats_file) { + int err = AVERROR(errno); + char buf[128]; + av_strerror(err, buf, sizeof(buf)); + av_log(ctx, AV_LOG_ERROR, "Could not open stats file %s: %s\n", + s->stats_file_str, buf); + return err; + } + } + + s->dinput.process = do_ssim; + s->dinput.shortest = 1; + s->dinput.repeatlast = 0; + return 0; +} + +static int query_formats(AVFilterContext *ctx) +{ + static const enum AVPixelFormat pix_fmts[] = { + AV_PIX_FMT_GRAY8, + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, + AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, + AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, + AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P, + AV_PIX_FMT_GBRP, + AV_PIX_FMT_NONE + }; + + AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts); + if (!fmts_list) + return AVERROR(ENOMEM); + return ff_set_common_formats(ctx, fmts_list); +} + +static int config_input_ref(AVFilterLink *inlink) +{ + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); + AVFilterContext *ctx = inlink->dst; + SSIMContext *s = ctx->priv; + int sum = 0, i; + + s->nb_components = desc->nb_components; + + if (ctx->inputs[0]->w != ctx->inputs[1]->w || + ctx->inputs[0]->h != ctx->inputs[1]->h) { + av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n"); + return AVERROR(EINVAL); + } + if (ctx->inputs[0]->format != ctx->inputs[1]->format) { + av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n"); + return AVERROR(EINVAL); + } + + s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0; + s->comps[0] = s->is_rgb ? 'R' : 'Y'; + s->comps[1] = s->is_rgb ? 'G' : 'U'; + s->comps[2] = s->is_rgb ? 'B' : 'V'; + s->comps[3] = 'A'; + + s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h); + s->planeheight[0] = s->planeheight[3] = inlink->h; + s->planewidth[1] = s->planewidth[2] = FF_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w); + s->planewidth[0] = s->planewidth[3] = inlink->w; + for (i = 0; i < s->nb_components; i++) + sum += s->planeheight[i] * s->planewidth[i]; + for (i = 0; i < s->nb_components; i++) + s->coefs[i] = (double) s->planeheight[i] * s->planewidth[i] / sum; + + s->temp = av_malloc((2 * inlink->w + 12) * sizeof(*s->temp)); + if (!s->temp) + return AVERROR(ENOMEM); + + s->dsp.ssim_4x4_line = ssim_4x4xn; + s->dsp.ssim_end_line = ssim_endn; + if (ARCH_X86) + ff_ssim_init_x86(&s->dsp); + + return 0; +} + +static int config_output(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + SSIMContext *s = ctx->priv; + AVFilterLink *mainlink = ctx->inputs[0]; + int ret; + + outlink->w = mainlink->w; + outlink->h = mainlink->h; + outlink->time_base = mainlink->time_base; + outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio; + outlink->frame_rate = mainlink->frame_rate; + + if ((ret = ff_dualinput_init(ctx, &s->dinput)) < 0) + return ret; + + return 0; +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *buf) +{ + SSIMContext *s = inlink->dst->priv; + return ff_dualinput_filter_frame(&s->dinput, inlink, buf); +} + +static int request_frame(AVFilterLink *outlink) +{ + SSIMContext *s = outlink->src->priv; + return ff_dualinput_request_frame(&s->dinput, outlink); +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + SSIMContext *s = ctx->priv; + + if (s->nb_frames > 0) { + char buf[256]; + int i; + buf[0] = 0; + for (i = 0; i < s->nb_components; i++) { + int c = s->is_rgb ? s->rgba_map[i] : i; + av_strlcatf(buf, sizeof(buf), " %c:%f", s->comps[i], s->ssim[c] / s->nb_frames); + } + av_log(ctx, AV_LOG_INFO, "SSIM%s All:%f (%f)\n", buf, + s->ssim_total / s->nb_frames, ssim_db(s->ssim_total, s->nb_frames)); + } + + ff_dualinput_uninit(&s->dinput); + + if (s->stats_file) + fclose(s->stats_file); + + av_freep(&s->temp); +} + +static const AVFilterPad ssim_inputs[] = { + { + .name = "main", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = filter_frame, + },{ + .name = "reference", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = filter_frame, + .config_props = config_input_ref, + }, + { NULL } +}; + +static const AVFilterPad ssim_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_output, + .request_frame = request_frame, + }, + { NULL } +}; + +AVFilter ff_vf_ssim = { + .name = "ssim", + .description = NULL_IF_CONFIG_SMALL("Calculate the SSIM between two video streams."), + .init = init, + .uninit = uninit, + .query_formats = query_formats, + .priv_size = sizeof(SSIMContext), + .priv_class = &ssim_class, + .inputs = ssim_inputs, + .outputs = ssim_outputs, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_stereo3d.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_stereo3d.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_stereo3d.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_stereo3d.c 2015-07-13 17:20:03.000000000 +0000 @@ -142,6 +142,7 @@ int pixstep[4]; AVFrame *prev; double ts_unit; + int in_off_left[4], in_off_right[4]; } Stereo3DContext; #define OFFSET(x) offsetof(Stereo3DContext, x) @@ -485,6 +486,42 @@ return av_clip_uint8(sum >> 16); } +typedef struct ThreadData { + AVFrame *ileft, *iright; + AVFrame *out; +} ThreadData; + +static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) +{ + Stereo3DContext *s = ctx->priv; + ThreadData *td = arg; + AVFrame *ileft = td->ileft; + AVFrame *iright = td->iright; + AVFrame *out = td->out; + int height = s->out.height; + int start = (height * jobnr ) / nb_jobs; + int end = (height * (jobnr+1)) / nb_jobs; + uint8_t *dst = out->data[0]; + const int **ana_matrix = s->ana_matrix; + int x, y, il, ir, o; + const uint8_t *lsrc = ileft->data[0]; + const uint8_t *rsrc = iright->data[0]; + int out_width = s->out.width; + + for (y = start; y < end; y++) { + o = out->linesize[0] * y; + il = s->in_off_left[0] + y * ileft->linesize[0]; + ir = s->in_off_right[0] + y * iright->linesize[0]; + for (x = 0; x < out_width; x++, il += 3, ir += 3, o+= 3) { + dst[o ] = ana_convert(ana_matrix[0], lsrc + il, rsrc + ir); + dst[o + 1] = ana_convert(ana_matrix[1], lsrc + il, rsrc + ir); + dst[o + 2] = ana_convert(ana_matrix[2], lsrc + il, rsrc + ir); + } + } + + return 0; +} + static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) { AVFilterContext *ctx = inlink->dst; @@ -492,7 +529,6 @@ AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out, *oleft, *oright, *ileft, *iright; int out_off_left[4], out_off_right[4]; - int in_off_left[4], in_off_right[4]; int i; switch (s->in.format) { @@ -534,8 +570,8 @@ for (i = 0; i < 4; i++) { int hsub = i == 1 || i == 2 ? s->hsub : 0; int vsub = i == 1 || i == 2 ? s->vsub : 0; - in_off_left[i] = (FF_CEIL_RSHIFT(s->in.row_left, vsub) + s->in.off_lstep) * ileft->linesize[i] + FF_CEIL_RSHIFT(s->in.off_left * s->pixstep[i], hsub); - in_off_right[i] = (FF_CEIL_RSHIFT(s->in.row_right, vsub) + s->in.off_rstep) * iright->linesize[i] + FF_CEIL_RSHIFT(s->in.off_right * s->pixstep[i], hsub); + s->in_off_left[i] = (FF_CEIL_RSHIFT(s->in.row_left, vsub) + s->in.off_lstep) * ileft->linesize[i] + FF_CEIL_RSHIFT(s->in.off_left * s->pixstep[i], hsub); + s->in_off_right[i] = (FF_CEIL_RSHIFT(s->in.row_right, vsub) + s->in.off_rstep) * iright->linesize[i] + FF_CEIL_RSHIFT(s->in.off_right * s->pixstep[i], hsub); out_off_left[i] = (FF_CEIL_RSHIFT(s->out.row_left, vsub) + s->out.off_lstep) * oleft->linesize[i] + FF_CEIL_RSHIFT(s->out.off_left * s->pixstep[i], hsub); out_off_right[i] = (FF_CEIL_RSHIFT(s->out.row_right, vsub) + s->out.off_rstep) * oright->linesize[i] + FF_CEIL_RSHIFT(s->out.off_right * s->pixstep[i], hsub); } @@ -556,12 +592,12 @@ for (i = 0; i < s->nb_planes; i++) { av_image_copy_plane(oleft->data[i] + out_off_left[i], oleft->linesize[i] * s->row_step, - ileft->data[i] + in_off_left[i], + ileft->data[i] + s->in_off_left[i], ileft->linesize[i] * s->row_step, s->linesize[i], s->pheight[i]); av_image_copy_plane(oright->data[i] + out_off_right[i], oright->linesize[i] * s->row_step, - iright->data[i] + in_off_right[i], + iright->data[i] + s->in_off_right[i], iright->linesize[i] * s->row_step, s->linesize[i], s->pheight[i]); } @@ -571,7 +607,7 @@ case MONO_R: for (i = 0; i < s->nb_planes; i++) { av_image_copy_plane(out->data[i], out->linesize[i], - iright->data[i] + in_off_left[i], + iright->data[i] + s->in_off_left[i], iright->linesize[i], s->linesize[i], s->pheight[i]); } @@ -590,23 +626,11 @@ case ANAGLYPH_YB_HALF: case ANAGLYPH_YB_COLOR: case ANAGLYPH_YB_DUBOIS: { - int x, y, il, ir, o; - const uint8_t *lsrc = ileft->data[0]; - const uint8_t *rsrc = iright->data[0]; - uint8_t *dst = out->data[0]; - int out_width = s->out.width; - const int **ana_matrix = s->ana_matrix; - - for (y = 0; y < s->out.height; y++) { - o = out->linesize[0] * y; - il = in_off_left[0] + y * ileft->linesize[0]; - ir = in_off_right[0] + y * iright->linesize[0]; - for (x = 0; x < out_width; x++, il += 3, ir += 3, o+= 3) { - dst[o ] = ana_convert(ana_matrix[0], lsrc + il, rsrc + ir); - dst[o + 1] = ana_convert(ana_matrix[1], lsrc + il, rsrc + ir); - dst[o + 2] = ana_convert(ana_matrix[2], lsrc + il, rsrc + ir); - } - } + ThreadData td; + + td.ileft = ileft; td.iright = iright; td.out = out; + ctx->internal->execute(ctx, filter_slice, &td, NULL, + FFMIN(s->out.height, ctx->graph->nb_threads)); break; } default: @@ -663,4 +687,5 @@ .inputs = stereo3d_inputs, .outputs = stereo3d_outputs, .priv_class = &stereo3d_class, + .flags = AVFILTER_FLAG_SLICE_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_transpose.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_transpose.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_transpose.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_transpose.c 2015-06-30 17:20:03.000000000 +0000 @@ -151,7 +151,7 @@ int hsub = plane == 1 || plane == 2 ? trans->hsub : 0; int vsub = plane == 1 || plane == 2 ? trans->vsub : 0; int pixstep = trans->pixsteps[plane]; - int inh = in->height >> vsub; + int inh = FF_CEIL_RSHIFT(in->height, vsub); int outw = FF_CEIL_RSHIFT(out->width, hsub); int outh = FF_CEIL_RSHIFT(out->height, vsub); int start = (outh * jobnr ) / nb_jobs; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_uspp.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_uspp.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_uspp.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_uspp.c 2015-07-28 17:20:07.000000000 +0000 @@ -351,7 +351,7 @@ avctx_enc->gop_size = INT_MAX; avctx_enc->max_b_frames = 0; avctx_enc->pix_fmt = inlink->format; - avctx_enc->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_LOW_DELAY; + avctx_enc->flags = AV_CODEC_FLAG_QSCALE | CODEC_FLAG_LOW_DELAY; avctx_enc->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; avctx_enc->global_quality = 123; av_dict_set(&opts, "no_bitstream", "1", 0); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_w3fdif.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_w3fdif.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_w3fdif.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_w3fdif.c 2015-07-13 17:20:03.000000000 +0000 @@ -40,7 +40,8 @@ int eof; int nb_planes; AVFrame *prev, *cur, *next; ///< previous, current, next frames - int32_t *work_line; ///< line we are calculating + int32_t **work_line; ///< lines we are calculating + int nb_threads; } W3FDIFContext; #define OFFSET(x) offsetof(W3FDIFContext, x) @@ -82,9 +83,10 @@ static int config_input(AVFilterLink *inlink) { - W3FDIFContext *s = inlink->dst->priv; + AVFilterContext *ctx = inlink->dst; + W3FDIFContext *s = ctx->priv; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); - int ret; + int ret, i; if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0) return ret; @@ -93,10 +95,17 @@ s->planeheight[0] = s->planeheight[3] = inlink->h; s->nb_planes = av_pix_fmt_count_planes(inlink->format); - s->work_line = av_calloc(s->linesize[0], sizeof(*s->work_line)); + s->nb_threads = ctx->graph->nb_threads; + s->work_line = av_calloc(s->nb_threads, sizeof(*s->work_line)); if (!s->work_line) return AVERROR(ENOMEM); + for (i = 0; i < s->nb_threads; i++) { + s->work_line[i] = av_calloc(s->linesize[0], sizeof(*s->work_line[0])); + if (!s->work_line[i]) + return AVERROR(ENOMEM); + } + return 0; } @@ -128,11 +137,20 @@ static const int32_t coef_hf[2][5] = {{ -4096, 8192, -4096, 0, 0}, { 2032, -7602, 11140, -7602, 2032}}; -static void deinterlace_plane(AVFilterContext *ctx, AVFrame *out, - const AVFrame *cur, const AVFrame *adj, - const int filter, const int plane) +typedef struct ThreadData { + AVFrame *out, *cur, *adj; + int plane; +} ThreadData; + +static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) { W3FDIFContext *s = ctx->priv; + ThreadData *td = arg; + AVFrame *out = td->out; + AVFrame *cur = td->cur; + AVFrame *adj = td->adj; + const int plane = td->plane; + const int filter = s->filter; uint8_t *in_line, *in_lines_cur[5], *in_lines_adj[5]; uint8_t *out_line, *out_pixel; int32_t *work_line, *work_pixel; @@ -144,15 +162,17 @@ const int cur_line_stride = cur->linesize[plane]; const int adj_line_stride = adj->linesize[plane]; const int dst_line_stride = out->linesize[plane]; + const int start = (height * jobnr) / nb_jobs; + const int end = (height * (jobnr+1)) / nb_jobs; int i, j, y_in, y_out; /* copy unchanged the lines of the field */ - y_out = s->field == cur->top_field_first; + y_out = start + (s->field == cur->top_field_first) - (start & 1); in_line = cur_data + (y_out * cur_line_stride); out_line = dst_data + (y_out * dst_line_stride); - while (y_out < height) { + while (y_out < end) { memcpy(out_line, in_line, linesize); y_out += 2; in_line += cur_line_stride * 2; @@ -160,13 +180,13 @@ } /* interpolate other lines of the field */ - y_out = s->field != cur->top_field_first; + y_out = start + (s->field != cur->top_field_first) - (start & 1); out_line = dst_data + (y_out * dst_line_stride); - while (y_out < height) { + while (y_out < end) { /* clear workspace */ - memset(s->work_line, 0, sizeof(*s->work_line) * linesize); + memset(s->work_line[jobnr], 0, sizeof(*s->work_line[jobnr]) * linesize); /* get low vertical frequencies from current field */ for (j = 0; j < n_coef_lf[filter]; j++) { @@ -180,7 +200,7 @@ in_lines_cur[j] = cur_data + (y_in * cur_line_stride); } - work_line = s->work_line; + work_line = s->work_line[jobnr]; switch (n_coef_lf[filter]) { case 2: for (i = 0; i < linesize; i++) { @@ -210,7 +230,7 @@ in_lines_adj[j] = adj_data + (y_in * adj_line_stride); } - work_line = s->work_line; + work_line = s->work_line[jobnr]; switch (n_coef_hf[filter]) { case 3: for (i = 0; i < linesize; i++) { @@ -238,7 +258,7 @@ } /* save scaled result to the output frame, scaling down by 256 * 256 */ - work_pixel = s->work_line; + work_pixel = s->work_line[jobnr]; out_pixel = out_line; for (j = 0; j < linesize; j++, out_pixel++, work_pixel++) @@ -248,6 +268,8 @@ y_out += 2; out_line += dst_line_stride * 2; } + + return 0; } static int filter(AVFilterContext *ctx, int is_second) @@ -255,6 +277,7 @@ W3FDIFContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out, *adj; + ThreadData td; int plane; out = ff_get_video_buffer(outlink, outlink->w, outlink->h); @@ -278,8 +301,11 @@ } adj = s->field ? s->next : s->prev; - for (plane = 0; plane < s->nb_planes; plane++) - deinterlace_plane(ctx, out, s->cur, adj, s->filter, plane); + td.out = out; td.cur = s->cur; td.adj = adj; + for (plane = 0; plane < s->nb_planes; plane++) { + td.plane = plane; + ctx->internal->execute(ctx, deinterlace_slice, &td, NULL, FFMIN(s->planeheight[plane], s->nb_threads)); + } s->field = !s->field; @@ -355,10 +381,15 @@ static av_cold void uninit(AVFilterContext *ctx) { W3FDIFContext *s = ctx->priv; + int i; av_frame_free(&s->prev); av_frame_free(&s->cur ); av_frame_free(&s->next); + + for (i = 0; i < s->nb_threads; i++) + av_freep(&s->work_line[i]); + av_freep(&s->work_line); } @@ -391,5 +422,5 @@ .query_formats = query_formats, .inputs = w3fdif_inputs, .outputs = w3fdif_outputs, - .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL, + .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_zoompan.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_zoompan.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vf_zoompan.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vf_zoompan.c 2015-06-12 17:20:03.000000000 +0000 @@ -262,6 +262,7 @@ AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ411P, + AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/vsrc_testsrc.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/vsrc_testsrc.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/vsrc_testsrc.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/vsrc_testsrc.c 2015-08-02 17:20:02.000000000 +0000 @@ -30,7 +30,7 @@ * rgbtestsrc is ported from MPlayer libmpcodecs/vf_rgbtest.c by * Michael Niedermayer. * - * smptebars and smptehdbars are by Paul B Mahol. + * allyuv, smptebars and smptehdbars are by Paul B Mahol. */ #include @@ -1080,3 +1080,84 @@ #endif /* CONFIG_SMPTEHDBARS_FILTER */ #endif /* CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER */ + +#if CONFIG_ALLYUV_FILTER + +static const AVOption allyuv_options[] = { + COMMON_OPTIONS_NOSIZE + { NULL } +}; + +AVFILTER_DEFINE_CLASS(allyuv); + +static void allyuv_fill_picture(AVFilterContext *ctx, AVFrame *frame) +{ + const int ys = frame->linesize[0]; + const int us = frame->linesize[1]; + const int vs = frame->linesize[2]; + int x, y, j; + + for (y = 0; y < 4096; y++) { + for (x = 0; x < 2048; x++) { + frame->data[0][y * ys + x] = ((x / 8) % 256); + frame->data[0][y * ys + 4095 - x] = ((x / 8) % 256); + } + + for (x = 0; x < 2048; x+=8) { + for (j = 0; j < 8; j++) { + frame->data[1][vs * y + x + j] = (y%16 + (j % 8) * 16); + frame->data[1][vs * y + 4095 - x - j] = (128 + y%16 + (j % 8) * 16); + } + } + + for (x = 0; x < 4096; x++) + frame->data[2][y * us + x] = 256 * y / 4096; + } +} + +static av_cold int allyuv_init(AVFilterContext *ctx) +{ + TestSourceContext *test = ctx->priv; + + test->w = test->h = 4096; + test->draw_once = 1; + test->fill_picture_fn = allyuv_fill_picture; + return init(ctx); +} + +static int allyuv_query_formats(AVFilterContext *ctx) +{ + static const enum AVPixelFormat pix_fmts[] = { + AV_PIX_FMT_YUV444P, AV_PIX_FMT_GBRP, + AV_PIX_FMT_NONE + }; + + AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts); + if (!fmts_list) + return AVERROR(ENOMEM); + return ff_set_common_formats(ctx, fmts_list); +} + +static const AVFilterPad avfilter_vsrc_allyuv_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .request_frame = request_frame, + .config_props = config_props, + }, + { NULL } +}; + +AVFilter ff_vsrc_allyuv = { + .name = "allyuv", + .description = NULL_IF_CONFIG_SMALL("Generate all yuv colors."), + .priv_size = sizeof(TestSourceContext), + .priv_class = &allyuv_class, + .init = allyuv_init, + .uninit = uninit, + .query_formats = allyuv_query_formats, + .inputs = NULL, + .outputs = avfilter_vsrc_allyuv_outputs, +}; + +#endif /* CONFIG_ALLYUV_FILTER */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/Makefile ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/Makefile --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/Makefile 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/Makefile 2015-07-15 17:20:03.000000000 +0000 @@ -6,8 +6,11 @@ OBJS-$(CONFIG_INTERLACE_FILTER) += x86/vf_interlace_init.o OBJS-$(CONFIG_NOISE_FILTER) += x86/vf_noise.o OBJS-$(CONFIG_PP7_FILTER) += x86/vf_pp7_init.o +OBJS-$(CONFIG_PSNR_FILTER) += x86/vf_psnr_init.o OBJS-$(CONFIG_PULLUP_FILTER) += x86/vf_pullup_init.o +OBJS-$(CONFIG_REMOVEGRAIN_FILTER) += x86/vf_removegrain_init.o OBJS-$(CONFIG_SPP_FILTER) += x86/vf_spp.o +OBJS-$(CONFIG_SSIM_FILTER) += x86/vf_ssim_init.o OBJS-$(CONFIG_TINTERLACE_FILTER) += x86/vf_tinterlace_init.o OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume_init.o OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif_init.o @@ -18,7 +21,12 @@ YASM-OBJS-$(CONFIG_IDET_FILTER) += x86/vf_idet.o YASM-OBJS-$(CONFIG_INTERLACE_FILTER) += x86/vf_interlace.o YASM-OBJS-$(CONFIG_PP7_FILTER) += x86/vf_pp7.o +YASM-OBJS-$(CONFIG_PSNR_FILTER) += x86/vf_psnr.o YASM-OBJS-$(CONFIG_PULLUP_FILTER) += x86/vf_pullup.o +ifdef CONFIG_GPL +YASM-OBJS-$(CONFIG_REMOVEGRAIN_FILTER) += x86/vf_removegrain.o +endif +YASM-OBJS-$(CONFIG_SSIM_FILTER) += x86/vf_ssim.o YASM-OBJS-$(CONFIG_TINTERLACE_FILTER) += x86/vf_interlace.o YASM-OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume.o YASM-OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif.o x86/yadif-16.o x86/yadif-10.o diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_interlace.asm ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_interlace.asm --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_interlace.asm 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_interlace.asm 2015-07-26 17:20:03.000000000 +0000 @@ -37,7 +37,7 @@ pcmpeqb m6, m6 -.loop +.loop: mova m0, [r3+r1] mova m1, [r3+r1+mmsize] pavgb m0, [r4+r1] diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_psnr.asm ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_psnr.asm --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_psnr.asm 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_psnr.asm 2015-07-15 17:20:03.000000000 +0000 @@ -0,0 +1,140 @@ +;***************************************************************************** +;* x86-optimized functions for interlace filter +;* +;* Copyright (C) 2015 Ronald S. Bultje +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "libavutil/x86/x86util.asm" + +SECTION .text + +%macro SSE_LINE_FN 2 ; 8 or 16, byte or word +INIT_XMM sse2 +%if ARCH_X86_32 +%if %1 == 8 +cglobal sse_line_%1 %+ bit, 0, 6, 8, res, buf, w, px1, px2, ref +%else +cglobal sse_line_%1 %+ bit, 0, 7, 8, res, buf, reshigh, w, px1, px2, ref +%endif + mov bufq, r0mp + mov refq, r1mp + mov wd, r2m +%else +cglobal sse_line_%1 %+ bit, 3, 5, 8, buf, ref, w, px1, px2 +%endif + pxor m6, m6 + pxor m7, m7 + sub wd, mmsize*2 + jl .end + +.loop: + movu m0, [bufq+mmsize*0] + movu m1, [bufq+mmsize*1] + movu m2, [refq+mmsize*0] + movu m3, [refq+mmsize*1] +%if %1 == 8 + add bufq, mmsize*2 + add refq, mmsize*2 + psubusb m4, m0, m2 + psubusb m5, m1, m3 + psubusb m2, m0 + psubusb m3, m1 + por m2, m4 + por m3, m5 + punpcklbw m0, m2, m6 + punpcklbw m1, m3, m6 + punpckhbw m2, m6 + punpckhbw m3, m6 +%else + psubw m0, m2 + psubw m1, m3 + movu m2, [bufq+mmsize*2] + movu m3, [bufq+mmsize*3] + movu m4, [refq+mmsize*2] + movu m5, [refq+mmsize*3] + psubw m2, m4 + psubw m3, m5 + add bufq, mmsize*4 + add refq, mmsize*4 +%endif + pmaddwd m0, m0 + pmaddwd m1, m1 + pmaddwd m2, m2 + pmaddwd m3, m3 + paddd m0, m1 + paddd m2, m3 +%if %1 == 8 + paddd m7, m0 + paddd m7, m2 +%else + paddd m0, m2 + punpckldq m2, m0, m6 + punpckhdq m0, m6 + paddq m7, m0 + paddq m7, m2 +%endif + sub wd, mmsize*2 + jge .loop + +.end: + add wd, mmsize*2 + movhlps m0, m7 +%if %1 == 8 + paddd m7, m0 + pshufd m0, m7, 1 + paddd m7, m0 + movd eax, m7 +%else + paddq m7, m0 +%if ARCH_X86_32 + movd eax, m7 + psrldq m7, 4 + movd edx, m7 +%else + movq rax, m7 +%endif +%endif + + ; deal with cases where w % 32 != 0 + test wd, wd + jz .end_scalar +.loop_scalar: + movzx px1d, %2 [bufq+wq*(%1/8)-(%1/8)] + movzx px2d, %2 [refq+wq*(%1/8)-(%1/8)] + sub px1d, px2d + imul px1d, px1d +%if %1 == 8 + add eax, px1d +%elif ARCH_X86_64 + add rax, px1q +%else + add eax, px1d + adc edx, 0 +%endif + dec wd + jg .loop_scalar + +.end_scalar: + ; for %1=8, no need to zero edx on x86-32, since edx=wd, which is zero + RET +%endmacro + +INIT_XMM sse2 +SSE_LINE_FN 8, byte +SSE_LINE_FN 16, word diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_psnr_init.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_psnr_init.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_psnr_init.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_psnr_init.c 2015-07-14 17:20:02.000000000 +0000 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2015 Ronald S. Bultje + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/x86/cpu.h" + +#include "libavfilter/psnr.h" + +uint64_t ff_sse_line_8bit_sse2(const uint8_t *buf, const uint8_t *ref, int w); +uint64_t ff_sse_line_16bit_sse2(const uint8_t *buf, const uint8_t *ref, int w); + +void ff_psnr_init_x86(PSNRDSPContext *dsp, int bpp) +{ + int cpu_flags = av_get_cpu_flags(); + + if (EXTERNAL_SSE2(cpu_flags)) { + if (bpp <= 8) { + dsp->sse_line = ff_sse_line_8bit_sse2; + } else if (bpp <= 15) { + dsp->sse_line = ff_sse_line_16bit_sse2; + } + } +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_removegrain.asm ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_removegrain.asm --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_removegrain.asm 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_removegrain.asm 2015-07-15 17:20:03.000000000 +0000 @@ -0,0 +1,1218 @@ +;***************************************************************************** +;* x86-optimized functions for removegrain filter +;* +;* Copyright (C) 2015 James Darnley +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or modify +;* it under the terms of the GNU General Public License as published by +;* the Free Software Foundation; either version 2 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 General Public License for more details. +;* +;* You should have received a copy of the GNU 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. +;***************************************************************************** + +; column: -1 0 +1 +; row -1: a1 a2 a3 +; row 0: a4 c a5 +; row +1: a6 a7 a8 + +%include "libavutil/x86/x86util.asm" + +SECTION_RODATA 32 + +pw_4: times 16 dw 4 +pw_8: times 16 dw 8 +pw_div9: times 16 dw ((1<<16)+4)/9 + +SECTION_TEXT + +;*** Preprocessor helpers + +%define a1 srcq+stride_n-1 +%define a2 srcq+stride_n +%define a3 srcq+stride_n+1 +%define a4 srcq-1 +%define c srcq +%define a5 srcq+1 +%define a6 srcq+stride_p-1 +%define a7 srcq+stride_p +%define a8 srcq+stride_p+1 + +; %1 dest simd register +; %2 source memory location +; %3 zero location (simd register/memory) +%macro LOAD 3 + movh %1, %2 + punpcklbw %1, %3 +%endmacro + +%macro LOAD_SQUARE 0 + movu m1, [a1] + movu m2, [a2] + movu m3, [a3] + movu m4, [a4] + movu m0, [c] + movu m5, [a5] + movu m6, [a6] + movu m7, [a7] + movu m8, [a8] +%endmacro + +; %1 zero location (simd register/memory) +%macro LOAD_SQUARE_16 1 + LOAD m1, [a1], %1 + LOAD m2, [a2], %1 + LOAD m3, [a3], %1 + LOAD m4, [a4], %1 + LOAD m0, [c], %1 + LOAD m5, [a5], %1 + LOAD m6, [a6], %1 + LOAD m7, [a7], %1 + LOAD m8, [a8], %1 +%endmacro + +; %1 data type +; %2 simd register to hold maximums +; %3 simd register to hold minimums +; %4 temp location (simd register/memory) +%macro SORT_PAIR 4 + mova %4, %2 + pmin%1 %2, %3 + pmax%1 %3, %4 +%endmacro + +%macro SORT_AXIS 0 + SORT_PAIR ub, m1, m8, m9 + SORT_PAIR ub, m2, m7, m10 + SORT_PAIR ub, m3, m6, m11 + SORT_PAIR ub, m4, m5, m12 +%endmacro + + +%macro SORT_AXIS_16 0 + SORT_PAIR sw, m1, m8, m9 + SORT_PAIR sw, m2, m7, m10 + SORT_PAIR sw, m3, m6, m11 + SORT_PAIR sw, m4, m5, m12 +%endmacro + +; The loop doesn't need to do all the iterations. It could stop when the right +; pixels are in the right registers. +%macro SORT_SQUARE 0 + %assign k 7 + %rep 7 + %assign i 1 + %assign j 2 + %rep k + SORT_PAIR ub, m %+ i , m %+ j , m9 + %assign i i+1 + %assign j j+1 + %endrep + %assign k k-1 + %endrep +%endmacro + +; %1 dest simd register +; %2 source (simd register/memory) +; %3 temp simd register +%macro ABS_DIFF 3 + mova %3, %2 + psubusb %3, %1 + psubusb %1, %2 + por %1, %3 +%endmacro + +; %1 dest simd register +; %2 source (simd register/memory) +; %3 temp simd register +%macro ABS_DIFF_W 3 + mova %3, %2 + psubusw %3, %1 + psubusw %1, %2 + por %1, %3 +%endmacro + +; %1 simd register that holds the "false" values and will hold the result +; %2 simd register that holds the "true" values +; %3 location (simd register/memory) that hold the mask +%macro BLEND 3 +%if cpuflag(avx2) + vpblendvb %1, %1, %2, %3 +%else + pand %2, %3 + pandn %3, %1 + por %3, %2 + SWAP %1, %3 +%endif +%endmacro + +; Functions + +INIT_XMM sse2 +cglobal rg_fl_mode_1, 4, 5, 3, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + .loop: + movu m0, [a1] + mova m1, m0 + + movu m2, [a2] + pmaxub m0, m2 + pminub m1, m2 + + movu m2, [a3] + pmaxub m0, m2 + pminub m1, m2 + + movu m2, [a4] + pmaxub m0, m2 + pminub m1, m2 + + movu m2, [a5] + pmaxub m0, m2 + pminub m1, m2 + + movu m2, [a6] + pmaxub m0, m2 + pminub m1, m2 + + movu m2, [a7] + pmaxub m0, m2 + pminub m1, m2 + + movu m2, [a8] + pmaxub m0, m2 + pminub m1, m2 + + movu m2, [c] + pminub m2, m0 + pmaxub m2, m1 + + movu [dstq], m2 + add srcq, mmsize + add dstq, mmsize + sub pixelsd, mmsize + jg .loop +RET + +%if ARCH_X86_64 +cglobal rg_fl_mode_2, 4, 5, 10, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + .loop: + LOAD_SQUARE + SORT_SQUARE + + CLIPUB m0, m2, m7 + + movu [dstq], m0 + add srcq, mmsize + add dstq, mmsize + sub pixelsd, mmsize + jg .loop +RET + +cglobal rg_fl_mode_3, 4, 5, 10, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + .loop: + LOAD_SQUARE + SORT_SQUARE + + CLIPUB m0, m3, m6 + + movu [dstq], m0 + add srcq, mmsize + add dstq, mmsize + sub pixelsd, mmsize + jg .loop +RET + +cglobal rg_fl_mode_4, 4, 5, 10, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + .loop: + LOAD_SQUARE + SORT_SQUARE + + CLIPUB m0, m4, m5 + + movu [dstq], m0 + add srcq, mmsize + add dstq, mmsize + sub pixelsd, mmsize + jg .loop +RET + +cglobal rg_fl_mode_5, 4, 5, 13, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + .loop: + LOAD_SQUARE + SORT_AXIS + + mova m9, m0 + mova m10, m0 + mova m11, m0 + mova m12, m0 + + CLIPUB m9, m1, m8 + CLIPUB m10, m2, m7 + CLIPUB m11, m3, m6 + CLIPUB m12, m4, m5 + + mova m8, m9 ; clip1 + mova m7, m10 ; clip2 + mova m6, m11 ; clip3 + mova m5, m12 ; clip4 + + ABS_DIFF m9, m0, m1 ; c1 + ABS_DIFF m10, m0, m2 ; c2 + ABS_DIFF m11, m0, m3 ; c3 + ABS_DIFF m12, m0, m4 ; c4 + + pminub m9, m10 + pminub m9, m11 + pminub m9, m12 ; mindiff + + pcmpeqb m10, m9 + pcmpeqb m11, m9 + pcmpeqb m12, m9 + + ; Notice the order here: c1, c3, c2, c4 + BLEND m8, m6, m11 + BLEND m8, m7, m10 + BLEND m8, m5, m12 + + movu [dstq], m8 + add srcq, mmsize + add dstq, mmsize + sub pixelsd, mmsize + jg .loop +RET + +cglobal rg_fl_mode_6, 4, 5, 16, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + ; Some register saving suggestions: the zero can be somewhere other than a + ; register, the center pixels could be on the stack. + + pxor m15, m15 + .loop: + LOAD_SQUARE_16 m15 + SORT_AXIS_16 + + mova m9, m0 + mova m10, m0 + mova m11, m0 + mova m12, m0 + CLIPW m9, m1, m8 ; clip1 + CLIPW m10, m2, m7 ; clip2 + CLIPW m11, m3, m6 ; clip3 + CLIPW m12, m4, m5 ; clip4 + + psubw m8, m1 ; d1 + psubw m7, m2 ; d2 + psubw m6, m3 ; d3 + psubw m5, m4 ; d4 + + mova m1, m9 + mova m2, m10 + mova m3, m11 + mova m4, m12 + ABS_DIFF_W m1, m0, m13 + ABS_DIFF_W m2, m0, m14 + ABS_DIFF_W m3, m0, m13 + ABS_DIFF_W m4, m0, m14 + psllw m1, 1 + psllw m2, 1 + psllw m3, 1 + psllw m4, 1 + paddw m1, m8 ; c1 + paddw m2, m7 ; c2 + paddw m3, m6 ; c3 + paddw m4, m5 ; c4 + ; As the differences (d1..d4) can only be postive, there is no need to + ; clip to zero. Also, the maximum positive value is less than 768. + + pminsw m1, m2 + pminsw m1, m3 + pminsw m1, m4 + + pcmpeqw m2, m1 + pcmpeqw m3, m1 + pcmpeqw m4, m1 + + BLEND m9, m11, m3 + BLEND m9, m10, m2 + BLEND m9, m12, m4 + packuswb m9, m9 + + movh [dstq], m9 + add srcq, mmsize/2 + add dstq, mmsize/2 + sub pixelsd, mmsize/2 + jg .loop +RET + +; This is just copy-pasted straight from mode 6 with the left shifts removed. +cglobal rg_fl_mode_7, 4, 5, 16, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + ; Can this be done without unpacking? + + pxor m15, m15 + .loop: + LOAD_SQUARE_16 m15 + SORT_AXIS_16 + + mova m9, m0 + mova m10, m0 + mova m11, m0 + mova m12, m0 + CLIPW m9, m1, m8 ; clip1 + CLIPW m10, m2, m7 ; clip2 + CLIPW m11, m3, m6 ; clip3 + CLIPW m12, m4, m5 ; clip4 + + psubw m8, m1 ; d1 + psubw m7, m2 ; d2 + psubw m6, m3 ; d3 + psubw m5, m4 ; d4 + + mova m1, m9 + mova m2, m10 + mova m3, m11 + mova m4, m12 + ABS_DIFF_W m1, m0, m13 + ABS_DIFF_W m2, m0, m14 + ABS_DIFF_W m3, m0, m13 + ABS_DIFF_W m4, m0, m14 + paddw m1, m8 ; c1 + paddw m2, m7 ; c2 + paddw m3, m6 ; c3 + paddw m4, m5 ; c4 + + pminsw m1, m2 + pminsw m1, m3 + pminsw m1, m4 + + pcmpeqw m2, m1 + pcmpeqw m3, m1 + pcmpeqw m4, m1 + + BLEND m9, m11, m3 + BLEND m9, m10, m2 + BLEND m9, m12, m4 + packuswb m9, m9 + + movh [dstq], m9 + add srcq, mmsize/2 + add dstq, mmsize/2 + sub pixelsd, mmsize/2 + jg .loop +RET + +; This is just copy-pasted straight from mode 6 with a few changes. +cglobal rg_fl_mode_8, 4, 5, 16, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + pxor m15, m15 + .loop: + LOAD_SQUARE_16 m15 + SORT_AXIS_16 + + mova m9, m0 + mova m10, m0 + mova m11, m0 + mova m12, m0 + CLIPW m9, m1, m8 ; clip1 + CLIPW m10, m2, m7 ; clip2 + CLIPW m11, m3, m6 ; clip3 + CLIPW m12, m4, m5 ; clip4 + + psubw m8, m1 ; d1 + psubw m7, m2 ; d2 + psubw m6, m3 ; d3 + psubw m5, m4 ; d4 + psllw m8, 1 + psllw m7, 1 + psllw m6, 1 + psllw m5, 1 + + mova m1, m9 + mova m2, m10 + mova m3, m11 + mova m4, m12 + ABS_DIFF_W m1, m0, m13 + ABS_DIFF_W m2, m0, m14 + ABS_DIFF_W m3, m0, m13 + ABS_DIFF_W m4, m0, m14 + paddw m1, m8 ; c1 + paddw m2, m7 ; c1 + paddw m3, m6 ; c1 + paddw m4, m5 ; c1 + ; As the differences (d1..d4) can only be postive, there is no need to + ; clip to zero. Also, the maximum positive value is less than 768. + + pminsw m1, m2 + pminsw m1, m3 + pminsw m1, m4 + + pcmpeqw m2, m1 + pcmpeqw m3, m1 + pcmpeqw m4, m1 + + BLEND m9, m11, m3 + BLEND m9, m10, m2 + BLEND m9, m12, m4 + packuswb m9, m9 + + movh [dstq], m9 + add srcq, mmsize/2 + add dstq, mmsize/2 + sub pixelsd, mmsize/2 + jg .loop +RET + +cglobal rg_fl_mode_9, 4, 5, 13, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + .loop: + LOAD_SQUARE + SORT_AXIS + + mova m9, m0 + mova m10, m0 + mova m11, m0 + mova m12, m0 + CLIPUB m9, m1, m8 ; clip1 + CLIPUB m10, m2, m7 ; clip2 + CLIPUB m11, m3, m6 ; clip3 + CLIPUB m12, m4, m5 ; clip4 + + psubb m8, m1 ; d1 + psubb m7, m2 ; d2 + psubb m6, m3 ; d3 + psubb m5, m4 ; d4 + + pminub m8, m7 + pminub m8, m6 + pminub m8, m5 + + pcmpeqb m7, m8 + pcmpeqb m6, m8 + pcmpeqb m5, m8 + + BLEND m9, m11, m6 + BLEND m9, m10, m7 + BLEND m9, m12, m5 + + movu [dstq], m9 + add srcq, mmsize + add dstq, mmsize + sub pixelsd, mmsize + jg .loop +RET +%endif + +cglobal rg_fl_mode_10, 4, 5, 8, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + .loop: + movu m0, [c] + + movu m1, [a4] + mova m2, m1 + ABS_DIFF m1, m0, m7 + + movu m3, [a5] ; load pixel + mova m4, m3 + ABS_DIFF m4, m0, m7 ; absolute difference from center + pminub m1, m4 ; mindiff + pcmpeqb m4, m1 ; if (difference == mindiff) + BLEND m2, m3, m4 ; return pixel + + movu m5, [a1] + mova m6, m5 + ABS_DIFF m6, m0, m7 + pminub m1, m6 + pcmpeqb m6, m1 + BLEND m2, m5, m6 + + movu m3, [a3] + mova m4, m3 + ABS_DIFF m4, m0, m7 + pminub m1, m4 + pcmpeqb m4, m1 + BLEND m2, m3, m4 + + movu m5, [a2] + mova m6, m5 + ABS_DIFF m6, m0, m7 + pminub m1, m6 + pcmpeqb m6, m1 + BLEND m2, m5, m6 + + movu m3, [a6] + mova m4, m3 + ABS_DIFF m4, m0, m7 + pminub m1, m4 + pcmpeqb m4, m1 + BLEND m2, m3, m4 + + movu m5, [a8] + mova m6, m5 + ABS_DIFF m6, m0, m7 + pminub m1, m6 + pcmpeqb m6, m1 + BLEND m2, m5, m6 + + movu m3, [a7] + mova m4, m3 + ABS_DIFF m4, m0, m7 + pminub m1, m4 + pcmpeqb m4, m1 + BLEND m2, m3, m4 + + movu [dstq], m2 + add srcq, mmsize + add dstq, mmsize + sub pixelsd, mmsize + jg .loop +RET + +cglobal rg_fl_mode_11_12, 4, 5, 7, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + pxor m0, m0 + .loop: + LOAD m1, [c], m0 + LOAD m2, [a2], m0 + LOAD m3, [a4], m0 + LOAD m4, [a5], m0 + LOAD m5, [a7], m0 + + psllw m1, 2 + paddw m2, m3 + paddw m4, m5 + paddw m2, m4 + psllw m2, 1 + + LOAD m3, [a1], m0 + LOAD m4, [a3], m0 + LOAD m5, [a6], m0 + LOAD m6, [a8], m0 + paddw m1, m2 + paddw m3, m4 + paddw m5, m6 + paddw m1, m3 + paddw m1, m5 + + paddw m1, [pw_8] + psraw m1, 4 + + packuswb m1, m1 + + movh [dstq], m1 + add srcq, mmsize/2 + add dstq, mmsize/2 + sub pixelsd, mmsize/2 + jg .loop +RET + +cglobal rg_fl_mode_13_14, 4, 5, 8, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + .loop: + movu m1, [a1] + movu m2, [a8] + mova m0, m1 + pavgb m1, m2 + ABS_DIFF m0, m2, m6 + + movu m3, [a3] + movu m4, [a6] + mova m5, m3 + pavgb m3, m4 + ABS_DIFF m5, m4, m7 + pminub m0, m5 + pcmpeqb m5, m0 + BLEND m1, m3, m5 + + movu m2, [a2] + movu m3, [a7] + mova m4, m2 + pavgb m2, m3 + ABS_DIFF m4, m3, m6 + pminub m0, m4 + pcmpeqb m4, m0 + BLEND m1, m2, m4 + + movu [dstq], m1 + add srcq, mmsize + add dstq, mmsize + sub pixelsd, mmsize + jg .loop +RET + +%if ARCH_X86_64 +cglobal rg_fl_mode_15_16, 4, 5, 16, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + pxor m15, m15 + .loop: + LOAD_SQUARE_16 m15 + + mova m9, m1 + mova m10, m2 + mova m11, m3 + ABS_DIFF_W m9, m8, m12 + ABS_DIFF_W m10, m7, m13 + ABS_DIFF_W m11, m6, m14 + pminsw m9, m10 + pminsw m9, m11 + pcmpeqw m10, m9 + pcmpeqw m11, m9 + + mova m12, m2 + mova m13, m1 + mova m14, m6 + paddw m12, m7 + psllw m12, 1 + paddw m13, m3 + paddw m14, m8 + paddw m12, [pw_4] + paddw m13, m14 + paddw m12, m13 + psrlw m12, 3 + + SORT_PAIR ub, m1, m8, m0 + SORT_PAIR ub, m2, m7, m9 + SORT_PAIR ub, m3, m6, m14 + mova m4, m12 + mova m5, m12 + CLIPW m4, m1, m8 + CLIPW m5, m2, m7 + CLIPW m12, m3, m6 + + BLEND m4, m12, m11 + BLEND m4, m5, m10 + packuswb m4, m4 + + movh [dstq], m4 + add srcq, mmsize/2 + add dstq, mmsize/2 + sub pixelsd, mmsize/2 + jg .loop +RET + +cglobal rg_fl_mode_17, 4, 5, 9, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + .loop: + LOAD_SQUARE + SORT_AXIS + + pmaxub m1, m2 + pmaxub m3, m4 + + pminub m8, m7 + pminub m5, m6 + + pmaxub m1, m3 + pminub m8, m5 + + mova m2, m1 + pminub m1, m8 + pmaxub m8, m2 + + CLIPUB m0, m1, m8 + + movu [dstq], m0 + add srcq, mmsize + add dstq, mmsize + sub pixelsd, mmsize + jg .loop +RET + +cglobal rg_fl_mode_18, 4, 5, 16, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + .loop: + LOAD_SQUARE + + mova m9, m1 + mova m10, m8 + ABS_DIFF m9, m0, m11 + ABS_DIFF m10, m0, m12 + pmaxub m9, m10 ; m9 = d1 + + mova m10, m2 + mova m11, m7 + ABS_DIFF m10, m0, m12 + ABS_DIFF m11, m0, m13 + pmaxub m10, m11 ; m10 = d2 + + mova m11, m3 + mova m12, m6 + ABS_DIFF m11, m0, m13 + ABS_DIFF m12, m0, m14 + pmaxub m11, m12 ; m11 = d3 + + mova m12, m4 + mova m13, m5 + ABS_DIFF m12, m0, m14 + ABS_DIFF m13, m0, m15 + pmaxub m12, m13 ; m12 = d4 + + mova m13, m9 + pminub m13, m10 + pminub m13, m11 + pminub m13, m12 ; m13 = mindiff + + pcmpeqb m10, m13 + pcmpeqb m11, m13 + pcmpeqb m12, m13 + + mova m14, m1 + pminub m1, m8 + pmaxub m8, m14 + + mova m13, m0 + mova m14, m1 + pminub m1, m8 + pmaxub m8, m14 + CLIPUB m13, m1, m8 ; m13 = ret...d1 + + mova m14, m0 + mova m15, m3 + pminub m3, m6 + pmaxub m6, m15 + CLIPUB m14, m3, m6 + pand m14, m11 + pandn m11, m13 + por m14, m11 ; m14 = ret...d3 + + mova m15, m0 + mova m1, m2 + pminub m2, m7 + pmaxub m7, m1 + CLIPUB m15, m2, m7 + pand m15, m10 + pandn m10, m14 + por m15, m10 ; m15 = ret...d2 + + mova m1, m0 + mova m2, m4 + pminub m4, m5 + pmaxub m5, m2 + CLIPUB m1, m4, m5 + pand m1, m12 + pandn m12, m15 + por m1, m12 ; m15 = ret...d4 + + movu [dstq], m1 + add srcq, mmsize + add dstq, mmsize + sub pixelsd, mmsize + jg .loop +RET +%endif + +cglobal rg_fl_mode_19, 4, 5, 7, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + pxor m0, m0 + .loop: + LOAD m1, [a1], m0 + LOAD m2, [a2], m0 + paddw m1, m2 + + LOAD m3, [a3], m0 + LOAD m4, [a4], m0 + paddw m3, m4 + + LOAD m5, [a5], m0 + LOAD m6, [a6], m0 + paddw m5, m6 + + LOAD m2, [a7], m0 + LOAD m4, [a8], m0 + paddw m2, m4 + + paddw m1, m3 + paddw m2, m5 + paddw m1, m2 + + paddw m1, [pw_4] + psraw m1, 3 + + packuswb m1, m1 + + movh [dstq], m1 + add srcq, mmsize/2 + add dstq, mmsize/2 + sub pixelsd, mmsize/2 + jg .loop +RET + +cglobal rg_fl_mode_20, 4, 5, 7, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + pxor m0, m0 + .loop: + LOAD m1, [a1], m0 + LOAD m2, [a2], m0 + paddw m1, m2 + + LOAD m3, [a3], m0 + LOAD m4, [a4], m0 + paddw m3, m4 + + LOAD m5, [a5], m0 + LOAD m6, [a6], m0 + paddw m5, m6 + + LOAD m2, [a7], m0 + LOAD m4, [a8], m0 + paddw m2, m4 + + LOAD m6, [c], m0 + paddw m1, m3 + paddw m2, m5 + paddw m6, [pw_4] + + paddw m1, m2 + paddw m1, m6 + + pmulhuw m1, [pw_div9] + + packuswb m1, m1 + + movh [dstq], m1 + add srcq, mmsize/2 + add dstq, mmsize/2 + sub pixelsd, mmsize/2 + jg .loop +RET + +cglobal rg_fl_mode_21, 4, 5, 8, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + pxor m0, m0 + .loop: + movu m1, [a1] + movu m2, [a8] + pavgb m7, m1, m2 + punpckhbw m3, m1, m0 + punpcklbw m1, m0 + punpckhbw m4, m2, m0 + punpcklbw m2, m0 + paddw m3, m4 + paddw m1, m2 + psrlw m3, 1 + psrlw m1, 1 + packuswb m1, m3 + + movu m2, [a2] + movu m3, [a7] + pavgb m6, m2, m3 + punpckhbw m4, m2, m0 + punpcklbw m2, m0 + punpckhbw m5, m3, m0 + punpcklbw m3, m0 + paddw m4, m5 + paddw m2, m3 + psrlw m4, 1 + psrlw m2, 1 + packuswb m2, m4 + + pminub m1, m2 + pmaxub m7, m6 + + movu m2, [a3] + movu m3, [a6] + pavgb m6, m2, m3 + punpckhbw m4, m2, m0 + punpcklbw m2, m0 + punpckhbw m5, m3, m0 + punpcklbw m3, m0 + paddw m4, m5 + paddw m2, m3 + psrlw m4, 1 + psrlw m2, 1 + packuswb m2, m4 + + pminub m1, m2 + pmaxub m7, m6 + + movu m2, [a4] + movu m3, [a5] + pavgb m6, m2, m3 + punpckhbw m4, m2, m0 + punpcklbw m2, m0 + punpckhbw m5, m3, m0 + punpcklbw m3, m0 + paddw m4, m5 + paddw m2, m3 + psrlw m4, 1 + psrlw m2, 1 + packuswb m2, m4 + + pminub m1, m2 + pmaxub m7, m6 + + movu m3, [c] + CLIPUB m3, m1, m7 + + movu [dstq], m3 + add srcq, mmsize + add dstq, mmsize + sub pixelsd, mmsize + jg .loop +RET + +cglobal rg_fl_mode_22, 4, 5, 8, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + .loop: + movu m0, [a1] + movu m1, [a8] + pavgb m0, m1 + movu m2, [a2] + movu m3, [a7] + pavgb m2, m3 + movu m4, [a3] + movu m5, [a6] + pavgb m4, m5 + movu m6, [a4] + movu m7, [a5] + pavgb m6, m7 + + mova m1, m0 + mova m3, m2 + mova m5, m4 + mova m7, m6 + pminub m0, m2 + pminub m4, m6 + pmaxub m1, m3 + pmaxub m5, m7 + pminub m0, m4 + pmaxub m1, m5 + + movu m2, [c] + CLIPUB m2, m0, m1 + + movu [dstq], m2 + add srcq, mmsize + add dstq, mmsize + sub pixelsd, mmsize + jg .loop +RET + +%if ARCH_X86_64 +cglobal rg_fl_mode_23, 4, 5, 16, 0, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + pxor m15, m15 + .loop: + LOAD_SQUARE_16 m15 + SORT_AXIS_16 + + mova m9, m8 + mova m10, m7 + mova m11, m6 + mova m12, m5 + psubw m9, m1 ; linediff1 + psubw m10, m2 ; linediff2 + psubw m11, m3 ; linediff3 + psubw m12, m4 ; linediff4 + + psubw m1, m0 + psubw m2, m0 + psubw m3, m0 + psubw m4, m0 + pminsw m1, m9 ; d1 + pminsw m2, m10 ; d2 + pminsw m3, m11 ; d3 + pminsw m4, m12 ; d4 + pmaxsw m1, m2 + pmaxsw m3, m4 + pmaxsw m1, m3 + pmaxsw m1, m15 ; d + + mova m13, m0 + mova m14, m0 + mova m2, m0 + mova m4, m0 + psubw m13, m8 + psubw m14, m7 + psubw m2, m6 + psubw m4, m5 + pminsw m9, m13 ; u1 + pminsw m10, m14 ; u2 + pminsw m11, m2 ; u3 + pminsw m12, m4 ; u4 + pmaxsw m9, m10 + pmaxsw m11, m12 + pmaxsw m9, m11 + pmaxsw m9, m15 ; u + + paddw m0, m1 + psubw m0, m9 + packuswb m0, m0 + + movh [dstq], m0 + add srcq, mmsize/2 + add dstq, mmsize/2 + sub pixelsd, mmsize/2 + jg .loop +RET + +cglobal rg_fl_mode_24, 4, 5, 16, mmsize, dst, src, stride, pixels + mov r4q, strideq + neg r4q + %define stride_p strideq + %define stride_n r4q + + pxor m15, m15 + .loop: + LOAD_SQUARE_16 m15 + mova [rsp], m0 + SORT_AXIS_16 + + mova m9, m8 + mova m10, m7 + mova m11, m6 + mova m12, m5 + psubw m9, m1 ; linediff1 + psubw m10, m2 ; linediff2 + psubw m11, m3 ; linediff3 + psubw m12, m4 ; linediff4 + + psubw m1, [rsp] ; td1 + psubw m2, [rsp] ; td2 + psubw m3, [rsp] ; td3 + psubw m4, [rsp] ; td4 + mova m0, m9 + mova m13, m10 + mova m14, m11 + mova m15, m12 + psubw m0, m1 + psubw m13, m2 + psubw m14, m3 + psubw m15, m4 + pminsw m1, m0 ; d1 + pminsw m2, m13 ; d2 + pminsw m3, m14 ; d3 + pminsw m4, m15 ; d4 + pmaxsw m1, m2 + pmaxsw m3, m4 + + mova m0, [rsp] + mova m13, [rsp] + mova m14, [rsp] + mova m15, [rsp] + psubw m0, m8 ; tu1 + psubw m13, m7 ; tu2 + psubw m14, m6 ; tu3 + psubw m15, m5 ; tu4 + psubw m9, m0 + psubw m10, m13 + psubw m11, m14 + psubw m12, m15 + pminsw m9, m0 ; u1 + pminsw m10, m13 ; u2 + pminsw m11, m14 ; u3 + pminsw m12, m15 ; u4 + pmaxsw m9, m10 + pmaxsw m11, m12 + + pmaxsw m1, m3 ; d without max(d,0) + pmaxsw m9, m11 ; u without max(u,0) + pxor m15, m15 + pmaxsw m1, m15 + pmaxsw m9, m15 + + mova m0, [rsp] + paddw m0, m1 + psubw m0, m9 + packuswb m0, m0 + + movh [dstq], m0 + add srcq, mmsize/2 + add dstq, mmsize/2 + sub pixelsd, mmsize/2 + jg .loop +RET +%endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_removegrain_init.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_removegrain_init.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_removegrain_init.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_removegrain_init.c 2015-07-15 17:20:03.000000000 +0000 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2015 James Darnley + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/x86/cpu.h" +#include "libavfilter/removegrain.h" + +void ff_rg_fl_mode_1_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_10_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_11_12_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_13_14_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_19_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_20_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_21_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_22_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +#if ARCH_X86_64 +void ff_rg_fl_mode_2_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_3_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_4_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_5_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_6_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_7_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_8_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_9_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_15_16_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_17_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_18_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_23_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +void ff_rg_fl_mode_24_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels); +#endif + +av_cold void ff_removegrain_init_x86(RemoveGrainContext *rg) +{ +#if CONFIG_GPL + int cpu_flags = av_get_cpu_flags(); + int i; + + for (i = 0; i < rg->nb_planes; i++) { + if (EXTERNAL_SSE2(cpu_flags)) + switch (rg->mode[i]) { + case 1: rg->fl[i] = ff_rg_fl_mode_1_sse2; break; + case 10: rg->fl[i] = ff_rg_fl_mode_10_sse2; break; + case 11: /* fall through */ + case 12: rg->fl[i] = ff_rg_fl_mode_11_12_sse2; break; + case 13: /* fall through */ + case 14: rg->fl[i] = ff_rg_fl_mode_13_14_sse2; break; + case 19: rg->fl[i] = ff_rg_fl_mode_19_sse2; break; + case 20: rg->fl[i] = ff_rg_fl_mode_20_sse2; break; + case 21: rg->fl[i] = ff_rg_fl_mode_21_sse2; break; + case 22: rg->fl[i] = ff_rg_fl_mode_22_sse2; break; +#if ARCH_X86_64 + case 2: rg->fl[i] = ff_rg_fl_mode_2_sse2; break; + case 3: rg->fl[i] = ff_rg_fl_mode_3_sse2; break; + case 4: rg->fl[i] = ff_rg_fl_mode_4_sse2; break; + case 5: rg->fl[i] = ff_rg_fl_mode_5_sse2; break; + case 6: rg->fl[i] = ff_rg_fl_mode_6_sse2; break; + case 7: rg->fl[i] = ff_rg_fl_mode_7_sse2; break; + case 8: rg->fl[i] = ff_rg_fl_mode_8_sse2; break; + case 9: rg->fl[i] = ff_rg_fl_mode_9_sse2; break; + case 15: /* fall through */ + case 16: rg->fl[i] = ff_rg_fl_mode_15_16_sse2; break; + case 17: rg->fl[i] = ff_rg_fl_mode_17_sse2; break; + case 18: rg->fl[i] = ff_rg_fl_mode_18_sse2; break; + case 23: rg->fl[i] = ff_rg_fl_mode_23_sse2; break; + case 24: rg->fl[i] = ff_rg_fl_mode_24_sse2; break; +#endif /* ARCH_x86_64 */ + } + } +#endif /* CONFIG_GPL */ +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_ssim.asm ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_ssim.asm --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_ssim.asm 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_ssim.asm 2015-07-20 17:20:03.000000000 +0000 @@ -0,0 +1,247 @@ +;***************************************************************************** +;* x86-optimized functions for ssim filter +;* +;* Copyright (C) 2015 Ronald S. Bultje +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "libavutil/x86/x86util.asm" + +SECTION_RODATA + +pw_1: times 8 dw 1 +ssim_c1: times 4 dd 416 ;(.01*.01*255*255*64 + .5) +ssim_c2: times 4 dd 235963 ;(.03*.03*255*255*64*63 + .5) + +SECTION .text + +%macro SSIM_4X4_LINE 1 +%if ARCH_X86_64 +cglobal ssim_4x4_line, 6, 8, %1, buf, buf_stride, ref, ref_stride, sums, w, buf_stride3, ref_stride3 +%else +cglobal ssim_4x4_line, 5, 7, %1, buf, buf_stride, ref, ref_stride, sums, buf_stride3, ref_stride3 +%define wd r5mp +%endif + lea ref_stride3q, [ref_strideq*3] + lea buf_stride3q, [buf_strideq*3] +%if notcpuflag(xop) + pxor m7, m7 + mova m15, [pw_1] +%endif + +.loop: +%if cpuflag(xop) + pmovzxbw m0, [bufq+buf_strideq*0] + pmovzxbw m1, [refq+ref_strideq*0] + pmaddwd m4, m0, m0 + pmaddwd m6, m0, m1 + pmovzxbw m2, [bufq+buf_strideq*1] + vpmadcswd m4, m1, m1, m4 + pmovzxbw m3, [refq+ref_strideq*1] + paddw m0, m2 + vpmadcswd m4, m2, m2, m4 + vpmadcswd m6, m2, m3, m6 + paddw m1, m3 + vpmadcswd m4, m3, m3, m4 + + pmovzxbw m2, [bufq+buf_strideq*2] + pmovzxbw m3, [refq+ref_strideq*2] + vpmadcswd m4, m2, m2, m4 + vpmadcswd m6, m2, m3, m6 + pmovzxbw m5, [bufq+buf_stride3q] + pmovzxbw m7, [refq+ref_stride3q] + vpmadcswd m4, m3, m3, m4 + vpmadcswd m6, m5, m7, m6 + paddw m0, m2 + paddw m1, m3 + vpmadcswd m4, m5, m5, m4 + paddw m0, m5 + paddw m1, m7 + vpmadcswd m4, m7, m7, m4 +%else + movh m0, [bufq+buf_strideq*0] ; a1 + movh m1, [refq+ref_strideq*0] ; b1 + movh m2, [bufq+buf_strideq*1] ; a2 + movh m3, [refq+ref_strideq*1] ; b2 + punpcklbw m0, m7 ; s1 [word] + punpcklbw m1, m7 ; s2 [word] + punpcklbw m2, m7 ; s1 [word] + punpcklbw m3, m7 ; s2 [word] + pmaddwd m4, m0, m0 ; a1 * a1 + pmaddwd m5, m1, m1 ; b1 * b1 + pmaddwd m8, m2, m2 ; a2 * a2 + pmaddwd m9, m3, m3 ; b2 * b2 + paddd m4, m5 ; ss + paddd m8, m9 ; ss + pmaddwd m6, m0, m1 ; a1 * b1 = ss12 + pmaddwd m5, m2, m3 ; a2 * b2 = ss12 + paddw m0, m2 + paddw m1, m3 + paddd m6, m5 ; s12 + paddd m4, m8 ; ss + + movh m2, [bufq+buf_strideq*2] ; a3 + movh m3, [refq+ref_strideq*2] ; b3 + movh m5, [bufq+buf_stride3q] ; a4 + movh m8, [refq+ref_stride3q] ; b4 + punpcklbw m2, m7 ; s1 [word] + punpcklbw m3, m7 ; s2 [word] + punpcklbw m5, m7 ; s1 [word] + punpcklbw m8, m7 ; s2 [word] + pmaddwd m9, m2, m2 ; a3 * a3 + pmaddwd m10, m3, m3 ; b3 * b3 + pmaddwd m12, m5, m5 ; a4 * a4 + pmaddwd m13, m8, m8 ; b4 * b4 + pmaddwd m11, m2, m3 ; a3 * b3 = ss12 + pmaddwd m14, m5, m8 ; a4 * b4 = ss12 + paddd m9, m10 + paddd m12, m13 + paddw m0, m2 + paddw m1, m3 + paddw m0, m5 + paddw m1, m8 + paddd m6, m11 + paddd m4, m9 + paddd m6, m14 + paddd m4, m12 +%endif + + ; m0 = [word] s1 a,a,a,a,b,b,b,b + ; m1 = [word] s2 a,a,a,a,b,b,b,b + ; m4 = [dword] ss a,a,b,b + ; m6 = [dword] s12 a,a,b,b + +%if cpuflag(xop) + vphaddwq m0, m0 ; [dword] s1 a, 0, b, 0 + vphaddwq m1, m1 ; [dword] s2 a, 0, b, 0 + vphadddq m4, m4 ; [dword] ss a, 0, b, 0 + vphadddq m6, m6 ; [dword] s12 a, 0, b, 0 + punpckhdq m2, m0, m1 ; [dword] s1 b, s2 b, 0, 0 + punpckldq m0, m1 ; [dword] s1 a, s2 a, 0, 0 + punpckhdq m3, m4, m6 ; [dword] ss b, s12 b, 0, 0 + punpckldq m4, m6 ; [dword] ss a, s12 a, 0, 0 + punpcklqdq m1, m2, m3 ; [dword] b s1, s2, ss, s12 + punpcklqdq m0, m4 ; [dword] a s1, s2, ss, s12 +%else + pmaddwd m0, m15 ; [dword] s1 a,a,b,b + pmaddwd m1, m15 ; [dword] s2 a,a,b,b + phaddd m0, m4 ; [dword] s1 a, b, ss a, b + phaddd m1, m6 ; [dword] s2 a, b, s12 a, b + punpckhdq m2, m0, m1 ; [dword] ss a, s12 a, ss b, s12 b + punpckldq m0, m1 ; [dword] s1 a, s2 a, s1 b, s2 b + punpckhqdq m1, m0, m2 ; [dword] b s1, s2, ss, s12 + punpcklqdq m0, m2 ; [dword] a s1, s2, ss, s12 +%endif + + mova [sumsq+ 0], m0 + mova [sumsq+mmsize], m1 + + add bufq, mmsize/2 + add refq, mmsize/2 + add sumsq, mmsize*2 + sub wd, mmsize/8 + jg .loop + RET +%endmacro + +%if ARCH_X86_64 +INIT_XMM ssse3 +SSIM_4X4_LINE 16 +%endif +%if HAVE_XOP_EXTERNAL +INIT_XMM xop +SSIM_4X4_LINE 8 +%endif + +INIT_XMM sse4 +cglobal ssim_end_line, 3, 3, 6, sum0, sum1, w + pxor m0, m0 +.loop: + mova m1, [sum0q+mmsize*0] + mova m2, [sum0q+mmsize*1] + mova m3, [sum0q+mmsize*2] + mova m4, [sum0q+mmsize*3] + paddd m1, [sum1q+mmsize*0] + paddd m2, [sum1q+mmsize*1] + paddd m3, [sum1q+mmsize*2] + paddd m4, [sum1q+mmsize*3] + paddd m1, m2 + paddd m2, m3 + paddd m3, m4 + paddd m4, [sum0q+mmsize*4] + paddd m4, [sum1q+mmsize*4] + TRANSPOSE4x4D 1, 2, 3, 4, 5 + + ; m1 = fs1, m2 = fs2, m3 = fss, m4 = fs12 + pslld m3, 6 + pslld m4, 6 + pmulld m5, m1, m2 ; fs1 * fs2 + pmulld m1, m1 ; fs1 * fs1 + pmulld m2, m2 ; fs2 * fs2 + psubd m3, m1 + psubd m4, m5 ; covariance + psubd m3, m2 ; variance + + ; m1 = fs1 * fs1, m2 = fs2 * fs2, m3 = variance, m4 = covariance, m5 = fs1 * fs2 + paddd m4, m4 ; 2 * covariance + paddd m5, m5 ; 2 * fs1 * fs2 + paddd m1, m2 ; fs1 * fs1 + fs2 * fs2 + paddd m3, [ssim_c2] ; variance + ssim_c2 + paddd m4, [ssim_c2] ; 2 * covariance + ssim_c2 + paddd m5, [ssim_c1] ; 2 * fs1 * fs2 + ssim_c1 + paddd m1, [ssim_c1] ; fs1 * fs1 + fs2 * fs2 + ssim_c1 + + ; convert to float + cvtdq2ps m3, m3 + cvtdq2ps m4, m4 + cvtdq2ps m5, m5 + cvtdq2ps m1, m1 + mulps m4, m5 + mulps m3, m1 + divps m4, m3 ; ssim_endl + addps m0, m4 ; ssim + add sum0q, mmsize*4 + add sum1q, mmsize*4 + sub wd, 4 + jg .loop + + ; subps the ones we added too much + test wd, wd + jz .end + add wd, 4 + test wd, 2 + jz .skip2 + psrldq m4, 8 +.skip2: + test wd, 1 + jz .skip1 + psrldq m4, 4 +.skip1: + subps m0, m4 + +.end: + movhlps m4, m0 + addps m0, m4 + movss m4, m0 + shufps m0, m0, 1 + addss m0, m4 +%if ARCH_X86_32 + movss r0m, m0 + fld r0mp +%endif + RET diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_ssim_init.c ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_ssim_init.c --- ffmpeg-2.7.1~trusty~ppa1/libavfilter/x86/vf_ssim_init.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavfilter/x86/vf_ssim_init.c 2015-07-20 17:20:03.000000000 +0000 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015 Ronald S. Bultje + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/x86/cpu.h" + +#include "libavfilter/ssim.h" + +void ff_ssim_4x4_line_ssse3(const uint8_t *buf, ptrdiff_t buf_stride, + const uint8_t *ref, ptrdiff_t ref_stride, + int (*sums)[4], int w); +void ff_ssim_4x4_line_xop (const uint8_t *buf, ptrdiff_t buf_stride, + const uint8_t *ref, ptrdiff_t ref_stride, + int (*sums)[4], int w); +float ff_ssim_end_line_sse4(const int (*sum0)[4], const int (*sum1)[4], int w); + +void ff_ssim_init_x86(SSIMDSPContext *dsp) +{ + int cpu_flags = av_get_cpu_flags(); + + if (ARCH_X86_64 && EXTERNAL_SSSE3(cpu_flags)) + dsp->ssim_4x4_line = ff_ssim_4x4_line_ssse3; + if (EXTERNAL_SSE4(cpu_flags)) + dsp->ssim_end_line = ff_ssim_end_line_sse4; + if (EXTERNAL_XOP(cpu_flags)) + dsp->ssim_4x4_line = ff_ssim_4x4_line_xop; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/4xm.c ffmpeg-2.7.2~trusty~ppa1/libavformat/4xm.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/4xm.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/4xm.c 2015-07-28 17:20:07.000000000 +0000 @@ -111,7 +111,7 @@ st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_4XM; - st->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE); + st->codec->extradata = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); st->codec->extradata_size = 4; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/ac3dec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/ac3dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/ac3dec.c 2015-06-18 18:55:02.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/ac3dec.c 2015-07-18 17:20:03.000000000 +0000 @@ -80,7 +80,7 @@ if(codec_id != expected_codec_id) return 0; // keep this in sync with mp3 probe, both need to avoid // issues with MPEG-files! - if (first_frames>=4) return AVPROBE_SCORE_EXTENSION + 1; + if (first_frames>=7) return AVPROBE_SCORE_EXTENSION + 1; else if(max_frames>200)return AVPROBE_SCORE_EXTENSION; else if(max_frames>=4) return AVPROBE_SCORE_EXTENSION/2; else if(max_frames>=1) return 1; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/act.c ffmpeg-2.7.2~trusty~ppa1/libavformat/act.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/act.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/act.c 2015-07-12 17:20:02.000000000 +0000 @@ -75,7 +75,7 @@ avio_skip(pb, 16); size=avio_rl32(pb); - ff_get_wav_header(pb, st->codec, size, 0); + ff_get_wav_header(s, pb, st->codec, size, 0); /* 8000Hz (Fine-rec) file format has 10 bytes long diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/aiffdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/aiffdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/aiffdec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/aiffdec.c 2015-06-11 17:20:04.000000000 +0000 @@ -91,7 +91,7 @@ } /* Returns the number of sound data frames or negative on error */ -static unsigned int get_aiff_header(AVFormatContext *s, int size, +static int get_aiff_header(AVFormatContext *s, int size, unsigned version) { AVIOContext *pb = s->pb; @@ -99,7 +99,7 @@ AIFFInputContext *aiff = s->priv_data; int exp; uint64_t val; - double sample_rate; + int sample_rate; unsigned int num_frames; if (size & 1) @@ -109,9 +109,16 @@ num_frames = avio_rb32(pb); codec->bits_per_coded_sample = avio_rb16(pb); - exp = avio_rb16(pb); + exp = avio_rb16(pb) - 16383 - 63; val = avio_rb64(pb); - sample_rate = ldexp(val, exp - 16383 - 63); + if (exp <-63 || exp >63) { + av_log(s, AV_LOG_ERROR, "exp %d is out of range\n", exp); + return AVERROR_INVALIDDATA; + } + if (exp >= 0) + sample_rate = val << exp; + else + sample_rate = (val + (1ULL<<(-exp-1))) >> -exp; codec->sample_rate = sample_rate; size -= 18; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/allformats.c ffmpeg-2.7.2~trusty~ppa1/libavformat/allformats.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/allformats.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/allformats.c 2015-07-18 17:20:03.000000000 +0000 @@ -77,6 +77,7 @@ REGISTER_MUXDEMUX(APNG, apng); REGISTER_DEMUXER (AQTITLE, aqtitle); REGISTER_MUXDEMUX(ASF, asf); + REGISTER_DEMUXER (ASF_O, asf_o); REGISTER_MUXDEMUX(ASS, ass); REGISTER_MUXDEMUX(AST, ast); REGISTER_MUXER (ASF_STREAM, asf_stream); @@ -92,6 +93,7 @@ REGISTER_DEMUXER (BINK, bink); REGISTER_MUXDEMUX(BIT, bit); REGISTER_DEMUXER (BMV, bmv); + REGISTER_DEMUXER (BFSTM, bfstm); REGISTER_DEMUXER (BRSTM, brstm); REGISTER_DEMUXER (BOA, boa); REGISTER_DEMUXER (C93, c93); @@ -333,6 +335,7 @@ /* image demuxers */ REGISTER_DEMUXER (IMAGE_BMP_PIPE, image_bmp_pipe); + REGISTER_DEMUXER (IMAGE_DDS_PIPE, image_dds_pipe); REGISTER_DEMUXER (IMAGE_DPX_PIPE, image_dpx_pipe); REGISTER_DEMUXER (IMAGE_EXR_PIPE, image_exr_pipe); REGISTER_DEMUXER (IMAGE_J2K_PIPE, image_j2k_pipe); @@ -348,6 +351,7 @@ /* protocols */ + REGISTER_PROTOCOL(ASYNC, async); REGISTER_PROTOCOL(BLURAY, bluray); REGISTER_PROTOCOL(CACHE, cache); REGISTER_PROTOCOL(CONCAT, concat); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/anm.c ffmpeg-2.7.2~trusty~ppa1/libavformat/anm.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/anm.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/anm.c 2015-07-28 17:20:07.000000000 +0000 @@ -133,7 +133,7 @@ /* color cycling and palette data */ st->codec->extradata_size = 16*8 + 4*256; - st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + st->codec->extradata = av_mallocz(st->codec->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) { return AVERROR(ENOMEM); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/apetag.c ffmpeg-2.7.2~trusty~ppa1/libavformat/apetag.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/apetag.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/apetag.c 2015-07-28 17:20:07.000000000 +0000 @@ -55,7 +55,7 @@ av_log(s, AV_LOG_WARNING, "Invalid APE tag key '%s'.\n", key); return -1; } - if (size > INT32_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { + if (size > INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE) { av_log(s, AV_LOG_ERROR, "APE tag size too large.\n"); return AVERROR_INVALIDDATA; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/apngdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/apngdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/apngdec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/apngdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -132,7 +132,7 @@ return AVERROR_INVALIDDATA; new_size = previous_size + len; - new_extradata = av_realloc(s->extradata, new_size + FF_INPUT_BUFFER_PADDING_SIZE); + new_extradata = av_realloc(s->extradata, new_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!new_extradata) return AVERROR(ENOMEM); s->extradata = new_extradata; @@ -178,7 +178,7 @@ return ret; /* extradata will contain every chunk up to the first fcTL (excluded) */ - st->codec->extradata = av_malloc(len + 12 + FF_INPUT_BUFFER_PADDING_SIZE); + st->codec->extradata = av_malloc(len + 12 + AV_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); st->codec->extradata_size = len + 12; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/apngenc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/apngenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/apngenc.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/apngenc.c 2015-07-16 17:20:02.000000000 +0000 @@ -173,7 +173,7 @@ "Frame rate is too high or specified too precisely. Unable to copy losslessly.\n"); apng->framerate_warned = 1; } - } else if (apng->last_delay.den > 0) { + } else if (apng->last_delay.num > 0) { delay = apng->last_delay; } else { delay = apng->prev_delay; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/asfdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/asfdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/asfdec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/asfdec.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1623 +0,0 @@ -/* - * ASF compatible demuxer - * Copyright (c) 2000, 2001 Fabrice Bellard - * - * 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 - -#include "libavutil/attributes.h" -#include "libavutil/avassert.h" -#include "libavutil/avstring.h" -#include "libavutil/bswap.h" -#include "libavutil/common.h" -#include "libavutil/dict.h" -#include "libavutil/internal.h" -#include "libavutil/mathematics.h" -#include "libavutil/opt.h" -#include "avformat.h" -#include "avio_internal.h" -#include "avlanguage.h" -#include "id3v2.h" -#include "internal.h" -#include "riff.h" -#include "asf.h" -#include "asfcrypt.h" - -typedef struct ASFContext { - const AVClass *class; - int asfid2avid[128]; ///< conversion table from asf ID 2 AVStream ID - ASFStream streams[128]; ///< it's max number and it's not that big - uint32_t stream_bitrates[128]; ///< max number of streams, bitrate for each (for streaming) - AVRational dar[128]; - char stream_languages[128][6]; ///< max number of streams, language for each (RFC1766, e.g. en-US) - /* non streamed additonnal info */ - /* packet filling */ - int packet_size_left; - /* only for reading */ - uint64_t data_offset; ///< beginning of the first data packet - uint64_t data_object_offset; ///< data object offset (excl. GUID & size) - uint64_t data_object_size; ///< size of the data object - int index_read; - - ASFMainHeader hdr; - - int packet_flags; - int packet_property; - int packet_timestamp; - int packet_segsizetype; - int packet_segments; - int packet_seq; - int packet_replic_size; - int packet_key_frame; - int packet_padsize; - unsigned int packet_frag_offset; - unsigned int packet_frag_size; - int64_t packet_frag_timestamp; - int ts_is_pts; - int packet_multi_size; - int packet_time_delta; - int packet_time_start; - int64_t packet_pos; - - int stream_index; - - ASFStream *asf_st; ///< currently decoded stream - - int no_resync_search; - int export_xmp; -} ASFContext; - -static const AVOption options[] = { - { "no_resync_search", "Don't try to resynchronize by looking for a certain optional start code", offsetof(ASFContext, no_resync_search), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, - { "export_xmp", "Export full XMP metadata", offsetof(ASFContext, export_xmp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, - { NULL }, -}; - -static const AVClass asf_class = { - .class_name = "asf demuxer", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; - -#undef NDEBUG -#include - -#define ASF_MAX_STREAMS 127 -#define FRAME_HEADER_SIZE 16 -// Fix Me! FRAME_HEADER_SIZE may be different. (17 is known to be too large) - -#ifdef DEBUG -static const ff_asf_guid stream_bitrate_guid = { /* (http://get.to/sdp) */ - 0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2 -}; - -#define PRINT_IF_GUID(g, cmp) \ - if (!ff_guidcmp(g, &cmp)) \ - av_log(NULL, AV_LOG_TRACE, "(GUID: %s) ", # cmp) - -static void print_guid(ff_asf_guid *g) -{ - int i; - PRINT_IF_GUID(g, ff_asf_header); - else PRINT_IF_GUID(g, ff_asf_file_header); - else PRINT_IF_GUID(g, ff_asf_stream_header); - else PRINT_IF_GUID(g, ff_asf_audio_stream); - else PRINT_IF_GUID(g, ff_asf_audio_conceal_none); - else PRINT_IF_GUID(g, ff_asf_video_stream); - else PRINT_IF_GUID(g, ff_asf_video_conceal_none); - else PRINT_IF_GUID(g, ff_asf_command_stream); - else PRINT_IF_GUID(g, ff_asf_comment_header); - else PRINT_IF_GUID(g, ff_asf_codec_comment_header); - else PRINT_IF_GUID(g, ff_asf_codec_comment1_header); - else PRINT_IF_GUID(g, ff_asf_data_header); - else PRINT_IF_GUID(g, ff_asf_simple_index_header); - else PRINT_IF_GUID(g, ff_asf_head1_guid); - else PRINT_IF_GUID(g, ff_asf_head2_guid); - else PRINT_IF_GUID(g, ff_asf_my_guid); - else PRINT_IF_GUID(g, ff_asf_ext_stream_header); - else PRINT_IF_GUID(g, ff_asf_extended_content_header); - else PRINT_IF_GUID(g, ff_asf_ext_stream_embed_stream_header); - else PRINT_IF_GUID(g, ff_asf_ext_stream_audio_stream); - else PRINT_IF_GUID(g, ff_asf_metadata_header); - else PRINT_IF_GUID(g, ff_asf_metadata_library_header); - else PRINT_IF_GUID(g, ff_asf_marker_header); - else PRINT_IF_GUID(g, stream_bitrate_guid); - else PRINT_IF_GUID(g, ff_asf_language_guid); - else - av_log(NULL, AV_LOG_TRACE, "(GUID: unknown) "); - for (i = 0; i < 16; i++) - av_log(NULL, AV_LOG_TRACE, " 0x%02x,", (*g)[i]); - av_log(NULL, AV_LOG_TRACE, "}\n"); -} -#undef PRINT_IF_GUID -#else -#define print_guid(g) while(0) -#endif - -static int asf_probe(AVProbeData *pd) -{ - /* check file header */ - if (!ff_guidcmp(pd->buf, &ff_asf_header)) - return AVPROBE_SCORE_MAX; - else - return 0; -} - -/* size of type 2 (BOOL) is 32bit for "Extended Content Description Object" - * but 16 bit for "Metadata Object" and "Metadata Library Object" */ -static int get_value(AVIOContext *pb, int type, int type2_size) -{ - switch (type) { - case 2: - return (type2_size == 32) ? avio_rl32(pb) : avio_rl16(pb); - case 3: - return avio_rl32(pb); - case 4: - return avio_rl64(pb); - case 5: - return avio_rl16(pb); - default: - return INT_MIN; - } -} - -/* MSDN claims that this should be "compatible with the ID3 frame, APIC", - * but in reality this is only loosely similar */ -static int asf_read_picture(AVFormatContext *s, int len) -{ - AVPacket pkt = { 0 }; - const CodecMime *mime = ff_id3v2_mime_tags; - enum AVCodecID id = AV_CODEC_ID_NONE; - char mimetype[64]; - uint8_t *desc = NULL; - AVStream *st = NULL; - int ret, type, picsize, desc_len; - - /* type + picsize + mime + desc */ - if (len < 1 + 4 + 2 + 2) { - av_log(s, AV_LOG_ERROR, "Invalid attached picture size: %d.\n", len); - return AVERROR_INVALIDDATA; - } - - /* picture type */ - type = avio_r8(s->pb); - len--; - if (type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || type < 0) { - av_log(s, AV_LOG_WARNING, "Unknown attached picture type: %d.\n", type); - type = 0; - } - - /* picture data size */ - picsize = avio_rl32(s->pb); - len -= 4; - - /* picture MIME type */ - len -= avio_get_str16le(s->pb, len, mimetype, sizeof(mimetype)); - while (mime->id != AV_CODEC_ID_NONE) { - if (!strncmp(mime->str, mimetype, sizeof(mimetype))) { - id = mime->id; - break; - } - mime++; - } - if (id == AV_CODEC_ID_NONE) { - av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n", - mimetype); - return 0; - } - - if (picsize >= len) { - av_log(s, AV_LOG_ERROR, "Invalid attached picture data size: %d >= %d.\n", - picsize, len); - return AVERROR_INVALIDDATA; - } - - /* picture description */ - desc_len = (len - picsize) * 2 + 1; - desc = av_malloc(desc_len); - if (!desc) - return AVERROR(ENOMEM); - len -= avio_get_str16le(s->pb, len - picsize, desc, desc_len); - - ret = av_get_packet(s->pb, &pkt, picsize); - if (ret < 0) - goto fail; - - st = avformat_new_stream(s, NULL); - if (!st) { - ret = AVERROR(ENOMEM); - goto fail; - } - st->disposition |= AV_DISPOSITION_ATTACHED_PIC; - st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - st->codec->codec_id = id; - st->attached_pic = pkt; - st->attached_pic.stream_index = st->index; - st->attached_pic.flags |= AV_PKT_FLAG_KEY; - - if (*desc) - av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL); - else - av_freep(&desc); - - av_dict_set(&st->metadata, "comment", ff_id3v2_picture_types[type], 0); - - return 0; - -fail: - av_freep(&desc); - av_free_packet(&pkt); - return ret; -} - -static void get_id3_tag(AVFormatContext *s, int len) -{ - ID3v2ExtraMeta *id3v2_extra_meta = NULL; - - ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, len); - if (id3v2_extra_meta) - ff_id3v2_parse_apic(s, &id3v2_extra_meta); - ff_id3v2_free_extra_meta(&id3v2_extra_meta); -} - -static void get_tag(AVFormatContext *s, const char *key, int type, int len, int type2_size) -{ - ASFContext *asf = s->priv_data; - char *value = NULL; - int64_t off = avio_tell(s->pb); -#define LEN 22 - - if ((unsigned)len >= (UINT_MAX - LEN) / 2) - return; - - if (!asf->export_xmp && !strncmp(key, "xmp", 3)) - goto finish; - - value = av_malloc(2 * len + LEN); - if (!value) - goto finish; - - if (type == 0) { // UTF16-LE - avio_get_str16le(s->pb, len, value, 2 * len + 1); - } else if (type == -1) { // ASCII - avio_read(s->pb, value, len); - value[len]=0; - } else if (type == 1) { // byte array - if (!strcmp(key, "WM/Picture")) { // handle cover art - asf_read_picture(s, len); - } else if (!strcmp(key, "ID3")) { // handle ID3 tag - get_id3_tag(s, len); - } else { - av_log(s, AV_LOG_VERBOSE, "Unsupported byte array in tag %s.\n", key); - } - goto finish; - } else if (type > 1 && type <= 5) { // boolean or DWORD or QWORD or WORD - uint64_t num = get_value(s->pb, type, type2_size); - snprintf(value, LEN, "%"PRIu64, num); - } else if (type == 6) { // (don't) handle GUID - av_log(s, AV_LOG_DEBUG, "Unsupported GUID value in tag %s.\n", key); - goto finish; - } else { - av_log(s, AV_LOG_DEBUG, - "Unsupported value type %d in tag %s.\n", type, key); - goto finish; - } - if (*value) - av_dict_set(&s->metadata, key, value, 0); - -finish: - av_freep(&value); - avio_seek(s->pb, off + len, SEEK_SET); -} - -static int asf_read_file_properties(AVFormatContext *s, int64_t size) -{ - ASFContext *asf = s->priv_data; - AVIOContext *pb = s->pb; - - ff_get_guid(pb, &asf->hdr.guid); - asf->hdr.file_size = avio_rl64(pb); - asf->hdr.create_time = avio_rl64(pb); - avio_rl64(pb); /* number of packets */ - asf->hdr.play_time = avio_rl64(pb); - asf->hdr.send_time = avio_rl64(pb); - asf->hdr.preroll = avio_rl32(pb); - asf->hdr.ignore = avio_rl32(pb); - asf->hdr.flags = avio_rl32(pb); - asf->hdr.min_pktsize = avio_rl32(pb); - asf->hdr.max_pktsize = avio_rl32(pb); - if (asf->hdr.min_pktsize >= (1U << 29)) - return AVERROR_INVALIDDATA; - asf->hdr.max_bitrate = avio_rl32(pb); - s->packet_size = asf->hdr.max_pktsize; - - return 0; -} - -static int asf_read_stream_properties(AVFormatContext *s, int64_t size) -{ - ASFContext *asf = s->priv_data; - AVIOContext *pb = s->pb; - AVStream *st; - ASFStream *asf_st; - ff_asf_guid g; - enum AVMediaType type; - int type_specific_size, sizeX; - unsigned int tag1; - int64_t pos1, pos2, start_time; - int test_for_ext_stream_audio, is_dvr_ms_audio = 0; - - if (s->nb_streams == ASF_MAX_STREAMS) { - av_log(s, AV_LOG_ERROR, "too many streams\n"); - return AVERROR(EINVAL); - } - - pos1 = avio_tell(pb); - - st = avformat_new_stream(s, NULL); - if (!st) - return AVERROR(ENOMEM); - avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */ - start_time = asf->hdr.preroll; - - if (!(asf->hdr.flags & 0x01)) { // if we aren't streaming... - int64_t fsize = avio_size(pb); - if (fsize <= 0 || (int64_t)asf->hdr.file_size <= 0 || - 20*FFABS(fsize - (int64_t)asf->hdr.file_size) < FFMIN(fsize, asf->hdr.file_size)) - st->duration = asf->hdr.play_time / - (10000000 / 1000) - start_time; - } - ff_get_guid(pb, &g); - - test_for_ext_stream_audio = 0; - if (!ff_guidcmp(&g, &ff_asf_audio_stream)) { - type = AVMEDIA_TYPE_AUDIO; - } else if (!ff_guidcmp(&g, &ff_asf_video_stream)) { - type = AVMEDIA_TYPE_VIDEO; - } else if (!ff_guidcmp(&g, &ff_asf_jfif_media)) { - type = AVMEDIA_TYPE_VIDEO; - st->codec->codec_id = AV_CODEC_ID_MJPEG; - } else if (!ff_guidcmp(&g, &ff_asf_command_stream)) { - type = AVMEDIA_TYPE_DATA; - } else if (!ff_guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) { - test_for_ext_stream_audio = 1; - type = AVMEDIA_TYPE_UNKNOWN; - } else { - return -1; - } - ff_get_guid(pb, &g); - avio_skip(pb, 8); /* total_size */ - type_specific_size = avio_rl32(pb); - avio_rl32(pb); - st->id = avio_rl16(pb) & 0x7f; /* stream id */ - // mapping of asf ID to AV stream ID; - asf->asfid2avid[st->id] = s->nb_streams - 1; - asf_st = &asf->streams[st->id]; - - avio_rl32(pb); - - if (test_for_ext_stream_audio) { - ff_get_guid(pb, &g); - if (!ff_guidcmp(&g, &ff_asf_ext_stream_audio_stream)) { - type = AVMEDIA_TYPE_AUDIO; - is_dvr_ms_audio = 1; - ff_get_guid(pb, &g); - avio_rl32(pb); - avio_rl32(pb); - avio_rl32(pb); - ff_get_guid(pb, &g); - avio_rl32(pb); - } - } - - st->codec->codec_type = type; - if (type == AVMEDIA_TYPE_AUDIO) { - int ret = ff_get_wav_header(pb, st->codec, type_specific_size, 0); - if (ret < 0) - return ret; - if (is_dvr_ms_audio) { - // codec_id and codec_tag are unreliable in dvr_ms - // files. Set them later by probing stream. - st->request_probe = 1; - st->codec->codec_tag = 0; - } - if (st->codec->codec_id == AV_CODEC_ID_AAC) - st->need_parsing = AVSTREAM_PARSE_NONE; - else - st->need_parsing = AVSTREAM_PARSE_FULL; - /* We have to init the frame size at some point .... */ - pos2 = avio_tell(pb); - if (size >= (pos2 + 8 - pos1 + 24)) { - asf_st->ds_span = avio_r8(pb); - asf_st->ds_packet_size = avio_rl16(pb); - asf_st->ds_chunk_size = avio_rl16(pb); - avio_rl16(pb); // ds_data_size - avio_r8(pb); // ds_silence_data - } - if (asf_st->ds_span > 1) { - if (!asf_st->ds_chunk_size || - (asf_st->ds_packet_size / asf_st->ds_chunk_size <= 1) || - asf_st->ds_packet_size % asf_st->ds_chunk_size) - asf_st->ds_span = 0; // disable descrambling - } - } else if (type == AVMEDIA_TYPE_VIDEO && - size - (avio_tell(pb) - pos1 + 24) >= 51) { - avio_rl32(pb); - avio_rl32(pb); - avio_r8(pb); - avio_rl16(pb); /* size */ - sizeX = avio_rl32(pb); /* size */ - st->codec->width = avio_rl32(pb); - st->codec->height = avio_rl32(pb); - /* not available for asf */ - avio_rl16(pb); /* panes */ - st->codec->bits_per_coded_sample = avio_rl16(pb); /* depth */ - tag1 = avio_rl32(pb); - avio_skip(pb, 20); - if (sizeX > 40) { - st->codec->extradata_size = ffio_limit(pb, sizeX - 40); - st->codec->extradata = av_mallocz(st->codec->extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); - if (!st->codec->extradata) - return AVERROR(ENOMEM); - avio_read(pb, st->codec->extradata, st->codec->extradata_size); - } - - /* Extract palette from extradata if bpp <= 8 */ - /* This code assumes that extradata contains only palette */ - /* This is true for all paletted codecs implemented in libavcodec */ - if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) { -#if HAVE_BIGENDIAN - int i; - for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE) / 4; i++) - asf_st->palette[i] = av_bswap32(((uint32_t *)st->codec->extradata)[i]); -#else - memcpy(asf_st->palette, st->codec->extradata, - FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); -#endif - asf_st->palette_changed = 1; - } - - st->codec->codec_tag = tag1; - st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1); - if (tag1 == MKTAG('D', 'V', 'R', ' ')) { - st->need_parsing = AVSTREAM_PARSE_FULL; - /* issue658 contains wrong w/h and MS even puts a fake seq header - * with wrong w/h in extradata while a correct one is in the stream. - * maximum lameness */ - st->codec->width = - st->codec->height = 0; - av_freep(&st->codec->extradata); - st->codec->extradata_size = 0; - } - if (st->codec->codec_id == AV_CODEC_ID_H264) - st->need_parsing = AVSTREAM_PARSE_FULL_ONCE; - if (st->codec->codec_id == AV_CODEC_ID_MPEG4) - st->need_parsing = AVSTREAM_PARSE_FULL_ONCE; - } - pos2 = avio_tell(pb); - avio_skip(pb, size - (pos2 - pos1 + 24)); - - return 0; -} - -static int asf_read_ext_stream_properties(AVFormatContext *s, int64_t size) -{ - ASFContext *asf = s->priv_data; - AVIOContext *pb = s->pb; - ff_asf_guid g; - int ext_len, payload_ext_ct, stream_ct, i; - uint32_t leak_rate, stream_num; - unsigned int stream_languageid_index; - - avio_rl64(pb); // starttime - avio_rl64(pb); // endtime - leak_rate = avio_rl32(pb); // leak-datarate - avio_rl32(pb); // bucket-datasize - avio_rl32(pb); // init-bucket-fullness - avio_rl32(pb); // alt-leak-datarate - avio_rl32(pb); // alt-bucket-datasize - avio_rl32(pb); // alt-init-bucket-fullness - avio_rl32(pb); // max-object-size - avio_rl32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved) - stream_num = avio_rl16(pb); // stream-num - - stream_languageid_index = avio_rl16(pb); // stream-language-id-index - if (stream_num < 128) - asf->streams[stream_num].stream_language_index = stream_languageid_index; - - avio_rl64(pb); // avg frametime in 100ns units - stream_ct = avio_rl16(pb); // stream-name-count - payload_ext_ct = avio_rl16(pb); // payload-extension-system-count - - if (stream_num < 128) { - asf->stream_bitrates[stream_num] = leak_rate; - asf->streams[stream_num].payload_ext_ct = 0; - } - - for (i = 0; i < stream_ct; i++) { - avio_rl16(pb); - ext_len = avio_rl16(pb); - avio_skip(pb, ext_len); - } - - for (i = 0; i < payload_ext_ct; i++) { - int size; - ff_get_guid(pb, &g); - size = avio_rl16(pb); - ext_len = avio_rl32(pb); - avio_skip(pb, ext_len); - if (stream_num < 128 && i < FF_ARRAY_ELEMS(asf->streams[stream_num].payload)) { - ASFPayload *p = &asf->streams[stream_num].payload[i]; - p->type = g[0]; - p->size = size; - av_log(s, AV_LOG_DEBUG, "Payload extension %x %d\n", g[0], p->size ); - asf->streams[stream_num].payload_ext_ct ++; - } - } - - return 0; -} - -static int asf_read_content_desc(AVFormatContext *s, int64_t size) -{ - AVIOContext *pb = s->pb; - int len1, len2, len3, len4, len5; - - len1 = avio_rl16(pb); - len2 = avio_rl16(pb); - len3 = avio_rl16(pb); - len4 = avio_rl16(pb); - len5 = avio_rl16(pb); - get_tag(s, "title", 0, len1, 32); - get_tag(s, "author", 0, len2, 32); - get_tag(s, "copyright", 0, len3, 32); - get_tag(s, "comment", 0, len4, 32); - avio_skip(pb, len5); - - return 0; -} - -static int asf_read_ext_content_desc(AVFormatContext *s, int64_t size) -{ - AVIOContext *pb = s->pb; - ASFContext *asf = s->priv_data; - int desc_count, i, ret; - - desc_count = avio_rl16(pb); - for (i = 0; i < desc_count; i++) { - int name_len, value_type, value_len; - char name[1024]; - - name_len = avio_rl16(pb); - if (name_len % 2) // must be even, broken lavf versions wrote len-1 - name_len += 1; - if ((ret = avio_get_str16le(pb, name_len, name, sizeof(name))) < name_len) - avio_skip(pb, name_len - ret); - value_type = avio_rl16(pb); - value_len = avio_rl16(pb); - if (!value_type && value_len % 2) - value_len += 1; - /* My sample has that stream set to 0 maybe that mean the container. - * ASF stream count starts at 1. I am using 0 to the container value - * since it's unused. */ - if (!strcmp(name, "AspectRatioX")) - asf->dar[0].num = get_value(s->pb, value_type, 32); - else if (!strcmp(name, "AspectRatioY")) - asf->dar[0].den = get_value(s->pb, value_type, 32); - else - get_tag(s, name, value_type, value_len, 32); - } - - return 0; -} - -static int asf_read_language_list(AVFormatContext *s, int64_t size) -{ - AVIOContext *pb = s->pb; - ASFContext *asf = s->priv_data; - int j, ret; - int stream_count = avio_rl16(pb); - for (j = 0; j < stream_count; j++) { - char lang[6]; - unsigned int lang_len = avio_r8(pb); - if ((ret = avio_get_str16le(pb, lang_len, lang, - sizeof(lang))) < lang_len) - avio_skip(pb, lang_len - ret); - if (j < 128) - av_strlcpy(asf->stream_languages[j], lang, - sizeof(*asf->stream_languages)); - } - - return 0; -} - -static int asf_read_metadata(AVFormatContext *s, int64_t size) -{ - AVIOContext *pb = s->pb; - ASFContext *asf = s->priv_data; - int n, stream_num, name_len, value_len; - int ret, i; - n = avio_rl16(pb); - - for (i = 0; i < n; i++) { - char name[1024]; - int value_type; - - avio_rl16(pb); // lang_list_index - stream_num = avio_rl16(pb); - name_len = avio_rl16(pb); - value_type = avio_rl16(pb); /* value_type */ - value_len = avio_rl32(pb); - - if ((ret = avio_get_str16le(pb, name_len, name, sizeof(name))) < name_len) - avio_skip(pb, name_len - ret); - av_log(s, AV_LOG_TRACE, "%d stream %d name_len %2d type %d len %4d <%s>\n", - i, stream_num, name_len, value_type, value_len, name); - - if (!strcmp(name, "AspectRatioX")){ - int aspect_x = get_value(s->pb, value_type, 16); - if(stream_num < 128) - asf->dar[stream_num].num = aspect_x; - } else if(!strcmp(name, "AspectRatioY")){ - int aspect_y = get_value(s->pb, value_type, 16); - if(stream_num < 128) - asf->dar[stream_num].den = aspect_y; - } else { - get_tag(s, name, value_type, value_len, 16); - } - } - - return 0; -} - -static int asf_read_marker(AVFormatContext *s, int64_t size) -{ - AVIOContext *pb = s->pb; - ASFContext *asf = s->priv_data; - int i, count, name_len, ret; - char name[1024]; - - avio_rl64(pb); // reserved 16 bytes - avio_rl64(pb); // ... - count = avio_rl32(pb); // markers count - avio_rl16(pb); // reserved 2 bytes - name_len = avio_rl16(pb); // name length - for (i = 0; i < name_len; i++) - avio_r8(pb); // skip the name - - for (i = 0; i < count; i++) { - int64_t pres_time; - int name_len; - - avio_rl64(pb); // offset, 8 bytes - pres_time = avio_rl64(pb); // presentation time - pres_time -= asf->hdr.preroll * 10000; - avio_rl16(pb); // entry length - avio_rl32(pb); // send time - avio_rl32(pb); // flags - name_len = avio_rl32(pb); // name length - if ((ret = avio_get_str16le(pb, name_len * 2, name, - sizeof(name))) < name_len) - avio_skip(pb, name_len - ret); - avpriv_new_chapter(s, i, (AVRational) { 1, 10000000 }, pres_time, - AV_NOPTS_VALUE, name); - } - - return 0; -} - -static int asf_read_header(AVFormatContext *s) -{ - ASFContext *asf = s->priv_data; - ff_asf_guid g; - AVIOContext *pb = s->pb; - int i; - int64_t gsize; - - ff_get_guid(pb, &g); - if (ff_guidcmp(&g, &ff_asf_header)) - return AVERROR_INVALIDDATA; - avio_rl64(pb); - avio_rl32(pb); - avio_r8(pb); - avio_r8(pb); - memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid)); - - for (i = 0; i<128; i++) - asf->streams[i].stream_language_index = 128; // invalid stream index means no language info - - for (;;) { - uint64_t gpos = avio_tell(pb); - ff_get_guid(pb, &g); - gsize = avio_rl64(pb); - print_guid(&g); - if (!ff_guidcmp(&g, &ff_asf_data_header)) { - asf->data_object_offset = avio_tell(pb); - /* If not streaming, gsize is not unlimited (how?), - * and there is enough space in the file.. */ - if (!(asf->hdr.flags & 0x01) && gsize >= 100) - asf->data_object_size = gsize - 24; - else - asf->data_object_size = (uint64_t)-1; - break; - } - if (gsize < 24) - return AVERROR_INVALIDDATA; - if (!ff_guidcmp(&g, &ff_asf_file_header)) { - int ret = asf_read_file_properties(s, gsize); - if (ret < 0) - return ret; - } else if (!ff_guidcmp(&g, &ff_asf_stream_header)) { - int ret = asf_read_stream_properties(s, gsize); - if (ret < 0) - return ret; - } else if (!ff_guidcmp(&g, &ff_asf_comment_header)) { - asf_read_content_desc(s, gsize); - } else if (!ff_guidcmp(&g, &ff_asf_language_guid)) { - asf_read_language_list(s, gsize); - } else if (!ff_guidcmp(&g, &ff_asf_extended_content_header)) { - asf_read_ext_content_desc(s, gsize); - } else if (!ff_guidcmp(&g, &ff_asf_metadata_header)) { - asf_read_metadata(s, gsize); - } else if (!ff_guidcmp(&g, &ff_asf_metadata_library_header)) { - asf_read_metadata(s, gsize); - } else if (!ff_guidcmp(&g, &ff_asf_ext_stream_header)) { - asf_read_ext_stream_properties(s, gsize); - - // there could be a optional stream properties object to follow - // if so the next iteration will pick it up - continue; - } else if (!ff_guidcmp(&g, &ff_asf_head1_guid)) { - ff_get_guid(pb, &g); - avio_skip(pb, 6); - continue; - } else if (!ff_guidcmp(&g, &ff_asf_marker_header)) { - asf_read_marker(s, gsize); - } else if (avio_feof(pb)) { - return AVERROR_EOF; - } else { - if (!s->keylen) { - if (!ff_guidcmp(&g, &ff_asf_content_encryption)) { - unsigned int len; - int ret; - AVPacket pkt; - av_log(s, AV_LOG_WARNING, - "DRM protected stream detected, decoding will likely fail!\n"); - len= avio_rl32(pb); - av_log(s, AV_LOG_DEBUG, "Secret data:\n"); - - if ((ret = av_get_packet(pb, &pkt, len)) < 0) - return ret; - av_hex_dump_log(s, AV_LOG_DEBUG, pkt.data, pkt.size); - av_free_packet(&pkt); - len= avio_rl32(pb); - get_tag(s, "ASF_Protection_Type", -1, len, 32); - len= avio_rl32(pb); - get_tag(s, "ASF_Key_ID", -1, len, 32); - len= avio_rl32(pb); - get_tag(s, "ASF_License_URL", -1, len, 32); - } else if (!ff_guidcmp(&g, &ff_asf_ext_content_encryption)) { - av_log(s, AV_LOG_WARNING, - "Ext DRM protected stream detected, decoding will likely fail!\n"); - av_dict_set(&s->metadata, "encryption", "ASF Extended Content Encryption", 0); - } else if (!ff_guidcmp(&g, &ff_asf_digital_signature)) { - av_log(s, AV_LOG_INFO, "Digital signature detected!\n"); - } - } - } - if (avio_tell(pb) != gpos + gsize) - av_log(s, AV_LOG_DEBUG, - "gpos mismatch our pos=%"PRIu64", end=%"PRId64"\n", - avio_tell(pb) - gpos, gsize); - avio_seek(pb, gpos + gsize, SEEK_SET); - } - ff_get_guid(pb, &g); - avio_rl64(pb); - avio_r8(pb); - avio_r8(pb); - if (avio_feof(pb)) - return AVERROR_EOF; - asf->data_offset = avio_tell(pb); - asf->packet_size_left = 0; - - for (i = 0; i < 128; i++) { - int stream_num = asf->asfid2avid[i]; - if (stream_num >= 0) { - AVStream *st = s->streams[stream_num]; - if (!st->codec->bit_rate) - st->codec->bit_rate = asf->stream_bitrates[i]; - if (asf->dar[i].num > 0 && asf->dar[i].den > 0) { - av_reduce(&st->sample_aspect_ratio.num, - &st->sample_aspect_ratio.den, - asf->dar[i].num, asf->dar[i].den, INT_MAX); - } else if ((asf->dar[0].num > 0) && (asf->dar[0].den > 0) && - // Use ASF container value if the stream doesn't set AR. - (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)) - av_reduce(&st->sample_aspect_ratio.num, - &st->sample_aspect_ratio.den, - asf->dar[0].num, asf->dar[0].den, INT_MAX); - - av_log(s, AV_LOG_TRACE, "i=%d, st->codec->codec_type:%d, asf->dar %d:%d sar=%d:%d\n", - i, st->codec->codec_type, asf->dar[i].num, asf->dar[i].den, - st->sample_aspect_ratio.num, st->sample_aspect_ratio.den); - - // copy and convert language codes to the frontend - if (asf->streams[i].stream_language_index < 128) { - const char *rfc1766 = asf->stream_languages[asf->streams[i].stream_language_index]; - if (rfc1766 && strlen(rfc1766) > 1) { - const char primary_tag[3] = { rfc1766[0], rfc1766[1], '\0' }; // ignore country code if any - const char *iso6392 = av_convert_lang_to(primary_tag, - AV_LANG_ISO639_2_BIBL); - if (iso6392) - av_dict_set(&st->metadata, "language", iso6392, 0); - } - } - } - } - - ff_metadata_conv(&s->metadata, NULL, ff_asf_metadata_conv); - - return 0; -} - -#define DO_2BITS(bits, var, defval) \ - switch (bits & 3) { \ - case 3: \ - var = avio_rl32(pb); \ - rsize += 4; \ - break; \ - case 2: \ - var = avio_rl16(pb); \ - rsize += 2; \ - break; \ - case 1: \ - var = avio_r8(pb); \ - rsize++; \ - break; \ - default: \ - var = defval; \ - break; \ - } - -/** - * Load a single ASF packet into the demuxer. - * @param s demux context - * @param pb context to read data from - * @return 0 on success, <0 on error - */ -static int asf_get_packet(AVFormatContext *s, AVIOContext *pb) -{ - ASFContext *asf = s->priv_data; - uint32_t packet_length, padsize; - int rsize = 8; - int c, d, e, off; - - // if we do not know packet size, allow skipping up to 32 kB - off = 32768; - if (asf->no_resync_search) - off = 3; - else if (s->packet_size > 0) - off = (avio_tell(pb) - s->internal->data_offset) % s->packet_size + 3; - - c = d = e = -1; - while (off-- > 0) { - c = d; - d = e; - e = avio_r8(pb); - if (c == 0x82 && !d && !e) - break; - } - - if (c != 0x82) { - /* This code allows handling of -EAGAIN at packet boundaries (i.e. - * if the packet sync code above triggers -EAGAIN). This does not - * imply complete -EAGAIN handling support at random positions in - * the stream. */ - if (pb->error == AVERROR(EAGAIN)) - return AVERROR(EAGAIN); - if (!avio_feof(pb)) - av_log(s, AV_LOG_ERROR, - "ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb)); - } - if ((c & 0x8f) == 0x82) { - if (d || e) { - if (!avio_feof(pb)) - av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n"); - return AVERROR_INVALIDDATA; - } - c = avio_r8(pb); - d = avio_r8(pb); - rsize += 3; - } else if(!avio_feof(pb)) { - avio_seek(pb, -1, SEEK_CUR); // FIXME - } - - asf->packet_flags = c; - asf->packet_property = d; - - DO_2BITS(asf->packet_flags >> 5, packet_length, s->packet_size); - DO_2BITS(asf->packet_flags >> 1, padsize, 0); // sequence ignored - DO_2BITS(asf->packet_flags >> 3, padsize, 0); // padding length - - // the following checks prevent overflows and infinite loops - if (!packet_length || packet_length >= (1U << 29)) { - av_log(s, AV_LOG_ERROR, - "invalid packet_length %"PRIu32" at:%"PRId64"\n", - packet_length, avio_tell(pb)); - return AVERROR_INVALIDDATA; - } - if (padsize >= packet_length) { - av_log(s, AV_LOG_ERROR, - "invalid padsize %"PRIu32" at:%"PRId64"\n", padsize, avio_tell(pb)); - return AVERROR_INVALIDDATA; - } - - asf->packet_timestamp = avio_rl32(pb); - avio_rl16(pb); /* duration */ - // rsize has at least 11 bytes which have to be present - - if (asf->packet_flags & 0x01) { - asf->packet_segsizetype = avio_r8(pb); - rsize++; - asf->packet_segments = asf->packet_segsizetype & 0x3f; - } else { - asf->packet_segments = 1; - asf->packet_segsizetype = 0x80; - } - if (rsize > packet_length - padsize) { - asf->packet_size_left = 0; - av_log(s, AV_LOG_ERROR, - "invalid packet header length %d for pktlen %"PRIu32"-%"PRIu32" at %"PRId64"\n", - rsize, packet_length, padsize, avio_tell(pb)); - return AVERROR_INVALIDDATA; - } - asf->packet_size_left = packet_length - padsize - rsize; - if (packet_length < asf->hdr.min_pktsize) - padsize += asf->hdr.min_pktsize - packet_length; - asf->packet_padsize = padsize; - av_log(s, AV_LOG_TRACE, "packet: size=%d padsize=%d left=%d\n", - s->packet_size, asf->packet_padsize, asf->packet_size_left); - return 0; -} - -/** - * - * @return <0 if error - */ -static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb) -{ - ASFContext *asf = s->priv_data; - ASFStream *asfst; - int rsize = 1; - int num = avio_r8(pb); - int i; - int64_t ts0, ts1 av_unused; - - asf->packet_segments--; - asf->packet_key_frame = num >> 7; - asf->stream_index = asf->asfid2avid[num & 0x7f]; - asfst = &asf->streams[num & 0x7f]; - // sequence should be ignored! - DO_2BITS(asf->packet_property >> 4, asf->packet_seq, 0); - DO_2BITS(asf->packet_property >> 2, asf->packet_frag_offset, 0); - DO_2BITS(asf->packet_property, asf->packet_replic_size, 0); - av_log(asf, AV_LOG_TRACE, "key:%d stream:%d seq:%d offset:%d replic_size:%d\n", - asf->packet_key_frame, asf->stream_index, asf->packet_seq, - asf->packet_frag_offset, asf->packet_replic_size); - if (rsize+(int64_t)asf->packet_replic_size > asf->packet_size_left) { - av_log(s, AV_LOG_ERROR, "packet_replic_size %d is invalid\n", asf->packet_replic_size); - return AVERROR_INVALIDDATA; - } - if (asf->packet_replic_size >= 8) { - int64_t end = avio_tell(pb) + asf->packet_replic_size; - AVRational aspect; - asfst->packet_obj_size = avio_rl32(pb); - if (asfst->packet_obj_size >= (1 << 24) || asfst->packet_obj_size <= 0) { - av_log(s, AV_LOG_ERROR, "packet_obj_size invalid\n"); - asfst->packet_obj_size = 0; - return AVERROR_INVALIDDATA; - } - asf->packet_frag_timestamp = avio_rl32(pb); // timestamp - - for (i = 0; i < asfst->payload_ext_ct; i++) { - ASFPayload *p = &asfst->payload[i]; - int size = p->size; - int64_t payend; - if (size == 0xFFFF) - size = avio_rl16(pb); - payend = avio_tell(pb) + size; - if (payend > end) { - av_log(s, AV_LOG_ERROR, "too long payload\n"); - break; - } - switch (p->type) { - case 0x50: -// duration = avio_rl16(pb); - break; - case 0x54: - aspect.num = avio_r8(pb); - aspect.den = avio_r8(pb); - if (aspect.num > 0 && aspect.den > 0 && asf->stream_index >= 0) { - s->streams[asf->stream_index]->sample_aspect_ratio = aspect; - } - break; - case 0x2A: - avio_skip(pb, 8); - ts0 = avio_rl64(pb); - ts1 = avio_rl64(pb); - if (ts0!= -1) asf->packet_frag_timestamp = ts0/10000; - else asf->packet_frag_timestamp = AV_NOPTS_VALUE; - asf->ts_is_pts = 1; - break; - case 0x5B: - case 0xB7: - case 0xCC: - case 0xC0: - case 0xA0: - //unknown - break; - } - avio_seek(pb, payend, SEEK_SET); - } - - avio_seek(pb, end, SEEK_SET); - rsize += asf->packet_replic_size; // FIXME - check validity - } else if (asf->packet_replic_size == 1) { - // multipacket - frag_offset is beginning timestamp - asf->packet_time_start = asf->packet_frag_offset; - asf->packet_frag_offset = 0; - asf->packet_frag_timestamp = asf->packet_timestamp; - - asf->packet_time_delta = avio_r8(pb); - rsize++; - } else if (asf->packet_replic_size != 0) { - av_log(s, AV_LOG_ERROR, "unexpected packet_replic_size of %d\n", - asf->packet_replic_size); - return AVERROR_INVALIDDATA; - } - if (asf->packet_flags & 0x01) { - DO_2BITS(asf->packet_segsizetype >> 6, asf->packet_frag_size, 0); // 0 is illegal - if (rsize > asf->packet_size_left) { - av_log(s, AV_LOG_ERROR, "packet_replic_size is invalid\n"); - return AVERROR_INVALIDDATA; - } else if (asf->packet_frag_size > asf->packet_size_left - rsize) { - if (asf->packet_frag_size > asf->packet_size_left - rsize + asf->packet_padsize) { - av_log(s, AV_LOG_ERROR, "packet_frag_size is invalid (%d-%d)\n", - asf->packet_size_left, rsize); - return AVERROR_INVALIDDATA; - } else { - int diff = asf->packet_frag_size - (asf->packet_size_left - rsize); - asf->packet_size_left += diff; - asf->packet_padsize -= diff; - } - } - } else { - asf->packet_frag_size = asf->packet_size_left - rsize; - } - if (asf->packet_replic_size == 1) { - asf->packet_multi_size = asf->packet_frag_size; - if (asf->packet_multi_size > asf->packet_size_left) - return AVERROR_INVALIDDATA; - } - asf->packet_size_left -= rsize; - - return 0; -} - -/** - * Parse data from individual ASF packets (which were previously loaded - * with asf_get_packet()). - * @param s demux context - * @param pb context to read data from - * @param pkt pointer to store packet data into - * @return 0 if data was stored in pkt, <0 on error or 1 if more ASF - * packets need to be loaded (through asf_get_packet()) - */ -static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt) -{ - ASFContext *asf = s->priv_data; - ASFStream *asf_st = 0; - for (;;) { - int ret; - if (avio_feof(pb)) - return AVERROR_EOF; - if (asf->packet_size_left < FRAME_HEADER_SIZE || - asf->packet_segments < 1 && asf->packet_time_start == 0) { - int ret = asf->packet_size_left + asf->packet_padsize; - - assert(ret >= 0); - /* fail safe */ - avio_skip(pb, ret); - - asf->packet_pos = avio_tell(pb); - if (asf->data_object_size != (uint64_t)-1 && - (asf->packet_pos - asf->data_object_offset >= asf->data_object_size)) - return AVERROR_EOF; /* Do not exceed the size of the data object */ - return 1; - } - if (asf->packet_time_start == 0) { - if (asf_read_frame_header(s, pb) < 0) { - asf->packet_time_start = asf->packet_segments = 0; - continue; - } - if (asf->stream_index < 0 || - s->streams[asf->stream_index]->discard >= AVDISCARD_ALL || - (!asf->packet_key_frame && - (s->streams[asf->stream_index]->discard >= AVDISCARD_NONKEY || asf->streams[s->streams[asf->stream_index]->id].skip_to_key))) { - asf->packet_time_start = 0; - /* unhandled packet (should not happen) */ - avio_skip(pb, asf->packet_frag_size); - asf->packet_size_left -= asf->packet_frag_size; - if (asf->stream_index < 0) - av_log(s, AV_LOG_ERROR, "ff asf skip %d (unknown stream)\n", - asf->packet_frag_size); - continue; - } - asf->asf_st = &asf->streams[s->streams[asf->stream_index]->id]; - asf->asf_st->skip_to_key = 0; - } - asf_st = asf->asf_st; - av_assert0(asf_st); - - if (!asf_st->frag_offset && asf->packet_frag_offset) { - av_log(s, AV_LOG_TRACE, "skipping asf data pkt with fragment offset for " - "stream:%d, expected:%d but got %d from pkt)\n", - asf->stream_index, asf_st->frag_offset, - asf->packet_frag_offset); - avio_skip(pb, asf->packet_frag_size); - asf->packet_size_left -= asf->packet_frag_size; - continue; - } - - if (asf->packet_replic_size == 1) { - // frag_offset is here used as the beginning timestamp - asf->packet_frag_timestamp = asf->packet_time_start; - asf->packet_time_start += asf->packet_time_delta; - asf_st->packet_obj_size = asf->packet_frag_size = avio_r8(pb); - asf->packet_size_left--; - asf->packet_multi_size--; - if (asf->packet_multi_size < asf_st->packet_obj_size) { - asf->packet_time_start = 0; - avio_skip(pb, asf->packet_multi_size); - asf->packet_size_left -= asf->packet_multi_size; - continue; - } - asf->packet_multi_size -= asf_st->packet_obj_size; - } - - if (asf_st->pkt.size != asf_st->packet_obj_size || - // FIXME is this condition sufficient? - asf_st->frag_offset + asf->packet_frag_size > asf_st->pkt.size) { - int ret; - - if (asf_st->pkt.data) { - av_log(s, AV_LOG_INFO, - "freeing incomplete packet size %d, new %d\n", - asf_st->pkt.size, asf_st->packet_obj_size); - asf_st->frag_offset = 0; - av_free_packet(&asf_st->pkt); - } - /* new packet */ - if ((ret = av_new_packet(&asf_st->pkt, asf_st->packet_obj_size)) < 0) - return ret; - asf_st->seq = asf->packet_seq; - if (asf->ts_is_pts) { - asf_st->pkt.pts = asf->packet_frag_timestamp - asf->hdr.preroll; - } else - asf_st->pkt.dts = asf->packet_frag_timestamp - asf->hdr.preroll; - asf_st->pkt.stream_index = asf->stream_index; - asf_st->pkt.pos = asf_st->packet_pos = asf->packet_pos; - asf_st->pkt_clean = 0; - - if (asf_st->pkt.data && asf_st->palette_changed) { - uint8_t *pal; - pal = av_packet_new_side_data(&asf_st->pkt, AV_PKT_DATA_PALETTE, - AVPALETTE_SIZE); - if (!pal) { - av_log(s, AV_LOG_ERROR, "Cannot append palette to packet\n"); - } else { - memcpy(pal, asf_st->palette, AVPALETTE_SIZE); - asf_st->palette_changed = 0; - } - } - av_log(asf, AV_LOG_TRACE, "new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n", - asf->stream_index, asf->packet_key_frame, - asf_st->pkt.flags & AV_PKT_FLAG_KEY, - s->streams[asf->stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO, - asf_st->packet_obj_size); - if (s->streams[asf->stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO) - asf->packet_key_frame = 1; - if (asf->packet_key_frame) - asf_st->pkt.flags |= AV_PKT_FLAG_KEY; - } - - /* read data */ - av_log(asf, AV_LOG_TRACE, "READ PACKET s:%d os:%d o:%d,%d l:%d DATA:%p\n", - s->packet_size, asf_st->pkt.size, asf->packet_frag_offset, - asf_st->frag_offset, asf->packet_frag_size, asf_st->pkt.data); - asf->packet_size_left -= asf->packet_frag_size; - if (asf->packet_size_left < 0) - continue; - - if (asf->packet_frag_offset >= asf_st->pkt.size || - asf->packet_frag_size > asf_st->pkt.size - asf->packet_frag_offset) { - av_log(s, AV_LOG_ERROR, - "packet fragment position invalid %u,%u not in %u\n", - asf->packet_frag_offset, asf->packet_frag_size, - asf_st->pkt.size); - continue; - } - - if (asf->packet_frag_offset != asf_st->frag_offset && !asf_st->pkt_clean) { - memset(asf_st->pkt.data + asf_st->frag_offset, 0, asf_st->pkt.size - asf_st->frag_offset); - asf_st->pkt_clean = 1; - } - - ret = avio_read(pb, asf_st->pkt.data + asf->packet_frag_offset, - asf->packet_frag_size); - if (ret != asf->packet_frag_size) { - if (ret < 0 || asf->packet_frag_offset + ret == 0) - return ret < 0 ? ret : AVERROR_EOF; - - if (asf_st->ds_span > 1) { - // scrambling, we can either drop it completely or fill the remainder - // TODO: should we fill the whole packet instead of just the current - // fragment? - memset(asf_st->pkt.data + asf->packet_frag_offset + ret, 0, - asf->packet_frag_size - ret); - ret = asf->packet_frag_size; - } else { - // no scrambling, so we can return partial packets - av_shrink_packet(&asf_st->pkt, asf->packet_frag_offset + ret); - } - } - if (s->key && s->keylen == 20) - ff_asfcrypt_dec(s->key, asf_st->pkt.data + asf->packet_frag_offset, - ret); - asf_st->frag_offset += ret; - /* test if whole packet is read */ - if (asf_st->frag_offset == asf_st->pkt.size) { - // workaround for macroshit radio DVR-MS files - if (s->streams[asf->stream_index]->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO && - asf_st->pkt.size > 100) { - int i; - for (i = 0; i < asf_st->pkt.size && !asf_st->pkt.data[i]; i++) - ; - if (i == asf_st->pkt.size) { - av_log(s, AV_LOG_DEBUG, "discarding ms fart\n"); - asf_st->frag_offset = 0; - av_free_packet(&asf_st->pkt); - continue; - } - } - - /* return packet */ - if (asf_st->ds_span > 1) { - if (asf_st->pkt.size != asf_st->ds_packet_size * asf_st->ds_span) { - av_log(s, AV_LOG_ERROR, - "pkt.size != ds_packet_size * ds_span (%d %d %d)\n", - asf_st->pkt.size, asf_st->ds_packet_size, - asf_st->ds_span); - } else { - /* packet descrambling */ - AVBufferRef *buf = av_buffer_alloc(asf_st->pkt.size + - FF_INPUT_BUFFER_PADDING_SIZE); - if (buf) { - uint8_t *newdata = buf->data; - int offset = 0; - memset(newdata + asf_st->pkt.size, 0, - FF_INPUT_BUFFER_PADDING_SIZE); - while (offset < asf_st->pkt.size) { - int off = offset / asf_st->ds_chunk_size; - int row = off / asf_st->ds_span; - int col = off % asf_st->ds_span; - int idx = row + col * asf_st->ds_packet_size / asf_st->ds_chunk_size; - assert(offset + asf_st->ds_chunk_size <= asf_st->pkt.size); - assert(idx + 1 <= asf_st->pkt.size / asf_st->ds_chunk_size); - memcpy(newdata + offset, - asf_st->pkt.data + idx * asf_st->ds_chunk_size, - asf_st->ds_chunk_size); - offset += asf_st->ds_chunk_size; - } - av_buffer_unref(&asf_st->pkt.buf); - asf_st->pkt.buf = buf; - asf_st->pkt.data = buf->data; - } - } - } - asf_st->frag_offset = 0; - *pkt = asf_st->pkt; -#if FF_API_DESTRUCT_PACKET -FF_DISABLE_DEPRECATION_WARNINGS - asf_st->pkt.destruct = NULL; -FF_ENABLE_DEPRECATION_WARNINGS -#endif - asf_st->pkt.buf = 0; - asf_st->pkt.size = 0; - asf_st->pkt.data = 0; - asf_st->pkt.side_data_elems = 0; - asf_st->pkt.side_data = NULL; - break; // packet completed - } - } - return 0; -} - -static int asf_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - ASFContext *asf = s->priv_data; - - for (;;) { - int ret; - - /* parse cached packets, if any */ - if ((ret = asf_parse_packet(s, s->pb, pkt)) <= 0) - return ret; - if ((ret = asf_get_packet(s, s->pb)) < 0) - assert(asf->packet_size_left < FRAME_HEADER_SIZE || - asf->packet_segments < 1); - asf->packet_time_start = 0; - } -} - -// Added to support seeking after packets have been read -// If information is not reset, read_packet fails due to -// leftover information from previous reads -static void asf_reset_header(AVFormatContext *s) -{ - ASFContext *asf = s->priv_data; - ASFStream *asf_st; - int i; - - asf->packet_size_left = 0; - asf->packet_flags = 0; - asf->packet_property = 0; - asf->packet_timestamp = 0; - asf->packet_segsizetype = 0; - asf->packet_segments = 0; - asf->packet_seq = 0; - asf->packet_replic_size = 0; - asf->packet_key_frame = 0; - asf->packet_padsize = 0; - asf->packet_frag_offset = 0; - asf->packet_frag_size = 0; - asf->packet_frag_timestamp = 0; - asf->packet_multi_size = 0; - asf->packet_time_delta = 0; - asf->packet_time_start = 0; - - for (i = 0; i < 128; i++) { - asf_st = &asf->streams[i]; - av_free_packet(&asf_st->pkt); - asf_st->packet_obj_size = 0; - asf_st->frag_offset = 0; - asf_st->seq = 0; - } - asf->asf_st = NULL; -} - -static void skip_to_key(AVFormatContext *s) -{ - ASFContext *asf = s->priv_data; - int i; - - for (i = 0; i < 128; i++) { - int j = asf->asfid2avid[i]; - ASFStream *asf_st = &asf->streams[i]; - if (j < 0 || s->streams[j]->codec->codec_type != AVMEDIA_TYPE_VIDEO) - continue; - - asf_st->skip_to_key = 1; - } -} - -static int asf_read_close(AVFormatContext *s) -{ - asf_reset_header(s); - - return 0; -} - -static int64_t asf_read_pts(AVFormatContext *s, int stream_index, - int64_t *ppos, int64_t pos_limit) -{ - ASFContext *asf = s->priv_data; - AVPacket pkt1, *pkt = &pkt1; - ASFStream *asf_st; - int64_t pts; - int64_t pos = *ppos; - int i; - int64_t start_pos[ASF_MAX_STREAMS]; - - for (i = 0; i < s->nb_streams; i++) - start_pos[i] = pos; - - if (s->packet_size > 0) - pos = (pos + s->packet_size - 1 - s->internal->data_offset) / - s->packet_size * s->packet_size + - s->internal->data_offset; - *ppos = pos; - if (avio_seek(s->pb, pos, SEEK_SET) < 0) - return AV_NOPTS_VALUE; - - ff_read_frame_flush(s); - asf_reset_header(s); - for (;;) { - if (av_read_frame(s, pkt) < 0) { - av_log(s, AV_LOG_INFO, "asf_read_pts failed\n"); - return AV_NOPTS_VALUE; - } - - pts = pkt->dts; - - av_free_packet(pkt); - if (pkt->flags & AV_PKT_FLAG_KEY) { - i = pkt->stream_index; - - asf_st = &asf->streams[s->streams[i]->id]; - -// assert((asf_st->packet_pos - s->data_offset) % s->packet_size == 0); - pos = asf_st->packet_pos; - - av_add_index_entry(s->streams[i], pos, pts, pkt->size, - pos - start_pos[i] + 1, AVINDEX_KEYFRAME); - start_pos[i] = asf_st->packet_pos + 1; - - if (pkt->stream_index == stream_index) - break; - } - } - - *ppos = pos; - return pts; -} - -static int asf_build_simple_index(AVFormatContext *s, int stream_index) -{ - ff_asf_guid g; - ASFContext *asf = s->priv_data; - int64_t current_pos = avio_tell(s->pb); - int64_t ret; - - if((ret = avio_seek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET)) < 0) { - return ret; - } - - if ((ret = ff_get_guid(s->pb, &g)) < 0) - goto end; - - /* the data object can be followed by other top-level objects, - * skip them until the simple index object is reached */ - while (ff_guidcmp(&g, &ff_asf_simple_index_header)) { - int64_t gsize = avio_rl64(s->pb); - if (gsize < 24 || avio_feof(s->pb)) { - goto end; - } - avio_skip(s->pb, gsize - 24); - if ((ret = ff_get_guid(s->pb, &g)) < 0) - goto end; - } - - { - int64_t itime, last_pos = -1; - int pct, ict; - int i; - int64_t av_unused gsize = avio_rl64(s->pb); - if ((ret = ff_get_guid(s->pb, &g)) < 0) - goto end; - itime = avio_rl64(s->pb); - pct = avio_rl32(s->pb); - ict = avio_rl32(s->pb); - av_log(s, AV_LOG_DEBUG, - "itime:0x%"PRIx64", pct:%d, ict:%d\n", itime, pct, ict); - - for (i = 0; i < ict; i++) { - int pktnum = avio_rl32(s->pb); - int pktct = avio_rl16(s->pb); - int64_t pos = s->internal->data_offset + s->packet_size * (int64_t)pktnum; - int64_t index_pts = FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0); - - if (pos != last_pos) { - av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d pts: %"PRId64"\n", - pktnum, pktct, index_pts); - av_add_index_entry(s->streams[stream_index], pos, index_pts, - s->packet_size, 0, AVINDEX_KEYFRAME); - last_pos = pos; - } - } - asf->index_read = ict > 1; - } -end: -// if (avio_feof(s->pb)) { -// ret = 0; -// } - avio_seek(s->pb, current_pos, SEEK_SET); - return ret; -} - -static int asf_read_seek(AVFormatContext *s, int stream_index, - int64_t pts, int flags) -{ - ASFContext *asf = s->priv_data; - AVStream *st = s->streams[stream_index]; - int ret = 0; - - if (s->packet_size <= 0) - return -1; - - /* Try using the protocol's read_seek if available */ - if (s->pb) { - int64_t ret = avio_seek_time(s->pb, stream_index, pts, flags); - if (ret >= 0) - asf_reset_header(s); - if (ret != AVERROR(ENOSYS)) - return ret; - } - - /* explicitly handle the case of seeking to 0 */ - if (!pts) { - asf_reset_header(s); - avio_seek(s->pb, s->internal->data_offset, SEEK_SET); - return 0; - } - - if (!asf->index_read) { - ret = asf_build_simple_index(s, stream_index); - if (ret < 0) - asf->index_read = -1; - } - - if (asf->index_read > 0 && st->index_entries) { - int index = av_index_search_timestamp(st, pts, flags); - if (index >= 0) { - /* find the position */ - uint64_t pos = st->index_entries[index].pos; - - /* do the seek */ - av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos); - if(avio_seek(s->pb, pos, SEEK_SET) < 0) - return -1; - asf_reset_header(s); - skip_to_key(s); - return 0; - } - } - /* no index or seeking by index failed */ - if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0) - return -1; - asf_reset_header(s); - skip_to_key(s); - return 0; -} - -AVInputFormat ff_asf_demuxer = { - .name = "asf", - .long_name = NULL_IF_CONFIG_SMALL("ASF (Advanced / Active Streaming Format)"), - .priv_data_size = sizeof(ASFContext), - .read_probe = asf_probe, - .read_header = asf_read_header, - .read_packet = asf_read_packet, - .read_close = asf_read_close, - .read_seek = asf_read_seek, - .read_timestamp = asf_read_pts, - .flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH, - .priv_class = &asf_class, -}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/asfdec_f.c ffmpeg-2.7.2~trusty~ppa1/libavformat/asfdec_f.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/asfdec_f.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/asfdec_f.c 2015-07-28 17:20:07.000000000 +0000 @@ -0,0 +1,1699 @@ +/* + * ASF compatible demuxer + * Copyright (c) 2000, 2001 Fabrice Bellard + * + * 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 + +#include "libavutil/attributes.h" +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/bswap.h" +#include "libavutil/common.h" +#include "libavutil/dict.h" +#include "libavutil/internal.h" +#include "libavutil/mathematics.h" +#include "libavutil/opt.h" +#include "avformat.h" +#include "avio_internal.h" +#include "avlanguage.h" +#include "id3v2.h" +#include "internal.h" +#include "riff.h" +#include "asf.h" +#include "asfcrypt.h" + +typedef struct ASFPayload { + uint8_t type; + uint16_t size; +} ASFPayload; + +typedef struct ASFStream { + int num; + unsigned char seq; + /* use for reading */ + AVPacket pkt; + int frag_offset; + int packet_obj_size; + int timestamp; + int64_t duration; + int skip_to_key; + int pkt_clean; + + int ds_span; /* descrambling */ + int ds_packet_size; + int ds_chunk_size; + + int64_t packet_pos; + + uint16_t stream_language_index; + + int palette_changed; + uint32_t palette[256]; + + int payload_ext_ct; + ASFPayload payload[8]; +} ASFStream; + +typedef struct ASFContext { + const AVClass *class; + int asfid2avid[128]; ///< conversion table from asf ID 2 AVStream ID + ASFStream streams[128]; ///< it's max number and it's not that big + uint32_t stream_bitrates[128]; ///< max number of streams, bitrate for each (for streaming) + AVRational dar[128]; + char stream_languages[128][6]; ///< max number of streams, language for each (RFC1766, e.g. en-US) + /* non streamed additonnal info */ + /* packet filling */ + int packet_size_left; + /* only for reading */ + uint64_t data_offset; ///< beginning of the first data packet + uint64_t data_object_offset; ///< data object offset (excl. GUID & size) + uint64_t data_object_size; ///< size of the data object + int index_read; + + ASFMainHeader hdr; + + int packet_flags; + int packet_property; + int packet_timestamp; + int packet_segsizetype; + int packet_segments; + int packet_seq; + int packet_replic_size; + int packet_key_frame; + int packet_padsize; + unsigned int packet_frag_offset; + unsigned int packet_frag_size; + int64_t packet_frag_timestamp; + int ts_is_pts; + int packet_multi_size; + int packet_time_delta; + int packet_time_start; + int64_t packet_pos; + + int stream_index; + + ASFStream *asf_st; ///< currently decoded stream + + int no_resync_search; + int export_xmp; + + int uses_std_ecc; +} ASFContext; + +static const AVOption options[] = { + { "no_resync_search", "Don't try to resynchronize by looking for a certain optional start code", offsetof(ASFContext, no_resync_search), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, + { "export_xmp", "Export full XMP metadata", offsetof(ASFContext, export_xmp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, + { NULL }, +}; + +static const AVClass asf_class = { + .class_name = "asf demuxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +#undef NDEBUG +#include + +#define ASF_MAX_STREAMS 127 +#define FRAME_HEADER_SIZE 6 +// Fix Me! FRAME_HEADER_SIZE may be different. +// (7 is known to be too large for GipsyGuitar.wmv) + +#ifdef DEBUG +static const ff_asf_guid stream_bitrate_guid = { /* (http://get.to/sdp) */ + 0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2 +}; + +#define PRINT_IF_GUID(g, cmp) \ + if (!ff_guidcmp(g, &cmp)) \ + av_log(NULL, AV_LOG_TRACE, "(GUID: %s) ", # cmp) + +static void print_guid(ff_asf_guid *g) +{ + int i; + PRINT_IF_GUID(g, ff_asf_header); + else PRINT_IF_GUID(g, ff_asf_file_header); + else PRINT_IF_GUID(g, ff_asf_stream_header); + else PRINT_IF_GUID(g, ff_asf_audio_stream); + else PRINT_IF_GUID(g, ff_asf_audio_conceal_none); + else PRINT_IF_GUID(g, ff_asf_video_stream); + else PRINT_IF_GUID(g, ff_asf_video_conceal_none); + else PRINT_IF_GUID(g, ff_asf_command_stream); + else PRINT_IF_GUID(g, ff_asf_comment_header); + else PRINT_IF_GUID(g, ff_asf_codec_comment_header); + else PRINT_IF_GUID(g, ff_asf_codec_comment1_header); + else PRINT_IF_GUID(g, ff_asf_data_header); + else PRINT_IF_GUID(g, ff_asf_simple_index_header); + else PRINT_IF_GUID(g, ff_asf_head1_guid); + else PRINT_IF_GUID(g, ff_asf_head2_guid); + else PRINT_IF_GUID(g, ff_asf_my_guid); + else PRINT_IF_GUID(g, ff_asf_ext_stream_header); + else PRINT_IF_GUID(g, ff_asf_extended_content_header); + else PRINT_IF_GUID(g, ff_asf_ext_stream_embed_stream_header); + else PRINT_IF_GUID(g, ff_asf_ext_stream_audio_stream); + else PRINT_IF_GUID(g, ff_asf_metadata_header); + else PRINT_IF_GUID(g, ff_asf_metadata_library_header); + else PRINT_IF_GUID(g, ff_asf_marker_header); + else PRINT_IF_GUID(g, stream_bitrate_guid); + else PRINT_IF_GUID(g, ff_asf_language_guid); + else + av_log(NULL, AV_LOG_TRACE, "(GUID: unknown) "); + for (i = 0; i < 16; i++) + av_log(NULL, AV_LOG_TRACE, " 0x%02x,", (*g)[i]); + av_log(NULL, AV_LOG_TRACE, "}\n"); +} +#undef PRINT_IF_GUID +#else +#define print_guid(g) while(0) +#endif + +static int asf_probe(AVProbeData *pd) +{ + /* check file header */ + if (!ff_guidcmp(pd->buf, &ff_asf_header)) + return AVPROBE_SCORE_MAX; + else + return 0; +} + +/* size of type 2 (BOOL) is 32bit for "Extended Content Description Object" + * but 16 bit for "Metadata Object" and "Metadata Library Object" */ +static int get_value(AVIOContext *pb, int type, int type2_size) +{ + switch (type) { + case 2: + return (type2_size == 32) ? avio_rl32(pb) : avio_rl16(pb); + case 3: + return avio_rl32(pb); + case 4: + return avio_rl64(pb); + case 5: + return avio_rl16(pb); + default: + return INT_MIN; + } +} + +/* MSDN claims that this should be "compatible with the ID3 frame, APIC", + * but in reality this is only loosely similar */ +static int asf_read_picture(AVFormatContext *s, int len) +{ + AVPacket pkt = { 0 }; + const CodecMime *mime = ff_id3v2_mime_tags; + enum AVCodecID id = AV_CODEC_ID_NONE; + char mimetype[64]; + uint8_t *desc = NULL; + AVStream *st = NULL; + int ret, type, picsize, desc_len; + + /* type + picsize + mime + desc */ + if (len < 1 + 4 + 2 + 2) { + av_log(s, AV_LOG_ERROR, "Invalid attached picture size: %d.\n", len); + return AVERROR_INVALIDDATA; + } + + /* picture type */ + type = avio_r8(s->pb); + len--; + if (type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || type < 0) { + av_log(s, AV_LOG_WARNING, "Unknown attached picture type: %d.\n", type); + type = 0; + } + + /* picture data size */ + picsize = avio_rl32(s->pb); + len -= 4; + + /* picture MIME type */ + len -= avio_get_str16le(s->pb, len, mimetype, sizeof(mimetype)); + while (mime->id != AV_CODEC_ID_NONE) { + if (!strncmp(mime->str, mimetype, sizeof(mimetype))) { + id = mime->id; + break; + } + mime++; + } + if (id == AV_CODEC_ID_NONE) { + av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n", + mimetype); + return 0; + } + + if (picsize >= len) { + av_log(s, AV_LOG_ERROR, "Invalid attached picture data size: %d >= %d.\n", + picsize, len); + return AVERROR_INVALIDDATA; + } + + /* picture description */ + desc_len = (len - picsize) * 2 + 1; + desc = av_malloc(desc_len); + if (!desc) + return AVERROR(ENOMEM); + len -= avio_get_str16le(s->pb, len - picsize, desc, desc_len); + + ret = av_get_packet(s->pb, &pkt, picsize); + if (ret < 0) + goto fail; + + st = avformat_new_stream(s, NULL); + if (!st) { + ret = AVERROR(ENOMEM); + goto fail; + } + st->disposition |= AV_DISPOSITION_ATTACHED_PIC; + st->codec->codec_type = AVMEDIA_TYPE_VIDEO; + st->codec->codec_id = id; + st->attached_pic = pkt; + st->attached_pic.stream_index = st->index; + st->attached_pic.flags |= AV_PKT_FLAG_KEY; + + if (*desc) + av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL); + else + av_freep(&desc); + + av_dict_set(&st->metadata, "comment", ff_id3v2_picture_types[type], 0); + + return 0; + +fail: + av_freep(&desc); + av_free_packet(&pkt); + return ret; +} + +static void get_id3_tag(AVFormatContext *s, int len) +{ + ID3v2ExtraMeta *id3v2_extra_meta = NULL; + + ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, len); + if (id3v2_extra_meta) + ff_id3v2_parse_apic(s, &id3v2_extra_meta); + ff_id3v2_free_extra_meta(&id3v2_extra_meta); +} + +static void get_tag(AVFormatContext *s, const char *key, int type, int len, int type2_size) +{ + ASFContext *asf = s->priv_data; + char *value = NULL; + int64_t off = avio_tell(s->pb); +#define LEN 22 + + if ((unsigned)len >= (UINT_MAX - LEN) / 2) + return; + + if (!asf->export_xmp && !strncmp(key, "xmp", 3)) + goto finish; + + value = av_malloc(2 * len + LEN); + if (!value) + goto finish; + + switch (type) { + case ASF_UNICODE: + avio_get_str16le(s->pb, len, value, 2 * len + 1); + break; + case -1: // ASCI + avio_read(s->pb, value, len); + value[len]=0; + break; + case ASF_BYTE_ARRAY: + if (!strcmp(key, "WM/Picture")) { // handle cover art + asf_read_picture(s, len); + } else if (!strcmp(key, "ID3")) { // handle ID3 tag + get_id3_tag(s, len); + } else { + av_log(s, AV_LOG_VERBOSE, "Unsupported byte array in tag %s.\n", key); + } + goto finish; + case ASF_BOOL: + case ASF_DWORD: + case ASF_QWORD: + case ASF_WORD: { + uint64_t num = get_value(s->pb, type, type2_size); + snprintf(value, LEN, "%"PRIu64, num); + break; + } + case ASF_GUID: + av_log(s, AV_LOG_DEBUG, "Unsupported GUID value in tag %s.\n", key); + goto finish; + default: + av_log(s, AV_LOG_DEBUG, + "Unsupported value type %d in tag %s.\n", type, key); + goto finish; + } + if (*value) + av_dict_set(&s->metadata, key, value, 0); + +finish: + av_freep(&value); + avio_seek(s->pb, off + len, SEEK_SET); +} + +static int asf_read_file_properties(AVFormatContext *s, int64_t size) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + + ff_get_guid(pb, &asf->hdr.guid); + asf->hdr.file_size = avio_rl64(pb); + asf->hdr.create_time = avio_rl64(pb); + avio_rl64(pb); /* number of packets */ + asf->hdr.play_time = avio_rl64(pb); + asf->hdr.send_time = avio_rl64(pb); + asf->hdr.preroll = avio_rl32(pb); + asf->hdr.ignore = avio_rl32(pb); + asf->hdr.flags = avio_rl32(pb); + asf->hdr.min_pktsize = avio_rl32(pb); + asf->hdr.max_pktsize = avio_rl32(pb); + if (asf->hdr.min_pktsize >= (1U << 29)) + return AVERROR_INVALIDDATA; + asf->hdr.max_bitrate = avio_rl32(pb); + s->packet_size = asf->hdr.max_pktsize; + + return 0; +} + +static int asf_read_stream_properties(AVFormatContext *s, int64_t size) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + AVStream *st; + ASFStream *asf_st; + ff_asf_guid g; + enum AVMediaType type; + int type_specific_size, sizeX; + unsigned int tag1; + int64_t pos1, pos2, start_time; + int test_for_ext_stream_audio, is_dvr_ms_audio = 0; + + if (s->nb_streams == ASF_MAX_STREAMS) { + av_log(s, AV_LOG_ERROR, "too many streams\n"); + return AVERROR(EINVAL); + } + + pos1 = avio_tell(pb); + + st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */ + start_time = asf->hdr.preroll; + + if (!(asf->hdr.flags & 0x01)) { // if we aren't streaming... + int64_t fsize = avio_size(pb); + if (fsize <= 0 || (int64_t)asf->hdr.file_size <= 0 || + 20*FFABS(fsize - (int64_t)asf->hdr.file_size) < FFMIN(fsize, asf->hdr.file_size)) + st->duration = asf->hdr.play_time / + (10000000 / 1000) - start_time; + } + ff_get_guid(pb, &g); + + test_for_ext_stream_audio = 0; + if (!ff_guidcmp(&g, &ff_asf_audio_stream)) { + type = AVMEDIA_TYPE_AUDIO; + } else if (!ff_guidcmp(&g, &ff_asf_video_stream)) { + type = AVMEDIA_TYPE_VIDEO; + } else if (!ff_guidcmp(&g, &ff_asf_jfif_media)) { + type = AVMEDIA_TYPE_VIDEO; + st->codec->codec_id = AV_CODEC_ID_MJPEG; + } else if (!ff_guidcmp(&g, &ff_asf_command_stream)) { + type = AVMEDIA_TYPE_DATA; + } else if (!ff_guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) { + test_for_ext_stream_audio = 1; + type = AVMEDIA_TYPE_UNKNOWN; + } else { + return -1; + } + ff_get_guid(pb, &g); + avio_skip(pb, 8); /* total_size */ + type_specific_size = avio_rl32(pb); + avio_rl32(pb); + st->id = avio_rl16(pb) & 0x7f; /* stream id */ + // mapping of asf ID to AV stream ID; + asf->asfid2avid[st->id] = s->nb_streams - 1; + asf_st = &asf->streams[st->id]; + + avio_rl32(pb); + + if (test_for_ext_stream_audio) { + ff_get_guid(pb, &g); + if (!ff_guidcmp(&g, &ff_asf_ext_stream_audio_stream)) { + type = AVMEDIA_TYPE_AUDIO; + is_dvr_ms_audio = 1; + ff_get_guid(pb, &g); + avio_rl32(pb); + avio_rl32(pb); + avio_rl32(pb); + ff_get_guid(pb, &g); + avio_rl32(pb); + } + } + + st->codec->codec_type = type; + if (type == AVMEDIA_TYPE_AUDIO) { + int ret = ff_get_wav_header(s, pb, st->codec, type_specific_size, 0); + if (ret < 0) + return ret; + if (is_dvr_ms_audio) { + // codec_id and codec_tag are unreliable in dvr_ms + // files. Set them later by probing stream. + st->request_probe = 1; + st->codec->codec_tag = 0; + } + if (st->codec->codec_id == AV_CODEC_ID_AAC) + st->need_parsing = AVSTREAM_PARSE_NONE; + else + st->need_parsing = AVSTREAM_PARSE_FULL; + /* We have to init the frame size at some point .... */ + pos2 = avio_tell(pb); + if (size >= (pos2 + 8 - pos1 + 24)) { + asf_st->ds_span = avio_r8(pb); + asf_st->ds_packet_size = avio_rl16(pb); + asf_st->ds_chunk_size = avio_rl16(pb); + avio_rl16(pb); // ds_data_size + avio_r8(pb); // ds_silence_data + } + if (asf_st->ds_span > 1) { + if (!asf_st->ds_chunk_size || + (asf_st->ds_packet_size / asf_st->ds_chunk_size <= 1) || + asf_st->ds_packet_size % asf_st->ds_chunk_size) + asf_st->ds_span = 0; // disable descrambling + } + } else if (type == AVMEDIA_TYPE_VIDEO && + size - (avio_tell(pb) - pos1 + 24) >= 51) { + avio_rl32(pb); + avio_rl32(pb); + avio_r8(pb); + avio_rl16(pb); /* size */ + sizeX = avio_rl32(pb); /* size */ + st->codec->width = avio_rl32(pb); + st->codec->height = avio_rl32(pb); + /* not available for asf */ + avio_rl16(pb); /* panes */ + st->codec->bits_per_coded_sample = avio_rl16(pb); /* depth */ + tag1 = avio_rl32(pb); + avio_skip(pb, 20); + if (sizeX > 40) { + st->codec->extradata_size = ffio_limit(pb, sizeX - 40); + st->codec->extradata = av_mallocz(st->codec->extradata_size + + AV_INPUT_BUFFER_PADDING_SIZE); + if (!st->codec->extradata) + return AVERROR(ENOMEM); + avio_read(pb, st->codec->extradata, st->codec->extradata_size); + } + + /* Extract palette from extradata if bpp <= 8 */ + /* This code assumes that extradata contains only palette */ + /* This is true for all paletted codecs implemented in libavcodec */ + if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) { +#if HAVE_BIGENDIAN + int i; + for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE) / 4; i++) + asf_st->palette[i] = av_bswap32(((uint32_t *)st->codec->extradata)[i]); +#else + memcpy(asf_st->palette, st->codec->extradata, + FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); +#endif + asf_st->palette_changed = 1; + } + + st->codec->codec_tag = tag1; + st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1); + if (tag1 == MKTAG('D', 'V', 'R', ' ')) { + st->need_parsing = AVSTREAM_PARSE_FULL; + /* issue658 contains wrong w/h and MS even puts a fake seq header + * with wrong w/h in extradata while a correct one is in the stream. + * maximum lameness */ + st->codec->width = + st->codec->height = 0; + av_freep(&st->codec->extradata); + st->codec->extradata_size = 0; + } + if (st->codec->codec_id == AV_CODEC_ID_H264) + st->need_parsing = AVSTREAM_PARSE_FULL_ONCE; + if (st->codec->codec_id == AV_CODEC_ID_MPEG4) + st->need_parsing = AVSTREAM_PARSE_FULL_ONCE; + } + pos2 = avio_tell(pb); + avio_skip(pb, size - (pos2 - pos1 + 24)); + + return 0; +} + +static int asf_read_ext_stream_properties(AVFormatContext *s, int64_t size) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + ff_asf_guid g; + int ext_len, payload_ext_ct, stream_ct, i; + uint32_t leak_rate, stream_num; + unsigned int stream_languageid_index; + + avio_rl64(pb); // starttime + avio_rl64(pb); // endtime + leak_rate = avio_rl32(pb); // leak-datarate + avio_rl32(pb); // bucket-datasize + avio_rl32(pb); // init-bucket-fullness + avio_rl32(pb); // alt-leak-datarate + avio_rl32(pb); // alt-bucket-datasize + avio_rl32(pb); // alt-init-bucket-fullness + avio_rl32(pb); // max-object-size + avio_rl32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved) + stream_num = avio_rl16(pb); // stream-num + + stream_languageid_index = avio_rl16(pb); // stream-language-id-index + if (stream_num < 128) + asf->streams[stream_num].stream_language_index = stream_languageid_index; + + avio_rl64(pb); // avg frametime in 100ns units + stream_ct = avio_rl16(pb); // stream-name-count + payload_ext_ct = avio_rl16(pb); // payload-extension-system-count + + if (stream_num < 128) { + asf->stream_bitrates[stream_num] = leak_rate; + asf->streams[stream_num].payload_ext_ct = 0; + } + + for (i = 0; i < stream_ct; i++) { + avio_rl16(pb); + ext_len = avio_rl16(pb); + avio_skip(pb, ext_len); + } + + for (i = 0; i < payload_ext_ct; i++) { + int size; + ff_get_guid(pb, &g); + size = avio_rl16(pb); + ext_len = avio_rl32(pb); + avio_skip(pb, ext_len); + if (stream_num < 128 && i < FF_ARRAY_ELEMS(asf->streams[stream_num].payload)) { + ASFPayload *p = &asf->streams[stream_num].payload[i]; + p->type = g[0]; + p->size = size; + av_log(s, AV_LOG_DEBUG, "Payload extension %x %d\n", g[0], p->size ); + asf->streams[stream_num].payload_ext_ct ++; + } + } + + return 0; +} + +static int asf_read_content_desc(AVFormatContext *s, int64_t size) +{ + AVIOContext *pb = s->pb; + int len1, len2, len3, len4, len5; + + len1 = avio_rl16(pb); + len2 = avio_rl16(pb); + len3 = avio_rl16(pb); + len4 = avio_rl16(pb); + len5 = avio_rl16(pb); + get_tag(s, "title", 0, len1, 32); + get_tag(s, "author", 0, len2, 32); + get_tag(s, "copyright", 0, len3, 32); + get_tag(s, "comment", 0, len4, 32); + avio_skip(pb, len5); + + return 0; +} + +static int asf_read_ext_content_desc(AVFormatContext *s, int64_t size) +{ + AVIOContext *pb = s->pb; + ASFContext *asf = s->priv_data; + int desc_count, i, ret; + + desc_count = avio_rl16(pb); + for (i = 0; i < desc_count; i++) { + int name_len, value_type, value_len; + char name[1024]; + + name_len = avio_rl16(pb); + if (name_len % 2) // must be even, broken lavf versions wrote len-1 + name_len += 1; + if ((ret = avio_get_str16le(pb, name_len, name, sizeof(name))) < name_len) + avio_skip(pb, name_len - ret); + value_type = avio_rl16(pb); + value_len = avio_rl16(pb); + if (!value_type && value_len % 2) + value_len += 1; + /* My sample has that stream set to 0 maybe that mean the container. + * ASF stream count starts at 1. I am using 0 to the container value + * since it's unused. */ + if (!strcmp(name, "AspectRatioX")) + asf->dar[0].num = get_value(s->pb, value_type, 32); + else if (!strcmp(name, "AspectRatioY")) + asf->dar[0].den = get_value(s->pb, value_type, 32); + else + get_tag(s, name, value_type, value_len, 32); + } + + return 0; +} + +static int asf_read_language_list(AVFormatContext *s, int64_t size) +{ + AVIOContext *pb = s->pb; + ASFContext *asf = s->priv_data; + int j, ret; + int stream_count = avio_rl16(pb); + for (j = 0; j < stream_count; j++) { + char lang[6]; + unsigned int lang_len = avio_r8(pb); + if ((ret = avio_get_str16le(pb, lang_len, lang, + sizeof(lang))) < lang_len) + avio_skip(pb, lang_len - ret); + if (j < 128) + av_strlcpy(asf->stream_languages[j], lang, + sizeof(*asf->stream_languages)); + } + + return 0; +} + +static int asf_read_metadata(AVFormatContext *s, int64_t size) +{ + AVIOContext *pb = s->pb; + ASFContext *asf = s->priv_data; + int n, stream_num, name_len_utf16, name_len_utf8, value_len; + int ret, i; + n = avio_rl16(pb); + + for (i = 0; i < n; i++) { + uint8_t *name; + int value_type; + + avio_rl16(pb); // lang_list_index + stream_num = avio_rl16(pb); + name_len_utf16 = avio_rl16(pb); + value_type = avio_rl16(pb); /* value_type */ + value_len = avio_rl32(pb); + + name_len_utf8 = 2*name_len_utf16 + 1; + name = av_malloc(name_len_utf8); + if (!name) + return AVERROR(ENOMEM); + + if ((ret = avio_get_str16le(pb, name_len_utf16, name, name_len_utf8)) < name_len_utf16) + avio_skip(pb, name_len_utf16 - ret); + av_log(s, AV_LOG_TRACE, "%d stream %d name_len %2d type %d len %4d <%s>\n", + i, stream_num, name_len_utf16, value_type, value_len, name); + + if (!strcmp(name, "AspectRatioX")){ + int aspect_x = get_value(s->pb, value_type, 16); + if(stream_num < 128) + asf->dar[stream_num].num = aspect_x; + } else if(!strcmp(name, "AspectRatioY")){ + int aspect_y = get_value(s->pb, value_type, 16); + if(stream_num < 128) + asf->dar[stream_num].den = aspect_y; + } else { + get_tag(s, name, value_type, value_len, 16); + } + av_freep(&name); + } + + return 0; +} + +static int asf_read_marker(AVFormatContext *s, int64_t size) +{ + AVIOContext *pb = s->pb; + ASFContext *asf = s->priv_data; + int i, count, name_len, ret; + char name[1024]; + + avio_rl64(pb); // reserved 16 bytes + avio_rl64(pb); // ... + count = avio_rl32(pb); // markers count + avio_rl16(pb); // reserved 2 bytes + name_len = avio_rl16(pb); // name length + for (i = 0; i < name_len; i++) + avio_r8(pb); // skip the name + + for (i = 0; i < count; i++) { + int64_t pres_time; + int name_len; + + avio_rl64(pb); // offset, 8 bytes + pres_time = avio_rl64(pb); // presentation time + pres_time -= asf->hdr.preroll * 10000; + avio_rl16(pb); // entry length + avio_rl32(pb); // send time + avio_rl32(pb); // flags + name_len = avio_rl32(pb); // name length + if ((ret = avio_get_str16le(pb, name_len * 2, name, + sizeof(name))) < name_len) + avio_skip(pb, name_len - ret); + avpriv_new_chapter(s, i, (AVRational) { 1, 10000000 }, pres_time, + AV_NOPTS_VALUE, name); + } + + return 0; +} + +static int asf_read_header(AVFormatContext *s) +{ + ASFContext *asf = s->priv_data; + ff_asf_guid g; + AVIOContext *pb = s->pb; + int i; + int64_t gsize; + + ff_get_guid(pb, &g); + if (ff_guidcmp(&g, &ff_asf_header)) + return AVERROR_INVALIDDATA; + avio_rl64(pb); + avio_rl32(pb); + avio_r8(pb); + avio_r8(pb); + memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid)); + + for (i = 0; i<128; i++) + asf->streams[i].stream_language_index = 128; // invalid stream index means no language info + + for (;;) { + uint64_t gpos = avio_tell(pb); + int ret = 0; + ff_get_guid(pb, &g); + gsize = avio_rl64(pb); + print_guid(&g); + if (!ff_guidcmp(&g, &ff_asf_data_header)) { + asf->data_object_offset = avio_tell(pb); + /* If not streaming, gsize is not unlimited (how?), + * and there is enough space in the file.. */ + if (!(asf->hdr.flags & 0x01) && gsize >= 100) + asf->data_object_size = gsize - 24; + else + asf->data_object_size = (uint64_t)-1; + break; + } + if (gsize < 24) + return AVERROR_INVALIDDATA; + if (!ff_guidcmp(&g, &ff_asf_file_header)) { + ret = asf_read_file_properties(s, gsize); + } else if (!ff_guidcmp(&g, &ff_asf_stream_header)) { + ret = asf_read_stream_properties(s, gsize); + } else if (!ff_guidcmp(&g, &ff_asf_comment_header)) { + asf_read_content_desc(s, gsize); + } else if (!ff_guidcmp(&g, &ff_asf_language_guid)) { + asf_read_language_list(s, gsize); + } else if (!ff_guidcmp(&g, &ff_asf_extended_content_header)) { + asf_read_ext_content_desc(s, gsize); + } else if (!ff_guidcmp(&g, &ff_asf_metadata_header)) { + asf_read_metadata(s, gsize); + } else if (!ff_guidcmp(&g, &ff_asf_metadata_library_header)) { + asf_read_metadata(s, gsize); + } else if (!ff_guidcmp(&g, &ff_asf_ext_stream_header)) { + asf_read_ext_stream_properties(s, gsize); + + // there could be a optional stream properties object to follow + // if so the next iteration will pick it up + continue; + } else if (!ff_guidcmp(&g, &ff_asf_head1_guid)) { + ff_get_guid(pb, &g); + avio_skip(pb, 6); + continue; + } else if (!ff_guidcmp(&g, &ff_asf_marker_header)) { + asf_read_marker(s, gsize); + } else if (avio_feof(pb)) { + return AVERROR_EOF; + } else { + if (!s->keylen) { + if (!ff_guidcmp(&g, &ff_asf_content_encryption)) { + unsigned int len; + AVPacket pkt; + av_log(s, AV_LOG_WARNING, + "DRM protected stream detected, decoding will likely fail!\n"); + len= avio_rl32(pb); + av_log(s, AV_LOG_DEBUG, "Secret data:\n"); + + if ((ret = av_get_packet(pb, &pkt, len)) < 0) + return ret; + av_hex_dump_log(s, AV_LOG_DEBUG, pkt.data, pkt.size); + av_free_packet(&pkt); + len= avio_rl32(pb); + get_tag(s, "ASF_Protection_Type", -1, len, 32); + len= avio_rl32(pb); + get_tag(s, "ASF_Key_ID", -1, len, 32); + len= avio_rl32(pb); + get_tag(s, "ASF_License_URL", -1, len, 32); + } else if (!ff_guidcmp(&g, &ff_asf_ext_content_encryption)) { + av_log(s, AV_LOG_WARNING, + "Ext DRM protected stream detected, decoding will likely fail!\n"); + av_dict_set(&s->metadata, "encryption", "ASF Extended Content Encryption", 0); + } else if (!ff_guidcmp(&g, &ff_asf_digital_signature)) { + av_log(s, AV_LOG_INFO, "Digital signature detected!\n"); + } + } + } + if (ret < 0) + return ret; + + if (avio_tell(pb) != gpos + gsize) + av_log(s, AV_LOG_DEBUG, + "gpos mismatch our pos=%"PRIu64", end=%"PRId64"\n", + avio_tell(pb) - gpos, gsize); + avio_seek(pb, gpos + gsize, SEEK_SET); + } + ff_get_guid(pb, &g); + avio_rl64(pb); + avio_r8(pb); + avio_r8(pb); + if (avio_feof(pb)) + return AVERROR_EOF; + asf->data_offset = avio_tell(pb); + asf->packet_size_left = 0; + + for (i = 0; i < 128; i++) { + int stream_num = asf->asfid2avid[i]; + if (stream_num >= 0) { + AVStream *st = s->streams[stream_num]; + if (!st->codec->bit_rate) + st->codec->bit_rate = asf->stream_bitrates[i]; + if (asf->dar[i].num > 0 && asf->dar[i].den > 0) { + av_reduce(&st->sample_aspect_ratio.num, + &st->sample_aspect_ratio.den, + asf->dar[i].num, asf->dar[i].den, INT_MAX); + } else if ((asf->dar[0].num > 0) && (asf->dar[0].den > 0) && + // Use ASF container value if the stream doesn't set AR. + (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)) + av_reduce(&st->sample_aspect_ratio.num, + &st->sample_aspect_ratio.den, + asf->dar[0].num, asf->dar[0].den, INT_MAX); + + av_log(s, AV_LOG_TRACE, "i=%d, st->codec->codec_type:%d, asf->dar %d:%d sar=%d:%d\n", + i, st->codec->codec_type, asf->dar[i].num, asf->dar[i].den, + st->sample_aspect_ratio.num, st->sample_aspect_ratio.den); + + // copy and convert language codes to the frontend + if (asf->streams[i].stream_language_index < 128) { + const char *rfc1766 = asf->stream_languages[asf->streams[i].stream_language_index]; + if (rfc1766 && strlen(rfc1766) > 1) { + const char primary_tag[3] = { rfc1766[0], rfc1766[1], '\0' }; // ignore country code if any + const char *iso6392 = av_convert_lang_to(primary_tag, + AV_LANG_ISO639_2_BIBL); + if (iso6392) + av_dict_set(&st->metadata, "language", iso6392, 0); + } + } + } + } + + ff_metadata_conv(&s->metadata, NULL, ff_asf_metadata_conv); + + return 0; +} + +#define DO_2BITS(bits, var, defval) \ + switch (bits & 3) { \ + case 3: \ + var = avio_rl32(pb); \ + rsize += 4; \ + break; \ + case 2: \ + var = avio_rl16(pb); \ + rsize += 2; \ + break; \ + case 1: \ + var = avio_r8(pb); \ + rsize++; \ + break; \ + default: \ + var = defval; \ + break; \ + } + +/** + * Load a single ASF packet into the demuxer. + * @param s demux context + * @param pb context to read data from + * @return 0 on success, <0 on error + */ +static int asf_get_packet(AVFormatContext *s, AVIOContext *pb) +{ + ASFContext *asf = s->priv_data; + uint32_t packet_length, padsize; + int rsize = 8; + int c, d, e, off; + + if (asf->uses_std_ecc > 0) { + // if we do not know packet size, allow skipping up to 32 kB + off = 32768; + if (asf->no_resync_search) + off = 3; +// else if (s->packet_size > 0 && !asf->uses_std_ecc) +// off = (avio_tell(pb) - s->internal->data_offset) % s->packet_size + 3; + + c = d = e = -1; + while (off-- > 0) { + c = d; + d = e; + e = avio_r8(pb); + if (c == 0x82 && !d && !e) + break; + } + + if (c != 0x82) { + /* This code allows handling of -EAGAIN at packet boundaries (i.e. + * if the packet sync code above triggers -EAGAIN). This does not + * imply complete -EAGAIN handling support at random positions in + * the stream. */ + if (pb->error == AVERROR(EAGAIN)) + return AVERROR(EAGAIN); + if (!avio_feof(pb)) + av_log(s, AV_LOG_ERROR, + "ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb)); + } + if ((c & 0x8f) == 0x82) { + if (d || e) { + if (!avio_feof(pb)) + av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n"); + return AVERROR_INVALIDDATA; + } + c = avio_r8(pb); + d = avio_r8(pb); + rsize += 3; + } else if(!avio_feof(pb)) { + avio_seek(pb, -1, SEEK_CUR); // FIXME + } + } else { + c = avio_r8(pb); + if (c & 0x80) { + rsize ++; + if (!(c & 0x60)) { + d = avio_r8(pb); + e = avio_r8(pb); + avio_seek(pb, (c & 0xF) - 2, SEEK_CUR); + rsize += c & 0xF; + } + + if (c != 0x82) + avpriv_request_sample(s, "Invalid ECC byte\n"); + + if (!asf->uses_std_ecc) + asf->uses_std_ecc = (c == 0x82 && !d && !e) ? 1 : -1; + + c = avio_r8(pb); + } else + asf->uses_std_ecc = -1; + d = avio_r8(pb); + } + + asf->packet_flags = c; + asf->packet_property = d; + + DO_2BITS(asf->packet_flags >> 5, packet_length, s->packet_size); + DO_2BITS(asf->packet_flags >> 1, padsize, 0); // sequence ignored + DO_2BITS(asf->packet_flags >> 3, padsize, 0); // padding length + + // the following checks prevent overflows and infinite loops + if (!packet_length || packet_length >= (1U << 29)) { + av_log(s, AV_LOG_ERROR, + "invalid packet_length %"PRIu32" at:%"PRId64"\n", + packet_length, avio_tell(pb)); + return AVERROR_INVALIDDATA; + } + if (padsize >= packet_length) { + av_log(s, AV_LOG_ERROR, + "invalid padsize %"PRIu32" at:%"PRId64"\n", padsize, avio_tell(pb)); + return AVERROR_INVALIDDATA; + } + + asf->packet_timestamp = avio_rl32(pb); + avio_rl16(pb); /* duration */ + // rsize has at least 11 bytes which have to be present + + if (asf->packet_flags & 0x01) { + asf->packet_segsizetype = avio_r8(pb); + rsize++; + asf->packet_segments = asf->packet_segsizetype & 0x3f; + } else { + asf->packet_segments = 1; + asf->packet_segsizetype = 0x80; + } + if (rsize > packet_length - padsize) { + asf->packet_size_left = 0; + av_log(s, AV_LOG_ERROR, + "invalid packet header length %d for pktlen %"PRIu32"-%"PRIu32" at %"PRId64"\n", + rsize, packet_length, padsize, avio_tell(pb)); + return AVERROR_INVALIDDATA; + } + asf->packet_size_left = packet_length - padsize - rsize; + if (packet_length < asf->hdr.min_pktsize) + padsize += asf->hdr.min_pktsize - packet_length; + asf->packet_padsize = padsize; + av_log(s, AV_LOG_TRACE, "packet: size=%d padsize=%d left=%d\n", + s->packet_size, asf->packet_padsize, asf->packet_size_left); + return 0; +} + +/** + * + * @return <0 if error + */ +static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb) +{ + ASFContext *asf = s->priv_data; + ASFStream *asfst; + int rsize = 1; + int num = avio_r8(pb); + int i; + int64_t ts0, ts1 av_unused; + + asf->packet_segments--; + asf->packet_key_frame = num >> 7; + asf->stream_index = asf->asfid2avid[num & 0x7f]; + asfst = &asf->streams[num & 0x7f]; + // sequence should be ignored! + DO_2BITS(asf->packet_property >> 4, asf->packet_seq, 0); + DO_2BITS(asf->packet_property >> 2, asf->packet_frag_offset, 0); + DO_2BITS(asf->packet_property, asf->packet_replic_size, 0); + av_log(asf, AV_LOG_TRACE, "key:%d stream:%d seq:%d offset:%d replic_size:%d num:%X packet_property %X\n", + asf->packet_key_frame, asf->stream_index, asf->packet_seq, + asf->packet_frag_offset, asf->packet_replic_size, num, asf->packet_property); + if (rsize+(int64_t)asf->packet_replic_size > asf->packet_size_left) { + av_log(s, AV_LOG_ERROR, "packet_replic_size %d is invalid\n", asf->packet_replic_size); + return AVERROR_INVALIDDATA; + } + if (asf->packet_replic_size >= 8) { + int64_t end = avio_tell(pb) + asf->packet_replic_size; + AVRational aspect; + asfst->packet_obj_size = avio_rl32(pb); + if (asfst->packet_obj_size >= (1 << 24) || asfst->packet_obj_size < 0) { + av_log(s, AV_LOG_ERROR, "packet_obj_size %d invalid\n", asfst->packet_obj_size); + asfst->packet_obj_size = 0; + return AVERROR_INVALIDDATA; + } + asf->packet_frag_timestamp = avio_rl32(pb); // timestamp + + for (i = 0; i < asfst->payload_ext_ct; i++) { + ASFPayload *p = &asfst->payload[i]; + int size = p->size; + int64_t payend; + if (size == 0xFFFF) + size = avio_rl16(pb); + payend = avio_tell(pb) + size; + if (payend > end) { + av_log(s, AV_LOG_ERROR, "too long payload\n"); + break; + } + switch (p->type) { + case 0x50: +// duration = avio_rl16(pb); + break; + case 0x54: + aspect.num = avio_r8(pb); + aspect.den = avio_r8(pb); + if (aspect.num > 0 && aspect.den > 0 && asf->stream_index >= 0) { + s->streams[asf->stream_index]->sample_aspect_ratio = aspect; + } + break; + case 0x2A: + avio_skip(pb, 8); + ts0 = avio_rl64(pb); + ts1 = avio_rl64(pb); + if (ts0!= -1) asf->packet_frag_timestamp = ts0/10000; + else asf->packet_frag_timestamp = AV_NOPTS_VALUE; + asf->ts_is_pts = 1; + break; + case 0x5B: + case 0xB7: + case 0xCC: + case 0xC0: + case 0xA0: + //unknown + break; + } + avio_seek(pb, payend, SEEK_SET); + } + + avio_seek(pb, end, SEEK_SET); + rsize += asf->packet_replic_size; // FIXME - check validity + } else if (asf->packet_replic_size == 1) { + // multipacket - frag_offset is beginning timestamp + asf->packet_time_start = asf->packet_frag_offset; + asf->packet_frag_offset = 0; + asf->packet_frag_timestamp = asf->packet_timestamp; + + asf->packet_time_delta = avio_r8(pb); + rsize++; + } else if (asf->packet_replic_size != 0) { + av_log(s, AV_LOG_ERROR, "unexpected packet_replic_size of %d\n", + asf->packet_replic_size); + return AVERROR_INVALIDDATA; + } + if (asf->packet_flags & 0x01) { + DO_2BITS(asf->packet_segsizetype >> 6, asf->packet_frag_size, 0); // 0 is illegal + if (rsize > asf->packet_size_left) { + av_log(s, AV_LOG_ERROR, "packet_replic_size is invalid\n"); + return AVERROR_INVALIDDATA; + } else if (asf->packet_frag_size > asf->packet_size_left - rsize) { + if (asf->packet_frag_size > asf->packet_size_left - rsize + asf->packet_padsize) { + av_log(s, AV_LOG_ERROR, "packet_frag_size is invalid (%d>%d-%d+%d)\n", + asf->packet_frag_size, asf->packet_size_left, rsize, asf->packet_padsize); + return AVERROR_INVALIDDATA; + } else { + int diff = asf->packet_frag_size - (asf->packet_size_left - rsize); + asf->packet_size_left += diff; + asf->packet_padsize -= diff; + } + } + } else { + asf->packet_frag_size = asf->packet_size_left - rsize; + } + if (asf->packet_replic_size == 1) { + asf->packet_multi_size = asf->packet_frag_size; + if (asf->packet_multi_size > asf->packet_size_left) + return AVERROR_INVALIDDATA; + } + asf->packet_size_left -= rsize; + + return 0; +} + +/** + * Parse data from individual ASF packets (which were previously loaded + * with asf_get_packet()). + * @param s demux context + * @param pb context to read data from + * @param pkt pointer to store packet data into + * @return 0 if data was stored in pkt, <0 on error or 1 if more ASF + * packets need to be loaded (through asf_get_packet()) + */ +static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt) +{ + ASFContext *asf = s->priv_data; + ASFStream *asf_st = 0; + for (;;) { + int ret; + if (avio_feof(pb)) + return AVERROR_EOF; + if (asf->packet_size_left < FRAME_HEADER_SIZE || + asf->packet_segments < 1 && asf->packet_time_start == 0) { + int ret = asf->packet_size_left + asf->packet_padsize; + + if (asf->packet_size_left && asf->packet_size_left < FRAME_HEADER_SIZE) + av_log(s, AV_LOG_WARNING, "Skip due to FRAME_HEADER_SIZE\n"); + + assert(ret >= 0); + /* fail safe */ + avio_skip(pb, ret); + + asf->packet_pos = avio_tell(pb); + if (asf->data_object_size != (uint64_t)-1 && + (asf->packet_pos - asf->data_object_offset >= asf->data_object_size)) + return AVERROR_EOF; /* Do not exceed the size of the data object */ + return 1; + } + if (asf->packet_time_start == 0) { + if (asf_read_frame_header(s, pb) < 0) { + asf->packet_time_start = asf->packet_segments = 0; + continue; + } + if (asf->stream_index < 0 || + s->streams[asf->stream_index]->discard >= AVDISCARD_ALL || + (!asf->packet_key_frame && + (s->streams[asf->stream_index]->discard >= AVDISCARD_NONKEY || asf->streams[s->streams[asf->stream_index]->id].skip_to_key))) { + asf->packet_time_start = 0; + /* unhandled packet (should not happen) */ + avio_skip(pb, asf->packet_frag_size); + asf->packet_size_left -= asf->packet_frag_size; + if (asf->stream_index < 0) + av_log(s, AV_LOG_ERROR, "ff asf skip %d (unknown stream)\n", + asf->packet_frag_size); + continue; + } + asf->asf_st = &asf->streams[s->streams[asf->stream_index]->id]; + if (!asf->packet_frag_offset) + asf->asf_st->skip_to_key = 0; + } + asf_st = asf->asf_st; + av_assert0(asf_st); + + if (!asf_st->frag_offset && asf->packet_frag_offset) { + av_log(s, AV_LOG_TRACE, "skipping asf data pkt with fragment offset for " + "stream:%d, expected:%d but got %d from pkt)\n", + asf->stream_index, asf_st->frag_offset, + asf->packet_frag_offset); + avio_skip(pb, asf->packet_frag_size); + asf->packet_size_left -= asf->packet_frag_size; + continue; + } + + if (asf->packet_replic_size == 1) { + // frag_offset is here used as the beginning timestamp + asf->packet_frag_timestamp = asf->packet_time_start; + asf->packet_time_start += asf->packet_time_delta; + asf_st->packet_obj_size = asf->packet_frag_size = avio_r8(pb); + asf->packet_size_left--; + asf->packet_multi_size--; + if (asf->packet_multi_size < asf_st->packet_obj_size) { + asf->packet_time_start = 0; + avio_skip(pb, asf->packet_multi_size); + asf->packet_size_left -= asf->packet_multi_size; + continue; + } + asf->packet_multi_size -= asf_st->packet_obj_size; + } + + if (asf_st->pkt.size != asf_st->packet_obj_size || + // FIXME is this condition sufficient? + asf_st->frag_offset + asf->packet_frag_size > asf_st->pkt.size) { + int ret; + + if (asf_st->pkt.data) { + av_log(s, AV_LOG_INFO, + "freeing incomplete packet size %d, new %d\n", + asf_st->pkt.size, asf_st->packet_obj_size); + asf_st->frag_offset = 0; + av_free_packet(&asf_st->pkt); + } + /* new packet */ + if ((ret = av_new_packet(&asf_st->pkt, asf_st->packet_obj_size)) < 0) + return ret; + asf_st->seq = asf->packet_seq; + if (asf->ts_is_pts) { + asf_st->pkt.pts = asf->packet_frag_timestamp - asf->hdr.preroll; + } else + asf_st->pkt.dts = asf->packet_frag_timestamp - asf->hdr.preroll; + asf_st->pkt.stream_index = asf->stream_index; + asf_st->pkt.pos = asf_st->packet_pos = asf->packet_pos; + asf_st->pkt_clean = 0; + + if (asf_st->pkt.data && asf_st->palette_changed) { + uint8_t *pal; + pal = av_packet_new_side_data(&asf_st->pkt, AV_PKT_DATA_PALETTE, + AVPALETTE_SIZE); + if (!pal) { + av_log(s, AV_LOG_ERROR, "Cannot append palette to packet\n"); + } else { + memcpy(pal, asf_st->palette, AVPALETTE_SIZE); + asf_st->palette_changed = 0; + } + } + av_log(asf, AV_LOG_TRACE, "new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n", + asf->stream_index, asf->packet_key_frame, + asf_st->pkt.flags & AV_PKT_FLAG_KEY, + s->streams[asf->stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO, + asf_st->packet_obj_size); + if (s->streams[asf->stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO) + asf->packet_key_frame = 1; + if (asf->packet_key_frame) + asf_st->pkt.flags |= AV_PKT_FLAG_KEY; + } + + /* read data */ + av_log(asf, AV_LOG_TRACE, "READ PACKET s:%d os:%d o:%d,%d l:%d DATA:%p\n", + s->packet_size, asf_st->pkt.size, asf->packet_frag_offset, + asf_st->frag_offset, asf->packet_frag_size, asf_st->pkt.data); + asf->packet_size_left -= asf->packet_frag_size; + if (asf->packet_size_left < 0) + continue; + + if (asf->packet_frag_offset >= asf_st->pkt.size || + asf->packet_frag_size > asf_st->pkt.size - asf->packet_frag_offset) { + av_log(s, AV_LOG_ERROR, + "packet fragment position invalid %u,%u not in %u\n", + asf->packet_frag_offset, asf->packet_frag_size, + asf_st->pkt.size); + continue; + } + + if (asf->packet_frag_offset != asf_st->frag_offset && !asf_st->pkt_clean) { + memset(asf_st->pkt.data + asf_st->frag_offset, 0, asf_st->pkt.size - asf_st->frag_offset); + asf_st->pkt_clean = 1; + } + + ret = avio_read(pb, asf_st->pkt.data + asf->packet_frag_offset, + asf->packet_frag_size); + if (ret != asf->packet_frag_size) { + if (ret < 0 || asf->packet_frag_offset + ret == 0) + return ret < 0 ? ret : AVERROR_EOF; + + if (asf_st->ds_span > 1) { + // scrambling, we can either drop it completely or fill the remainder + // TODO: should we fill the whole packet instead of just the current + // fragment? + memset(asf_st->pkt.data + asf->packet_frag_offset + ret, 0, + asf->packet_frag_size - ret); + ret = asf->packet_frag_size; + } else { + // no scrambling, so we can return partial packets + av_shrink_packet(&asf_st->pkt, asf->packet_frag_offset + ret); + } + } + if (s->key && s->keylen == 20) + ff_asfcrypt_dec(s->key, asf_st->pkt.data + asf->packet_frag_offset, + ret); + asf_st->frag_offset += ret; + /* test if whole packet is read */ + if (asf_st->frag_offset == asf_st->pkt.size) { + // workaround for macroshit radio DVR-MS files + if (s->streams[asf->stream_index]->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO && + asf_st->pkt.size > 100) { + int i; + for (i = 0; i < asf_st->pkt.size && !asf_st->pkt.data[i]; i++) + ; + if (i == asf_st->pkt.size) { + av_log(s, AV_LOG_DEBUG, "discarding ms fart\n"); + asf_st->frag_offset = 0; + av_free_packet(&asf_st->pkt); + continue; + } + } + + /* return packet */ + if (asf_st->ds_span > 1) { + if (asf_st->pkt.size != asf_st->ds_packet_size * asf_st->ds_span) { + av_log(s, AV_LOG_ERROR, + "pkt.size != ds_packet_size * ds_span (%d %d %d)\n", + asf_st->pkt.size, asf_st->ds_packet_size, + asf_st->ds_span); + } else { + /* packet descrambling */ + AVBufferRef *buf = av_buffer_alloc(asf_st->pkt.size + + AV_INPUT_BUFFER_PADDING_SIZE); + if (buf) { + uint8_t *newdata = buf->data; + int offset = 0; + memset(newdata + asf_st->pkt.size, 0, + AV_INPUT_BUFFER_PADDING_SIZE); + while (offset < asf_st->pkt.size) { + int off = offset / asf_st->ds_chunk_size; + int row = off / asf_st->ds_span; + int col = off % asf_st->ds_span; + int idx = row + col * asf_st->ds_packet_size / asf_st->ds_chunk_size; + assert(offset + asf_st->ds_chunk_size <= asf_st->pkt.size); + assert(idx + 1 <= asf_st->pkt.size / asf_st->ds_chunk_size); + memcpy(newdata + offset, + asf_st->pkt.data + idx * asf_st->ds_chunk_size, + asf_st->ds_chunk_size); + offset += asf_st->ds_chunk_size; + } + av_buffer_unref(&asf_st->pkt.buf); + asf_st->pkt.buf = buf; + asf_st->pkt.data = buf->data; + } + } + } + asf_st->frag_offset = 0; + *pkt = asf_st->pkt; +#if FF_API_DESTRUCT_PACKET +FF_DISABLE_DEPRECATION_WARNINGS + asf_st->pkt.destruct = NULL; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + asf_st->pkt.buf = 0; + asf_st->pkt.size = 0; + asf_st->pkt.data = 0; + asf_st->pkt.side_data_elems = 0; + asf_st->pkt.side_data = NULL; + break; // packet completed + } + } + return 0; +} + +static int asf_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + ASFContext *asf = s->priv_data; + + for (;;) { + int ret; + + /* parse cached packets, if any */ + if ((ret = asf_parse_packet(s, s->pb, pkt)) <= 0) + return ret; + if ((ret = asf_get_packet(s, s->pb)) < 0) + assert(asf->packet_size_left < FRAME_HEADER_SIZE || + asf->packet_segments < 1); + asf->packet_time_start = 0; + } +} + +// Added to support seeking after packets have been read +// If information is not reset, read_packet fails due to +// leftover information from previous reads +static void asf_reset_header(AVFormatContext *s) +{ + ASFContext *asf = s->priv_data; + ASFStream *asf_st; + int i; + + asf->packet_size_left = 0; + asf->packet_flags = 0; + asf->packet_property = 0; + asf->packet_timestamp = 0; + asf->packet_segsizetype = 0; + asf->packet_segments = 0; + asf->packet_seq = 0; + asf->packet_replic_size = 0; + asf->packet_key_frame = 0; + asf->packet_padsize = 0; + asf->packet_frag_offset = 0; + asf->packet_frag_size = 0; + asf->packet_frag_timestamp = 0; + asf->packet_multi_size = 0; + asf->packet_time_delta = 0; + asf->packet_time_start = 0; + + for (i = 0; i < 128; i++) { + asf_st = &asf->streams[i]; + av_free_packet(&asf_st->pkt); + asf_st->packet_obj_size = 0; + asf_st->frag_offset = 0; + asf_st->seq = 0; + } + asf->asf_st = NULL; +} + +static void skip_to_key(AVFormatContext *s) +{ + ASFContext *asf = s->priv_data; + int i; + + for (i = 0; i < 128; i++) { + int j = asf->asfid2avid[i]; + ASFStream *asf_st = &asf->streams[i]; + if (j < 0 || s->streams[j]->codec->codec_type != AVMEDIA_TYPE_VIDEO) + continue; + + asf_st->skip_to_key = 1; + } +} + +static int asf_read_close(AVFormatContext *s) +{ + asf_reset_header(s); + + return 0; +} + +static int64_t asf_read_pts(AVFormatContext *s, int stream_index, + int64_t *ppos, int64_t pos_limit) +{ + ASFContext *asf = s->priv_data; + AVPacket pkt1, *pkt = &pkt1; + ASFStream *asf_st; + int64_t pts; + int64_t pos = *ppos; + int i; + int64_t start_pos[ASF_MAX_STREAMS]; + + for (i = 0; i < s->nb_streams; i++) + start_pos[i] = pos; + + if (s->packet_size > 0) + pos = (pos + s->packet_size - 1 - s->internal->data_offset) / + s->packet_size * s->packet_size + + s->internal->data_offset; + *ppos = pos; + if (avio_seek(s->pb, pos, SEEK_SET) < 0) + return AV_NOPTS_VALUE; + + ff_read_frame_flush(s); + asf_reset_header(s); + for (;;) { + if (av_read_frame(s, pkt) < 0) { + av_log(s, AV_LOG_INFO, "asf_read_pts failed\n"); + return AV_NOPTS_VALUE; + } + + pts = pkt->dts; + + av_free_packet(pkt); + if (pkt->flags & AV_PKT_FLAG_KEY) { + i = pkt->stream_index; + + asf_st = &asf->streams[s->streams[i]->id]; + +// assert((asf_st->packet_pos - s->data_offset) % s->packet_size == 0); + pos = asf_st->packet_pos; + av_assert1(pkt->pos == asf_st->packet_pos); + + av_add_index_entry(s->streams[i], pos, pts, pkt->size, + pos - start_pos[i] + 1, AVINDEX_KEYFRAME); + start_pos[i] = asf_st->packet_pos + 1; + + if (pkt->stream_index == stream_index) + break; + } + } + + *ppos = pos; + return pts; +} + +static int asf_build_simple_index(AVFormatContext *s, int stream_index) +{ + ff_asf_guid g; + ASFContext *asf = s->priv_data; + int64_t current_pos = avio_tell(s->pb); + int64_t ret; + + if((ret = avio_seek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET)) < 0) { + return ret; + } + + if ((ret = ff_get_guid(s->pb, &g)) < 0) + goto end; + + /* the data object can be followed by other top-level objects, + * skip them until the simple index object is reached */ + while (ff_guidcmp(&g, &ff_asf_simple_index_header)) { + int64_t gsize = avio_rl64(s->pb); + if (gsize < 24 || avio_feof(s->pb)) { + goto end; + } + avio_skip(s->pb, gsize - 24); + if ((ret = ff_get_guid(s->pb, &g)) < 0) + goto end; + } + + { + int64_t itime, last_pos = -1; + int pct, ict; + int i; + int64_t av_unused gsize = avio_rl64(s->pb); + if ((ret = ff_get_guid(s->pb, &g)) < 0) + goto end; + itime = avio_rl64(s->pb); + pct = avio_rl32(s->pb); + ict = avio_rl32(s->pb); + av_log(s, AV_LOG_DEBUG, + "itime:0x%"PRIx64", pct:%d, ict:%d\n", itime, pct, ict); + + for (i = 0; i < ict; i++) { + int pktnum = avio_rl32(s->pb); + int pktct = avio_rl16(s->pb); + int64_t pos = s->internal->data_offset + s->packet_size * (int64_t)pktnum; + int64_t index_pts = FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0); + + if (pos != last_pos) { + av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d pts: %"PRId64"\n", + pktnum, pktct, index_pts); + av_add_index_entry(s->streams[stream_index], pos, index_pts, + s->packet_size, 0, AVINDEX_KEYFRAME); + last_pos = pos; + } + } + asf->index_read = ict > 1; + } +end: +// if (avio_feof(s->pb)) { +// ret = 0; +// } + avio_seek(s->pb, current_pos, SEEK_SET); + return ret; +} + +static int asf_read_seek(AVFormatContext *s, int stream_index, + int64_t pts, int flags) +{ + ASFContext *asf = s->priv_data; + AVStream *st = s->streams[stream_index]; + int ret = 0; + + if (s->packet_size <= 0) + return -1; + + /* Try using the protocol's read_seek if available */ + if (s->pb) { + int64_t ret = avio_seek_time(s->pb, stream_index, pts, flags); + if (ret >= 0) + asf_reset_header(s); + if (ret != AVERROR(ENOSYS)) + return ret; + } + + /* explicitly handle the case of seeking to 0 */ + if (!pts) { + asf_reset_header(s); + avio_seek(s->pb, s->internal->data_offset, SEEK_SET); + return 0; + } + + if (!asf->index_read) { + ret = asf_build_simple_index(s, stream_index); + if (ret < 0) + asf->index_read = -1; + } + + if (asf->index_read > 0 && st->index_entries) { + int index = av_index_search_timestamp(st, pts, flags); + if (index >= 0) { + /* find the position */ + uint64_t pos = st->index_entries[index].pos; + + /* do the seek */ + av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos); + if(avio_seek(s->pb, pos, SEEK_SET) < 0) + return -1; + asf_reset_header(s); + skip_to_key(s); + return 0; + } + } + /* no index or seeking by index failed */ + if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0) + return -1; + asf_reset_header(s); + skip_to_key(s); + return 0; +} + +AVInputFormat ff_asf_demuxer = { + .name = "asf", + .long_name = NULL_IF_CONFIG_SMALL("ASF (Advanced / Active Streaming Format)"), + .priv_data_size = sizeof(ASFContext), + .read_probe = asf_probe, + .read_header = asf_read_header, + .read_packet = asf_read_packet, + .read_close = asf_read_close, + .read_seek = asf_read_seek, + .read_timestamp = asf_read_pts, + .flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH, + .priv_class = &asf_class, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/asfdec_o.c ffmpeg-2.7.2~trusty~ppa1/libavformat/asfdec_o.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/asfdec_o.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/asfdec_o.c 2015-08-02 17:20:02.000000000 +0000 @@ -0,0 +1,1731 @@ +/* + * Microsoft Advanced Streaming Format demuxer + * Copyright (c) 2014 Alexandra Hájková + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/attributes.h" +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/bswap.h" +#include "libavutil/common.h" +#include "libavutil/dict.h" +#include "libavutil/internal.h" +#include "libavutil/mathematics.h" +#include "libavutil/opt.h" +#include "libavutil/time_internal.h" + +#include "avformat.h" +#include "avio_internal.h" +#include "avlanguage.h" +#include "id3v2.h" +#include "internal.h" +#include "riff.h" +#include "asf.h" +#include "asfcrypt.h" + +#define ASF_BOOL 0x2 +#define ASF_WORD 0x5 +#define ASF_GUID 0x6 +#define ASF_DWORD 0x3 +#define ASF_QWORD 0x4 +#define ASF_UNICODE 0x0 +#define ASF_FLAG_BROADCAST 0x1 +#define ASF_BYTE_ARRAY 0x1 +#define ASF_TYPE_AUDIO 0x2 +#define ASF_TYPE_VIDEO 0x1 +#define ASF_STREAM_NUM 0x7F +#define ASF_MAX_STREAMS 128 +#define BMP_HEADER_SIZE 40 +#define ASF_NUM_OF_PAYLOADS 0x3F +#define ASF_ERROR_CORRECTION_LENGTH_TYPE 0x60 +#define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2 + +typedef struct GUIDParseTable { + const char *name; + ff_asf_guid guid; + int (*read_object)(AVFormatContext *, const struct GUIDParseTable *); + int is_subobject; +} GUIDParseTable; + +typedef struct ASFPacket { + AVPacket avpkt; + int64_t dts; + uint32_t frame_num; // ASF payloads with the same number are parts of the same frame + int flags; + int data_size; + int duration; + int size_left; + uint8_t stream_index; +} ASFPacket; + +typedef struct ASFStream { + uint8_t stream_index; // from packet header + int index; // stream index in AVFormatContext, set in asf_read_stream_properties + int type; + int indexed; // added index entries from the Simple Index Object or not + int8_t span; // for deinterleaving + uint16_t virtual_pkt_len; + uint16_t virtual_chunk_len; + int16_t lang_idx; + ASFPacket pkt; +} ASFStream; + +typedef struct ASFStreamData{ + char langs[32]; + AVDictionary *asf_met; // for storing per-stream metadata + AVRational aspect_ratio; +} ASFStreamData; + +typedef struct ASFContext { + int data_reached; + int is_simple_index; // is simple index present or not 1/0 + int is_header; + + uint64_t preroll; + uint64_t nb_packets; // ASF packets + uint32_t packet_size; + int64_t send_time; + int duration; + + uint32_t b_flags; // flags with broadcast flag + uint32_t prop_flags; // file properties object flags + + uint64_t data_size; // data object size + uint64_t unknown_size; // size of the unknown object + + int64_t offset; // offset of the current object + + int64_t data_offset; + int64_t first_packet_offset; // packet offset + int64_t unknown_offset; // for top level header objects or subobjects without specified behavior + + // ASF file must not contain more than 128 streams according to the specification + ASFStream *asf_st[ASF_MAX_STREAMS]; + ASFStreamData asf_sd[ASF_MAX_STREAMS]; + int nb_streams; + + int stream_index; // from packet header, for the subpayload case + + // packet parameteres + uint64_t sub_header_offset; // offset of subplayload header + int64_t sub_dts; + uint8_t dts_delta; // for subpayloads + uint32_t packet_size_internal; // packet size stored inside ASFPacket, can be 0 + int64_t packet_offset; // offset of the current packet inside Data Object + uint32_t pad_len; // padding after payload + uint32_t rep_data_len; + + // packet state + uint64_t sub_left; // subpayloads left or not + unsigned int nb_sub; // number of subpayloads read so far from the current ASF packet + uint16_t mult_sub_len; // total length of subpayloads array inside multiple payload + uint64_t nb_mult_left; // multiple payloads left + int return_subpayload; + enum { + PARSE_PACKET_HEADER, + READ_SINGLE, + READ_MULTI, + READ_MULTI_SUB + } state; +} ASFContext; + +static int detect_unknown_subobject(AVFormatContext *s, int64_t offset, int64_t size); +static const GUIDParseTable *find_guid(ff_asf_guid guid); + +static int asf_probe(AVProbeData *pd) +{ + /* check file header */ + if (!ff_guidcmp(pd->buf, &ff_asf_header)) + return AVPROBE_SCORE_MAX/2; + else + return 0; +} + +static void swap_guid(ff_asf_guid guid) +{ + FFSWAP(unsigned char, guid[0], guid[3]); + FFSWAP(unsigned char, guid[1], guid[2]); + FFSWAP(unsigned char, guid[4], guid[5]); + FFSWAP(unsigned char, guid[6], guid[7]); +} + +static void align_position(AVIOContext *pb, int64_t offset, uint64_t size) +{ + if (avio_tell(pb) != offset + size) + avio_seek(pb, offset + size, SEEK_SET); +} + +static int asf_read_unknown(AVFormatContext *s, const GUIDParseTable *g) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + uint64_t size = avio_rl64(pb); + int ret; + + if (asf->is_header) + asf->unknown_size = size; + asf->is_header = 0; + if (!g->is_subobject) { + if (!(ret = strcmp(g->name, "Header Extension"))) + avio_skip(pb, 22); // skip reserved fields and Data Size + if ((ret = detect_unknown_subobject(s, asf->unknown_offset, + asf->unknown_size)) < 0) + return ret; + } else + avio_skip(pb, size - 24); + + return 0; +} + +static int get_asf_string(AVIOContext *pb, int maxlen, char *buf, int buflen) +{ + char *q = buf; + int ret = 0; + if (buflen <= 0) + return AVERROR(EINVAL); + while (ret + 1 < maxlen) { + uint8_t tmp; + uint32_t ch; + GET_UTF16(ch, (ret += 2) <= maxlen ? avio_rl16(pb) : 0, break;); + PUT_UTF8(ch, tmp, if (q - buf < buflen - 1) *q++ = tmp;) + } + *q = 0; + + return ret; +} + +static int asf_read_marker(AVFormatContext *s, const GUIDParseTable *g) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + uint64_t size = avio_rl64(pb); + int i, nb_markers, ret; + size_t len; + char name[1024]; + + avio_skip(pb, 8); + avio_skip(pb, 8); // skip reserved GUID + nb_markers = avio_rl32(pb); + avio_skip(pb, 2); // skip reserved field + len = avio_rl16(pb); + for (i = 0; i < len; i++) + avio_skip(pb, 1); + + for (i = 0; i < nb_markers; i++) { + int64_t pts; + + avio_skip(pb, 8); + pts = avio_rl64(pb); + pts -= asf->preroll * 10000; + avio_skip(pb, 2); // entry length + avio_skip(pb, 4); // send time + avio_skip(pb, 4); // flags + len = avio_rl32(pb); + + if ((ret = avio_get_str16le(pb, len, name, + sizeof(name))) < len) + avio_skip(pb, len - ret); + avpriv_new_chapter(s, i, (AVRational) { 1, 10000000 }, pts, + AV_NOPTS_VALUE, name); + } + align_position(pb, asf->offset, size); + + return 0; +} + +static int asf_read_metadata(AVFormatContext *s, const char *title, uint16_t len, + unsigned char *ch, uint16_t buflen) +{ + AVIOContext *pb = s->pb; + + avio_get_str16le(pb, len, ch, buflen); + if (ch[0]) { + if (av_dict_set(&s->metadata, title, ch, 0) < 0) + av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n"); + } + + return 0; +} + +static int asf_read_value(AVFormatContext *s, const uint8_t *name, uint16_t name_len, + uint16_t val_len, int type, AVDictionary **met) +{ + int ret; + uint8_t *value; + uint16_t buflen = 2 * val_len + 1; + AVIOContext *pb = s->pb; + + value = av_malloc(buflen); + if (!value) + return AVERROR(ENOMEM); + if (type == ASF_UNICODE) { + // get_asf_string reads UTF-16 and converts it to UTF-8 which needs longer buffer + if ((ret = get_asf_string(pb, val_len, value, buflen)) < 0) + goto failed; + if (av_dict_set(met, name, value, 0) < 0) + av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n"); + } else { + char buf[256]; + if (val_len > sizeof(buf)) { + ret = AVERROR_INVALIDDATA; + goto failed; + } + if ((ret = avio_read(pb, value, val_len)) < 0) + goto failed; + if (ret < 2 * val_len) + value[ret] = '\0'; + else + value[2 * val_len - 1] = '\0'; + snprintf(buf, sizeof(buf), "%s", value); + if (av_dict_set(met, name, buf, 0) < 0) + av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n"); + } + av_freep(&value); + + return 0; + +failed: + av_freep(&value); + return ret; +} + +static int asf_read_generic_value(AVFormatContext *s, const uint8_t *name, + uint16_t name_len, int type, AVDictionary **met) +{ + AVIOContext *pb = s->pb; + uint64_t value; + char buf[32]; + + switch (type) { + case ASF_BOOL: + value = avio_rl32(pb); + break; + case ASF_DWORD: + value = avio_rl32(pb); + break; + case ASF_QWORD: + value = avio_rl64(pb); + break; + case ASF_WORD: + value = avio_rl16(pb); + break; + default: + return AVERROR_INVALIDDATA; + } + snprintf(buf, sizeof(buf), "%"PRIu64, value); + if (av_dict_set(met, name, buf, 0) < 0) + av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n"); + + return 0; +} + +/* MSDN claims that this should be "compatible with the ID3 frame, APIC", + * but in reality this is only loosely similar */ +static int asf_read_picture(AVFormatContext *s, int len) +{ + ASFContext *asf = s->priv_data; + AVPacket pkt = { 0 }; + const CodecMime *mime = ff_id3v2_mime_tags; + enum AVCodecID id = AV_CODEC_ID_NONE; + char mimetype[64]; + uint8_t *desc = NULL; + AVStream *st = NULL; + int ret, type, picsize, desc_len; + ASFStream *asf_st; + + /* type + picsize + mime + desc */ + if (len < 1 + 4 + 2 + 2) { + av_log(s, AV_LOG_ERROR, "Invalid attached picture size: %d.\n", len); + return AVERROR_INVALIDDATA; + } + + /* picture type */ + type = avio_r8(s->pb); + len--; + if (type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || type < 0) { + av_log(s, AV_LOG_WARNING, "Unknown attached picture type: %d.\n", type); + type = 0; + } + + /* picture data size */ + picsize = avio_rl32(s->pb); + len -= 4; + + /* picture MIME type */ + len -= avio_get_str16le(s->pb, len, mimetype, sizeof(mimetype)); + while (mime->id != AV_CODEC_ID_NONE) { + if (!strncmp(mime->str, mimetype, sizeof(mimetype))) { + id = mime->id; + break; + } + mime++; + } + if (id == AV_CODEC_ID_NONE) { + av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n", + mimetype); + return 0; + } + + if (picsize >= len) { + av_log(s, AV_LOG_ERROR, "Invalid attached picture data size: %d >= %d.\n", + picsize, len); + return AVERROR_INVALIDDATA; + } + + /* picture description */ + desc_len = (len - picsize) * 2 + 1; + desc = av_malloc(desc_len); + if (!desc) + return AVERROR(ENOMEM); + len -= avio_get_str16le(s->pb, len - picsize, desc, desc_len); + + ret = av_get_packet(s->pb, &pkt, picsize); + if (ret < 0) + goto fail; + + st = avformat_new_stream(s, NULL); + if (!st) { + ret = AVERROR(ENOMEM); + goto fail; + } + asf->asf_st[asf->nb_streams] = av_mallocz(sizeof(*asf_st)); + asf_st = asf->asf_st[asf->nb_streams]; + if (!asf_st) { + ret = AVERROR(ENOMEM); + goto fail; + } + + st->disposition |= AV_DISPOSITION_ATTACHED_PIC; + st->codec->codec_type = asf_st->type = AVMEDIA_TYPE_VIDEO; + st->codec->codec_id = id; + st->attached_pic = pkt; + st->attached_pic.stream_index = asf_st->index = st->index; + st->attached_pic.flags |= AV_PKT_FLAG_KEY; + + asf->nb_streams++; + + if (*desc) { + if (av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL) < 0) + av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n"); + } else + av_freep(&desc); + + if (av_dict_set(&st->metadata, "comment", ff_id3v2_picture_types[type], 0) < 0) + av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n"); + + return 0; + +fail: + av_freep(&desc); + av_free_packet(&pkt); + return ret; +} + +static void get_id3_tag(AVFormatContext *s, int len) +{ + ID3v2ExtraMeta *id3v2_extra_meta = NULL; + + ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, len); + if (id3v2_extra_meta) + ff_id3v2_parse_apic(s, &id3v2_extra_meta); + ff_id3v2_free_extra_meta(&id3v2_extra_meta); +} + +static int process_metadata(AVFormatContext *s, const uint8_t *name, uint16_t name_len, + uint16_t val_len, uint16_t type, AVDictionary **met) +{ + int ret; + ff_asf_guid guid; + + if (val_len) { + switch (type) { + case ASF_UNICODE: + asf_read_value(s, name, name_len, val_len, type, met); + break; + case ASF_BYTE_ARRAY: + if (!strcmp(name, "WM/Picture")) // handle cover art + asf_read_picture(s, val_len); + else if (!strcmp(name, "ID3")) // handle ID3 tag + get_id3_tag(s, val_len); + else + asf_read_value(s, name, name_len, val_len, type, met); + break; + case ASF_GUID: + ff_get_guid(s->pb, &guid); + break; + default: + if ((ret = asf_read_generic_value(s, name, name_len, type, met)) < 0) + return ret; + break; + } + } + + return 0; +} + +static int asf_read_ext_content(AVFormatContext *s, const GUIDParseTable *g) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + uint64_t size = avio_rl64(pb); + uint16_t nb_desc = avio_rl16(pb); + int i, ret; + + for (i = 0; i < nb_desc; i++) { + uint16_t name_len, type, val_len; + uint8_t *name = NULL; + + name_len = avio_rl16(pb); + if (!name_len) + return AVERROR_INVALIDDATA; + name = av_malloc(name_len); + if (!name) + return AVERROR(ENOMEM); + avio_get_str16le(pb, name_len, name, + name_len); + type = avio_rl16(pb); + val_len = avio_rl16(pb); + + ret = process_metadata(s, name, name_len, val_len, type, &s->metadata); + av_freep(&name); + if (ret < 0) + return ret; + } + + align_position(pb, asf->offset, size); + return 0; +} + +static AVStream *find_stream(AVFormatContext *s, uint16_t st_num) +{ + AVStream *st = NULL; + ASFContext *asf = s->priv_data; + int i; + + for (i = 0; i < asf->nb_streams; i++) { + if (asf->asf_st[i]->stream_index == st_num) { + st = s->streams[asf->asf_st[i]->index]; + break; + } + } + + return st; +} + +static void asf_store_aspect_ratio(AVFormatContext *s, uint8_t st_num, uint8_t *name) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + uint16_t value = 0; + + value = avio_rl16(pb); + + if (st_num < ASF_MAX_STREAMS) { + if (!strcmp(name, "AspectRatioX")) + asf->asf_sd[st_num].aspect_ratio.num = value; + else + asf->asf_sd[st_num].aspect_ratio.den = value; + } +} + +static int asf_read_metadata_obj(AVFormatContext *s, const GUIDParseTable *g) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + uint64_t size = avio_rl64(pb); + uint16_t nb_recs = avio_rl16(pb); // number of records in the Description Records list + int i, ret; + + for (i = 0; i < nb_recs; i++) { + uint16_t name_len, buflen, type, val_len, st_num; + uint8_t *name = NULL; + + avio_skip(pb, 2); // skip reserved field + st_num = avio_rl16(pb); + name_len = avio_rl16(pb); + buflen = 2 * name_len + 1; + if (!name_len) + break; + type = avio_rl16(pb); + val_len = avio_rl32(pb); + name = av_malloc(name_len); + if (!name) + return AVERROR(ENOMEM); + avio_get_str16le(pb, name_len, name, + buflen); + + if (!strcmp(name, "AspectRatioX") || !strcmp(name, "AspectRatioY")) { + asf_store_aspect_ratio(s, st_num, name); + } else { + if (st_num < ASF_MAX_STREAMS) { + if ((ret = process_metadata(s, name, name_len, val_len, type, + &asf->asf_sd[st_num].asf_met)) < 0) { + av_freep(&name); + break; + } + } + } + av_freep(&name); + } + + align_position(pb, asf->offset, size); + return 0; +} + +static int asf_read_content_desc(AVFormatContext *s, const GUIDParseTable *g) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + int i; + static const char *const titles[] = + { "Title", "Author", "Copyright", "Description", "Rate" }; + uint16_t len[5], buflen[5] = { 0 }; + uint8_t *ch; + uint64_t size = avio_rl64(pb); + + for (i = 0; i < 5; i++) { + len[i] = avio_rl16(pb); + // utf8 string should be <= 2 * utf16 string, extra byte for the terminator + buflen[i] = 2 * len[i] + 1; + } + + for (i = 0; i < 5; i++) { + ch = av_malloc(buflen[i]); + if (!ch) + return(AVERROR(ENOMEM)); + asf_read_metadata(s, titles[i], len[i], ch, buflen[i]); + av_freep(&ch); + } + align_position(pb, asf->offset, size); + + return 0; +} + +static int asf_read_properties(AVFormatContext *s, const GUIDParseTable *g) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + uint64_t creation_time; + + avio_rl64(pb); // read object size + avio_skip(pb, 16); // skip File ID + avio_skip(pb, 8); // skip File size + creation_time = avio_rl64(pb); + if (!(asf->b_flags & ASF_FLAG_BROADCAST)) { + struct tm tmbuf; + struct tm *tm; + char buf[64]; + + // creation date is in 100 ns units from 1 Jan 1601, conversion to s + creation_time /= 10000000; + // there are 11644473600 seconds between 1 Jan 1601 and 1 Jan 1970 + creation_time -= 11644473600; + tm = gmtime_r(&creation_time, &tmbuf); + if (tm) { + if (!strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm)) + buf[0] = '\0'; + } else + buf[0] = '\0'; + if (buf[0]) { + if (av_dict_set(&s->metadata, "creation_time", buf, 0) < 0) + av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n"); + } + } + asf->nb_packets = avio_rl64(pb); + asf->duration = avio_rl64(pb) / 10000; // stream duration + avio_skip(pb, 8); // skip send duration + asf->preroll = avio_rl64(pb); + asf->duration -= asf->preroll; + asf->b_flags = avio_rl32(pb); + avio_skip(pb, 4); // skip minimal packet size + asf->packet_size = avio_rl32(pb); + avio_skip(pb, 4); // skip max_bitrate + + return 0; +} + +static int parse_video_info(AVIOContext *pb, AVStream *st) +{ + uint16_t size; + unsigned int tag; + + st->codec->width = avio_rl32(pb); + st->codec->height = avio_rl32(pb); + avio_skip(pb, 1); // skip reserved flags + size = avio_rl16(pb); // size of the Format Data + tag = ff_get_bmp_header(pb, st, NULL); + st->codec->codec_tag = tag; + st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag); + + if (size > BMP_HEADER_SIZE) { + int ret; + st->codec->extradata_size = size - BMP_HEADER_SIZE; + if (!(st->codec->extradata = av_malloc(st->codec->extradata_size + + AV_INPUT_BUFFER_PADDING_SIZE))) { + st->codec->extradata_size = 0; + return AVERROR(ENOMEM); + } + memset(st->codec->extradata + st->codec->extradata_size , 0, + AV_INPUT_BUFFER_PADDING_SIZE); + if ((ret = avio_read(pb, st->codec->extradata, + st->codec->extradata_size)) < 0) + return ret; + } + return 0; +} + +static int asf_read_stream_properties(AVFormatContext *s, const GUIDParseTable *g) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + uint64_t size; + uint32_t err_data_len, ts_data_len; // type specific data length + uint16_t flags; + ff_asf_guid stream_type; + enum AVMediaType type; + int i, ret; + uint8_t stream_index; + AVStream *st; + ASFStream *asf_st; + + // ASF file must not contain more than 128 streams according to the specification + if (asf->nb_streams >= ASF_MAX_STREAMS) + return AVERROR_INVALIDDATA; + + size = avio_rl64(pb); + ff_get_guid(pb, &stream_type); + if (!ff_guidcmp(&stream_type, &ff_asf_audio_stream)) + type = AVMEDIA_TYPE_AUDIO; + else if (!ff_guidcmp(&stream_type, &ff_asf_video_stream)) + type = AVMEDIA_TYPE_VIDEO; + else if (!ff_guidcmp(&stream_type, &ff_asf_jfif_media)) + type = AVMEDIA_TYPE_VIDEO; + else if (!ff_guidcmp(&stream_type, &ff_asf_command_stream)) + type = AVMEDIA_TYPE_DATA; + else if (!ff_guidcmp(&stream_type, + &ff_asf_ext_stream_embed_stream_header)) + type = AVMEDIA_TYPE_UNKNOWN; + else + return AVERROR_INVALIDDATA; + + ff_get_guid(pb, &stream_type); // error correction type + avio_skip(pb, 8); // skip the time offset + ts_data_len = avio_rl32(pb); + err_data_len = avio_rl32(pb); + flags = avio_rl16(pb); // bit 15 - Encrypted Content + + stream_index = flags & ASF_STREAM_NUM; + for (i = 0; i < asf->nb_streams; i++) + if (stream_index == asf->asf_st[i]->stream_index) { + av_log(s, AV_LOG_WARNING, + "Duplicate stream found, this stream will be ignored.\n"); + align_position(pb, asf->offset, size); + return 0; + } + + st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + avpriv_set_pts_info(st, 32, 1, 1000); // pts should be dword, in milliseconds + st->codec->codec_type = type; + asf->asf_st[asf->nb_streams] = av_mallocz(sizeof(*asf_st)); + if (!asf->asf_st[asf->nb_streams]) + return AVERROR(ENOMEM); + asf_st = asf->asf_st[asf->nb_streams]; + asf->nb_streams++; + asf_st->stream_index = stream_index; + asf_st->index = st->index; + asf_st->indexed = 0; + st->id = flags & ASF_STREAM_NUM; + av_init_packet(&asf_st->pkt.avpkt); + asf_st->pkt.data_size = 0; + avio_skip(pb, 4); // skip reserved field + + switch (type) { + case AVMEDIA_TYPE_AUDIO: + asf_st->type = AVMEDIA_TYPE_AUDIO; + if ((ret = ff_get_wav_header(s, pb, st->codec, ts_data_len, 0)) < 0) + return ret; + break; + case AVMEDIA_TYPE_VIDEO: + asf_st->type = AVMEDIA_TYPE_VIDEO; + if ((ret = parse_video_info(pb, st)) < 0) + return ret; + break; + default: + avio_skip(pb, ts_data_len); + break; + } + + if (err_data_len) { + if (type == AVMEDIA_TYPE_AUDIO) { + uint8_t span = avio_r8(pb); + if (span > 1) { + asf_st->span = span; + asf_st->virtual_pkt_len = avio_rl16(pb); + asf_st->virtual_chunk_len = avio_rl16(pb); + if (!asf_st->virtual_chunk_len || !asf_st->virtual_pkt_len) + return AVERROR_INVALIDDATA; + avio_skip(pb, err_data_len - 5); + } else + avio_skip(pb, err_data_len - 1); + } else + avio_skip(pb, err_data_len); + } + + align_position(pb, asf->offset, size); + + return 0; +} + +static void set_language(AVFormatContext *s, const char *rfc1766, AVDictionary **met) +{ + // language abbr should contain at least 2 chars + if (rfc1766 && strlen(rfc1766) > 1) { + const char primary_tag[3] = { rfc1766[0], rfc1766[1], '\0' }; // ignore country code if any + const char *iso6392 = av_convert_lang_to(primary_tag, + AV_LANG_ISO639_2_BIBL); + if (iso6392) + if (av_dict_set(met, "language", iso6392, 0) < 0) + av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n"); + } +} + +static int asf_read_ext_stream_properties(AVFormatContext *s, const GUIDParseTable *g) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + AVStream *st = NULL; + ff_asf_guid guid; + uint16_t nb_st_name, nb_pay_exts, st_num, lang_idx; + int i, ret; + uint32_t bitrate; + uint64_t start_time, end_time, time_per_frame; + uint64_t size = avio_rl64(pb); + + start_time = avio_rl64(pb); + end_time = avio_rl64(pb); + bitrate = avio_rl32(pb); + avio_skip(pb, 28); // skip some unused values + st_num = avio_rl16(pb); + st_num &= ASF_STREAM_NUM; + lang_idx = avio_rl16(pb); // Stream Language ID Index + for (i = 0; i < asf->nb_streams; i++) { + if (st_num == asf->asf_st[i]->stream_index) { + st = s->streams[asf->asf_st[i]->index]; + asf->asf_st[i]->lang_idx = lang_idx; + break; + } + } + time_per_frame = avio_rl64(pb); // average time per frame + if (st) { + st->start_time = start_time; + st->duration = end_time - start_time; + st->codec->bit_rate = bitrate; + st->avg_frame_rate.num = 10000000; + st->avg_frame_rate.den = time_per_frame; + } + nb_st_name = avio_rl16(pb); + nb_pay_exts = avio_rl16(pb); + for (i = 0; i < nb_st_name; i++) { + uint16_t len; + + avio_rl16(pb); // Language ID Index + len = avio_rl16(pb); + avio_skip(pb, len); + } + + for (i = 0; i < nb_pay_exts; i++) { + uint32_t len; + avio_skip(pb, 16); // Extension System ID + avio_skip(pb, 2); // Extension Data Size + len = avio_rl32(pb); + avio_skip(pb, len); + } + + if ((ret = ff_get_guid(pb, &guid)) < 0) { + align_position(pb, asf->offset, size); + + return 0; + } + + g = find_guid(guid); + if (g && !(strcmp(g->name, "Stream Properties"))) { + if ((ret = g->read_object(s, g)) < 0) + return ret; + } + + align_position(pb, asf->offset, size); + return 0; +} + +static int asf_read_language_list(AVFormatContext *s, const GUIDParseTable *g) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + int i, ret; + uint64_t size = avio_rl64(pb); + uint16_t nb_langs = avio_rl16(pb); + + if (nb_langs < ASF_MAX_STREAMS) { + for (i = 0; i < nb_langs; i++) { + size_t len; + len = avio_r8(pb); + if (!len) + len = 6; + if ((ret = get_asf_string(pb, len, asf->asf_sd[i].langs, + sizeof(asf->asf_sd[i].langs))) < 0) { + return ret; + } + } + } + + align_position(pb, asf->offset, size); + return 0; +} + +// returns data object offset when reading this object for the first time +static int asf_read_data(AVFormatContext *s, const GUIDParseTable *g) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + uint64_t size = asf->data_size = avio_rl64(pb); + int i; + + if (!asf->data_reached) { + asf->data_reached = 1; + asf->data_offset = asf->offset; + } + + for (i = 0; i < asf->nb_streams; i++) { + if (!(asf->b_flags & ASF_FLAG_BROADCAST)) + s->streams[i]->duration = asf->duration; + } + asf->nb_mult_left = 0; + asf->sub_left = 0; + asf->state = PARSE_PACKET_HEADER; + asf->return_subpayload = 0; + asf->packet_size_internal = 0; + avio_skip(pb, 16); // skip File ID + size = avio_rl64(pb); // Total Data Packets + if (size != asf->nb_packets) + av_log(s, AV_LOG_WARNING, + "Number of Packets from File Properties Object is not equal to Total" + "Datapackets value! num of packets %"PRIu64" total num %"PRIu64".\n", + size, asf->nb_packets); + avio_skip(pb, 2); // skip reserved field + asf->first_packet_offset = avio_tell(pb); + if (pb->seekable && !(asf->b_flags & ASF_FLAG_BROADCAST)) + align_position(pb, asf->offset, asf->data_size); + + return 0; +} + +static int asf_read_simple_index(AVFormatContext *s, const GUIDParseTable *g) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + AVStream *st = NULL; + uint64_t interval; // index entry time interval in 100 ns units, usually it's 1s + uint32_t pkt_num, nb_entries; + int32_t prev_pkt_num = -1; + int i; + uint64_t size = avio_rl64(pb); + + // simple index objects should be ordered by stream number, this loop tries to find + // the first not indexed video stream + for (i = 0; i < asf->nb_streams; i++) { + if ((asf->asf_st[i]->type == AVMEDIA_TYPE_VIDEO) && !asf->asf_st[i]->indexed) { + asf->asf_st[i]->indexed = 1; + st = s->streams[asf->asf_st[i]->index]; + break; + } + } + if (!st) { + avio_skip(pb, size - 24); // if there's no video stream, skip index object + return 0; + } + avio_skip(pb, 16); // skip File ID + interval = avio_rl64(pb); + avio_skip(pb, 4); + nb_entries = avio_rl32(pb); + for (i = 0; i < nb_entries; i++) { + pkt_num = avio_rl32(pb); + avio_skip(pb, 2); + if (prev_pkt_num != pkt_num) { + av_add_index_entry(st, asf->first_packet_offset + asf->packet_size * + pkt_num, av_rescale(interval, i, 10000), + asf->packet_size, 0, AVINDEX_KEYFRAME); + prev_pkt_num = pkt_num; + } + } + asf->is_simple_index = 1; + align_position(pb, asf->offset, size); + + return 0; +} + +static const GUIDParseTable gdef[] = { + { "Data", { 0x75, 0xB2, 0x26, 0x36, 0x66, 0x8E, 0x11, 0xCF, 0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C }, asf_read_data, 1 }, + { "Simple Index", { 0x33, 0x00, 0x08, 0x90, 0xE5, 0xB1, 0x11, 0xCF, 0x89, 0xF4, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB }, asf_read_simple_index, 1 }, + { "Content Description", { 0x75, 0xB2, 0x26, 0x33, 0x66 ,0x8E, 0x11, 0xCF, 0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C }, asf_read_content_desc, 1 }, + { "Extended Content Description", { 0xD2, 0xD0, 0xA4, 0x40, 0xE3, 0x07, 0x11, 0xD2, 0x97, 0xF0, 0x00, 0xA0, 0xC9, 0x5e, 0xA8, 0x50 }, asf_read_ext_content, 1 }, + { "Stream Bitrate Properties", { 0x7B, 0xF8, 0x75, 0xCE, 0x46, 0x8D, 0x11, 0xD1, 0x8D, 0x82, 0x00, 0x60, 0x97, 0xC9, 0xA2, 0xB2 }, asf_read_unknown, 1 }, + { "File Properties", { 0x8C, 0xAB, 0xDC, 0xA1, 0xA9, 0x47, 0x11, 0xCF, 0x8E, 0xE4, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65 }, asf_read_properties, 1 }, + { "Header Extension", { 0x5F, 0xBF, 0x03, 0xB5, 0xA9, 0x2E, 0x11, 0xCF, 0x8E, 0xE3, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65 }, asf_read_unknown, 0 }, + { "Stream Properties", { 0xB7, 0xDC, 0x07, 0x91, 0xA9, 0xB7, 0x11, 0xCF, 0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65 }, asf_read_stream_properties, 1 }, + { "Codec List", { 0x86, 0xD1, 0x52, 0x40, 0x31, 0x1D, 0x11, 0xD0, 0xA3, 0xA4, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6 }, asf_read_unknown, 1 }, + { "Marker", { 0xF4, 0x87, 0xCD, 0x01, 0xA9, 0x51, 0x11, 0xCF, 0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65 }, asf_read_marker, 1 }, + { "Script Command", { 0x1E, 0xFB, 0x1A, 0x30, 0x0B, 0x62, 0x11, 0xD0, 0xA3, 0x9B, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6 }, asf_read_unknown, 1 }, + { "Language List", { 0x7C, 0x43, 0x46, 0xa9, 0xef, 0xe0, 0x4B, 0xFC, 0xB2, 0x29, 0x39, 0x3e, 0xde, 0x41, 0x5c, 0x85 }, asf_read_language_list, 1}, + { "Padding", { 0x18, 0x06, 0xD4, 0x74, 0xCA, 0xDF, 0x45, 0x09, 0xA4, 0xBA, 0x9A, 0xAB, 0xCB, 0x96, 0xAA, 0xE8 }, asf_read_unknown, 1 }, + { "DRMv1 Header", { 0x22, 0x11, 0xB3, 0xFB, 0xBD, 0x23, 0x11, 0xD2, 0xB4, 0xB7, 0x00, 0xA0, 0xC9, 0x55, 0xFC, 0x6E }, asf_read_unknown, 1 }, + { "DRMv2 Header", { 0x29, 0x8A, 0xE6, 0x14, 0x26, 0x22, 0x4C, 0x17, 0xB9, 0x35, 0xDA, 0xE0, 0x7E, 0xE9, 0x28, 0x9c }, asf_read_unknown, 1 }, + { "Index", { 0xD6, 0xE2, 0x29, 0xD3, 0x35, 0xDA, 0x11, 0xD1, 0x90, 0x34, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xBE }, asf_read_unknown, 1 }, + { "Media Object Index", { 0xFE, 0xB1, 0x03, 0xF8, 0x12, 0xAD, 0x4C, 0x64, 0x84, 0x0F, 0x2A, 0x1D, 0x2F, 0x7A, 0xD4, 0x8C }, asf_read_unknown, 1 }, + { "Timecode Index", { 0x3C, 0xB7, 0x3F, 0xD0, 0x0C, 0x4A, 0x48, 0x03, 0x95, 0x3D, 0xED, 0xF7, 0xB6, 0x22, 0x8F, 0x0C }, asf_read_unknown, 0 }, + { "Bitrate_Mutual_Exclusion", { 0xD6, 0xE2, 0x29, 0xDC, 0x35, 0xDA, 0x11, 0xD1, 0x90, 0x34, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xBE }, asf_read_unknown, 1 }, + { "Error Correction", { 0x75, 0xB2, 0x26, 0x35, 0x66, 0x8E, 0x11, 0xCF, 0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C }, asf_read_unknown, 1 }, + { "Content Branding", { 0x22, 0x11, 0xB3, 0xFA, 0xBD, 0x23, 0x11, 0xD2, 0xB4, 0xB7, 0x00, 0xA0, 0xC9, 0x55, 0xFC, 0x6E }, asf_read_unknown, 1 }, + { "Content Encryption", { 0x22, 0x11, 0xB3, 0xFB, 0xBD, 0x23, 0x11, 0xD2, 0xB4, 0xB7, 0x00, 0xA0, 0xC9, 0x55, 0xFC, 0x6E }, asf_read_unknown, 1 }, + { "Extended Content Encryption", { 0x29, 0x8A, 0xE6, 0x14, 0x26, 0x22, 0x4C, 0x17, 0xB9, 0x35, 0xDA, 0xE0, 0x7E, 0xE9, 0x28, 0x9C }, asf_read_unknown, 1 }, + { "Digital Signature", { 0x22, 0x11, 0xB3, 0xFC, 0xBD, 0x23, 0x11, 0xD2, 0xB4, 0xB7, 0x00, 0xA0, 0xC9, 0x55, 0xFC, 0x6E }, asf_read_unknown, 1 }, + { "Extended Stream Properties", { 0x14, 0xE6, 0xA5, 0xCB, 0xC6, 0x72, 0x43, 0x32, 0x83, 0x99, 0xA9, 0x69, 0x52, 0x06, 0x5B, 0x5A }, asf_read_ext_stream_properties, 1 }, + { "Advanced Mutual Exclusion", { 0xA0, 0x86, 0x49, 0xCF, 0x47, 0x75, 0x46, 0x70, 0x8A, 0x16, 0x6E, 0x35, 0x35, 0x75, 0x66, 0xCD }, asf_read_unknown, 1 }, + { "Group Mutual Exclusion", { 0xD1, 0x46, 0x5A, 0x40, 0x5A, 0x79, 0x43, 0x38, 0xB7, 0x1B, 0xE3, 0x6B, 0x8F, 0xD6, 0xC2, 0x49 }, asf_read_unknown, 1}, + { "Stream Prioritization", { 0xD4, 0xFE, 0xD1, 0x5B, 0x88, 0xD3, 0x45, 0x4F, 0x81, 0xF0, 0xED, 0x5C, 0x45, 0x99, 0x9E, 0x24 }, asf_read_unknown, 1 }, + { "Bandwidth Sharing Object", { 0xA6, 0x96, 0x09, 0xE6, 0x51, 0x7B, 0x11, 0xD2, 0xB6, 0xAF, 0x00, 0xC0, 0x4F, 0xD9, 0x08, 0xE9 }, asf_read_unknown, 1 }, + { "Metadata", { 0xC5, 0xF8, 0xCB, 0xEA, 0x5B, 0xAF, 0x48, 0x77, 0x84, 0x67, 0xAA, 0x8C, 0x44, 0xFA, 0x4C, 0xCA }, asf_read_metadata_obj, 1 }, + { "Metadata Library", { 0x44, 0x23, 0x1C, 0x94, 0x94, 0x98, 0x49, 0xD1, 0xA1, 0x41, 0x1D, 0x13, 0x4E, 0x45, 0x70, 0x54 }, asf_read_metadata_obj, 1 }, + { "Audio Spread", { 0xBF, 0xC3, 0xCD, 0x50, 0x61, 0x8F, 0x11, 0xCF, 0x8B, 0xB2, 0x00, 0xAA, 0x00, 0xB4, 0xE2, 0x20 }, asf_read_unknown, 1 }, + { "Index Parameters", { 0xD6, 0xE2, 0x29, 0xDF, 0x35, 0xDA, 0x11, 0xD1, 0x90, 0x34, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xBE }, asf_read_unknown, 1 }, + { "Content Encryption System Windows Media DRM Network Devices", + { 0x7A, 0x07, 0x9B, 0xB6, 0xDA, 0XA4, 0x4e, 0x12, 0xA5, 0xCA, 0x91, 0xD3, 0x8D, 0xC1, 0x1A, 0x8D }, asf_read_unknown, 1 }, + { "Mutex Language", { 0xD6, 0xE2, 0x2A, 0x00, 0x25, 0xDA, 0x11, 0xD1, 0x90, 0x34, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xBE }, asf_read_unknown, 1 }, + { "Mutex Bitrate", { 0xD6, 0xE2, 0x2A, 0x01, 0x25, 0xDA, 0x11, 0xD1, 0x90, 0x34, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xBE }, asf_read_unknown, 1 }, + { "Mutex Unknown", { 0xD6, 0xE2, 0x2A, 0x02, 0x25, 0xDA, 0x11, 0xD1, 0x90, 0x34, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xBE }, asf_read_unknown, 1 }, + { "Bandwith Sharing Exclusive", { 0xAF, 0x60, 0x60, 0xAA, 0x51, 0x97, 0x11, 0xD2, 0xB6, 0xAF, 0x00, 0xC0, 0x4F, 0xD9, 0x08, 0xE9 }, asf_read_unknown, 1 }, + { "Bandwith Sharing Partial", { 0xAF, 0x60, 0x60, 0xAB, 0x51, 0x97, 0x11, 0xD2, 0xB6, 0xAF, 0x00, 0xC0, 0x4F, 0xD9, 0x08, 0xE9 }, asf_read_unknown, 1 }, + { "Payload Extension System Timecode", { 0x39, 0x95, 0x95, 0xEC, 0x86, 0x67, 0x4E, 0x2D, 0x8F, 0xDB, 0x98, 0x81, 0x4C, 0xE7, 0x6C, 0x1E }, asf_read_unknown, 1 }, + { "Payload Extension System File Name", { 0xE1, 0x65, 0xEC, 0x0E, 0x19, 0xED, 0x45, 0xD7, 0xB4, 0xA7, 0x25, 0xCB, 0xD1, 0xE2, 0x8E, 0x9B }, asf_read_unknown, 1 }, + { "Payload Extension System Content Type", { 0xD5, 0x90, 0xDC, 0x20, 0x07, 0xBC, 0x43, 0x6C, 0x9C, 0xF7, 0xF3, 0xBB, 0xFB, 0xF1, 0xA4, 0xDC }, asf_read_unknown, 1 }, + { "Payload Extension System Pixel Aspect Ratio", { 0x1, 0x1E, 0xE5, 0x54, 0xF9, 0xEA, 0x4B, 0xC8, 0x82, 0x1A, 0x37, 0x6B, 0x74, 0xE4, 0xC4, 0xB8 }, asf_read_unknown, 1 }, + { "Payload Extension System Sample Duration", { 0xC6, 0xBD, 0x94, 0x50, 0x86, 0x7F, 0x49, 0x07, 0x83, 0xA3, 0xC7, 0x79, 0x21, 0xB7, 0x33, 0xAD }, asf_read_unknown, 1 }, + { "Payload Extension System Encryption Sample ID", { 0x66, 0x98, 0xB8, 0x4E, 0x0A, 0xFA, 0x43, 0x30, 0xAE, 0xB2, 0x1C, 0x0A, 0x98, 0xD7, 0xA4, 0x4D }, asf_read_unknown, 1 }, + { "Payload Extension System Degradable JPEG", { 0x00, 0xE1, 0xAF, 0x06, 0x7B, 0xEC, 0x11, 0xD1, 0xA5, 0x82, 0x00, 0xC0, 0x4F, 0xC2, 0x9C, 0xFB }, asf_read_unknown, 1 }, +}; + +#define READ_LEN(flag, name, len) \ + do { \ + if ((flag) == name ## IS_BYTE) \ + len = avio_r8(pb); \ + else if ((flag) == name ## IS_WORD) \ + len = avio_rl16(pb); \ + else if ((flag) == name ## IS_DWORD) \ + len = avio_rl32(pb); \ + else \ + len = 0; \ + } while(0) + +static int asf_read_subpayload(AVFormatContext *s, AVPacket *pkt, int is_header) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + uint8_t sub_len; + int ret, i; + + if (is_header) { + asf->dts_delta = avio_r8(pb); + if (asf->nb_mult_left) { + asf->mult_sub_len = avio_rl16(pb); // total + } + asf->sub_header_offset = avio_tell(pb); + asf->nb_sub = 0; + asf->sub_left = 1; + } + sub_len = avio_r8(pb); + if ((ret = av_get_packet(pb, pkt, sub_len)) < 0) // each subpayload is entire frame + return ret; + for (i = 0; i < asf->nb_streams; i++) { + if (asf->stream_index == asf->asf_st[i]->stream_index) { + pkt->stream_index = asf->asf_st[i]->index; + break; + } + } + asf->return_subpayload = 1; + if (!sub_len) + asf->return_subpayload = 0; + + if (sub_len) + asf->nb_sub++; + pkt->dts = asf->sub_dts + (asf->nb_sub - 1) * asf->dts_delta - asf->preroll; + if (asf->nb_mult_left && (avio_tell(pb) >= + (asf->sub_header_offset + asf->mult_sub_len))) { + asf->sub_left = 0; + asf->nb_mult_left--; + } + if (avio_tell(pb) >= asf->packet_offset + asf->packet_size - asf->pad_len) { + asf->sub_left = 0; + if (!asf->nb_mult_left) { + avio_skip(pb, asf->pad_len); + if (avio_tell(pb) != asf->packet_offset + asf->packet_size) { + if (!asf->packet_size) + return AVERROR_INVALIDDATA; + av_log(s, AV_LOG_WARNING, + "Position %"PRId64" wrong, should be %"PRId64"\n", + avio_tell(pb), asf->packet_offset + asf->packet_size); + avio_seek(pb, asf->packet_offset + asf->packet_size, SEEK_SET); + } + } + } + + return 0; +} + +static void reset_packet(ASFPacket *asf_pkt) +{ + asf_pkt->size_left = 0; + asf_pkt->data_size = 0; + asf_pkt->duration = 0; + asf_pkt->flags = 0; + asf_pkt->dts = 0; + asf_pkt->duration = 0; + av_free_packet(&asf_pkt->avpkt); + av_init_packet(&asf_pkt->avpkt); +} + +static int asf_read_replicated_data(AVFormatContext *s, ASFPacket *asf_pkt) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + int ret; + + if (!asf_pkt->data_size) { + asf_pkt->data_size = asf_pkt->size_left = avio_rl32(pb); // read media object size + if (asf_pkt->data_size <= 0) + return AVERROR_EOF; + if ((ret = av_new_packet(&asf_pkt->avpkt, asf_pkt->data_size)) < 0) + return ret; + } else + avio_skip(pb, 4); // reading of media object size is already done + asf_pkt->dts = avio_rl32(pb); // read presentation time + if (asf->rep_data_len && (asf->rep_data_len >= 8)) + avio_skip(pb, asf->rep_data_len - 8); // skip replicated data + + return 0; +} + +static int asf_read_multiple_payload(AVFormatContext *s, AVPacket *pkt, + ASFPacket *asf_pkt) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + uint16_t pay_len; + unsigned char *p; + int ret; + int skip = 0; + + // if replicated lenght is 1, subpayloads are present + if (asf->rep_data_len == 1) { + asf->sub_left = 1; + asf->state = READ_MULTI_SUB; + pkt->flags = asf_pkt->flags; + if ((ret = asf_read_subpayload(s, pkt, 1)) < 0) + return ret; + } else { + if (asf->rep_data_len) + if ((ret = asf_read_replicated_data(s, asf_pkt)) < 0) + return ret; + pay_len = avio_rl16(pb); // payload length should be WORD + if (pay_len > asf->packet_size) { + av_log(s, AV_LOG_ERROR, + "Error: invalid data packet size, pay_len %"PRIu16", " + "asf->packet_size %"PRIu32", offset %"PRId64".\n", + pay_len, asf->packet_size, avio_tell(pb)); + return AVERROR_INVALIDDATA; + } + p = asf_pkt->avpkt.data + asf_pkt->data_size - asf_pkt->size_left; + if (pay_len > asf_pkt->size_left) { + av_log(s, AV_LOG_ERROR, + "Error: invalid buffer size, pay_len %d, data size left %d.\n", + pay_len, asf_pkt->size_left); + skip = pay_len - asf_pkt->size_left; + pay_len = asf_pkt->size_left; + } + if ((ret = avio_read(pb, p, pay_len)) < 0) + return ret; + if (s->key && s->keylen == 20) + ff_asfcrypt_dec(s->key, p, ret); + avio_skip(pb, skip); + asf_pkt->size_left -= pay_len; + asf->nb_mult_left--; + } + + return 0; +} + +static int asf_read_single_payload(AVFormatContext *s, AVPacket *pkt, + ASFPacket *asf_pkt) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + int64_t offset; + uint64_t size; + unsigned char *p; + int ret; + + if (!asf_pkt->data_size) { + asf_pkt->data_size = asf_pkt->size_left = avio_rl32(pb); // read media object size + if (asf_pkt->data_size <= 0) + return AVERROR_EOF; + if ((ret = av_new_packet(&asf_pkt->avpkt, asf_pkt->data_size)) < 0) + return ret; + } else + avio_skip(pb, 4); // skip media object size + asf_pkt->dts = avio_rl32(pb); // read presentation time + if (asf->rep_data_len >= 8) + avio_skip(pb, asf->rep_data_len - 8); // skip replicated data + offset = avio_tell(pb); + + // size of the payload - size of the packet without header and padding + if (asf->packet_size_internal) + size = asf->packet_size_internal - offset + asf->packet_offset - asf->pad_len; + else + size = asf->packet_size - offset + asf->packet_offset - asf->pad_len; + if (size > asf->packet_size) { + av_log(s, AV_LOG_ERROR, + "Error: invalid data packet size, offset %"PRId64".\n", + avio_tell(pb)); + return AVERROR_INVALIDDATA; + } + p = asf_pkt->avpkt.data + asf_pkt->data_size - asf_pkt->size_left; + if (size > asf_pkt->size_left) + return AVERROR_INVALIDDATA; + if (asf_pkt->size_left > size) + asf_pkt->size_left -= size; + else + asf_pkt->size_left = 0; + if ((ret = avio_read(pb, p, size)) < 0) + return ret; + if (s->key && s->keylen == 20) + ff_asfcrypt_dec(s->key, p, ret); + if (asf->packet_size_internal) + avio_skip(pb, asf->packet_size - asf->packet_size_internal); + avio_skip(pb, asf->pad_len); // skip padding + + return 0; +} + +static int asf_read_payload(AVFormatContext *s, AVPacket *pkt) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + int ret, i; + ASFPacket *asf_pkt = NULL; + + if (!asf->sub_left) { + uint32_t off_len, media_len; + uint8_t stream_num; + + stream_num = avio_r8(pb); + asf->stream_index = stream_num & ASF_STREAM_NUM; + for (i = 0; i < asf->nb_streams; i++) { + if (asf->stream_index == asf->asf_st[i]->stream_index) { + asf_pkt = &asf->asf_st[i]->pkt; + asf_pkt->stream_index = asf->asf_st[i]->index; + break; + } + } + if (!asf_pkt) + return AVERROR_INVALIDDATA; + if (stream_num >> 7) + asf_pkt->flags |= AV_PKT_FLAG_KEY; + READ_LEN(asf->prop_flags & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE, + ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_, media_len); + READ_LEN(asf->prop_flags & ASF_PL_MASK_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_SIZE, + ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_, off_len); + READ_LEN(asf->prop_flags & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE, + ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_, asf->rep_data_len); + if (asf_pkt->size_left && (asf_pkt->frame_num != media_len)) { + av_log(s, AV_LOG_WARNING, "Unfinished frame will be ignored\n"); + reset_packet(asf_pkt); + } + asf_pkt->frame_num = media_len; + asf->sub_dts = off_len; + if (asf->nb_mult_left) { + if ((ret = asf_read_multiple_payload(s, pkt, asf_pkt)) < 0) + return ret; + } else if (asf->rep_data_len == 1) { + asf->sub_left = 1; + asf->state = READ_SINGLE; + pkt->flags = asf_pkt->flags; + if ((ret = asf_read_subpayload(s, pkt, 1)) < 0) + return ret; + } else { + if ((ret = asf_read_single_payload(s, pkt, asf_pkt)) < 0) + return ret; + } + } else { + for (i = 0; i <= asf->nb_streams; i++) { + if (asf->stream_index == asf->asf_st[i]->stream_index) { + asf_pkt = &asf->asf_st[i]->pkt; + break; + } + } + if (!asf_pkt) + return AVERROR_INVALIDDATA; + pkt->flags = asf_pkt->flags; + pkt->dts = asf_pkt->dts; + pkt->stream_index = asf->asf_st[i]->index; + if ((ret = asf_read_subpayload(s, pkt, 0)) < 0) // read subpayload without its header + return ret; + } + + return 0; +} + +static int asf_read_packet_header(AVFormatContext *s) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + uint64_t size; + uint32_t av_unused seq; + unsigned char error_flags, len_flags, pay_flags; + + asf->packet_offset = avio_tell(pb); + error_flags = avio_r8(pb); // read Error Correction Flags + if (error_flags & ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT) { + if (!(error_flags & ASF_ERROR_CORRECTION_LENGTH_TYPE)) { + size = error_flags & ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; + avio_skip(pb, size); + } + len_flags = avio_r8(pb); + } else + len_flags = error_flags; + asf->prop_flags = avio_r8(pb); + READ_LEN(len_flags & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE, + ASF_PPI_FLAG_PACKET_LENGTH_FIELD_, asf->packet_size_internal); + READ_LEN(len_flags & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE, + ASF_PPI_FLAG_SEQUENCE_FIELD_, seq); + READ_LEN(len_flags & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE, + ASF_PPI_FLAG_PADDING_LENGTH_FIELD_, asf->pad_len ); + asf->send_time = avio_rl32(pb); // send time + avio_skip(pb, 2); // skip duration + if (len_flags & ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT) { // Multiple Payloads present + pay_flags = avio_r8(pb); + asf->nb_mult_left = (pay_flags & ASF_NUM_OF_PAYLOADS); + } + + return 0; +} + +static int asf_deinterleave(AVFormatContext *s, ASFPacket *asf_pkt, int st_num) +{ + ASFContext *asf = s->priv_data; + ASFStream *asf_st = asf->asf_st[st_num]; + unsigned char *p = asf_pkt->avpkt.data; + uint16_t pkt_len = asf->asf_st[st_num]->virtual_pkt_len; + uint16_t chunk_len = asf->asf_st[st_num]->virtual_chunk_len; + int nchunks = pkt_len / chunk_len; + AVPacket pkt; + int pos = 0, j, l, ret; + + + if ((ret = av_new_packet(&pkt, asf_pkt->data_size)) < 0) + return ret; + + while (asf_pkt->data_size >= asf_st->span * pkt_len + pos) { + if (pos >= asf_pkt->data_size) { + break; + } + for (l = 0; l < pkt_len; l++) { + if (pos >= asf_pkt->data_size) { + break; + } + for (j = 0; j < asf_st->span; j++) { + if ((pos + chunk_len) >= asf_pkt->data_size) + break; + memcpy(pkt.data + pos, + p + (j * nchunks + l) * chunk_len, + chunk_len); + pos += chunk_len; + } + } + p += asf_st->span * pkt_len; + if (p > asf_pkt->avpkt.data + asf_pkt->data_size) + break; + } + av_free_packet(&asf_pkt->avpkt); + asf_pkt->avpkt = pkt; + + return 0; +} + +static int asf_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + int ret, i; + + if ((avio_tell(pb) >= asf->data_offset + asf->data_size) && + !(asf->b_flags & ASF_FLAG_BROADCAST)) + return AVERROR_EOF; + while (!pb->eof_reached) { + if (asf->state == PARSE_PACKET_HEADER) { + asf_read_packet_header(s); + if (!asf->nb_mult_left) + asf->state = READ_SINGLE; + else + asf->state = READ_MULTI; + } + if ((ret = asf_read_payload(s, pkt)) < 0) + return ret; + switch (asf->state) { + case READ_SINGLE: + if (!asf->sub_left) + asf->state = PARSE_PACKET_HEADER; + break; + case READ_MULTI_SUB: + if (!asf->sub_left && !asf->nb_mult_left) { + asf->state = PARSE_PACKET_HEADER; + if (!asf->return_subpayload) + avio_skip(pb, asf->pad_len); // skip padding + if (asf->packet_offset + asf->packet_size > avio_tell(pb)) + avio_seek(pb, asf->packet_offset + asf->packet_size, SEEK_SET); + } else if (!asf->sub_left) + asf->state = READ_MULTI; + break; + case READ_MULTI: + if (!asf->nb_mult_left) { + asf->state = PARSE_PACKET_HEADER; + if (!asf->return_subpayload) { + avio_skip(pb, asf->pad_len); // skip padding + } + if (asf->packet_offset + asf->packet_size > avio_tell(pb)) + avio_seek(pb, asf->packet_offset + asf->packet_size, SEEK_SET); + } + break; + } + if (asf->return_subpayload) { + asf->return_subpayload = 0; + return 0; + } + for (i = 0; i < s->nb_streams; i++) { + ASFPacket *asf_pkt = &asf->asf_st[i]->pkt; + if (asf_pkt && !asf_pkt->size_left && asf_pkt->data_size) { + if (asf->asf_st[i]->span > 1 && + asf->asf_st[i]->type == AVMEDIA_TYPE_AUDIO) + if ((ret = asf_deinterleave(s, asf_pkt, i)) < 0) + return ret; + av_packet_move_ref(pkt, &asf_pkt->avpkt); + pkt->stream_index = asf->asf_st[i]->index; + pkt->flags = asf_pkt->flags; + pkt->dts = asf_pkt->dts - asf->preroll; + asf_pkt->data_size = 0; + asf_pkt->frame_num = 0; + return 0; + } + } + } + + if (pb->eof_reached) + return AVERROR_EOF; + + return 0; +} + +static int asf_read_close(AVFormatContext *s) +{ + ASFContext *asf = s->priv_data; + int i; + + for (i = 0; i < ASF_MAX_STREAMS; i++) { + av_dict_free(&asf->asf_sd[i].asf_met); + if (i < asf->nb_streams) { + av_free_packet(&asf->asf_st[i]->pkt.avpkt); + av_freep(&asf->asf_st[i]); + } + } + + asf->nb_streams = 0; + return 0; +} + +static void reset_packet_state(AVFormatContext *s) +{ + ASFContext *asf = s->priv_data; + int i; + + asf->state = PARSE_PACKET_HEADER; + asf->offset = 0; + asf->return_subpayload = 0; + asf->sub_left = 0; + asf->sub_header_offset = 0; + asf->packet_offset = asf->first_packet_offset; + asf->pad_len = 0; + asf->rep_data_len = 0; + asf->dts_delta = 0; + asf->mult_sub_len = 0; + asf->nb_mult_left = 0; + asf->nb_sub = 0; + asf->prop_flags = 0; + asf->sub_dts = 0; + for (i = 0; i < asf->nb_streams; i++) { + ASFPacket *pkt = &asf->asf_st[i]->pkt; + pkt->size_left = 0; + pkt->data_size = 0; + pkt->duration = 0; + pkt->flags = 0; + pkt->dts = 0; + pkt->duration = 0; + av_free_packet(&pkt->avpkt); + av_init_packet(&pkt->avpkt); + } +} + +/* + * Find a timestamp for the requested position within the payload + * where the pos (position) is the offset inside the Data Object. + * When position is not on the packet boundary, asf_read_timestamp tries + * to find the closest packet offset after this position. If this packet + * is a key frame, this packet timestamp is read and an index entry is created + * for the packet. If this packet belongs to the requested stream, + * asf_read_timestamp upgrades pos to the packet beginning offset and + * returns this packet's dts. So returned dts is the dts of the first key frame with + * matching stream number after given position. + */ +static int64_t asf_read_timestamp(AVFormatContext *s, int stream_index, + int64_t *pos, int64_t pos_limit) +{ + ASFContext *asf = s->priv_data; + int64_t pkt_pos = *pos, pkt_offset, dts = AV_NOPTS_VALUE, data_end; + AVPacket pkt; + int n; + + data_end = asf->data_offset + asf->data_size; + + n = (pkt_pos - asf->first_packet_offset + asf->packet_size - 1) / + asf->packet_size; + n = av_clip(n, 0, ((data_end - asf->first_packet_offset) / asf->packet_size - 1)); + pkt_pos = asf->first_packet_offset + n * asf->packet_size; + + avio_seek(s->pb, pkt_pos, SEEK_SET); + pkt_offset = pkt_pos; + + reset_packet_state(s); + while (avio_tell(s->pb) < data_end) { + + int i, ret, st_found; + + av_init_packet(&pkt); + pkt_offset = avio_tell(s->pb); + if ((ret = asf_read_packet(s, &pkt)) < 0) { + dts = AV_NOPTS_VALUE; + return ret; + } + // ASFPacket may contain fragments of packets belonging to different streams, + // pkt_offset is the offset of the first fragment within it. + if ((pkt_offset >= (pkt_pos + asf->packet_size))) + pkt_pos += asf->packet_size; + for (i = 0; i < asf->nb_streams; i++) { + ASFStream *st = asf->asf_st[i]; + + st_found = 0; + if (pkt.flags & AV_PKT_FLAG_KEY) { + dts = pkt.dts; + if (dts) { + av_add_index_entry(s->streams[pkt.stream_index], pkt_pos, + dts, pkt.size, 0, AVINDEX_KEYFRAME); + if (stream_index == st->index) { + st_found = 1; + break; + } + } + } + } + if (st_found) + break; + av_free_packet(&pkt); + } + *pos = pkt_pos; + + av_free_packet(&pkt); + return dts; +} + +static int asf_read_seek(AVFormatContext *s, int stream_index, + int64_t timestamp, int flags) +{ + ASFContext *asf = s->priv_data; + int idx, ret; + + if (s->streams[stream_index]->nb_index_entries && asf->is_simple_index) { + idx = av_index_search_timestamp(s->streams[stream_index], timestamp, flags); + if (idx < 0 || idx >= s->streams[stream_index]->nb_index_entries) + return AVERROR_INVALIDDATA; + avio_seek(s->pb, s->streams[stream_index]->index_entries[idx].pos, SEEK_SET); + } else { + if ((ret = ff_seek_frame_binary(s, stream_index, timestamp, flags)) < 0) + return ret; + } + + reset_packet_state(s); + + return 0; +} + +static const GUIDParseTable *find_guid(ff_asf_guid guid) +{ + int j, ret; + const GUIDParseTable *g; + + swap_guid(guid); + g = gdef; + for (j = 0; j < FF_ARRAY_ELEMS(gdef); j++) { + if (!(ret = memcmp(guid, g->guid, sizeof(g->guid)))) + return g; + g++; + } + + return NULL; +} + +static int detect_unknown_subobject(AVFormatContext *s, int64_t offset, int64_t size) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + const GUIDParseTable *g = NULL; + ff_asf_guid guid; + int ret; + + while (avio_tell(pb) <= offset + size) { + if (avio_tell(pb) == asf->offset) + break; + asf->offset = avio_tell(pb); + if ((ret = ff_get_guid(pb, &guid)) < 0) + return ret; + g = find_guid(guid); + if (g) { + if ((ret = g->read_object(s, g)) < 0) + return ret; + } else { + GUIDParseTable g2; + + g2.name = "Unknown"; + g2.is_subobject = 1; + asf_read_unknown(s, &g2); + } + } + + return 0; +} + +static int asf_read_header(AVFormatContext *s) +{ + ASFContext *asf = s->priv_data; + AVIOContext *pb = s->pb; + const GUIDParseTable *g = NULL; + ff_asf_guid guid; + int i, ret; + uint64_t size; + + asf->preroll = 0; + asf->is_simple_index = 0; + ff_get_guid(pb, &guid); + if (ff_guidcmp(&guid, &ff_asf_header)) + return AVERROR_INVALIDDATA; + avio_skip(pb, 8); // skip header object size + avio_skip(pb, 6); // skip number of header objects and 2 reserved bytes + asf->data_reached = 0; + + /* 1 is here instead of pb->eof_reached because (when not streaming), Data are skipped + * for the first time, + * Index object is processed and got eof and then seeking back to the Data is performed. + */ + while (1) { + // for the cases when object size is invalid + if (avio_tell(pb) == asf->offset) + break; + asf->offset = avio_tell(pb); + if ((ret = ff_get_guid(pb, &guid)) < 0) { + if (ret == AVERROR_EOF && asf->data_reached) + break; + else + goto failed; + } + g = find_guid(guid); + if (g) { + asf->unknown_offset = asf->offset; + asf->is_header = 1; + if ((ret = g->read_object(s, g)) < 0) + goto failed; + } else { + size = avio_rl64(pb); + align_position(pb, asf->offset, size); + } + if (asf->data_reached && (!pb->seekable || (asf->b_flags & ASF_FLAG_BROADCAST))) + break; + } + + if (!asf->data_reached) { + av_log(s, AV_LOG_ERROR, "Data Object was not found.\n"); + ret = AVERROR_INVALIDDATA; + goto failed; + } + if (pb->seekable) + avio_seek(pb, asf->first_packet_offset, SEEK_SET); + + for (i = 0; i < asf->nb_streams; i++) { + const char *rfc1766 = asf->asf_sd[asf->asf_st[i]->lang_idx].langs; + AVStream *st = s->streams[asf->asf_st[i]->index]; + set_language(s, rfc1766, &st->metadata); + } + + for (i = 0; i < ASF_MAX_STREAMS; i++) { + AVStream *st = NULL; + + st = find_stream(s, i); + if (st) { + av_dict_copy(&st->metadata, asf->asf_sd[i].asf_met, AV_DICT_IGNORE_SUFFIX); + if (asf->asf_sd[i].aspect_ratio.num > 0 && asf->asf_sd[i].aspect_ratio.den > 0) { + st->sample_aspect_ratio.num = asf->asf_sd[i].aspect_ratio.num; + st->sample_aspect_ratio.den = asf->asf_sd[i].aspect_ratio.den; + } + } + } + + return 0; + +failed: + asf_read_close(s); + return ret; +} + +AVInputFormat ff_asf_o_demuxer = { + .name = "asf_o", + .long_name = NULL_IF_CONFIG_SMALL("ASF (Advanced / Active Streaming Format)"), + .priv_data_size = sizeof(ASFContext), + .read_probe = asf_probe, + .read_header = asf_read_header, + .read_packet = asf_read_packet, + .read_close = asf_read_close, + .read_timestamp = asf_read_timestamp, + .read_seek = asf_read_seek, + .flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH, +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/asfenc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/asfenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/asfenc.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/asfenc.c 2015-06-28 17:20:02.000000000 +0000 @@ -183,6 +183,38 @@ #define DATA_HEADER_SIZE 50 +typedef struct ASFPayload { + uint8_t type; + uint16_t size; +} ASFPayload; + +typedef struct ASFStream { + int num; + unsigned char seq; + /* use for reading */ + AVPacket pkt; + int frag_offset; + int packet_obj_size; + int timestamp; + int64_t duration; + int skip_to_key; + int pkt_clean; + + int ds_span; /* descrambling */ + int ds_packet_size; + int ds_chunk_size; + + int64_t packet_pos; + + uint16_t stream_language_index; + + int palette_changed; + uint32_t palette[256]; + + int payload_ext_ct; + ASFPayload payload[8]; +} ASFStream; + typedef struct ASFContext { uint32_t seqno; int is_streamed; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/asf.h ffmpeg-2.7.2~trusty~ppa1/libavformat/asf.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/asf.h 2015-06-18 18:55:02.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/asf.h 2015-07-02 17:20:03.000000000 +0000 @@ -28,37 +28,15 @@ #define PACKET_SIZE 3200 -typedef struct ASFPayload { - uint8_t type; - uint16_t size; -} ASFPayload; - -typedef struct ASFStream { - int num; - unsigned char seq; - /* use for reading */ - AVPacket pkt; - int frag_offset; - int packet_obj_size; - int timestamp; - int64_t duration; - int skip_to_key; - int pkt_clean; - - int ds_span; /* descrambling */ - int ds_packet_size; - int ds_chunk_size; - - int64_t packet_pos; - - uint16_t stream_language_index; - - int palette_changed; - uint32_t palette[256]; - - int payload_ext_ct; - ASFPayload payload[8]; -} ASFStream; +typedef enum ASFDataType { + ASF_UNICODE = 0, + ASF_BYTE_ARRAY = 1, + ASF_BOOL = 2, + ASF_DWORD = 3, + ASF_QWORD = 4, + ASF_WORD = 5, + ASF_GUID = 6, +}ASFDataType; typedef struct ASFMainHeader { ff_asf_guid guid; ///< generated by client computer diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/async.c ffmpeg-2.7.2~trusty~ppa1/libavformat/async.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/async.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/async.c 2015-07-25 17:20:02.000000000 +0000 @@ -0,0 +1,559 @@ +/* + * Input async protocol. + * Copyright (c) 2015 Zhang Rui + * + * 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 + * + * Based on libavformat/cache.c by Michael Niedermayer + */ + + /** + * @TODO + * support timeout + * support backward short seek + * support work with concatdec, hls + */ + +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/error.h" +#include "libavutil/fifo.h" +#include "libavutil/log.h" +#include "libavutil/opt.h" +#include "url.h" +#include +#include + +#if HAVE_UNISTD_H +#include +#endif + +#define BUFFER_CAPACITY (4 * 1024 * 1024) +#define SHORT_SEEK_THRESHOLD (256 * 1024) + +typedef struct Context { + AVClass *class; + URLContext *inner; + + int seek_request; + size_t seek_pos; + int seek_whence; + int seek_completed; + int64_t seek_ret; + + int io_error; + int io_eof_reached; + + size_t logical_pos; + size_t logical_size; + AVFifoBuffer *fifo; + + pthread_cond_t cond_wakeup_main; + pthread_cond_t cond_wakeup_background; + pthread_mutex_t mutex; + pthread_t async_buffer_thread; + + int abort_request; + AVIOInterruptCB interrupt_callback; +} Context; + +static int async_check_interrupt(void *arg) +{ + URLContext *h = arg; + Context *c = h->priv_data; + + if (c->abort_request) + return 1; + + if (ff_check_interrupt(&c->interrupt_callback)) + c->abort_request = 1; + + return c->abort_request; +} + +static void *async_buffer_task(void *arg) +{ + URLContext *h = arg; + Context *c = h->priv_data; + AVFifoBuffer *fifo = c->fifo; + int ret = 0; + + while (1) { + int fifo_space, to_copy; + + pthread_mutex_lock(&c->mutex); + if (async_check_interrupt(h)) { + c->io_eof_reached = 1; + c->io_error = AVERROR_EXIT; + pthread_cond_signal(&c->cond_wakeup_main); + pthread_mutex_unlock(&c->mutex); + break; + } + + if (c->seek_request) { + ret = ffurl_seek(c->inner, c->seek_pos, c->seek_whence); + if (ret < 0) { + c->io_eof_reached = 1; + c->io_error = ret; + } else { + c->io_eof_reached = 0; + c->io_error = 0; + } + + c->seek_completed = 1; + c->seek_ret = ret; + c->seek_request = 0; + + av_fifo_reset(fifo); + + pthread_cond_signal(&c->cond_wakeup_main); + pthread_mutex_unlock(&c->mutex); + continue; + } + + fifo_space = av_fifo_space(fifo); + if (c->io_eof_reached || fifo_space <= 0) { + pthread_cond_signal(&c->cond_wakeup_main); + pthread_cond_wait(&c->cond_wakeup_background, &c->mutex); + pthread_mutex_unlock(&c->mutex); + continue; + } + pthread_mutex_unlock(&c->mutex); + + to_copy = FFMIN(4096, fifo_space); + ret = av_fifo_generic_write(fifo, c->inner, to_copy, (void *)ffurl_read); + + pthread_mutex_lock(&c->mutex); + if (ret <= 0) { + c->io_eof_reached = 1; + if (ret < 0) { + c->io_error = ret; + } + } + + pthread_cond_signal(&c->cond_wakeup_main); + pthread_mutex_unlock(&c->mutex); + } + + return NULL; +} + +static int async_open(URLContext *h, const char *arg, int flags, AVDictionary **options) +{ + Context *c = h->priv_data; + int ret; + AVIOInterruptCB interrupt_callback = {.callback = async_check_interrupt, .opaque = h}; + + av_strstart(arg, "async:", &arg); + + c->fifo = av_fifo_alloc(BUFFER_CAPACITY); + if (!c->fifo) { + ret = AVERROR(ENOMEM); + goto fifo_fail; + } + + /* wrap interrupt callback */ + c->interrupt_callback = h->interrupt_callback; + ret = ffurl_open(&c->inner, arg, flags, &interrupt_callback, options); + if (ret != 0) { + av_log(h, AV_LOG_ERROR, "ffurl_open failed : %s, %s\n", strerror(ret), arg); + goto url_fail; + } + + c->logical_size = ffurl_size(c->inner); + h->is_streamed = c->inner->is_streamed; + + ret = pthread_mutex_init(&c->mutex, NULL); + if (ret != 0) { + av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", strerror(ret)); + goto mutex_fail; + } + + ret = pthread_cond_init(&c->cond_wakeup_main, NULL); + if (ret != 0) { + av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", strerror(ret)); + goto cond_wakeup_main_fail; + } + + ret = pthread_cond_init(&c->cond_wakeup_background, NULL); + if (ret != 0) { + av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", strerror(ret)); + goto cond_wakeup_background_fail; + } + + ret = pthread_create(&c->async_buffer_thread, NULL, async_buffer_task, h); + if (ret) { + av_log(h, AV_LOG_ERROR, "pthread_create failed : %s\n", strerror(ret)); + goto thread_fail; + } + + return 0; + +thread_fail: + pthread_cond_destroy(&c->cond_wakeup_background); +cond_wakeup_background_fail: + pthread_cond_destroy(&c->cond_wakeup_main); +cond_wakeup_main_fail: + pthread_mutex_destroy(&c->mutex); +mutex_fail: + ffurl_close(c->inner); +url_fail: + av_fifo_freep(&c->fifo); +fifo_fail: + return ret; +} + +static int async_close(URLContext *h) +{ + Context *c = h->priv_data; + int ret; + + pthread_mutex_lock(&c->mutex); + c->abort_request = 1; + pthread_cond_signal(&c->cond_wakeup_background); + pthread_mutex_unlock(&c->mutex); + + ret = pthread_join(c->async_buffer_thread, NULL); + if (ret != 0) + av_log(h, AV_LOG_ERROR, "pthread_join(): %s\n", strerror(ret)); + + pthread_cond_destroy(&c->cond_wakeup_background); + pthread_cond_destroy(&c->cond_wakeup_main); + pthread_mutex_destroy(&c->mutex); + ffurl_close(c->inner); + av_fifo_freep(&c->fifo); + + return 0; +} + +static int async_read_internal(URLContext *h, void *dest, int size, int read_complete, + void (*func)(void*, void*, int)) +{ + Context *c = h->priv_data; + AVFifoBuffer *fifo = c->fifo; + int to_read = size; + int ret = 0; + + pthread_mutex_lock(&c->mutex); + + while (to_read > 0) { + int fifo_size, to_copy; + if (async_check_interrupt(h)) { + ret = AVERROR_EXIT; + break; + } + fifo_size = av_fifo_size(fifo); + to_copy = FFMIN(to_read, fifo_size); + if (to_copy > 0) { + av_fifo_generic_read(fifo, dest, to_copy, func); + if (!func) + dest = (uint8_t *)dest + to_copy; + c->logical_pos += to_copy; + to_read -= to_copy; + ret = size - to_read; + + if (to_read <= 0 || !read_complete) + break; + } else if (c->io_eof_reached) { + if (ret <= 0) + ret = AVERROR_EOF; + break; + } + pthread_cond_signal(&c->cond_wakeup_background); + pthread_cond_wait(&c->cond_wakeup_main, &c->mutex); + } + + pthread_cond_signal(&c->cond_wakeup_background); + pthread_mutex_unlock(&c->mutex); + + return ret; +} + +static int async_read(URLContext *h, unsigned char *buf, int size) +{ + return async_read_internal(h, buf, size, 0, NULL); +} + +static void fifo_do_not_copy_func(void* dest, void* src, int size) { + // do not copy +} + +static int64_t async_seek(URLContext *h, int64_t pos, int whence) +{ + Context *c = h->priv_data; + AVFifoBuffer *fifo = c->fifo; + int64_t ret; + int64_t new_logical_pos; + int fifo_size; + + if (whence == AVSEEK_SIZE) { + av_log(h, AV_LOG_TRACE, "async_seek: AVSEEK_SIZE: %"PRId64"\n", (int64_t)c->logical_size); + return c->logical_size; + } else if (whence == SEEK_CUR) { + av_log(h, AV_LOG_TRACE, "async_seek: %"PRId64"\n", pos); + new_logical_pos = pos + c->logical_pos; + } else if (whence == SEEK_SET){ + av_log(h, AV_LOG_TRACE, "async_seek: %"PRId64"\n", pos); + new_logical_pos = pos; + } else { + return AVERROR(EINVAL); + } + if (new_logical_pos < 0) + return AVERROR(EINVAL); + + fifo_size = av_fifo_size(fifo); + if (new_logical_pos == c->logical_pos) { + /* current position */ + return c->logical_pos; + } else if ((new_logical_pos > c->logical_pos) && + (new_logical_pos < (c->logical_pos + fifo_size + SHORT_SEEK_THRESHOLD))) { + /* fast seek */ + av_log(h, AV_LOG_TRACE, "async_seek: fask_seek %"PRId64" from %d dist:%d/%d\n", + new_logical_pos, (int)c->logical_pos, + (int)(new_logical_pos - c->logical_pos), fifo_size); + async_read_internal(h, NULL, new_logical_pos - c->logical_pos, 1, fifo_do_not_copy_func); + return c->logical_pos; + } else if (c->logical_size <= 0) { + /* can not seek */ + return AVERROR(EINVAL); + } else if (new_logical_pos > c->logical_size) { + /* beyond end */ + return AVERROR(EINVAL); + } + + pthread_mutex_lock(&c->mutex); + + c->seek_request = 1; + c->seek_pos = new_logical_pos; + c->seek_whence = SEEK_SET; + c->seek_completed = 0; + c->seek_ret = 0; + + while (1) { + if (async_check_interrupt(h)) { + ret = AVERROR_EXIT; + break; + } + if (c->seek_completed) { + if (c->seek_ret >= 0) + c->logical_pos = c->seek_ret; + ret = c->seek_ret; + break; + } + pthread_cond_signal(&c->cond_wakeup_background); + pthread_cond_wait(&c->cond_wakeup_main, &c->mutex); + } + + pthread_mutex_unlock(&c->mutex); + + return ret; +} + +#define OFFSET(x) offsetof(Context, x) +#define D AV_OPT_FLAG_DECODING_PARAM + +static const AVOption options[] = { + {NULL}, +}; + +static const AVClass async_context_class = { + .class_name = "Async", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +URLProtocol ff_async_protocol = { + .name = "async", + .url_open2 = async_open, + .url_read = async_read, + .url_seek = async_seek, + .url_close = async_close, + .priv_data_size = sizeof(Context), + .priv_data_class = &async_context_class, +}; + +#ifdef TEST + +#define TEST_SEEK_POS (1536) +#define TEST_STREAM_SIZE (2048) + +typedef struct TestContext { + AVClass *class; + size_t logical_pos; + size_t logical_size; +} TestContext; + +static int async_test_open(URLContext *h, const char *arg, int flags, AVDictionary **options) +{ + TestContext *c = h->priv_data; + c->logical_pos = 0; + c->logical_size = TEST_STREAM_SIZE; + return 0; +} + +static int async_test_close(URLContext *h) +{ + return 0; +} + +static int async_test_read(URLContext *h, unsigned char *buf, int size) +{ + TestContext *c = h->priv_data; + int i; + int read_len = 0; + + if (c->logical_pos >= c->logical_size) + return AVERROR_EOF; + + for (i = 0; i < size; ++i) { + buf[i] = c->logical_pos & 0xFF; + + c->logical_pos++; + read_len++; + + if (c->logical_pos >= c->logical_size) + break; + } + + return read_len; +} + +static int64_t async_test_seek(URLContext *h, int64_t pos, int whence) +{ + TestContext *c = h->priv_data; + int64_t new_logical_pos; + + if (whence == AVSEEK_SIZE) { + return c->logical_size; + } else if (whence == SEEK_CUR) { + new_logical_pos = pos + c->logical_pos; + } else if (whence == SEEK_SET){ + new_logical_pos = pos; + } else { + return AVERROR(EINVAL); + } + if (new_logical_pos < 0) + return AVERROR(EINVAL); + + c->logical_pos = new_logical_pos; + return new_logical_pos; +} + +static const AVClass async_test_context_class = { + .class_name = "Async-Test", + .item_name = av_default_item_name, + .version = LIBAVUTIL_VERSION_INT, +}; + +URLProtocol ff_async_test_protocol = { + .name = "async-test", + .url_open2 = async_test_open, + .url_read = async_test_read, + .url_seek = async_test_seek, + .url_close = async_test_close, + .priv_data_size = sizeof(TestContext), + .priv_data_class = &async_test_context_class, +}; + +int main(void) +{ + URLContext *h = NULL; + int i; + int ret; + int64_t size; + int64_t pos; + int64_t read_len; + unsigned char buf[4096]; + + ffurl_register_protocol(&ff_async_protocol); + ffurl_register_protocol(&ff_async_test_protocol); + + ret = ffurl_open(&h, "async:async-test:", AVIO_FLAG_READ, NULL, NULL); + printf("open: %d\n", ret); + + size = ffurl_size(h); + printf("size: %"PRId64"\n", size); + + pos = ffurl_seek(h, 0, SEEK_CUR); + read_len = 0; + while (1) { + ret = ffurl_read(h, buf, sizeof(buf)); + if (ret == AVERROR_EOF) { + printf("read-error: AVERROR_EOF at %"PRId64"\n", ffurl_seek(h, 0, SEEK_CUR)); + break; + } + else if (ret == 0) + break; + else if (ret < 0) { + printf("read-error: %d at %"PRId64"\n", ret, ffurl_seek(h, 0, SEEK_CUR)); + goto fail; + } else { + for (i = 0; i < ret; ++i) { + if (buf[i] != (pos & 0xFF)) { + printf("read-mismatch: actual %d, expecting %d, at %"PRId64"\n", + (int)buf[i], (int)(pos & 0xFF), pos); + break; + } + pos++; + } + } + + read_len += ret; + } + printf("read: %"PRId64"\n", read_len); + + ret = ffurl_read(h, buf, 1); + printf("read: %d\n", ret); + + pos = ffurl_seek(h, TEST_SEEK_POS, SEEK_SET); + printf("seek: %"PRId64"\n", pos); + + read_len = 0; + while (1) { + ret = ffurl_read(h, buf, sizeof(buf)); + if (ret == AVERROR_EOF) + break; + else if (ret == 0) + break; + else if (ret < 0) { + printf("read-error: %d at %"PRId64"\n", ret, ffurl_seek(h, 0, SEEK_CUR)); + goto fail; + } else { + for (i = 0; i < ret; ++i) { + if (buf[i] != (pos & 0xFF)) { + printf("read-mismatch: actual %d, expecting %d, at %"PRId64"\n", + (int)buf[i], (int)(pos & 0xFF), pos); + break; + } + pos++; + } + } + + read_len += ret; + } + printf("read: %"PRId64"\n", read_len); + + ret = ffurl_read(h, buf, 1); + printf("read: %d\n", ret); + +fail: + ffurl_close(h); + return 0; +} + +#endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/avc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/avc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/avc.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/avc.c 2015-07-28 17:20:07.000000000 +0000 @@ -180,7 +180,7 @@ if (11 + sps_size + pps_size > *size) return AVERROR_INVALIDDATA; out_size = 8 + sps_size + pps_size; - out = av_mallocz(out_size + FF_INPUT_BUFFER_PADDING_SIZE); + out = av_mallocz(out_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!out) return AVERROR(ENOMEM); AV_WB32(&out[0], 0x00000001); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/avidec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/avidec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/avidec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/avidec.c 2015-07-28 17:20:07.000000000 +0000 @@ -823,7 +823,7 @@ st->codec->extradata_size += 9; if ((ret = av_reallocp(&st->codec->extradata, st->codec->extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE)) < 0) { + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) { st->codec->extradata_size = 0; return ret; } else @@ -835,7 +835,7 @@ // avio_skip(pb, size - 5 * 4); break; case AVMEDIA_TYPE_AUDIO: - ret = ff_get_wav_header(pb, st->codec, size, 0); + ret = ff_get_wav_header(s, pb, st->codec, size, 0); if (ret < 0) return ret; ast->dshow_block_align = st->codec->block_align; @@ -1681,9 +1681,13 @@ if (n >= 2) { int64_t pos = st->index_entries[0].pos; - avio_seek(s->pb, pos + 4, SEEK_SET); + unsigned tag[2]; + avio_seek(s->pb, pos, SEEK_SET); + tag[0] = avio_r8(s->pb); + tag[1] = avio_r8(s->pb); + avio_rl16(s->pb); size = avio_rl32(s->pb); - if (pos + size > st->index_entries[1].pos) + if (get_stream_idx(tag) == i && pos + size > st->index_entries[1].pos) last_start = INT64_MAX; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/aviobuf.c ffmpeg-2.7.2~trusty~ppa1/libavformat/aviobuf.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/aviobuf.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/aviobuf.c 2015-08-01 17:20:02.000000000 +0000 @@ -97,6 +97,7 @@ s->seekable = seek ? AVIO_SEEKABLE_NORMAL : 0; s->max_packet_size = 0; s->update_checksum = NULL; + s->short_seek_threshold = SHORT_SEEK_THRESHOLD; if (!read_packet && !write_flag) { s->pos = buffer_size; @@ -232,7 +233,7 @@ /* can do the seek inside the buffer */ s->buf_ptr = s->buffer + offset1; } else if ((!s->seekable || - offset1 <= s->buf_end + SHORT_SEEK_THRESHOLD - s->buffer) && + offset1 <= s->buf_end + s->short_seek_threshold - s->buffer) && !s->write_flag && offset1 >= 0 && (!s->direct || !s->seek) && (whence != SEEK_END || force)) { @@ -1020,6 +1021,23 @@ return 0; } +int avio_accept(AVIOContext *s, AVIOContext **c) +{ + int ret; + URLContext *sc = s->opaque; + URLContext *cc = NULL; + ret = ffurl_accept(sc, &cc); + if (ret < 0) + return ret; + return ffio_fdopen(c, cc); +} + +int avio_handshake(AVIOContext *c) +{ + URLContext *cc = c->opaque; + return ffurl_handshake(cc); +} + /* output in a dynamic buffer */ typedef struct DynBuffer { @@ -1129,7 +1147,7 @@ { DynBuffer *d; int size; - static const char padbuf[FF_INPUT_BUFFER_PADDING_SIZE] = {0}; + static const char padbuf[AV_INPUT_BUFFER_PADDING_SIZE] = {0}; int padding = 0; if (!s) { @@ -1140,7 +1158,7 @@ /* don't attempt to pad fixed-size packet buffers */ if (!s->max_packet_size) { avio_write(s, padbuf, sizeof(padbuf)); - padding = FF_INPUT_BUFFER_PADDING_SIZE; + padding = AV_INPUT_BUFFER_PADDING_SIZE; } avio_flush(s); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/avio.c ffmpeg-2.7.2~trusty~ppa1/libavformat/avio.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/avio.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/avio.c 2015-08-01 17:20:02.000000000 +0000 @@ -211,6 +211,26 @@ return 0; } +int ffurl_accept(URLContext *s, URLContext **c) +{ + av_assert0(!*c); + if (s->prot->url_accept) + return s->prot->url_accept(s, c); + return AVERROR(EBADF); +} + +int ffurl_handshake(URLContext *c) +{ + int ret; + if (c->prot->url_handshake) { + ret = c->prot->url_handshake(c); + if (ret) + return ret; + } + c->is_connected = 1; + return 0; +} + #define URL_SCHEME_CHARS \ "abcdefghijklmnopqrstuvwxyz" \ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ @@ -421,6 +441,44 @@ return ret; } +int avpriv_io_move(const char *url_src, const char *url_dst) +{ + URLContext *h_src, *h_dst; + int ret = ffurl_alloc(&h_src, url_src, AVIO_FLAG_READ_WRITE, NULL); + if (ret < 0) + return ret; + ret = ffurl_alloc(&h_dst, url_dst, AVIO_FLAG_WRITE, NULL); + if (ret < 0) { + ffurl_close(h_src); + return ret; + } + + if (h_src->prot == h_dst->prot && h_src->prot->url_move) + ret = h_src->prot->url_move(h_src, h_dst); + else + ret = AVERROR(ENOSYS); + + ffurl_close(h_src); + ffurl_close(h_dst); + return ret; +} + +int avpriv_io_delete(const char *url) +{ + URLContext *h; + int ret = ffurl_alloc(&h, url, AVIO_FLAG_WRITE, NULL); + if (ret < 0) + return ret; + + if (h->prot->url_delete) + ret = h->prot->url_delete(h); + else + ret = AVERROR(ENOSYS); + + ffurl_close(h); + return ret; +} + int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options) { URLContext *h = NULL; @@ -447,6 +505,7 @@ if (ret < 0) goto fail; + h->is_connected = 1; ctx->url_context = h; *s = ctx; return 0; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/avio.h ffmpeg-2.7.2~trusty~ppa1/libavformat/avio.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/avio.h 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/avio.h 2015-08-01 17:20:02.000000000 +0000 @@ -196,6 +196,12 @@ * This field is internal to libavformat and access from outside is not allowed. */ int orig_buffer_size; + + /** + * Threshold to favor readahead over seek. + * This is current internal only, do not use from outside. + */ + int short_seek_threshold; } AVIOContext; /* unbuffered I/O */ @@ -224,6 +230,25 @@ int avio_check(const char *url, int flags); /** + * Move or rename a resource. + * + * @note url_src and url_dst should share the same protocol and authority. + * + * @param url_src url to resource to be moved + * @param url_dst new url to resource if the operation succeeded + * @return >=0 on success or negative on error. + */ +int avpriv_io_move(const char *url_src, const char *url_dst); + +/** + * Delete a resource. + * + * @param url resource to be deleted. + * @return >=0 on success or negative on error. + */ +int avpriv_io_delete(const char *url); + +/** * Open directory for reading. * * @param s directory read context. Pointer to a NULL pointer must be passed. @@ -560,7 +585,7 @@ /** * Return the written size and a pointer to the buffer. The buffer * must be freed with av_free(). - * Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer. + * Padding of AV_INPUT_BUFFER_PADDING_SIZE is added to the buffer. * * @param s IO context * @param pbuffer pointer to a byte buffer @@ -623,4 +648,33 @@ */ int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size); +/** + * Accept and allocate a client context on a server context. + * @param s the server context + * @param c the client context, must be unallocated + * @return >= 0 on success or a negative value corresponding + * to an AVERROR on failure + */ +int avio_accept(AVIOContext *s, AVIOContext **c); + +/** + * Perform one step of the protocol handshake to accept a new client. + * This function must be called on a client returned by avio_accept() before + * using it as a read/write context. + * It is separate from avio_accept() because it may block. + * A step of the handshake is defined by places where the application may + * decide to change the proceedings. + * For example, on a protocol with a request header and a reply header, each + * one can constitute a step because the application may use the parameters + * from the request to change parameters in the reply; or each individual + * chunk of the request can constitute a step. + * If the handshake is already finished, avio_handshake() does nothing and + * returns 0 immediately. + * + * @param c the client context to perform the handshake on + * @return 0 on a complete and successful handshake + * > 0 if the handshake progressed, but is not complete + * < 0 for an AVERROR code + */ +int avio_handshake(AVIOContext *c); #endif /* AVFORMAT_AVIO_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/brstm.c ffmpeg-2.7.2~trusty~ppa1/libavformat/brstm.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/brstm.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/brstm.c 2015-07-12 17:20:02.000000000 +0000 @@ -30,8 +30,12 @@ uint32_t current_block; uint32_t samples_per_block; uint32_t last_block_used_bytes; + uint32_t last_block_size; + uint32_t last_block_samples; + uint32_t data_start; uint8_t *table; uint8_t *adpc; + int little_endian; } BRSTMDemuxContext; static int probe(AVProbeData *p) @@ -43,6 +47,16 @@ return 0; } +static int probe_bfstm(AVProbeData *p) +{ + if ((AV_RL32(p->buf) == MKTAG('F','S','T','M') || + AV_RL32(p->buf) == MKTAG('C','S','T','M')) && + (AV_RL16(p->buf + 4) == 0xFFFE || + AV_RL16(p->buf + 4) == 0xFEFF)) + return AVPROBE_SCORE_MAX / 3 * 2; + return 0; +} + static int read_close(AVFormatContext *s) { BRSTMDemuxContext *b = s->priv_data; @@ -53,14 +67,34 @@ return 0; } +static av_always_inline unsigned int read16(AVFormatContext *s) +{ + BRSTMDemuxContext *b = s->priv_data; + if (b->little_endian) + return avio_rl16(s->pb); + else + return avio_rb16(s->pb); +} + +static av_always_inline unsigned int read32(AVFormatContext *s) +{ + BRSTMDemuxContext *b = s->priv_data; + if (b->little_endian) + return avio_rl32(s->pb); + else + return avio_rb32(s->pb); +} + static int read_header(AVFormatContext *s) { BRSTMDemuxContext *b = s->priv_data; int bom, major, minor, codec, chunk; - int64_t pos, h1offset, toffset; - uint32_t size, start, asize; + int64_t h1offset, pos, toffset; + uint32_t size, asize, start = 0; AVStream *st; int ret = AVERROR_EOF; + int loop = 0; + int bfstm = !strcmp("bfstm", s->iformat->name); st = avformat_new_stream(s, NULL); if (!st) @@ -74,31 +108,75 @@ av_log(s, AV_LOG_ERROR, "invalid byte order: %X\n", bom); return AVERROR_INVALIDDATA; } - if (bom == 0xFFFE) { - avpriv_request_sample(s, "little endian byte order"); - return AVERROR_PATCHWELCOME; - } - major = avio_r8(s->pb); - minor = avio_r8(s->pb); - avio_skip(s->pb, 4); // size of file - size = avio_rb16(s->pb); - if (size < 14) - return AVERROR_INVALIDDATA; + if (bom == 0xFFFE) + b->little_endian = 1; - avio_skip(s->pb, size - 14); - pos = avio_tell(s->pb); - if (avio_rl32(s->pb) != MKTAG('H','E','A','D')) - return AVERROR_INVALIDDATA; - size = avio_rb32(s->pb); - if (size < 256) + if (!bfstm) { + major = avio_r8(s->pb); + minor = avio_r8(s->pb); + avio_skip(s->pb, 4); // size of file + size = read16(s); + if (size < 14) + return AVERROR_INVALIDDATA; + + avio_skip(s->pb, size - 14); + pos = avio_tell(s->pb); + if (avio_rl32(s->pb) != MKTAG('H','E','A','D')) + return AVERROR_INVALIDDATA; + } else { + uint32_t info_offset = 0; + uint16_t section_count, header_size, i; + + header_size = read16(s); // 6 + + avio_skip(s->pb, 4); // Unknown constant 0x00030000 + avio_skip(s->pb, 4); // size of file + section_count = read16(s); + avio_skip(s->pb, 2); // padding + for (i = 0; avio_tell(s->pb) < header_size + && !(start && info_offset) + && i < section_count; i++) { + uint16_t flag = read16(s); + avio_skip(s->pb, 2); + switch (flag) { + case 0x4000: + info_offset = read32(s); + /*info_size =*/ read32(s); + break; + case 0x4001: + avio_skip(s->pb, 4); // seek offset + avio_skip(s->pb, 4); // seek size + break; + case 0x4002: + start = read32(s) + 8; + avio_skip(s->pb, 4); //data_size = read32(s); + break; + case 0x4003: + avio_skip(s->pb, 4); // REGN offset + avio_skip(s->pb, 4); // REGN size + break; + } + } + + if (!info_offset || !start) + return AVERROR_INVALIDDATA; + + avio_skip(s->pb, info_offset - avio_tell(s->pb)); + pos = avio_tell(s->pb); + if (avio_rl32(s->pb) != MKTAG('I','N','F','O')) + return AVERROR_INVALIDDATA; + } + + size = read32(s); + if (size < 192) return AVERROR_INVALIDDATA; avio_skip(s->pb, 4); // unknown - h1offset = avio_rb32(s->pb); + h1offset = read32(s); if (h1offset > size) return AVERROR_INVALIDDATA; avio_skip(s->pb, 12); - toffset = avio_rb32(s->pb) + 16LL; + toffset = read32(s) + 16LL; if (toffset > size) return AVERROR_INVALIDDATA; @@ -107,57 +185,77 @@ switch (codec) { case 0: codec = AV_CODEC_ID_PCM_S8_PLANAR; break; - case 1: codec = AV_CODEC_ID_PCM_S16BE_PLANAR; break; - case 2: codec = AV_CODEC_ID_ADPCM_THP; break; + case 1: codec = b->little_endian ? + AV_CODEC_ID_PCM_S16LE_PLANAR : + AV_CODEC_ID_PCM_S16BE_PLANAR; break; + case 2: codec = b->little_endian ? + AV_CODEC_ID_ADPCM_THP_LE : + AV_CODEC_ID_ADPCM_THP; break; default: avpriv_request_sample(s, "codec %d", codec); return AVERROR_PATCHWELCOME; } - avio_skip(s->pb, 1); // loop flag + loop = avio_r8(s->pb); // loop flag st->codec->codec_id = codec; st->codec->channels = avio_r8(s->pb); if (!st->codec->channels) return AVERROR_INVALIDDATA; avio_skip(s->pb, 1); // padding - st->codec->sample_rate = avio_rb16(s->pb); + + st->codec->sample_rate = bfstm ? read32(s) : read16(s); if (!st->codec->sample_rate) return AVERROR_INVALIDDATA; - avio_skip(s->pb, 2); // padding - avio_skip(s->pb, 4); // loop start sample + if (!bfstm) + avio_skip(s->pb, 2); // padding + + if (loop) { + if (av_dict_set_int(&s->metadata, "loop_start", + av_rescale(read32(s), AV_TIME_BASE, + st->codec->sample_rate), + 0) < 0) + return AVERROR(ENOMEM); + } else { + avio_skip(s->pb, 4); + } + st->start_time = 0; - st->duration = avio_rb32(s->pb); + st->duration = read32(s); avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); - start = avio_rb32(s->pb); + if (!bfstm) + start = read32(s); b->current_block = 0; - b->block_count = avio_rb32(s->pb); + b->block_count = read32(s); if (b->block_count > UINT16_MAX) { av_log(s, AV_LOG_WARNING, "too many blocks: %u\n", b->block_count); return AVERROR_INVALIDDATA; } - b->block_size = avio_rb32(s->pb); - if (b->block_size > UINT16_MAX / st->codec->channels) + b->block_size = read32(s); + if (b->block_size > UINT32_MAX / st->codec->channels) return AVERROR_INVALIDDATA; - b->block_size *= st->codec->channels; - b->samples_per_block = avio_rb32(s->pb); - b->last_block_used_bytes = avio_rb32(s->pb); - if (b->last_block_used_bytes > UINT16_MAX / st->codec->channels) + b->samples_per_block = read32(s); + b->last_block_used_bytes = read32(s); + b->last_block_samples = read32(s); + b->last_block_size = read32(s); + if (b->last_block_size > UINT32_MAX / st->codec->channels) + return AVERROR_INVALIDDATA; + if (b->last_block_used_bytes > b->last_block_size) return AVERROR_INVALIDDATA; - b->last_block_used_bytes *= st->codec->channels; - avio_skip(s->pb, 4); // last block samples - avio_skip(s->pb, 4); // last block size - if (codec == AV_CODEC_ID_ADPCM_THP) { + if (codec == AV_CODEC_ID_ADPCM_THP || codec == AV_CODEC_ID_ADPCM_THP_LE) { int ch; avio_skip(s->pb, pos + toffset - avio_tell(s->pb)); - toffset = avio_rb32(s->pb) + 16LL; + if (!bfstm) + toffset = read32(s) + 16LL; + else + toffset = toffset + read32(s) + st->codec->channels * 8 - 8; if (toffset > size) return AVERROR_INVALIDDATA; @@ -171,7 +269,7 @@ ret = AVERROR_INVALIDDATA; goto fail; } - avio_skip(s->pb, 24); + avio_skip(s->pb, bfstm ? 14 : 24); } } @@ -179,19 +277,22 @@ ret = AVERROR_INVALIDDATA; goto fail; } + avio_skip(s->pb, size - (avio_tell(s->pb) - pos)); while (!avio_feof(s->pb)) { chunk = avio_rl32(s->pb); - size = avio_rb32(s->pb); + size = read32(s); if (size < 8) { ret = AVERROR_INVALIDDATA; goto fail; } size -= 8; switch (chunk) { + case MKTAG('S','E','E','K'): case MKTAG('A','D','P','C'): - if (codec != AV_CODEC_ID_ADPCM_THP) + if (codec != AV_CODEC_ID_ADPCM_THP && + codec != AV_CODEC_ID_ADPCM_THP_LE) goto skip; asize = b->block_count * st->codec->channels * 4; @@ -208,19 +309,36 @@ ret = AVERROR(ENOMEM); goto fail; } - avio_read(s->pb, b->adpc, asize); + if (bfstm && codec != AV_CODEC_ID_ADPCM_THP_LE) { + // Big-endian BFSTMs have little-endian SEEK tables + // for some strange reason. + int i; + for (i = 0; i < asize; i += 2) { + b->adpc[i+1] = avio_r8(s->pb); + b->adpc[i] = avio_r8(s->pb); + } + } else { + avio_read(s->pb, b->adpc, asize); + } avio_skip(s->pb, size - asize); } break; case MKTAG('D','A','T','A'): if ((start < avio_tell(s->pb)) || - (!b->adpc && codec == AV_CODEC_ID_ADPCM_THP)) { + (!b->adpc && (codec == AV_CODEC_ID_ADPCM_THP || + codec == AV_CODEC_ID_ADPCM_THP_LE))) { ret = AVERROR_INVALIDDATA; goto fail; } avio_skip(s->pb, start - avio_tell(s->pb)); - if (major != 1 || minor) + if (bfstm && (codec == AV_CODEC_ID_ADPCM_THP || + codec == AV_CODEC_ID_ADPCM_THP_LE)) + avio_skip(s->pb, 24); + + b->data_start = avio_tell(s->pb); + + if (!bfstm && (major != 1 || minor)) avpriv_request_sample(s, "Version %d.%d", major, minor); return 0; @@ -241,15 +359,25 @@ { AVCodecContext *codec = s->streams[0]->codec; BRSTMDemuxContext *b = s->priv_data; - uint32_t samples, size; - int ret; + uint32_t samples, size, skip = 0; + int ret, i; if (avio_feof(s->pb)) return AVERROR_EOF; b->current_block++; if (b->current_block == b->block_count) { size = b->last_block_used_bytes; - samples = size / (8 * codec->channels) * 14; + samples = b->last_block_samples; + skip = b->last_block_size - b->last_block_used_bytes; + + if (samples < size * 14 / 8) { + uint32_t adjusted_size = samples / 14 * 8; + if (samples % 14) + adjusted_size += (samples % 14 + 1) / 2 + 1; + + skip += size - adjusted_size; + size = adjusted_size; + } } else if (b->current_block < b->block_count) { size = b->block_size; samples = b->samples_per_block; @@ -257,23 +385,36 @@ return AVERROR_EOF; } - if (codec->codec_id == AV_CODEC_ID_ADPCM_THP) { + if (codec->codec_id == AV_CODEC_ID_ADPCM_THP || + codec->codec_id == AV_CODEC_ID_ADPCM_THP_LE) { uint8_t *dst; - if (av_new_packet(pkt, 8 + (32 + 4) * codec->channels + size) < 0) + if (av_new_packet(pkt, 8 + (32 + 4 + size) * codec->channels) < 0) return AVERROR(ENOMEM); dst = pkt->data; - bytestream_put_be32(&dst, size); - bytestream_put_be32(&dst, samples); + if (codec->codec_id == AV_CODEC_ID_ADPCM_THP_LE) { + bytestream_put_le32(&dst, size * codec->channels); + bytestream_put_le32(&dst, samples); + } else { + bytestream_put_be32(&dst, size * codec->channels); + bytestream_put_be32(&dst, samples); + } bytestream_put_buffer(&dst, b->table, 32 * codec->channels); bytestream_put_buffer(&dst, b->adpc + 4 * codec->channels * (b->current_block - 1), 4 * codec->channels); - ret = avio_read(s->pb, dst, size); - if (ret != size) - av_free_packet(pkt); + for (i = 0; i < codec->channels; i++) { + ret = avio_read(s->pb, dst, size); + dst += size; + avio_skip(s->pb, skip); + if (ret != size) { + av_free_packet(pkt); + break; + } + } pkt->duration = samples; } else { + size *= codec->channels; ret = av_get_packet(s->pb, pkt, size); } @@ -285,6 +426,24 @@ return ret; } +static int read_seek(AVFormatContext *s, int stream_index, + int64_t timestamp, int flags) +{ + AVStream *st = s->streams[stream_index]; + BRSTMDemuxContext *b = s->priv_data; + int64_t ret = 0; + + timestamp /= b->samples_per_block; + ret = avio_seek(s->pb, b->data_start + timestamp * b->block_size * + st->codec->channels, SEEK_SET); + if (ret < 0) + return ret; + + b->current_block = timestamp; + ff_update_cur_dts(s, st, timestamp * b->samples_per_block); + return 0; +} + AVInputFormat ff_brstm_demuxer = { .name = "brstm", .long_name = NULL_IF_CONFIG_SMALL("BRSTM (Binary Revolution Stream)"), @@ -293,5 +452,18 @@ .read_header = read_header, .read_packet = read_packet, .read_close = read_close, + .read_seek = read_seek, .extensions = "brstm", }; + +AVInputFormat ff_bfstm_demuxer = { + .name = "bfstm", + .long_name = NULL_IF_CONFIG_SMALL("BFSTM (Binary Cafe Stream)"), + .priv_data_size = sizeof(BRSTMDemuxContext), + .read_probe = probe_bfstm, + .read_header = read_header, + .read_packet = read_packet, + .read_close = read_close, + .read_seek = read_seek, + .extensions = "bfstm,bcstm", +}; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/cafdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/cafdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/cafdec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/cafdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -101,7 +101,7 @@ AVIOContext *pb = s->pb; AVStream *st = s->streams[0]; - if (size < 0 || size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) + if (size < 0 || size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) return -1; if (st->codec->codec_id == AV_CODEC_ID_AAC) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/concatdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/concatdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/concatdec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/concatdec.c 2015-07-17 17:20:02.000000000 +0000 @@ -41,8 +41,13 @@ typedef struct { char *url; int64_t start_time; + int64_t file_start_time; + int64_t file_inpoint; int64_t duration; ConcatStream *streams; + int64_t inpoint; + int64_t outpoint; + AVDictionary *metadata; int nb_streams; } ConcatFile; @@ -54,6 +59,7 @@ AVFormatContext *avf; int safe; int seekable; + int eof; ConcatMatchMode stream_match_mode; unsigned auto_convert; } ConcatContext; @@ -142,6 +148,8 @@ file->url = url; file->start_time = AV_NOPTS_VALUE; file->duration = AV_NOPTS_VALUE; + file->inpoint = AV_NOPTS_VALUE; + file->outpoint = AV_NOPTS_VALUE; return 0; @@ -172,6 +180,8 @@ st->avg_frame_rate = source_st->avg_frame_rate; st->time_base = source_st->time_base; st->sample_aspect_ratio = source_st->sample_aspect_ratio; + + av_dict_copy(&st->metadata, source_st->metadata, 0); return 0; } @@ -304,8 +314,14 @@ file->start_time = !fileno ? 0 : cat->files[fileno - 1].start_time + cat->files[fileno - 1].duration; + file->file_start_time = (avf->start_time == AV_NOPTS_VALUE) ? 0 : avf->start_time; + file->file_inpoint = (file->file_inpoint == AV_NOPTS_VALUE) ? file->file_start_time : file->inpoint; if ((ret = match_streams(avf)) < 0) return ret; + if (file->inpoint != AV_NOPTS_VALUE) { + if ((ret = avformat_seek_file(cat->avf, -1, INT64_MIN, file->inpoint, file->inpoint, 0)) < 0) + return ret; + } return 0; } @@ -319,6 +335,7 @@ for (i = 0; i < cat->nb_files; i++) { av_freep(&cat->files[i].url); av_freep(&cat->files[i].streams); + av_dict_free(&cat->files[i].metadata); } av_freep(&cat->files); return 0; @@ -351,20 +368,38 @@ } if ((ret = add_file(avf, filename, &file, &nb_files_alloc)) < 0) goto fail; - } else if (!strcmp(keyword, "duration")) { + } else if (!strcmp(keyword, "duration") || !strcmp(keyword, "inpoint") || !strcmp(keyword, "outpoint")) { char *dur_str = get_keyword(&cursor); int64_t dur; if (!file) { - av_log(avf, AV_LOG_ERROR, "Line %d: duration without file\n", - line); + av_log(avf, AV_LOG_ERROR, "Line %d: %s without file\n", + line, keyword); FAIL(AVERROR_INVALIDDATA); } if ((ret = av_parse_time(&dur, dur_str, 1)) < 0) { - av_log(avf, AV_LOG_ERROR, "Line %d: invalid duration '%s'\n", - line, dur_str); + av_log(avf, AV_LOG_ERROR, "Line %d: invalid %s '%s'\n", + line, keyword, dur_str); goto fail; } - file->duration = dur; + if (!strcmp(keyword, "duration")) + file->duration = dur; + else if (!strcmp(keyword, "inpoint")) + file->inpoint = dur; + else if (!strcmp(keyword, "outpoint")) + file->outpoint = dur; + } else if (!strcmp(keyword, "file_packet_metadata")) { + char *metadata; + metadata = av_get_token((const char **)&cursor, SPACE_CHARS); + if (!metadata) { + av_log(avf, AV_LOG_ERROR, "Line %d: packet metadata required\n", line); + FAIL(AVERROR_INVALIDDATA); + } + if ((ret = av_dict_parse_string(&file->metadata, metadata, "=", "", 0)) < 0) { + av_log(avf, AV_LOG_ERROR, "Line %d: failed to parse metadata string\n", line); + av_freep(&metadata); + FAIL(AVERROR_INVALIDDATA); + } + av_freep(&metadata); } else if (!strcmp(keyword, "stream")) { if (!avformat_new_stream(avf, NULL)) FAIL(AVERROR(ENOMEM)); @@ -401,8 +436,11 @@ cat->files[i].start_time = time; else time = cat->files[i].start_time; - if (cat->files[i].duration == AV_NOPTS_VALUE) - break; + if (cat->files[i].duration == AV_NOPTS_VALUE) { + if (cat->files[i].inpoint == AV_NOPTS_VALUE || cat->files[i].outpoint == AV_NOPTS_VALUE) + break; + cat->files[i].duration = cat->files[i].outpoint - cat->files[i].inpoint; + } time += cat->files[i].duration; } if (i == cat->nb_files) { @@ -426,11 +464,18 @@ ConcatContext *cat = avf->priv_data; unsigned fileno = cat->cur_file - cat->files; - if (cat->cur_file->duration == AV_NOPTS_VALUE) + if (cat->cur_file->duration == AV_NOPTS_VALUE) { cat->cur_file->duration = cat->avf->duration; + if (cat->cur_file->inpoint != AV_NOPTS_VALUE) + cat->cur_file->duration -= (cat->cur_file->inpoint - cat->cur_file->file_start_time); + if (cat->cur_file->outpoint != AV_NOPTS_VALUE) + cat->cur_file->duration -= cat->avf->duration - (cat->cur_file->outpoint - cat->cur_file->file_start_time); + } - if (++fileno >= cat->nb_files) + if (++fileno >= cat->nb_files) { + cat->eof = 1; return AVERROR_EOF; + } return open_file(avf, fileno); } @@ -474,20 +519,35 @@ return 0; } +/* Returns true if the packet dts is greater or equal to the specified outpoint. */ +static int packet_after_outpoint(ConcatContext *cat, AVPacket *pkt) +{ + if (cat->cur_file->outpoint != AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE) { + return av_compare_ts(pkt->dts, cat->avf->streams[pkt->stream_index]->time_base, + cat->cur_file->outpoint, AV_TIME_BASE_Q) >= 0; + } + return 0; +} + static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt) { ConcatContext *cat = avf->priv_data; int ret; - int64_t file_start_time, delta; + int64_t delta; ConcatStream *cs; AVStream *st; + if (cat->eof) + return AVERROR_EOF; + if (!cat->avf) return AVERROR(EIO); while (1) { ret = av_read_frame(cat->avf, pkt); - if (ret == AVERROR_EOF) { + if (ret == AVERROR_EOF || packet_after_outpoint(cat, pkt)) { + if (ret == 0) + av_packet_unref(pkt); if ((ret = open_next_file(avf)) < 0) return ret; continue; @@ -515,10 +575,7 @@ av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base)); - file_start_time = cat->avf->start_time; - if (file_start_time == AV_NOPTS_VALUE) - file_start_time = 0; - delta = av_rescale_q(cat->cur_file->start_time - file_start_time, + delta = av_rescale_q(cat->cur_file->start_time - cat->cur_file->file_inpoint, AV_TIME_BASE_Q, cat->avf->streams[pkt->stream_index]->time_base); if (pkt->pts != AV_NOPTS_VALUE) @@ -528,6 +585,19 @@ av_log(avf, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s\n", av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base)); + if (cat->cur_file->metadata) { + uint8_t* metadata; + int metadata_len; + char* packed_metadata = av_packet_pack_dictionary(cat->cur_file->metadata, &metadata_len); + if (!packed_metadata) + return AVERROR(ENOMEM); + if (!(metadata = av_packet_new_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, metadata_len))) { + av_freep(&packed_metadata); + return AVERROR(ENOMEM); + } + memcpy(metadata, packed_metadata, metadata_len); + av_freep(&packed_metadata); + } return ret; } @@ -545,7 +615,7 @@ int64_t min_ts, int64_t ts, int64_t max_ts, int flags) { ConcatContext *cat = avf->priv_data; - int64_t t0 = cat->cur_file->start_time - cat->avf->start_time; + int64_t t0 = cat->cur_file->start_time - cat->cur_file->file_inpoint; ts -= t0; min_ts = min_ts == INT64_MIN ? INT64_MIN : min_ts - t0; @@ -616,6 +686,7 @@ cat->cur_file = cur_file_saved; } else { avformat_close_input(&cur_avf_saved); + cat->eof = 0; } return ret; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/dtsdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/dtsdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/dtsdec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/dtsdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -34,7 +34,7 @@ int markers[4*16] = {0}; int sum, max, i; int64_t diff = 0; - uint8_t hdr[12 + FF_INPUT_BUFFER_PADDING_SIZE] = { 0 }; + uint8_t hdr[12 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 }; buf = p->buf + FFMIN(4096, p->buf_size); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/dump.c ffmpeg-2.7.2~trusty~ppa1/libavformat/dump.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/dump.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/dump.c 2015-07-23 17:20:03.000000000 +0000 @@ -377,6 +377,9 @@ av_log(ctx, AV_LOG_INFO, "audio service type: "); dump_audioservicetype(ctx, &sd); break; + case AV_PKT_DATA_QUALITY_STATS: + av_log(ctx, AV_LOG_INFO, "quality factor: %d, pict_type: %c", AV_RL32(sd.data), av_get_picture_type_char(sd.data[4])); + break; default: av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)", sd.type, sd.size); @@ -509,7 +512,7 @@ int secs, us; av_log(NULL, AV_LOG_INFO, ", start: "); secs = ic->start_time / AV_TIME_BASE; - us = abs(ic->start_time % AV_TIME_BASE); + us = llabs(ic->start_time % AV_TIME_BASE); av_log(NULL, AV_LOG_INFO, "%d.%06d", secs, (int) av_rescale(us, 1000000, AV_TIME_BASE)); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/dxa.c ffmpeg-2.7.2~trusty~ppa1/libavformat/dxa.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/dxa.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/dxa.c 2015-07-12 17:20:02.000000000 +0000 @@ -106,7 +106,7 @@ ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); - ret = ff_get_wav_header(pb, ast->codec, fsize, 0); + ret = ff_get_wav_header(s, pb, ast->codec, fsize, 0); if (ret < 0) return ret; if (ast->codec->sample_rate > 0) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/electronicarts.c ffmpeg-2.7.2~trusty~ppa1/libavformat/electronicarts.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/electronicarts.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/electronicarts.c 2015-06-25 17:20:03.000000000 +0000 @@ -59,17 +59,25 @@ #define MVhd_TAG MKTAG('M', 'V', 'h', 'd') #define MV0K_TAG MKTAG('M', 'V', '0', 'K') #define MV0F_TAG MKTAG('M', 'V', '0', 'F') +#define AVhd_TAG MKTAG('A', 'V', 'h', 'd') +#define AV0K_TAG MKTAG('A', 'V', '0', 'K') +#define AV0F_TAG MKTAG('A', 'V', '0', 'F') #define MVIh_TAG MKTAG('M', 'V', 'I', 'h') /* CMV header */ #define MVIf_TAG MKTAG('M', 'V', 'I', 'f') /* CMV I-frame */ +#define AVP6_TAG MKTAG('A', 'V', 'P', '6') -typedef struct EaDemuxContext { - int big_endian; - - enum AVCodecID video_codec; +typedef struct VideoProperties { + enum AVCodecID codec; AVRational time_base; int width, height; int nb_frames; - int video_stream_index; + int stream_index; +} VideoProperties; + +typedef struct EaDemuxContext { + int big_endian; + + VideoProperties video, alpha; enum AVCodecID audio_codec; int audio_stream_index; @@ -301,46 +309,43 @@ ea->audio_codec = AV_CODEC_ID_ADPCM_IMA_EA_SEAD; } -static void process_video_header_mdec(AVFormatContext *s) +static void process_video_header_mdec(AVFormatContext *s, VideoProperties *video) { - EaDemuxContext *ea = s->priv_data; AVIOContext *pb = s->pb; avio_skip(pb, 4); - ea->width = avio_rl16(pb); - ea->height = avio_rl16(pb); - ea->time_base = (AVRational) { 1, 15 }; - ea->video_codec = AV_CODEC_ID_MDEC; + video->width = avio_rl16(pb); + video->height = avio_rl16(pb); + video->time_base = (AVRational) { 1, 15 }; + video->codec = AV_CODEC_ID_MDEC; } -static int process_video_header_vp6(AVFormatContext *s) +static int process_video_header_vp6(AVFormatContext *s, VideoProperties *video) { - EaDemuxContext *ea = s->priv_data; - AVIOContext *pb = s->pb; + AVIOContext *pb = s->pb; avio_skip(pb, 8); - ea->nb_frames = avio_rl32(pb); + video->nb_frames = avio_rl32(pb); avio_skip(pb, 4); - ea->time_base.den = avio_rl32(pb); - ea->time_base.num = avio_rl32(pb); - if (ea->time_base.den <= 0 || ea->time_base.num <= 0) { + video->time_base.den = avio_rl32(pb); + video->time_base.num = avio_rl32(pb); + if (video->time_base.den <= 0 || video->time_base.num <= 0) { av_log(s, AV_LOG_ERROR, "Timebase is invalid\n"); return AVERROR_INVALIDDATA; } - ea->video_codec = AV_CODEC_ID_VP6; + video->codec = AV_CODEC_ID_VP6; return 1; } -static void process_video_header_cmv(AVFormatContext *s) +static void process_video_header_cmv(AVFormatContext *s, VideoProperties *video) { - EaDemuxContext *ea = s->priv_data; int fps; avio_skip(s->pb, 10); fps = avio_rl16(s->pb); if (fps) - ea->time_base = (AVRational) { 1, fps }; - ea->video_codec = AV_CODEC_ID_CMV; + video->time_base = (AVRational) { 1, fps }; + video->codec = AV_CODEC_ID_CMV; } /* Process EA file header. @@ -352,7 +357,7 @@ AVIOContext *pb = s->pb; int i; - for (i = 0; i < 5 && (!ea->audio_codec || !ea->video_codec); i++) { + for (i = 0; i < 5 && (!ea->audio_codec || !ea->video.codec); i++) { uint64_t startpos = avio_tell(pb); int err = 0; @@ -394,40 +399,44 @@ break; case MVIh_TAG: - process_video_header_cmv(s); + process_video_header_cmv(s, &ea->video); break; case kVGT_TAG: - ea->video_codec = AV_CODEC_ID_TGV; + ea->video.codec = AV_CODEC_ID_TGV; break; case mTCD_TAG: - process_video_header_mdec(s); + process_video_header_mdec(s, &ea->video); break; case MPCh_TAG: - ea->video_codec = AV_CODEC_ID_MPEG2VIDEO; + ea->video.codec = AV_CODEC_ID_MPEG2VIDEO; break; case pQGT_TAG: case TGQs_TAG: - ea->video_codec = AV_CODEC_ID_TGQ; - ea->time_base = (AVRational) { 1, 15 }; + ea->video.codec = AV_CODEC_ID_TGQ; + ea->video.time_base = (AVRational) { 1, 15 }; break; case pIQT_TAG: - ea->video_codec = AV_CODEC_ID_TQI; - ea->time_base = (AVRational) { 1, 15 }; + ea->video.codec = AV_CODEC_ID_TQI; + ea->video.time_base = (AVRational) { 1, 15 }; break; case MADk_TAG: - ea->video_codec = AV_CODEC_ID_MAD; + ea->video.codec = AV_CODEC_ID_MAD; avio_skip(pb, 6); - ea->time_base = (AVRational) { avio_rl16(pb), 1000 }; + ea->video.time_base = (AVRational) { avio_rl16(pb), 1000 }; break; case MVhd_TAG: - err = process_video_header_vp6(s); + err = process_video_header_vp6(s, &ea->video); + break; + + case AVhd_TAG: + err = process_video_header_vp6(s, &ea->alpha); break; } @@ -458,6 +467,7 @@ case MPCh_TAG: case MVhd_TAG: case MVIh_TAG: + case AVP6_TAG: break; default: return 0; @@ -472,6 +482,34 @@ return AVPROBE_SCORE_MAX; } +static int init_video_stream(AVFormatContext *s, VideoProperties *video) +{ + AVStream *st; + + if (!video->codec) + return 0; + + /* initialize the video decoder stream */ + st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + video->stream_index = st->index; + st->codec->codec_type = AVMEDIA_TYPE_VIDEO; + st->codec->codec_id = video->codec; + // parsing is necessary to make FFmpeg generate correct timestamps + if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO) + st->need_parsing = AVSTREAM_PARSE_HEADERS; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = video->width; + st->codec->height = video->height; + st->duration = st->nb_frames = video->nb_frames; + if (video->time_base.num) + avpriv_set_pts_info(st, 64, video->time_base.num, video->time_base.den); + st->r_frame_rate = + st->avg_frame_rate = av_inv_q(video->time_base); + return 0; +} + static int ea_read_header(AVFormatContext *s) { EaDemuxContext *ea = s->priv_data; @@ -480,26 +518,8 @@ if (process_ea_header(s)<=0) return AVERROR(EIO); - if (ea->video_codec) { - /* initialize the video decoder stream */ - st = avformat_new_stream(s, NULL); - if (!st) - return AVERROR(ENOMEM); - ea->video_stream_index = st->index; - st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - st->codec->codec_id = ea->video_codec; - // parsing is necessary to make FFmpeg generate correct timestamps - if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO) - st->need_parsing = AVSTREAM_PARSE_HEADERS; - st->codec->codec_tag = 0; /* no fourcc */ - st->codec->width = ea->width; - st->codec->height = ea->height; - st->duration = st->nb_frames = ea->nb_frames; - if (ea->time_base.num) - avpriv_set_pts_info(st, 64, ea->time_base.num, ea->time_base.den); - st->r_frame_rate = - st->avg_frame_rate = av_inv_q(ea->time_base); - } + if (init_video_stream(s, &ea->video) || init_video_stream(s, &ea->alpha)) + return AVERROR(ENOMEM); if (ea->audio_codec) { if (ea->num_channels <= 0 || ea->num_channels > 2) { @@ -659,10 +679,12 @@ goto get_video_packet; case MV0K_TAG: + case AV0K_TAG: case MPCh_TAG: case pIQT_TAG: key = AV_PKT_FLAG_KEY; case MV0F_TAG: + case AV0F_TAG: get_video_packet: if (!chunk_size) continue; @@ -676,7 +698,10 @@ break; } partial_packet = chunk_type == MVIh_TAG; - pkt->stream_index = ea->video_stream_index; + if (chunk_type == AV0K_TAG || chunk_type == AV0F_TAG) + pkt->stream_index = ea->alpha.stream_index; + else + pkt->stream_index = ea->video.stream_index; pkt->flags |= key; packet_read = 1; break; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/ffmdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/ffmdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/ffmdec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/ffmdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -326,7 +326,7 @@ codec->flags = avio_rb32(pb); codec->flags2 = avio_rb32(pb); codec->debug = avio_rb32(pb); - if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) { + if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { if (ff_get_extradata(codec, pb, avio_rb32(pb)) < 0) return AVERROR(ENOMEM); } @@ -573,7 +573,7 @@ default: goto fail; } - if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) { + if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { if (ff_get_extradata(codec, pb, avio_rb32(pb)) < 0) return AVERROR(ENOMEM); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/ffmenc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/ffmenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/ffmenc.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/ffmenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -268,7 +268,7 @@ avio_wb32(pb, codec->flags); avio_wb32(pb, codec->flags2); avio_wb32(pb, codec->debug); - if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) { + if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { avio_wb32(pb, codec->extradata_size); avio_write(pb, codec->extradata, codec->extradata_size); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/file.c ffmpeg-2.7.2~trusty~ppa1/libavformat/file.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/file.c 2015-06-18 18:55:02.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/file.c 2015-06-22 17:20:02.000000000 +0000 @@ -131,6 +131,42 @@ return ret; } +static int file_delete(URLContext *h) +{ +#if HAVE_UNISTD_H + int ret; + const char *filename = h->filename; + av_strstart(filename, "file:", &filename); + + ret = rmdir(filename); + if (ret < 0 && errno == ENOTDIR) + ret = unlink(filename); + if (ret < 0) + return AVERROR(errno); + + return ret; +#else + return AVERROR(ENOSYS); +#endif /* HAVE_UNISTD_H */ +} + +static int file_move(URLContext *h_src, URLContext *h_dst) +{ +#if HAVE_UNISTD_H + const char *filename_src = h_src->filename; + const char *filename_dst = h_dst->filename; + av_strstart(filename_src, "file:", &filename_src); + av_strstart(filename_dst, "file:", &filename_src); + + if (rename(filename_src, filename_dst) < 0) + return AVERROR(errno); + + return 0; +#else + return AVERROR(ENOSYS); +#endif /* HAVE_UNISTD_H */ +} + #if CONFIG_FILE_PROTOCOL static int file_open(URLContext *h, const char *filename, int flags) @@ -198,6 +234,8 @@ .url_close = file_close, .url_get_file_handle = file_get_handle, .url_check = file_check, + .url_delete = file_delete, + .url_move = file_move, .priv_data_size = sizeof(FileContext), .priv_data_class = &file_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/flacdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/flacdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/flacdec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/flacdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -58,7 +58,7 @@ case FLAC_METADATA_TYPE_CUESHEET: case FLAC_METADATA_TYPE_PICTURE: case FLAC_METADATA_TYPE_VORBIS_COMMENT: - buffer = av_mallocz(metadata_size + FF_INPUT_BUFFER_PADDING_SIZE); + buffer = av_mallocz(metadata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!buffer) { return AVERROR(ENOMEM); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/flac_picture.c ffmpeg-2.7.2~trusty~ppa1/libavformat/flac_picture.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/flac_picture.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/flac_picture.c 2015-07-28 17:20:07.000000000 +0000 @@ -108,10 +108,10 @@ ret = AVERROR_INVALIDDATA; goto fail; } - if (!(data = av_buffer_alloc(len + FF_INPUT_BUFFER_PADDING_SIZE))) { + if (!(data = av_buffer_alloc(len + AV_INPUT_BUFFER_PADDING_SIZE))) { RETURN_ERROR(AVERROR(ENOMEM)); } - memset(data->data + len, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(data->data + len, 0, AV_INPUT_BUFFER_PADDING_SIZE); if (avio_read(pb, data->data, len) != len) { av_log(s, AV_LOG_ERROR, "Error reading attached picture data.\n"); if (s->error_recognition & AV_EF_EXPLODE) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/flvdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/flvdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/flvdec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/flvdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -654,7 +654,7 @@ { av_free(flv->new_extradata[stream]); flv->new_extradata[stream] = av_mallocz(size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!flv->new_extradata[stream]) return AVERROR(ENOMEM); flv->new_extradata_size[stream] = size; @@ -789,7 +789,8 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) { FLVContext *flv = s->priv_data; - int ret, i, type, size, flags; + int ret, i, size, flags; + enum FlvTagType type; int stream_type=-1; int64_t next, pos, meta_pos; int64_t dts, pts = AV_NOPTS_VALUE; @@ -896,8 +897,9 @@ } av_log(s, AV_LOG_TRACE, "%d %X %d \n", stream_type, flags, st->discard); - if ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || - stream_type == FLV_STREAM_TYPE_AUDIO) + if (s->pb->seekable && + ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || + stream_type == FLV_STREAM_TYPE_AUDIO)) av_add_index_entry(st, pos, dts, size, 0, AVINDEX_KEYFRAME); if ( (st->discard >= AVDISCARD_NONKEY && !((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || (stream_type == FLV_STREAM_TYPE_AUDIO))) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/flv.h ffmpeg-2.7.2~trusty~ppa1/libavformat/flv.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/flv.h 2015-03-13 17:34:50.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/flv.h 2015-06-13 17:20:02.000000000 +0000 @@ -56,7 +56,7 @@ FLV_HEADER_FLAG_HASAUDIO = 4, }; -enum { +enum FlvTagType { FLV_TAG_TYPE_AUDIO = 0x08, FLV_TAG_TYPE_VIDEO = 0x09, FLV_TAG_TYPE_META = 0x12, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/hevc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/hevc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/hevc.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/hevc.c 2015-07-28 17:20:07.000000000 +0000 @@ -644,7 +644,7 @@ uint8_t *dst; uint32_t i, len; - dst = av_malloc(src_len); + dst = av_malloc(src_len + AV_INPUT_BUFFER_PADDING_SIZE); if (!dst) return NULL; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/hls.c ffmpeg-2.7.2~trusty~ppa1/libavformat/hls.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/hls.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/hls.c 2015-07-30 17:20:02.000000000 +0000 @@ -182,6 +182,7 @@ char *user_agent; ///< holds HTTP user agent set as an AVOption to the HTTP protocol context char *cookies; ///< holds HTTP cookie values set in either the initial response or as an AVOption to the HTTP protocol context char *headers; ///< holds HTTP headers set as an AVOption to the HTTP protocol context + AVDictionary *avio_opts; } HLSContext; static int read_chomp_line(AVIOContext *s, char *buf, int maxlen) @@ -494,6 +495,53 @@ /* pls = NULL => Master Playlist or parentless Media Playlist * pls = !NULL => parented Media Playlist, playlist+variant allocated */ +static int open_in(HLSContext *c, AVIOContext **in, const char *url) +{ + AVDictionary *tmp = NULL; + int ret; + + av_dict_copy(&tmp, c->avio_opts, 0); + + ret = avio_open2(in, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp); + + av_dict_free(&tmp); + return ret; +} + +static int url_connect(struct playlist *pls, AVDictionary *opts, AVDictionary *opts2) +{ + AVDictionary *tmp = NULL; + int ret; + + av_dict_copy(&tmp, opts, 0); + av_dict_copy(&tmp, opts2, 0); + + av_opt_set_dict(pls->input, &tmp); + + if ((ret = ffurl_connect(pls->input, NULL)) < 0) { + ffurl_close(pls->input); + pls->input = NULL; + } + + av_dict_free(&tmp); + return ret; +} + +static int open_url(HLSContext *c, URLContext **uc, const char *url, AVDictionary *opts) +{ + AVDictionary *tmp = NULL; + int ret; + + av_dict_copy(&tmp, c->avio_opts, 0); + av_dict_copy(&tmp, opts, 0); + + ret = ffurl_open(uc, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp); + + av_dict_free(&tmp); + + return ret; +} + static int parse_playlist(HLSContext *c, const char *url, struct playlist *pls, AVIOContext *in) { @@ -513,6 +561,7 @@ char tmp_str[MAX_URL_SIZE]; if (!in) { +#if 1 AVDictionary *opts = NULL; close_in = 1; /* Some HLS servers don't like being sent the range header */ @@ -528,6 +577,12 @@ av_dict_free(&opts); if (ret < 0) return ret; +#else + ret = open_in(c, &in, url); + if (ret < 0) + return ret; + close_in = 1; +#endif } if (av_opt_get(in, "location", AV_OPT_SEARCH_CHILDREN, &new_url) >= 0) @@ -752,7 +807,7 @@ if (apic) { int size = pls->ctx->streams[1]->attached_pic.size; - if (size != apic->buf->size - FF_INPUT_BUFFER_PADDING_SIZE) + if (size != apic->buf->size - AV_INPUT_BUFFER_PADDING_SIZE) return 1; if (memcmp(apic->buf->data, pls->ctx->streams[1]->attached_pic.data, size) != 0) @@ -940,15 +995,13 @@ seg->url, seg->url_offset, pls->index); if (seg->key_type == KEY_NONE) { - ret = ffurl_open(&pls->input, seg->url, AVIO_FLAG_READ, - &pls->parent->interrupt_callback, &opts); - + ret = open_url(pls->parent->priv_data, &pls->input, seg->url, opts); } else if (seg->key_type == KEY_AES_128) { +// HLSContext *c = var->parent->priv_data; char iv[33], key[33], url[MAX_URL_SIZE]; if (strcmp(seg->key, pls->key_url)) { URLContext *uc; - if (ffurl_open(&uc, seg->key, AVIO_FLAG_READ, - &pls->parent->interrupt_callback, &opts2) == 0) { + if (open_url(pls->parent->priv_data, &uc, seg->key, opts2) == 0) { if (ffurl_read_complete(uc, pls->key, sizeof(pls->key)) != sizeof(pls->key)) { av_log(NULL, AV_LOG_ERROR, "Unable to read key file %s\n", @@ -970,15 +1023,14 @@ snprintf(url, sizeof(url), "crypto+%s", seg->url); else snprintf(url, sizeof(url), "crypto:%s", seg->url); + if ((ret = ffurl_alloc(&pls->input, url, AVIO_FLAG_READ, &pls->parent->interrupt_callback)) < 0) goto cleanup; av_opt_set(pls->input->priv_data, "key", key, 0); av_opt_set(pls->input->priv_data, "iv", iv, 0); - if ((ret = ffurl_connect(pls->input, &opts)) < 0) { - ffurl_close(pls->input); - pls->input = NULL; + if ((ret = url_connect(pls, c->avio_opts, opts)) < 0) { goto cleanup; } ret = 0; @@ -1085,6 +1137,8 @@ ret = open_input(c, v); if (ret < 0) { + if (ff_check_interrupt(c->interrupt_callback)) + return AVERROR_EXIT; av_log(v->parent, AV_LOG_WARNING, "Failed to open segment of playlist %d\n", v->index); v->cur_seq_no += 1; @@ -1252,6 +1306,26 @@ return pls->start_seq_no; } +static int save_avio_options(AVFormatContext *s) +{ + HLSContext *c = s->priv_data; + const char *opts[] = { "headers", "user_agent", "user-agent", "cookies", NULL }, **opt = opts; + uint8_t *buf; + int ret = 0; + + while (*opt) { + if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0) { + ret = av_dict_set(&c->avio_opts, *opt, buf, + AV_DICT_DONT_STRDUP_VAL); + if (ret < 0) + return ret; + } + opt++; + } + + return ret; +} + static int hls_read_header(AVFormatContext *s) { URLContext *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb->opaque; @@ -1279,6 +1353,12 @@ if ((ret = parse_playlist(c, s->filename, NULL, s->pb)) < 0) goto fail; + if ((ret = save_avio_options(s)) < 0) + goto fail; + + /* Some HLS servers don't like being sent the range header */ + av_dict_set(&c->avio_opts, "seekable", "0", 0); + if (c->n_variants == 0) { av_log(NULL, AV_LOG_WARNING, "Empty playlist\n"); ret = AVERROR_EOF; @@ -1629,6 +1709,9 @@ free_playlist_list(c); free_variant_list(c); free_rendition_list(c); + + av_dict_free(&c->avio_opts); + return 0; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/hlsenc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/hlsenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/hlsenc.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/hlsenc.c 2015-07-27 17:20:04.000000000 +0000 @@ -37,12 +37,19 @@ #include "internal.h" #include "os_support.h" +#define KEYSIZE 16 +#define LINE_BUFFER_SIZE 1024 + typedef struct HLSSegment { char filename[1024]; + char sub_filename[1024]; double duration; /* in seconds */ int64_t pos; int64_t size; + char key_uri[LINE_BUFFER_SIZE + 1]; + char iv_string[KEYSIZE*2 + 1]; + struct HLSSegment *next; } HLSSegment; @@ -61,8 +68,10 @@ int64_t sequence; int64_t start_sequence; AVOutputFormat *oformat; + AVOutputFormat *vtt_oformat; AVFormatContext *avf; + AVFormatContext *vtt_avf; float time; // Set by a private option. int max_nb_segments; // Set by a private option. @@ -73,6 +82,7 @@ int allowcache; int64_t recording_time; int has_video; + int has_subtitle; int64_t start_pts; int64_t end_pts; double duration; // last segment duration computed so far, in seconds @@ -86,17 +96,29 @@ HLSSegment *old_segments; char *basename; + char *vtt_basename; + char *vtt_m3u8_name; char *baseurl; char *format_options_str; + char *vtt_format_options_str; + char *subtitle_filename; AVDictionary *format_options; + + char *key_info_file; + char key_file[LINE_BUFFER_SIZE + 1]; + char key_uri[LINE_BUFFER_SIZE + 1]; + char key_string[KEYSIZE*2 + 1]; + char iv_string[KEYSIZE*2 + 1]; + AVDictionary *vtt_format_options; + } HLSContext; static int hls_delete_old_segments(HLSContext *hls) { HLSSegment *segment, *previous_segment = NULL; float playlist_duration = 0.0f; - int ret = 0, path_size; - char *dirname = NULL, *p, *path; + int ret = 0, path_size, sub_path_size; + char *dirname = NULL, *p, *path, *sub_path; segment = hls->segments; while (segment) { @@ -138,13 +160,28 @@ ret = AVERROR(ENOMEM); goto fail; } + sub_path_size = strlen(dirname) + strlen(segment->sub_filename) + 1; + sub_path = av_malloc(sub_path_size); + if (!sub_path) { + ret = AVERROR(ENOMEM); + goto fail; + } + av_strlcpy(path, dirname, path_size); av_strlcat(path, segment->filename, path_size); if (unlink(path) < 0) { av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n", path, strerror(errno)); } + + av_strlcpy(sub_path, dirname, sub_path_size); + av_strlcat(sub_path, segment->sub_filename, sub_path_size); + if (unlink(sub_path) < 0) { + av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n", + sub_path, strerror(errno)); + } av_free(path); + av_free(sub_path); previous_segment = segment; segment = previous_segment->next; av_free(previous_segment); @@ -156,10 +193,65 @@ return ret; } +static int hls_encryption_start(AVFormatContext *s) +{ + HLSContext *hls = s->priv_data; + int ret; + AVIOContext *pb; + uint8_t key[KEYSIZE]; + + if ((ret = avio_open2(&pb, hls->key_info_file, AVIO_FLAG_READ, + &s->interrupt_callback, NULL)) < 0) { + av_log(hls, AV_LOG_ERROR, + "error opening key info file %s\n", hls->key_info_file); + return ret; + } + + ff_get_line(pb, hls->key_uri, sizeof(hls->key_uri)); + hls->key_uri[strcspn(hls->key_uri, "\r\n")] = '\0'; + + ff_get_line(pb, hls->key_file, sizeof(hls->key_file)); + hls->key_file[strcspn(hls->key_file, "\r\n")] = '\0'; + + ff_get_line(pb, hls->iv_string, sizeof(hls->iv_string)); + hls->iv_string[strcspn(hls->iv_string, "\r\n")] = '\0'; + + avio_close(pb); + + if (!*hls->key_uri) { + av_log(hls, AV_LOG_ERROR, "no key URI specified in key info file\n"); + return AVERROR(EINVAL); + } + + if (!*hls->key_file) { + av_log(hls, AV_LOG_ERROR, "no key file specified in key info file\n"); + return AVERROR(EINVAL); + } + + if ((ret = avio_open2(&pb, hls->key_file, AVIO_FLAG_READ, + &s->interrupt_callback, NULL)) < 0) { + av_log(hls, AV_LOG_ERROR, "error opening key file %s\n", hls->key_file); + return ret; + } + + ret = avio_read(pb, key, sizeof(key)); + avio_close(pb); + if (ret != sizeof(key)) { + av_log(hls, AV_LOG_ERROR, "error reading key file %s\n", hls->key_file); + if (ret >= 0 || ret == AVERROR_EOF) + ret = AVERROR(EINVAL); + return ret; + } + ff_data_to_hex(hls->key_string, key, sizeof(key), 0); + + return 0; +} + static int hls_mux_init(AVFormatContext *s) { HLSContext *hls = s->priv_data; AVFormatContext *oc; + AVFormatContext *vtt_oc; int i, ret; ret = avformat_alloc_output_context2(&hls->avf, hls->oformat, NULL, NULL); @@ -172,9 +264,24 @@ oc->max_delay = s->max_delay; av_dict_copy(&oc->metadata, s->metadata, 0); + if(hls->vtt_oformat) { + ret = avformat_alloc_output_context2(&hls->vtt_avf, hls->vtt_oformat, NULL, NULL); + if (ret < 0) + return ret; + vtt_oc = hls->vtt_avf; + vtt_oc->oformat = hls->vtt_oformat; + av_dict_copy(&vtt_oc->metadata, s->metadata, 0); + } + for (i = 0; i < s->nb_streams; i++) { AVStream *st; - if (!(st = avformat_new_stream(oc, NULL))) + AVFormatContext *loc; + if (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) + loc = vtt_oc; + else + loc = oc; + + if (!(st = avformat_new_stream(loc, NULL))) return AVERROR(ENOMEM); avcodec_copy_context(st->codec, s->streams[i]->codec); st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio; @@ -197,11 +304,19 @@ av_strlcpy(en->filename, av_basename(hls->avf->filename), sizeof(en->filename)); + if(hls->has_subtitle) + av_strlcpy(en->sub_filename, av_basename(hls->vtt_avf->filename), sizeof(en->sub_filename)); + en->duration = duration; en->pos = pos; en->size = size; en->next = NULL; + if (hls->key_info_file) { + av_strlcpy(en->key_uri, hls->key_uri, sizeof(en->key_uri)); + av_strlcpy(en->iv_string, hls->iv_string, sizeof(en->iv_string)); + } + if (!hls->segments) hls->segments = en; else @@ -246,12 +361,15 @@ int target_duration = 0; int ret = 0; AVIOContext *out = NULL; + AVIOContext *sub_out = NULL; char temp_filename[1024]; int64_t sequence = FFMAX(hls->start_sequence, hls->sequence - hls->nb_entries); int version = hls->flags & HLS_SINGLE_FILE ? 4 : 3; const char *proto = avio_find_protocol_name(s->filename); int use_rename = proto && !strcmp(proto, "file"); static unsigned warned_non_file; + char *key_uri = NULL; + char *iv_string = NULL; if (!use_rename && !warned_non_file++) av_log(s, AV_LOG_ERROR, "Cannot use rename on non file protocol, this may lead to races and temporarly partial files\n"); @@ -282,6 +400,16 @@ hls->discontinuity_set = 1; } for (en = hls->segments; en; en = en->next) { + if (hls->key_info_file && (!key_uri || strcmp(en->key_uri, key_uri) || + av_strcasecmp(en->iv_string, iv_string))) { + avio_printf(out, "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", en->key_uri); + if (*en->iv_string) + avio_printf(out, ",IV=0x%s", en->iv_string); + avio_printf(out, "\n"); + key_uri = en->key_uri; + iv_string = en->iv_string; + } + if (hls->flags & HLS_ROUND_DURATIONS) avio_printf(out, "#EXTINF:%d,\n", (int)round(en->duration)); else @@ -297,8 +425,39 @@ if (last && (hls->flags & HLS_OMIT_ENDLIST)==0) avio_printf(out, "#EXT-X-ENDLIST\n"); + if( hls->vtt_m3u8_name ) { + if ((ret = avio_open2(&sub_out, hls->vtt_m3u8_name, AVIO_FLAG_WRITE, + &s->interrupt_callback, NULL)) < 0) + goto fail; + avio_printf(sub_out, "#EXTM3U\n"); + avio_printf(sub_out, "#EXT-X-VERSION:%d\n", version); + if (hls->allowcache == 0 || hls->allowcache == 1) { + avio_printf(sub_out, "#EXT-X-ALLOW-CACHE:%s\n", hls->allowcache == 0 ? "NO" : "YES"); + } + avio_printf(sub_out, "#EXT-X-TARGETDURATION:%d\n", target_duration); + avio_printf(sub_out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence); + + av_log(s, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", + sequence); + + for (en = hls->segments; en; en = en->next) { + avio_printf(sub_out, "#EXTINF:%f,\n", en->duration); + if (hls->flags & HLS_SINGLE_FILE) + avio_printf(sub_out, "#EXT-X-BYTERANGE:%"PRIi64"@%"PRIi64"\n", + en->size, en->pos); + if (hls->baseurl) + avio_printf(sub_out, "%s", hls->baseurl); + avio_printf(sub_out, "%s\n", en->sub_filename); + } + + if (last) + avio_printf(sub_out, "#EXT-X-ENDLIST\n"); + + } + fail: avio_closep(&out); + avio_closep(&sub_out); if (ret >= 0 && use_rename) ff_rename(temp_filename, s->filename, s); return ret; @@ -308,26 +467,72 @@ { HLSContext *c = s->priv_data; AVFormatContext *oc = c->avf; + AVFormatContext *vtt_oc = c->vtt_avf; + AVDictionary *options = NULL; + char *filename, iv_string[KEYSIZE*2 + 1]; int err = 0; - if (c->flags & HLS_SINGLE_FILE) + if (c->flags & HLS_SINGLE_FILE) { av_strlcpy(oc->filename, c->basename, sizeof(oc->filename)); - else + if (c->vtt_basename) + av_strlcpy(vtt_oc->filename, c->vtt_basename, + sizeof(vtt_oc->filename)); + } else { if (av_get_frame_filename(oc->filename, sizeof(oc->filename), c->basename, c->wrap ? c->sequence % c->wrap : c->sequence) < 0) { av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", c->basename); return AVERROR(EINVAL); } + if( c->vtt_basename) { + if (av_get_frame_filename(vtt_oc->filename, sizeof(vtt_oc->filename), + c->vtt_basename, c->wrap ? c->sequence % c->wrap : c->sequence) < 0) { + av_log(vtt_oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", c->vtt_basename); + return AVERROR(EINVAL); + } + } + } c->number++; - if ((err = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE, + if (c->key_info_file) { + if ((err = hls_encryption_start(s)) < 0) + return err; + if ((err = av_dict_set(&options, "encryption_key", c->key_string, 0)) + < 0) + return err; + err = av_strlcpy(iv_string, c->iv_string, sizeof(iv_string)); + if (!err) + snprintf(iv_string, sizeof(iv_string), "%032"PRIx64, c->sequence); + if ((err = av_dict_set(&options, "encryption_iv", iv_string, 0)) < 0) + return err; + + filename = av_asprintf("crypto:%s", oc->filename); + if (!filename) { + av_dict_free(&options); + return AVERROR(ENOMEM); + } + err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE, + &s->interrupt_callback, &options); + av_free(filename); + av_dict_free(&options); + if (err < 0) + return err; + } else + if ((err = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL)) < 0) - return err; + return err; + if (c->vtt_basename) { + if ((err = avio_open2(&vtt_oc->pb, vtt_oc->filename, AVIO_FLAG_WRITE, + &s->interrupt_callback, NULL)) < 0) + return err; + } if (oc->oformat->priv_class && oc->priv_data) av_opt_set(oc->priv_data, "mpegts_flags", "resend_headers", 0); + if (c->vtt_basename) + avformat_write_header(vtt_oc,NULL); + return 0; } @@ -337,8 +542,10 @@ int ret, i; char *p; const char *pattern = "%d.ts"; + const char *vtt_pattern = "%d.vtt"; AVDictionary *options = NULL; int basename_size; + int vtt_basename_size; hls->sequence = hls->start_sequence; hls->recording_time = hls->time * AV_TIME_BASE; @@ -352,9 +559,12 @@ } } - for (i = 0; i < s->nb_streams; i++) + for (i = 0; i < s->nb_streams; i++) { hls->has_video += s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO; + hls->has_subtitle += + s->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE; + } if (hls->has_video > 1) av_log(s, AV_LOG_WARNING, @@ -368,6 +578,14 @@ goto fail; } + if(hls->has_subtitle) { + hls->vtt_oformat = av_guess_format("webvtt", NULL, NULL); + if (!hls->oformat) { + ret = AVERROR_MUXER_NOT_FOUND; + goto fail; + } + } + if (hls->segment_filename) { hls->basename = av_strdup(hls->segment_filename); if (!hls->basename) { @@ -393,6 +611,35 @@ av_strlcat(hls->basename, pattern, basename_size); } + if(hls->has_subtitle) { + + if (hls->flags & HLS_SINGLE_FILE) + vtt_pattern = ".vtt"; + vtt_basename_size = strlen(s->filename) + strlen(vtt_pattern) + 1; + hls->vtt_basename = av_malloc(vtt_basename_size); + if (!hls->vtt_basename) { + ret = AVERROR(ENOMEM); + goto fail; + } + hls->vtt_m3u8_name = av_malloc(vtt_basename_size); + if (!hls->vtt_m3u8_name ) { + ret = AVERROR(ENOMEM); + goto fail; + } + av_strlcpy(hls->vtt_basename, s->filename, vtt_basename_size); + p = strrchr(hls->vtt_basename, '.'); + if (p) + *p = '\0'; + + if( hls->subtitle_filename ) { + strcpy(hls->vtt_m3u8_name, hls->subtitle_filename); + } else { + strcpy(hls->vtt_m3u8_name, hls->vtt_basename); + av_strlcat(hls->vtt_m3u8_name, "_vtt.m3u8", vtt_basename_size); + } + av_strlcat(hls->vtt_basename, vtt_pattern, vtt_basename_size); + } + if ((ret = hls_mux_init(s)) < 0) goto fail; @@ -406,10 +653,19 @@ ret = AVERROR(EINVAL); goto fail; } - av_assert0(s->nb_streams == hls->avf->nb_streams); + //av_assert0(s->nb_streams == hls->avf->nb_streams); for (i = 0; i < s->nb_streams; i++) { - AVStream *inner_st = hls->avf->streams[i]; + AVStream *inner_st; AVStream *outer_st = s->streams[i]; + if (outer_st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) + inner_st = hls->avf->streams[i]; + else if (hls->vtt_avf) + inner_st = hls->vtt_avf->streams[0]; + else { + /* We have a subtitle stream, when the user does not want one */ + inner_st = NULL; + continue; + } avpriv_set_pts_info(outer_st, inner_st->pts_wrap_bits, inner_st->time_base.num, inner_st->time_base.den); } fail: @@ -417,8 +673,12 @@ av_dict_free(&options); if (ret < 0) { av_freep(&hls->basename); + av_freep(&hls->vtt_basename); if (hls->avf) avformat_free_context(hls->avf); + if (hls->vtt_avf) + avformat_free_context(hls->vtt_avf); + } return ret; } @@ -426,12 +686,20 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) { HLSContext *hls = s->priv_data; - AVFormatContext *oc = hls->avf; + AVFormatContext *oc = NULL; AVStream *st = s->streams[pkt->stream_index]; int64_t end_pts = hls->recording_time * hls->number; int is_ref_pkt = 1; int ret, can_split = 1; + int stream_index = 0; + if( st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE ) { + oc = hls->vtt_avf; + stream_index = 0; + } else { + oc = hls->avf; + stream_index = pkt->stream_index; + } if (hls->start_pts == AV_NOPTS_VALUE) { hls->start_pts = pkt->pts; hls->end_pts = pkt->pts; @@ -470,6 +738,8 @@ hls->number++; } else { avio_closep(&oc->pb); + if (hls->vtt_avf) + avio_close(hls->vtt_avf->pb); ret = hls_start(s); } @@ -477,13 +747,16 @@ if (ret < 0) return ret; + if( st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE ) + oc = hls->vtt_avf; + else oc = hls->avf; if ((ret = hls_window(s, 0)) < 0) return ret; } - ret = ff_write_chained(oc, pkt->stream_index, pkt, s, 0); + ret = ff_write_chained(oc, stream_index, pkt, s, 0); return ret; } @@ -492,6 +765,7 @@ { HLSContext *hls = s->priv_data; AVFormatContext *oc = hls->avf; + AVFormatContext *vtt_oc = hls->vtt_avf; av_write_trailer(oc); if (oc->pb) { @@ -499,8 +773,22 @@ avio_closep(&oc->pb); hls_append_segment(hls, hls->duration, hls->start_pos, hls->size); } + + if (vtt_oc) { + if (vtt_oc->pb) + av_write_trailer(vtt_oc); + hls->size = avio_tell(hls->vtt_avf->pb) - hls->start_pos; + avio_closep(&vtt_oc->pb); + } av_freep(&hls->basename); avformat_free_context(oc); + + if (vtt_oc) { + av_freep(&hls->vtt_basename); + av_freep(&hls->vtt_m3u8_name); + avformat_free_context(vtt_oc); + } + hls->avf = NULL; hls_window(s, 1); @@ -516,10 +804,13 @@ {"hls_time", "set segment length in seconds", OFFSET(time), AV_OPT_TYPE_FLOAT, {.dbl = 2}, 0, FLT_MAX, E}, {"hls_list_size", "set maximum number of playlist entries", OFFSET(max_nb_segments), AV_OPT_TYPE_INT, {.i64 = 5}, 0, INT_MAX, E}, {"hls_ts_options","set hls mpegts list of options for the container format used for hls", OFFSET(format_options_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, + {"hls_vtt_options","set hls vtt list of options for the container format used for hls", OFFSET(vtt_format_options_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, {"hls_wrap", "set number after which the index wraps", OFFSET(wrap), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E}, {"hls_allow_cache", "explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments", OFFSET(allowcache), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, E}, {"hls_base_url", "url to prepend to each playlist entry", OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, {"hls_segment_filename", "filename template for segment files", OFFSET(segment_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, + {"hls_key_info_file", "file with key URI and key file path", OFFSET(key_info_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, + {"hls_subtitle_path", "set path of hls subtitles", OFFSET(subtitle_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, {"hls_flags", "set flags affecting HLS playlist and media file generation", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0 }, 0, UINT_MAX, E, "flags"}, {"single_file", "generate a single media file indexed with byte ranges", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SINGLE_FILE }, 0, UINT_MAX, E, "flags"}, {"delete_segments", "delete segment files that are no longer part of the playlist", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_DELETE_SEGMENTS }, 0, UINT_MAX, E, "flags"}, @@ -545,6 +836,7 @@ .priv_data_size = sizeof(HLSContext), .audio_codec = AV_CODEC_ID_AAC, .video_codec = AV_CODEC_ID_H264, + .subtitle_codec = AV_CODEC_ID_WEBVTT, .flags = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH, .write_header = hls_write_header, .write_packet = hls_write_packet, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/http.c ffmpeg-2.7.2~trusty~ppa1/libavformat/http.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/http.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/http.c 2015-08-01 17:20:02.000000000 +0000 @@ -25,6 +25,7 @@ #include #endif /* CONFIG_ZLIB */ +#include "libavutil/avassert.h" #include "libavutil/avstring.h" #include "libavutil/opt.h" @@ -44,6 +45,14 @@ * path names). */ #define BUFFER_SIZE MAX_URL_SIZE #define MAX_REDIRECTS 8 +#define HTTP_SINGLE 1 +#define HTTP_MUTLI 2 +typedef enum { + LOWER_PROTO, + READ_HEADERS, + WRITE_REPLY_HEADERS, + FINISH +}HandshakeState; typedef struct HTTPContext { const AVClass *class; @@ -97,6 +106,11 @@ char *method; int reconnect; int listen; + char *resource; + int reply_code; + int is_multi_client; + HandshakeState handshake_step; + int is_connected_server; } HTTPContext; #define OFFSET(x) offsetof(HTTPContext, x) @@ -128,7 +142,9 @@ { "end_offset", "try to limit the request to bytes preceding this offset", OFFSET(end_off), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT64_MAX, D }, { "method", "Override the HTTP method or set the expected HTTP method from a client", OFFSET(method), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, { "reconnect", "auto reconnect after disconnect before EOF", OFFSET(reconnect), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, D }, - { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, D | E }, + { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, D | E }, + { "resource", "The resource requested by a client", OFFSET(resource), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E }, + { "reply_code", "The http status code to return to a client", OFFSET(reply_code), AV_OPT_TYPE_INT, { .i64 = 200}, INT_MIN, 599, E}, { NULL } }; @@ -299,50 +315,143 @@ return default_averror; } -static void handle_http_errors(URLContext *h, int error) +static int http_write_reply(URLContext* h, int status_code) { - static const char bad_request[] = "HTTP/1.1 400 Bad Request\r\nContent-Type: text/plain\r\n\r\n400 Bad Request\r\n"; - static const char internal_server_error[] = "HTTP/1.1 500 Internal server error\r\nContent-Type: text/plain\r\n\r\n500 Internal server error\r\n"; + int ret, body = 0, reply_code, message_len; + const char *reply_text, *content_type; HTTPContext *s = h->priv_data; - if (h->is_connected) { - switch(error) { - case AVERROR_HTTP_BAD_REQUEST: - ffurl_write(s->hd, bad_request, strlen(bad_request)); - break; - default: - av_log(h, AV_LOG_ERROR, "Unhandled HTTP error.\n"); - ffurl_write(s->hd, internal_server_error, strlen(internal_server_error)); + char message[BUFFER_SIZE]; + content_type = "text/plain"; + + if (status_code < 0) + body = 1; + switch (status_code) { + case AVERROR_HTTP_BAD_REQUEST: + case 400: + reply_code = 400; + reply_text = "Bad Request"; + break; + case AVERROR_HTTP_FORBIDDEN: + case 403: + reply_code = 403; + reply_text = "Forbidden"; + break; + case AVERROR_HTTP_NOT_FOUND: + case 404: + reply_code = 404; + reply_text = "Not Found"; + break; + case 200: + reply_code = 200; + reply_text = "OK"; + content_type = "application/octet-stream"; + break; + case AVERROR_HTTP_SERVER_ERROR: + case 500: + reply_code = 500; + reply_text = "Internal server error"; + break; + default: + return AVERROR(EINVAL); + } + if (body) { + s->chunked_post = 0; + message_len = snprintf(message, sizeof(message), + "HTTP/1.1 %03d %s\r\n" + "Content-Type: %s\r\n" + "Content-Length: %zu\r\n" + "\r\n" + "%03d %s\r\n", + reply_code, + reply_text, + content_type, + strlen(reply_text) + 6, // 3 digit status code + space + \r\n + reply_code, + reply_text); + } else { + s->chunked_post = 1; + message_len = snprintf(message, sizeof(message), + "HTTP/1.1 %03d %s\r\n" + "Content-Type: %s\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n", + reply_code, + reply_text, + content_type); + } + av_log(h, AV_LOG_TRACE, "HTTP reply header: \n%s----\n", message); + if ((ret = ffurl_write(s->hd, message, message_len)) < 0) + return ret; + return 0; +} + +static void handle_http_errors(URLContext *h, int error) +{ + av_assert0(error < 0); + http_write_reply(h, error); +} + +static int http_handshake(URLContext *c) +{ + int ret, err, new_location; + HTTPContext *ch = c->priv_data; + URLContext *cl = ch->hd; + switch (ch->handshake_step) { + case LOWER_PROTO: + av_log(c, AV_LOG_TRACE, "Lower protocol\n"); + if ((ret = ffurl_handshake(cl) > 0)) + return 2 + ret; + if ((ret < 0)) + return ret; + ch->handshake_step = READ_HEADERS; + ch->is_connected_server = 1; + return 2; + case READ_HEADERS: + av_log(c, AV_LOG_TRACE, "Read headers\n"); + if ((err = http_read_header(c, &new_location)) < 0) { + handle_http_errors(c, err); + return err; } + ch->handshake_step = WRITE_REPLY_HEADERS; + return 1; + case WRITE_REPLY_HEADERS: + av_log(c, AV_LOG_TRACE, "Reply code: %d\n", ch->reply_code); + if ((err = http_write_reply(c, ch->reply_code)) < 0) + return err; + ch->handshake_step = FINISH; + return 1; + case FINISH: + return 0; } + // this should never be reached. + return AVERROR(EINVAL); } static int http_listen(URLContext *h, const char *uri, int flags, AVDictionary **options) { HTTPContext *s = h->priv_data; int ret; - static const char header[] = "HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nTransfer-Encoding: chunked\r\n\r\n"; char hostname[1024], proto[10]; char lower_url[100]; const char *lower_proto = "tcp"; - int port, new_location; + int port; av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri); if (!strcmp(proto, "https")) lower_proto = "tls"; ff_url_join(lower_url, sizeof(lower_url), lower_proto, NULL, hostname, port, NULL); - av_dict_set(options, "listen", "1", 0); + if ((ret = av_dict_set_int(options, "listen", s->listen, 0)) < 0) + goto fail; if ((ret = ffurl_open(&s->hd, lower_url, AVIO_FLAG_READ_WRITE, &h->interrupt_callback, options)) < 0) goto fail; - if ((ret = http_read_header(h, &new_location)) < 0) - goto fail; - if ((ret = ffurl_write(s->hd, header, strlen(header))) < 0) - goto fail; - return 0; - + s->handshake_step = LOWER_PROTO; + if (s->listen == HTTP_SINGLE) { /* single client */ + s->reply_code = 200; + while ((ret = http_handshake(h)) > 0); + } fail: - handle_http_errors(h, ret); av_dict_free(&s->chained_options); return ret; } @@ -367,9 +476,16 @@ if (s->headers) { int len = strlen(s->headers); - if (len < 2 || strcmp("\r\n", s->headers + len - 2)) + if (len < 2 || strcmp("\r\n", s->headers + len - 2)) { av_log(h, AV_LOG_WARNING, "No trailing CRLF found in HTTP header.\n"); + ret = av_reallocp(&s->headers, len + 3); + if (ret < 0) + return ret; + s->headers[len] = '\r'; + s->headers[len + 1] = '\n'; + s->headers[len + 2] = '\0'; + } } if (s->listen) { @@ -381,6 +497,26 @@ return ret; } +static int http_accept(URLContext *s, URLContext **c) +{ + int ret; + HTTPContext *sc = s->priv_data; + HTTPContext *cc; + URLContext *sl = sc->hd; + URLContext *cl = NULL; + + av_assert0(sc->listen); + if ((ret = ffurl_alloc(c, s->filename, s->flags, &sl->interrupt_callback)) < 0) + goto fail; + cc = (*c)->priv_data; + if ((ret = ffurl_accept(sl, &cl)) < 0) + goto fail; + cc->hd = cl; + cc->is_multi_client = 1; +fail: + return ret; +} + static int http_getc(HTTPContext *s) { int len; @@ -575,7 +711,7 @@ p = line; if (line_count == 0) { - if (s->listen) { + if (s->is_connected_server) { // HTTP method method = p; while (!av_isspace(*p)) @@ -596,6 +732,8 @@ "(%s autodetected %s received)\n", auto_method, method); return ff_http_averror(400, AVERROR(EIO)); } + if (!(s->method = av_strdup(method))) + return AVERROR(ENOMEM); } // HTTP resource @@ -606,6 +744,8 @@ p++; *(p++) = '\0'; av_log(h, AV_LOG_TRACE, "Requested resource: %s\n", resource); + if (!(s->resource = av_strdup(resource))) + return AVERROR(ENOMEM); // HTTP version while (av_isspace(*p)) @@ -1242,7 +1382,8 @@ HTTPContext *s = h->priv_data; /* signal end of chunked encoding if used */ - if ((flags & AVIO_FLAG_WRITE) && s->chunked_post) { + if (((flags & AVIO_FLAG_WRITE) && s->chunked_post) || + ((flags & AVIO_FLAG_READ) && s->chunked_post && s->listen)) { ret = ffurl_write(s->hd, footer, sizeof(footer) - 1); ret = ret > 0 ? 0 : ret; s->end_chunked_post = 1; @@ -1344,6 +1485,8 @@ URLProtocol ff_http_protocol = { .name = "http", .url_open2 = http_open, + .url_accept = http_accept, + .url_handshake = http_handshake, .url_read = http_read, .url_write = http_write, .url_seek = http_seek, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/id3v2.c ffmpeg-2.7.2~trusty~ppa1/libavformat/id3v2.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/id3v2.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/id3v2.c 2015-07-28 17:20:07.000000000 +0000 @@ -535,6 +535,13 @@ av_freep(&apic); } +static void rstrip_spaces(char *buf) +{ + size_t len = strlen(buf); + while (len > 0 && buf[len - 1] == ' ') + buf[--len] = 0; +} + static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen, const char *tag, ID3v2ExtraMeta **extra_meta, int isv34) @@ -598,16 +605,20 @@ goto fail; } - apic->buf = av_buffer_alloc(taglen + FF_INPUT_BUFFER_PADDING_SIZE); + apic->buf = av_buffer_alloc(taglen + AV_INPUT_BUFFER_PADDING_SIZE); if (!apic->buf || !taglen || avio_read(pb, apic->buf->data, taglen) != taglen) goto fail; - memset(apic->buf->data + taglen, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(apic->buf->data + taglen, 0, AV_INPUT_BUFFER_PADDING_SIZE); new_extra->tag = "APIC"; new_extra->data = apic; new_extra->next = *extra_meta; *extra_meta = new_extra; + // The description must be unique, and some ID3v2 tag writers add spaces + // to write several APIC entries with the same description. + rstrip_spaces(apic->description); + return; fail: @@ -1083,6 +1094,9 @@ st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = apic->id; + if (AV_RB64(apic->buf->data) == 0x89504e470d0a1a0a) + st->codec->codec_id = AV_CODEC_ID_PNG; + if (apic->description[0]) av_dict_set(&st->metadata, "title", apic->description, 0); @@ -1091,7 +1105,7 @@ av_init_packet(&st->attached_pic); st->attached_pic.buf = apic->buf; st->attached_pic.data = apic->buf->data; - st->attached_pic.size = apic->buf->size - FF_INPUT_BUFFER_PADDING_SIZE; + st->attached_pic.size = apic->buf->size - AV_INPUT_BUFFER_PADDING_SIZE; st->attached_pic.stream_index = st->index; st->attached_pic.flags |= AV_PKT_FLAG_KEY; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/iff.c ffmpeg-2.7.2~trusty~ppa1/libavformat/iff.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/iff.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/iff.c 2015-07-28 17:20:07.000000000 +0000 @@ -455,7 +455,7 @@ return AVERROR_INVALIDDATA; } st->codec->extradata_size = data_size + IFF_EXTRA_VIDEO_SIZE; - st->codec->extradata = av_malloc(data_size + IFF_EXTRA_VIDEO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); + st->codec->extradata = av_malloc(data_size + IFF_EXTRA_VIDEO_SIZE + AV_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); if (avio_read(pb, st->codec->extradata + IFF_EXTRA_VIDEO_SIZE, data_size) < 0) @@ -682,7 +682,7 @@ if (!st->codec->extradata) { st->codec->extradata_size = IFF_EXTRA_VIDEO_SIZE; - st->codec->extradata = av_malloc(IFF_EXTRA_VIDEO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); + st->codec->extradata = av_malloc(IFF_EXTRA_VIDEO_SIZE + AV_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/img2.c ffmpeg-2.7.2~trusty~ppa1/libavformat/img2.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/img2.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/img2.c 2015-06-23 17:20:03.000000000 +0000 @@ -45,6 +45,7 @@ { AV_CODEC_ID_PBM, "pbm" }, { AV_CODEC_ID_PAM, "pam" }, { AV_CODEC_ID_ALIAS_PIX, "pix" }, + { AV_CODEC_ID_DDS, "dds" }, { AV_CODEC_ID_MPEG1VIDEO, "mpg1-img" }, { AV_CODEC_ID_MPEG2VIDEO, "mpg2-img" }, { AV_CODEC_ID_MPEG4, "mpg4-img" }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/img2dec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/img2dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/img2dec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/img2dec.c 2015-06-29 17:20:04.000000000 +0000 @@ -609,6 +609,17 @@ return AVPROBE_SCORE_EXTENSION / 4; } +static int dds_probe(AVProbeData *p) +{ + const uint8_t *b = p->buf; + + if ( AV_RB64(b) == 0x444453207c000000 + && AV_RL32(b + 8) + && AV_RL32(b + 12)) + return AVPROBE_SCORE_MAX - 1; + return 0; +} + static int dpx_probe(AVProbeData *p) { const uint8_t *b = p->buf; @@ -714,9 +725,15 @@ { const uint8_t *b = p->buf; - if (!b[10] && AV_RB32(b+11) == 0x1102ff0c && !b[15] || - p->buf_size >= 528 && !b[522] && AV_RB32(b+523) == 0x1102ff0c && !b[527]) - return AVPROBE_SCORE_EXTENSION + 1; + if ( p->buf_size >= 528 + && (AV_RB64(b + 520) & 0xFFFFFFFFFFFF) == 0x001102ff0c00 + && AV_RB16(b + 520) + && AV_RB16(b + 518)) + return AVPROBE_SCORE_MAX * 3 / 4; + if ( (AV_RB64(b + 8) & 0xFFFFFFFFFFFF) == 0x001102ff0c00 + && AV_RB16(b + 8) + && AV_RB16(b + 6)) + return AVPROBE_SCORE_EXTENSION / 4; return 0; } @@ -799,6 +816,7 @@ }; IMAGEAUTO_DEMUXER(bmp, AV_CODEC_ID_BMP) +IMAGEAUTO_DEMUXER(dds, AV_CODEC_ID_DDS) IMAGEAUTO_DEMUXER(dpx, AV_CODEC_ID_DPX) IMAGEAUTO_DEMUXER(exr, AV_CODEC_ID_EXR) IMAGEAUTO_DEMUXER(j2k, AV_CODEC_ID_JPEG2000) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/internal.h ffmpeg-2.7.2~trusty~ppa1/libavformat/internal.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/internal.h 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/internal.h 2015-07-28 17:20:07.000000000 +0000 @@ -254,6 +254,8 @@ unsigned int *index_entries_allocated_size, int64_t pos, int64_t timestamp, int size, int distance, int flags); +void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance); + /** * Add a new chapter. * @@ -447,7 +449,7 @@ int size); /** - * Allocate extradata with additional FF_INPUT_BUFFER_PADDING_SIZE at end + * Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end * which is always set to 0. * * @param size size of extradata @@ -456,7 +458,7 @@ int ff_alloc_extradata(AVCodecContext *avctx, int size); /** - * Allocate extradata with additional FF_INPUT_BUFFER_PADDING_SIZE at end + * Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end * which is always set to 0 and fill it from pb. * * @param size size of extradata diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/ipmovie.c ffmpeg-2.7.2~trusty~ppa1/libavformat/ipmovie.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/ipmovie.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/ipmovie.c 2015-07-26 17:20:03.000000000 +0000 @@ -78,7 +78,7 @@ #define PALETTE_COUNT 256 typedef struct IPMVEContext { - + AVFormatContext *avf; unsigned char *buf; int buf_size; @@ -212,6 +212,31 @@ return chunk_type; } +static int init_audio(AVFormatContext *s) +{ + IPMVEContext *ipmovie = s->priv_data; + AVStream *st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + avpriv_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate); + ipmovie->audio_stream_index = st->index; + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; + st->codec->codec_id = ipmovie->audio_type; + st->codec->codec_tag = 0; /* no tag */ + st->codec->channels = ipmovie->audio_channels; + st->codec->channel_layout = st->codec->channels == 1 ? AV_CH_LAYOUT_MONO : + AV_CH_LAYOUT_STEREO; + st->codec->sample_rate = ipmovie->audio_sample_rate; + st->codec->bits_per_coded_sample = ipmovie->audio_bits; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_coded_sample; + if (st->codec->codec_id == AV_CODEC_ID_INTERPLAY_DPCM) + st->codec->bit_rate /= 2; + st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample; + + return 0; +} + /* This function loads and processes a single chunk in an IP movie file. * It returns the type of chunk that was processed. */ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, @@ -516,6 +541,9 @@ } } + if (s->avf->nb_streams == 1 && s->audio_type) + init_audio(s->avf); + /* make a note of where the stream is sitting */ s->next_chunk_offset = avio_tell(pb); @@ -551,6 +579,8 @@ int chunk_type, i; uint8_t signature_buffer[sizeof(signature)]; + ipmovie->avf = s; + avio_read(pb, signature_buffer, sizeof(signature_buffer)); while (memcmp(signature_buffer, signature, sizeof(signature))) { memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1); @@ -600,25 +630,9 @@ st->codec->bits_per_coded_sample = ipmovie->video_bpp; if (ipmovie->audio_type) { - st = avformat_new_stream(s, NULL); - if (!st) - return AVERROR(ENOMEM); - avpriv_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate); - ipmovie->audio_stream_index = st->index; - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_id = ipmovie->audio_type; - st->codec->codec_tag = 0; /* no tag */ - st->codec->channels = ipmovie->audio_channels; - st->codec->channel_layout = st->codec->channels == 1 ? AV_CH_LAYOUT_MONO : - AV_CH_LAYOUT_STEREO; - st->codec->sample_rate = ipmovie->audio_sample_rate; - st->codec->bits_per_coded_sample = ipmovie->audio_bits; - st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * - st->codec->bits_per_coded_sample; - if (st->codec->codec_id == AV_CODEC_ID_INTERPLAY_DPCM) - st->codec->bit_rate /= 2; - st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample; - } + return init_audio(s); + } else + s->ctx_flags |= AVFMTCTX_NOHEADER; return 0; } @@ -643,7 +657,7 @@ else if (ret == CHUNK_INIT_VIDEO || ret == CHUNK_INIT_AUDIO) continue; else - ret = -1; + continue; return ret; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/isom.c ffmpeg-2.7.2~trusty~ppa1/libavformat/isom.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/isom.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/isom.c 2015-07-27 17:20:04.000000000 +0000 @@ -110,7 +110,7 @@ { AV_CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') }, /* PhotoJPEG */ { AV_CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'a') }, /* Motion-JPEG (format A) */ - { AV_CODEC_ID_MJPEG, MKTAG('A', 'V', 'D', 'J') }, /* MJPEG with alpha-channel (AVID JFIF meridien compressed) */ + { AV_CODEC_ID_AVRN , MKTAG('A', 'V', 'D', 'J') }, /* MJPEG with alpha-channel (AVID JFIF meridien compressed) */ /* { AV_CODEC_ID_MJPEG, MKTAG('A', 'V', 'R', 'n') }, *//* MJPEG with alpha-channel (AVID ABVB/Truevision NuVista) */ { AV_CODEC_ID_MJPEG, MKTAG('d', 'm', 'b', '1') }, /* Motion JPEG OpenDML */ { AV_CODEC_ID_MJPEGB, MKTAG('m', 'j', 'p', 'b') }, /* Motion-JPEG (format B) */ @@ -258,6 +258,10 @@ { AV_CODEC_ID_AIC, MKTAG('i', 'c', 'o', 'd') }, + { AV_CODEC_ID_HAP, MKTAG('H', 'a', 'p', '1') }, + { AV_CODEC_ID_HAP, MKTAG('H', 'a', 'p', '5') }, + { AV_CODEC_ID_HAP, MKTAG('H', 'a', 'p', 'Y') }, + { AV_CODEC_ID_NONE, 0 }, }; @@ -447,19 +451,24 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb) { enum AVCodecID codec_id; + unsigned v; int len, tag; int ret; int object_type_id = avio_r8(pb); avio_r8(pb); /* stream type */ avio_rb24(pb); /* buffer size db */ - avio_rb32(pb); /* max bitrate */ - avio_rb32(pb); /* avg bitrate */ if(avcodec_is_open(st->codec)) { av_log(fc, AV_LOG_DEBUG, "codec open in read_dec_config_descr\n"); return -1; } + v = avio_rb32(pb); + if (v < INT32_MAX) + st->codec->rc_max_rate = v; + + st->codec->bit_rate = avio_rb32(pb); /* avg bitrate */ + codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id); if (codec_id) st->codec->codec_id= codec_id; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/isom.h ffmpeg-2.7.2~trusty~ppa1/libavformat/isom.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/isom.h 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/isom.h 2015-07-20 17:20:03.000000000 +0000 @@ -198,6 +198,14 @@ MOVFragmentIndex** fragment_index_data; unsigned fragment_index_count; int atom_depth; + unsigned int aax_mode; ///< 'aax' file has been detected + uint8_t file_key[20]; + uint8_t file_iv[20]; + void *activation_bytes; + int activation_bytes_size; + void *audible_fixed_key; + int audible_fixed_key_size; + struct AVAES *aes_decrypt; } MOVContext; int ff_mp4_read_descr_len(AVIOContext *pb); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/ivfenc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/ivfenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/ivfenc.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/ivfenc.c 2015-07-12 17:20:02.000000000 +0000 @@ -20,6 +20,11 @@ #include "avformat.h" #include "libavutil/intreadwrite.h" +typedef struct IVFEncContext { + unsigned frame_cnt; + uint64_t last_pts, sum_delta_pts; +} IVFEncContext; + static int ivf_write_header(AVFormatContext *s) { AVCodecContext *ctx; @@ -43,7 +48,7 @@ avio_wl16(pb, ctx->height); avio_wl32(pb, s->streams[0]->time_base.den); avio_wl32(pb, s->streams[0]->time_base.num); - avio_wl64(pb, s->streams[0]->duration); // TODO: duration or number of frames?!? + avio_wl64(pb, 0xFFFFFFFFFFFFFFFFULL); return 0; } @@ -51,14 +56,36 @@ static int ivf_write_packet(AVFormatContext *s, AVPacket *pkt) { AVIOContext *pb = s->pb; + IVFEncContext *ctx = s->priv_data; + avio_wl32(pb, pkt->size); avio_wl64(pb, pkt->pts); avio_write(pb, pkt->data, pkt->size); + if (ctx->frame_cnt) + ctx->sum_delta_pts += pkt->pts - ctx->last_pts; + ctx->frame_cnt++; + ctx->last_pts = pkt->pts; + + return 0; +} + +static int ivf_write_trailer(AVFormatContext *s) +{ + AVIOContext *pb = s->pb; + if (pb->seekable) { + IVFEncContext *ctx = s->priv_data; + size_t end = avio_tell(pb); + + avio_seek(pb, 24, SEEK_SET); + avio_wl64(pb, ctx->frame_cnt * ctx->sum_delta_pts / (ctx->frame_cnt - 1)); + avio_seek(pb, end, SEEK_SET); + } return 0; } AVOutputFormat ff_ivf_muxer = { + .priv_data_size = sizeof(IVFEncContext), .name = "ivf", .long_name = NULL_IF_CONFIG_SMALL("On2 IVF"), .extensions = "ivf", @@ -66,4 +93,5 @@ .video_codec = AV_CODEC_ID_VP8, .write_header = ivf_write_header, .write_packet = ivf_write_packet, + .write_trailer = ivf_write_trailer, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/jacosubdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/jacosubdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/jacosubdec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/jacosubdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -172,7 +172,7 @@ jacosub->timeres = 30; - av_bprint_init(&header, 1024+FF_INPUT_BUFFER_PADDING_SIZE, 4096); + av_bprint_init(&header, 1024+AV_INPUT_BUFFER_PADDING_SIZE, 4096); while (!avio_feof(pb)) { int cmd_len; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/jvdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/jvdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/jvdec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/jvdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -196,7 +196,7 @@ return ret; if (ret < size) { memset(pkt->data + JV_PREAMBLE_SIZE + ret, 0, - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); pkt->flags |= AV_PKT_FLAG_CORRUPT; } pkt->size = ret + JV_PREAMBLE_SIZE; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/libnut.c ffmpeg-2.7.2~trusty~ppa1/libavformat/libnut.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/libnut.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/libnut.c 2015-06-13 17:20:02.000000000 +0000 @@ -179,7 +179,7 @@ return avio_read(bc, buf, len); } -static off_t av_seek(void * h, long long pos, int whence) { +static off_t av_seek(void * h, int64_t pos, int whence) { AVIOContext * bc = h; if (whence == SEEK_END) { pos = avio_size(bc) + pos; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/libsmbclient.c ffmpeg-2.7.2~trusty~ppa1/libavformat/libsmbclient.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/libsmbclient.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/libsmbclient.c 2015-06-24 17:20:02.000000000 +0000 @@ -287,6 +287,67 @@ return 0; } +static int libsmbc_delete(URLContext *h) +{ + LIBSMBContext *libsmbc = h->priv_data; + int ret; + struct stat st; + + if ((ret = libsmbc_connect(h)) < 0) + goto cleanup; + + if ((libsmbc->fd = smbc_open(h->filename, O_WRONLY, 0666)) < 0) { + ret = AVERROR(errno); + goto cleanup; + } + + if (smbc_fstat(libsmbc->fd, &st) < 0) { + ret = AVERROR(errno); + goto cleanup; + } + + smbc_close(libsmbc->fd); + libsmbc->fd = -1; + + if (S_ISDIR(st.st_mode)) { + if (smbc_rmdir(h->filename) < 0) { + ret = AVERROR(errno); + goto cleanup; + } + } else { + if (smbc_unlink(h->filename) < 0) { + ret = AVERROR(errno); + goto cleanup; + } + } + + ret = 0; + +cleanup: + libsmbc_close(h); + return ret; +} + +static int libsmbc_move(URLContext *h_src, URLContext *h_dst) +{ + LIBSMBContext *libsmbc = h_src->priv_data; + int ret; + + if ((ret = libsmbc_connect(h_src)) < 0) + goto cleanup; + + if ((libsmbc->dh = smbc_rename(h_src->filename, h_dst->filename)) < 0) { + ret = AVERROR(errno); + goto cleanup; + } + + ret = 0; + +cleanup: + libsmbc_close(h_src); + return ret; +} + #define OFFSET(x) offsetof(LIBSMBContext, x) #define D AV_OPT_FLAG_DECODING_PARAM #define E AV_OPT_FLAG_ENCODING_PARAM @@ -311,6 +372,8 @@ .url_write = libsmbc_write, .url_seek = libsmbc_seek, .url_close = libsmbc_close, + .url_delete = libsmbc_delete, + .url_move = libsmbc_move, .url_open_dir = libsmbc_open_dir, .url_read_dir = libsmbc_read_dir, .url_close_dir = libsmbc_close_dir, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/libssh.c ffmpeg-2.7.2~trusty~ppa1/libavformat/libssh.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/libssh.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/libssh.c 2015-06-24 17:20:02.000000000 +0000 @@ -24,6 +24,7 @@ #include "libavutil/avstring.h" #include "libavutil/opt.h" #include "libavutil/attributes.h" +#include "libavformat/avio.h" #include "avformat.h" #include "internal.h" #include "url.h" @@ -33,6 +34,7 @@ ssh_session session; sftp_session sftp; sftp_file file; + sftp_dir dir; int64_t filesize; int rw_timeout; int trunc; @@ -187,11 +189,11 @@ return 0; } -static av_cold int libssh_open(URLContext *h, const char *url, int flags) +static av_cold int libssh_connect(URLContext *h, const char *url, char *path, size_t path_size) { LIBSSHContext *libssh = h->priv_data; - char proto[10], path[MAX_URL_SIZE], hostname[1024], credencials[1024]; - int port, ret; + char proto[10], hostname[1024], credencials[1024]; + int port = 22, ret; const char *user = NULL, *pass = NULL; char *end = NULL; @@ -199,23 +201,38 @@ credencials, sizeof(credencials), hostname, sizeof(hostname), &port, - path, sizeof(path), + path, path_size, url); + if (!(*path)) + av_strlcpy(path, "/", path_size); + // a port of 0 will use a port from ~/.ssh/config or the default value 22 if (port < 0 || port > 65535) port = 0; if ((ret = libssh_create_ssh_session(libssh, hostname, port)) < 0) - goto fail; + return ret; user = av_strtok(credencials, ":", &end); pass = av_strtok(end, ":", &end); if ((ret = libssh_authentication(libssh, user, pass)) < 0) - goto fail; + return ret; if ((ret = libssh_create_sftp_session(libssh)) < 0) + return ret; + + return 0; +} + +static av_cold int libssh_open(URLContext *h, const char *url, int flags) +{ + int ret; + LIBSSHContext *libssh = h->priv_data; + char path[MAX_URL_SIZE]; + + if ((ret = libssh_connect(h, url, path, sizeof(path))) < 0) goto fail; if ((ret = libssh_open_file(libssh, flags, path)) < 0) @@ -293,6 +310,168 @@ return bytes_written; } +static int libssh_open_dir(URLContext *h) +{ + LIBSSHContext *libssh = h->priv_data; + int ret; + char path[MAX_URL_SIZE]; + + if ((ret = libssh_connect(h, h->filename, path, sizeof(path))) < 0) + goto fail; + + if (!(libssh->dir = sftp_opendir(libssh->sftp, path))) { + av_log(libssh, AV_LOG_ERROR, "Error opening sftp dir: %s\n", ssh_get_error(libssh->session)); + ret = AVERROR(EIO); + goto fail; + } + + return 0; + + fail: + libssh_close(h); + return ret; +} + +static int libssh_read_dir(URLContext *h, AVIODirEntry **next) +{ + LIBSSHContext *libssh = h->priv_data; + sftp_attributes attr = NULL; + AVIODirEntry *entry; + + *next = entry = ff_alloc_dir_entry(); + if (!entry) + return AVERROR(ENOMEM); + + do { + if (attr) + sftp_attributes_free(attr); + attr = sftp_readdir(libssh->sftp, libssh->dir); + if (!attr) { + av_freep(next); + if (sftp_dir_eof(libssh->dir)) + return 0; + return AVERROR(EIO); + } + } while (!strcmp(attr->name, ".") || !strcmp(attr->name, "..")); + + entry->name = av_strdup(attr->name); + entry->group_id = attr->gid; + entry->user_id = attr->uid; + entry->size = attr->size; + entry->access_timestamp = INT64_C(1000000) * attr->atime; + entry->modification_timestamp = INT64_C(1000000) * attr->mtime; + entry->filemode = attr->permissions & 0777; + switch(attr->type) { + case SSH_FILEXFER_TYPE_REGULAR: + entry->type = AVIO_ENTRY_FILE; + break; + case SSH_FILEXFER_TYPE_DIRECTORY: + entry->type = AVIO_ENTRY_DIRECTORY; + break; + case SSH_FILEXFER_TYPE_SYMLINK: + entry->type = AVIO_ENTRY_SYMBOLIC_LINK; + break; + case SSH_FILEXFER_TYPE_SPECIAL: + /* Special type includes: sockets, char devices, block devices and pipes. + It is probably better to return unknown type, to not confuse anybody. */ + case SSH_FILEXFER_TYPE_UNKNOWN: + default: + entry->type = AVIO_ENTRY_UNKNOWN; + } + sftp_attributes_free(attr); + return 0; +} + +static int libssh_close_dir(URLContext *h) +{ + LIBSSHContext *libssh = h->priv_data; + if (libssh->dir) + sftp_closedir(libssh->dir); + libssh->dir = NULL; + libssh_close(h); + return 0; +} + +static int libssh_delete(URLContext *h) +{ + int ret; + LIBSSHContext *libssh = h->priv_data; + sftp_attributes attr = NULL; + char path[MAX_URL_SIZE]; + + if ((ret = libssh_connect(h, h->filename, path, sizeof(path))) < 0) + goto cleanup; + + if (!(attr = sftp_stat(libssh->sftp, path))) { + ret = AVERROR(sftp_get_error(libssh->sftp)); + goto cleanup; + } + + if (attr->type == SSH_FILEXFER_TYPE_DIRECTORY) { + if (sftp_rmdir(libssh->sftp, path) < 0) { + ret = AVERROR(sftp_get_error(libssh->sftp)); + goto cleanup; + } + } else { + if (sftp_unlink(libssh->sftp, path) < 0) { + ret = AVERROR(sftp_get_error(libssh->sftp)); + goto cleanup; + } + } + + ret = 0; + +cleanup: + if (attr) + sftp_attributes_free(attr); + libssh_close(h); + return ret; +} + +static int libssh_move(URLContext *h_src, URLContext *h_dst) +{ + int ret; + LIBSSHContext *libssh = h_src->priv_data; + char path_src[MAX_URL_SIZE], path_dst[MAX_URL_SIZE]; + char hostname_src[1024], hostname_dst[1024]; + char credentials_src[1024], credentials_dst[1024]; + int port_src = 22, port_dst = 22; + + av_url_split(NULL, 0, + credentials_src, sizeof(credentials_src), + hostname_src, sizeof(hostname_src), + &port_src, + path_src, sizeof(path_src), + h_src->filename); + + av_url_split(NULL, 0, + credentials_dst, sizeof(credentials_dst), + hostname_dst, sizeof(hostname_dst), + &port_dst, + path_dst, sizeof(path_dst), + h_dst->filename); + + if (strcmp(credentials_src, credentials_dst) || + strcmp(hostname_src, hostname_dst) || + port_src != port_dst) { + return AVERROR(EINVAL); + } + + if ((ret = libssh_connect(h_src, h_src->filename, path_src, sizeof(path_src))) < 0) + goto cleanup; + + if (sftp_rename(libssh->sftp, path_src, path_dst) < 0) { + ret = AVERROR(sftp_get_error(libssh->sftp)); + goto cleanup; + } + + ret = 0; + +cleanup: + libssh_close(h_src); + return ret; +} + #define OFFSET(x) offsetof(LIBSSHContext, x) #define D AV_OPT_FLAG_DECODING_PARAM #define E AV_OPT_FLAG_ENCODING_PARAM @@ -317,6 +496,11 @@ .url_write = libssh_write, .url_seek = libssh_seek, .url_close = libssh_close, + .url_delete = libssh_delete, + .url_move = libssh_move, + .url_open_dir = libssh_open_dir, + .url_read_dir = libssh_read_dir, + .url_close_dir = libssh_close_dir, .priv_data_size = sizeof(LIBSSHContext), .priv_data_class = &libssh_context_class, .flags = URL_PROTOCOL_FLAG_NETWORK, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/Makefile ffmpeg-2.7.2~trusty~ppa1/libavformat/Makefile --- ffmpeg-2.7.1~trusty~ppa1/libavformat/Makefile 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/Makefile 2015-07-21 17:20:03.000000000 +0000 @@ -82,7 +82,9 @@ OBJS-$(CONFIG_APNG_DEMUXER) += apngdec.o OBJS-$(CONFIG_APNG_MUXER) += apngenc.o OBJS-$(CONFIG_AQTITLE_DEMUXER) += aqtitledec.o subtitles.o -OBJS-$(CONFIG_ASF_DEMUXER) += asfdec.o asf.o asfcrypt.o \ +OBJS-$(CONFIG_ASF_DEMUXER) += asfdec_f.o asf.o asfcrypt.o \ + avlanguage.o +OBJS-$(CONFIG_ASF_O_DEMUXER) += asfdec_o.o asf.o asfcrypt.o \ avlanguage.o OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o OBJS-$(CONFIG_ASS_DEMUXER) += assdec.o subtitles.o @@ -105,6 +107,7 @@ OBJS-$(CONFIG_BIT_MUXER) += bit.o OBJS-$(CONFIG_BMV_DEMUXER) += bmv.o OBJS-$(CONFIG_BOA_DEMUXER) += boadec.o +OBJS-$(CONFIG_BFSTM_DEMUXER) += brstm.o OBJS-$(CONFIG_BRSTM_DEMUXER) += brstm.o OBJS-$(CONFIG_C93_DEMUXER) += c93.o vocdec.o voc.o OBJS-$(CONFIG_CAF_DEMUXER) += cafdec.o caf.o mov.o mov_chan.o \ @@ -199,6 +202,7 @@ OBJS-$(CONFIG_IMAGE2_ALIAS_PIX_DEMUXER) += img2_alias_pix.o OBJS-$(CONFIG_IMAGE2_BRENDER_PIX_DEMUXER) += img2_brender_pix.o OBJS-$(CONFIG_IMAGE_BMP_PIPE_DEMUXER) += img2dec.o img2.o +OBJS-$(CONFIG_IMAGE_DDS_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_DPX_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_EXR_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_J2K_PIPE_DEMUXER) += img2dec.o img2.o @@ -467,7 +471,7 @@ OBJS-$(CONFIG_WEBVTT_MUXER) += webvttenc.o OBJS-$(CONFIG_WSAUD_DEMUXER) += westwood_aud.o OBJS-$(CONFIG_WSVQA_DEMUXER) += westwood_vqa.o -OBJS-$(CONFIG_WTV_DEMUXER) += wtvdec.o wtv_common.o asfdec.o asf.o asfcrypt.o \ +OBJS-$(CONFIG_WTV_DEMUXER) += wtvdec.o wtv_common.o asfdec_f.o asf.o asfcrypt.o \ avlanguage.o mpegts.o isom.o OBJS-$(CONFIG_WTV_MUXER) += wtvenc.o wtv_common.o \ mpegtsenc.o asf.o @@ -492,6 +496,7 @@ OBJS-$(CONFIG_LIBSMBCLIENT_PROTOCOL) += libsmbclient.o # protocols I/O +OBJS-$(CONFIG_ASYNC_PROTOCOL) += async.o OBJS-$(CONFIG_APPLEHTTP_PROTOCOL) += hlsproto.o OBJS-$(CONFIG_BLURAY_PROTOCOL) += bluray.o OBJS-$(CONFIG_CACHE_PROTOCOL) += cache.o @@ -541,7 +546,8 @@ SKIPHEADERS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh.h SKIPHEADERS-$(CONFIG_NETWORK) += network.h rtsp.h -TESTPROGS = seek \ +TESTPROGS = async \ + seek \ srtp \ url \ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/matroskadec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/matroskadec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/matroskadec.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/matroskadec.c 2015-07-28 17:20:07.000000000 +0000 @@ -806,7 +806,7 @@ /* big-endian ordering; build up number */ while (n++ < size) - *num = (*num << 8) | avio_r8(pb); + *num = ((uint64_t)*num << 8) | avio_r8(pb); } return 0; @@ -995,6 +995,15 @@ return res; } +static int is_ebml_id_valid(uint32_t id) +{ + // Due to endian nonsense in Matroska, the highest byte with any bits set + // will contain the leading length bit. This bit in turn identifies the + // total byte length of the element by its position within the byte. + unsigned int bits = av_log2(id); + return id && (bits + 7) / 8 == (8 - bits % 8); +} + /* * Allocate and return the entry for the level1 element with the given ID. If * an entry already exists, return the existing entry. @@ -1005,6 +1014,9 @@ int i; MatroskaLevel1Element *elem; + if (!is_ebml_id_valid(id)) + return NULL; + // Some files link to all clusters; useless. if (id == MATROSKA_ID_CLUSTER) return NULL; @@ -1780,7 +1792,7 @@ ffio_init_context(&b, track->codec_priv.data, track->codec_priv.size, 0, NULL, NULL, NULL, NULL); - ret = ff_get_wav_header(&b, st->codec, track->codec_priv.size, 0); + ret = ff_get_wav_header(s, &b, st->codec, track->codec_priv.size, 0); if (ret < 0) return ret; codec_id = st->codec->codec_id; @@ -1841,7 +1853,7 @@ } else if (codec_id == AV_CODEC_ID_AAC && !track->codec_priv.size) { int profile = matroska_aac_profile(track->codec_id); int sri = matroska_aac_sri(track->audio.samplerate); - extradata = av_mallocz(5 + FF_INPUT_BUFFER_PADDING_SIZE); + extradata = av_mallocz(5 + AV_INPUT_BUFFER_PADDING_SIZE); if (!extradata) return AVERROR(ENOMEM); extradata[0] = (profile << 3) | ((sri & 0x0E) >> 1); @@ -1854,13 +1866,13 @@ extradata_size = 5; } else extradata_size = 2; - } else if (codec_id == AV_CODEC_ID_ALAC && track->codec_priv.size && track->codec_priv.size < INT_MAX - 12 - FF_INPUT_BUFFER_PADDING_SIZE) { + } else if (codec_id == AV_CODEC_ID_ALAC && track->codec_priv.size && track->codec_priv.size < INT_MAX - 12 - AV_INPUT_BUFFER_PADDING_SIZE) { /* Only ALAC's magic cookie is stored in Matroska's track headers. * Create the "atom size", "tag", and "tag version" fields the * decoder expects manually. */ extradata_size = 12 + track->codec_priv.size; extradata = av_mallocz(extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!extradata) return AVERROR(ENOMEM); AV_WB32(extradata, extradata_size); @@ -1870,7 +1882,7 @@ track->codec_priv.size); } else if (codec_id == AV_CODEC_ID_TTA) { extradata_size = 30; - extradata = av_mallocz(extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + extradata = av_mallocz(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!extradata) return AVERROR(ENOMEM); ffio_init_context(&b, extradata, extradata_size, 1, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/matroskaenc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/matroskaenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/matroskaenc.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/matroskaenc.c 2015-07-10 17:20:03.000000000 +0000 @@ -1772,7 +1772,7 @@ if (codec->codec_type != AVMEDIA_TYPE_SUBTITLE) { mkv_write_block(s, pb, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe); - if (codec->codec_type == AVMEDIA_TYPE_VIDEO && keyframe || add_cue) { + if (s->pb->seekable && (codec->codec_type == AVMEDIA_TYPE_VIDEO && keyframe || add_cue)) { ret = mkv_add_cuepoint(mkv->cues, pkt->stream_index, dash_tracknum, ts, mkv->cluster_pos, relative_packet_pos, -1); if (ret < 0) return ret; } @@ -1792,10 +1792,12 @@ end_ebml_master(pb, blockgroup); } - ret = mkv_add_cuepoint(mkv->cues, pkt->stream_index, dash_tracknum, ts, - mkv->cluster_pos, relative_packet_pos, duration); - if (ret < 0) - return ret; + if (s->pb->seekable) { + ret = mkv_add_cuepoint(mkv->cues, pkt->stream_index, dash_tracknum, ts, + mkv->cluster_pos, relative_packet_pos, duration); + if (ret < 0) + return ret; + } } mkv->duration = FFMAX(mkv->duration, ts + duration); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/mlvdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/mlvdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/mlvdec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/mlvdec.c 2015-07-12 17:20:02.000000000 +0000 @@ -143,7 +143,7 @@ vst->codec->codec_tag = MKTAG('B', 'I', 'T', 16); size -= 164; } else if (ast && type == MKTAG('W', 'A', 'V', 'I') && size >= 16) { - ret = ff_get_wav_header(pb, ast->codec, 16, 0); + ret = ff_get_wav_header(avctx, pb, ast->codec, 16, 0); if (ret < 0) return ret; size -= 16; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/mov.c ffmpeg-2.7.2~trusty~ppa1/libavformat/mov.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/mov.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/mov.c 2015-08-02 17:20:02.000000000 +0000 @@ -37,6 +37,8 @@ #include "libavutil/dict.h" #include "libavutil/display.h" #include "libavutil/opt.h" +#include "libavutil/aes.h" +#include "libavutil/sha.h" #include "libavutil/timecode.h" #include "libavcodec/ac3tab.h" #include "avformat.h" @@ -769,7 +771,7 @@ return 0; st = c->fc->streams[c->fc->nb_streams-1]; - if ((ret = ff_get_wav_header(pb, st->codec, atom.size, 0)) < 0) + if ((ret = ff_get_wav_header(c->fc, pb, st->codec, atom.size, 0)) < 0) av_log(c->fc, AV_LOG_WARNING, "get_wav_header failed\n"); return ret; @@ -807,6 +809,120 @@ return 0; /* now go for moov */ } +#define DRM_BLOB_SIZE 56 + +static int mov_read_adrm(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + uint8_t intermediate_key[20]; + uint8_t intermediate_iv[20]; + uint8_t input[64]; + uint8_t output[64]; + uint8_t file_checksum[20]; + uint8_t calculated_checksum[20]; + struct AVSHA *sha; + int i; + int ret = 0; + uint8_t *activation_bytes = c->activation_bytes; + uint8_t *fixed_key = c->audible_fixed_key; + + c->aax_mode = 1; + + sha = av_sha_alloc(); + if (!sha) + return AVERROR(ENOMEM); + c->aes_decrypt = av_aes_alloc(); + if (!c->aes_decrypt) { + ret = AVERROR(ENOMEM); + goto fail; + } + + /* drm blob processing */ + avio_read(pb, output, 8); // go to offset 8, absolute postion 0x251 + avio_read(pb, input, DRM_BLOB_SIZE); + avio_read(pb, output, 4); // go to offset 4, absolute postion 0x28d + avio_read(pb, file_checksum, 20); + + av_log(c->fc, AV_LOG_INFO, "[aax] file checksum == "); // required by external tools + for (i = 0; i < 20; i++) + av_log(sha, AV_LOG_INFO, "%02x", file_checksum[i]); + av_log(c->fc, AV_LOG_INFO, "\n"); + + /* verify activation data */ + if (!activation_bytes) { + av_log(c->fc, AV_LOG_WARNING, "[aax] activation_bytes option is missing!\n"); + ret = 0; /* allow ffprobe to continue working on .aax files */ + goto fail; + } + if (c->activation_bytes_size != 4) { + av_log(c->fc, AV_LOG_FATAL, "[aax] activation_bytes value needs to be 4 bytes!\n"); + ret = AVERROR(EINVAL); + goto fail; + } + + /* verify fixed key */ + if (c->audible_fixed_key_size != 16) { + av_log(c->fc, AV_LOG_FATAL, "[aax] audible_fixed_key value needs to be 16 bytes!\n"); + ret = AVERROR(EINVAL); + goto fail; + } + + /* AAX (and AAX+) key derivation */ + av_sha_init(sha, 160); + av_sha_update(sha, fixed_key, 16); + av_sha_update(sha, activation_bytes, 4); + av_sha_final(sha, intermediate_key); + av_sha_init(sha, 160); + av_sha_update(sha, fixed_key, 16); + av_sha_update(sha, intermediate_key, 20); + av_sha_update(sha, activation_bytes, 4); + av_sha_final(sha, intermediate_iv); + av_sha_init(sha, 160); + av_sha_update(sha, intermediate_key, 16); + av_sha_update(sha, intermediate_iv, 16); + av_sha_final(sha, calculated_checksum); + if (memcmp(calculated_checksum, file_checksum, 20)) { // critical error + av_log(c->fc, AV_LOG_ERROR, "[aax] mismatch in checksums!\n"); + ret = AVERROR_INVALIDDATA; + goto fail; + } + av_aes_init(c->aes_decrypt, intermediate_key, 128, 1); + av_aes_crypt(c->aes_decrypt, output, input, DRM_BLOB_SIZE >> 4, intermediate_iv, 1); + for (i = 0; i < 4; i++) { + // file data (in output) is stored in big-endian mode + if (activation_bytes[i] != output[3 - i]) { // critical error + av_log(c->fc, AV_LOG_ERROR, "[aax] error in drm blob decryption!\n"); + ret = AVERROR_INVALIDDATA; + goto fail; + } + } + memcpy(c->file_key, output + 8, 16); + memcpy(input, output + 26, 16); + av_sha_init(sha, 160); + av_sha_update(sha, input, 16); + av_sha_update(sha, c->file_key, 16); + av_sha_update(sha, fixed_key, 16); + av_sha_final(sha, c->file_iv); + +fail: + av_free(sha); + + return ret; +} + +// Audible AAX (and AAX+) bytestream decryption +static int aax_filter(uint8_t *input, int size, MOVContext *c) +{ + int blocks = 0; + unsigned char iv[16]; + + memcpy(iv, c->file_iv, 16); // iv is overwritten + blocks = size >> 4; // trailing bytes are not encrypted! + av_aes_init(c->aes_decrypt, c->file_key, 128, 1); + av_aes_crypt(c->aes_decrypt, input, input, blocks, iv, 1); + + return 0; +} + /* read major brand, minor version and compatible brands and store them as metadata */ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom) { @@ -1024,7 +1140,7 @@ { AVStream *st; char color_parameter_type[5] = { 0 }; - int color_primaries, color_trc, color_matrix; + uint16_t color_primaries, color_trc, color_matrix; int ret; if (c->fc->nb_streams < 1) @@ -1130,14 +1246,14 @@ static int mov_realloc_extradata(AVCodecContext *codec, MOVAtom atom) { int err = 0; - uint64_t size = (uint64_t)codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE; + uint64_t size = (uint64_t)codec->extradata_size + atom.size + 8 + AV_INPUT_BUFFER_PADDING_SIZE; if (size > INT_MAX || (uint64_t)atom.size > INT_MAX) return AVERROR_INVALIDDATA; if ((err = av_reallocp(&codec->extradata, size)) < 0) { codec->extradata_size = 0; return err; } - codec->extradata_size = size - FF_INPUT_BUFFER_PADDING_SIZE; + codec->extradata_size = size - AV_INPUT_BUFFER_PADDING_SIZE; return 0; } @@ -1159,7 +1275,7 @@ codec->extradata_size -= atom.size - err; result = err; } - memset(buf + 8 + err, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(buf + 8 + err, 0, AV_INPUT_BUFFER_PADDING_SIZE); return result; } @@ -1669,6 +1785,15 @@ ff_mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, flags); } + if (version == 0 || (version == 1 && sc->audio_cid != -2)) { + /* can't correctly handle variable sized packet as audio unit */ + switch (st->codec->codec_id) { + case AV_CODEC_ID_MP2: + case AV_CODEC_ID_MP3: + st->need_parsing = AVSTREAM_PARSE_FULL; + break; + } + } } switch (st->codec->codec_id) { @@ -1774,7 +1899,7 @@ av_freep(&st->codec->extradata); st->codec->extradata_size = 0; - st->codec->extradata = av_mallocz(strlen(buf) + FF_INPUT_BUFFER_PADDING_SIZE); + st->codec->extradata = av_mallocz(strlen(buf) + AV_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); st->codec->extradata_size = strlen(buf); @@ -1802,7 +1927,7 @@ val = AV_RB32(st->codec->extradata + 4); tmcd_ctx->tmcd_flags = val; if (val & 1) - st->codec->flags2 |= CODEC_FLAG2_DROP_FRAME_TIMECODE; + st->codec->flags2 |= AV_CODEC_FLAG2_DROP_FRAME_TIMECODE; st->codec->time_base.den = st->codec->extradata[16]; /* number of frame */ st->codec->time_base.num = 1; /* adjust for per frame dur in counter mode */ @@ -1889,7 +2014,6 @@ case AV_CODEC_ID_MP3: /* force type after stsd for m1a hdlr */ st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->need_parsing = AVSTREAM_PARSE_FULL; break; case AV_CODEC_ID_GSM: case AV_CODEC_ID_ADPCM_MS: @@ -1985,9 +2109,10 @@ id = mov_codec_id(st, format); - av_log(c->fc, AV_LOG_TRACE, "size=%"PRId64" 4CC= %c%c%c%c codec_type=%d\n", size, + av_log(c->fc, AV_LOG_TRACE, + "size=%"PRId64" 4CC= %c%c%c%c/0x%08x codec_type=%d\n", size, (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff, - (format >> 24) & 0xff, st->codec->codec_type); + (format >> 24) & 0xff, format, st->codec->codec_type); if (st->codec->codec_type==AVMEDIA_TYPE_VIDEO) { st->codec->codec_id = id; @@ -2211,7 +2336,7 @@ num_bytes = (entries*field_size+4)>>3; - buf = av_malloc(num_bytes+FF_INPUT_BUFFER_PADDING_SIZE); + buf = av_malloc(num_bytes+AV_INPUT_BUFFER_PADDING_SIZE); if (!buf) { av_freep(&sc->sample_sizes); return AVERROR(ENOMEM); @@ -2689,6 +2814,35 @@ } } +static int test_same_origin(const char *src, const char *ref) { + char src_proto[64]; + char ref_proto[64]; + char src_auth[256]; + char ref_auth[256]; + char src_host[256]; + char ref_host[256]; + int src_port=-1; + int ref_port=-1; + + av_url_split(src_proto, sizeof(src_proto), src_auth, sizeof(src_auth), src_host, sizeof(src_host), &src_port, NULL, 0, src); + av_url_split(ref_proto, sizeof(ref_proto), ref_auth, sizeof(ref_auth), ref_host, sizeof(ref_host), &ref_port, NULL, 0, ref); + + if (strlen(src) == 0) { + return -1; + } else if (strlen(src_auth) + 1 >= sizeof(src_auth) || + strlen(ref_auth) + 1 >= sizeof(ref_auth) || + strlen(src_host) + 1 >= sizeof(src_host) || + strlen(ref_host) + 1 >= sizeof(ref_host)) { + return 0; + } else if (strcmp(src_proto, ref_proto) || + strcmp(src_auth, ref_auth) || + strcmp(src_host, ref_host) || + src_port != ref_port) { + return 0; + } else + return 1; +} + static int mov_open_dref(MOVContext *c, AVIOContext **pb, const char *src, MOVDref *ref, AVIOInterruptCB *int_cb) { @@ -2699,7 +2853,7 @@ /* try relative path, we do not try the absolute because it can leak information about our system to an attacker */ - if (ref->nlvl_to > 0 && ref->nlvl_from > 0 && ref->path[0] != '/') { + if (ref->nlvl_to > 0 && ref->nlvl_from > 0) { char filename[1025]; const char *src_path; int i, l; @@ -2729,9 +2883,23 @@ av_strlcat(filename, "../", sizeof(filename)); av_strlcat(filename, ref->path + l + 1, sizeof(filename)); - if (!c->use_absolute_path && !c->fc->open_cb) - if(strstr(ref->path + l + 1, "..") || ref->nlvl_from > 1) + if (!c->use_absolute_path && !c->fc->open_cb) { + int same_origin = test_same_origin(src, filename); + + if (!same_origin) { + av_log(c->fc, AV_LOG_ERROR, + "Reference with mismatching origin, %s not tried for security reasons, " + "set demuxer option use_absolute_path to allow it anyway\n", + ref->path); return AVERROR(ENOENT); + } + + if(strstr(ref->path + l + 1, "..") || + strstr(ref->path + l + 1, ":") || + (ref->nlvl_from > 1 && same_origin < 0) || + (filename[0] == '/' && src_path == src)) + return AVERROR(ENOENT); + } if (strlen(filename) + 1 == sizeof(filename)) return AVERROR(ENOENT); @@ -3585,6 +3753,7 @@ { MKTAG('e','l','s','t'), mov_read_elst }, { MKTAG('e','n','d','a'), mov_read_enda }, { MKTAG('f','i','e','l'), mov_read_fiel }, +{ MKTAG('a','d','r','m'), mov_read_adrm }, { MKTAG('f','t','y','p'), mov_read_ftyp }, { MKTAG('g','l','b','l'), mov_read_glbl }, { MKTAG('h','d','l','r'), mov_read_hdlr }, @@ -3964,6 +4133,9 @@ AVStream *st = s->streams[i]; MOVStreamContext *sc = st->priv_data; + if (!sc) + continue; + av_freep(&sc->ctts_data); for (j = 0; j < sc->drefs_count; j++) { av_freep(&sc->drefs[j].path); @@ -4003,6 +4175,8 @@ } av_freep(&mov->fragment_index_data); + av_freep(&mov->aes_decrypt); + return 0; } @@ -4290,6 +4464,7 @@ break; } } + ff_configure_buffers_for_index(s, AV_TIME_BASE); return 0; } @@ -4421,6 +4596,9 @@ pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0; pkt->pos = sample->pos; + if (mov->aax_mode) + aax_filter(pkt->data, pkt->size, mov); + return 0; } @@ -4534,6 +4712,12 @@ AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = FLAGS }, { "export_xmp", "Export full XMP metadata", OFFSET(export_xmp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = FLAGS }, + { "activation_bytes", "Secret bytes for Audible AAX files", OFFSET(activation_bytes), + AV_OPT_TYPE_BINARY, .flags = AV_OPT_FLAG_DECODING_PARAM }, + { "audible_fixed_key", // extracted from libAAX_SDK.so and AAXSDKWin.dll files! + "Fixed key used for handling Audible AAX files", OFFSET(audible_fixed_key), + AV_OPT_TYPE_BINARY, {.str="77214d4b196a87cd520045fd20a51d67"}, + .flags = AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/movenc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/movenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/movenc.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/movenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -733,7 +733,7 @@ "dvc1 atom. Set the delay_moov flag to fix this.\n"); } - unescaped = av_mallocz(track->vos_len + FF_INPUT_BUFFER_PADDING_SIZE); + unescaped = av_mallocz(track->vos_len + AV_INPUT_BUFFER_PADDING_SIZE); if (!unescaped) return AVERROR(ENOMEM); start = find_next_marker(track->vos_data, end); @@ -2573,7 +2573,7 @@ int ret, size; uint8_t *buf; - if (!st || mov->fc->flags & AVFMT_FLAG_BITEXACT) + if (!st) return 0; ret = avio_open_dyn_buf(&pb_buf); @@ -2919,9 +2919,10 @@ mov_write_string_metadata(s, pb, "\251wrt", "composer" , 1); mov_write_string_metadata(s, pb, "\251alb", "album" , 1); mov_write_string_metadata(s, pb, "\251day", "date" , 1); - if (!mov->exact && - !mov_write_string_metadata(s, pb, "\251too", "encoding_tool", 1)) - mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1); + if (!mov_write_string_metadata(s, pb, "\251too", "encoding_tool", 1)) { + if (!(s->flags & AVFMT_FLAG_BITEXACT)) + mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1); + } mov_write_string_metadata(s, pb, "\251cmt", "comment" , 1); mov_write_string_metadata(s, pb, "\251gen", "genre" , 1); mov_write_string_metadata(s, pb, "\251cpy", "copyright", 1); @@ -3115,7 +3116,6 @@ static int mov_write_uuidusmt_tag(AVIOContext *pb, AVFormatContext *s) { - MOVMuxContext *mov = s->priv_data; AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0); int64_t pos, pos2; @@ -3140,7 +3140,7 @@ avio_wb16(pb, 0x0); /* ? */ avio_wb16(pb, 0x021C); /* data */ - if (!mov->exact) + if (!(s->flags & AVFMT_FLAG_BITEXACT)) mov_write_psp_udta_tag(pb, LIBAVCODEC_IDENT, "eng", 0x04); mov_write_psp_udta_tag(pb, title->value, "eng", 0x01); mov_write_psp_udta_tag(pb, "2006/04/01 11:11:11", "und", 0x03); @@ -3275,7 +3275,7 @@ avio_printf(pb, "\n"); avio_printf(pb, "\n"); avio_printf(pb, "\n"); - if (!mov->exact) + if (!(mov->fc->flags & AVFMT_FLAG_BITEXACT)) avio_printf(pb, "\n", LIBAVFORMAT_IDENT); avio_printf(pb, "\n"); @@ -4341,7 +4341,7 @@ if (enc->codec_id == AV_CODEC_ID_AMR_NB) { /* We must find out how many AMR blocks there are in one packet */ - static uint16_t packed_size[16] = + static const uint16_t packed_size[16] = {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 1}; int len = 0; @@ -4960,9 +4960,6 @@ else if (!strcmp("f4v", s->oformat->name)) mov->mode = MODE_F4V; } - if (s->flags & AVFMT_FLAG_BITEXACT) - mov->exact = 1; - if (mov->flags & FF_MOV_FLAG_DELAY_MOOV) mov->flags |= FF_MOV_FLAG_EMPTY_MOOV; @@ -5247,8 +5244,13 @@ mov_write_mdat_tag(pb, mov); } - if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { mov->time = ff_iso8601_to_unix_time(t->value); + if (mov->time < 0) { + av_log(s, AV_LOG_WARNING, "Failed to parse creation_time %s\n", t->value); + mov->time = 0; + } + } if (mov->time) mov->time += 0x7C25B080; // 1970 based -> 1904 based @@ -5588,7 +5590,7 @@ AVOutputFormat ff_mp4_muxer = { .name = "mp4", .long_name = NULL_IF_CONFIG_SMALL("MP4 (MPEG-4 Part 14)"), - .mime_type = "application/mp4", + .mime_type = "video/mp4", .extensions = "mp4", .priv_data_size = sizeof(MOVMuxContext), .audio_codec = AV_CODEC_ID_AAC, @@ -5642,7 +5644,7 @@ AVOutputFormat ff_ipod_muxer = { .name = "ipod", .long_name = NULL_IF_CONFIG_SMALL("iPod H.264 MP4 (MPEG-4 Part 14)"), - .mime_type = "application/mp4", + .mime_type = "video/mp4", .extensions = "m4v,m4a", .priv_data_size = sizeof(MOVMuxContext), .audio_codec = AV_CODEC_ID_AAC, @@ -5660,7 +5662,7 @@ AVOutputFormat ff_ismv_muxer = { .name = "ismv", .long_name = NULL_IF_CONFIG_SMALL("ISMV/ISMA (Smooth Streaming)"), - .mime_type = "application/mp4", + .mime_type = "video/mp4", .extensions = "ismv,isma", .priv_data_size = sizeof(MOVMuxContext), .audio_codec = AV_CODEC_ID_AAC, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/movenc.h ffmpeg-2.7.2~trusty~ppa1/libavformat/movenc.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/movenc.h 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/movenc.h 2015-07-18 17:20:03.000000000 +0000 @@ -164,7 +164,6 @@ int flags; int rtp_flags; - int exact; int iods_skip; int iods_video_profile; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/mp3dec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/mp3dec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/mp3dec.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/mp3dec.c 2015-07-20 17:20:03.000000000 +0000 @@ -54,7 +54,7 @@ int is_cbr; } MP3DecContext; -static int check(AVFormatContext *s, int64_t pos); +static int check(AVIOContext *pb, int64_t pos); /* mp3 read */ @@ -98,7 +98,7 @@ avcodec_free_context(&avctx); // keep this in sync with ac3 probe, both need to avoid // issues with MPEG-files! - if (first_frames>=4) return AVPROBE_SCORE_EXTENSION + 1; + if (first_frames>=7) return AVPROBE_SCORE_EXTENSION + 1; else if(max_frames>200)return AVPROBE_SCORE_EXTENSION; else if(max_frames>=4 && max_frames >= p->buf_size/10000) return AVPROBE_SCORE_EXTENSION / 2; else if(ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC) && 2*ff_id3v2_tag_len(buf0) >= p->buf_size) @@ -376,8 +376,8 @@ for (i = 0; i < 64 * 1024; i++) { if (!(i&1023)) ffio_ensure_seekback(s->pb, i + 1024 + 4); - if (check(s, off + i) >= 0) { - av_log(s, AV_LOG_INFO, "Skipping %d bytes of junk at %lld.\n", i, (long long)off); + if (check(s->pb, off + i) >= 0) { + av_log(s, AV_LOG_INFO, "Skipping %d bytes of junk at %"PRId64".\n", i, off); avio_seek(s->pb, off + i, SEEK_SET); break; } @@ -415,74 +415,45 @@ pkt->flags &= ~AV_PKT_FLAG_CORRUPT; pkt->stream_index = 0; - if (ret >= ID3v1_TAG_SIZE && - memcmp(&pkt->data[ret - ID3v1_TAG_SIZE], "TAG", 3) == 0) - ret -= ID3v1_TAG_SIZE; - - /* note: we need to modify the packet size here to handle the last - packet */ - pkt->size = ret; return ret; } -static int check(AVFormatContext *s, int64_t pos) +#define SEEK_WINDOW 4096 + +static int check(AVIOContext *pb, int64_t pos) { - int64_t ret = avio_seek(s->pb, pos, SEEK_SET); + int64_t ret = avio_seek(pb, pos, SEEK_SET); unsigned header; MPADecodeHeader sd; if (ret < 0) return ret; - header = avio_rb32(s->pb); + + header = avio_rb32(pb); if (ff_mpa_check_header(header) < 0) return -1; if (avpriv_mpegaudio_decode_header(&sd, header) == 1) return -1; + return sd.frame_size; } -static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, - int flags) +static int64_t mp3_sync(AVFormatContext *s, int64_t target_pos, int flags) { - MP3DecContext *mp3 = s->priv_data; - AVIndexEntry *ie, ie1; - AVStream *st = s->streams[0]; - int64_t ret = av_index_search_timestamp(st, timestamp, flags); - int i, j; int dir = (flags&AVSEEK_FLAG_BACKWARD) ? -1 : 1; int64_t best_pos; - int best_score; - - if (mp3->usetoc == 2) - return -1; // generic index code - - if ( mp3->is_cbr - && (mp3->usetoc == 0 || !mp3->xing_toc) - && st->duration > 0 - && mp3->header_filesize > s->internal->data_offset - && mp3->frames) { - ie = &ie1; - timestamp = av_clip64(timestamp, 0, st->duration); - ie->timestamp = timestamp; - ie->pos = av_rescale(timestamp, mp3->header_filesize, st->duration) + s->internal->data_offset; - } else if (mp3->xing_toc) { - if (ret < 0) - return ret; - - ie = &st->index_entries[ret]; - } else { - return -1; - } + int best_score, i, j; + int64_t ret; - avio_seek(s->pb, FFMAX(ie->pos - 4096, 0), SEEK_SET); - ret = avio_seek(s->pb, ie->pos, SEEK_SET); + avio_seek(s->pb, FFMAX(target_pos - SEEK_WINDOW, 0), SEEK_SET); + ret = avio_seek(s->pb, target_pos, SEEK_SET); if (ret < 0) return ret; #define MIN_VALID 3 - best_pos = ie->pos; + best_pos = target_pos; best_score = 999; - for(i=0; i<4096; i++) { - int64_t pos = ie->pos + (dir > 0 ? i - 1024 : -i); + for(i=0; i 0 ? i - SEEK_WINDOW/4 : -i); int64_t candidate = -1; int score = 999; @@ -490,10 +461,10 @@ continue; for(j=0; jpb, pos); if(ret < 0) break; - if ((ie->pos - pos)*dir <= 0 && abs(MIN_VALID/2-j) < score) { + if ((target_pos - pos)*dir <= 0 && abs(MIN_VALID/2-j) < score) { candidate = pos; score = abs(MIN_VALID/2-j); } @@ -507,9 +478,42 @@ } } - ret = avio_seek(s->pb, best_pos, SEEK_SET); - if (ret < 0) - return ret; + return avio_seek(s->pb, best_pos, SEEK_SET); +} + +static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, + int flags) +{ + MP3DecContext *mp3 = s->priv_data; + AVIndexEntry *ie, ie1; + AVStream *st = s->streams[0]; + int64_t ret = av_index_search_timestamp(st, timestamp, flags); + int64_t best_pos; + + if (mp3->usetoc == 2) + return -1; // generic index code + + if ( mp3->is_cbr + && (mp3->usetoc == 0 || !mp3->xing_toc) + && st->duration > 0 + && mp3->header_filesize > s->internal->data_offset + && mp3->frames) { + ie = &ie1; + timestamp = av_clip64(timestamp, 0, st->duration); + ie->timestamp = timestamp; + ie->pos = av_rescale(timestamp, mp3->header_filesize, st->duration) + s->internal->data_offset; + } else if (mp3->xing_toc) { + if (ret < 0) + return ret; + + ie = &st->index_entries[ret]; + } else { + return -1; + } + + best_pos = mp3_sync(s, ie->pos, flags); + if (best_pos < 0) + return best_pos; if (mp3->is_cbr && ie == &ie1) { int frame_duration = av_rescale(st->duration, 1, mp3->frames); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/mpc8.c ffmpeg-2.7.2~trusty~ppa1/libavformat/mpc8.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/mpc8.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/mpc8.c 2015-07-28 17:20:07.000000000 +0000 @@ -154,7 +154,7 @@ av_log(s, AV_LOG_ERROR, "Bad seek table size\n"); return; } - if(!(buf = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE))) + if(!(buf = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE))) return; ret = avio_read(s->pb, buf, size); if (ret != size) { @@ -162,7 +162,7 @@ av_free(buf); return; } - memset(buf+size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(buf+size, 0, AV_INPUT_BUFFER_PADDING_SIZE); init_get_bits(&gb, buf, size * 8); size = gb_get_v(&gb); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/mpegts.c ffmpeg-2.7.2~trusty~ppa1/libavformat/mpegts.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/mpegts.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/mpegts.c 2015-07-28 17:20:07.000000000 +0000 @@ -698,6 +698,7 @@ #endif { 0x1b, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264 }, { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264 }, + { 0x21, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_JPEG2000 }, { 0x24, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC }, { 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS }, { 0xd1, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_DIRAC }, @@ -835,6 +836,14 @@ st->codec->codec_id = old_codec_id; st->codec->codec_type = old_codec_type; } + if ((st->codec->codec_id == AV_CODEC_ID_NONE || + (st->request_probe > 0 && st->request_probe < AVPROBE_SCORE_STREAM_RETRY / 5)) && + !avcodec_is_open(st->codec) && + stream_type == STREAM_TYPE_PRIVATE_DATA) { + st->codec->codec_type = AVMEDIA_TYPE_DATA; + st->codec->codec_id = AV_CODEC_ID_BIN_DATA; + st->request_probe = AVPROBE_SCORE_STREAM_RETRY / 5; + } return 0; } @@ -862,7 +871,7 @@ av_log(pes->stream, AV_LOG_WARNING, "PES packet size mismatch\n"); pes->flags |= AV_PKT_FLAG_CORRUPT; } - memset(pkt->data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE); // Separate out the AC3 substream from an HDMV combined TrueHD/AC3 PID if (pes->sub_st && pes->stream_type == 0x83 && pes->extended_stream_id == 0x76) @@ -894,8 +903,8 @@ int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0; int dts_flag = -1, cts_flag = -1; int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE; - uint8_t buf_padded[128 + FF_INPUT_BUFFER_PADDING_SIZE]; - int buf_padded_size = FFMIN(buf_size, sizeof(buf_padded) - FF_INPUT_BUFFER_PADDING_SIZE); + uint8_t buf_padded[128 + AV_INPUT_BUFFER_PADDING_SIZE]; + int buf_padded_size = FFMIN(buf_size, sizeof(buf_padded) - AV_INPUT_BUFFER_PADDING_SIZE); memcpy(buf_padded, buf, buf_padded_size); @@ -1027,7 +1036,7 @@ /* allocate pes buffer */ pes->buffer = av_buffer_alloc(pes->total_size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!pes->buffer) return AVERROR(ENOMEM); @@ -1131,7 +1140,10 @@ p += 5; buf_size -= 5; } - if (pes->ts->fix_teletext_pts && pes->st->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT) { + if ( pes->ts->fix_teletext_pts + && ( pes->st->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT + || pes->st->codec->codec_id == AV_CODEC_ID_DVB_SUBTITLE) + ) { AVProgram *p = NULL; while ((p = av_find_program_from_stream(pes->stream, p, pes->st->index))) { if (p->pcr_pid != -1 && p->discard != AVDISCARD_ALL) { @@ -1160,7 +1172,11 @@ pes->st->pts_wrap_behavior = st->pts_wrap_behavior; if (pes->dts == AV_NOPTS_VALUE || pes->dts < pcr) { pes->pts = pes->dts = pcr; - } else if (pes->dts > pcr + 3654 + 9000) { + } else if (pes->st->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT && + pes->dts > pcr + 3654 + 9000) { + pes->pts = pes->dts = pcr + 3654 + 9000; + } else if (pes->st->codec->codec_id == AV_CODEC_ID_DVB_SUBTITLE && + pes->dts > pcr + 10*90000) { //10sec pes->pts = pes->dts = pcr + 3654 + 9000; } break; @@ -1178,7 +1194,7 @@ new_pes_packet(pes, ts->pkt); pes->total_size = MAX_PES_PAYLOAD; pes->buffer = av_buffer_alloc(pes->total_size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!pes->buffer) return AVERROR(ENOMEM); ts->stop_parse = 1; @@ -1635,9 +1651,7 @@ if (language_count > 0) { /* 4 bytes per language code (3 bytes) with comma or NUL byte should fit language buffer */ - if (language_count > sizeof(language) / 4) { - language_count = sizeof(language) / 4; - } + av_assert0(language_count <= sizeof(language) / 4); if (st->codec->extradata == NULL) { if (ff_alloc_extradata(st->codec, language_count * 2)) { @@ -1687,9 +1701,7 @@ uint8_t *extradata; /* 4 bytes per language code (3 bytes) with comma or NUL byte should fit language buffer */ - if (language_count > sizeof(language) / 4) { - language_count = sizeof(language) / 4; - } + av_assert0(language_count <= sizeof(language) / 4); if (st->codec->extradata == NULL) { if (ff_alloc_extradata(st->codec, language_count * 5)) { @@ -1758,7 +1770,7 @@ case 0x05: /* registration descriptor */ st->codec->codec_tag = bytestream_get_le32(pp); av_log(fc, AV_LOG_TRACE, "reg_desc=%.4s\n", (char *)&st->codec->codec_tag); - if (st->codec->codec_id == AV_CODEC_ID_NONE) + if (st->codec->codec_id == AV_CODEC_ID_NONE || st->request_probe > 0) mpegts_find_stream_type(st, st->codec->codec_tag, REGD_types); break; case 0x52: /* stream identifier descriptor */ @@ -1781,7 +1793,7 @@ ext_desc_tag == 0x80) { /* User defined (provisional Opus) */ if (!st->codec->extradata) { st->codec->extradata = av_mallocz(sizeof(opus_default_extradata) + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); @@ -2370,7 +2382,7 @@ static int handle_packets(MpegTSContext *ts, int64_t nb_packets) { AVFormatContext *s = ts->stream; - uint8_t packet[TS_PACKET_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; + uint8_t packet[TS_PACKET_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; const uint8_t *data; int64_t packet_num; int ret = 0; @@ -2397,7 +2409,7 @@ ts->stop_parse = 0; packet_num = 0; - memset(packet + TS_PACKET_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(packet + TS_PACKET_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE); for (;;) { packet_num++; if (nb_packets != 0 && packet_num >= nb_packets || @@ -2431,7 +2443,7 @@ #define CHECK_BLOCK 100 if (check_count < CHECK_COUNT) - return AVERROR_INVALIDDATA; + return 0; for (i = 0; i 6) return AVPROBE_SCORE_MAX + sumscore - CHECK_COUNT; else if (maxscore > 6) return AVPROBE_SCORE_MAX/2 + sumscore - CHECK_COUNT; else - return AVERROR_INVALIDDATA; + return 0; } /* return the 90kHz PCR and the extension for the 27MHz PCR. return diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/mpegtsenc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/mpegtsenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/mpegtsenc.c 2015-06-19 20:44:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/mpegtsenc.c 2015-07-19 17:20:03.000000000 +0000 @@ -98,9 +98,14 @@ int pcr_period; #define MPEGTS_FLAG_REEMIT_PAT_PMT 0x01 #define MPEGTS_FLAG_AAC_LATM 0x02 +#define MPEGTS_FLAG_PAT_PMT_AT_FRAMES 0x04 int flags; int copyts; int tables_version; + float pat_period; + float sdt_period; + int64_t last_pat_ts; + int64_t last_sdt_ts; int omit_video_pes_length; } MpegTSWrite; @@ -783,6 +788,16 @@ service->pcr_packet_period = 1; } + ts->last_pat_ts = AV_NOPTS_VALUE; + ts->last_sdt_ts = AV_NOPTS_VALUE; + // The user specified a period, use only it + if (ts->pat_period < INT_MAX/2) { + ts->pat_packet_period = INT_MAX; + } + if (ts->sdt_period < INT_MAX/2) { + ts->sdt_packet_period = INT_MAX; + } + // output a PCR as soon as possible service->pcr_packet_count = service->pcr_packet_period; ts->pat_packet_count = ts->pat_packet_period - 1; @@ -833,17 +848,27 @@ } /* send SDT, PAT and PMT tables regulary */ -static void retransmit_si_info(AVFormatContext *s, int force_pat) +static void retransmit_si_info(AVFormatContext *s, int force_pat, int64_t dts) { MpegTSWrite *ts = s->priv_data; int i; - if (++ts->sdt_packet_count == ts->sdt_packet_period) { + if (++ts->sdt_packet_count == ts->sdt_packet_period || + (dts != AV_NOPTS_VALUE && ts->last_sdt_ts == AV_NOPTS_VALUE) || + (dts != AV_NOPTS_VALUE && dts - ts->last_sdt_ts >= ts->sdt_period*90000.0) + ) { ts->sdt_packet_count = 0; + if (dts != AV_NOPTS_VALUE) + ts->last_sdt_ts = FFMAX(dts, ts->last_sdt_ts); mpegts_write_sdt(s); } - if (++ts->pat_packet_count == ts->pat_packet_period || force_pat) { + if (++ts->pat_packet_count == ts->pat_packet_period || + (dts != AV_NOPTS_VALUE && ts->last_pat_ts == AV_NOPTS_VALUE) || + (dts != AV_NOPTS_VALUE && dts - ts->last_pat_ts >= ts->pat_period*90000.0) || + force_pat) { ts->pat_packet_count = 0; + if (dts != AV_NOPTS_VALUE) + ts->last_pat_ts = FFMAX(dts, ts->last_pat_ts); mpegts_write_pat(s); for (i = 0; i < ts->nb_services; i++) mpegts_write_pmt(s, ts->services[i]); @@ -971,9 +996,14 @@ int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE); int force_pat = st->codec->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key; + av_assert0(ts_st->payload != buf || st->codec->codec_type != AVMEDIA_TYPE_VIDEO); + if (ts->flags & MPEGTS_FLAG_PAT_PMT_AT_FRAMES && st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + force_pat = 1; + } + is_start = 1; while (payload_size > 0) { - retransmit_si_info(s, force_pat); + retransmit_si_info(s, force_pat, dts); force_pat = 0; write_pcr = 0; @@ -1313,9 +1343,9 @@ if (!ts_st->amux) { av_log(s, AV_LOG_ERROR, "AAC bitstream not in ADTS format " "and extradata missing\n"); - return AVERROR_INVALIDDATA; - } - + if (!st->nb_frames) + return AVERROR_INVALIDDATA; + } else { av_init_packet(&pkt2); pkt2.data = pkt->data; pkt2.size = pkt->size; @@ -1334,6 +1364,7 @@ size = avio_close_dyn_buf(ts_st->amux->pb, &data); ts_st->amux->pb = NULL; buf = data; + } } } else if (st->codec->codec_id == AV_CODEC_ID_HEVC) { int ret = check_hevc_startcode(s, st, pkt); @@ -1504,6 +1535,9 @@ { "latm", "Use LATM packetization for AAC", 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_AAC_LATM }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" }, + { "pat_pmt_at_frames", "Reemit PAT and PMT at each video frame", + 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_PAT_PMT_AT_FRAMES}, 0, INT_MAX, + AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" }, // backward compatibility { "resend_headers", "Reemit PAT/PMT before writing the next packet", offsetof(MpegTSWrite, reemit_pat_pmt), AV_OPT_TYPE_INT, @@ -1520,6 +1554,12 @@ { "pcr_period", "PCR retransmission time", offsetof(MpegTSWrite, pcr_period), AV_OPT_TYPE_INT, { .i64 = PCR_RETRANS_TIME }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, + { "pat_period", "PAT/PMT retransmission time limit in seconds", + offsetof(MpegTSWrite, pat_period), AV_OPT_TYPE_FLOAT, + { .dbl = INT_MAX }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, + { "sdt_period", "SDT retransmission time limit in seconds", + offsetof(MpegTSWrite, sdt_period), AV_OPT_TYPE_FLOAT, + { .dbl = INT_MAX }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { NULL }, }; @@ -1541,6 +1581,6 @@ .write_header = mpegts_write_header, .write_packet = mpegts_write_packet, .write_trailer = mpegts_write_end, - .flags = AVFMT_ALLOW_FLUSH, + .flags = AVFMT_ALLOW_FLUSH | AVFMT_VARIABLE_FPS, .priv_class = &mpegts_muxer_class, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/mpjpeg.c ffmpeg-2.7.2~trusty~ppa1/libavformat/mpjpeg.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/mpjpeg.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/mpjpeg.c 2015-07-09 17:20:03.000000000 +0000 @@ -33,10 +33,7 @@ static int mpjpeg_write_header(AVFormatContext *s) { MPJPEGContext *mpj = s->priv_data; - uint8_t buf1[256]; - - snprintf(buf1, sizeof(buf1), "--%s\r\n", mpj->boundary_tag); - avio_write(s->pb, buf1, strlen(buf1)); + avio_printf(s->pb, "--%s\r\n", mpj->boundary_tag); avio_flush(s->pb); return 0; } @@ -44,17 +41,12 @@ static int mpjpeg_write_packet(AVFormatContext *s, AVPacket *pkt) { MPJPEGContext *mpj = s->priv_data; - uint8_t buf1[256]; - - snprintf(buf1, sizeof(buf1), "Content-type: image/jpeg\r\n"); - avio_write(s->pb, buf1, strlen(buf1)); - - snprintf(buf1, sizeof(buf1), "Content-length: %d\r\n\r\n", pkt->size); - avio_write(s->pb, buf1, strlen(buf1)); + avio_printf(s->pb, "Content-type: image/jpeg\r\n"); + avio_printf(s->pb, "Content-length: %d\r\n\r\n", + pkt->size); avio_write(s->pb, pkt->data, pkt->size); - snprintf(buf1, sizeof(buf1), "\r\n--%s\r\n", mpj->boundary_tag); - avio_write(s->pb, buf1, strlen(buf1)); + avio_printf(s->pb, "\r\n--%s\r\n", mpj->boundary_tag); return 0; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/mpjpegdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/mpjpegdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/mpjpegdec.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/mpjpegdec.c 2015-06-28 17:20:02.000000000 +0000 @@ -123,6 +123,8 @@ return AVERROR_INVALIDDATA; st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_MJPEG; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/msnwc_tcp.c ffmpeg-2.7.2~trusty~ppa1/libavformat/msnwc_tcp.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/msnwc_tcp.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/msnwc_tcp.c 2015-06-29 17:20:04.000000000 +0000 @@ -67,7 +67,7 @@ } } - return -1; + return 0; } static int msnwc_tcp_read_header(AVFormatContext *ctx) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/mux.c ffmpeg-2.7.2~trusty~ppa1/libavformat/mux.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/mux.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/mux.c 2015-07-28 17:20:07.000000000 +0000 @@ -251,7 +251,7 @@ goto fail; #if FF_API_LAVF_BITEXACT - if (s->nb_streams && s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT) + if (s->nb_streams && s->streams[0]->codec->flags & AV_CODEC_FLAG_BITEXACT) s->flags |= AVFMT_FLAG_BITEXACT; #endif @@ -348,7 +348,7 @@ } if (of->flags & AVFMT_GLOBALHEADER && - !(codec->flags & CODEC_FLAG_GLOBAL_HEADER)) + !(codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) av_log(s, AV_LOG_WARNING, "Codec for stream %d does not use global headers " "but container format requires global headers\n", i); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/mxf.c ffmpeg-2.7.2~trusty~ppa1/libavformat/mxf.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/mxf.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/mxf.c 2015-07-22 17:20:04.000000000 +0000 @@ -69,6 +69,11 @@ { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AV_PIX_FMT_NONE }, }; +const MXFCodecUL ff_mxf_codec_tag_uls[] = { + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0E,0x04,0x03,0x01,0x01,0x03,0x01,0x00 }, 15, MKTAG('A', 'V', 'u', 'p') }, /* Avid 1:1 */ + { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, 0 }, +}; + static const struct { enum AVPixelFormat pix_fmt; const char data[16]; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/mxfdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/mxfdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/mxfdec.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/mxfdec.c 2015-08-04 17:20:03.000000000 +0000 @@ -166,6 +166,7 @@ enum MXFMetadataSetType type; UID essence_container_ul; UID essence_codec_ul; + UID codec_ul; AVRational sample_rate; AVRational aspect_ratio; int width; @@ -232,6 +233,7 @@ int nb_segments; MXFIndexTableSegment **segments; /* sorted by IndexStartPosition */ AVIndexEntry *fake_index; /* used for calling ff_index_search_timestamp() */ + int8_t *offsets; /* temporal offsets for display order to stored order conversion */ } MXFIndexTable; typedef struct MXFContext { @@ -974,6 +976,9 @@ case 0x3004: avio_read(pb, descriptor->essence_container_ul, 16); break; + case 0x3005: + avio_read(pb, descriptor->codec_ul, 16); + break; case 0x3006: descriptor->linked_track_id = avio_rb32(pb); break; @@ -1151,6 +1156,11 @@ { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AV_CODEC_ID_NONE }, }; +static const MXFCodecUL mxf_codec_uls[] = { + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14, AV_CODEC_ID_JPEG2000 }, + { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AV_CODEC_ID_NONE }, +}; + static const char* const mxf_data_essence_descriptor[] = { "vbi_vanc_smpte_436M", }; @@ -1325,6 +1335,7 @@ { int i, j, x; int8_t max_temporal_offset = -128; + uint8_t *flags; /* first compute how many entries we have */ for (i = 0; i < index_table->nb_segments; i++) { @@ -1343,8 +1354,12 @@ return 0; if (!(index_table->ptses = av_calloc(index_table->nb_ptses, sizeof(int64_t))) || - !(index_table->fake_index = av_calloc(index_table->nb_ptses, sizeof(AVIndexEntry)))) { + !(index_table->fake_index = av_calloc(index_table->nb_ptses, sizeof(AVIndexEntry))) || + !(index_table->offsets = av_calloc(index_table->nb_ptses, sizeof(int8_t))) || + !(flags = av_calloc(index_table->nb_ptses, sizeof(uint8_t)))) { av_freep(&index_table->ptses); + av_freep(&index_table->fake_index); + av_freep(&index_table->offsets); return AVERROR(ENOMEM); } @@ -1402,8 +1417,7 @@ break; } - index_table->fake_index[x].timestamp = x; - index_table->fake_index[x].flags = !(s->flag_entries[j] & 0x30) ? AVINDEX_KEYFRAME : 0; + flags[x] = !(s->flag_entries[j] & 0x30) ? AVINDEX_KEYFRAME : 0; if (index < 0 || index >= index_table->nb_ptses) { av_log(mxf->fc, AV_LOG_ERROR, @@ -1412,11 +1426,20 @@ continue; } + index_table->offsets[x] = offset; index_table->ptses[index] = x; max_temporal_offset = FFMAX(max_temporal_offset, offset); } } + /* calculate the fake index table in display order */ + for (x = 0; x < index_table->nb_ptses; x++) { + index_table->fake_index[x].timestamp = x; + if (index_table->ptses[x] != AV_NOPTS_VALUE) + index_table->fake_index[index_table->ptses[x]].flags = flags[x]; + } + av_freep(&flags); + index_table->first_dts = -max_temporal_offset; return 0; @@ -1950,6 +1973,11 @@ /* TODO: drop PictureEssenceCoding and SoundEssenceCompression, only check EssenceContainer */ codec_ul = mxf_get_codec_ul(ff_mxf_codec_uls, &descriptor->essence_codec_ul); st->codec->codec_id = (enum AVCodecID)codec_ul->id; + if (st->codec->codec_id == AV_CODEC_ID_NONE) { + codec_ul = mxf_get_codec_ul(mxf_codec_uls, &descriptor->codec_ul); + st->codec->codec_id = (enum AVCodecID)codec_ul->id; + } + av_log(mxf->fc, AV_LOG_VERBOSE, "%s: Universal Label: ", avcodec_get_name(st->codec->codec_id)); for (k = 0; k < 16; k++) { @@ -1974,10 +2002,6 @@ st->codec->width = descriptor->width; st->codec->height = descriptor->height; /* Field height, not frame height */ switch (descriptor->frame_layout) { - case SegmentedFrame: - /* This one is a weird layout I don't fully understand. */ - av_log(mxf->fc, AV_LOG_INFO, "SegmentedFrame layout isn't currently supported\n"); - break; case FullFrame: st->codec->field_order = AV_FIELD_PROGRESSIVE; break; @@ -1989,6 +2013,8 @@ It's also for compatibility with the old behavior. */ case MixedFields: break; + case SegmentedFrame: + st->codec->field_order = AV_FIELD_PROGRESSIVE; case SeparateFields: switch (descriptor->field_dominance) { case MXF_TFF: @@ -2017,12 +2043,16 @@ &descriptor->essence_codec_ul); st->codec->pix_fmt = (enum AVPixelFormat)pix_fmt_ul->id; if (st->codec->pix_fmt == AV_PIX_FMT_NONE) { - /* support files created before RP224v10 by defaulting to UYVY422 - if subsampling is 4:2:2 and component depth is 8-bit */ - if (descriptor->horiz_subsampling == 2 && - descriptor->vert_subsampling == 1 && - descriptor->component_depth == 8) { - st->codec->pix_fmt = AV_PIX_FMT_UYVY422; + st->codec->codec_tag = mxf_get_codec_ul(ff_mxf_codec_tag_uls, + &descriptor->essence_codec_ul)->id; + if (!st->codec->codec_tag) { + /* support files created before RP224v10 by defaulting to UYVY422 + if subsampling is 4:2:2 and component depth is 8-bit */ + if (descriptor->horiz_subsampling == 2 && + descriptor->vert_subsampling == 1 && + descriptor->component_depth == 8) { + st->codec->pix_fmt = AV_PIX_FMT_UYVY422; + } } } } @@ -3071,6 +3101,7 @@ av_freep(&mxf->index_tables[i].segments); av_freep(&mxf->index_tables[i].ptses); av_freep(&mxf->index_tables[i].fake_index); + av_freep(&mxf->index_tables[i].offsets); } } av_freep(&mxf->index_tables); @@ -3144,6 +3175,8 @@ /* behave as if we have a proper index */ if ((sample_time = ff_index_search_timestamp(t->fake_index, t->nb_ptses, sample_time, flags)) < 0) return sample_time; + /* get the stored order index from the display order index */ + sample_time += t->offsets[sample_time]; } else { /* no IndexEntryArray (one or more CBR segments) * make sure we don't seek past the end */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/mxf.h ffmpeg-2.7.2~trusty~ppa1/libavformat/mxf.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/mxf.h 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/mxf.h 2015-07-22 17:20:04.000000000 +0000 @@ -78,6 +78,7 @@ extern const MXFCodecUL ff_mxf_data_definition_uls[]; extern const MXFCodecUL ff_mxf_codec_uls[]; extern const MXFCodecUL ff_mxf_pixel_format_uls[]; +extern const MXFCodecUL ff_mxf_codec_tag_uls[]; int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat *pix_fmt); const MXFSamplesPerFrame *ff_mxf_get_samples_per_frame(AVFormatContext *s, AVRational time_base); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/mxg.c ffmpeg-2.7.2~trusty~ppa1/libavformat/mxg.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/mxg.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/mxg.c 2015-07-28 17:20:07.000000000 +0000 @@ -111,7 +111,7 @@ soi_pos = mxg->soi_ptr - mxg->buffer; buffer = av_fast_realloc(mxg->buffer, &mxg->buffer_size, current_pos + cache_size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!buffer) return AVERROR(ENOMEM); mxg->buffer = buffer; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/network.c ffmpeg-2.7.2~trusty~ppa1/libavformat/network.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/network.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/network.c 2015-08-01 17:20:02.000000000 +0000 @@ -187,12 +187,11 @@ return fd; } -int ff_listen_bind(int fd, const struct sockaddr *addr, - socklen_t addrlen, int timeout, URLContext *h) +int ff_listen(int fd, const struct sockaddr *addr, + socklen_t addrlen) { int ret; int reuse = 1; - struct pollfd lp = { fd, POLLIN, 0 }; if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse))) { av_log(NULL, AV_LOG_WARNING, "setsockopt(SO_REUSEADDR) failed\n"); } @@ -203,6 +202,13 @@ ret = listen(fd, 1); if (ret) return ff_neterrno(); + return ret; +} + +int ff_accept(int fd, int timeout, URLContext *h) +{ + int ret; + struct pollfd lp = { fd, POLLIN, 0 }; ret = ff_poll_interrupt(&lp, 1, timeout, &h->interrupt_callback); if (ret < 0) @@ -211,15 +217,24 @@ ret = accept(fd, NULL, NULL); if (ret < 0) return ff_neterrno(); - - closesocket(fd); - if (ff_socket_nonblock(ret, 1) < 0) av_log(NULL, AV_LOG_DEBUG, "ff_socket_nonblock failed\n"); return ret; } +int ff_listen_bind(int fd, const struct sockaddr *addr, + socklen_t addrlen, int timeout, URLContext *h) +{ + int ret; + if ((ret = ff_listen(fd, addr, addrlen)) < 0) + return ret; + if ((ret = ff_accept(fd, timeout, h)) < 0) + return ret; + closesocket(fd); + return ret; +} + int ff_listen_connect(int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h, int will_try_next) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/network.h ffmpeg-2.7.2~trusty~ppa1/libavformat/network.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/network.h 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/network.h 2015-08-01 17:20:02.000000000 +0000 @@ -255,6 +255,26 @@ URLContext *h); /** + * Bind to a file descriptor to an address without accepting connections. + * @param fd First argument of bind(). + * @param addr Second argument of bind(). + * @param addrlen Third argument of bind(). + * @return 0 on success or an AVERROR on failure. + */ +int ff_listen(int fd, const struct sockaddr *addr, socklen_t addrlen); + +/** + * Poll for a single connection on the passed file descriptor. + * @param fd The listening socket file descriptor. + * @param timeout Polling timeout in milliseconds. + * @param h URLContext providing interrupt check + * callback and logging context. + * @return A non-blocking file descriptor on success + * or an AVERROR on failure. + */ +int ff_accept(int fd, int timeout, URLContext *h); + +/** * Connect to a file descriptor and poll for result. * * @param fd First argument of connect(), diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/nutdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/nutdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/nutdec.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/nutdec.c 2015-07-01 17:20:03.000000000 +0000 @@ -1005,6 +1005,9 @@ AV_WL32(dst+4, skip_end); } + if (avio_tell(bc) >= maxpos) + return AVERROR_INVALIDDATA; + return 0; } @@ -1277,6 +1280,8 @@ next_node[1]->pos, next_node[1]->pos, next_node[0]->ts, next_node[1]->ts, AVSEEK_FLAG_BACKWARD, &ts, nut_read_timestamp); + if (pos < 0) + return pos; if (!(flags & AVSEEK_FLAG_BACKWARD)) { dummy.pos = pos + 16; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/nutenc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/nutenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/nutenc.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/nutenc.c 2015-07-25 17:20:02.000000000 +0000 @@ -933,6 +933,7 @@ break; case AV_PKT_DATA_METADATA_UPDATE: case AV_PKT_DATA_STRINGS_METADATA: + case AV_PKT_DATA_QUALITY_STATS: // belongs into meta, not side data break; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/nut.h ffmpeg-2.7.2~trusty~ppa1/libavformat/nut.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/nut.h 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/nut.h 2015-06-16 17:20:04.000000000 +0000 @@ -41,18 +41,18 @@ #define NUT_MIN_VERSION 2 typedef enum{ - FLAG_KEY = 1, ///nstreams - 1) * sizeof(*ogg->streams)); int i; + int ret = 0; if (!ost) return AVERROR(ENOMEM); @@ -80,15 +82,21 @@ for (i = 0; i < ogg->nstreams; i++) { struct ogg_stream *os = ogg->streams + i; - os->buf = av_mallocz(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE); - memcpy(os->buf, ost->streams[i].buf, os->bufpos); + os->buf = av_mallocz(os->bufsize + AV_INPUT_BUFFER_PADDING_SIZE); + if (os->buf) + memcpy(os->buf, ost->streams[i].buf, os->bufpos); + else + ret = AVERROR(ENOMEM); os->new_metadata = NULL; os->new_metadata_size = 0; } ogg->state = ost; - return 0; + if (ret < 0) + ogg_restore(s, 0); + + return ret; } static int ogg_restore(AVFormatContext *s, int discard) @@ -255,7 +263,7 @@ memset(os, 0, sizeof(*os)); os->serial = serial; os->bufsize = DECODER_BUFFER_SIZE; - os->buf = av_malloc(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE); + os->buf = av_malloc(os->bufsize + AV_INPUT_BUFFER_PADDING_SIZE); os->header = -1; os->start_granule = OGG_NOGRANULE_VALUE; if (!os->buf) @@ -277,7 +285,7 @@ static int ogg_new_buf(struct ogg *ogg, int idx) { struct ogg_stream *os = ogg->streams + idx; - uint8_t *nb = av_malloc(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE); + uint8_t *nb = av_malloc(os->bufsize + AV_INPUT_BUFFER_PADDING_SIZE); int size = os->bufpos - os->pstart; if (!nb) @@ -416,7 +424,7 @@ } if (os->bufsize - os->bufpos < size) { - uint8_t *nb = av_malloc((os->bufsize *= 2) + FF_INPUT_BUFFER_PADDING_SIZE); + uint8_t *nb = av_malloc((os->bufsize *= 2) + AV_INPUT_BUFFER_PADDING_SIZE); if (!nb) return AVERROR(ENOMEM); memcpy(nb, os->buf, os->bufpos); @@ -432,7 +440,7 @@ os->granule = gp; os->flags = flags; - memset(os->buf + os->bufpos, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(os->buf + os->bufpos, 0, AV_INPUT_BUFFER_PADDING_SIZE); if (sid) *sid = idx; @@ -899,6 +907,7 @@ os->keyframe_seek = 1; ret = ff_seek_frame_binary(s, stream_index, timestamp, flags); + ogg_reset(s); os = ogg->streams + stream_index; if (ret < 0) os->keyframe_seek = 0; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/oggparsedirac.c ffmpeg-2.7.2~trusty~ppa1/libavformat/oggparsedirac.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/oggparsedirac.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/oggparsedirac.c 2015-07-09 17:20:03.000000000 +0000 @@ -31,14 +31,19 @@ AVStream *st = s->streams[idx]; dirac_source_params source; GetBitContext gb; + int ret; // already parsed the header if (st->codec->codec_id == AV_CODEC_ID_DIRAC) return 0; - init_get_bits(&gb, os->buf + os->pstart + 13, (os->psize - 13) * 8); - if (avpriv_dirac_parse_sequence_header(st->codec, &gb, &source) < 0) - return -1; + ret = init_get_bits8(&gb, os->buf + os->pstart + 13, (os->psize - 13)); + if (ret < 0) + return ret; + + ret = avpriv_dirac_parse_sequence_header(st->codec, &gb, &source); + if (ret < 0) + return ret; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_DIRAC; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/oggparseogm.c ffmpeg-2.7.2~trusty~ppa1/libavformat/oggparseogm.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/oggparseogm.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/oggparseogm.c 2015-07-28 17:20:07.000000000 +0000 @@ -102,7 +102,7 @@ size -= 4; } if (size > 52) { - av_assert0(FF_INPUT_BUFFER_PADDING_SIZE <= 52); + av_assert0(AV_INPUT_BUFFER_PADDING_SIZE <= 52); size -= 52; ff_alloc_extradata(st->codec, size); bytestream2_get_buffer(&p, st->codec->extradata, st->codec->extradata_size); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/oggparsetheora.c ffmpeg-2.7.2~trusty~ppa1/libavformat/oggparsetheora.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/oggparsetheora.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/oggparsetheora.c 2015-07-28 17:20:07.000000000 +0000 @@ -127,11 +127,11 @@ } if ((err = av_reallocp(&st->codec->extradata, - cds + FF_INPUT_BUFFER_PADDING_SIZE)) < 0) { + cds + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) { st->codec->extradata_size = 0; return err; } - memset(st->codec->extradata + cds, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(st->codec->extradata + cds, 0, AV_INPUT_BUFFER_PADDING_SIZE); cdp = st->codec->extradata + st->codec->extradata_size; *cdp++ = os->psize >> 8; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/oggparsevorbis.c ffmpeg-2.7.2~trusty~ppa1/libavformat/oggparsevorbis.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/oggparsevorbis.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/oggparsevorbis.c 2015-07-28 17:20:07.000000000 +0000 @@ -242,7 +242,7 @@ offset += priv->len[i]; av_freep(&priv->packet[i]); } - if ((err = av_reallocp(buf, offset + FF_INPUT_BUFFER_PADDING_SIZE)) < 0) + if ((err = av_reallocp(buf, offset + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) return err; return offset; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/options.c ffmpeg-2.7.2~trusty~ppa1/libavformat/options.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/options.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/options.c 2015-07-04 21:09:16.000000000 +0000 @@ -20,6 +20,8 @@ #include "avformat.h" #include "avio_internal.h" #include "internal.h" + +#include "libavutil/internal.h" #include "libavutil/opt.h" /** @@ -27,7 +29,9 @@ * Options definition for AVFormatContext. */ +FF_DISABLE_DEPRECATION_WARNINGS #include "options_table.h" +FF_ENABLE_DEPRECATION_WARNINGS static const char* format_to_name(void* ptr) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/qcp.c ffmpeg-2.7.2~trusty~ppa1/libavformat/qcp.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/qcp.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/qcp.c 2015-06-21 17:20:02.000000000 +0000 @@ -57,6 +57,11 @@ 0x91, 0xef, 0x73, 0x6a, 0x51, 0x00, 0xce, 0xb4 }; +static const uint8_t guid_4gv[16] = { + 0xca, 0x29, 0xfd, 0x3c, 0x53, 0xf6, 0xf5, 0x4e, + 0x90, 0xe9, 0xf4, 0x23, 0x6d, 0x59, 0x9b, 0x61 +}; + /** * SMV GUID as stored in the file */ @@ -106,6 +111,8 @@ st->codec->codec_id = AV_CODEC_ID_EVRC; } else if (!memcmp(buf, guid_smv, 16)) { st->codec->codec_id = AV_CODEC_ID_SMV; + } else if (!memcmp(buf, guid_4gv, 16)) { + st->codec->codec_id = AV_CODEC_ID_4GV; } else { av_log(s, AV_LOG_ERROR, "Unknown codec GUID "FF_PRI_GUID".\n", FF_ARG_GUID(buf)); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/rawdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/rawdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/rawdec.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/rawdec.c 2015-07-30 17:20:02.000000000 +0000 @@ -188,10 +188,10 @@ } if (nb_invalid*4 + 1 < nb_frames) { - static const char ct_jpeg[] = "\r\nContent-Type: image/jpeg\r\n\r\n"; + static const char ct_jpeg[] = "\r\nContent-Type: image/jpeg\r\n"; int i; - for (i=0; ibuf_size - sizeof(ct_jpeg), 100); i++) + for (i=0; ibuf_size - (int)sizeof(ct_jpeg), 100); i++) if (!memcmp(p->buf + i, ct_jpeg, sizeof(ct_jpeg) - 1)) return AVPROBE_SCORE_EXTENSION; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/rawenc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/rawenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/rawenc.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/rawenc.c 2015-06-21 17:20:02.000000000 +0000 @@ -56,6 +56,25 @@ #endif #if CONFIG_ADX_MUXER + +static int adx_write_trailer(AVFormatContext *s) +{ + AVIOContext *pb = s->pb; + AVCodecContext *avctx = s->streams[0]->codec; + + if (pb->seekable) { + int64_t file_size = avio_tell(pb); + uint64_t sample_count = (file_size - 36) / avctx->channels / 18 * 32; + if (sample_count <= UINT32_MAX) { + avio_seek(pb, 12, SEEK_SET); + avio_wb32(pb, sample_count); + avio_seek(pb, file_size, SEEK_SET); + } + } + + return 0; +} + AVOutputFormat ff_adx_muxer = { .name = "adx", .long_name = NULL_IF_CONFIG_SMALL("CRI ADX"), @@ -64,6 +83,7 @@ .video_codec = AV_CODEC_ID_NONE, .write_header = force_one_stream, .write_packet = ff_raw_write_packet, + .write_trailer = adx_write_trailer, .flags = AVFMT_NOTIMESTAMPS, }; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/rdt.c ffmpeg-2.7.2~trusty~ppa1/libavformat/rdt.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/rdt.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/rdt.c 2015-07-28 17:20:07.000000000 +0000 @@ -86,7 +86,7 @@ RMStream **rmst; uint8_t *mlti_data; unsigned int mlti_data_size; - char buffer[RTP_MAX_PACKET_LENGTH + FF_INPUT_BUFFER_PADDING_SIZE]; + char buffer[RTP_MAX_PACKET_LENGTH + AV_INPUT_BUFFER_PADDING_SIZE]; int audio_pkt_cnt; /**< remaining audio packets in rmdec */ }; @@ -398,7 +398,7 @@ len -= 2; /* skip embracing " at start/end */ } *target_len = len * 3 / 4; - target = av_mallocz(*target_len + FF_INPUT_BUFFER_PADDING_SIZE); + target = av_mallocz(*target_len + AV_INPUT_BUFFER_PADDING_SIZE); if (!target) return NULL; av_base64_decode(target, p, *target_len); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/redspark.c ffmpeg-2.7.2~trusty~ppa1/libavformat/redspark.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/redspark.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/redspark.c 2015-07-28 17:20:07.000000000 +0000 @@ -67,7 +67,7 @@ return AVERROR(ENOMEM); codec = st->codec; - header = av_malloc(HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); + header = av_malloc(HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE); if (!header) return AVERROR(ENOMEM); pbc = header; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/riff.c ffmpeg-2.7.2~trusty~ppa1/libavformat/riff.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/riff.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/riff.c 2015-06-16 17:20:04.000000000 +0000 @@ -112,6 +112,7 @@ { AV_CODEC_ID_MPEG4, MKTAG('P', 'L', 'V', '1') }, /* Pelco DVR MPEG-4 */ { AV_CODEC_ID_MPEG4, MKTAG('G', 'L', 'V', '4') }, { AV_CODEC_ID_MPEG4, MKTAG('G', 'M', 'P', '4') }, /* GeoVision camera */ + { AV_CODEC_ID_MPEG4, MKTAG('M', 'N', 'M', '4') }, /* March Networks DVR */ { AV_CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') }, { AV_CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, { AV_CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/riffdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/riffdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/riffdec.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/riffdec.c 2015-07-12 17:20:02.000000000 +0000 @@ -31,10 +31,12 @@ int ff_get_guid(AVIOContext *s, ff_asf_guid *g) { + int ret; av_assert0(sizeof(*g) == 16); //compiler will optimize this out - if (avio_read(s, *g, sizeof(*g)) < (int)sizeof(*g)) { + ret = avio_read(s, *g, sizeof(*g)); + if (ret < (int)sizeof(*g)) { memset(*g, 0, sizeof(*g)); - return AVERROR_INVALIDDATA; + return ret < 0 ? ret : AVERROR_INVALIDDATA; } return 0; } @@ -81,25 +83,29 @@ } /* "big_endian" values are needed for RIFX file format */ -int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size, int big_endian) +int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, + AVCodecContext *codec, int size, int big_endian) { int id; + uint64_t bitrate; - if (size < 14) + if (size < 14) { avpriv_request_sample(codec, "wav header size < 14"); + return AVERROR_INVALIDDATA; + } codec->codec_type = AVMEDIA_TYPE_AUDIO; if (!big_endian) { id = avio_rl16(pb); codec->channels = avio_rl16(pb); codec->sample_rate = avio_rl32(pb); - codec->bit_rate = avio_rl32(pb) * 8; + bitrate = avio_rl32(pb) * 8LL; codec->block_align = avio_rl16(pb); } else { id = avio_rb16(pb); codec->channels = avio_rb16(pb); codec->sample_rate = avio_rb32(pb); - codec->bit_rate = avio_rb32(pb) * 8; + bitrate = avio_rb32(pb) * 8LL; codec->block_align = avio_rb16(pb); } if (size == 14) { /* We're dealing with plain vanilla WAVEFORMAT */ @@ -142,8 +148,25 @@ if (size > 0) avio_skip(pb, size); } + + if (bitrate > INT_MAX) { + if (s->error_recognition & AV_EF_EXPLODE) { + av_log(s, AV_LOG_ERROR, + "The bitrate %"PRIu64" is too large.\n", + bitrate); + return AVERROR_INVALIDDATA; + } else { + av_log(s, AV_LOG_WARNING, + "The bitrate %"PRIu64" is too large, resetting to 0.", + bitrate); + codec->bit_rate = 0; + } + } else { + codec->bit_rate = bitrate; + } + if (codec->sample_rate <= 0) { - av_log(NULL, AV_LOG_ERROR, + av_log(s, AV_LOG_ERROR, "Invalid sample rate: %d\n", codec->sample_rate); return AVERROR_INVALIDDATA; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/riff.h ffmpeg-2.7.2~trusty~ppa1/libavformat/riff.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/riff.h 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/riff.h 2015-07-12 17:20:02.000000000 +0000 @@ -62,7 +62,7 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc, int flags); enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps); -int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size, int big_endian); +int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecContext *codec, int size, int big_endian); extern const AVCodecTag ff_codec_bmp_tags[]; // exposed through avformat_get_riff_video_tags() extern const AVCodecTag ff_codec_wav_tags[]; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/rmdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/rmdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/rmdec.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/rmdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -220,7 +220,7 @@ if (version == 5) avio_r8(pb); codecdata_length = avio_rb32(pb); - if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){ + if(codecdata_length + AV_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){ av_log(s, AV_LOG_ERROR, "codecdata_length too large\n"); return -1; } @@ -250,7 +250,7 @@ if (version == 5) avio_r8(pb); codecdata_length = avio_rb32(pb); - if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){ + if(codecdata_length + AV_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){ av_log(s, AV_LOG_ERROR, "codecdata_length too large\n"); return -1; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/rtmp.h ffmpeg-2.7.2~trusty~ppa1/libavformat/rtmp.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/rtmp.h 2015-03-15 02:46:04.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/rtmp.h 2015-07-30 17:20:02.000000000 +0000 @@ -29,9 +29,6 @@ #define RTMP_HANDSHAKE_PACKET_SIZE 1536 -#define HMAC_IPAD_VAL 0x36 -#define HMAC_OPAD_VAL 0x5C - /** * emulated Flash client version - 9.0.124.2 on Linux * @{ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/rtmpproto.c ffmpeg-2.7.2~trusty~ppa1/libavformat/rtmpproto.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/rtmpproto.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/rtmpproto.c 2015-07-30 17:20:02.000000000 +0000 @@ -27,12 +27,12 @@ #include "libavcodec/bytestream.h" #include "libavutil/avstring.h" #include "libavutil/base64.h" +#include "libavutil/hmac.h" #include "libavutil/intfloat.h" #include "libavutil/lfg.h" #include "libavutil/md5.h" #include "libavutil/opt.h" #include "libavutil/random_seed.h" -#include "libavutil/sha.h" #include "avformat.h" #include "internal.h" @@ -49,8 +49,8 @@ #endif #define APP_MAX_LENGTH 1024 -#define PLAYPATH_MAX_LENGTH 256 -#define TCURL_MAX_LENGTH 512 +#define PLAYPATH_MAX_LENGTH 512 +#define TCURL_MAX_LENGTH 1024 #define FLASHVER_MAX_LENGTH 64 #define RTMP_PKTDATA_DEFAULT_SIZE 4096 #define RTMP_HEADER 11 @@ -956,41 +956,22 @@ int ff_rtmp_calc_digest(const uint8_t *src, int len, int gap, const uint8_t *key, int keylen, uint8_t *dst) { - struct AVSHA *sha; - uint8_t hmac_buf[64+32] = {0}; - int i; + AVHMAC *hmac; - sha = av_sha_alloc(); - if (!sha) + hmac = av_hmac_alloc(AV_HMAC_SHA256); + if (!hmac) return AVERROR(ENOMEM); - if (keylen < 64) { - memcpy(hmac_buf, key, keylen); - } else { - av_sha_init(sha, 256); - av_sha_update(sha,key, keylen); - av_sha_final(sha, hmac_buf); - } - for (i = 0; i < 64; i++) - hmac_buf[i] ^= HMAC_IPAD_VAL; - - av_sha_init(sha, 256); - av_sha_update(sha, hmac_buf, 64); + av_hmac_init(hmac, key, keylen); if (gap <= 0) { - av_sha_update(sha, src, len); + av_hmac_update(hmac, src, len); } else { //skip 32 bytes used for storing digest - av_sha_update(sha, src, gap); - av_sha_update(sha, src + gap + 32, len - gap - 32); + av_hmac_update(hmac, src, gap); + av_hmac_update(hmac, src + gap + 32, len - gap - 32); } - av_sha_final(sha, hmac_buf + 64); - - for (i = 0; i < 64; i++) - hmac_buf[i] ^= HMAC_IPAD_VAL ^ HMAC_OPAD_VAL; //reuse XORed key for opad - av_sha_init(sha, 256); - av_sha_update(sha, hmac_buf, 64+32); - av_sha_final(sha, dst); + av_hmac_final(hmac, dst, 32); - av_free(sha); + av_hmac_free(hmac); return 0; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/rtpdec_h264.c ffmpeg-2.7.2~trusty~ppa1/libavformat/rtpdec_h264.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/rtpdec_h264.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/rtpdec_h264.c 2015-07-28 17:20:07.000000000 +0000 @@ -119,7 +119,7 @@ uint8_t *dest = av_realloc(*data_ptr, packet_size + sizeof(start_sequence) + *size_ptr + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!dest) { av_log(s, AV_LOG_ERROR, "Unable to allocate memory for extradata!\n"); @@ -132,7 +132,7 @@ memcpy(dest + *size_ptr + sizeof(start_sequence), decoded_packet, packet_size); memset(dest + *size_ptr + sizeof(start_sequence) + - packet_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + packet_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); *size_ptr += sizeof(start_sequence) + packet_size; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/rtpdec_hevc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/rtpdec_hevc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/rtpdec_hevc.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/rtpdec_hevc.c 2015-07-28 17:20:07.000000000 +0000 @@ -152,7 +152,7 @@ codec->extradata_size = hevc_data->vps_size + hevc_data->sps_size + hevc_data->pps_size + hevc_data->sei_size; codec->extradata = av_malloc(codec->extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!codec->extradata) { ret = AVERROR(ENOMEM); codec->extradata_size = 0; @@ -166,7 +166,7 @@ pos += hevc_data->pps_size; memcpy(codec->extradata + pos, hevc_data->sei, hevc_data->sei_size); pos += hevc_data->sei_size; - memset(codec->extradata + pos, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(codec->extradata + pos, 0, AV_INPUT_BUFFER_PADDING_SIZE); } av_freep(&hevc_data->vps); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/rtpdec_latm.c ffmpeg-2.7.2~trusty~ppa1/libavformat/rtpdec_latm.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/rtpdec_latm.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/rtpdec_latm.c 2015-07-28 17:20:07.000000000 +0000 @@ -97,7 +97,7 @@ int audio_mux_version, same_time_framing, num_programs, num_layers; /* Pad this buffer, too, to avoid out of bounds reads with get_bits below */ - config = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); + config = av_mallocz(len + AV_INPUT_BUFFER_PADDING_SIZE); if (!config) return AVERROR(ENOMEM); ff_hex_to_data(config, value); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/rtpdec_qt.c ffmpeg-2.7.2~trusty~ppa1/libavformat/rtpdec_qt.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/rtpdec_qt.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/rtpdec_qt.c 2015-07-28 17:20:07.000000000 +0000 @@ -174,14 +174,14 @@ if (qt->pkt.size > 0 && qt->timestamp == *timestamp) { int err; if ((err = av_reallocp(&qt->pkt.data, qt->pkt.size + alen + - FF_INPUT_BUFFER_PADDING_SIZE)) < 0) { + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) { qt->pkt.size = 0; return err; } } else { av_freep(&qt->pkt.data); av_init_packet(&qt->pkt); - qt->pkt.data = av_realloc(NULL, alen + FF_INPUT_BUFFER_PADDING_SIZE); + qt->pkt.data = av_realloc(NULL, alen + AV_INPUT_BUFFER_PADDING_SIZE); if (!qt->pkt.data) return AVERROR(ENOMEM); qt->pkt.size = 0; @@ -198,7 +198,7 @@ qt->pkt.data = NULL; pkt->flags = keyframe ? AV_PKT_FLAG_KEY : 0; pkt->stream_index = st->index; - memset(pkt->data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE); return 0; } return AVERROR(EAGAIN); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/rtpdec_xiph.c ffmpeg-2.7.2~trusty~ppa1/libavformat/rtpdec_xiph.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/rtpdec_xiph.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/rtpdec_xiph.c 2015-07-28 17:20:07.000000000 +0000 @@ -262,8 +262,8 @@ /* allocate extra space: * -- length/255 +2 for xiphlacing * -- one for the '2' marker - * -- FF_INPUT_BUFFER_PADDING_SIZE required */ - extradata_alloc = length + length/255 + 3 + FF_INPUT_BUFFER_PADDING_SIZE; + * -- AV_INPUT_BUFFER_PADDING_SIZE required */ + extradata_alloc = length + length/255 + 3 + AV_INPUT_BUFFER_PADDING_SIZE; if (ff_alloc_extradata(codec, extradata_alloc)) { av_log(codec, AV_LOG_ERROR, "Out of memory\n"); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/rtpenc_jpeg.c ffmpeg-2.7.2~trusty~ppa1/libavformat/rtpenc_jpeg.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/rtpenc_jpeg.c 2015-06-19 20:44:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/rtpenc_jpeg.c 2015-07-20 17:20:03.000000000 +0000 @@ -21,13 +21,14 @@ #include "libavcodec/bytestream.h" #include "libavcodec/mjpeg.h" +#include "libavcodec/jpegtables.h" #include "libavutil/intreadwrite.h" #include "rtpenc.h" void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size) { RTPMuxContext *s = s1->priv_data; - const uint8_t *qtables = NULL; + const uint8_t *qtables[4] = { NULL }; int nb_qtables = 0; uint8_t type; uint8_t w, h; @@ -63,24 +64,50 @@ continue; if (buf[i + 1] == DQT) { - if (buf[i + 4]) + int tables, j; + if (buf[i + 4] & 0xF0) av_log(s1, AV_LOG_WARNING, "Only 8-bit precision is supported.\n"); /* a quantization table is 64 bytes long */ - nb_qtables = AV_RB16(&buf[i + 2]) / 65; - if (i + 4 + nb_qtables * 65 > size) { + tables = AV_RB16(&buf[i + 2]) / 65; + if (i + 5 + tables * 65 > size) { av_log(s1, AV_LOG_ERROR, "Too short JPEG header. Aborted!\n"); return; } + if (nb_qtables + tables > 4) { + av_log(s1, AV_LOG_ERROR, "Invalid number of quantisation tables\n"); + return; + } - qtables = &buf[i + 4]; + for (j = 0; j < tables; j++) + qtables[nb_qtables + j] = buf + i + 5 + j * 65; + nb_qtables += tables; } else if (buf[i + 1] == SOF0) { if (buf[i + 14] != 17 || buf[i + 17] != 17) { av_log(s1, AV_LOG_ERROR, "Only 1x1 chroma blocks are supported. Aborted!\n"); return; } + } else if (buf[i + 1] == DHT) { + if ( AV_RB16(&buf[i + 2]) < 418 + || i + 420 >= size + || buf[i + 4] != 0x00 + || buf[i + 33] != 0x01 + || buf[i + 62] != 0x10 + || buf[i + 241] != 0x11 + || memcmp(buf + i + 5, avpriv_mjpeg_bits_dc_luminance + 1, 16) + || memcmp(buf + i + 21, avpriv_mjpeg_val_dc, 12) + || memcmp(buf + i + 34, avpriv_mjpeg_bits_dc_chrominance + 1, 16) + || memcmp(buf + i + 50, avpriv_mjpeg_val_dc, 12) + || memcmp(buf + i + 63, avpriv_mjpeg_bits_ac_luminance + 1, 16) + || memcmp(buf + i + 79, avpriv_mjpeg_val_ac_luminance, 162) + || memcmp(buf + i + 242, avpriv_mjpeg_bits_ac_chrominance + 1, 16) + || memcmp(buf + i + 258, avpriv_mjpeg_val_ac_chrominance, 162)) { + av_log(s1, AV_LOG_ERROR, + "RFC 2435 requires standard Huffman tables for jpeg\n"); + return; + } } else if (buf[i + 1] == SOS) { /* SOS is last marker in the header */ i += AV_RB16(&buf[i + 2]) + 2; @@ -92,6 +119,10 @@ break; } } + if (nb_qtables && nb_qtables != 2) + av_log(s1, AV_LOG_WARNING, + "RFC 2435 suggests two quantization tables, %d provided\n", + nb_qtables); /* skip JPEG header */ buf += i; @@ -130,7 +161,7 @@ bytestream_put_be16(&p, 64 * nb_qtables); for (i = 0; i < nb_qtables; i++) - bytestream_put_buffer(&p, &qtables[65 * i + 1], 64); + bytestream_put_buffer(&p, qtables[i], 64); } /* copy payload data */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/rtsp.c ffmpeg-2.7.2~trusty~ppa1/libavformat/rtsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/rtsp.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/rtsp.c 2015-07-30 17:20:02.000000000 +0000 @@ -1136,6 +1136,7 @@ unsigned char ch; const char *p; int ret, content_length, line_count = 0, request = 0; + int first_line = 1; unsigned char *content = NULL; start: @@ -1155,8 +1156,7 @@ return AVERROR_EOF; if (ch == '\n') break; - if (ch == '$') { - /* XXX: only parse it if first char on line ? */ + if (ch == '$' && first_line && q == buf) { if (return_on_interleaved_data) { return 1; } else @@ -1167,6 +1167,7 @@ } } *q = '\0'; + first_line = 0; av_log(s, AV_LOG_TRACE, "line='%s'\n", buf); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/sdp.c ffmpeg-2.7.2~trusty~ppa1/libavformat/sdp.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/sdp.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/sdp.c 2015-07-28 17:20:07.000000000 +0000 @@ -685,7 +685,7 @@ const char *mode; uint64_t vad_option; - if (c->flags & CODEC_FLAG_QSCALE) + if (c->flags & AV_CODEC_FLAG_QSCALE) mode = "on"; else if (!av_opt_get_int(c, "vad", AV_OPT_FLAG_ENCODING_PARAM, &vad_option) && vad_option) mode = "vad"; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/segment.c ffmpeg-2.7.2~trusty~ppa1/libavformat/segment.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/segment.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/segment.c 2015-06-13 17:20:02.000000000 +0000 @@ -860,7 +860,8 @@ if (!seg->write_header_trailer) { if ((ret = segment_end(s, 0, 1)) < 0) goto fail; - open_null_ctx(&oc->pb); + if ((ret = open_null_ctx(&oc->pb)) < 0) + goto fail; ret = av_write_trailer(oc); close_null_ctxp(&oc->pb); } else { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/spdifenc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/spdifenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/spdifenc.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/spdifenc.c 2015-07-28 17:20:07.000000000 +0000 @@ -525,7 +525,7 @@ if (ctx->extra_bswap ^ (ctx->spdif_flags & SPDIF_FLAG_BIGENDIAN)) { avio_write(s->pb, ctx->out_buf, ctx->out_bytes & ~1); } else { - av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->out_bytes + FF_INPUT_BUFFER_PADDING_SIZE); + av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->out_bytes + AV_INPUT_BUFFER_PADDING_SIZE); if (!ctx->buffer) return AVERROR(ENOMEM); ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (uint16_t *)ctx->out_buf, ctx->out_bytes >> 1); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/swfdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/swfdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/swfdec.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/swfdec.c 2015-07-08 17:20:04.000000000 +0000 @@ -407,10 +407,8 @@ } if (st->codec->pix_fmt != AV_PIX_FMT_NONE && st->codec->pix_fmt != pix_fmt) { av_log(s, AV_LOG_ERROR, "pixel format change unsupported\n"); - res = AVERROR_PATCHWELCOME; - goto bitmap_end; - } - st->codec->pix_fmt = pix_fmt; + } else + st->codec->pix_fmt = pix_fmt; if (linesize * height > pkt->size) { res = AVERROR_INVALIDDATA; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/takdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/takdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/takdec.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/takdec.c 2015-07-28 17:20:07.000000000 +0000 @@ -82,10 +82,10 @@ if (size <= 3) return AVERROR_INVALIDDATA; - buffer = av_malloc(size - 3 + FF_INPUT_BUFFER_PADDING_SIZE); + buffer = av_malloc(size - 3 + AV_INPUT_BUFFER_PADDING_SIZE); if (!buffer) return AVERROR(ENOMEM); - memset(buffer + size - 3, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(buffer + size - 3, 0, AV_INPUT_BUFFER_PADDING_SIZE); ffio_init_checksum(pb, tak_check_crc, 0xCE04B7U); if (avio_read(pb, buffer, size - 3) != size - 3) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/tcp.c ffmpeg-2.7.2~trusty~ppa1/libavformat/tcp.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/tcp.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/tcp.c 2015-08-01 17:20:02.000000000 +0000 @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avformat.h" +#include "libavutil/avassert.h" #include "libavutil/parseutils.h" #include "libavutil/opt.h" #include "libavutil/time.h" @@ -44,7 +45,7 @@ #define D AV_OPT_FLAG_DECODING_PARAM #define E AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "listen", "Listen for incoming connections", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = D|E }, + { "listen", "Listen for incoming connections", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, .flags = D|E }, { "timeout", "set timeout (in microseconds) of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "listen_timeout", "Connection awaiting timeout (in milliseconds)", OFFSET(listen_timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { NULL } @@ -125,12 +126,17 @@ goto fail; } - if (s->listen) { - if ((ret = ff_listen_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen, - s->listen_timeout, h)) < 0) { + if (s->listen == 2) { + // multi-client + if ((ret = ff_listen(fd, cur_ai->ai_addr, cur_ai->ai_addrlen)) < 0) + goto fail1; + } else if (s->listen == 1) { + // single client + if ((fd = ff_listen_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen, + s->listen_timeout, h)) < 0) { + ret = fd; goto fail1; } - fd = ret; } else { if ((ret = ff_listen_connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen, s->open_timeout / 1000, h, !!cur_ai->ai_next)) < 0) { @@ -163,6 +169,22 @@ return ret; } +static int tcp_accept(URLContext *s, URLContext **c) +{ + TCPContext *sc = s->priv_data; + TCPContext *cc; + int ret; + av_assert0(sc->listen); + if ((ret = ffurl_alloc(c, s->filename, s->flags, &s->interrupt_callback)) < 0) + return ret; + cc = (*c)->priv_data; + ret = ff_accept(sc->fd, sc->listen_timeout, s); + if (ret < 0) + return ff_neterrno(); + cc->fd = ret; + return 0; +} + static int tcp_read(URLContext *h, uint8_t *buf, int size) { TCPContext *s = h->priv_data; @@ -223,6 +245,7 @@ URLProtocol ff_tcp_protocol = { .name = "tcp", .url_open = tcp_open, + .url_accept = tcp_accept, .url_read = tcp_read, .url_write = tcp_write, .url_close = tcp_close, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/url.h ffmpeg-2.7.2~trusty~ppa1/libavformat/url.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/url.h 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/url.h 2015-08-01 17:20:02.000000000 +0000 @@ -58,6 +58,8 @@ * for those nested protocols. */ int (*url_open2)(URLContext *h, const char *url, int flags, AVDictionary **options); + int (*url_accept)(URLContext *s, URLContext **c); + int (*url_handshake)(URLContext *c); /** * Read data from the protocol. @@ -90,6 +92,8 @@ int (*url_open_dir)(URLContext *h); int (*url_read_dir)(URLContext *h, AVIODirEntry **next); int (*url_close_dir)(URLContext *h); + int (*url_delete)(URLContext *h); + int (*url_move)(URLContext *h_src, URLContext *h_dst); } URLProtocol; /** @@ -138,6 +142,29 @@ const AVIOInterruptCB *int_cb, AVDictionary **options); /** + * Accept an URLContext c on an URLContext s + * + * @param s server context + * @param c client context, must be unallocated. + * @return >= 0 on success, ff_neterrno() on failure. + */ +int ffurl_accept(URLContext *s, URLContext **c); + +/** + * Perform one step of the protocol handshake to accept a new client. + * See avio_handshake() for details. + * Implementations should try to return decreasing values. + * If the protocol uses an underlying protocol, the underlying handshake is + * usually the first step, and the return value can be: + * (largest value for this protocol) + (return value from other protocol) + * + * @param c the client context + * @return >= 0 on success or a negative value corresponding + * to an AVERROR code on failure + */ +int ffurl_handshake(URLContext *c); + +/** * Read up to size bytes from the resource accessed by h, and store * the read bytes in buf. * diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/utils.c ffmpeg-2.7.2~trusty~ppa1/libavformat/utils.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/utils.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/utils.c 2015-07-28 17:20:07.000000000 +0000 @@ -1585,26 +1585,26 @@ int i; AVStream *st; int best_stream = 0; - int best_score = -1; + int best_score = INT_MIN; if (s->nb_streams <= 0) return -1; for (i = 0; i < s->nb_streams; i++) { int score = 0; st = s->streams[i]; - if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && - !(st->disposition & AV_DISPOSITION_ATTACHED_PIC)) { - if (!st->codec->width && !st->codec->height && !st->codec_info_nb_frames) - score += 25; - else - score += 100; + if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) + score -= 400; + if (st->codec->width && st->codec->height) + score += 50; + score+= 25; } if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { - if (!st->codec->sample_rate && !st->codec_info_nb_frames) - score += 12; - else + if (st->codec->sample_rate) score += 50; } + if (st->codec_info_nb_frames) + score += 12; if (st->discard != AVDISCARD_ALL) score += 200; @@ -1781,6 +1781,63 @@ return m; } +void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance) +{ + int ist1, ist2; + int64_t pos_delta = 0; + int64_t skip = 0; + //We could use URLProtocol flags here but as many user applications do not use URLProtocols this would be unreliable + const char *proto = avio_find_protocol_name(s->filename); + + if (!proto) { + av_log(s, AV_LOG_INFO, + "Protocol name not provided, cannot determine if input is local or " + "a network protocol, buffers and access patterns cannot be configured " + "optimally without knowing the protocol\n"); + } + + if (proto && !(strcmp(proto, "file") && strcmp(proto, "pipe") && strcmp(proto, "cache"))) + return; + + for (ist1 = 0; ist1 < s->nb_streams; ist1++) { + AVStream *st1 = s->streams[ist1]; + for (ist2 = 0; ist2 < s->nb_streams; ist2++) { + AVStream *st2 = s->streams[ist2]; + int i1, i2; + + if (ist1 == ist2) + continue; + + for (i1 = i2 = 0; i1 < st1->nb_index_entries; i1++) { + AVIndexEntry *e1 = &st1->index_entries[i1]; + int64_t e1_pts = av_rescale_q(e1->timestamp, st1->time_base, AV_TIME_BASE_Q); + + skip = FFMAX(skip, e1->size); + for (; i2 < st2->nb_index_entries; i2++) { + AVIndexEntry *e2 = &st2->index_entries[i2]; + int64_t e2_pts = av_rescale_q(e2->timestamp, st2->time_base, AV_TIME_BASE_Q); + if (e2_pts - e1_pts < time_tolerance) + continue; + pos_delta = FFMAX(pos_delta, e1->pos - e2->pos); + break; + } + } + } + } + + pos_delta *= 2; + /* XXX This could be adjusted depending on protocol*/ + if (s->pb->buffer_size < pos_delta && pos_delta < (1<<24)) { + av_log(s, AV_LOG_VERBOSE, "Reconfiguring buffers to size %"PRId64"\n", pos_delta); + ffio_set_buf_size(s->pb, pos_delta); + s->pb->short_seek_threshold = FFMAX(s->pb->short_seek_threshold, pos_delta/2); + } + + if (skip < (1<<23)) { + s->pb->short_seek_threshold = FFMAX(s->pb->short_seek_threshold, skip); + } +} + int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp, int flags) { return ff_index_search_timestamp(st->index_entries, st->nb_index_entries, @@ -2665,7 +2722,7 @@ ret >= 0 && (!has_codec_parameters(st, NULL) || !has_decode_delay_been_guessed(st) || (!st->codec_info_nb_frames && - st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF))) { + (st->codec->codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF)))) { got_picture = 0; switch (st->codec->codec_type) { case AVMEDIA_TYPE_VIDEO: @@ -2865,14 +2922,14 @@ { int ret; - if (size < 0 || size >= INT32_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { + if (size < 0 || size >= INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE) { avctx->extradata = NULL; avctx->extradata_size = 0; return AVERROR(EINVAL); } - avctx->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE); if (avctx->extradata) { - memset(avctx->extradata + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(avctx->extradata + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); avctx->extradata_size = size; ret = 0; } else { @@ -3033,6 +3090,7 @@ int flush_codecs; int64_t max_analyze_duration = ic->max_analyze_duration2; int64_t max_stream_analyze_duration; + int64_t max_subtitle_analyze_duration; int64_t probesize = ic->probesize2; if (!max_analyze_duration) @@ -3044,9 +3102,11 @@ av_opt_set(ic, "skip_clear", "1", AV_OPT_SEARCH_CHILDREN); max_stream_analyze_duration = max_analyze_duration; + max_subtitle_analyze_duration = max_analyze_duration; if (!max_analyze_duration) { max_stream_analyze_duration = max_analyze_duration = 5*AV_TIME_BASE; + max_subtitle_analyze_duration = 30*AV_TIME_BASE; if (!strcmp(ic->iformat->name, "flv")) max_stream_analyze_duration = 30*AV_TIME_BASE; } @@ -3264,6 +3324,7 @@ } if (st->codec_info_nb_frames>1) { int64_t t = 0; + int64_t limit; if (st->time_base.den > 0) t = av_rescale_q(st->info->codec_info_duration, st->time_base, AV_TIME_BASE_Q); @@ -3276,10 +3337,14 @@ && st->info->fps_last_dts != AV_NOPTS_VALUE) t = FFMAX(t, av_rescale_q(st->info->fps_last_dts - st->info->fps_first_dts, st->time_base, AV_TIME_BASE_Q)); - if (t >= (analyzed_all_streams ? max_analyze_duration : max_stream_analyze_duration)) { - av_log(ic, AV_LOG_VERBOSE, "max_analyze_duration %"PRId64" reached at %"PRId64" microseconds\n", + if (analyzed_all_streams) limit = max_analyze_duration; + else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) limit = max_subtitle_analyze_duration; + else limit = max_stream_analyze_duration; + + if (t >= limit) { + av_log(ic, AV_LOG_VERBOSE, "max_analyze_duration %"PRId64" reached at %"PRId64" microseconds st:%d\n", max_analyze_duration, - t); + t, pkt->stream_index); if (ic->flags & AVFMT_FLAG_NOBUFFER) av_packet_unref(pkt); break; @@ -3308,7 +3373,7 @@ * it takes longer and uses more memory. For MPEG-4, we need to * decompress for QuickTime. * - * If CODEC_CAP_CHANNEL_CONF is set this will force decoding of at + * If AV_CODEC_CAP_CHANNEL_CONF is set this will force decoding of at * least one frame of codec data, this makes sure the codec initializes * the channel configuration and does not only trust the values from * the container. */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/version.h ffmpeg-2.7.2~trusty~ppa1/libavformat/version.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/version.h 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/version.h 2015-07-17 17:20:02.000000000 +0000 @@ -30,8 +30,8 @@ #include "libavutil/version.h" #define LIBAVFORMAT_VERSION_MAJOR 56 -#define LIBAVFORMAT_VERSION_MINOR 36 -#define LIBAVFORMAT_VERSION_MICRO 100 +#define LIBAVFORMAT_VERSION_MINOR 40 +#define LIBAVFORMAT_VERSION_MICRO 101 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/wavdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/wavdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/wavdec.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/wavdec.c 2015-07-31 17:20:05.000000000 +0000 @@ -134,7 +134,7 @@ if (!*st) return AVERROR(ENOMEM); - ret = ff_get_wav_header(pb, (*st)->codec, size, wav->rifx); + ret = ff_get_wav_header(s, pb, (*st)->codec, size, wav->rifx); if (ret < 0) return ret; handle_stream_probing(*st); @@ -429,8 +429,20 @@ avio_seek(pb, data_ofs, SEEK_SET); + if (data_size > (INT64_MAX>>3)) { + av_log(s, AV_LOG_WARNING, "Data size %"PRId64" is too large\n", data_size); + data_size = 0; + } + if ( data_size > 0 && sample_count && st->codec->channels - && data_size / sample_count / st->codec->channels > 8) { + && (data_size << 3) / sample_count / st->codec->channels > st->codec->bits_per_coded_sample) { + av_log(s, AV_LOG_WARNING, "ignoring wrong sample_count %"PRId64"\n", sample_count); + sample_count = 0; + } + + /* G.729 hack (for Ticket4577) + * FIXME: Come up with cleaner, more general solution */ + if (st->codec->codec_id == AV_CODEC_ID_G729 && sample_count && (data_size << 3) > sample_count) { av_log(s, AV_LOG_WARNING, "ignoring wrong sample_count %"PRId64"\n", sample_count); sample_count = 0; } @@ -689,7 +701,7 @@ if (!memcmp(guid, ff_w64_guid_fmt, 16)) { /* subtract chunk header size - normal wav file doesn't count it */ - ret = ff_get_wav_header(pb, st->codec, size - 24, 0); + ret = ff_get_wav_header(s, pb, st->codec, size - 24, 0); if (ret < 0) return ret; avio_skip(pb, FFALIGN(size, INT64_C(8)) - size); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/wtvdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/wtvdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/wtvdec.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/wtvdec.c 2015-07-12 17:20:02.000000000 +0000 @@ -670,7 +670,7 @@ if (!st) return NULL; if (!ff_guidcmp(formattype, ff_format_waveformatex)) { - int ret = ff_get_wav_header(pb, st->codec, size, 0); + int ret = ff_get_wav_header(s, pb, st->codec, size, 0); if (ret < 0) return NULL; } else { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/xwma.c ffmpeg-2.7.2~trusty~ppa1/libavformat/xwma.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/xwma.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/xwma.c 2015-07-12 17:20:02.000000000 +0000 @@ -75,7 +75,7 @@ if (!st) return AVERROR(ENOMEM); - ret = ff_get_wav_header(pb, st->codec, size, 0); + ret = ff_get_wav_header(s, pb, st->codec, size, 0); if (ret < 0) return ret; st->need_parsing = AVSTREAM_PARSE_NONE; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/yuv4mpegdec.c ffmpeg-2.7.2~trusty~ppa1/libavformat/yuv4mpegdec.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/yuv4mpegdec.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/yuv4mpegdec.c 2015-07-12 17:20:02.000000000 +0000 @@ -256,6 +256,12 @@ st->sample_aspect_ratio = (AVRational){ aspectn, aspectd }; st->codec->chroma_sample_location = chroma_sample_location; st->codec->field_order = field_order; + s->packet_size = avpicture_get_size(st->codec->pix_fmt, width, height) + Y4M_FRAME_MAGIC_LEN; + if ((int) s->packet_size < 0) + return s->packet_size; + s->internal->data_offset = avio_tell(pb); + + st->duration = (avio_size(pb) - avio_tell(pb)) / s->packet_size; return 0; } @@ -264,8 +270,8 @@ { int i; char header[MAX_FRAME_HEADER+1]; - int packet_size, width, height, ret; - AVStream *st = s->streams[0]; + int ret; + int64_t off = avio_tell(s->pb); for (i = 0; i < MAX_FRAME_HEADER; i++) { header[i] = avio_r8(s->pb); @@ -284,20 +290,22 @@ if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC))) return AVERROR_INVALIDDATA; - width = st->codec->width; - height = st->codec->height; - - packet_size = avpicture_get_size(st->codec->pix_fmt, width, height); - if (packet_size < 0) - return packet_size; - - ret = av_get_packet(s->pb, pkt, packet_size); + ret = av_get_packet(s->pb, pkt, s->packet_size - Y4M_FRAME_MAGIC_LEN); if (ret < 0) return ret; - else if (ret != packet_size) + else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN) return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO); pkt->stream_index = 0; + pkt->pts = (off - s->internal->data_offset) / s->packet_size; + pkt->duration = 1; + return 0; +} + +static int yuv4_read_seek(AVFormatContext *s, int stream_index, + int64_t pts, int flags) +{ + avio_seek(s->pb, pts * s->packet_size + s->internal->data_offset, SEEK_SET); return 0; } @@ -316,5 +324,6 @@ .read_probe = yuv4_probe, .read_header = yuv4_read_header, .read_packet = yuv4_read_packet, + .read_seek = yuv4_read_seek, .extensions = "y4m", }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/yuv4mpegenc.c ffmpeg-2.7.2~trusty~ppa1/libavformat/yuv4mpegenc.c --- ffmpeg-2.7.1~trusty~ppa1/libavformat/yuv4mpegenc.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/yuv4mpegenc.c 2015-07-04 21:09:16.000000000 +0000 @@ -143,7 +143,6 @@ int width, height, h_chroma_shift, v_chroma_shift; int i; char buf2[Y4M_LINE_MAX + 1]; - char buf1[20]; uint8_t *ptr, *ptr1, *ptr2; memcpy(&picture_tmp, pkt->data, sizeof(AVPicture)); @@ -163,8 +162,7 @@ /* construct frame header */ - snprintf(buf1, sizeof(buf1), "%s\n", Y4M_FRAME_MAGIC); - avio_write(pb, buf1, strlen(buf1)); + avio_printf(s->pb, "%s\n", Y4M_FRAME_MAGIC); width = st->codec->width; height = st->codec->height; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavformat/yuv4mpeg.h ffmpeg-2.7.2~trusty~ppa1/libavformat/yuv4mpeg.h --- ffmpeg-2.7.1~trusty~ppa1/libavformat/yuv4mpeg.h 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavformat/yuv4mpeg.h 2015-07-11 17:20:02.000000000 +0000 @@ -23,5 +23,6 @@ #define Y4M_MAGIC "YUV4MPEG2" #define Y4M_FRAME_MAGIC "FRAME" +#define Y4M_FRAME_MAGIC_LEN 6 #endif /* AVFORMAT_YUV4MPEG_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/adler32.c ffmpeg-2.7.2~trusty~ppa1/libavutil/adler32.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/adler32.c 2015-06-18 18:55:04.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/adler32.c 2015-06-19 17:20:03.000000000 +0000 @@ -108,7 +108,7 @@ int main(int argc, char **argv) { int i; - char data[LEN]; + uint8_t data[LEN]; av_log_set_level(AV_LOG_DEBUG); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/aes.c ffmpeg-2.7.2~trusty~ppa1/libavutil/aes.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/aes.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/aes.c 2015-06-19 17:20:03.000000000 +0000 @@ -311,8 +311,8 @@ AVAES ae, ad; AVLFG prng; - av_aes_init(&ae, "PI=3.141592654..", 128, 0); - av_aes_init(&ad, "PI=3.141592654..", 128, 1); + av_aes_init(&ae, (const uint8_t*)"PI=3.141592654..", 128, 0); + av_aes_init(&ad, (const uint8_t*)"PI=3.141592654..", 128, 1); av_lfg_init(&prng, 1); for (i = 0; i < 10000; i++) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/arm/intmath.h ffmpeg-2.7.2~trusty~ppa1/libavutil/arm/intmath.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/arm/intmath.h 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/arm/intmath.h 2015-07-20 17:20:03.000000000 +0000 @@ -31,9 +31,9 @@ #if HAVE_ARMV6_INLINE #define av_clip_uint8 av_clip_uint8_arm -static av_always_inline av_const unsigned av_clip_uint8_arm(int a) +static av_always_inline av_const int av_clip_uint8_arm(int a) { - unsigned x; + int x; __asm__ ("usat %0, #8, %1" : "=r"(x) : "r"(a)); return x; } @@ -47,9 +47,9 @@ } #define av_clip_uint16 av_clip_uint16_arm -static av_always_inline av_const unsigned av_clip_uint16_arm(int a) +static av_always_inline av_const int av_clip_uint16_arm(int a) { - unsigned x; + int x; __asm__ ("usat %0, #16, %1" : "=r"(x) : "r"(a)); return x; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/avstring.c ffmpeg-2.7.2~trusty~ppa1/libavutil/avstring.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/avstring.c 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/avstring.c 2015-06-19 17:20:03.000000000 +0000 @@ -408,7 +408,7 @@ goto end; } - if (code >= 1<<31) { + if (code >= 1U<<31) { ret = AVERROR(EILSEQ); /* out-of-range value */ goto end; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/avutil.h ffmpeg-2.7.2~trusty~ppa1/libavutil/avutil.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/avutil.h 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/avutil.h 2015-07-03 17:20:03.000000000 +0000 @@ -171,6 +171,13 @@ unsigned avutil_version(void); /** + * Return an informative version string. This usually is the actual release + * version number or a git commit description. This string has no fixed format + * and can change any time. It should never be parsed by code. + */ +const char *av_version_info(void); + +/** * Return the libavutil build-time configuration. */ const char *avutil_configuration(void); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/blowfish.c ffmpeg-2.7.2~trusty~ppa1/libavutil/blowfish.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/blowfish.c 2015-06-18 18:55:04.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/blowfish.c 2015-08-02 17:20:02.000000000 +0000 @@ -24,8 +24,18 @@ #include "avutil.h" #include "common.h" #include "intreadwrite.h" +#include "mem.h" #include "blowfish.h" +#if !FF_API_CRYPTO_CONTEXT +#define AV_BF_ROUNDS 16 + +struct AVBlowfish { + uint32_t p[AV_BF_ROUNDS + 2]; + uint32_t s[4][256]; +}; +#endif + static const uint32_t orig_p[AV_BF_ROUNDS + 2] = { 0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89, @@ -300,6 +310,11 @@ + ctx->s[3][ Xl & 0xFF])\ ^ P; +AVBlowfish *av_blowfish_alloc(void) +{ + return av_mallocz(sizeof(struct AVBlowfish)); +} + av_cold void av_blowfish_init(AVBlowfish *ctx, const uint8_t *key, int key_len) { uint32_t data, data_l, data_r; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/blowfish.h ffmpeg-2.7.2~trusty~ppa1/libavutil/blowfish.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/blowfish.h 2015-03-13 17:34:51.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/blowfish.h 2015-08-02 17:20:02.000000000 +0000 @@ -23,6 +23,7 @@ #define AVUTIL_BLOWFISH_H #include +#include "version.h" /** * @defgroup lavu_blowfish Blowfish @@ -30,12 +31,21 @@ * @{ */ +#if FF_API_CRYPTO_CONTEXT #define AV_BF_ROUNDS 16 typedef struct AVBlowfish { uint32_t p[AV_BF_ROUNDS + 2]; uint32_t s[4][256]; } AVBlowfish; +#else +typedef struct AVBlowfish AVBlowfish; +#endif + +/** + * Allocate an AVBlowfish context. + */ +AVBlowfish *av_blowfish_alloc(void); /** * Initialize an AVBlowfish context. diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/crc.c ffmpeg-2.7.2~trusty~ppa1/libavutil/crc.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/crc.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/crc.c 2015-06-19 17:20:03.000000000 +0000 @@ -383,7 +383,8 @@ { uint8_t buf[1999]; int i; - int p[6][3] = { { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 }, + unsigned + p[6][3] = { { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 }, { AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0 }, { AV_CRC_24_IEEE , 0x864CFB , 0xB704CE }, { AV_CRC_16_ANSI_LE, 0xA001 , 0xBFD8 }, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/des.c ffmpeg-2.7.2~trusty~ppa1/libavutil/des.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/des.c 2015-06-18 18:55:04.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/des.c 2015-08-02 17:20:02.000000000 +0000 @@ -22,9 +22,15 @@ #include "avutil.h" #include "common.h" #include "intreadwrite.h" +#include "mem.h" #include "des.h" -typedef struct AVDES AVDES; +#if !FF_API_CRYPTO_CONTEXT +struct AVDES { + uint64_t round_keys[3][16]; + int triple_des; +}; +#endif #define T(a, b, c, d, e, f, g, h) 64-a,64-b,64-c,64-d,64-e,64-f,64-g,64-h static const uint8_t IP_shuffle[] = { @@ -286,6 +292,11 @@ return in; } +AVDES *av_des_alloc(void) +{ + return av_mallocz(sizeof(struct AVDES)); +} + int av_des_init(AVDES *d, const uint8_t *key, int key_bits, av_unused int decrypt) { if (key_bits != 64 && key_bits != 192) return -1; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/des.h ffmpeg-2.7.2~trusty~ppa1/libavutil/des.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/des.h 2015-03-12 19:53:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/des.h 2015-08-02 17:20:02.000000000 +0000 @@ -24,16 +24,32 @@ #include -struct AVDES { +/** + * @defgroup lavu_des DES + * @ingroup lavu_crypto + * @{ + */ + +#if FF_API_CRYPTO_CONTEXT +typedef struct AVDES { uint64_t round_keys[3][16]; int triple_des; -}; +} AVDES; +#else +typedef struct AVDES AVDES; +#endif + +/** + * Allocate an AVDES context. + */ +AVDES *av_des_alloc(void); /** * @brief Initializes an AVDES context. * * @param key_bits must be 64 or 192 * @param decrypt 0 for encryption/CBC-MAC, 1 for decryption + * @return zero on success, negative value otherwise */ int av_des_init(struct AVDES *d, const uint8_t *key, int key_bits, int decrypt); @@ -58,4 +74,8 @@ */ void av_des_mac(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count); +/** + * @} + */ + #endif /* AVUTIL_DES_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/fifo.c ffmpeg-2.7.2~trusty~ppa1/libavutil/fifo.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/fifo.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/fifo.c 2015-07-14 17:20:02.000000000 +0000 @@ -129,7 +129,8 @@ do { int len = FFMIN(f->end - wptr, size); if (func) { - if (func(src, wptr, len) <= 0) + len = func(src, wptr, len); + if (len <= 0) break; } else { memcpy(wptr, src, len); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/fixed_dsp.c ffmpeg-2.7.2~trusty~ppa1/libavutil/fixed_dsp.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/fixed_dsp.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/fixed_dsp.c 2015-06-20 17:20:02.000000000 +0000 @@ -121,7 +121,7 @@ } } -static int ff_scalarproduct_fixed_c(const int *v1, const int *v2, int len) +static int scalarproduct_fixed_c(const int *v1, const int *v2, int len) { /** p is initialized with 0x40000000 so that the proper rounding will occur * at the end */ @@ -158,7 +158,7 @@ fdsp->vector_fmul_add = vector_fmul_add_c; fdsp->vector_fmul_reverse = vector_fmul_reverse_c; fdsp->butterflies_fixed = butterflies_fixed_c; - fdsp->scalarproduct_fixed = ff_scalarproduct_fixed_c; + fdsp->scalarproduct_fixed = scalarproduct_fixed_c; return fdsp; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/frame.c ffmpeg-2.7.2~trusty~ppa1/libavutil/frame.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/frame.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/frame.c 2015-07-14 17:20:02.000000000 +0000 @@ -463,6 +463,9 @@ { int i; + if (!frame) + return; + wipe_side_data(frame); for (i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/frame.h ffmpeg-2.7.2~trusty~ppa1/libavutil/frame.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/frame.h 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/frame.h 2015-07-18 17:20:03.000000000 +0000 @@ -507,7 +507,7 @@ /** * frame timestamp estimated using various heuristics, in stream time base - * Code outside libavcodec should access this field using: + * Code outside libavutil should access this field using: * av_frame_get_best_effort_timestamp(frame) * - encoding: unused * - decoding: set by libavcodec, read by user. @@ -516,7 +516,7 @@ /** * reordered pos from the last AVPacket that has been input into the decoder - * Code outside libavcodec should access this field using: + * Code outside libavutil should access this field using: * av_frame_get_pkt_pos(frame) * - encoding: unused * - decoding: Read by user. @@ -526,7 +526,7 @@ /** * duration of the corresponding packet, expressed in * AVStream->time_base units, 0 if unknown. - * Code outside libavcodec should access this field using: + * Code outside libavutil should access this field using: * av_frame_get_pkt_duration(frame) * - encoding: unused * - decoding: Read by user. @@ -535,7 +535,7 @@ /** * metadata. - * Code outside libavcodec should access this field using: + * Code outside libavutil should access this field using: * av_frame_get_metadata(frame) * - encoding: Set by user. * - decoding: Set by libavcodec. @@ -546,7 +546,7 @@ * decode error flags of the frame, set to a combination of * FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there * were errors during the decoding. - * Code outside libavcodec should access this field using: + * Code outside libavutil should access this field using: * av_frame_get_decode_error_flags(frame) * - encoding: unused * - decoding: set by libavcodec, read by user. @@ -557,7 +557,7 @@ /** * number of audio channels, only used for audio. - * Code outside libavcodec should access this field using: + * Code outside libavutil should access this field using: * av_frame_get_channels(frame) * - encoding: unused * - decoding: Read by user. @@ -583,7 +583,7 @@ /** * Accessors for some AVFrame fields. * The position of these field in the structure is not part of the ABI, - * they should not be accessed directly outside libavcodec. + * they should not be accessed directly outside libavutil. */ int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame); void av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/hmac.c ffmpeg-2.7.2~trusty~ppa1/libavutil/hmac.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/hmac.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/hmac.c 2015-07-30 17:20:02.000000000 +0000 @@ -81,6 +81,9 @@ c->hash = av_sha_alloc(); break; case AV_HMAC_SHA224: +#if FF_API_HMAC + case AV_HMAC_SHA224_DEPRECATED: +#endif c->blocklen = 64; c->hashlen = 28; c->init = sha224_init; @@ -89,6 +92,9 @@ c->hash = av_sha_alloc(); break; case AV_HMAC_SHA256: +#if FF_API_HMAC + case AV_HMAC_SHA256_DEPRECATED: +#endif c->blocklen = 64; c->hashlen = 32; c->init = sha256_init; @@ -207,7 +213,8 @@ int main(void) { uint8_t key1[20], key3[131], data3[50]; - enum AVHMACType i = AV_HMAC_SHA224; + AVHMAC *hmac; + enum AVHMACType i; static const uint8_t key2[] = "Jefe"; static const uint8_t data1[] = "Hi There"; static const uint8_t data2[] = "what do ya want for nothing?"; @@ -216,34 +223,39 @@ static const uint8_t data6[] = "This is a test using a larger than block-size key and a larger " "than block-size data. The key needs to be hashed before being used" " by the HMAC algorithm."; - AVHMAC *hmac = av_hmac_alloc(AV_HMAC_MD5); - if (!hmac) - return 1; memset(key1, 0x0b, sizeof(key1)); memset(key3, 0xaa, sizeof(key3)); memset(data3, 0xdd, sizeof(data3)); - // RFC 2202 test vectors - test(hmac, key1, 16, data1, sizeof(data1)); - test(hmac, key2, sizeof(key2), data2, sizeof(data2)); - test(hmac, key3, 16, data3, sizeof(data3)); - test(hmac, key3, 80, data4, sizeof(data4)); - test(hmac, key3, 80, data5, sizeof(data5)); - av_hmac_free(hmac); - - /* SHA-1 */ - hmac = av_hmac_alloc(AV_HMAC_SHA1); - if (!hmac) - return 1; - // RFC 2202 test vectors - test(hmac, key1, sizeof(key1), data1, sizeof(data1)); - test(hmac, key2, sizeof(key2), data2, sizeof(data2)); - test(hmac, key3, 20, data3, sizeof(data3)); - test(hmac, key3, 80, data4, sizeof(data4)); - test(hmac, key3, 80, data5, sizeof(data5)); - av_hmac_free(hmac); + + /* MD5, SHA-1 */ + for (i = AV_HMAC_MD5; i <= AV_HMAC_SHA1; i++) { + hmac = av_hmac_alloc(i); + if (!hmac) + return 1; + // RFC 2202 test vectors + test(hmac, key1, hmac->hashlen, data1, sizeof(data1)); + test(hmac, key2, sizeof(key2), data2, sizeof(data2)); + test(hmac, key3, hmac->hashlen, data3, sizeof(data3)); + test(hmac, key3, 80, data4, sizeof(data4)); + test(hmac, key3, 80, data5, sizeof(data5)); + av_hmac_free(hmac); + } /* SHA-2 */ - while (i <= AV_HMAC_SHA512) { + for (i = AV_HMAC_SHA224; i <= AV_HMAC_SHA256; i++) { + hmac = av_hmac_alloc(i); + if (!hmac) + return 1; + // RFC 4231 test vectors + test(hmac, key1, sizeof(key1), data1, sizeof(data1)); + test(hmac, key2, sizeof(key2), data2, sizeof(data2)); + test(hmac, key3, 20, data3, sizeof(data3)); + test(hmac, key3, sizeof(key3), data4, sizeof(data4)); + test(hmac, key3, sizeof(key3), data6, sizeof(data6)); + av_hmac_free(hmac); + } + + for (i = AV_HMAC_SHA384; i <= AV_HMAC_SHA512; i++) { hmac = av_hmac_alloc(i); if (!hmac) return 1; @@ -254,7 +266,6 @@ test(hmac, key3, sizeof(key3), data4, sizeof(data4)); test(hmac, key3, sizeof(key3), data6, sizeof(data6)); av_hmac_free(hmac); - i++; } return 0; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/hmac.h ffmpeg-2.7.2~trusty~ppa1/libavutil/hmac.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/hmac.h 2015-03-15 02:46:05.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/hmac.h 2015-07-30 17:20:02.000000000 +0000 @@ -23,6 +23,7 @@ #include +#include "version.h" /** * @defgroup lavu_hmac HMAC * @ingroup lavu_crypto @@ -32,9 +33,13 @@ enum AVHMACType { AV_HMAC_MD5, AV_HMAC_SHA1, - AV_HMAC_SHA224 = 10, + AV_HMAC_SHA224, AV_HMAC_SHA256, - AV_HMAC_SHA384, +#if FF_API_HMAC + AV_HMAC_SHA224_DEPRECATED = 10, + AV_HMAC_SHA256_DEPRECATED, +#endif + AV_HMAC_SHA384 = 12, AV_HMAC_SHA512, }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/imgutils.c ffmpeg-2.7.2~trusty~ppa1/libavutil/imgutils.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/imgutils.c 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/imgutils.c 2015-06-13 17:20:02.000000000 +0000 @@ -78,7 +78,7 @@ int max_step [4]; /* max pixel step for each plane */ int max_step_comp[4]; /* the component for each plane which has the max pixel step */ - if ((unsigned)pix_fmt >= AV_PIX_FMT_NB || desc->flags & AV_PIX_FMT_FLAG_HWACCEL) + if (!desc || desc->flags & AV_PIX_FMT_FLAG_HWACCEL) return AVERROR(EINVAL); av_image_fill_max_pixsteps(max_step, max_step_comp, desc); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/internal.h ffmpeg-2.7.2~trusty~ppa1/libavutil/internal.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/internal.h 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/internal.h 2015-07-08 17:20:04.000000000 +0000 @@ -238,8 +238,8 @@ #if HAVE_LIBC_MSVCRT #include #if defined(_VC_CRT_MAJOR_VERSION) && _VC_CRT_MAJOR_VERSION < 14 -#pragma comment(linker, "/include:"EXTERN_PREFIX"avpriv_strtod") -#pragma comment(linker, "/include:"EXTERN_PREFIX"avpriv_snprintf") +#pragma comment(linker, "/include:" EXTERN_PREFIX "avpriv_strtod") +#pragma comment(linker, "/include:" EXTERN_PREFIX "avpriv_snprintf") #endif #define avpriv_open ff_open diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/intmath.h ffmpeg-2.7.2~trusty~ppa1/libavutil/intmath.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/intmath.h 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/intmath.h 2015-07-19 17:20:03.000000000 +0000 @@ -39,22 +39,22 @@ */ #if HAVE_FAST_CLZ -#if AV_GCC_VERSION_AT_LEAST(3,4) +#if defined( __INTEL_COMPILER ) #ifndef ff_log2 -# define ff_log2(x) (31 - __builtin_clz((x)|1)) +# define ff_log2(x) (_bit_scan_reverse((x)|1)) # ifndef ff_log2_16bit # define ff_log2_16bit av_log2 # endif #endif /* ff_log2 */ -#elif defined( __INTEL_COMPILER ) +#elif AV_GCC_VERSION_AT_LEAST(3,4) #ifndef ff_log2 -# define ff_log2(x) (_bit_scan_reverse((x)|1)) +# define ff_log2(x) (31 - __builtin_clz((x)|1)) # ifndef ff_log2_16bit # define ff_log2_16bit av_log2 # endif #endif /* ff_log2 */ -#endif #endif /* AV_GCC_VERSION_AT_LEAST(3,4) */ +#endif extern const uint8_t ff_log2_tab[256]; @@ -115,13 +115,13 @@ */ #if HAVE_FAST_CLZ -#if AV_GCC_VERSION_AT_LEAST(3,4) +#if defined( __INTEL_COMPILER ) #ifndef ff_ctz -#define ff_ctz(v) __builtin_ctz(v) +#define ff_ctz(v) _bit_scan_forward(v) #endif -#elif defined( __INTEL_COMPILER ) +#elif AV_GCC_VERSION_AT_LEAST(3,4) #ifndef ff_ctz -#define ff_ctz(v) _bit_scan_forward(v) +#define ff_ctz(v) __builtin_ctz(v) #endif #endif #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/log.h ffmpeg-2.7.2~trusty~ppa1/libavutil/log.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/log.h 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/log.h 2015-06-26 17:20:02.000000000 +0000 @@ -196,13 +196,13 @@ */ #define AV_LOG_DEBUG 48 -#define AV_LOG_MAX_OFFSET (AV_LOG_DEBUG - AV_LOG_QUIET) - /** * Extremely verbose debugging, useful for libav* development. */ #define AV_LOG_TRACE 56 +#define AV_LOG_MAX_OFFSET (AV_LOG_TRACE - AV_LOG_QUIET) + /** * @} */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/Makefile ffmpeg-2.7.2~trusty~ppa1/libavutil/Makefile --- ffmpeg-2.7.1~trusty~ppa1/libavutil/Makefile 2015-06-19 20:44:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/Makefile 2015-07-23 17:20:03.000000000 +0000 @@ -63,6 +63,7 @@ twofish.h \ version.h \ xtea.h \ + tea.h \ HEADERS-$(CONFIG_LZO) += lzo.h @@ -78,7 +79,6 @@ OBJS = adler32.o \ aes.o \ - atomic.o \ audio_fifo.o \ avstring.o \ base64.o \ @@ -135,6 +135,9 @@ utils.o \ xga_font_data.o \ xtea.o \ + tea.o \ + +OBJS-$(!HAVE_ATOMICS_NATIVE) += atomic.o \ OBJS-$(CONFIG_LZO) += lzo.o OBJS-$(CONFIG_OPENCL) += opencl.o opencl_internal.o @@ -190,6 +193,7 @@ twofish \ utf8 \ xtea \ + tea \ TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/mem.c ffmpeg-2.7.2~trusty~ppa1/libavutil/mem.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/mem.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/mem.c 2015-07-13 17:20:03.000000000 +0000 @@ -59,6 +59,8 @@ #endif /* MALLOC_PREFIX */ +#include "mem_internal.h" + #define ALIGN (HAVE_AVX ? 32 : 16) /* NOTE: if you want to override these functions with your own @@ -480,7 +482,7 @@ if (min_size < *size) return ptr; - min_size = FFMAX(17 * min_size / 16 + 32, min_size); + min_size = FFMAX(min_size + min_size / 16 + 32, min_size); ptr = av_realloc(ptr, min_size); /* we could set this to the unmodified min_size but this is safer @@ -494,22 +496,6 @@ return ptr; } -static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc) -{ - void *val; - - if (min_size < *size) - return 0; - min_size = FFMAX(17 * min_size / 16 + 32, min_size); - av_freep(ptr); - val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size); - memcpy(ptr, &val, sizeof(val)); - if (!val) - min_size = 0; - *size = min_size; - return 1; -} - void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size) { ff_fast_malloc(ptr, size, min_size, 0); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/mem_internal.h ffmpeg-2.7.2~trusty~ppa1/libavutil/mem_internal.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/mem_internal.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/mem_internal.h 2015-07-14 17:20:02.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2002 Fabrice Bellard + * + * 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 + */ + +#ifndef AVUTIL_MEM_INTERNAL_H +#define AVUTIL_MEM_INTERNAL_H + +#include "avassert.h" +#include "mem.h" + +static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc) +{ + void *val; + + memcpy(&val, ptr, sizeof(val)); + if (min_size <= *size) { + av_assert0(val || !min_size); + return 0; + } + min_size = FFMAX(min_size + min_size / 16 + 32, min_size); + av_freep(ptr); + val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size); + memcpy(ptr, &val, sizeof(val)); + if (!val) + min_size = 0; + *size = min_size; + return 1; +} +#endif /* AVUTIL_MEM_INTERNAL_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/mips/generic_macros_msa.h ffmpeg-2.7.2~trusty~ppa1/libavutil/mips/generic_macros_msa.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/mips/generic_macros_msa.h 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/mips/generic_macros_msa.h 2015-07-23 17:20:03.000000000 +0000 @@ -24,6 +24,9 @@ #include #include +#define ALIGNMENT 16 +#define ALLOC_ALIGNED(align) __attribute__ ((aligned((align) << 1))) + #define LD_B(RTYPE, psrc) *((RTYPE *)(psrc)) #define LD_UB(...) LD_B(v16u8, __VA_ARGS__) #define LD_SB(...) LD_B(v16i8, __VA_ARGS__) @@ -333,6 +336,7 @@ LD_B4(RTYPE, (psrc), stride, out0, out1, out2, out3); \ LD_B2(RTYPE, (psrc) + 4 * stride, stride, out4, out5); \ } +#define LD_UB6(...) LD_B6(v16u8, __VA_ARGS__) #define LD_SB6(...) LD_B6(v16i8, __VA_ARGS__) #define LD_B7(RTYPE, psrc, stride, \ @@ -341,6 +345,7 @@ LD_B5(RTYPE, (psrc), stride, out0, out1, out2, out3, out4); \ LD_B2(RTYPE, (psrc) + 5 * stride, stride, out5, out6); \ } +#define LD_UB7(...) LD_B7(v16u8, __VA_ARGS__) #define LD_SB7(...) LD_B7(v16i8, __VA_ARGS__) #define LD_B8(RTYPE, psrc, stride, \ @@ -403,6 +408,19 @@ } #define LD_SH16(...) LD_H16(v8i16, __VA_ARGS__) +/* Description : Load as 4x4 block of signed halfword elements from 1D source + data into 4 vectors (Each vector with 4 signed halfwords) + Arguments : Inputs - psrc + Outputs - out0, out1, out2, out3 +*/ +#define LD4x4_SH(psrc, out0, out1, out2, out3) \ +{ \ + out0 = LD_SH(psrc); \ + out2 = LD_SH(psrc + 8); \ + out1 = (v8i16) __msa_ilvl_d((v2i64) out0, (v2i64) out0); \ + out3 = (v8i16) __msa_ilvl_d((v2i64) out2, (v2i64) out2); \ +} + /* Description : Load 2 vectors of signed word elements with stride Arguments : Inputs - psrc (source pointer to load from) - stride @@ -492,6 +510,14 @@ ST_SW(in0, (pdst)); \ ST_SW(in1, (pdst) + stride); \ } +#define ST_SW8(in0, in1, in2, in3, in4, in5, in6, in7, \ + pdst, stride) \ +{ \ + ST_SW2(in0, in1, (pdst), stride); \ + ST_SW2(in2, in3, (pdst) + 2 * stride, stride); \ + ST_SW2(in4, in5, (pdst) + 4 * stride, stride); \ + ST_SW2(in6, in7, (pdst) + 6 * stride, stride); \ +} /* Description : Store as 2x4 byte block to destination memory from input vector Arguments : Inputs - in, stidx, pdst, stride @@ -747,6 +773,33 @@ SW(out15_m, pblk_12x8_m + 8); \ } +/* Description : average with rounding (in0 + in1 + 1) / 2. + Arguments : Inputs - in0, in1, in2, in3, + Outputs - out0, out1 + Return Type - signed byte + Details : Each byte element from 'in0' vector is added with each byte + element from 'in1' vector. The addition of the elements plus 1 + (for rounding) is done unsigned with full precision, + i.e. the result has one extra bit. Unsigned division by 2 + (or logical shift right by one bit) is performed before writing + the result to vector 'out0' + Similar for the pair of 'in2' and 'in3' +*/ +#define AVER_UB2(RTYPE, in0, in1, in2, in3, out0, out1) \ +{ \ + out0 = (RTYPE) __msa_aver_u_b((v16u8) in0, (v16u8) in1); \ + out1 = (RTYPE) __msa_aver_u_b((v16u8) in2, (v16u8) in3); \ +} +#define AVER_UB2_UB(...) AVER_UB2(v16u8, __VA_ARGS__) + +#define AVER_UB4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \ + out0, out1, out2, out3) \ +{ \ + AVER_UB2(RTYPE, in0, in1, in2, in3, out0, out1) \ + AVER_UB2(RTYPE, in4, in5, in6, in7, out2, out3) \ +} +#define AVER_UB4_UB(...) AVER_UB4(v16u8, __VA_ARGS__) + /* Description : Immediate number of columns to slide with zero Arguments : Inputs - in0, in1, slide_val Outputs - out0, out1 @@ -761,6 +814,17 @@ out1 = (RTYPE) __msa_sldi_b((v16i8) zero_m, (v16i8) in1, slide_val); \ } #define SLDI_B2_0_UB(...) SLDI_B2_0(v16u8, __VA_ARGS__) +#define SLDI_B2_0_SB(...) SLDI_B2_0(v16i8, __VA_ARGS__) +#define SLDI_B2_0_SW(...) SLDI_B2_0(v4i32, __VA_ARGS__) + +#define SLDI_B3_0(RTYPE, in0, in1, in2, out0, out1, out2, slide_val) \ +{ \ + v16i8 zero_m = { 0 }; \ + SLDI_B2_0(RTYPE, in0, in1, out0, out1, slide_val); \ + out2 = (RTYPE) __msa_sldi_b((v16i8) zero_m, (v16i8) in2, slide_val); \ +} +#define SLDI_B3_0_UB(...) SLDI_B3_0(v16u8, __VA_ARGS__) +#define SLDI_B3_0_SB(...) SLDI_B3_0(v16i8, __VA_ARGS__) #define SLDI_B4_0(RTYPE, in0, in1, in2, in3, \ out0, out1, out2, out3, slide_val) \ @@ -768,7 +832,9 @@ SLDI_B2_0(RTYPE, in0, in1, out0, out1, slide_val); \ SLDI_B2_0(RTYPE, in2, in3, out2, out3, slide_val); \ } +#define SLDI_B4_0_UB(...) SLDI_B4_0(v16u8, __VA_ARGS__) #define SLDI_B4_0_SB(...) SLDI_B4_0(v16i8, __VA_ARGS__) +#define SLDI_B4_0_SH(...) SLDI_B4_0(v8i16, __VA_ARGS__) /* Description : Immediate number of columns to slide Arguments : Inputs - in0_0, in0_1, in1_0, in1_1, slide_val @@ -786,6 +852,14 @@ #define SLDI_B2_SB(...) SLDI_B2(v16i8, __VA_ARGS__) #define SLDI_B2_SH(...) SLDI_B2(v8i16, __VA_ARGS__) +#define SLDI_B3(RTYPE, in0_0, in0_1, in0_2, in1_0, in1_1, in1_2, \ + out0, out1, out2, slide_val) \ +{ \ + SLDI_B2(RTYPE, in0_0, in0_1, in1_0, in1_1, out0, out1, slide_val) \ + out2 = (RTYPE) __msa_sldi_b((v16i8) in0_2, (v16i8) in1_2, slide_val); \ +} +#define SLDI_B3_SB(...) SLDI_B3(v16i8, __VA_ARGS__) +#define SLDI_B3_UH(...) SLDI_B3(v8u16, __VA_ARGS__) /* Description : Shuffle byte vector elements as per mask vector Arguments : Inputs - in0, in1, in2, in3, mask0, mask1 @@ -821,6 +895,31 @@ VSHF_B2(RTYPE, in0, in1, in0, in1, mask2, mask3, out2, out3); \ } #define VSHF_B4_SB(...) VSHF_B4(v16i8, __VA_ARGS__) +#define VSHF_B4_SH(...) VSHF_B4(v8i16, __VA_ARGS__) + +/* Description : Shuffle halfword vector elements as per mask vector + Arguments : Inputs - in0, in1, in2, in3, mask0, mask1 + Outputs - out0, out1 + Return Type - as per RTYPE + Details : Selective halfword elements from in0 & in1 are copied to out0 + as per control vector mask0 + Selective halfword elements from in2 & in3 are copied to out1 + as per control vector mask1 +*/ +#define VSHF_H2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) \ +{ \ + out0 = (RTYPE) __msa_vshf_h((v8i16) mask0, (v8i16) in1, (v8i16) in0); \ + out1 = (RTYPE) __msa_vshf_h((v8i16) mask1, (v8i16) in3, (v8i16) in2); \ +} +#define VSHF_H2_SH(...) VSHF_H2(v8i16, __VA_ARGS__) + +#define VSHF_H3(RTYPE, in0, in1, in2, in3, in4, in5, mask0, mask1, mask2, \ + out0, out1, out2) \ +{ \ + VSHF_H2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1); \ + out2 = (RTYPE) __msa_vshf_h((v8i16) mask2, (v8i16) in5, (v8i16) in4); \ +} +#define VSHF_H3_SH(...) VSHF_H3(v8i16, __VA_ARGS__) /* Description : Shuffle byte vector elements as per mask vector Arguments : Inputs - in0, in1, in2, in3, mask0, mask1 @@ -842,6 +941,34 @@ Arguments : Inputs - mult0, mult1 cnst0, cnst1 Outputs - out0, out1 + Return Type - unsigned halfword + Details : Unsigned byte elements from mult0 are multiplied with + unsigned byte elements from cnst0 producing a result + twice the size of input i.e. unsigned halfword. + Then this multiplication results of adjacent odd-even elements + are added together and stored to the out vector + (2 unsigned halfword results) +*/ +#define DOTP_UB2(RTYPE, mult0, mult1, cnst0, cnst1, out0, out1) \ +{ \ + out0 = (RTYPE) __msa_dotp_u_h((v16u8) mult0, (v16u8) cnst0); \ + out1 = (RTYPE) __msa_dotp_u_h((v16u8) mult1, (v16u8) cnst1); \ +} +#define DOTP_UB2_UH(...) DOTP_UB2(v8u16, __VA_ARGS__) + +#define DOTP_UB4(RTYPE, mult0, mult1, mult2, mult3, \ + cnst0, cnst1, cnst2, cnst3, \ + out0, out1, out2, out3) \ +{ \ + DOTP_UB2(RTYPE, mult0, mult1, cnst0, cnst1, out0, out1); \ + DOTP_UB2(RTYPE, mult2, mult3, cnst2, cnst3, out2, out3); \ +} +#define DOTP_UB4_UH(...) DOTP_UB4(v8u16, __VA_ARGS__) + +/* Description : Dot product of byte vector elements + Arguments : Inputs - mult0, mult1 + cnst0, cnst1 + Outputs - out0, out1 Return Type - signed halfword Details : Signed byte elements from mult0 are multiplied with signed byte elements from cnst0 producing a result @@ -930,6 +1057,27 @@ } #define DPADD_SB4_SH(...) DPADD_SB4(v8i16, __VA_ARGS__) +/* Description : Dot product & addition of byte vector elements + Arguments : Inputs - mult0, mult1 + cnst0, cnst1 + Outputs - out0, out1 + Return Type - unsigned halfword + Details : Unsigned byte elements from mult0 are multiplied with + unsigned byte elements from cnst0 producing a result + twice the size of input i.e. unsigned halfword. + Then this multiplication results of adjacent odd-even elements + are added to the out vector + (2 unsigned halfword results) +*/ +#define DPADD_UB2(RTYPE, mult0, mult1, cnst0, cnst1, out0, out1) \ +{ \ + out0 = (RTYPE) __msa_dpadd_u_h((v8u16) out0, \ + (v16u8) mult0, (v16u8) cnst0); \ + out1 = (RTYPE) __msa_dpadd_u_h((v8u16) out1, \ + (v16u8) mult1, (v16u8) cnst1); \ +} +#define DPADD_UB2_UH(...) DPADD_UB2(v8u16, __VA_ARGS__) + /* Description : Dot product & addition of halfword vector elements Arguments : Inputs - mult0, mult1 cnst0, cnst1 @@ -959,6 +1107,28 @@ } #define DPADD_SH4_SW(...) DPADD_SH4(v4i32, __VA_ARGS__) +/* Description : Minimum values between unsigned elements of + either vector are copied to the output vector + Arguments : Inputs - in0, in1, min_vec + Outputs - in0, in1, (in place) + Return Type - unsigned halfword + Details : Minimum of unsigned halfword element values from 'in0' and + 'min_value' are written to output vector 'in0' +*/ +#define MIN_UH2(RTYPE, in0, in1, min_vec) \ +{ \ + in0 = (RTYPE) __msa_min_u_h((v8u16) in0, min_vec); \ + in1 = (RTYPE) __msa_min_u_h((v8u16) in1, min_vec); \ +} +#define MIN_UH2_UH(...) MIN_UH2(v8u16, __VA_ARGS__) + +#define MIN_UH4(RTYPE, in0, in1, in2, in3, min_vec) \ +{ \ + MIN_UH2(RTYPE, in0, in1, min_vec); \ + MIN_UH2(RTYPE, in2, in3, min_vec); \ +} +#define MIN_UH4_UH(...) MIN_UH4(v8u16, __VA_ARGS__) + /* Description : Clips all halfword elements of input vector between min & max out = ((in) < (min)) ? (min) : (((in) > (max)) ? (max) : (in)) Arguments : Inputs - in (input vector) @@ -1018,6 +1188,100 @@ out_m; \ } ) +/* Description : Addition of 4 signed word elements + 4 signed word elements of input vector are added together and + resulted integer sum is returned + Arguments : Inputs - in (signed word vector) + Outputs - sum_m (i32 sum) + Return Type - signed word +*/ +#define HADD_SW_S32(in) \ +( { \ + v2i64 res0_m, res1_m; \ + int32_t sum_m; \ + \ + res0_m = __msa_hadd_s_d((v4i32) in, (v4i32) in); \ + res1_m = __msa_splati_d(res0_m, 1); \ + res0_m = res0_m + res1_m; \ + sum_m = __msa_copy_s_w((v4i32) res0_m, 0); \ + sum_m; \ +} ) + +/* Description : Addition of 8 unsigned halfword elements + 8 unsigned halfword elements of input vector are added + together and resulted integer sum is returned + Arguments : Inputs - in (unsigned halfword vector) + Outputs - sum_m (u32 sum) + Return Type - unsigned word +*/ +#define HADD_UH_U32(in) \ +( { \ + v4u32 res_m; \ + v2u64 res0_m, res1_m; \ + uint32_t sum_m; \ + \ + res_m = __msa_hadd_u_w((v8u16) in, (v8u16) in); \ + res0_m = __msa_hadd_u_d(res_m, res_m); \ + res1_m = (v2u64) __msa_splati_d((v2i64) res0_m, 1); \ + res0_m = res0_m + res1_m; \ + sum_m = __msa_copy_u_w((v4i32) res0_m, 0); \ + sum_m; \ +} ) + +/* Description : Horizontal addition of signed byte vector elements + Arguments : Inputs - in0, in1 + Outputs - out0, out1 + Return Type - as per RTYPE + Details : Each signed odd byte element from 'in0' is added to + even signed byte element from 'in0' (pairwise) and the + halfword result is stored in 'out0' +*/ +#define HADD_SB2(RTYPE, in0, in1, out0, out1) \ +{ \ + out0 = (RTYPE) __msa_hadd_s_h((v16i8) in0, (v16i8) in0); \ + out1 = (RTYPE) __msa_hadd_s_h((v16i8) in1, (v16i8) in1); \ +} +#define HADD_SB2_SH(...) HADD_SB2(v8i16, __VA_ARGS__) + +#define HADD_SB4(RTYPE, in0, in1, in2, in3, out0, out1, out2, out3) \ +{ \ + HADD_SB2(RTYPE, in0, in1, out0, out1); \ + HADD_SB2(RTYPE, in2, in3, out2, out3); \ +} +#define HADD_SB4_UH(...) HADD_SB4(v8u16, __VA_ARGS__) +#define HADD_SB4_SH(...) HADD_SB4(v8i16, __VA_ARGS__) + +/* Description : Horizontal addition of unsigned byte vector elements + Arguments : Inputs - in0, in1 + Outputs - out0, out1 + Return Type - as per RTYPE + Details : Each unsigned odd byte element from 'in0' is added to + even unsigned byte element from 'in0' (pairwise) and the + halfword result is stored in 'out0' +*/ +#define HADD_UB2(RTYPE, in0, in1, out0, out1) \ +{ \ + out0 = (RTYPE) __msa_hadd_u_h((v16u8) in0, (v16u8) in0); \ + out1 = (RTYPE) __msa_hadd_u_h((v16u8) in1, (v16u8) in1); \ +} +#define HADD_UB2_UH(...) HADD_UB2(v8u16, __VA_ARGS__) + +#define HADD_UB3(RTYPE, in0, in1, in2, out0, out1, out2) \ +{ \ + HADD_UB2(RTYPE, in0, in1, out0, out1); \ + out2 = (RTYPE) __msa_hadd_u_h((v16u8) in2, (v16u8) in2); \ +} +#define HADD_UB3_UH(...) HADD_UB3(v8u16, __VA_ARGS__) + +#define HADD_UB4(RTYPE, in0, in1, in2, in3, out0, out1, out2, out3) \ +{ \ + HADD_UB2(RTYPE, in0, in1, out0, out1); \ + HADD_UB2(RTYPE, in2, in3, out2, out3); \ +} +#define HADD_UB4_UB(...) HADD_UB4(v16u8, __VA_ARGS__) +#define HADD_UB4_UH(...) HADD_UB4(v8u16, __VA_ARGS__) +#define HADD_UB4_SH(...) HADD_UB4(v8i16, __VA_ARGS__) + /* Description : Horizontal subtraction of unsigned byte vector elements Arguments : Inputs - in0, in1 Outputs - out0, out1 @@ -1034,6 +1298,51 @@ #define HSUB_UB2_UH(...) HSUB_UB2(v8u16, __VA_ARGS__) #define HSUB_UB2_SH(...) HSUB_UB2(v8i16, __VA_ARGS__) +#define HSUB_UB4(RTYPE, in0, in1, in2, in3, out0, out1, out2, out3) \ +{ \ + HSUB_UB2(RTYPE, in0, in1, out0, out1); \ + HSUB_UB2(RTYPE, in2, in3, out2, out3); \ +} +#define HSUB_UB4_UH(...) HSUB_UB4(v8u16, __VA_ARGS__) +#define HSUB_UB4_SH(...) HSUB_UB4(v8i16, __VA_ARGS__) + +/* Description : SAD (Sum of Absolute Difference) + Arguments : Inputs - in0, in1, ref0, ref1 (unsigned byte src & ref) + Outputs - sad_m (halfword vector with sad) + Return Type - unsigned halfword + Details : Absolute difference of all the byte elements from 'in0' with + 'ref0' is calculated and preserved in 'diff0'. From the 16 + unsigned absolute diff values, even-odd pairs are added + together to generate 8 halfword results. +*/ +#define SAD_UB2_UH(in0, in1, ref0, ref1) \ +( { \ + v16u8 diff0_m, diff1_m; \ + v8u16 sad_m = { 0 }; \ + \ + diff0_m = __msa_asub_u_b((v16u8) in0, (v16u8) ref0); \ + diff1_m = __msa_asub_u_b((v16u8) in1, (v16u8) ref1); \ + \ + sad_m += __msa_hadd_u_h((v16u8) diff0_m, (v16u8) diff0_m); \ + sad_m += __msa_hadd_u_h((v16u8) diff1_m, (v16u8) diff1_m); \ + \ + sad_m; \ +} ) + +/* Description : Insert specified word elements from input vectors to 1 + destination vector + Arguments : Inputs - in0, in1, in2, in3 (4 input vectors) + Outputs - out (output vector) + Return Type - as per RTYPE +*/ +#define INSERT_W2(RTYPE, in0, in1, out) \ +{ \ + out = (RTYPE) __msa_insert_w((v4i32) out, 0, in0); \ + out = (RTYPE) __msa_insert_w((v4i32) out, 1, in1); \ +} +#define INSERT_W2_UB(...) INSERT_W2(v16u8, __VA_ARGS__) +#define INSERT_W2_SB(...) INSERT_W2(v16i8, __VA_ARGS__) + #define INSERT_W4(RTYPE, in0, in1, in2, in3, out) \ { \ out = (RTYPE) __msa_insert_w((v4i32) out, 0, in0); \ @@ -1060,6 +1369,25 @@ #define INSERT_D2_SB(...) INSERT_D2(v16i8, __VA_ARGS__) #define INSERT_D2_SD(...) INSERT_D2(v2i64, __VA_ARGS__) +/* Description : Interleave even byte elements from vectors + Arguments : Inputs - in0, in1, in2, in3 + Outputs - out0, out1 + Return Type - as per RTYPE + Details : Even byte elements of 'in0' and even byte + elements of 'in1' are interleaved and copied to 'out0' + Even byte elements of 'in2' and even byte + elements of 'in3' are interleaved and copied to 'out1' +*/ +#define ILVEV_B2(RTYPE, in0, in1, in2, in3, out0, out1) \ +{ \ + out0 = (RTYPE) __msa_ilvev_b((v16i8) in1, (v16i8) in0); \ + out1 = (RTYPE) __msa_ilvev_b((v16i8) in3, (v16i8) in2); \ +} +#define ILVEV_B2_UB(...) ILVEV_B2(v16u8, __VA_ARGS__) +#define ILVEV_B2_SB(...) ILVEV_B2(v16i8, __VA_ARGS__) +#define ILVEV_B2_SH(...) ILVEV_B2(v8i16, __VA_ARGS__) +#define ILVEV_B2_SD(...) ILVEV_B2(v2i64, __VA_ARGS__) + /* Description : Interleave even halfword elements from vectors Arguments : Inputs - in0, in1, in2, in3 Outputs - out0, out1 @@ -1075,6 +1403,8 @@ out1 = (RTYPE) __msa_ilvev_h((v8i16) in3, (v8i16) in2); \ } #define ILVEV_H2_UB(...) ILVEV_H2(v16u8, __VA_ARGS__) +#define ILVEV_H2_SH(...) ILVEV_H2(v8i16, __VA_ARGS__) +#define ILVEV_H2_SW(...) ILVEV_H2(v4i32, __VA_ARGS__) /* Description : Interleave even word elements from vectors Arguments : Inputs - in0, in1, in2, in3 @@ -1090,7 +1420,10 @@ out0 = (RTYPE) __msa_ilvev_w((v4i32) in1, (v4i32) in0); \ out1 = (RTYPE) __msa_ilvev_w((v4i32) in3, (v4i32) in2); \ } +#define ILVEV_W2_UB(...) ILVEV_W2(v16u8, __VA_ARGS__) #define ILVEV_W2_SB(...) ILVEV_W2(v16i8, __VA_ARGS__) +#define ILVEV_W2_UH(...) ILVEV_W2(v8u16, __VA_ARGS__) +#define ILVEV_W2_SD(...) ILVEV_W2(v2i64, __VA_ARGS__) /* Description : Interleave even double word elements from vectors Arguments : Inputs - in0, in1, in2, in3 @@ -1107,6 +1440,8 @@ out1 = (RTYPE) __msa_ilvev_d((v2i64) in3, (v2i64) in2); \ } #define ILVEV_D2_UB(...) ILVEV_D2(v16u8, __VA_ARGS__) +#define ILVEV_D2_SB(...) ILVEV_D2(v16i8, __VA_ARGS__) +#define ILVEV_D2_SW(...) ILVEV_D2(v4i32, __VA_ARGS__) /* Description : Interleave left half of byte elements from vectors Arguments : Inputs - in0, in1, in2, in3 @@ -1122,7 +1457,9 @@ out0 = (RTYPE) __msa_ilvl_b((v16i8) in0, (v16i8) in1); \ out1 = (RTYPE) __msa_ilvl_b((v16i8) in2, (v16i8) in3); \ } +#define ILVL_B2_UB(...) ILVL_B2(v16u8, __VA_ARGS__) #define ILVL_B2_SB(...) ILVL_B2(v16i8, __VA_ARGS__) +#define ILVL_B2_UH(...) ILVL_B2(v8u16, __VA_ARGS__) #define ILVL_B2_SH(...) ILVL_B2(v8i16, __VA_ARGS__) #define ILVL_B4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \ @@ -1131,6 +1468,7 @@ ILVL_B2(RTYPE, in0, in1, in2, in3, out0, out1); \ ILVL_B2(RTYPE, in4, in5, in6, in7, out2, out3); \ } +#define ILVL_B4_UB(...) ILVL_B4(v16u8, __VA_ARGS__) #define ILVL_B4_SB(...) ILVL_B4(v16i8, __VA_ARGS__) #define ILVL_B4_UH(...) ILVL_B4(v8u16, __VA_ARGS__) #define ILVL_B4_SH(...) ILVL_B4(v8i16, __VA_ARGS__) @@ -1159,6 +1497,7 @@ ILVL_H2(RTYPE, in4, in5, in6, in7, out2, out3); \ } #define ILVL_H4_SH(...) ILVL_H4(v8i16, __VA_ARGS__) +#define ILVL_H4_SW(...) ILVL_H4(v4i32, __VA_ARGS__) /* Description : Interleave left half of word elements from vectors Arguments : Inputs - in0, in1, in2, in3 @@ -1174,7 +1513,9 @@ out0 = (RTYPE) __msa_ilvl_w((v4i32) in0, (v4i32) in1); \ out1 = (RTYPE) __msa_ilvl_w((v4i32) in2, (v4i32) in3); \ } +#define ILVL_W2_UB(...) ILVL_W2(v16u8, __VA_ARGS__) #define ILVL_W2_SB(...) ILVL_W2(v16i8, __VA_ARGS__) +#define ILVL_W2_SH(...) ILVL_W2(v8i16, __VA_ARGS__) /* Description : Interleave right half of byte elements from vectors Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7 @@ -1212,9 +1553,22 @@ ILVR_B2(RTYPE, in0, in1, in2, in3, out0, out1); \ ILVR_B2(RTYPE, in4, in5, in6, in7, out2, out3); \ } +#define ILVR_B4_UB(...) ILVR_B4(v16u8, __VA_ARGS__) #define ILVR_B4_SB(...) ILVR_B4(v16i8, __VA_ARGS__) #define ILVR_B4_UH(...) ILVR_B4(v8u16, __VA_ARGS__) #define ILVR_B4_SH(...) ILVR_B4(v8i16, __VA_ARGS__) +#define ILVR_B4_SW(...) ILVR_B4(v4i32, __VA_ARGS__) + +#define ILVR_B8(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \ + in8, in9, in10, in11, in12, in13, in14, in15, \ + out0, out1, out2, out3, out4, out5, out6, out7) \ +{ \ + ILVR_B4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \ + out0, out1, out2, out3); \ + ILVR_B4(RTYPE, in8, in9, in10, in11, in12, in13, in14, in15, \ + out4, out5, out6, out7); \ +} +#define ILVR_B8_UH(...) ILVR_B8(v8u16, __VA_ARGS__) /* Description : Interleave right half of halfword elements from vectors Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7 @@ -1248,6 +1602,7 @@ ILVR_H2(RTYPE, in4, in5, in6, in7, out2, out3); \ } #define ILVR_H4_SH(...) ILVR_H4(v8i16, __VA_ARGS__) +#define ILVR_H4_SW(...) ILVR_H4(v4i32, __VA_ARGS__) #define ILVR_W2(RTYPE, in0, in1, in2, in3, out0, out1) \ { \ @@ -1256,6 +1611,7 @@ } #define ILVR_W2_UB(...) ILVR_W2(v16u8, __VA_ARGS__) #define ILVR_W2_SB(...) ILVR_W2(v16i8, __VA_ARGS__) +#define ILVR_W2_SH(...) ILVR_W2(v8i16, __VA_ARGS__) #define ILVR_W4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \ out0, out1, out2, out3) \ @@ -1264,6 +1620,7 @@ ILVR_W2(RTYPE, in4, in5, in6, in7, out2, out3); \ } #define ILVR_W4_SB(...) ILVR_W4(v16i8, __VA_ARGS__) +#define ILVR_W4_UB(...) ILVR_W4(v16u8, __VA_ARGS__) /* Description : Interleave right half of double word elements from vectors Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7 @@ -1279,6 +1636,7 @@ out0 = (RTYPE) __msa_ilvr_d((v2i64) (in0), (v2i64) (in1)); \ out1 = (RTYPE) __msa_ilvr_d((v2i64) (in2), (v2i64) (in3)); \ } +#define ILVR_D2_UB(...) ILVR_D2(v16u8, __VA_ARGS__) #define ILVR_D2_SB(...) ILVR_D2(v16i8, __VA_ARGS__) #define ILVR_D2_SH(...) ILVR_D2(v8i16, __VA_ARGS__) @@ -1296,6 +1654,7 @@ ILVR_D2(RTYPE, in4, in5, in6, in7, out2, out3); \ } #define ILVR_D4_SB(...) ILVR_D4(v16i8, __VA_ARGS__) +#define ILVR_D4_UB(...) ILVR_D4(v16u8, __VA_ARGS__) /* Description : Interleave both left and right half of input vectors Arguments : Inputs - in0, in1 @@ -1311,8 +1670,11 @@ out0 = (RTYPE) __msa_ilvr_b((v16i8) in0, (v16i8) in1); \ out1 = (RTYPE) __msa_ilvl_b((v16i8) in0, (v16i8) in1); \ } +#define ILVRL_B2_UB(...) ILVRL_B2(v16u8, __VA_ARGS__) #define ILVRL_B2_SB(...) ILVRL_B2(v16i8, __VA_ARGS__) +#define ILVRL_B2_UH(...) ILVRL_B2(v8u16, __VA_ARGS__) #define ILVRL_B2_SH(...) ILVRL_B2(v8i16, __VA_ARGS__) +#define ILVRL_B2_SW(...) ILVRL_B2(v4i32, __VA_ARGS__) #define ILVRL_H2(RTYPE, in0, in1, out0, out1) \ { \ @@ -1345,6 +1707,7 @@ in0 = (RTYPE) __msa_maxi_s_h((v8i16) in0, (max_val)); \ in1 = (RTYPE) __msa_maxi_s_h((v8i16) in1, (max_val)); \ } +#define MAXI_SH2_UH(...) MAXI_SH2(v8u16, __VA_ARGS__) #define MAXI_SH2_SH(...) MAXI_SH2(v8i16, __VA_ARGS__) #define MAXI_SH4(RTYPE, in0, in1, in2, in3, max_val) \ @@ -1370,6 +1733,7 @@ in1 = (RTYPE) __msa_sat_u_h((v8u16) in1, sat_val); \ } #define SAT_UH2_UH(...) SAT_UH2(v8u16, __VA_ARGS__) +#define SAT_UH2_SH(...) SAT_UH2(v8i16, __VA_ARGS__) #define SAT_UH4(RTYPE, in0, in1, in2, in3, sat_val) \ { \ @@ -1450,6 +1814,15 @@ #define SPLATI_H2_SB(...) SPLATI_H2(v16i8, __VA_ARGS__) #define SPLATI_H2_SH(...) SPLATI_H2(v8i16, __VA_ARGS__) +#define SPLATI_H3(RTYPE, in, idx0, idx1, idx2, \ + out0, out1, out2) \ +{ \ + SPLATI_H2(RTYPE, in, idx0, idx1, out0, out1); \ + out2 = (RTYPE) __msa_splati_h((v8i16) in, idx2); \ +} +#define SPLATI_H3_SB(...) SPLATI_H3(v16i8, __VA_ARGS__) +#define SPLATI_H3_SH(...) SPLATI_H3(v8i16, __VA_ARGS__) + #define SPLATI_H4(RTYPE, in, idx0, idx1, idx2, idx3, \ out0, out1, out2, out3) \ { \ @@ -1582,6 +1955,24 @@ } #define PCKEV_D4_UB(...) PCKEV_D4(v16u8, __VA_ARGS__) +/* Description : Pack odd double word elements of vector pairs + Arguments : Inputs - in0, in1 + Outputs - out0, out1 + Return Type - as per RTYPE + Details : As operation is on same input 'in0' vector, index 1 double word + element is overwritten to index 0 and result is written to out0 + As operation is on same input 'in1' vector, index 1 double word + element is overwritten to index 0 and result is written to out1 +*/ +#define PCKOD_D2(RTYPE, in0, in1, in2, in3, out0, out1) \ +{ \ + out0 = (RTYPE) __msa_pckod_d((v2i64) in0, (v2i64) in1); \ + out1 = (RTYPE) __msa_pckod_d((v2i64) in2, (v2i64) in3); \ +} +#define PCKOD_D2_UB(...) PCKOD_D2(v16u8, __VA_ARGS__) +#define PCKOD_D2_SH(...) PCKOD_D2(v8i16, __VA_ARGS__) +#define PCKOD_D2_SD(...) PCKOD_D2(v2i64, __VA_ARGS__) + /* Description : Each byte element is logically xor'ed with immediate 128 Arguments : Inputs - in0, in1 Outputs - in0, in1 (in-place) @@ -1870,6 +2261,60 @@ ADD2(in4, in5, in6, in7, out2, out3); \ } +/* Description : Subtraction of 2 pairs of vectors + Arguments : Inputs - in0, in1, in2, in3 + Outputs - out0, out1 + Details : Each element from 2 pairs vectors is subtracted and 2 results + are produced +*/ +#define SUB2(in0, in1, in2, in3, out0, out1) \ +{ \ + out0 = in0 - in1; \ + out1 = in2 - in3; \ +} +#define SUB4(in0, in1, in2, in3, in4, in5, in6, in7, out0, out1, out2, out3) \ +{ \ + out0 = in0 - in1; \ + out1 = in2 - in3; \ + out2 = in4 - in5; \ + out3 = in6 - in7; \ +} + +/* Description : Sign extend halfword elements from right half of the vector + Arguments : Inputs - in (input halfword vector) + Outputs - out (sign extended word vectors) + Return Type - signed word + Details : Sign bit of halfword elements from input vector 'in' is + extracted and interleaved with same vector 'in0' to generate + 4 word elements keeping sign intact +*/ +#define UNPCK_R_SH_SW(in, out) \ +{ \ + v8i16 sign_m; \ + \ + sign_m = __msa_clti_s_h((v8i16) in, 0); \ + out = (v4i32) __msa_ilvr_h(sign_m, (v8i16) in); \ +} + +/* Description : Sign extend byte elements from input vector and return + halfword results in pair of vectors + Arguments : Inputs - in (1 input byte vector) + Outputs - out0, out1 (sign extended 2 halfword vectors) + Return Type - signed halfword + Details : Sign bit of byte elements from input vector 'in' is + extracted and interleaved right with same vector 'in0' to + generate 8 signed halfword elements in 'out0' + Then interleaved left with same vector 'in0' to + generate 8 signed halfword elements in 'out1' +*/ +#define UNPCK_SB_SH(in, out0, out1) \ +{ \ + v16i8 tmp_m; \ + \ + tmp_m = __msa_clti_s_b((v16i8) in, 0); \ + ILVRL_B2_SH(tmp_m, in, out0, out1); \ +} + /* Description : Zero extend unsigned byte elements to halfword elements Arguments : Inputs - in (1 input unsigned byte vector) Outputs - out0, out1 (unsigned 2 halfword vectors) @@ -1903,6 +2348,18 @@ ILVRL_H2_SW(tmp_m, in, out0, out1); \ } +/* Description : Swap two variables + Arguments : Inputs - in0, in1 + Outputs - in0, in1 (in-place) + Details : Swapping of two input variables using xor +*/ +#define SWAP(in0, in1) \ +{ \ + in0 = in0 ^ in1; \ + in1 = in0 ^ in1; \ + in0 = in0 ^ in1; \ +} + /* Description : Butterfly of 4 input vectors Arguments : Inputs - in0, in1, in2, in3 Outputs - out0, out1, out2, out3 @@ -1917,6 +2374,54 @@ out3 = in0 - in3; \ } +/* Description : Butterfly of 8 input vectors + Arguments : Inputs - in0 ... in7 + Outputs - out0 .. out7 + Details : Butterfly operation +*/ +#define BUTTERFLY_8(in0, in1, in2, in3, in4, in5, in6, in7, \ + out0, out1, out2, out3, out4, out5, out6, out7) \ +{ \ + out0 = in0 + in7; \ + out1 = in1 + in6; \ + out2 = in2 + in5; \ + out3 = in3 + in4; \ + \ + out4 = in3 - in4; \ + out5 = in2 - in5; \ + out6 = in1 - in6; \ + out7 = in0 - in7; \ +} + +/* Description : Butterfly of 16 input vectors + Arguments : Inputs - in0 ... in15 + Outputs - out0 .. out15 + Details : Butterfly operation +*/ +#define BUTTERFLY_16(in0, in1, in2, in3, in4, in5, in6, in7, \ + in8, in9, in10, in11, in12, in13, in14, in15, \ + out0, out1, out2, out3, out4, out5, out6, out7, \ + out8, out9, out10, out11, out12, out13, out14, out15) \ +{ \ + out0 = in0 + in15; \ + out1 = in1 + in14; \ + out2 = in2 + in13; \ + out3 = in3 + in12; \ + out4 = in4 + in11; \ + out5 = in5 + in10; \ + out6 = in6 + in9; \ + out7 = in7 + in8; \ + \ + out8 = in7 - in8; \ + out9 = in6 - in9; \ + out10 = in5 - in10; \ + out11 = in4 - in11; \ + out12 = in3 - in12; \ + out13 = in2 - in13; \ + out14 = in1 - in14; \ + out15 = in0 - in15; \ +} + /* Description : Transposes input 4x4 byte block Arguments : Inputs - in0, in1, in2, in3 (input 4x4 byte block) Outputs - out0, out1, out2, out3 (output 4x4 byte block) @@ -1959,8 +2464,69 @@ out1 = (RTYPE) __msa_ilvl_d((v2i64) out2, (v2i64) out0); \ out3 = (RTYPE) __msa_ilvl_d((v2i64) out0, (v2i64) out2); \ } - #define TRANSPOSE8x4_UB_UB(...) TRANSPOSE8x4_UB(v16u8, __VA_ARGS__) +#define TRANSPOSE8x4_UB_UH(...) TRANSPOSE8x4_UB(v8u16, __VA_ARGS__) + +/* Description : Transposes input 8x8 byte block + Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7 + (input 8x8 byte block) + Outputs - out0, out1, out2, out3, out4, out5, out6, out7 + (output 8x8 byte block) + Return Type - unsigned byte + Details : +*/ +#define TRANSPOSE8x8_UB(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \ + out0, out1, out2, out3, out4, out5, out6, out7) \ +{ \ + v16i8 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + v16i8 tmp4_m, tmp5_m, tmp6_m, tmp7_m; \ + \ + ILVR_B4_SB(in2, in0, in3, in1, in6, in4, in7, in5, \ + tmp0_m, tmp1_m, tmp2_m, tmp3_m); \ + ILVRL_B2_SB(tmp1_m, tmp0_m, tmp4_m, tmp5_m); \ + ILVRL_B2_SB(tmp3_m, tmp2_m, tmp6_m, tmp7_m); \ + ILVRL_W2(RTYPE, tmp6_m, tmp4_m, out0, out2); \ + ILVRL_W2(RTYPE, tmp7_m, tmp5_m, out4, out6); \ + SLDI_B2_0(RTYPE, out0, out2, out1, out3, 8); \ + SLDI_B2_0(RTYPE, out4, out6, out5, out7, 8); \ +} +#define TRANSPOSE8x8_UB_UB(...) TRANSPOSE8x8_UB(v16u8, __VA_ARGS__) +#define TRANSPOSE8x8_UB_UH(...) TRANSPOSE8x8_UB(v8u16, __VA_ARGS__) + +/* Description : Transposes 16x4 block into 4x16 with byte elements in vectors + Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7, + in8, in9, in10, in11, in12, in13, in14, in15 + Outputs - out0, out1, out2, out3 + Return Type - unsigned byte + Details : +*/ +#define TRANSPOSE16x4_UB_UB(in0, in1, in2, in3, in4, in5, in6, in7, \ + in8, in9, in10, in11, in12, in13, in14, in15, \ + out0, out1, out2, out3) \ +{ \ + v2i64 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + \ + ILVEV_W2_SD(in0, in4, in8, in12, tmp0_m, tmp1_m); \ + out1 = (v16u8) __msa_ilvev_d(tmp1_m, tmp0_m); \ + \ + ILVEV_W2_SD(in1, in5, in9, in13, tmp0_m, tmp1_m); \ + out3 = (v16u8) __msa_ilvev_d(tmp1_m, tmp0_m); \ + \ + ILVEV_W2_SD(in2, in6, in10, in14, tmp0_m, tmp1_m); \ + \ + tmp2_m = __msa_ilvev_d(tmp1_m, tmp0_m); \ + ILVEV_W2_SD(in3, in7, in11, in15, tmp0_m, tmp1_m); \ + \ + tmp3_m = __msa_ilvev_d(tmp1_m, tmp0_m); \ + ILVEV_B2_SD(out1, out3, tmp2_m, tmp3_m, tmp0_m, tmp1_m); \ + out0 = (v16u8) __msa_ilvev_h((v8i16) tmp1_m, (v8i16) tmp0_m); \ + out2 = (v16u8) __msa_ilvod_h((v8i16) tmp1_m, (v8i16) tmp0_m); \ + \ + tmp0_m = (v2i64) __msa_ilvod_b((v16i8) out3, (v16i8) out1); \ + tmp1_m = (v2i64) __msa_ilvod_b((v16i8) tmp3_m, (v16i8) tmp2_m); \ + out1 = (v16u8) __msa_ilvev_h((v8i16) tmp1_m, (v8i16) tmp0_m); \ + out3 = (v16u8) __msa_ilvod_h((v8i16) tmp1_m, (v8i16) tmp0_m); \ +} /* Description : Transposes 16x8 block into 8x16 with byte elements in vectors Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7, @@ -2011,6 +2577,22 @@ out7 = (v16u8) __msa_ilvod_w((v4i32) tmp3_m, (v4i32) tmp2_m); \ } +/* Description : Transposes 4x4 block with half word elements in vectors + Arguments : Inputs - in0, in1, in2, in3 + Outputs - out0, out1, out2, out3 + Return Type - signed halfword + Details : +*/ +#define TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, out0, out1, out2, out3) \ +{ \ + v8i16 s0_m, s1_m; \ + \ + ILVR_H2_SH(in1, in0, in3, in2, s0_m, s1_m); \ + ILVRL_W2_SH(s1_m, s0_m, out0, out2); \ + out1 = (v8i16) __msa_ilvl_d((v2i64) out0, (v2i64) out0); \ + out3 = (v8i16) __msa_ilvl_d((v2i64) out0, (v2i64) out2); \ +} + /* Description : Transposes 8x8 block with half word elements in vectors Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7 Outputs - out0, out1, out2, out3, out4, out5, out6, out7 @@ -2061,6 +2643,239 @@ out3 = (v4i32) __msa_ilvl_d((v2i64) s3_m, (v2i64) s1_m); \ } +/* Description : Average byte elements from pair of vectors and store 8x4 byte + block in destination memory + Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7, pdst, stride + Outputs - + Return Type - + Details : Each byte element from input vector pair 'in0' and 'in1' are + averaged (a + b)/2 and stored in 'tmp0_m' + Each byte element from input vector pair 'in2' and 'in3' are + averaged (a + b)/2 and stored in 'tmp1_m' + Each byte element from input vector pair 'in4' and 'in5' are + averaged (a + b)/2 and stored in 'tmp2_m' + Each byte element from input vector pair 'in6' and 'in7' are + averaged (a + b)/2 and stored in 'tmp3_m' + The half vector results from all 4 vectors are stored in + destination memory as 8x4 byte block +*/ +#define AVE_ST8x4_UB(in0, in1, in2, in3, in4, in5, in6, in7, pdst, stride) \ +{ \ + uint64_t out0_m, out1_m, out2_m, out3_m; \ + v16u8 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + \ + tmp0_m = __msa_ave_u_b((v16u8) in0, (v16u8) in1); \ + tmp1_m = __msa_ave_u_b((v16u8) in2, (v16u8) in3); \ + tmp2_m = __msa_ave_u_b((v16u8) in4, (v16u8) in5); \ + tmp3_m = __msa_ave_u_b((v16u8) in6, (v16u8) in7); \ + \ + out0_m = __msa_copy_u_d((v2i64) tmp0_m, 0); \ + out1_m = __msa_copy_u_d((v2i64) tmp1_m, 0); \ + out2_m = __msa_copy_u_d((v2i64) tmp2_m, 0); \ + out3_m = __msa_copy_u_d((v2i64) tmp3_m, 0); \ + SD4(out0_m, out1_m, out2_m, out3_m, pdst, stride); \ +} + +/* Description : Average byte elements from pair of vectors and store 16x4 byte + block in destination memory + Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7, pdst, stride + Outputs - + Return Type - + Details : Each byte element from input vector pair 'in0' and 'in1' are + averaged (a + b)/2 and stored in 'tmp0_m' + Each byte element from input vector pair 'in2' and 'in3' are + averaged (a + b)/2 and stored in 'tmp1_m' + Each byte element from input vector pair 'in4' and 'in5' are + averaged (a + b)/2 and stored in 'tmp2_m' + Each byte element from input vector pair 'in6' and 'in7' are + averaged (a + b)/2 and stored in 'tmp3_m' + The results from all 4 vectors are stored in destination + memory as 16x4 byte block +*/ +#define AVE_ST16x4_UB(in0, in1, in2, in3, in4, in5, in6, in7, pdst, stride) \ +{ \ + v16u8 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + \ + tmp0_m = __msa_ave_u_b((v16u8) in0, (v16u8) in1); \ + tmp1_m = __msa_ave_u_b((v16u8) in2, (v16u8) in3); \ + tmp2_m = __msa_ave_u_b((v16u8) in4, (v16u8) in5); \ + tmp3_m = __msa_ave_u_b((v16u8) in6, (v16u8) in7); \ + \ + ST_UB4(tmp0_m, tmp1_m, tmp2_m, tmp3_m, pdst, stride); \ +} + +/* Description : Average rounded byte elements from pair of vectors and store + 8x4 byte block in destination memory + Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7, pdst, stride + Outputs - + Return Type - + Details : Each byte element from input vector pair 'in0' and 'in1' are + average rounded (a + b + 1)/2 and stored in 'tmp0_m' + Each byte element from input vector pair 'in2' and 'in3' are + average rounded (a + b + 1)/2 and stored in 'tmp1_m' + Each byte element from input vector pair 'in4' and 'in5' are + average rounded (a + b + 1)/2 and stored in 'tmp2_m' + Each byte element from input vector pair 'in6' and 'in7' are + average rounded (a + b + 1)/2 and stored in 'tmp3_m' + The half vector results from all 4 vectors are stored in + destination memory as 8x4 byte block +*/ +#define AVER_ST8x4_UB(in0, in1, in2, in3, in4, in5, in6, in7, pdst, stride) \ +{ \ + uint64_t out0_m, out1_m, out2_m, out3_m; \ + v16u8 tp0_m, tp1_m, tp2_m, tp3_m; \ + \ + AVER_UB4_UB(in0, in1, in2, in3, in4, in5, in6, in7, \ + tp0_m, tp1_m, tp2_m, tp3_m); \ + \ + out0_m = __msa_copy_u_d((v2i64) tp0_m, 0); \ + out1_m = __msa_copy_u_d((v2i64) tp1_m, 0); \ + out2_m = __msa_copy_u_d((v2i64) tp2_m, 0); \ + out3_m = __msa_copy_u_d((v2i64) tp3_m, 0); \ + SD4(out0_m, out1_m, out2_m, out3_m, pdst, stride); \ +} + +/* Description : Average rounded byte elements from pair of vectors and store + 16x4 byte block in destination memory + Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7, pdst, stride + Outputs - + Return Type - + Details : Each byte element from input vector pair 'in0' and 'in1' are + average rounded (a + b + 1)/2 and stored in 'tmp0_m' + Each byte element from input vector pair 'in2' and 'in3' are + average rounded (a + b + 1)/2 and stored in 'tmp1_m' + Each byte element from input vector pair 'in4' and 'in5' are + average rounded (a + b + 1)/2 and stored in 'tmp2_m' + Each byte element from input vector pair 'in6' and 'in7' are + average rounded (a + b + 1)/2 and stored in 'tmp3_m' + The vector results from all 4 vectors are stored in + destination memory as 16x4 byte block +*/ +#define AVER_ST16x4_UB(in0, in1, in2, in3, in4, in5, in6, in7, pdst, stride) \ +{ \ + v16u8 t0_m, t1_m, t2_m, t3_m; \ + \ + AVER_UB4_UB(in0, in1, in2, in3, in4, in5, in6, in7, \ + t0_m, t1_m, t2_m, t3_m); \ + ST_UB4(t0_m, t1_m, t2_m, t3_m, pdst, stride); \ +} + +/* Description : Average rounded byte elements from pair of vectors, + average rounded with destination and store 8x4 byte block + in destination memory + Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7, pdst, stride + Outputs - + Return Type - + Details : Each byte element from input vector pair 'in0' and 'in1' are + average rounded (a + b + 1)/2 and stored in 'tmp0_m' + Each byte element from input vector pair 'in2' and 'in3' are + average rounded (a + b + 1)/2 and stored in 'tmp1_m' + Each byte element from input vector pair 'in4' and 'in5' are + average rounded (a + b + 1)/2 and stored in 'tmp2_m' + Each byte element from input vector pair 'in6' and 'in7' are + average rounded (a + b + 1)/2 and stored in 'tmp3_m' + The half vector results from all 4 vectors are stored in + destination memory as 8x4 byte block +*/ +#define AVER_DST_ST8x4_UB(in0, in1, in2, in3, in4, in5, in6, in7, \ + pdst, stride) \ +{ \ + v16u8 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + v16u8 dst0_m, dst1_m, dst2_m, dst3_m; \ + \ + LD_UB4(pdst, stride, dst0_m, dst1_m, dst2_m, dst3_m); \ + AVER_UB4_UB(in0, in1, in2, in3, in4, in5, in6, in7, \ + tmp0_m, tmp1_m, tmp2_m, tmp3_m); \ + AVER_ST8x4_UB(dst0_m, tmp0_m, dst1_m, tmp1_m, \ + dst2_m, tmp2_m, dst3_m, tmp3_m, pdst, stride); \ +} + +/* Description : Average rounded byte elements from pair of vectors, + average rounded with destination and store 16x4 byte block + in destination memory + Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7, pdst, stride + Outputs - + Return Type - + Details : Each byte element from input vector pair 'in0' and 'in1' are + average rounded (a + b + 1)/2 and stored in 'tmp0_m' + Each byte element from input vector pair 'in2' and 'in3' are + average rounded (a + b + 1)/2 and stored in 'tmp1_m' + Each byte element from input vector pair 'in4' and 'in5' are + average rounded (a + b + 1)/2 and stored in 'tmp2_m' + Each byte element from input vector pair 'in6' and 'in7' are + average rounded (a + b + 1)/2 and stored in 'tmp3_m' + The vector results from all 4 vectors are stored in + destination memory as 16x4 byte block +*/ +#define AVER_DST_ST16x4_UB(in0, in1, in2, in3, in4, in5, in6, in7, \ + pdst, stride) \ +{ \ + v16u8 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + v16u8 dst0_m, dst1_m, dst2_m, dst3_m; \ + \ + LD_UB4(pdst, stride, dst0_m, dst1_m, dst2_m, dst3_m); \ + AVER_UB4_UB(in0, in1, in2, in3, in4, in5, in6, in7, \ + tmp0_m, tmp1_m, tmp2_m, tmp3_m); \ + AVER_ST16x4_UB(dst0_m, tmp0_m, dst1_m, tmp1_m, \ + dst2_m, tmp2_m, dst3_m, tmp3_m, pdst, stride); \ +} + +/* Description : Add block 4x4 + Arguments : Inputs - in0, in1, in2, in3, pdst, stride + Outputs - + Return Type - unsigned bytes + Details : Least significant 4 bytes from each input vector are added to + the destination bytes, clipped between 0-255 and then stored. +*/ +#define ADDBLK_ST4x4_UB(in0, in1, in2, in3, pdst, stride) \ +{ \ + uint32_t src0_m, src1_m, src2_m, src3_m; \ + uint32_t out0_m, out1_m, out2_m, out3_m; \ + v8i16 inp0_m, inp1_m, res0_m, res1_m; \ + v16i8 dst0_m = { 0 }; \ + v16i8 dst1_m = { 0 }; \ + v16i8 zero_m = { 0 }; \ + \ + ILVR_D2_SH(in1, in0, in3, in2, inp0_m, inp1_m) \ + LW4(pdst, stride, src0_m, src1_m, src2_m, src3_m); \ + INSERT_W2_SB(src0_m, src1_m, dst0_m); \ + INSERT_W2_SB(src2_m, src3_m, dst1_m); \ + ILVR_B2_SH(zero_m, dst0_m, zero_m, dst1_m, res0_m, res1_m); \ + ADD2(res0_m, inp0_m, res1_m, inp1_m, res0_m, res1_m); \ + CLIP_SH2_0_255(res0_m, res1_m); \ + PCKEV_B2_SB(res0_m, res0_m, res1_m, res1_m, dst0_m, dst1_m); \ + \ + out0_m = __msa_copy_u_w((v4i32) dst0_m, 0); \ + out1_m = __msa_copy_u_w((v4i32) dst0_m, 1); \ + out2_m = __msa_copy_u_w((v4i32) dst1_m, 0); \ + out3_m = __msa_copy_u_w((v4i32) dst1_m, 1); \ + SW4(out0_m, out1_m, out2_m, out3_m, pdst, stride); \ +} + +/* Description : Dot product and addition of 3 signed halfword input vectors + Arguments : Inputs - in0, in1, in2, coeff0, coeff1, coeff2 + Outputs - out0_m + Return Type - signed halfword + Details : Dot product of 'in0' with 'coeff0' + Dot product of 'in1' with 'coeff1' + Dot product of 'in2' with 'coeff2' + Addition of all the 3 vector results + + out0_m = (in0 * coeff0) + (in1 * coeff1) + (in2 * coeff2) +*/ +#define DPADD_SH3_SH(in0, in1, in2, coeff0, coeff1, coeff2) \ +( { \ + v8i16 tmp1_m; \ + v8i16 out0_m; \ + \ + out0_m = __msa_dotp_s_h((v16i8) in0, (v16i8) coeff0); \ + out0_m = __msa_dpadd_s_h(out0_m, (v16i8) in1, (v16i8) coeff1); \ + tmp1_m = __msa_dotp_s_h((v16i8) in2, (v16i8) coeff2); \ + out0_m = __msa_adds_s_h(out0_m, tmp1_m); \ + \ + out0_m; \ +} ) + /* Description : Pack even elements of input vectors & xor with 128 Arguments : Inputs - in0, in1 Outputs - out_m @@ -2077,6 +2892,24 @@ out_m; \ } ) +/* Description : Converts inputs to unsigned bytes, interleave, average & store + as 8x4 unsigned byte block + Arguments : Inputs - in0, in1, in2, in3, dst0, dst1, dst2, dst3, + pdst, stride +*/ +#define CONVERT_UB_AVG_ST8x4_UB(in0, in1, in2, in3, \ + dst0, dst1, dst2, dst3, pdst, stride) \ +{ \ + v16u8 tmp0_m, tmp1_m, tmp2_m, tmp3_m; \ + uint8_t *pdst_m = (uint8_t *) (pdst); \ + \ + tmp0_m = PCKEV_XORI128_UB(in0, in1); \ + tmp1_m = PCKEV_XORI128_UB(in2, in3); \ + ILVR_D2_UB(dst1, dst0, dst3, dst2, tmp2_m, tmp3_m); \ + AVER_UB2_UB(tmp0_m, tmp2_m, tmp1_m, tmp3_m, tmp0_m, tmp1_m); \ + ST8x4_UB(tmp0_m, tmp1_m, pdst_m, stride); \ +} + /* Description : Pack even byte elements, extract 0 & 2 index words from pair of results and store 4 words in destination memory as per stride @@ -2096,4 +2929,31 @@ \ SW4(out0_m, out1_m, out2_m, out3_m, pdst, stride); \ } + +/* Description : Pack even byte elements and store byte vector in destination + memory + Arguments : Inputs - in0, in1, pdst +*/ +#define PCKEV_ST_SB(in0, in1, pdst) \ +{ \ + v16i8 tmp_m; \ + tmp_m = __msa_pckev_b((v16i8) in1, (v16i8) in0); \ + ST_SB(tmp_m, (pdst)); \ +} + +/* Description : Horizontal 2 tap filter kernel code + Arguments : Inputs - in0, in1, mask, coeff, shift +*/ +#define HORIZ_2TAP_FILT_UH(in0, in1, mask, coeff, shift) \ +( { \ + v16i8 tmp0_m; \ + v8u16 tmp1_m; \ + \ + tmp0_m = __msa_vshf_b((v16i8) mask, (v16i8) in1, (v16i8) in0); \ + tmp1_m = __msa_dotp_u_h((v16u8) tmp0_m, (v16u8) coeff); \ + tmp1_m = (v8u16) __msa_srari_h((v8i16) tmp1_m, shift); \ + tmp1_m = __msa_sat_u_h(tmp1_m, shift); \ + \ + tmp1_m; \ +} ) #endif /* AVUTIL_MIPS_GENERIC_MACROS_MSA_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/parseutils.c ffmpeg-2.7.2~trusty~ppa1/libavutil/parseutils.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/parseutils.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/parseutils.c 2015-07-21 17:20:03.000000000 +0000 @@ -111,9 +111,11 @@ { "hd720", 1280, 720 }, { "hd1080", 1920,1080 }, { "2k", 2048,1080 }, /* Digital Cinema System Specification */ + { "2kdci", 2048,1080 }, { "2kflat", 1998,1080 }, { "2kscope", 2048, 858 }, { "4k", 4096,2160 }, /* Digital Cinema System Specification */ + { "4kdci", 4096,2160 }, { "4kflat", 3996,2160 }, { "4kscope", 4096,1716 }, { "nhd", 640,360 }, @@ -122,6 +124,8 @@ { "fwqvga", 432,240 }, { "hvga", 480,320 }, { "qhd", 960,540 }, + { "uhd2160", 3840,2160 }, + { "uhd4320", 7680,4320 }, }; static const VideoRateAbbr video_rate_abbrs[]= { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/pixdesc.c ffmpeg-2.7.2~trusty~ppa1/libavutil/pixdesc.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/pixdesc.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/pixdesc.c 2015-08-03 17:20:02.000000000 +0000 @@ -1632,6 +1632,10 @@ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA, }, + [AV_PIX_FMT_VIDEOTOOLBOX] = { + .name = "videotoolbox_vld", + .flags = AV_PIX_FMT_FLAG_HWACCEL, + }, [AV_PIX_FMT_GBRP] = { .name = "gbrp", .nb_components = 3, @@ -1965,6 +1969,32 @@ .name = "mmal", .flags = AV_PIX_FMT_FLAG_HWACCEL, }, + [AV_PIX_FMT_AYUV64LE] = { + .name = "ayuv64le", + .nb_components = 4, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 7, 3, 0, 15 }, /* Y */ + { 0, 7, 5, 0, 15 }, /* U */ + { 0, 7, 7, 0, 15 }, /* V */ + { 0, 7, 1, 0, 15 }, /* A */ + }, + .flags = AV_PIX_FMT_FLAG_ALPHA, + }, + [AV_PIX_FMT_AYUV64BE] = { + .name = "ayuv64be", + .nb_components = 4, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 7, 3, 0, 15 }, /* Y */ + { 0, 7, 5, 0, 15 }, /* U */ + { 0, 7, 7, 0, 15 }, /* V */ + { 0, 7, 1, 0, 15 }, /* A */ + }, + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA, + }, }; static const char *color_range_names[AVCOL_RANGE_NB] = { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/pixfmt.h ffmpeg-2.7.2~trusty~ppa1/libavutil/pixfmt.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/pixfmt.h 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/pixfmt.h 2015-08-03 17:20:02.000000000 +0000 @@ -308,6 +308,10 @@ AV_PIX_FMT_YUV440P10BE, ///< planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian AV_PIX_FMT_YUV440P12LE, ///< planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian AV_PIX_FMT_YUV440P12BE, ///< planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian + AV_PIX_FMT_AYUV64LE, ///< packed AYUV 4:4:4,64bpp (1 Cr & Cb sample per 1x1 Y & A samples), little-endian + AV_PIX_FMT_AYUV64BE, ///< packed AYUV 4:4:4,64bpp (1 Cr & Cb sample per 1x1 Y & A samples), big-endian + + AV_PIX_FMT_VIDEOTOOLBOX, ///< hardware decoding through Videotoolbox AV_PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions @@ -401,6 +405,7 @@ #define AV_PIX_FMT_XYZ12 AV_PIX_FMT_NE(XYZ12BE, XYZ12LE) #define AV_PIX_FMT_NV20 AV_PIX_FMT_NE(NV20BE, NV20LE) +#define AV_PIX_FMT_AYUV64 AV_PIX_FMT_NE(AYUV64BE, AYUV64LE) #if FF_API_PIX_FMT diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/rc4.c ffmpeg-2.7.2~trusty~ppa1/libavutil/rc4.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/rc4.c 2014-12-01 00:21:49.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/rc4.c 2015-08-02 17:20:02.000000000 +0000 @@ -22,9 +22,20 @@ */ #include "avutil.h" #include "common.h" +#include "mem.h" #include "rc4.h" -typedef struct AVRC4 AVRC4; +#if !FF_API_CRYPTO_CONTEXT +struct AVRC4 { + uint8_t state[256]; + int x, y; +}; +#endif + +AVRC4 *av_rc4_alloc(void) +{ + return av_mallocz(sizeof(struct AVRC4)); +} int av_rc4_init(AVRC4 *r, const uint8_t *key, int key_bits, int decrypt) { int i, j; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/rc4.h ffmpeg-2.7.2~trusty~ppa1/libavutil/rc4.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/rc4.h 2015-03-12 19:53:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/rc4.h 2015-08-02 17:20:02.000000000 +0000 @@ -22,17 +22,34 @@ #define AVUTIL_RC4_H #include +#include "version.h" -struct AVRC4 { +/** + * @defgroup lavu_rc4 RC4 + * @ingroup lavu_crypto + * @{ + */ + +#if FF_API_CRYPTO_CONTEXT +typedef struct AVRC4 { uint8_t state[256]; int x, y; -}; +} AVRC4; +#else +typedef struct AVRC4 AVRC4; +#endif + +/** + * Allocate an AVRC4 context. + */ +AVRC4 *av_rc4_alloc(void); /** * @brief Initializes an AVRC4 context. * * @param key_bits must be a multiple of 8 * @param decrypt 0 for encryption, 1 for decryption, currently has no effect + * @return zero on success, negative value otherwise */ int av_rc4_init(struct AVRC4 *d, const uint8_t *key, int key_bits, int decrypt); @@ -47,4 +64,8 @@ */ void av_rc4_crypt(struct AVRC4 *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt); +/** + * @} + */ + #endif /* AVUTIL_RC4_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/softfloat.c ffmpeg-2.7.2~trusty~ppa1/libavutil/softfloat.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/softfloat.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/softfloat.c 2015-07-26 17:20:03.000000000 +0000 @@ -19,73 +19,18 @@ */ #include -#include #include "softfloat.h" #include "common.h" #include "log.h" -#undef printf +#ifdef TEST +#include static const SoftFloat FLOAT_0_017776489257 = {0x1234, 12}; static const SoftFloat FLOAT_1374_40625 = {0xabcd, 25}; static const SoftFloat FLOAT_0_1249694824218 = {0xFFF, 15}; -static av_const double av_sf2double(SoftFloat v) { - v.exp -= ONE_BITS +1; - if(v.exp > 0) return (double)v.mant * (double)(1 << v.exp); - else return (double)v.mant / (double)(1 << (-v.exp)); -} - -void av_sincos_sf(int a, int *s, int *c) -{ - int idx, sign; - int sv, cv; - int st, ct; - - idx = a >> 26; - sign = (idx << 27) >> 31; - cv = av_costbl_1_sf[idx & 0xf]; - cv = (cv ^ sign) - sign; - - idx -= 8; - sign = (idx << 27) >> 31; - sv = av_costbl_1_sf[idx & 0xf]; - sv = (sv ^ sign) - sign; - - idx = a >> 21; - ct = av_costbl_2_sf[idx & 0x1f]; - st = av_sintbl_2_sf[idx & 0x1f]; - - idx = (int)(((int64_t)cv * ct - (int64_t)sv * st + 0x20000000) >> 30); - - sv = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30); - - cv = idx; - - idx = a >> 16; - ct = av_costbl_3_sf[idx & 0x1f]; - st = av_sintbl_3_sf[idx & 0x1f]; - - idx = (int)(((int64_t)cv * ct - (int64_t)sv * st + 0x20000000) >> 30); - - sv = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30); - cv = idx; - - idx = a >> 11; - - ct = (int)(((int64_t)av_costbl_4_sf[idx & 0x1f] * (0x800 - (a & 0x7ff)) + - (int64_t)av_costbl_4_sf[(idx & 0x1f)+1]*(a & 0x7ff) + - 0x400) >> 11); - st = (int)(((int64_t)av_sintbl_4_sf[idx & 0x1f] * (0x800 - (a & 0x7ff)) + - (int64_t)av_sintbl_4_sf[(idx & 0x1f) + 1] * (a & 0x7ff) + - 0x400) >> 11); - - *c = (int)(((int64_t)cv * ct + (int64_t)sv * st + 0x20000000) >> 30); - - *s = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30); -} - int main(void){ SoftFloat one= av_int2sf(1, 0); SoftFloat sf1, sf2, sf3; @@ -152,6 +97,19 @@ sf1 = av_int2sf(0xE0000001, 0); printf("test4 softfloat: %.10lf (0x%08x %d)\n", (double)av_sf2double(sf1), sf1.mant, sf1.exp); + for(i= 0; i<4*36; i++){ + int s, c; + double errs, errc; + + av_sincos_sf(i*(1ULL<<32)/36/4, &s, &c); + errs = (double)s/ (1<<30) - sin(i*M_PI/36); + errc = (double)c/ (1<<30) - cos(i*M_PI/36); + if (fabs(errs) > 0.00000002 || fabs(errc) >0.001) { + printf("sincos FAIL %d %f %f %f %f\n", i, (float)s/ (1<<30), (float)c/ (1<<30), sin(i*M_PI/36), cos(i*M_PI/36)); + } + + } return 0; } +#endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/softfloat.h ffmpeg-2.7.2~trusty~ppa1/libavutil/softfloat.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/softfloat.h 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/softfloat.h 2015-07-23 17:20:03.000000000 +0000 @@ -36,6 +36,20 @@ int32_t exp; }SoftFloat; +static const SoftFloat FLOAT_0 = { 0, 0}; +static const SoftFloat FLOAT_05 = { 0x20000000, 0}; +static const SoftFloat FLOAT_1 = { 0x20000000, 1}; +static const SoftFloat FLOAT_EPSILON = { 0x29F16B12, -16}; +static const SoftFloat FLOAT_1584893192 = { 0x32B771ED, 1}; +static const SoftFloat FLOAT_100000 = { 0x30D40000, 17}; +static const SoftFloat FLOAT_0999999 = { 0x3FFFFBCE, 0}; + +static inline av_const double av_sf2double(SoftFloat v) { + v.exp -= ONE_BITS +1; + if(v.exp > 0) return (double)v.mant * (double)(1 << v.exp); + else return (double)v.mant / (double)(1 << (-v.exp)); +} + static av_const SoftFloat av_normalize_sf(SoftFloat a){ if(a.mant){ #if 1 @@ -91,7 +105,7 @@ * b has to be normalized and not zero. * @return Will not be more denormalized than a. */ -static av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b){ +static inline av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b){ a.exp -= b.exp; a.mant = ((int64_t)a.mant<<(ONE_BITS+1)) / b.mant; return av_normalize1_sf(a); @@ -175,6 +189,53 @@ /** * Rounding-to-nearest used. */ -void av_sincos_sf(int a, int *s, int *c); +static av_unused void av_sincos_sf(int a, int *s, int *c) +{ + int idx, sign; + int sv, cv; + int st, ct; + + idx = a >> 26; + sign = (idx << 27) >> 31; + cv = av_costbl_1_sf[idx & 0xf]; + cv = (cv ^ sign) - sign; + + idx -= 8; + sign = (idx << 27) >> 31; + sv = av_costbl_1_sf[idx & 0xf]; + sv = (sv ^ sign) - sign; + + idx = a >> 21; + ct = av_costbl_2_sf[idx & 0x1f]; + st = av_sintbl_2_sf[idx & 0x1f]; + + idx = (int)(((int64_t)cv * ct - (int64_t)sv * st + 0x20000000) >> 30); + + sv = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30); + + cv = idx; + + idx = a >> 16; + ct = av_costbl_3_sf[idx & 0x1f]; + st = av_sintbl_3_sf[idx & 0x1f]; + + idx = (int)(((int64_t)cv * ct - (int64_t)sv * st + 0x20000000) >> 30); + + sv = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30); + cv = idx; + + idx = a >> 11; + + ct = (int)(((int64_t)av_costbl_4_sf[idx & 0x1f] * (0x800 - (a & 0x7ff)) + + (int64_t)av_costbl_4_sf[(idx & 0x1f)+1]*(a & 0x7ff) + + 0x400) >> 11); + st = (int)(((int64_t)av_sintbl_4_sf[idx & 0x1f] * (0x800 - (a & 0x7ff)) + + (int64_t)av_sintbl_4_sf[(idx & 0x1f) + 1] * (a & 0x7ff) + + 0x400) >> 11); + + *c = (int)(((int64_t)cv * ct + (int64_t)sv * st + 0x20000000) >> 30); + + *s = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30); +} #endif /* AVUTIL_SOFTFLOAT_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/tea.c ffmpeg-2.7.2~trusty~ppa1/libavutil/tea.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/tea.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/tea.c 2015-07-22 17:20:04.000000000 +0000 @@ -0,0 +1,213 @@ +/* + * A 32-bit implementation of the TEA algorithm + * Copyright (c) 2015 Vesselin Bontchev + * + * Loosely based on the implementation of David Wheeler and Roger Needham, + * https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm#Reference_code + * + * 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 "avutil.h" +#include "common.h" +#include "intreadwrite.h" +#include "tea.h" + +typedef struct AVTEA { + uint32_t key[16]; + int rounds; +} AVTEA; + +struct AVTEA *av_tea_alloc(void) +{ + return av_mallocz(sizeof(struct AVTEA)); +} + +const int av_tea_size = sizeof(AVTEA); + +void av_tea_init(AVTEA *ctx, const uint8_t key[16], int rounds) +{ + int i; + + for (i = 0; i < 4; i++) + ctx->key[i] = AV_RB32(key + (i << 2)); + + ctx->rounds = rounds; +} + +static void tea_crypt_ecb(AVTEA *ctx, uint8_t *dst, const uint8_t *src, + int decrypt, uint8_t *iv) +{ + uint32_t v0, v1; + int rounds = ctx->rounds; + uint32_t k0, k1, k2, k3; + k0 = ctx->key[0]; + k1 = ctx->key[1]; + k2 = ctx->key[2]; + k3 = ctx->key[3]; + + v0 = AV_RB32(src); + v1 = AV_RB32(src + 4); + + if (decrypt) { + int i; + uint32_t delta = 0x9E3779B9U, sum = delta * (rounds / 2); + + for (i = 0; i < rounds / 2; i++) { + v1 -= ((v0 << 4) + k2) ^ (v0 + sum) ^ ((v0 >> 5) + k3); + v0 -= ((v1 << 4) + k0) ^ (v1 + sum) ^ ((v1 >> 5) + k1); + sum -= delta; + } + if (iv) { + v0 ^= AV_RB32(iv); + v1 ^= AV_RB32(iv + 4); + memcpy(iv, src, 8); + } + } else { + int i; + uint32_t sum = 0, delta = 0x9E3779B9U; + + for (i = 0; i < rounds / 2; i++) { + sum += delta; + v0 += ((v1 << 4) + k0) ^ (v1 + sum) ^ ((v1 >> 5) + k1); + v1 += ((v0 << 4) + k2) ^ (v0 + sum) ^ ((v0 >> 5) + k3); + } + } + + AV_WB32(dst, v0); + AV_WB32(dst + 4, v1); +} + +void av_tea_crypt(AVTEA *ctx, uint8_t *dst, const uint8_t *src, int count, + uint8_t *iv, int decrypt) +{ + int i; + + if (decrypt) { + while (count--) { + tea_crypt_ecb(ctx, dst, src, decrypt, iv); + + src += 8; + dst += 8; + } + } else { + while (count--) { + if (iv) { + for (i = 0; i < 8; i++) + dst[i] = src[i] ^ iv[i]; + tea_crypt_ecb(ctx, dst, dst, decrypt, NULL); + memcpy(iv, dst, 8); + } else { + tea_crypt_ecb(ctx, dst, src, decrypt, NULL); + } + src += 8; + dst += 8; + } + } +} + +#ifdef TEST +#include + +#define TEA_NUM_TESTS 4 + +// https://github.com/logandrews/TeaCrypt/blob/master/tea/tea_test.go +static const uint8_t tea_test_key[TEA_NUM_TESTS][16] = { + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF + }, + { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF + } +}; + +static const uint8_t tea_test_pt[TEA_NUM_TESTS][8] = { + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }, + { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }, + { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF } +}; + +static const uint8_t tea_test_ct[TEA_NUM_TESTS][8] = { + { 0x41, 0xEA, 0x3A, 0x0A, 0x94, 0xBA, 0xA9, 0x40 }, + { 0x6A, 0x2F, 0x9C, 0xF3, 0xFC, 0xCF, 0x3C, 0x55 }, + { 0xDE, 0xB1, 0xC0, 0xA2, 0x7E, 0x74, 0x5D, 0xB3 }, + { 0x12, 0x6C, 0x6B, 0x92, 0xC0, 0x65, 0x3A, 0x3E } +}; + +static void test_tea(AVTEA *ctx, uint8_t *dst, const uint8_t *src, + const uint8_t *ref, int len, uint8_t *iv, int dir, + const char *test) +{ + av_tea_crypt(ctx, dst, src, len, iv, dir); + if (memcmp(dst, ref, 8*len)) { + int i; + printf("%s failed\ngot ", test); + for (i = 0; i < 8*len; i++) + printf("%02x ", dst[i]); + printf("\nexpected "); + for (i = 0; i < 8*len; i++) + printf("%02x ", ref[i]); + printf("\n"); + exit(1); + } +} + +int main(void) +{ + AVTEA *ctx; + uint8_t buf[8], iv[8]; + int i; + static const uint8_t src[32] = "HelloWorldHelloWorldHelloWorld"; + uint8_t ct[32]; + uint8_t pl[32]; + + ctx = av_tea_alloc(); + if (!ctx) + return 1; + + for (i = 0; i < TEA_NUM_TESTS; i++) { + av_tea_init(ctx, tea_test_key[i], 64); + + test_tea(ctx, buf, tea_test_pt[i], tea_test_ct[i], 1, NULL, 0, "encryption"); + test_tea(ctx, buf, tea_test_ct[i], tea_test_pt[i], 1, NULL, 1, "decryption"); + + /* encrypt */ + memcpy(iv, "HALLO123", 8); + av_tea_crypt(ctx, ct, src, 4, iv, 0); + + /* decrypt into pl */ + memcpy(iv, "HALLO123", 8); + test_tea(ctx, pl, ct, src, 4, iv, 1, "CBC decryption"); + + memcpy(iv, "HALLO123", 8); + test_tea(ctx, ct, ct, src, 4, iv, 1, "CBC inplace decryption"); + } + + printf("Test encryption/decryption success.\n"); + av_free(ctx); + + return 0; +} + +#endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/tea.h ffmpeg-2.7.2~trusty~ppa1/libavutil/tea.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/tea.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/tea.h 2015-07-22 17:20:04.000000000 +0000 @@ -0,0 +1,71 @@ +/* + * A 32-bit implementation of the TEA algorithm + * Copyright (c) 2015 Vesselin Bontchev + * + * 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 + */ + +#ifndef AVUTIL_TEA_H +#define AVUTIL_TEA_H + +#include + +/** + * @file + * @brief Public header for libavutil TEA algorithm + * @defgroup lavu_tea TEA + * @ingroup lavu_crypto + * @{ + */ + +extern const int av_tea_size; + +struct AVTEA; + +/** + * Allocate an AVTEA context + * To free the struct: av_free(ptr) + */ +struct AVTEA *av_tea_alloc(void); + +/** + * Initialize an AVTEA context. + * + * @param ctx an AVTEA context + * @param key a key of 16 bytes used for encryption/decryption + * @param rounds the number of rounds in TEA (64 is the "standard") + */ +void av_tea_init(struct AVTEA *ctx, const uint8_t key[16], int rounds); + +/** + * Encrypt or decrypt a buffer using a previously initialized context. + * + * @param ctx an AVTEA context + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param count number of 8 byte blocks + * @param iv initialization vector for CBC mode, if NULL then ECB will be used + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_tea_crypt(struct AVTEA *ctx, uint8_t *dst, const uint8_t *src, + int count, uint8_t *iv, int decrypt); + +/** + * @} + */ + +#endif /* AVUTIL_TEA_H */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/utils.c ffmpeg-2.7.2~trusty~ppa1/libavutil/utils.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/utils.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/utils.c 2015-07-03 17:20:03.000000000 +0000 @@ -30,6 +30,11 @@ #include "libavutil/ffversion.h" const char av_util_ffversion[] = "FFmpeg version " FFMPEG_VERSION; +const char *av_version_info(void) +{ + return FFMPEG_VERSION; +} + unsigned avutil_version(void) { static int checks_done; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/version.h ffmpeg-2.7.2~trusty~ppa1/libavutil/version.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/version.h 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/version.h 2015-08-02 17:20:02.000000000 +0000 @@ -56,7 +56,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 54 -#define LIBAVUTIL_VERSION_MINOR 27 +#define LIBAVUTIL_VERSION_MINOR 30 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ @@ -122,6 +122,12 @@ #ifndef FF_API_DLOG #define FF_API_DLOG (LIBAVUTIL_VERSION_MAJOR < 55) #endif +#ifndef FF_API_HMAC +#define FF_API_HMAC (LIBAVUTIL_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_CRYPTO_CONTEXT +#define FF_API_CRYPTO_CONTEXT (LIBAVUTIL_VERSION_MAJOR < 56) +#endif #ifndef FF_CONST_AVUTIL55 #if LIBAVUTIL_VERSION_MAJOR >= 55 diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/x86/bswap.h ffmpeg-2.7.2~trusty~ppa1/libavutil/x86/bswap.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/x86/bswap.h 2015-03-13 17:34:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/x86/bswap.h 2015-07-19 17:20:03.000000000 +0000 @@ -39,7 +39,7 @@ } #endif /* !AV_GCC_VERSION_AT_LEAST(4,1) */ -#if !AV_GCC_VERSION_AT_LEAST(4,5) +#if !AV_GCC_VERSION_AT_LEAST(4,5) || defined(__INTEL_COMPILER) #define av_bswap32 av_bswap32 static av_always_inline av_const uint32_t av_bswap32(uint32_t x) { diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/x86/float_dsp.asm ffmpeg-2.7.2~trusty~ppa1/libavutil/x86/float_dsp.asm --- ffmpeg-2.7.1~trusty~ppa1/libavutil/x86/float_dsp.asm 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/x86/float_dsp.asm 2015-07-26 17:20:03.000000000 +0000 @@ -203,7 +203,7 @@ add dstq, lenq add winq, lenq neg lenq -.loop +.loop: mova m0, [winq + lenq] mova m4, [src0q + lenq] %if cpuflag(sse) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/x86/intmath.h ffmpeg-2.7.2~trusty~ppa1/libavutil/x86/intmath.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/x86/intmath.h 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/x86/intmath.h 2015-06-28 17:20:02.000000000 +0000 @@ -39,6 +39,12 @@ #if defined(__BMI2__) +#if AV_GCC_VERSION_AT_LEAST(5,1) +#define av_mod_uintp2 __builtin_ia32_bzhi_si +#elif HAVE_INLINE_ASM +/* GCC releases before 5.1.0 have a broken bzhi builtin, so for those we + * implement it using inline assembly + */ #define av_mod_uintp2 av_mod_uintp2_bmi2 static av_always_inline av_const unsigned av_mod_uintp2_bmi2(unsigned a, unsigned p) { @@ -50,6 +56,7 @@ return x; } } +#endif /* AV_GCC_VERSION_AT_LEAST */ #endif /* __BMI2__ */ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/x86/timer.h ffmpeg-2.7.2~trusty~ppa1/libavutil/x86/timer.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/x86/timer.h 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/x86/timer.h 2015-07-09 17:20:03.000000000 +0000 @@ -31,7 +31,12 @@ static inline uint64_t read_time(void) { uint32_t a, d; - __asm__ volatile("rdtsc" : "=a" (a), "=d" (d)); + __asm__ volatile( +#if ARCH_X86_64 || defined(__SSE2__) + "lfence \n\t" +#endif + "rdtsc \n\t" + : "=a" (a), "=d" (d)); return ((uint64_t)d << 32) + a; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/x86/x86inc.asm ffmpeg-2.7.2~trusty~ppa1/libavutil/x86/x86inc.asm --- ffmpeg-2.7.1~trusty~ppa1/libavutil/x86/x86inc.asm 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/x86/x86inc.asm 2015-08-04 17:20:03.000000000 +0000 @@ -1,7 +1,7 @@ ;***************************************************************************** ;* x86inc.asm: x264asm abstraction layer ;***************************************************************************** -;* Copyright (C) 2005-2013 x264 project +;* Copyright (C) 2005-2015 x264 project ;* ;* Authors: Loren Merritt ;* Anton Mitrofanov @@ -56,6 +56,15 @@ %endif %endif +%define FORMAT_ELF 0 +%ifidn __OUTPUT_FORMAT__,elf + %define FORMAT_ELF 1 +%elifidn __OUTPUT_FORMAT__,elf32 + %define FORMAT_ELF 1 +%elifidn __OUTPUT_FORMAT__,elf64 + %define FORMAT_ELF 1 +%endif + %ifdef PREFIX %define mangle(x) _ %+ x %else @@ -678,7 +687,7 @@ CAT_XDEFINE cglobaled_, %2, 1 %endif %xdefine current_function %2 - %ifidn __OUTPUT_FORMAT__,elf + %if FORMAT_ELF global %2:function %%VISIBILITY %else global %2 @@ -704,14 +713,16 @@ ; like cextern, but without the prefix %macro cextern_naked 1 - %xdefine %1 mangle(%1) + %ifdef PREFIX + %xdefine %1 mangle(%1) + %endif CAT_XDEFINE cglobaled_, %1, 1 extern %1 %endmacro %macro const 1-2+ %xdefine %1 mangle(private_prefix %+ _ %+ %1) - %ifidn __OUTPUT_FORMAT__,elf + %if FORMAT_ELF global %1:data hidden %else global %1 @@ -719,10 +730,9 @@ %1: %2 %endmacro -; This is needed for ELF, otherwise the GNU linker assumes the stack is -; executable by default. -%ifidn __OUTPUT_FORMAT__,elf -[section .note.GNU-stack noalloc noexec nowrite progbits] +; This is needed for ELF, otherwise the GNU linker assumes the stack is executable by default. +%if FORMAT_ELF + [SECTION .note.GNU-stack noalloc noexec nowrite progbits] %endif ; Overrides the default .text section. @@ -745,8 +755,8 @@ %assign cpuflags_avx (1<<11)| cpuflags_sse42 %assign cpuflags_xop (1<<12)| cpuflags_avx %assign cpuflags_fma4 (1<<13)| cpuflags_avx -%assign cpuflags_avx2 (1<<14)| cpuflags_avx -%assign cpuflags_fma3 (1<<15)| cpuflags_avx +%assign cpuflags_fma3 (1<<14)| cpuflags_avx +%assign cpuflags_avx2 (1<<15)| cpuflags_fma3 %assign cpuflags_cache32 (1<<16) %assign cpuflags_cache64 (1<<17) @@ -795,7 +805,7 @@ %endif %endif - %if cpuflag(sse2) + %if ARCH_X86_64 || cpuflag(sse2) CPUNOP amdnop %else CPUNOP basicnop @@ -1417,6 +1427,22 @@ %undef i %undef j +%macro FMA_INSTR 3 + %macro %1 4-7 %1, %2, %3 + %if cpuflag(xop) + v%5 %1, %2, %3, %4 + %else + %6 %1, %2, %3 + %7 %1, %4 + %endif + %endmacro +%endmacro + +FMA_INSTR pmacsww, pmullw, paddw +FMA_INSTR pmacsdd, pmulld, paddd ; sse4 emulation +FMA_INSTR pmacsdql, pmuldq, paddq ; sse4 emulation +FMA_INSTR pmadcswd, pmaddwd, paddd + ; tzcnt is equivalent to "rep bsf" and is backwards-compatible with bsf. ; This lets us use tzcnt without bumping the yasm version requirement yet. %define tzcnt rep bsf @@ -1463,13 +1489,15 @@ FMA4_INSTR fnmsubsd, fnmsub132sd, fnmsub213sd, fnmsub231sd FMA4_INSTR fnmsubss, fnmsub132ss, fnmsub213ss, fnmsub231ss -; workaround: vpbroadcastq is broken in x86_32 due to a yasm bug -%if ARCH_X86_64 == 0 -%macro vpbroadcastq 2 -%if sizeof%1 == 16 - movddup %1, %2 -%else - vbroadcastsd %1, %2 -%endif -%endmacro +; workaround: vpbroadcastq is broken in x86_32 due to a yasm bug (fixed in 1.3.0) +%ifdef __YASM_VER__ + %if __YASM_VERSION_ID__ < 0x01030000 && ARCH_X86_64 == 0 + %macro vpbroadcastq 2 + %if sizeof%1 == 16 + movddup %1, %2 + %else + vbroadcastsd %1, %2 + %endif + %endmacro + %endif %endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/x86/x86util.asm ffmpeg-2.7.2~trusty~ppa1/libavutil/x86/x86util.asm --- ffmpeg-2.7.1~trusty~ppa1/libavutil/x86/x86util.asm 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/x86/x86util.asm 2015-08-04 17:20:03.000000000 +0000 @@ -765,25 +765,6 @@ %endif %endmacro -%macro PMA_EMU 4 - %macro %1 5-8 %2, %3, %4 - %if cpuflag(xop) - v%6 %1, %2, %3, %4 - %elifidn %1, %4 - %7 %5, %2, %3 - %8 %1, %4, %5 - %else - %7 %1, %2, %3 - %8 %1, %4 - %endif - %endmacro -%endmacro - -PMA_EMU PMACSWW, pmacsww, pmullw, paddw -PMA_EMU PMACSDD, pmacsdd, pmulld, paddd ; sse4 emulation -PMA_EMU PMACSDQL, pmacsdql, pmuldq, paddq ; sse4 emulation -PMA_EMU PMADCSWD, pmadcswd, pmaddwd, paddd - ; Wrapper for non-FMA version of fmaddps %macro FMULADD_PS 5 %if cpuflag(fma3) || cpuflag(fma4) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/xtea.c ffmpeg-2.7.2~trusty~ppa1/libavutil/xtea.c --- ffmpeg-2.7.1~trusty~ppa1/libavutil/xtea.c 2015-06-18 18:55:04.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/xtea.c 2015-08-02 17:20:02.000000000 +0000 @@ -31,8 +31,20 @@ #include "avutil.h" #include "common.h" #include "intreadwrite.h" +#include "mem.h" #include "xtea.h" +#if !FF_API_CRYPTO_CONTEXT +struct AVXTEA { + uint32_t key[16]; +}; +#endif + +AVXTEA *av_xtea_alloc(void) +{ + return av_mallocz(sizeof(struct AVXTEA)); +} + void av_xtea_init(AVXTEA *ctx, const uint8_t key[16]) { int i; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libavutil/xtea.h ffmpeg-2.7.2~trusty~ppa1/libavutil/xtea.h --- ffmpeg-2.7.1~trusty~ppa1/libavutil/xtea.h 2015-06-18 18:55:04.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libavutil/xtea.h 2015-08-02 17:20:02.000000000 +0000 @@ -23,6 +23,7 @@ #define AVUTIL_XTEA_H #include +#include "version.h" /** * @file @@ -32,9 +33,18 @@ * @{ */ +#if FF_API_CRYPTO_CONTEXT typedef struct AVXTEA { uint32_t key[16]; } AVXTEA; +#else +typedef struct AVXTEA AVXTEA; +#endif + +/** + * Allocate an AVXTEA context. + */ +AVXTEA *av_xtea_alloc(void); /** * Initialize an AVXTEA context. diff -Nru ffmpeg-2.7.1~trusty~ppa1/libpostproc/postprocess_template.c ffmpeg-2.7.2~trusty~ppa1/libpostproc/postprocess_template.c --- ffmpeg-2.7.1~trusty~ppa1/libpostproc/postprocess_template.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libpostproc/postprocess_template.c 2015-06-13 17:20:02.000000000 +0000 @@ -1383,7 +1383,7 @@ #ifdef DEBUG_DERING_THRESHOLD __asm__ volatile("emms\n\t":); { - static long long numPixels=0; + static uint64_t numPixels=0; if(x!=1 && x!=8 && y!=1 && y!=8) numPixels++; // if((max-min)<20 || (max-min)*QP<200) // if((max-min)*QP < 500) diff -Nru ffmpeg-2.7.1~trusty~ppa1/library.mak ffmpeg-2.7.2~trusty~ppa1/library.mak --- ffmpeg-2.7.1~trusty~ppa1/library.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/library.mak 2015-07-08 17:20:04.000000000 +0000 @@ -34,6 +34,7 @@ LIBOBJS := $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS) $(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H $(TESTOBJS) $(TESTOBJS:.o=.i): CPPFLAGS += -DTEST +$(TESTOBJS) $(TESTOBJS:.o=.i): CFLAGS += -Umain $(SUBDIR)$(LIBNAME): $(OBJS) $(RM) $@ @@ -57,7 +58,7 @@ $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SLIBOBJS) $(SUBDIR)lib$(NAME).ver $(SLIB_CREATE_DEF_CMD) - $$(LD) $(SHFLAGS) $(LDFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS) + $$(LD) $(SHFLAGS) $(LDFLAGS) $(LDLIBFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS) $(SLIB_EXTRA_CMD) ifdef SUBDIR diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswresample/options.c ffmpeg-2.7.2~trusty~ppa1/libswresample/options.c --- ffmpeg-2.7.1~trusty~ppa1/libswresample/options.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswresample/options.c 2015-06-22 17:20:02.000000000 +0000 @@ -49,8 +49,8 @@ {"in_sample_fmt" , "set input sample format" , OFFSET( in_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM}, {"osf" , "set output sample format" , OFFSET(out_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM}, {"out_sample_fmt" , "set output sample format" , OFFSET(out_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM}, -{"tsf" , "set internal sample format" , OFFSET(int_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM}, -{"internal_sample_fmt" , "set internal sample format" , OFFSET(int_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM}, +{"tsf" , "set internal sample format" , OFFSET(user_int_sample_fmt), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM}, +{"internal_sample_fmt" , "set internal sample format" , OFFSET(user_int_sample_fmt), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM}, {"icl" , "set input channel layout" , OFFSET(user_in_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"}, {"in_channel_layout" , "set input channel layout" , OFFSET(user_in_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"}, {"ocl" , "set output channel layout" , OFFSET(user_out_ch_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"}, diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswresample/soxr_resample.c ffmpeg-2.7.2~trusty~ppa1/libswresample/soxr_resample.c --- ffmpeg-2.7.1~trusty~ppa1/libswresample/soxr_resample.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswresample/soxr_resample.c 2015-06-22 17:20:02.000000000 +0000 @@ -67,7 +67,17 @@ } static int flush(struct SwrContext *s){ + s->delayed_samples_fixup = soxr_delay((soxr_t)s->resample); + soxr_process((soxr_t)s->resample, NULL, 0, NULL, NULL, 0, NULL); + + { + float f; + size_t idone, odone; + soxr_process((soxr_t)s->resample, &f, 0, &idone, &f, 0, &odone); + s->delayed_samples_fixup -= soxr_delay((soxr_t)s->resample); + } + return 0; } @@ -87,18 +97,34 @@ } static int64_t get_delay(struct SwrContext *s, int64_t base){ - double delay_s = soxr_delay((soxr_t)s->resample) / s->out_sample_rate; + double delayed_samples = soxr_delay((soxr_t)s->resample); + double delay_s; + + if (s->flushed) + delayed_samples += s->delayed_samples_fixup; + + delay_s = delayed_samples / s->out_sample_rate; + return (int64_t)(delay_s * base + .5); } static int invert_initial_buffer(struct ResampleContext *c, AudioData *dst, const AudioData *src, - int in_count, int *out_idx, int *out_sz) -{ + int in_count, int *out_idx, int *out_sz){ return 0; } +static int64_t get_out_samples(struct SwrContext *s, int in_samples){ + double out_samples = (double)s->out_sample_rate / s->in_sample_rate * in_samples; + double delayed_samples = soxr_delay((soxr_t)s->resample); + + if (s->flushed) + delayed_samples += s->delayed_samples_fixup; + + return (int64_t)(out_samples + delayed_samples + 1 + .5); +} + struct Resampler const swri_soxr_resampler={ create, destroy, process, flush, NULL /* set_compensation */, get_delay, - invert_initial_buffer, + invert_initial_buffer, get_out_samples }; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswresample/swresample.c ffmpeg-2.7.2~trusty~ppa1/libswresample/swresample.c --- ffmpeg-2.7.1~trusty~ppa1/libswresample/swresample.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswresample/swresample.c 2015-06-22 17:20:02.000000000 +0000 @@ -133,6 +133,7 @@ swri_audio_convert_free(&s->full_convert); swri_rematrix_free(s); + s->delayed_samples_fixup = 0; s->flushed = 0; } @@ -173,6 +174,8 @@ s-> in_ch_layout = s-> user_in_ch_layout; s->out_ch_layout = s->user_out_ch_layout; + s->int_sample_fmt= s->user_int_sample_fmt; + if(av_get_channel_layout_nb_channels(s-> in_ch_layout) > SWR_CH_MAX) { av_log(s, AV_LOG_WARNING, "Input channel layout 0x%"PRIx64" is invalid or unsupported.\n", s-> in_ch_layout); s->in_ch_layout = 0; @@ -210,7 +213,13 @@ s->rematrix_custom; if(s->int_sample_fmt == AV_SAMPLE_FMT_NONE){ - if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_S16P){ + if( av_get_planar_sample_fmt(s-> in_sample_fmt) <= AV_SAMPLE_FMT_S16P + && av_get_planar_sample_fmt(s->out_sample_fmt) <= AV_SAMPLE_FMT_S16P){ + s->int_sample_fmt= AV_SAMPLE_FMT_S16P; + }else if( av_get_planar_sample_fmt(s-> in_sample_fmt) <= AV_SAMPLE_FMT_S16P + && !s->rematrix + && s->out_sample_rate==s->in_sample_rate + && !(s->flags & SWR_FLAG_RESAMPLE)){ s->int_sample_fmt= AV_SAMPLE_FMT_S16P; }else if( av_get_planar_sample_fmt(s-> in_sample_fmt) == AV_SAMPLE_FMT_S32P && av_get_planar_sample_fmt(s->out_sample_fmt) == AV_SAMPLE_FMT_S32P @@ -220,10 +229,10 @@ }else if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_FLTP){ s->int_sample_fmt= AV_SAMPLE_FMT_FLTP; }else{ - av_log(s, AV_LOG_DEBUG, "Using double precision mode\n"); s->int_sample_fmt= AV_SAMPLE_FMT_DBLP; } } + av_log(s, AV_LOG_DEBUG, "Using %s internally between filters\n", av_get_sample_fmt_name(s->int_sample_fmt)); if( s->int_sample_fmt != AV_SAMPLE_FMT_S16P &&s->int_sample_fmt != AV_SAMPLE_FMT_S32P diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswresample/swresample_internal.h ffmpeg-2.7.2~trusty~ppa1/libswresample/swresample_internal.h --- ffmpeg-2.7.1~trusty~ppa1/libswresample/swresample_internal.h 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswresample/swresample_internal.h 2015-07-17 17:20:02.000000000 +0000 @@ -25,7 +25,7 @@ #include "libavutil/channel_layout.h" #include "config.h" -#define SWR_CH_MAX 32 +#define SWR_CH_MAX 64 #define SQRT3_2 1.22474487139158904909 /* sqrt(3/2) */ @@ -119,6 +119,7 @@ int user_used_ch_count; ///< User set used channel count int64_t user_in_ch_layout; ///< User set input channel layout int64_t user_out_ch_layout; ///< User set output channel layout + enum AVSampleFormat user_int_sample_fmt; ///< User set internal sample format struct DitherContext dither; @@ -157,6 +158,7 @@ int64_t outpts; ///< output PTS int64_t firstpts; ///< first PTS int drop_output; ///< number of output samples to drop + double delayed_samples_fixup; ///< soxr 0.1.1: needed to fixup delayed_samples after flush has been called. struct AudioConvert *in_convert; ///< input conversion context struct AudioConvert *out_convert; ///< output conversion context diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswresample/version.h ffmpeg-2.7.2~trusty~ppa1/libswresample/version.h --- ffmpeg-2.7.1~trusty~ppa1/libswresample/version.h 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswresample/version.h 2015-07-17 17:20:02.000000000 +0000 @@ -30,7 +30,7 @@ #define LIBSWRESAMPLE_VERSION_MAJOR 1 #define LIBSWRESAMPLE_VERSION_MINOR 2 -#define LIBSWRESAMPLE_VERSION_MICRO 100 +#define LIBSWRESAMPLE_VERSION_MICRO 101 #define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \ LIBSWRESAMPLE_VERSION_MINOR, \ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswresample/x86/audio_convert.asm ffmpeg-2.7.2~trusty~ppa1/libswresample/x86/audio_convert.asm --- ffmpeg-2.7.1~trusty~ppa1/libswresample/x86/audio_convert.asm 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswresample/x86/audio_convert.asm 2015-07-26 17:20:03.000000000 +0000 @@ -44,7 +44,7 @@ test src2q, mmsize-1 jne pack_2ch_%2_to_%1_u_int %+ SUFFIX %else -pack_2ch_%2_to_%1_u_int %+ SUFFIX +pack_2ch_%2_to_%1_u_int %+ SUFFIX: %endif lea srcq , [srcq + (1<<%5)*lenq] lea src2q, [src2q + (1<<%5)*lenq] @@ -101,7 +101,7 @@ test dst2q, mmsize-1 jne unpack_2ch_%2_to_%1_u_int %+ SUFFIX %else -unpack_2ch_%2_to_%1_u_int %+ SUFFIX +unpack_2ch_%2_to_%1_u_int %+ SUFFIX: %endif lea srcq , [srcq + (2<<%5)*lenq] lea dstq , [dstq + (1<<%4)*lenq] @@ -170,7 +170,7 @@ test srcq, mmsize-1 jne %2_to_%1_u_int %+ SUFFIX %else -%2_to_%1_u_int %+ SUFFIX +%2_to_%1_u_int %+ SUFFIX: %endif lea srcq , [srcq + (1<<%5)*lenq] lea dstq , [dstq + (1<<%4)*lenq] @@ -232,7 +232,7 @@ test src5q, mmsize-1 jne pack_6ch_%2_to_%1_u_int %+ SUFFIX %else -pack_6ch_%2_to_%1_u_int %+ SUFFIX +pack_6ch_%2_to_%1_u_int %+ SUFFIX: %endif sub src1q, srcq sub src2q, srcq @@ -335,7 +335,7 @@ test dst5q, mmsize-1 jne unpack_6ch_%2_to_%1_u_int %+ SUFFIX %else -unpack_6ch_%2_to_%1_u_int %+ SUFFIX +unpack_6ch_%2_to_%1_u_int %+ SUFFIX: %endif sub dst1q, dstq sub dst2q, dstq @@ -443,7 +443,7 @@ %endif jne pack_8ch_%2_to_%1_u_int %+ SUFFIX %else -pack_8ch_%2_to_%1_u_int %+ SUFFIX +pack_8ch_%2_to_%1_u_int %+ SUFFIX: %endif sub src1q, srcq sub src2q, srcq diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswresample/x86/rematrix.asm ffmpeg-2.7.2~trusty~ppa1/libswresample/x86/rematrix.asm --- ffmpeg-2.7.1~trusty~ppa1/libswresample/x86/rematrix.asm 2015-06-18 18:55:04.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswresample/x86/rematrix.asm 2015-07-26 17:20:03.000000000 +0000 @@ -37,7 +37,7 @@ test outq, mmsize-1 jne mix_2_1_float_u_int %+ SUFFIX %else -mix_2_1_float_u_int %+ SUFFIX +mix_2_1_float_u_int %+ SUFFIX: %endif VBROADCASTSS m4, [coeffpq + 4*index1q] VBROADCASTSS m5, [coeffpq + 4*index2q] @@ -79,7 +79,7 @@ test outq, mmsize-1 jne mix_1_1_float_u_int %+ SUFFIX %else -mix_1_1_float_u_int %+ SUFFIX +mix_1_1_float_u_int %+ SUFFIX: %endif VBROADCASTSS m2, [coeffpq + 4*indexq] shl lenq , 2 @@ -111,7 +111,7 @@ test outq, mmsize-1 jne mix_1_1_int16_u_int %+ SUFFIX %else -mix_1_1_int16_u_int %+ SUFFIX +mix_1_1_int16_u_int %+ SUFFIX: %endif movd m4, [coeffpq + 4*indexq] SPLATW m5, m4 @@ -166,7 +166,7 @@ test outq, mmsize-1 jne mix_2_1_int16_u_int %+ SUFFIX %else -mix_2_1_int16_u_int %+ SUFFIX +mix_2_1_int16_u_int %+ SUFFIX: %endif movd m4, [coeffpq + 4*index1q] movd m6, [coeffpq + 4*index2q] diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswresample/x86/resample.asm ffmpeg-2.7.2~trusty~ppa1/libswresample/x86/resample.asm --- ffmpeg-2.7.1~trusty~ppa1/libswresample/x86/resample.asm 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswresample/x86/resample.asm 2015-08-04 17:20:03.000000000 +0000 @@ -176,7 +176,12 @@ .inner_loop: movu m1, [srcq+min_filter_count_x4q*1] %ifidn %1, int16 - PMADCSWD m0, m1, [filterq+min_filter_count_x4q*1], m0, m1 +%if cpuflag(xop) + vpmadcswd m0, m1, [filterq+min_filter_count_x4q*1], m0 +%else + pmaddwd m1, [filterq+min_filter_count_x4q*1] + paddd m0, m1 +%endif %else ; float/double %if cpuflag(fma4) || cpuflag(fma3) fmaddp%4 m0, m1, [filterq+min_filter_count_x4q*1], m0 diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswscale/input.c ffmpeg-2.7.2~trusty~ppa1/libswscale/input.c --- ffmpeg-2.7.1~trusty~ppa1/libswscale/input.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswscale/input.c 2015-07-24 17:20:02.000000000 +0000 @@ -607,6 +607,33 @@ AV_WN16(dst + i * 2, AV_RB16(src + i * 4 + 2)); } +static void read_ayuv64le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, + uint32_t *unused2) +{ + int i; + for (i = 0; i < width; i++) + AV_WN16(dst + i * 2, AV_RL16(src + i * 8 + 2)); +} + + +static void read_ayuv64le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, + const uint8_t *unused1, int width, uint32_t *unused2) +{ + int i; + for (i = 0; i < width; i++) { + AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 4)); + AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6)); + } +} + +static void read_ayuv64le_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, + uint32_t *unused2) +{ + int i; + for (i = 0; i < width; i++) + AV_WN16(dst + i * 2, AV_RL16(src + i * 8)); +} + /* This is almost identical to the previous, end exists only because * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */ static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, @@ -987,6 +1014,9 @@ c->chrToYV12 = bswap16UV_c; break; #endif + case AV_PIX_FMT_AYUV64LE: + c->chrToYV12 = read_ayuv64le_UV_c; + break; } if (c->chrSrcHSubSample) { switch (srcFormat) { @@ -1271,6 +1301,9 @@ case AV_PIX_FMT_YA16BE: c->lumToYV12 = read_ya16be_gray_c; break; + case AV_PIX_FMT_AYUV64LE: + c->lumToYV12 = read_ayuv64le_Y_c; + break; case AV_PIX_FMT_YUYV422: case AV_PIX_FMT_YVYU422: case AV_PIX_FMT_YA8: @@ -1397,6 +1430,9 @@ case AV_PIX_FMT_YA16BE: c->alpToYV12 = read_ya16be_alpha_c; break; + case AV_PIX_FMT_AYUV64LE: + c->alpToYV12 = read_ayuv64le_A_c; + break; case AV_PIX_FMT_PAL8 : c->alpToYV12 = palToA_c; break; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswscale/output.c ffmpeg-2.7.2~trusty~ppa1/libswscale/output.c --- ffmpeg-2.7.1~trusty~ppa1/libswscale/output.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswscale/output.c 2015-07-25 17:20:02.000000000 +0000 @@ -684,7 +684,7 @@ const int16_t *chrFilter, const int32_t **chrUSrc, const int32_t **chrVSrc, int chrFilterSize, const int32_t **alpSrc, uint16_t *dest, int dstW, - int y, enum AVPixelFormat target, int hasAlpha) + int y, enum AVPixelFormat target, int hasAlpha, int eightbytes) { int i; int A1 = 0xffff<<14, A2 = 0xffff<<14; @@ -744,12 +744,19 @@ output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); - output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14); - output_pixel(&dest[4], av_clip_uintp2(R_B + Y2, 30) >> 14); - output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14); - output_pixel(&dest[6], av_clip_uintp2(B_R + Y2, 30) >> 14); - output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14); - dest += 8; + if (eightbytes) { + output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[6], av_clip_uintp2(B_R + Y2, 30) >> 14); + output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14); + dest += 8; + } else { + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); + dest += 6; + } } } @@ -758,7 +765,7 @@ const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf[2], uint16_t *dest, int dstW, int yalpha, int uvalpha, int y, - enum AVPixelFormat target, int hasAlpha) + enum AVPixelFormat target, int hasAlpha, int eightbytes) { const int32_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], @@ -799,12 +806,19 @@ output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); - output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14); - output_pixel(&dest[4], av_clip_uintp2(R_B + Y2, 30) >> 14); - output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14); - output_pixel(&dest[6], av_clip_uintp2(B_R + Y2, 30) >> 14); - output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14); - dest += 8; + if (eightbytes) { + output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[6], av_clip_uintp2(B_R + Y2, 30) >> 14); + output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14); + dest += 8; + } else { + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); + dest += 6; + } } } @@ -812,7 +826,7 @@ yuv2rgba64_1_c_template(SwsContext *c, const int32_t *buf0, const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf0, uint16_t *dest, int dstW, - int uvalpha, int y, enum AVPixelFormat target, int hasAlpha) + int uvalpha, int y, enum AVPixelFormat target, int hasAlpha, int eightbytes) { const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0]; int i; @@ -848,12 +862,19 @@ output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); - output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14); - output_pixel(&dest[4], av_clip_uintp2(R_B + Y2, 30) >> 14); - output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14); - output_pixel(&dest[6], av_clip_uintp2(B_R + Y2, 30) >> 14); - output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14); - dest += 8; + if (eightbytes) { + output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[6], av_clip_uintp2(B_R + Y2, 30) >> 14); + output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14); + dest += 8; + } else { + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); + dest += 6; + } } } else { const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1]; @@ -887,58 +908,68 @@ output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); - output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14); - output_pixel(&dest[4], av_clip_uintp2(R_B + Y2, 30) >> 14); - output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14); - output_pixel(&dest[6], av_clip_uintp2(B_R + Y2, 30) >> 14); - output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14); - dest += 8; + if (eightbytes) { + output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[6], av_clip_uintp2(B_R + Y2, 30) >> 14); + output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14); + dest += 8; + } else { + output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); + output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); + output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); + dest += 6; + } } } } static av_always_inline void -yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter, +yuv2rgba64_full_X_c_template(SwsContext *c, const int16_t *lumFilter, const int32_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int32_t **chrUSrc, const int32_t **chrVSrc, int chrFilterSize, const int32_t **alpSrc, uint16_t *dest, int dstW, - int y, enum AVPixelFormat target, int hasAlpha) + int y, enum AVPixelFormat target, int hasAlpha, int eightbytes) { int i; + int A = 0xffff<<14; - for (i = 0; i < ((dstW + 1) >> 1); i++) { + for (i = 0; i < dstW; i++) { int j; - int Y1 = -0x40000000; - int Y2 = -0x40000000; + int Y = -0x40000000; int U = -128 << 23; // 19 int V = -128 << 23; int R, G, B; for (j = 0; j < lumFilterSize; j++) { - Y1 += lumSrc[j][i * 2] * (unsigned)lumFilter[j]; - Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j]; + Y += lumSrc[j][i] * (unsigned)lumFilter[j]; } for (j = 0; j < chrFilterSize; j++) {; U += chrUSrc[j][i] * (unsigned)chrFilter[j]; V += chrVSrc[j][i] * (unsigned)chrFilter[j]; } + if (hasAlpha) { + A = -0x40000000; + for (j = 0; j < lumFilterSize; j++) { + A += alpSrc[j][i] * (unsigned)lumFilter[j]; + } + A >>= 1; + A += 0x20002000; + } + // 8bit: 12+15=27; 16-bit: 12+19=31 - Y1 >>= 14; // 10 - Y1 += 0x10000; - Y2 >>= 14; - Y2 += 0x10000; + Y >>= 14; // 10 + Y += 0x10000; U >>= 14; V >>= 14; // 8bit: 27 -> 17bit, 16bit: 31 - 14 = 17bit - Y1 -= c->yuv2rgb_y_offset; - Y2 -= c->yuv2rgb_y_offset; - Y1 *= c->yuv2rgb_y_coeff; - Y2 *= c->yuv2rgb_y_coeff; - Y1 += 1 << 13; // 21 - Y2 += 1 << 13; + Y -= c->yuv2rgb_y_offset; + Y *= c->yuv2rgb_y_coeff; + Y += 1 << 13; // 21 // 8bit: 17 + 13bit = 30bit, 16bit: 17 + 13bit = 30bit R = V * c->yuv2rgb_v2r_coeff; @@ -946,121 +977,140 @@ B = U * c->yuv2rgb_u2b_coeff; // 8bit: 30 - 22 = 8bit, 16bit: 30bit - 14 = 16bit - output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); - output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); - output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); - output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); - output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); - output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); - dest += 6; + output_pixel(&dest[0], av_clip_uintp2(R_B + Y, 30) >> 14); + output_pixel(&dest[1], av_clip_uintp2( G + Y, 30) >> 14); + output_pixel(&dest[2], av_clip_uintp2(B_R + Y, 30) >> 14); + if (eightbytes) { + output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14); + dest += 4; + } else { + dest += 3; + } } } static av_always_inline void -yuv2rgb48_2_c_template(SwsContext *c, const int32_t *buf[2], +yuv2rgba64_full_2_c_template(SwsContext *c, const int32_t *buf[2], const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf[2], uint16_t *dest, int dstW, int yalpha, int uvalpha, int y, - enum AVPixelFormat target, int hasAlpha) + enum AVPixelFormat target, int hasAlpha, int eightbytes) { const int32_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], - *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; + *vbuf0 = vbuf[0], *vbuf1 = vbuf[1], + *abuf0 = hasAlpha ? abuf[0] : NULL, + *abuf1 = hasAlpha ? abuf[1] : NULL; int yalpha1 = 4096 - yalpha; int uvalpha1 = 4096 - uvalpha; int i; + int A = 0xffff<<14; - for (i = 0; i < ((dstW + 1) >> 1); i++) { - int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14; - int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14; - int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14; - int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (-128 << 23)) >> 14; + for (i = 0; i < dstW; i++) { + int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 14; + int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14; + int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (-128 << 23)) >> 14; int R, G, B; - Y1 -= c->yuv2rgb_y_offset; - Y2 -= c->yuv2rgb_y_offset; - Y1 *= c->yuv2rgb_y_coeff; - Y2 *= c->yuv2rgb_y_coeff; - Y1 += 1 << 13; - Y2 += 1 << 13; + Y -= c->yuv2rgb_y_offset; + Y *= c->yuv2rgb_y_coeff; + Y += 1 << 13; R = V * c->yuv2rgb_v2r_coeff; G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; B = U * c->yuv2rgb_u2b_coeff; - output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); - output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); - output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); - output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); - output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); - output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); - dest += 6; + if (hasAlpha) { + A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 1; + + A += 1 << 13; + } + + output_pixel(&dest[0], av_clip_uintp2(R_B + Y, 30) >> 14); + output_pixel(&dest[1], av_clip_uintp2( G + Y, 30) >> 14); + output_pixel(&dest[2], av_clip_uintp2(B_R + Y, 30) >> 14); + if (eightbytes) { + output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14); + dest += 4; + } else { + dest += 3; + } } } static av_always_inline void -yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0, +yuv2rgba64_full_1_c_template(SwsContext *c, const int32_t *buf0, const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf0, uint16_t *dest, int dstW, - int uvalpha, int y, enum AVPixelFormat target, int hasAlpha) + int uvalpha, int y, enum AVPixelFormat target, int hasAlpha, int eightbytes) { const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0]; int i; + int A = 0xffff<<14; if (uvalpha < 2048) { - for (i = 0; i < ((dstW + 1) >> 1); i++) { - int Y1 = (buf0[i * 2] ) >> 2; - int Y2 = (buf0[i * 2 + 1]) >> 2; + for (i = 0; i < dstW; i++) { + int Y = (buf0[i]) >> 2; int U = (ubuf0[i] + (-128 << 11)) >> 2; int V = (vbuf0[i] + (-128 << 11)) >> 2; int R, G, B; - Y1 -= c->yuv2rgb_y_offset; - Y2 -= c->yuv2rgb_y_offset; - Y1 *= c->yuv2rgb_y_coeff; - Y2 *= c->yuv2rgb_y_coeff; - Y1 += 1 << 13; - Y2 += 1 << 13; + Y -= c->yuv2rgb_y_offset; + Y *= c->yuv2rgb_y_coeff; + Y += 1 << 13; + + if (hasAlpha) { + A = abuf0[i] << 11; + + A += 1 << 13; + } R = V * c->yuv2rgb_v2r_coeff; G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; B = U * c->yuv2rgb_u2b_coeff; - output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); - output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); - output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); - output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); - output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); - output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); - dest += 6; + output_pixel(&dest[0], av_clip_uintp2(R_B + Y, 30) >> 14); + output_pixel(&dest[1], av_clip_uintp2( G + Y, 30) >> 14); + output_pixel(&dest[2], av_clip_uintp2(B_R + Y, 30) >> 14); + if (eightbytes) { + output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14); + dest += 4; + } else { + dest += 3; + } } } else { const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1]; - for (i = 0; i < ((dstW + 1) >> 1); i++) { - int Y1 = (buf0[i * 2] ) >> 2; - int Y2 = (buf0[i * 2 + 1]) >> 2; + int A = 0xffff<<14; + for (i = 0; i < dstW; i++) { + int Y = (buf0[i] ) >> 2; int U = (ubuf0[i] + ubuf1[i] + (-128 << 12)) >> 3; int V = (vbuf0[i] + vbuf1[i] + (-128 << 12)) >> 3; int R, G, B; - Y1 -= c->yuv2rgb_y_offset; - Y2 -= c->yuv2rgb_y_offset; - Y1 *= c->yuv2rgb_y_coeff; - Y2 *= c->yuv2rgb_y_coeff; - Y1 += 1 << 13; - Y2 += 1 << 13; + Y -= c->yuv2rgb_y_offset; + Y *= c->yuv2rgb_y_coeff; + Y += 1 << 13; + + if (hasAlpha) { + A = abuf0[i] << 11; + + A += 1 << 13; + } R = V * c->yuv2rgb_v2r_coeff; G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; B = U * c->yuv2rgb_u2b_coeff; - output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14); - output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14); - output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14); - output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14); - output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14); - output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14); - dest += 6; + output_pixel(&dest[0], av_clip_uintp2(R_B + Y, 30) >> 14); + output_pixel(&dest[1], av_clip_uintp2( G + Y, 30) >> 14); + output_pixel(&dest[2], av_clip_uintp2(B_R + Y, 30) >> 14); + if (eightbytes) { + output_pixel(&dest[3], av_clip_uintp2(A, 30) >> 14); + dest += 4; + } else { + dest += 3; + } } } } @@ -1069,7 +1119,7 @@ #undef r_b #undef b_r -#define YUV2PACKED16WRAPPER(name, base, ext, fmt, hasAlpha) \ +#define YUV2PACKED16WRAPPER(name, base, ext, fmt, hasAlpha, eightbytes) \ static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ const int16_t **_lumSrc, int lumFilterSize, \ const int16_t *chrFilter, const int16_t **_chrUSrc, \ @@ -1084,7 +1134,7 @@ uint16_t *dest = (uint16_t *) _dest; \ name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \ chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ - alpSrc, dest, dstW, y, fmt, hasAlpha); \ + alpSrc, dest, dstW, y, fmt, hasAlpha, eightbytes); \ } \ \ static void name ## ext ## _2_c(SwsContext *c, const int16_t *_buf[2], \ @@ -1098,7 +1148,7 @@ **abuf = (const int32_t **) _abuf; \ uint16_t *dest = (uint16_t *) _dest; \ name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \ - dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \ + dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha, eightbytes); \ } \ \ static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \ @@ -1112,21 +1162,34 @@ *abuf0 = (const int32_t *) _abuf0; \ uint16_t *dest = (uint16_t *) _dest; \ name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \ - dstW, uvalpha, y, fmt, hasAlpha); \ + dstW, uvalpha, y, fmt, hasAlpha, eightbytes); \ } -YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48be, AV_PIX_FMT_RGB48BE, 0) -YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48le, AV_PIX_FMT_RGB48LE, 0) -YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48be, AV_PIX_FMT_BGR48BE, 0) -YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48le, AV_PIX_FMT_BGR48LE, 0) -YUV2PACKED16WRAPPER(yuv2, rgba64, rgba64be, AV_PIX_FMT_RGBA64BE, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64, rgba64le, AV_PIX_FMT_RGBA64LE, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64, rgbx64be, AV_PIX_FMT_RGBA64BE, 0) -YUV2PACKED16WRAPPER(yuv2, rgba64, rgbx64le, AV_PIX_FMT_RGBA64LE, 0) -YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64be, AV_PIX_FMT_BGRA64BE, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64le, AV_PIX_FMT_BGRA64LE, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64be, AV_PIX_FMT_BGRA64BE, 0) -YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64le, AV_PIX_FMT_BGRA64LE, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64, rgb48be, AV_PIX_FMT_RGB48BE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64, rgb48le, AV_PIX_FMT_RGB48LE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64, bgr48be, AV_PIX_FMT_BGR48BE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64, bgr48le, AV_PIX_FMT_BGR48LE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64, rgba64be, AV_PIX_FMT_RGBA64BE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, rgba64le, AV_PIX_FMT_RGBA64LE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, rgbx64be, AV_PIX_FMT_RGBA64BE, 0, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, rgbx64le, AV_PIX_FMT_RGBA64LE, 0, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64be, AV_PIX_FMT_BGRA64BE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64le, AV_PIX_FMT_BGRA64LE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64be, AV_PIX_FMT_BGRA64BE, 0, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64le, AV_PIX_FMT_BGRA64LE, 0, 1) + +YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgb48be_full, AV_PIX_FMT_RGB48BE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgb48le_full, AV_PIX_FMT_RGB48LE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgr48be_full, AV_PIX_FMT_BGR48BE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgr48le_full, AV_PIX_FMT_BGR48LE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgba64be_full, AV_PIX_FMT_RGBA64BE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgba64le_full, AV_PIX_FMT_RGBA64LE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgbx64be_full, AV_PIX_FMT_RGBA64BE, 0, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgbx64le_full, AV_PIX_FMT_RGBA64LE, 0, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgra64be_full, AV_PIX_FMT_BGRA64BE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgra64le_full, AV_PIX_FMT_BGRA64LE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgrx64be_full, AV_PIX_FMT_BGRA64BE, 0, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgrx64le_full, AV_PIX_FMT_BGRA64LE, 0, 1) /* * Write out 2 RGB pixels in the target pixel format. This function takes a @@ -1854,6 +1917,146 @@ } } +static void +yuv2ya8_1_c(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf0, uint8_t *dest, int dstW, + int uvalpha, int y) +{ + int hasAlpha = !!abuf0; + int i; + + for (i = 0; i < dstW; i++) { + int Y = (buf0[i] + 64) >> 7; + int A; + + Y = av_clip_uint8(Y); + + if (hasAlpha) { + A = (abuf0[i] + 64) >> 7; + if (A & 0x100) + A = av_clip_uint8(A); + } + + dest[i * 2 ] = Y; + dest[i * 2 + 1] = hasAlpha ? A : 255; + } +} + +static void +yuv2ya8_2_c(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, + int yalpha, int uvalpha, int y) +{ + int hasAlpha = abuf && abuf[0] && abuf[1]; + const int16_t *buf0 = buf[0], *buf1 = buf[1], + *abuf0 = hasAlpha ? abuf[0] : NULL, + *abuf1 = hasAlpha ? abuf[1] : NULL; + int yalpha1 = 4096 - yalpha; + int i; + + for (i = 0; i < dstW; i++) { + int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19; + int A; + + Y = av_clip_uint8(Y); + + if (hasAlpha) { + A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 19; + A = av_clip_uint8(A); + } + + dest[i * 2 ] = Y; + dest[i * 2 + 1] = hasAlpha ? A : 255; + } +} + +static void +yuv2ya8_X_c(SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, int dstW, int y) +{ + int hasAlpha = !!alpSrc; + int i; + + for (i = 0; i < dstW; i++) { + int j; + int Y = 1 << 18, A = 1 << 18; + + for (j = 0; j < lumFilterSize; j++) + Y += lumSrc[j][i] * lumFilter[j]; + + Y >>= 19; + if (Y & 0x100) + Y = av_clip_uint8(Y); + + if (hasAlpha) { + for (j = 0; j < lumFilterSize; j++) + A += alpSrc[j][i] * lumFilter[j]; + + A >>= 19; + + if (A & 0x100) + A = av_clip_uint8(A); + } + + dest[2 * i ] = Y; + dest[2 * i + 1] = hasAlpha ? A : 255; + } +} + +static void +yuv2ayuv64le_X_c(SwsContext *c, const int16_t *lumFilter, + const int16_t **_lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **_chrUSrc, + const int16_t **_chrVSrc, int chrFilterSize, + const int16_t **_alpSrc, uint8_t *dest, int dstW, int y) +{ + const int32_t **lumSrc = (const int32_t **) _lumSrc, + **chrUSrc = (const int32_t **) _chrUSrc, + **chrVSrc = (const int32_t **) _chrVSrc, + **alpSrc = (const int32_t **) _alpSrc; + int hasAlpha = !!alpSrc; + int i; + + for (i = 0; i < dstW; i++) { + int Y = 1 << 14, U = 1 << 14; + int V = 1 << 14, A = 1 << 14; + int j; + + Y -= 0x40000000; + U -= 0x40000000; + V -= 0x40000000; + A -= 0x40000000; + + for (j = 0; j < lumFilterSize; j++) + Y += lumSrc[j][i] * (unsigned)lumFilter[j]; + + for (j = 0; j < chrFilterSize; j++) + U += chrUSrc[j][i] * (unsigned)chrFilter[j]; + + for (j = 0; j < chrFilterSize; j++) + V += chrVSrc[j][i] * (unsigned)chrFilter[j]; + + if (hasAlpha) + for (j = 0; j < lumFilterSize; j++) + A += alpSrc[j][i] * (unsigned)lumFilter[j]; + + Y = 0x8000 + av_clip_int16(Y >> 15); + U = 0x8000 + av_clip_int16(U >> 15); + V = 0x8000 + av_clip_int16(V >> 15); + A = 0x8000 + av_clip_int16(A >> 15); + + AV_WL16(dest + 8 * i, hasAlpha ? A : 65535); + AV_WL16(dest + 8 * i + 2, Y); + AV_WL16(dest + 8 * i + 4, U); + AV_WL16(dest + 8 * i + 6, V); + } +} + av_cold void ff_sws_init_output_funcs(SwsContext *c, yuv2planar1_fn *yuv2plane1, yuv2planarX_fn *yuv2planeX, @@ -1973,7 +2176,64 @@ } #endif /* !CONFIG_SMALL */ break; - case AV_PIX_FMT_RGB24: + case AV_PIX_FMT_RGBA64LE: +#if CONFIG_SWSCALE_ALPHA + if (c->alpPixBuf) { + *yuv2packedX = yuv2rgba64le_full_X_c; + *yuv2packed2 = yuv2rgba64le_full_2_c; + *yuv2packed1 = yuv2rgba64le_full_1_c; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + *yuv2packedX = yuv2rgbx64le_full_X_c; + *yuv2packed2 = yuv2rgbx64le_full_2_c; + *yuv2packed1 = yuv2rgbx64le_full_1_c; + } + break; + case AV_PIX_FMT_RGBA64BE: +#if CONFIG_SWSCALE_ALPHA + if (c->alpPixBuf) { + *yuv2packedX = yuv2rgba64be_full_X_c; + *yuv2packed2 = yuv2rgba64be_full_2_c; + *yuv2packed1 = yuv2rgba64be_full_1_c; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + *yuv2packedX = yuv2rgbx64be_full_X_c; + *yuv2packed2 = yuv2rgbx64be_full_2_c; + *yuv2packed1 = yuv2rgbx64be_full_1_c; + } + break; + case AV_PIX_FMT_BGRA64LE: +#if CONFIG_SWSCALE_ALPHA + if (c->alpPixBuf) { + *yuv2packedX = yuv2bgra64le_full_X_c; + *yuv2packed2 = yuv2bgra64le_full_2_c; + *yuv2packed1 = yuv2bgra64le_full_1_c; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + *yuv2packedX = yuv2bgrx64le_full_X_c; + *yuv2packed2 = yuv2bgrx64le_full_2_c; + *yuv2packed1 = yuv2bgrx64le_full_1_c; + } + break; + case AV_PIX_FMT_BGRA64BE: +#if CONFIG_SWSCALE_ALPHA + if (c->alpPixBuf) { + *yuv2packedX = yuv2bgra64be_full_X_c; + *yuv2packed2 = yuv2bgra64be_full_2_c; + *yuv2packed1 = yuv2bgra64be_full_1_c; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + *yuv2packedX = yuv2bgrx64be_full_X_c; + *yuv2packed2 = yuv2bgrx64be_full_2_c; + *yuv2packed1 = yuv2bgrx64be_full_1_c; + } + break; + + case AV_PIX_FMT_RGB24: *yuv2packedX = yuv2rgb24_full_X_c; *yuv2packed2 = yuv2rgb24_full_2_c; *yuv2packed1 = yuv2rgb24_full_1_c; @@ -1983,6 +2243,26 @@ *yuv2packed2 = yuv2bgr24_full_2_c; *yuv2packed1 = yuv2bgr24_full_1_c; break; + case AV_PIX_FMT_RGB48LE: + *yuv2packedX = yuv2rgb48le_full_X_c; + *yuv2packed2 = yuv2rgb48le_full_2_c; + *yuv2packed1 = yuv2rgb48le_full_1_c; + break; + case AV_PIX_FMT_BGR48LE: + *yuv2packedX = yuv2bgr48le_full_X_c; + *yuv2packed2 = yuv2bgr48le_full_2_c; + *yuv2packed1 = yuv2bgr48le_full_1_c; + break; + case AV_PIX_FMT_RGB48BE: + *yuv2packedX = yuv2rgb48be_full_X_c; + *yuv2packed2 = yuv2rgb48be_full_2_c; + *yuv2packed1 = yuv2rgb48be_full_1_c; + break; + case AV_PIX_FMT_BGR48BE: + *yuv2packedX = yuv2bgr48be_full_X_c; + *yuv2packed2 = yuv2bgr48be_full_2_c; + *yuv2packed1 = yuv2bgr48be_full_1_c; + break; case AV_PIX_FMT_BGR4_BYTE: *yuv2packedX = yuv2bgr4_byte_full_X_c; *yuv2packed2 = yuv2bgr4_byte_full_2_c; @@ -2221,5 +2501,13 @@ *yuv2packed2 = yuv2uyvy422_2_c; *yuv2packedX = yuv2uyvy422_X_c; break; + case AV_PIX_FMT_YA8: + *yuv2packed1 = yuv2ya8_1_c; + *yuv2packed2 = yuv2ya8_2_c; + *yuv2packedX = yuv2ya8_X_c; + break; + case AV_PIX_FMT_AYUV64LE: + *yuv2packedX = yuv2ayuv64le_X_c; + break; } } diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswscale/ppc/yuv2rgb_altivec.c ffmpeg-2.7.2~trusty~ppa1/libswscale/ppc/yuv2rgb_altivec.c --- ffmpeg-2.7.1~trusty~ppa1/libswscale/ppc/yuv2rgb_altivec.c 2015-06-18 18:55:04.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswscale/ppc/yuv2rgb_altivec.c 2015-07-16 17:20:02.000000000 +0000 @@ -222,6 +222,7 @@ * optimized for JPEG decoding. */ +#if HAVE_BIGENDIAN #define vec_unh(x) \ (vector signed short) \ vec_perm(x, (__typeof__(x)) { 0 }, \ @@ -235,6 +236,10 @@ ((vector unsigned char) { \ 0x10, 0x08, 0x10, 0x09, 0x10, 0x0A, 0x10, 0x0B, \ 0x10, 0x0C, 0x10, 0x0D, 0x10, 0x0E, 0x10, 0x0F })) +#else +#define vec_unh(x)(vector signed short) vec_mergeh(x,(__typeof__(x)) { 0 }) +#define vec_unl(x)(vector signed short) vec_mergel(x,(__typeof__(x)) { 0 }) +#endif #define vec_clip_s16(x) \ vec_max(vec_min(x, ((vector signed short) { \ diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswscale/rgb2rgb.c ffmpeg-2.7.2~trusty~ppa1/libswscale/rgb2rgb.c --- ffmpeg-2.7.1~trusty~ppa1/libswscale/rgb2rgb.c 2015-06-18 18:55:04.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswscale/rgb2rgb.c 2015-06-23 17:20:03.000000000 +0000 @@ -51,6 +51,7 @@ void (*rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size); void (*rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size); +void (*shuffle_bytes_0321)(const uint8_t *src, uint8_t *dst, int src_size); void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size); void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, @@ -333,7 +334,6 @@ } \ } -DEFINE_SHUFFLE_BYTES(0, 3, 2, 1) DEFINE_SHUFFLE_BYTES(1, 2, 3, 0) DEFINE_SHUFFLE_BYTES(3, 0, 1, 2) DEFINE_SHUFFLE_BYTES(3, 2, 1, 0) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswscale/rgb2rgb.h ffmpeg-2.7.2~trusty~ppa1/libswscale/rgb2rgb.h --- ffmpeg-2.7.1~trusty~ppa1/libswscale/rgb2rgb.h 2015-06-18 18:55:04.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswscale/rgb2rgb.h 2015-06-23 17:20:03.000000000 +0000 @@ -50,6 +50,7 @@ extern void (*rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size); extern void (*rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size); +extern void (*shuffle_bytes_0321)(const uint8_t *src, uint8_t *dst, int src_size); extern void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size); void rgb64tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size); @@ -71,7 +72,6 @@ void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size); void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size); -void shuffle_bytes_0321(const uint8_t *src, uint8_t *dst, int src_size); void shuffle_bytes_1230(const uint8_t *src, uint8_t *dst, int src_size); void shuffle_bytes_3012(const uint8_t *src, uint8_t *dst, int src_size); void shuffle_bytes_3210(const uint8_t *src, uint8_t *dst, int src_size); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswscale/rgb2rgb_template.c ffmpeg-2.7.2~trusty~ppa1/libswscale/rgb2rgb_template.c --- ffmpeg-2.7.1~trusty~ppa1/libswscale/rgb2rgb_template.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswscale/rgb2rgb_template.c 2015-06-23 17:20:03.000000000 +0000 @@ -322,12 +322,26 @@ uint8_t *d = dst - idx; for (; idx < 15; idx += 4) { - register int v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00; + register unsigned v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00; v &= 0xff00ff; *(uint32_t *)&d[idx] = (v >> 16) + g + (v << 16); } } +static inline void shuffle_bytes_0321_c(const uint8_t *src, uint8_t *dst, + int src_size) +{ + int idx = 15 - src_size; + const uint8_t *s = src - idx; + uint8_t *d = dst - idx; + + for (; idx < 15; idx += 4) { + register unsigned v = *(const uint32_t *)&s[idx], g = v & 0x00ff00ff; + v &= 0xff00ff00; + *(uint32_t *)&d[idx] = (v >> 16) + g + (v << 16); + } +} + static inline void rgb24tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size) { unsigned i; @@ -929,7 +943,13 @@ rgb24to15 = rgb24to15_c; rgb24to16 = rgb24to16_c; rgb24tobgr24 = rgb24tobgr24_c; +#if HAVE_BIGENDIAN + shuffle_bytes_0321 = shuffle_bytes_2103_c; + shuffle_bytes_2103 = shuffle_bytes_0321_c; +#else + shuffle_bytes_0321 = shuffle_bytes_0321_c; shuffle_bytes_2103 = shuffle_bytes_2103_c; +#endif rgb32tobgr16 = rgb32tobgr16_c; rgb32tobgr15 = rgb32tobgr15_c; yv12toyuy2 = yv12toyuy2_c; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswscale/swscale.c ffmpeg-2.7.2~trusty~ppa1/libswscale/swscale.c --- ffmpeg-2.7.1~trusty~ppa1/libswscale/swscale.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswscale/swscale.c 2015-06-12 17:20:03.000000000 +0000 @@ -784,6 +784,8 @@ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); int i; + av_assert2(desc); + for (i = 0; i < 4; i++) { int plane = desc->comp[i].plane; if (!data[plane] || !linesizes[plane]) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswscale/swscale_internal.h ffmpeg-2.7.2~trusty~ppa1/libswscale/swscale_internal.h --- ffmpeg-2.7.1~trusty~ppa1/libswscale/swscale_internal.h 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswscale/swscale_internal.h 2015-07-24 17:20:02.000000000 +0000 @@ -790,6 +790,8 @@ || (x)==AV_PIX_FMT_YA8 \ || (x)==AV_PIX_FMT_YA16LE \ || (x)==AV_PIX_FMT_YA16BE \ + || (x)==AV_PIX_FMT_AYUV64LE \ + || (x)==AV_PIX_FMT_AYUV64BE \ || isRGBinInt(x) \ || isBGRinInt(x) \ ) diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswscale/swscale_unscaled.c ffmpeg-2.7.2~trusty~ppa1/libswscale/swscale_unscaled.c --- ffmpeg-2.7.1~trusty~ppa1/libswscale/swscale_unscaled.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswscale/swscale_unscaled.c 2015-07-24 17:20:02.000000000 +0000 @@ -1243,6 +1243,11 @@ if ((dstFormat == AV_PIX_FMT_RGB32_1 || dstFormat == AV_PIX_FMT_BGR32_1) && !isRGBA32(srcFormat) && ALT32_CORR<0) return NULL; + // Maintain symmetry between endianness + if (c->flags & SWS_BITEXACT) + if ((dstFormat == AV_PIX_FMT_RGB32 || dstFormat == AV_PIX_FMT_BGR32 ) && !isRGBA32(srcFormat) && ALT32_CORR>0) + return NULL; + return conv; } @@ -1671,6 +1676,7 @@ IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGRA64) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY16) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YA16) || + IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_AYUV64) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP9) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP10) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP12) || diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswscale/utils.c ffmpeg-2.7.2~trusty~ppa1/libswscale/utils.c --- ffmpeg-2.7.1~trusty~ppa1/libswscale/utils.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswscale/utils.c 2015-07-24 17:20:02.000000000 +0000 @@ -166,7 +166,7 @@ [AV_PIX_FMT_RGB444BE] = { 1, 1 }, [AV_PIX_FMT_BGR444LE] = { 1, 1 }, [AV_PIX_FMT_BGR444BE] = { 1, 1 }, - [AV_PIX_FMT_YA8] = { 1, 0 }, + [AV_PIX_FMT_YA8] = { 1, 1 }, [AV_PIX_FMT_YA16BE] = { 1, 0 }, [AV_PIX_FMT_YA16LE] = { 1, 0 }, [AV_PIX_FMT_BGR48BE] = { 1, 1 }, @@ -225,6 +225,7 @@ [AV_PIX_FMT_BAYER_GRBG16BE] = { 1, 0 }, [AV_PIX_FMT_XYZ12BE] = { 1, 1, 1 }, [AV_PIX_FMT_XYZ12LE] = { 1, 1, 1 }, + [AV_PIX_FMT_AYUV64LE] = { 1, 1}, }; int sws_isSupportedInput(enum AVPixelFormat pix_fmt) @@ -1036,6 +1037,7 @@ return AVERROR(EINVAL); } } + av_assert2(desc_src && desc_dst); i = flags & (SWS_POINT | SWS_AREA | @@ -1157,6 +1159,14 @@ if (flags & SWS_FULL_CHR_H_INT && isAnyRGB(dstFormat) && !isPlanarRGB(dstFormat) && + dstFormat != AV_PIX_FMT_RGBA64LE && + dstFormat != AV_PIX_FMT_RGBA64BE && + dstFormat != AV_PIX_FMT_BGRA64LE && + dstFormat != AV_PIX_FMT_BGRA64BE && + dstFormat != AV_PIX_FMT_RGB48LE && + dstFormat != AV_PIX_FMT_RGB48BE && + dstFormat != AV_PIX_FMT_BGR48LE && + dstFormat != AV_PIX_FMT_BGR48BE && dstFormat != AV_PIX_FMT_RGBA && dstFormat != AV_PIX_FMT_ARGB && dstFormat != AV_PIX_FMT_BGRA && @@ -1487,9 +1497,9 @@ /* Allocate pixbufs (we use dynamic allocation because otherwise we would * need to allocate several megabytes to handle all possible cases) */ - FF_ALLOC_OR_GOTO(c, c->lumPixBuf, c->vLumBufSize * 3 * sizeof(int16_t *), fail); - FF_ALLOC_OR_GOTO(c, c->chrUPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail); - FF_ALLOC_OR_GOTO(c, c->chrVPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail); + FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf, c->vLumBufSize * 3 * sizeof(int16_t *), fail); + FF_ALLOCZ_OR_GOTO(c, c->chrUPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail); + FF_ALLOCZ_OR_GOTO(c, c->chrVPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail); if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat)) FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf, c->vLumBufSize * 3 * sizeof(int16_t *), fail); /* Note we need at least one pixel more at the end because of the MMX code @@ -1653,6 +1663,22 @@ return c; } +static int isnan_vec(SwsVector *a) +{ + int i; + for (i=0; ilength; i++) + if (isnan(a->coeff[i])) + return 1; + return 0; +} + +static void makenan_vec(SwsVector *a) +{ + int i; + for (i=0; ilength; i++) + a->coeff[i] = NAN; +} + SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, float lumaSharpen, float chromaSharpen, float chromaHShift, float chromaVShift, @@ -1714,6 +1740,12 @@ sws_normalizeVec(filter->lumH, 1.0); sws_normalizeVec(filter->lumV, 1.0); + if (isnan_vec(filter->chrH) || + isnan_vec(filter->chrV) || + isnan_vec(filter->lumH) || + isnan_vec(filter->lumV)) + goto fail; + if (verbose) sws_printVec2(filter->chrH, NULL, AV_LOG_DEBUG); if (verbose) @@ -1889,6 +1921,10 @@ void sws_shiftVec(SwsVector *a, int shift) { SwsVector *shifted = sws_getShiftedVec(a, shift); + if (!shifted) { + makenan_vec(a); + return; + } av_free(a->coeff); a->coeff = shifted->coeff; a->length = shifted->length; @@ -1898,6 +1934,10 @@ void sws_addVec(SwsVector *a, SwsVector *b) { SwsVector *sum = sws_sumVec(a, b); + if (!sum) { + makenan_vec(a); + return; + } av_free(a->coeff); a->coeff = sum->coeff; a->length = sum->length; @@ -1907,6 +1947,10 @@ void sws_subVec(SwsVector *a, SwsVector *b) { SwsVector *diff = sws_diffVec(a, b); + if (!diff) { + makenan_vec(a); + return; + } av_free(a->coeff); a->coeff = diff->coeff; a->length = diff->length; @@ -1916,6 +1960,10 @@ void sws_convVec(SwsVector *a, SwsVector *b) { SwsVector *conv = sws_getConvVec(a, b); + if (!conv) { + makenan_vec(a); + return; + } av_free(a->coeff); a->coeff = conv->coeff; a->length = conv->length; diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswscale/x86/rgb2rgb_template.c ffmpeg-2.7.2~trusty~ppa1/libswscale/x86/rgb2rgb_template.c --- ffmpeg-2.7.1~trusty~ppa1/libswscale/x86/rgb2rgb_template.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswscale/x86/rgb2rgb_template.c 2015-06-23 17:20:03.000000000 +0000 @@ -1090,7 +1090,7 @@ : "r" (s), "r" (d), "m" (mask32b), "m" (mask32r), "m" (mmx_one) : "memory"); for (; idx<15; idx+=4) { - register int v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00; + register unsigned v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00; v &= 0xff00ff; *(uint32_t *)&d[idx] = (v>>16) + g + (v<<16); } @@ -1905,7 +1905,7 @@ "cmp %3, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15) - : "memory", "%"REG_a"" + : "memory", XMM_CLOBBERS("xmm0", "xmm1", "xmm2",) "%"REG_a ); #else __asm__( @@ -1943,7 +1943,9 @@ src2 += src2Stride; } __asm__( +#if !COMPILE_TEMPLATE_SSE2 EMMS" \n\t" +#endif SFENCE" \n\t" ::: "memory" ); @@ -1971,7 +1973,9 @@ dst2 += dst2Stride; } __asm__( +#if !COMPILE_TEMPLATE_SSE2 EMMS" \n\t" +#endif SFENCE" \n\t" ::: "memory" ); diff -Nru ffmpeg-2.7.1~trusty~ppa1/libswscale/x86/swscale_template.c ffmpeg-2.7.2~trusty~ppa1/libswscale/x86/swscale_template.c --- ffmpeg-2.7.1~trusty~ppa1/libswscale/x86/swscale_template.c 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/libswscale/x86/swscale_template.c 2015-07-04 21:09:16.000000000 +0000 @@ -399,6 +399,35 @@ } } +static void RENAME(yuv2bgr32_X)(SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, + int chrFilterSize, const int16_t **alpSrc, + uint8_t *dest, int dstW, int dstY) +{ + x86_reg dummy=0; + x86_reg dstW_reg = dstW; + x86_reg uv_off = c->uv_offx2; + + if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { + YSCALEYUV2PACKEDX + YSCALEYUV2RGBX + YSCALEYUV2PACKEDX_YA(ALP_MMX_FILTER_OFFSET, %%mm0, %%mm3, %%mm6, %%mm1, %%mm7) + "psraw $3, %%mm1 \n\t" + "psraw $3, %%mm7 \n\t" + "packuswb %%mm7, %%mm1 \n\t" + WRITEBGR32(%4, "%5", %%REGa, %%mm5, %%mm4, %%mm2, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6) + YSCALEYUV2PACKEDX_END + } else { + YSCALEYUV2PACKEDX + YSCALEYUV2RGBX + "pcmpeqd %%mm7, %%mm7 \n\t" + WRITEBGR32(%4, "%5", %%REGa, %%mm5, %%mm4, %%mm2, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) + YSCALEYUV2PACKEDX_END + } +} + #define REAL_WRITERGB16(dst, dstw, index) \ "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\ "pand "MANGLE(bFC)", %%mm4 \n\t" /* G */\ @@ -1491,6 +1520,7 @@ if (!(c->flags & SWS_FULL_CHR_H_INT)) { switch (c->dstFormat) { case AV_PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break; + case AV_PIX_FMT_BGR32: c->yuv2packedX = RENAME(yuv2bgr32_X); break; #if HAVE_6REGS case AV_PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X); break; #endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/LICENSE.md ffmpeg-2.7.2~trusty~ppa1/LICENSE.md --- ffmpeg-2.7.1~trusty~ppa1/LICENSE.md 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/LICENSE.md 2015-07-15 17:20:03.000000000 +0000 @@ -16,6 +16,7 @@ - optional x86 optimizations in the files - `libavcodec/x86/flac_dsp_gpl.asm` - `libavcodec/x86/idct_mmx.c` + - `libavfilter/x86/vf_removegrain.asm` - libutvideo encoding/decoding wrappers in `libavcodec/libutvideo*.cpp` - the X11 grabber in `libavdevice/x11grab.c` diff -Nru ffmpeg-2.7.1~trusty~ppa1/MAINTAINERS ffmpeg-2.7.2~trusty~ppa1/MAINTAINERS --- ffmpeg-2.7.1~trusty~ppa1/MAINTAINERS 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/MAINTAINERS 2015-08-04 17:20:03.000000000 +0000 @@ -14,7 +14,6 @@ Project Leader ============== -Michael Niedermayer final design decisions @@ -171,6 +170,7 @@ dvbsubdec.c Anshul Maheshwari dxa.c Kostya Shishkov eacmv*, eaidct*, eat* Peter Ross + evrc* Paul B Mahol exif.c, exif.h Thilo Borgmann ffv1* Michael Niedermayer ffwavesynth.c Nicolas George @@ -200,6 +200,7 @@ libcelt_dec.c Nicolas George libdirac* David Conrad libgsm.c Michel Bardiaux + libkvazaar.c Arttu Ylä-Outinen libopenjpeg.c Jaikrishnan Menon libopenjpegenc.c Michael Bradshaw libschroedinger* David Conrad @@ -237,6 +238,7 @@ qdm2.c, qdm2data.h Roberto Togni, Benjamin Larsson qdrw.c Kostya Shishkov qpeg.c Kostya Shishkov + qsv* Ivan Uskov qtrle.c Mike Melanson ra144.c, ra144.h, ra288.c, ra288.h Roberto Togni resample2.c Michael Niedermayer @@ -298,11 +300,12 @@ Hardware acceleration: crystalhd.c Philip Langdale - dxva2* Laurent Aimar + dxva2* Hendrik Leppkes, Laurent Aimar libstagefright.cpp Mohamed Naufal vaapi* Gwenole Beauchesne vda* Sebastien Zwickert - vdpau* Carl Eugen Hoyos + vdpau* Philip Langdale, Carl Eugen Hoyos + videotoolbox* Sebastien Zwickert libavdevice @@ -334,6 +337,7 @@ graphdump.c Nicolas George Filters: + f_drawgraph.c Paul B Mahol af_adelay.c Paul B Mahol af_aecho.c Paul B Mahol af_afade.c Paul B Mahol @@ -344,14 +348,20 @@ af_astreamsync.c Nicolas George af_atempo.c Pavel Koshevoy af_biquads.c Paul B Mahol + af_chorus.c Paul B Mahol af_compand.c Paul B Mahol af_ladspa.c Paul B Mahol af_pan.c Nicolas George + af_sidechaincompress.c Paul B Mahol af_silenceremove.c Paul B Mahol avf_avectorscope.c Paul B Mahol avf_showcqt.c Muhammad Faiz vf_blend.c Paul B Mahol + vf_colorchannelmixer.c Paul B Mahol vf_colorbalance.c Paul B Mahol + vf_colorkey.c Timo Rothenpieler + vf_colorlevels.c Paul B Mahol + vf_deband.c Paul B Mahol vf_dejudder.c Nicholas Robbins vf_delogo.c Jean Delvare (CC ) vf_drawbox.c/drawgrid Andrey Utkin @@ -362,12 +372,16 @@ vf_il.c Paul B Mahol vf_lenscorrection.c Daniel Oberhoff vf_mergeplanes.c Paul B Mahol + vf_neighbor.c Paul B Mahol vf_psnr.c Paul B Mahol + vf_random.c Paul B Mahol vf_scale.c Michael Niedermayer vf_separatefields.c Paul B Mahol + vf_ssim.c Paul B Mahol vf_stereo3d.c Paul B Mahol vf_telecine.c Paul B Mahol vf_yadif.c Michael Niedermayer + vf_zoompan.c Paul B Mahol Sources: vsrc_mandelbrot.c Michael Niedermayer @@ -415,6 +429,7 @@ gxf.c Reimar Doeffinger gxfenc.c Baptiste Coudurier hls.c Anssi Hannula + hls encryption (hlsenc.c) Christian Suloway idcin.c Mike Melanson idroqdec.c Mike Melanson iff.c Jaikrishnan Menon @@ -500,6 +515,7 @@ wvenc.c Paul B Mahol Protocols: + async.c Zhang Rui bluray.c Petri Hintukainen ftp.c Lukasz Marek http.c Ronald S. Bultje @@ -535,7 +551,7 @@ Linux / PowerPC Luca Barbato Windows MinGW Alex Beregszaszi, Ramiro Polla Windows Cygwin Victor Paesa -Windows MSVC Matthew Oliver +Windows MSVC Matthew Oliver, Hendrik Leppkes Windows ICL Matthew Oliver ADI/Blackfin DSP Marc Hoffman Sparc Roman Shaposhnik @@ -580,6 +596,7 @@ Nicolas George 24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93 Panagiotis Issaris 6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029 Peter Ross A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B +Philip Langdale 5DC5 8D66 5FBA 3A43 18EC 045E F8D6 B194 6A75 682E Reimar Doeffinger C61D 16E5 9E2C D10C 8958 38A4 0899 A2B9 06D4 D9C7 Reinhard Tartler 9300 5DC2 7E87 6C37 ED7B CA9A 9808 3544 9453 48A4 Reynaldo H. Verdejo Pinochet 6E27 CD34 170C C78E 4D4F 5F40 C18E 077F 3114 452A diff -Nru ffmpeg-2.7.1~trusty~ppa1/Makefile ffmpeg-2.7.2~trusty~ppa1/Makefile --- ffmpeg-2.7.1~trusty~ppa1/Makefile 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/Makefile 2015-08-03 17:20:02.000000000 +0000 @@ -31,7 +31,10 @@ OBJS-ffmpeg += ffmpeg_opt.o ffmpeg_filter.o OBJS-ffmpeg-$(HAVE_VDPAU_X11) += ffmpeg_vdpau.o OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o -OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_vda.o +ifndef CONFIG_VIDEOTOOLBOX +OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_videotoolbox.o +endif +OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o OBJS-ffserver += ffserver_config.o TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 @@ -60,6 +63,7 @@ FF_EXTRALIBS := $(FFEXTRALIBS) FF_DEP_LIBS := $(DEP_LIBS) +FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS) all: $(AVPROGS) @@ -81,7 +85,7 @@ ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS \ ALTIVEC-OBJS MMX-OBJS YASM-OBJS \ MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSPR1-OBJS MSA-OBJS \ - LOONGSON3-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS + MMI-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS define RESET $(1) := @@ -175,7 +179,7 @@ distclean:: $(RM) $(DISTCLEANSUFFIXES) - $(RM) config.* .config libavutil/avconfig.h .version version.h libavutil/ffversion.h libavcodec/codec_names.h + $(RM) config.* .config libavutil/avconfig.h .version avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h config: $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION) diff -Nru ffmpeg-2.7.1~trusty~ppa1/RELEASE ffmpeg-2.7.2~trusty~ppa1/RELEASE --- ffmpeg-2.7.1~trusty~ppa1/RELEASE 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/RELEASE 2015-07-20 17:20:03.000000000 +0000 @@ -1 +1 @@ -2.7.1 +2.7.git diff -Nru ffmpeg-2.7.1~trusty~ppa1/RELEASE_NOTES ffmpeg-2.7.2~trusty~ppa1/RELEASE_NOTES --- ffmpeg-2.7.1~trusty~ppa1/RELEASE_NOTES 2015-06-19 20:44:35.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/RELEASE_NOTES 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ - - ┌─────────────────────────────────────┠- │ RELEASE NOTES for FFmpeg 2.7 "Nash" │ - └─────────────────────────────────────┘ - - The FFmpeg Project proudly presents FFmpeg 2.7 "Nash", about 3 - months after the release of FFmpeg 2.6. - - A complete Changelog is available at the root of the project, and the - complete Git history on http://source.ffmpeg.org. - - We hope you will like this release as much as we enjoyed working on it, and - as usual, if you have any questions about it, or any FFmpeg related topic, - feel free to join us on the #ffmpeg IRC channel (on irc.freenode.net) or ask - on the mailing-lists. diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/api/api-flac-test.c ffmpeg-2.7.2~trusty~ppa1/tests/api/api-flac-test.c --- ffmpeg-2.7.1~trusty~ppa1/tests/api/api-flac-test.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/api/api-flac-test.c 2015-06-28 17:20:02.000000000 +0000 @@ -0,0 +1,276 @@ +/* + * Copyright (c) 2015 Ludmila Glinskih + * Copyright (c) 2001 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/* + * FLAC codec test. + * Encodes raw data to FLAC format and decodes it back to raw. Compares raw-data + * after that. + */ + +#include "libavcodec/avcodec.h" +#include "libavutil/common.h" +#include "libavutil/samplefmt.h" + +#define NUMBER_OF_FRAMES 200 +#define NAME_BUFF_SIZE 100 + +/* generate i-th frame of test audio */ +static int generate_raw_frame(uint16_t *frame_data, int i, int sample_rate, + int channels, int frame_size) +{ + int j, k; + + for (j = 0; j < frame_size; j++) { + frame_data[channels * j] = 10000 * ((j / 10 * i) % 2); + for (k = 1; k < channels; k++) + frame_data[channels * j + k] = frame_data[channels * j] * (k + 1); + } + return 0; +} + +static int init_encoder(AVCodec *enc, AVCodecContext **enc_ctx, + int64_t ch_layout, int sample_rate) +{ + AVCodecContext *ctx; + int result; + char name_buff[NAME_BUFF_SIZE]; + + av_get_channel_layout_string(name_buff, NAME_BUFF_SIZE, 0, ch_layout); + av_log(NULL, AV_LOG_INFO, "channel layout: %s, sample rate: %i\n", name_buff, sample_rate); + + ctx = avcodec_alloc_context3(enc); + if (!ctx) { + av_log(NULL, AV_LOG_ERROR, "Can't allocate encoder context\n"); + return AVERROR(ENOMEM); + } + + ctx->sample_fmt = AV_SAMPLE_FMT_S16; + ctx->sample_rate = sample_rate; + ctx->channel_layout = ch_layout; + + result = avcodec_open2(ctx, enc, NULL); + if (result < 0) { + av_log(ctx, AV_LOG_ERROR, "Can't open encoder\n"); + return result; + } + + *enc_ctx = ctx; + return 0; +} + +static int init_decoder(AVCodec *dec, AVCodecContext **dec_ctx, + int64_t ch_layout) +{ + AVCodecContext *ctx; + int result; + + ctx = avcodec_alloc_context3(dec); + if (!ctx) { + av_log(NULL, AV_LOG_ERROR , "Can't allocate decoder context\n"); + return AVERROR(ENOMEM); + } + + ctx->request_sample_fmt = AV_SAMPLE_FMT_S16; + /* XXX: FLAC ignores it for some reason */ + ctx->request_channel_layout = ch_layout; + ctx->channel_layout = ch_layout; + + result = avcodec_open2(ctx, dec, NULL); + if (result < 0) { + av_log(ctx, AV_LOG_ERROR, "Can't open decoder\n"); + return result; + } + + *dec_ctx = ctx; + return 0; +} + +static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, + AVCodecContext *dec_ctx) +{ + AVPacket enc_pkt; + AVFrame *in_frame, *out_frame; + uint8_t *raw_in = NULL, *raw_out = NULL; + int in_offset = 0, out_offset = 0; + int result = 0; + int got_output = 0; + int i = 0; + int in_frame_bytes, out_frame_bytes; + + in_frame = av_frame_alloc(); + if (!in_frame) { + av_log(NULL, AV_LOG_ERROR, "Can't allocate input frame\n"); + return AVERROR(ENOMEM); + } + + in_frame->nb_samples = enc_ctx->frame_size; + in_frame->format = enc_ctx->sample_fmt; + in_frame->channel_layout = enc_ctx->channel_layout; + if (av_frame_get_buffer(in_frame, 32) != 0) { + av_log(NULL, AV_LOG_ERROR, "Can't allocate a buffer for input frame\n"); + return AVERROR(ENOMEM); + } + + out_frame = av_frame_alloc(); + if (!out_frame) { + av_log(NULL, AV_LOG_ERROR, "Can't allocate output frame\n"); + return AVERROR(ENOMEM); + } + + raw_in = av_malloc(in_frame->linesize[0] * NUMBER_OF_FRAMES); + if (!raw_in) { + av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_in\n"); + return AVERROR(ENOMEM); + } + + raw_out = av_malloc(in_frame->linesize[0] * NUMBER_OF_FRAMES); + if (!raw_out) { + av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_out\n"); + return AVERROR(ENOMEM); + } + + for (i = 0; i < NUMBER_OF_FRAMES; i++) { + av_init_packet(&enc_pkt); + enc_pkt.data = NULL; + enc_pkt.size = 0; + + generate_raw_frame((uint16_t*)(in_frame->data[0]), i, enc_ctx->sample_rate, + enc_ctx->channels, enc_ctx->frame_size); + in_frame_bytes = in_frame->nb_samples * av_frame_get_channels(in_frame) * sizeof(uint16_t); + if (in_frame_bytes > in_frame->linesize[0]) { + av_log(NULL, AV_LOG_ERROR, "Incorrect value of input frame linesize\n"); + return 1; + } + memcpy(raw_in + in_offset, in_frame->data[0], in_frame_bytes); + in_offset += in_frame_bytes; + result = avcodec_encode_audio2(enc_ctx, &enc_pkt, in_frame, &got_output); + if (result < 0) { + av_log(NULL, AV_LOG_ERROR, "Error encoding audio frame\n"); + return result; + } + + /* if we get an encoded packet, feed it straight to the decoder */ + if (got_output) { + result = avcodec_decode_audio4(dec_ctx, out_frame, &got_output, &enc_pkt); + if (result < 0) { + av_log(NULL, AV_LOG_ERROR, "Error decoding audio packet\n"); + return result; + } + + if (got_output) { + if (result != enc_pkt.size) { + av_log(NULL, AV_LOG_INFO, "Decoder consumed only part of a packet, it is allowed to do so -- need to update this test\n"); + return AVERROR_UNKNOWN; + } + + if (in_frame->nb_samples != out_frame->nb_samples) { + av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different number of samples\n"); + return AVERROR_UNKNOWN; + } + + if (in_frame->channel_layout != out_frame->channel_layout) { + av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different channel layout\n"); + return AVERROR_UNKNOWN; + } + + if (in_frame->format != out_frame->format) { + av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different sample format\n"); + return AVERROR_UNKNOWN; + } + out_frame_bytes = out_frame->nb_samples * av_frame_get_channels(out_frame) * sizeof(uint16_t); + if (out_frame_bytes > out_frame->linesize[0]) { + av_log(NULL, AV_LOG_ERROR, "Incorrect value of output frame linesize\n"); + return 1; + } + memcpy(raw_out + out_offset, out_frame->data[0], out_frame_bytes); + out_offset += out_frame_bytes; + } + } + av_free_packet(&enc_pkt); + } + + if (memcmp(raw_in, raw_out, out_frame_bytes * NUMBER_OF_FRAMES) != 0) { + av_log(NULL, AV_LOG_ERROR, "Output differs\n"); + return 1; + } + + av_log(NULL, AV_LOG_INFO, "OK\n"); + + av_freep(&raw_in); + av_freep(&raw_out); + av_frame_free(&in_frame); + av_frame_free(&out_frame); + return 0; +} + +static int close_encoder(AVCodecContext **enc_ctx) +{ + avcodec_close(*enc_ctx); + av_freep(enc_ctx); + return 0; +} + +static int close_decoder(AVCodecContext **dec_ctx) +{ + avcodec_close(*dec_ctx); + av_freep(dec_ctx); + return 0; +} + +int main(void) +{ + AVCodec *enc = NULL, *dec = NULL; + AVCodecContext *enc_ctx = NULL, *dec_ctx = NULL; + uint64_t channel_layouts[] = {AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_5POINT1_BACK, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_STEREO_DOWNMIX}; + int sample_rates[] = {8000, 44100, 48000, 192000}; + int cl, sr; + + avcodec_register_all(); + + enc = avcodec_find_encoder(AV_CODEC_ID_FLAC); + if (!enc) { + av_log(NULL, AV_LOG_ERROR, "Can't find encoder\n"); + return 1; + } + + dec = avcodec_find_decoder(AV_CODEC_ID_FLAC); + if (!dec) { + av_log(NULL, AV_LOG_ERROR, "Can't find decoder\n"); + return 1; + } + + for (cl = 0; cl < FF_ARRAY_ELEMS(channel_layouts); cl++) { + for (sr = 0; sr < FF_ARRAY_ELEMS(sample_rates); sr++) { + if (init_encoder(enc, &enc_ctx, channel_layouts[cl], sample_rates[sr]) != 0) + return 1; + if (init_decoder(dec, &dec_ctx, channel_layouts[cl]) != 0) + return 1; + if (run_test(enc, dec, enc_ctx, dec_ctx) != 0) + return 1; + close_encoder(&enc_ctx); + close_decoder(&dec_ctx); + } + } + + return 0; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/api/api-h264-test.c ffmpeg-2.7.2~trusty~ppa1/tests/api/api-h264-test.c --- ffmpeg-2.7.1~trusty~ppa1/tests/api/api-h264-test.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/api/api-h264-test.c 2015-06-29 17:20:04.000000000 +0000 @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2015 Ludmila Glinskih + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * H264 codec test. + */ + +#include "libavutil/adler32.h" +#include "libavcodec/avcodec.h" +#include "libavformat/avformat.h" +#include "libavutil/imgutils.h" + +static int video_decode_example(const char *input_filename) +{ + AVCodec *codec = NULL; + AVCodecContext *origin_ctx = NULL, *ctx= NULL; + AVFrame *fr = NULL; + uint8_t *byte_buffer = NULL; + AVPacket pkt; + AVFormatContext *fmt_ctx = NULL; + int number_of_written_bytes; + int video_stream; + int get_frame = 0; + int byte_buffer_size; + int i = 0; + int result; + + result = avformat_open_input(&fmt_ctx, input_filename, NULL, NULL); + if (result < 0) { + av_log(NULL, AV_LOG_ERROR, "Can't open file\n"); + return result; + } + + result = avformat_find_stream_info(fmt_ctx, NULL); + if (result < 0) { + av_log(NULL, AV_LOG_ERROR, "Can't get stream info\n"); + return result; + } + + video_stream = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0); + if (video_stream < 0) { + av_log(NULL, AV_LOG_ERROR, "Can't find video stream in input file\n"); + return -1; + } + + origin_ctx = fmt_ctx->streams[video_stream]->codec; + + codec = avcodec_find_decoder(origin_ctx->codec_id); + if (!codec) { + av_log(NULL, AV_LOG_ERROR, "Can't find decoder\n"); + return -1; + } + + ctx = avcodec_alloc_context3(codec); + if (!ctx) { + av_log(NULL, AV_LOG_ERROR, "Can't allocate decoder context\n"); + return AVERROR(ENOMEM); + } + + result = avcodec_copy_context(ctx, origin_ctx); + if (result) { + av_log(NULL, AV_LOG_ERROR, "Can't copy decoder context\n"); + return result; + } + + result = avcodec_open2(ctx, codec, NULL); + if (result < 0) { + av_log(ctx, AV_LOG_ERROR, "Can't open decoder\n"); + return result; + } + + fr = av_frame_alloc(); + if (!fr) { + av_log(NULL, AV_LOG_ERROR, "Can't allocate frame\n"); + return AVERROR(ENOMEM); + } + + byte_buffer_size = av_image_get_buffer_size(ctx->pix_fmt, ctx->width, ctx->height, 16); + byte_buffer = av_malloc(byte_buffer_size); + if (!byte_buffer) { + av_log(NULL, AV_LOG_ERROR, "Can't allocate buffer\n"); + return AVERROR(ENOMEM); + } + + printf("#tb %d: %d/%d\n", video_stream, fmt_ctx->streams[video_stream]->time_base.num, fmt_ctx->streams[video_stream]->time_base.den); + i = 0; + av_init_packet(&pkt); + while (av_read_frame(fmt_ctx, &pkt) >= 0) { + if (pkt.stream_index == video_stream) { + get_frame = 0; + if (pkt.pts == AV_NOPTS_VALUE) + pkt.pts = pkt.dts = i; + result = avcodec_decode_video2(ctx, fr, &get_frame, &pkt); + if (result < 0) { + av_log(NULL, AV_LOG_ERROR, "Error decoding frame\n"); + return result; + } + if (get_frame) { + number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size, + (const uint8_t* const *)fr->data, (const int*) fr->linesize, + ctx->pix_fmt, ctx->width, ctx->height, 1); + if (number_of_written_bytes < 0) { + av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n"); + return number_of_written_bytes; + } + printf("%d, %10"PRId64", %10"PRId64", %8"PRId64", %8d, 0x%08lx\n", video_stream, + fr->pkt_pts, fr->pkt_dts, av_frame_get_pkt_duration(fr), + number_of_written_bytes, av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes)); + } + av_free_packet(&pkt); + av_init_packet(&pkt); + } + i++; + } + pkt.data = NULL; + pkt.size = 0; + if (pkt.pts == AV_NOPTS_VALUE) + pkt.pts = pkt.dts = i; + do { + get_frame = 0; + result = avcodec_decode_video2(ctx, fr, &get_frame, &pkt); + if (result < 0) { + av_log(NULL, AV_LOG_ERROR, "Error decoding frame\n"); + return result; + } + if (get_frame) { + number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size, + (const uint8_t* const *)fr->data, (const int*) fr->linesize, + ctx->pix_fmt, ctx->width, ctx->height, 1); + if (number_of_written_bytes < 0) { + av_log(NULL, AV_LOG_ERROR, "Can't copy image to buffer\n"); + return number_of_written_bytes; + } + printf("%d, %10"PRId64", %10"PRId64", %8"PRId64", %8d, 0x%08lx\n", video_stream, + fr->pkt_pts, fr->pkt_dts, av_frame_get_pkt_duration(fr), + number_of_written_bytes, av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes)); + } + i++; + } while (get_frame); + + av_free_packet(&pkt); + av_frame_free(&fr); + avcodec_close(ctx); + avformat_close_input(&fmt_ctx); + avcodec_free_context(&ctx); + av_freep(&byte_buffer); + return 0; +} + +int main(int argc, char **argv) +{ + if (argc < 2) + { + av_log(NULL, AV_LOG_ERROR, "Incorrect input\n"); + return 1; + } + + av_register_all(); + + if (video_decode_example(argv[1]) != 0) + return 1; + + return 0; +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/api/Makefile ffmpeg-2.7.2~trusty~ppa1/tests/api/Makefile --- ffmpeg-2.7.1~trusty~ppa1/tests/api/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/api/Makefile 2015-06-29 17:20:04.000000000 +0000 @@ -0,0 +1,17 @@ +APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac +APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264 +APITESTPROGS += $(APITESTPROGS-yes) + +APITESTOBJS := $(APITESTOBJS:%=$(APITESTSDIR)%) $(APITESTPROGS:%=$(APITESTSDIR)/%-test.o) +APITESTPROGS := $(APITESTPROGS:%=$(APITESTSDIR)/%-test$(EXESUF)) +-include $(wildcard $(APITESTOBJS:.o=.d)) + +$(APITESTOBJS): | $(sort $(dir $(APITESTOBJS))) +$(APITESTOBJS) $(APITESTOBJS:.o=.i): CPPFLAGS += -DTEST +$(APITESTOBJS) $(APITESTOBJS:.o=.i): CFLAGS += -Umain + +$(APITESTPROGS): %$(EXESUF): %.o $(EXEOBJS) $(FF_DEP_LIBS) + $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter %.o,$^) $(FF_DEP_LIBS) $(FFEXTRALIBS) $(ELIBS) + +testclean:: + $(RM) $(addprefix $(APITESTSDIR)/,$(CLEANSUFFIXES) *-test$(EXESUF)) diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/bswapdsp.c ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/bswapdsp.c --- ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/bswapdsp.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/bswapdsp.c 2015-07-26 17:20:03.000000000 +0000 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2015 Henrik Gramner + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 +#include "checkasm.h" +#include "libavcodec/bswapdsp.h" +#include "libavutil/common.h" +#include "libavutil/internal.h" +#include "libavutil/intreadwrite.h" + +#define BUF_SIZE 512 + +#define randomize_buffers() \ + do { \ + int i; \ + for (i = 0; i < BUF_SIZE; i += 4) { \ + uint32_t r = rnd(); \ + AV_WN32A(src0 + i, r); \ + AV_WN32A(src1 + i, r); \ + r = rnd(); \ + AV_WN32A(dst0 + i, r); \ + AV_WN32A(dst1 + i, r); \ + } \ + } while (0) + +#define check_bswap(type) \ + do { \ + int w; \ + for (w = 0; w < BUF_SIZE / sizeof(type); w++) { \ + int offset = (BUF_SIZE / sizeof(type) - w) & 15; /* Test various alignments */ \ + randomize_buffers(); \ + call_ref((type *)dst0 + offset, (type *)src0 + offset, w); \ + call_new((type *)dst1 + offset, (type *)src1 + offset, w); \ + if (memcmp(src0, src1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE)) \ + fail(); \ + bench_new((type *)dst1 + offset, (type *)src1 + offset, w); \ + } \ + } while (0) + +void checkasm_check_bswapdsp(void) +{ + LOCAL_ALIGNED_16(uint8_t, src0, [BUF_SIZE]); + LOCAL_ALIGNED_16(uint8_t, src1, [BUF_SIZE]); + LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]); + LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]); + BswapDSPContext h; + + ff_bswapdsp_init(&h); + + if (check_func(h.bswap_buf, "bswap_buf")) + check_bswap(uint32_t); + + if (check_func(h.bswap16_buf, "bswap16_buf")) + check_bswap(uint16_t); + + report("bswap"); +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/checkasm.c ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/checkasm.c --- ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/checkasm.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/checkasm.c 2015-07-30 17:20:02.000000000 +0000 @@ -0,0 +1,507 @@ +/* + * Assembly testing and benchmarking tool + * Copyright (c) 2015 Henrik Gramner + * Copyright (c) 2008 Loren Merritt + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 +#include +#include +#include +#include "checkasm.h" +#include "libavutil/common.h" +#include "libavutil/cpu.h" +#include "libavutil/random_seed.h" + +#if HAVE_IO_H +#include +#endif + +#if ARCH_X86 +#include "libavutil/x86/cpu.h" +#endif + +#if HAVE_SETCONSOLETEXTATTRIBUTE +#include +#define COLOR_RED FOREGROUND_RED +#define COLOR_GREEN FOREGROUND_GREEN +#define COLOR_YELLOW (FOREGROUND_RED|FOREGROUND_GREEN) +#else +#define COLOR_RED 1 +#define COLOR_GREEN 2 +#define COLOR_YELLOW 3 +#endif + +#if HAVE_UNISTD_H +#include +#endif + +#if !HAVE_ISATTY +#define isatty(fd) 1 +#endif + +/* List of tests to invoke */ +static const struct { + const char *name; + void (*func)(void); +} tests[] = { +#if CONFIG_BSWAPDSP + { "bswapdsp", checkasm_check_bswapdsp }, +#endif +#if CONFIG_H264PRED + { "h264pred", checkasm_check_h264pred }, +#endif +#if CONFIG_H264QPEL + { "h264qpel", checkasm_check_h264qpel }, +#endif + { NULL } +}; + +/* List of cpu flags to check */ +static const struct { + const char *name; + const char *suffix; + int flag; +} cpus[] = { +#if ARCH_AARCH64 + { "ARMV8", "armv8", AV_CPU_FLAG_ARMV8 }, + { "NEON", "neon", AV_CPU_FLAG_NEON }, +#elif ARCH_ARM + { "ARMV5TE", "armv5te", AV_CPU_FLAG_ARMV5TE }, + { "ARMV6", "armv6", AV_CPU_FLAG_ARMV6 }, + { "ARMV6T2", "armv6t2", AV_CPU_FLAG_ARMV6T2 }, + { "VFP", "vfp", AV_CPU_FLAG_VFP }, + { "VFPV3", "vfp3", AV_CPU_FLAG_VFPV3 }, + { "NEON", "neon", AV_CPU_FLAG_NEON }, +#elif ARCH_PPC + { "ALTIVEC", "altivec", AV_CPU_FLAG_ALTIVEC }, + { "VSX", "vsx", AV_CPU_FLAG_VSX }, + { "POWER8", "power8", AV_CPU_FLAG_POWER8 }, +#elif ARCH_X86 + { "MMX", "mmx", AV_CPU_FLAG_MMX|AV_CPU_FLAG_CMOV }, + { "MMXEXT", "mmxext", AV_CPU_FLAG_MMXEXT }, + { "3DNOW", "3dnow", AV_CPU_FLAG_3DNOW }, + { "3DNOWEXT", "3dnowext", AV_CPU_FLAG_3DNOWEXT }, + { "SSE", "sse", AV_CPU_FLAG_SSE }, + { "SSE2", "sse2", AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW }, + { "SSE3", "sse3", AV_CPU_FLAG_SSE3|AV_CPU_FLAG_SSE3SLOW }, + { "SSSE3", "ssse3", AV_CPU_FLAG_SSSE3|AV_CPU_FLAG_ATOM }, + { "SSE4.1", "sse4", AV_CPU_FLAG_SSE4 }, + { "SSE4.2", "sse42", AV_CPU_FLAG_SSE42 }, + { "AVX", "avx", AV_CPU_FLAG_AVX }, + { "XOP", "xop", AV_CPU_FLAG_XOP }, + { "FMA3", "fma3", AV_CPU_FLAG_FMA3 }, + { "FMA4", "fma4", AV_CPU_FLAG_FMA4 }, + { "AVX2", "avx2", AV_CPU_FLAG_AVX2 }, +#endif + { NULL } +}; + +typedef struct CheckasmFuncVersion { + struct CheckasmFuncVersion *next; + intptr_t (*func)(); + int ok; + int cpu; + int iterations; + uint64_t cycles; +} CheckasmFuncVersion; + +/* Binary search tree node */ +typedef struct CheckasmFunc { + struct CheckasmFunc *child[2]; + CheckasmFuncVersion versions; + char name[1]; +} CheckasmFunc; + +/* Internal state */ +static struct { + CheckasmFunc *funcs; + CheckasmFunc *current_func; + CheckasmFuncVersion *current_func_ver; + const char *current_test_name; + const char *bench_pattern; + int bench_pattern_len; + int num_checked; + int num_failed; + int nop_time; + int cpu_flag; + const char *cpu_flag_name; +} state; + +/* PRNG state */ +AVLFG checkasm_lfg; + +/* Print colored text to stderr if the terminal supports it */ +static void color_printf(int color, const char *fmt, ...) +{ + static int use_color = -1; + va_list arg; + +#if HAVE_SETCONSOLETEXTATTRIBUTE + static HANDLE con; + static WORD org_attributes; + + if (use_color < 0) { + CONSOLE_SCREEN_BUFFER_INFO con_info; + con = GetStdHandle(STD_ERROR_HANDLE); + if (con && con != INVALID_HANDLE_VALUE && GetConsoleScreenBufferInfo(con, &con_info)) { + org_attributes = con_info.wAttributes; + use_color = 1; + } else + use_color = 0; + } + if (use_color) + SetConsoleTextAttribute(con, (org_attributes & 0xfff0) | (color & 0x0f)); +#else + if (use_color < 0) { + const char *term = getenv("TERM"); + use_color = term && strcmp(term, "dumb") && isatty(2); + } + if (use_color) + fprintf(stderr, "\x1b[%d;3%dm", (color & 0x08) >> 3, color & 0x07); +#endif + + va_start(arg, fmt); + vfprintf(stderr, fmt, arg); + va_end(arg); + + if (use_color) { +#if HAVE_SETCONSOLETEXTATTRIBUTE + SetConsoleTextAttribute(con, org_attributes); +#else + fprintf(stderr, "\x1b[0m"); +#endif + } +} + +/* Deallocate a tree */ +static void destroy_func_tree(CheckasmFunc *f) +{ + if (f) { + CheckasmFuncVersion *v = f->versions.next; + while (v) { + CheckasmFuncVersion *next = v->next; + free(v); + v = next; + } + + destroy_func_tree(f->child[0]); + destroy_func_tree(f->child[1]); + free(f); + } +} + +/* Allocate a zero-initialized block, clean up and exit on failure */ +static void *checkasm_malloc(size_t size) +{ + void *ptr = calloc(1, size); + if (!ptr) { + fprintf(stderr, "checkasm: malloc failed\n"); + destroy_func_tree(state.funcs); + exit(1); + } + return ptr; +} + +/* Get the suffix of the specified cpu flag */ +static const char *cpu_suffix(int cpu) +{ + int i = FF_ARRAY_ELEMS(cpus); + + while (--i >= 0) + if (cpu & cpus[i].flag) + return cpus[i].suffix; + + return "c"; +} + +#ifdef AV_READ_TIME +static int cmp_nop(const void *a, const void *b) +{ + return *(const uint16_t*)a - *(const uint16_t*)b; +} + +/* Measure the overhead of the timing code (in decicycles) */ +static int measure_nop_time(void) +{ + uint16_t nops[10000]; + int i, nop_sum = 0; + + for (i = 0; i < 10000; i++) { + uint64_t t = AV_READ_TIME(); + nops[i] = AV_READ_TIME() - t; + } + + qsort(nops, 10000, sizeof(uint16_t), cmp_nop); + for (i = 2500; i < 7500; i++) + nop_sum += nops[i]; + + return nop_sum / 500; +} + +/* Print benchmark results */ +static void print_benchs(CheckasmFunc *f) +{ + if (f) { + print_benchs(f->child[0]); + + /* Only print functions with at least one assembly version */ + if (f->versions.cpu || f->versions.next) { + CheckasmFuncVersion *v = &f->versions; + do { + if (v->iterations) { + int decicycles = (10*v->cycles/v->iterations - state.nop_time) / 4; + printf("%s_%s: %d.%d\n", f->name, cpu_suffix(v->cpu), decicycles/10, decicycles%10); + } + } while ((v = v->next)); + } + + print_benchs(f->child[1]); + } +} +#endif + +/* ASCIIbetical sort except preserving natural order for numbers */ +static int cmp_func_names(const char *a, const char *b) +{ + int ascii_diff, digit_diff; + + for (; !(ascii_diff = *a - *b) && *a; a++, b++); + for (; av_isdigit(*a) && av_isdigit(*b); a++, b++); + + return (digit_diff = av_isdigit(*a) - av_isdigit(*b)) ? digit_diff : ascii_diff; +} + +/* Get a node with the specified name, creating it if it doesn't exist */ +static CheckasmFunc *get_func(const char *name, int length) +{ + CheckasmFunc *f, **f_ptr = &state.funcs; + + /* Search the tree for a matching node */ + while ((f = *f_ptr)) { + int cmp = cmp_func_names(name, f->name); + if (!cmp) + return f; + + f_ptr = &f->child[(cmp > 0)]; + } + + /* Allocate and insert a new node into the tree */ + f = *f_ptr = checkasm_malloc(sizeof(CheckasmFunc) + length); + memcpy(f->name, name, length+1); + + return f; +} + +/* Perform tests and benchmarks for the specified cpu flag if supported by the host */ +static void check_cpu_flag(const char *name, int flag) +{ + int old_cpu_flag = state.cpu_flag; + + flag |= old_cpu_flag; + av_set_cpu_flags_mask(flag); + state.cpu_flag = av_get_cpu_flags(); + + if (!flag || state.cpu_flag != old_cpu_flag) { + int i; + + state.cpu_flag_name = name; + for (i = 0; tests[i].func; i++) { + state.current_test_name = tests[i].name; + tests[i].func(); + } + } +} + +/* Print the name of the current CPU flag, but only do it once */ +static void print_cpu_name(void) +{ + if (state.cpu_flag_name) { + color_printf(COLOR_YELLOW, "%s:\n", state.cpu_flag_name); + state.cpu_flag_name = NULL; + } +} + +int main(int argc, char *argv[]) +{ + int i, seed, ret = 0; + + if (!tests[0].func || !cpus[0].flag) { + fprintf(stderr, "checkasm: no tests to perform\n"); + return 0; + } + + if (argc > 1 && !strncmp(argv[1], "--bench", 7)) { +#ifndef AV_READ_TIME + fprintf(stderr, "checkasm: --bench is not supported on your system\n"); + return 1; +#endif + if (argv[1][7] == '=') { + state.bench_pattern = argv[1] + 8; + state.bench_pattern_len = strlen(state.bench_pattern); + } else + state.bench_pattern = ""; + + argc--; + argv++; + } + + seed = (argc > 1) ? atoi(argv[1]) : av_get_random_seed(); + fprintf(stderr, "checkasm: using random seed %u\n", seed); + av_lfg_init(&checkasm_lfg, seed); + + check_cpu_flag(NULL, 0); + for (i = 0; cpus[i].flag; i++) + check_cpu_flag(cpus[i].name, cpus[i].flag); + + if (state.num_failed) { + fprintf(stderr, "checkasm: %d of %d tests have failed\n", state.num_failed, state.num_checked); + ret = 1; + } else { + fprintf(stderr, "checkasm: all %d tests passed\n", state.num_checked); +#ifdef AV_READ_TIME + if (state.bench_pattern) { + state.nop_time = measure_nop_time(); + printf("nop: %d.%d\n", state.nop_time/10, state.nop_time%10); + print_benchs(state.funcs); + } +#endif + } + + destroy_func_tree(state.funcs); + return ret; +} + +/* Decide whether or not the specified function needs to be tested and + * allocate/initialize data structures if needed. Returns a pointer to a + * reference function if the function should be tested, otherwise NULL */ +intptr_t (*checkasm_check_func(intptr_t (*func)(), const char *name, ...))() +{ + char name_buf[256]; + intptr_t (*ref)() = func; + CheckasmFuncVersion *v; + int name_length; + va_list arg; + + va_start(arg, name); + name_length = vsnprintf(name_buf, sizeof(name_buf), name, arg); + va_end(arg); + + if (!func || name_length <= 0 || name_length >= sizeof(name_buf)) + return NULL; + + state.current_func = get_func(name_buf, name_length); + v = &state.current_func->versions; + + if (v->func) { + CheckasmFuncVersion *prev; + do { + /* Only test functions that haven't already been tested */ + if (v->func == func) + return NULL; + + if (v->ok) + ref = v->func; + + prev = v; + } while ((v = v->next)); + + v = prev->next = checkasm_malloc(sizeof(CheckasmFuncVersion)); + } + + v->func = func; + v->ok = 1; + v->cpu = state.cpu_flag; + state.current_func_ver = v; + + if (state.cpu_flag) + state.num_checked++; + + return ref; +} + +/* Decide whether or not the current function needs to be benchmarked */ +int checkasm_bench_func(void) +{ + return !state.num_failed && state.bench_pattern && + !strncmp(state.current_func->name, state.bench_pattern, state.bench_pattern_len); +} + +/* Indicate that the current test has failed */ +void checkasm_fail_func(const char *msg, ...) +{ + if (state.current_func_ver->cpu && state.current_func_ver->ok) { + va_list arg; + + print_cpu_name(); + fprintf(stderr, " %s_%s (", state.current_func->name, cpu_suffix(state.current_func_ver->cpu)); + va_start(arg, msg); + vfprintf(stderr, msg, arg); + va_end(arg); + fprintf(stderr, ")\n"); + + state.current_func_ver->ok = 0; + state.num_failed++; + } +} + +/* Update benchmark results of the current function */ +void checkasm_update_bench(int iterations, uint64_t cycles) +{ + state.current_func_ver->iterations += iterations; + state.current_func_ver->cycles += cycles; +} + +/* Print the outcome of all tests performed since the last time this function was called */ +void checkasm_report(const char *name, ...) +{ + static int prev_checked, prev_failed, max_length; + + if (state.num_checked > prev_checked) { + int pad_length = max_length + 4; + va_list arg; + + print_cpu_name(); + pad_length -= fprintf(stderr, " - %s.", state.current_test_name); + va_start(arg, name); + pad_length -= vfprintf(stderr, name, arg); + va_end(arg); + fprintf(stderr, "%*c", FFMAX(pad_length, 0) + 2, '['); + + if (state.num_failed == prev_failed) + color_printf(COLOR_GREEN, "OK"); + else + color_printf(COLOR_RED, "FAILED"); + fprintf(stderr, "]\n"); + + prev_checked = state.num_checked; + prev_failed = state.num_failed; + } else if (!state.cpu_flag) { + /* Calculate the amount of padding required to make the output vertically aligned */ + int length = strlen(state.current_test_name); + va_list arg; + + va_start(arg, name); + length += vsnprintf(NULL, 0, name, arg); + va_end(arg); + + if (length > max_length) + max_length = length; + } +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/checkasm.h ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/checkasm.h --- ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/checkasm.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/checkasm.h 2015-07-27 17:20:04.000000000 +0000 @@ -0,0 +1,117 @@ +/* + * Assembly testing and benchmarking tool + * Copyright (c) 2015 Henrik Gramner + * Copyright (c) 2008 Loren Merritt + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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. + */ + +#ifndef CHECKASM_H +#define CHECKASM_H + +#include +#include "config.h" +#include "libavutil/avstring.h" +#include "libavutil/lfg.h" +#include "libavutil/timer.h" + +void checkasm_check_bswapdsp(void); +void checkasm_check_h264pred(void); +void checkasm_check_h264qpel(void); + +intptr_t (*checkasm_check_func(intptr_t (*func)(), const char *name, ...))() av_printf_format(2, 3); +int checkasm_bench_func(void); +void checkasm_fail_func(const char *msg, ...) av_printf_format(1, 2); +void checkasm_update_bench(int iterations, uint64_t cycles); +void checkasm_report(const char *name, ...) av_printf_format(1, 2); + +extern AVLFG checkasm_lfg; +#define rnd() av_lfg_get(&checkasm_lfg) + +static av_unused intptr_t (*func_ref)(); +static av_unused intptr_t (*func_new)(); + +#define BENCH_RUNS 1000 /* Trade-off between accuracy and speed */ + +/* Decide whether or not the specified function needs to be tested */ +#define check_func(func, ...) ((func_new = (intptr_t (*)())func) &&\ + (func_ref = checkasm_check_func(func_new, __VA_ARGS__))) + +/* Indicate that the current test has failed */ +#define fail() checkasm_fail_func("%s:%d", av_basename(__FILE__), __LINE__) + +/* Print the test outcome */ +#define report checkasm_report + +/* Call the reference function */ +#define call_ref(...) func_ref(__VA_ARGS__) + +#if ARCH_X86 && HAVE_YASM +/* Verifies that clobbered callee-saved registers are properly saved and restored */ +intptr_t checkasm_checked_call(intptr_t (*func)(), ...); +#endif + +/* Call the function */ +#if ARCH_X86_64 && HAVE_YASM +/* Evil hack: detect incorrect assumptions that 32-bit ints are zero-extended to 64-bit. + * This is done by clobbering the stack with junk around the stack pointer and calling the + * assembly function through x264_checkasm_call with added dummy arguments which forces all + * real arguments to be passed on the stack and not in registers. For 32-bit arguments the + * upper half of the 64-bit register locations on the stack will now contain junk which will + * cause misbehaving functions to either produce incorrect output or segfault. Note that + * even though this works extremely well in practice, it's technically not guaranteed + * and false negatives is theoretically possible, but there can never be any false positives. + */ +void checkasm_stack_clobber(uint64_t clobber, ...); +#define CLOB (UINT64_C(0xdeadbeefdeadbeef)) +#define call_new(...) (checkasm_stack_clobber(CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,\ + CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB),\ + checkasm_checked_call(func_new, 0, 0, 0, 0, 0, __VA_ARGS__)) +#elif ARCH_X86_32 && HAVE_YASM +#define call_new(...) checkasm_checked_call(func_new, __VA_ARGS__) +#else +#define call_new(...) func_new(__VA_ARGS__) +#endif + +/* Benchmark the function */ +#ifdef AV_READ_TIME +#define bench_new(...)\ + do {\ + if (checkasm_bench_func()) {\ + intptr_t (*tfunc)() = func_new;\ + uint64_t tsum = 0;\ + int ti, tcount = 0;\ + for (ti = 0; ti < BENCH_RUNS; ti++) {\ + uint64_t t = AV_READ_TIME();\ + tfunc(__VA_ARGS__);\ + tfunc(__VA_ARGS__);\ + tfunc(__VA_ARGS__);\ + tfunc(__VA_ARGS__);\ + t = AV_READ_TIME() - t;\ + if (t*tcount <= tsum*4 && ti > 0) {\ + tsum += t;\ + tcount++;\ + }\ + }\ + checkasm_update_bench(tcount, tsum);\ + }\ + } while (0) +#else +#define bench_new(...) while(0) +#endif + +#endif diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/h264pred.c ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/h264pred.c --- ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/h264pred.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/h264pred.c 2015-07-23 17:20:03.000000000 +0000 @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2015 Henrik Gramner + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 +#include "checkasm.h" +#include "libavcodec/avcodec.h" +#include "libavcodec/h264pred.h" +#include "libavutil/common.h" +#include "libavutil/internal.h" +#include "libavutil/intreadwrite.h" + +static const int codec_ids[4] = { AV_CODEC_ID_H264, AV_CODEC_ID_VP8, AV_CODEC_ID_RV40, AV_CODEC_ID_SVQ3 }; + +static const char * const pred4x4_modes[4][15] = { + { /* H264 */ + [VERT_PRED ] = "vertical", + [HOR_PRED ] = "horizontal", + [DC_PRED ] = "dc", + [DIAG_DOWN_LEFT_PRED ] = "down_left", + [DIAG_DOWN_RIGHT_PRED] = "down_right", + [VERT_RIGHT_PRED ] = "vertical_right", + [HOR_DOWN_PRED ] = "horizontal_right", + [VERT_LEFT_PRED ] = "vertical_left", + [HOR_UP_PRED ] = "horizontal_up", + [LEFT_DC_PRED ] = "left_dc", + [TOP_DC_PRED ] = "top_dc", + [DC_128_PRED ] = "dc_128", + }, + { /* VP8 */ + [VERT_PRED ] = "vertical_vp8", + [HOR_PRED ] = "horizontal_vp8", + [VERT_LEFT_PRED] = "vertical_left_vp8", + [TM_VP8_PRED ] = "tm_vp8", + [DC_127_PRED ] = "dc_127_vp8", + [DC_129_PRED ] = "dc_129_vp8", + }, + { /* RV40 */ + [DIAG_DOWN_LEFT_PRED ] = "down_left_rv40", + [VERT_LEFT_PRED ] = "vertical_left_rv40", + [HOR_UP_PRED ] = "horizontal_up_rv40", + [DIAG_DOWN_LEFT_PRED_RV40_NODOWN] = "down_left_nodown_rv40", + [HOR_UP_PRED_RV40_NODOWN ] = "horizontal_up_nodown_rv40", + [VERT_LEFT_PRED_RV40_NODOWN ] = "vertical_left_nodown_rv40", + }, + { /* SVQ3 */ + [DIAG_DOWN_LEFT_PRED] = "down_left_svq3", + }, +}; + +static const char * const pred8x8_modes[4][11] = { + { /* H264 */ + [DC_PRED8x8 ] = "dc", + [HOR_PRED8x8 ] = "horizontal", + [VERT_PRED8x8 ] = "vertical", + [PLANE_PRED8x8 ] = "plane", + [LEFT_DC_PRED8x8 ] = "left_dc", + [TOP_DC_PRED8x8 ] = "top_dc", + [DC_128_PRED8x8 ] = "dc_128", + [ALZHEIMER_DC_L0T_PRED8x8] = "mad_cow_dc_l0t", + [ALZHEIMER_DC_0LT_PRED8x8] = "mad_cow_dc_0lt", + [ALZHEIMER_DC_L00_PRED8x8] = "mad_cow_dc_l00", + [ALZHEIMER_DC_0L0_PRED8x8] = "mad_cow_dc_0l0", + }, + { /* VP8 */ + [PLANE_PRED8x8 ] = "tm_vp8", + [DC_127_PRED8x8] = "dc_127_vp8", + [DC_129_PRED8x8] = "dc_129_vp8", + }, + { /* RV40 */ + [DC_PRED8x8 ] = "dc_rv40", + [LEFT_DC_PRED8x8] = "left_dc_rv40", + [TOP_DC_PRED8x8 ] = "top_dc_rv40", + }, + /* nothing for SVQ3 */ +}; + +static const char * const pred16x16_modes[4][9] = { + { /* H264 */ + [DC_PRED8x8 ] = "dc", + [HOR_PRED8x8 ] = "horizontal", + [VERT_PRED8x8 ] = "vertical", + [PLANE_PRED8x8 ] = "plane", + [LEFT_DC_PRED8x8] = "left_dc", + [TOP_DC_PRED8x8 ] = "top_dc", + [DC_128_PRED8x8 ] = "dc_128", + }, + { /* VP8 */ + [PLANE_PRED8x8 ] = "tm_vp8", + [DC_127_PRED8x8] = "dc_127_vp8", + [DC_129_PRED8x8] = "dc_129_vp8", + }, + { /* RV40 */ + [PLANE_PRED8x8] = "plane_rv40", + }, + { /* SVQ3 */ + [PLANE_PRED8x8] = "plane_svq3", + }, +}; + +static const uint32_t pixel_mask[3] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff }; + +#define SIZEOF_PIXEL ((bit_depth + 7) / 8) +#define BUF_SIZE (3 * 16 * 17) + +#define check_pred_func(func, name, mode_name) \ + (mode_name && ((codec_ids[codec] == AV_CODEC_ID_H264) ? \ + check_func(func, "pred%s_%s_%d", name, mode_name, bit_depth) : \ + check_func(func, "pred%s_%s", name, mode_name))) + +#define randomize_buffers() \ + do { \ + uint32_t mask = pixel_mask[bit_depth - 8]; \ + int i; \ + for (i = 0; i < BUF_SIZE; i += 4) { \ + uint32_t r = rnd() & mask; \ + AV_WN32A(buf0 + i, r); \ + AV_WN32A(buf1 + i, r); \ + } \ + } while (0) + +#define src0 (buf0 + 4 * 16) /* Offset to allow room for top and left */ +#define src1 (buf1 + 4 * 16) + +static void check_pred4x4(H264PredContext *h, uint8_t *buf0, uint8_t *buf1, + int codec, int chroma_format, int bit_depth) +{ + if (chroma_format == 1) { + uint8_t *topright = buf0 + 2*16; + int pred_mode; + for (pred_mode = 0; pred_mode < 15; pred_mode++) { + if (check_pred_func(h->pred4x4[pred_mode], "4x4", pred4x4_modes[codec][pred_mode])) { + randomize_buffers(); + call_ref(src0, topright, (ptrdiff_t)12*SIZEOF_PIXEL); + call_new(src1, topright, (ptrdiff_t)12*SIZEOF_PIXEL); + if (memcmp(buf0, buf1, BUF_SIZE)) + fail(); + bench_new(src1, topright, (ptrdiff_t)12*SIZEOF_PIXEL); + } + } + } +} + +static void check_pred8x8(H264PredContext *h, uint8_t *buf0, uint8_t *buf1, + int codec, int chroma_format, int bit_depth) +{ + int pred_mode; + for (pred_mode = 0; pred_mode < 11; pred_mode++) { + if (check_pred_func(h->pred8x8[pred_mode], (chroma_format == 2) ? "8x16" : "8x8", + pred8x8_modes[codec][pred_mode])) { + randomize_buffers(); + call_ref(src0, (ptrdiff_t)24*SIZEOF_PIXEL); + call_new(src1, (ptrdiff_t)24*SIZEOF_PIXEL); + if (memcmp(buf0, buf1, BUF_SIZE)) + fail(); + bench_new(src1, (ptrdiff_t)24*SIZEOF_PIXEL); + } + } +} + +static void check_pred16x16(H264PredContext *h, uint8_t *buf0, uint8_t *buf1, + int codec, int chroma_format, int bit_depth) +{ + if (chroma_format == 1) { + int pred_mode; + for (pred_mode = 0; pred_mode < 9; pred_mode++) { + if (check_pred_func(h->pred16x16[pred_mode], "16x16", pred16x16_modes[codec][pred_mode])) { + randomize_buffers(); + call_ref(src0, (ptrdiff_t)48); + call_new(src1, (ptrdiff_t)48); + if (memcmp(buf0, buf1, BUF_SIZE)) + fail(); + bench_new(src1, (ptrdiff_t)48); + } + } + } +} + +static void check_pred8x8l(H264PredContext *h, uint8_t *buf0, uint8_t *buf1, + int codec, int chroma_format, int bit_depth) +{ + if (chroma_format == 1 && codec_ids[codec] == AV_CODEC_ID_H264) { + int pred_mode; + for (pred_mode = 0; pred_mode < 12; pred_mode++) { + if (check_pred_func(h->pred8x8l[pred_mode], "8x8l", pred4x4_modes[codec][pred_mode])) { + int neighbors; + for (neighbors = 0; neighbors <= 0xc000; neighbors += 0x4000) { + int has_topleft = neighbors & 0x8000; + int has_topright = neighbors & 0x4000; + + if ((pred_mode == DIAG_DOWN_RIGHT_PRED || pred_mode == VERT_RIGHT_PRED) && !has_topleft) + continue; /* Those aren't allowed according to the spec */ + + randomize_buffers(); + call_ref(src0, has_topleft, has_topright, (ptrdiff_t)24*SIZEOF_PIXEL); + call_new(src1, has_topleft, has_topright, (ptrdiff_t)24*SIZEOF_PIXEL); + if (memcmp(buf0, buf1, BUF_SIZE)) + fail(); + bench_new(src1, has_topleft, has_topright, (ptrdiff_t)24*SIZEOF_PIXEL); + } + } + } + } +} + +/* TODO: Add tests for H.264 lossless H/V prediction */ + +void checkasm_check_h264pred(void) +{ + static const struct { + void (*func)(H264PredContext*, uint8_t*, uint8_t*, int, int, int); + const char *name; + } tests[] = { + { check_pred4x4, "pred4x4" }, + { check_pred8x8, "pred8x8" }, + { check_pred16x16, "pred16x16" }, + { check_pred8x8l, "pred8x8l" }, + }; + + LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]); + LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]); + H264PredContext h; + int test, codec, chroma_format, bit_depth; + + for (test = 0; test < FF_ARRAY_ELEMS(tests); test++) { + for (codec = 0; codec < 4; codec++) { + int codec_id = codec_ids[codec]; + for (bit_depth = 8; bit_depth <= (codec_id == AV_CODEC_ID_H264 ? 10 : 8); bit_depth++) + for (chroma_format = 1; chroma_format <= (codec_id == AV_CODEC_ID_H264 ? 2 : 1); chroma_format++) { + ff_h264_pred_init(&h, codec_id, bit_depth, chroma_format); + tests[test].func(&h, buf0, buf1, codec, chroma_format, bit_depth); + } + } + report("%s", tests[test].name); + } +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/h264qpel.c ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/h264qpel.c --- ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/h264qpel.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/h264qpel.c 2015-07-27 17:20:04.000000000 +0000 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2015 Henrik Gramner + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 +#include "checkasm.h" +#include "libavcodec/h264qpel.h" +#include "libavutil/common.h" +#include "libavutil/internal.h" +#include "libavutil/intreadwrite.h" + +static const uint32_t pixel_mask[3] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff }; + +#define SIZEOF_PIXEL ((bit_depth + 7) / 8) +#define BUF_SIZE (2 * 16 * (16 + 3 + 4)) + +#define randomize_buffers() \ + do { \ + uint32_t mask = pixel_mask[bit_depth - 8]; \ + int k; \ + for (k = 0; k < BUF_SIZE; k += 4) { \ + uint32_t r = rnd() & mask; \ + AV_WN32A(buf0 + k, r); \ + AV_WN32A(buf1 + k, r); \ + r = rnd(); \ + AV_WN32A(dst0 + k, r); \ + AV_WN32A(dst1 + k, r); \ + } \ + } while (0) + +#define src0 (buf0 + 3 * 2 * 16) /* h264qpel functions read data from negative src pointer offsets */ +#define src1 (buf1 + 3 * 2 * 16) + +void checkasm_check_h264qpel(void) +{ + LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]); + LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]); + LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]); + LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]); + H264QpelContext h; + int op, bit_depth, i, j; + + for (op = 0; op < 2; op++) { + qpel_mc_func (*tab)[16] = op ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab; + const char *op_name = op ? "avg" : "put"; + + for (bit_depth = 8; bit_depth <= 10; bit_depth++) { + ff_h264qpel_init(&h, bit_depth); + for (i = 0; i < (op ? 3 : 4); i++) { + int size = 16 >> i; + for (j = 0; j < 16; j++) + if (check_func(tab[i][j], "%s_h264_qpel_%d_mc%d%d_%d", op_name, size, j & 3, j >> 2, bit_depth)) { + randomize_buffers(); + call_ref(dst0, src0, (ptrdiff_t)size * SIZEOF_PIXEL); + call_new(dst1, src1, (ptrdiff_t)size * SIZEOF_PIXEL); + if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE)) + fail(); + bench_new(dst1, src1, (ptrdiff_t)size * SIZEOF_PIXEL); + } + } + } + report("%s", op_name); + } +} diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/Makefile ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/Makefile --- ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/Makefile 2015-07-22 17:20:04.000000000 +0000 @@ -0,0 +1,35 @@ +# libavcodec tests +AVCODECOBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o +AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o +AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o + +CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes) + + +-include $(SRC_PATH)/tests/checkasm/$(ARCH)/Makefile + +CHECKASMOBJS += $(CHECKASMOBJS-yes) checkasm.o +CHECKASMOBJS := $(sort $(CHECKASMOBJS:%=tests/checkasm/%)) + +-include $(CHECKASMOBJS:.o=.d) + +CHECKASMDIRS := $(sort $(dir $(CHECKASMOBJS))) +$(CHECKASMOBJS): | $(CHECKASMDIRS) +OBJDIRS += $(CHECKASMDIRS) + +# We rely on function pointers intentionally declared without specified argument types. +tests/checkasm/%.o: CFLAGS := $(CFLAGS:-Wstrict-prototypes=-Wno-strict-prototypes) -Umain + +CHECKASM := tests/checkasm/checkasm$(EXESUF) + +$(CHECKASM): $(EXEOBJS) $(CHECKASMOBJS) $(FF_STATIC_DEP_LIBS) + $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(CHECKASMOBJS) $(FF_STATIC_DEP_LIBS) $(EXTRALIBS) + +checkasm: $(CHECKASM) + +clean:: checkasmclean + +checkasmclean: + $(RM) $(CHECKASM) $(CLEANSUFFIXES:%=tests/checkasm/%) $(CLEANSUFFIXES:%=tests/checkasm/$(ARCH)/%) + +.PHONY: checkasm diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/x86/checkasm.asm ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/x86/checkasm.asm --- ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/x86/checkasm.asm 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/x86/checkasm.asm 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,193 @@ +;***************************************************************************** +;* Assembly testing and benchmarking tool +;* Copyright (c) 2008 Loren Merritt +;* Copyright (c) 2012 Henrik Gramner +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or modify +;* it under the terms of the GNU General Public License as published by +;* the Free Software Foundation; either version 2 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 General Public License for more details. +;* +;* You should have received a copy of the GNU General Public License +;* along with this program; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. +;***************************************************************************** + +%define private_prefix checkasm +%include "libavutil/x86/x86inc.asm" + +SECTION_RODATA + +error_message: db "failed to preserve register", 0 + +%if ARCH_X86_64 +; just random numbers to reduce the chance of incidental match +ALIGN 16 +x6: dq 0x1a1b2550a612b48c,0x79445c159ce79064 +x7: dq 0x2eed899d5a28ddcd,0x86b2536fcd8cf636 +x8: dq 0xb0856806085e7943,0x3f2bf84fc0fcca4e +x9: dq 0xacbd382dcf5b8de2,0xd229e1f5b281303f +x10: dq 0x71aeaff20b095fd9,0xab63e2e11fa38ed9 +x11: dq 0x89b0c0765892729a,0x77d410d5c42c882d +x12: dq 0xc45ea11a955d8dd5,0x24b3c1d2a024048b +x13: dq 0x2e8ec680de14b47c,0xdd7b8919edd42786 +x14: dq 0x135ce6888fa02cbf,0x11e53e2b2ac655ef +x15: dq 0x011ff554472a7a10,0x6de8f4c914c334d5 +n7: dq 0x21f86d66c8ca00ce +n8: dq 0x75b6ba21077c48ad +n9: dq 0xed56bb2dcb3c7736 +n10: dq 0x8bda43d3fd1a7e06 +n11: dq 0xb64a9c9e5d318408 +n12: dq 0xdf9a54b303f1d3a3 +n13: dq 0x4a75479abd64e097 +n14: dq 0x249214109d5d1c88 +%endif + +SECTION .text + +cextern fail_func + +; max number of args used by any asm function. +; (max_args % 4) must equal 3 for stack alignment +%define max_args 15 + +%if ARCH_X86_64 + +;----------------------------------------------------------------------------- +; int checkasm_stack_clobber(uint64_t clobber, ...) +;----------------------------------------------------------------------------- +cglobal stack_clobber, 1,2 + ; Clobber the stack with junk below the stack pointer + %define size (max_args+6)*8 + SUB rsp, size + mov r1, size-8 +.loop: + mov [rsp+r1], r0 + sub r1, 8 + jge .loop + ADD rsp, size + RET + +%if WIN64 + %assign free_regs 7 +%else + %assign free_regs 9 +%endif + +;----------------------------------------------------------------------------- +; intptr_t checkasm_checked_call(intptr_t (*func)(), ...) +;----------------------------------------------------------------------------- +INIT_XMM +cglobal checked_call, 2,15,16,max_args*8+8 + mov r6, r0 + + ; All arguments have been pushed on the stack instead of registers in order to + ; test for incorrect assumptions that 32-bit ints are zero-extended to 64-bit. + mov r0, r6mp + mov r1, r7mp + mov r2, r8mp + mov r3, r9mp +%if UNIX64 + mov r4, r10mp + mov r5, r11mp + %assign i 6 + %rep max_args-6 + mov r9, [rsp+stack_offset+(i+1)*8] + mov [rsp+(i-6)*8], r9 + %assign i i+1 + %endrep +%else + %assign i 4 + %rep max_args-4 + mov r9, [rsp+stack_offset+(i+7)*8] + mov [rsp+i*8], r9 + %assign i i+1 + %endrep +%endif + +%if WIN64 + %assign i 6 + %rep 16-6 + mova m %+ i, [x %+ i] + %assign i i+1 + %endrep +%endif + +%assign i 14 +%rep 15-free_regs + mov r %+ i, [n %+ i] + %assign i i-1 +%endrep + call r6 +%assign i 14 +%rep 15-free_regs + xor r %+ i, [n %+ i] + or r14, r %+ i + %assign i i-1 +%endrep + +%if WIN64 + %assign i 6 + %rep 16-6 + pxor m %+ i, [x %+ i] + por m6, m %+ i + %assign i i+1 + %endrep + packsswb m6, m6 + movq r5, m6 + or r14, r5 +%endif + + jz .ok + mov r9, rax + lea r0, [error_message] + call fail_func + mov rax, r9 +.ok: + RET + +%else + +; just random numbers to reduce the chance of incidental match +%define n3 dword 0x6549315c +%define n4 dword 0xe02f3e23 +%define n5 dword 0xb78d0d1d +%define n6 dword 0x33627ba7 + +;----------------------------------------------------------------------------- +; intptr_t checkasm_checked_call(intptr_t (*func)(), ...) +;----------------------------------------------------------------------------- +cglobal checked_call, 1,7 + mov r3, n3 + mov r4, n4 + mov r5, n5 + mov r6, n6 +%rep max_args + PUSH dword [esp+20+max_args*4] +%endrep + call r0 + xor r3, n3 + xor r4, n4 + xor r5, n5 + xor r6, n6 + or r3, r4 + or r5, r6 + or r3, r5 + jz .ok + mov r3, eax + lea r0, [error_message] + mov [esp], r0 + call fail_func + mov eax, r3 +.ok: + add esp, max_args*4 + REP_RET + +%endif ; ARCH_X86_64 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/x86/Makefile ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/x86/Makefile --- ffmpeg-2.7.1~trusty~ppa1/tests/checkasm/x86/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/checkasm/x86/Makefile 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +CHECKASMOBJS-$(HAVE_YASM) += x86/checkasm.o + +tests/checkasm/x86/%.o: tests/checkasm/x86/%.asm + $(DEPYASM) $(YASMFLAGS) -I $( $(@:.o=.d) + $(YASM) $(YASMFLAGS) -I $( front channel FATE_AC3 += fate-ac3-4.0-downmix-mono -fate-ac3-4.0-downmix-mono: CMD = pcm -request_channels 1 -i $(TARGET_SAMPLES)/ac3/millers_crossing_4.0.ac3 +fate-ac3-4.0-downmix-mono: CMD = pcm -request_channel_layout 4 -i $(TARGET_SAMPLES)/ac3/millers_crossing_4.0.ac3 fate-ac3-4.0-downmix-mono: REF = $(SAMPLES)/ac3/millers_crossing_4.0_mono_v2.pcm +#request_channel_layout 3 -> left channel + right channel FATE_AC3 += fate-ac3-4.0-downmix-stereo -fate-ac3-4.0-downmix-stereo: CMD = pcm -request_channels 2 -i $(TARGET_SAMPLES)/ac3/millers_crossing_4.0.ac3 +fate-ac3-4.0-downmix-stereo: CMD = pcm -request_channel_layout 3 -i $(TARGET_SAMPLES)/ac3/millers_crossing_4.0.ac3 fate-ac3-4.0-downmix-stereo: REF = $(SAMPLES)/ac3/millers_crossing_4.0_stereo_v2.pcm FATE_AC3 += fate-ac3-5.1 @@ -19,11 +21,11 @@ fate-ac3-5.1: REF = $(SAMPLES)/ac3/monsters_inc_5.1_448_small_v2.pcm FATE_AC3 += fate-ac3-5.1-downmix-mono -fate-ac3-5.1-downmix-mono: CMD = pcm -request_channels 1 -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3 +fate-ac3-5.1-downmix-mono: CMD = pcm -request_channel_layout 4 -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3 fate-ac3-5.1-downmix-mono: REF = $(SAMPLES)/ac3/monsters_inc_5.1_448_small_mono_v2.pcm FATE_AC3 += fate-ac3-5.1-downmix-stereo -fate-ac3-5.1-downmix-stereo: CMD = pcm -request_channels 2 -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3 +fate-ac3-5.1-downmix-stereo: CMD = pcm -request_channel_layout 3 -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3 fate-ac3-5.1-downmix-stereo: REF = $(SAMPLES)/ac3/monsters_inc_5.1_448_small_stereo_v2.pcm FATE_AC3 += fate-ac3-fixed-2.0 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/acodec.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/acodec.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/acodec.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/acodec.mak 2015-08-04 17:20:03.000000000 +0000 @@ -103,7 +103,7 @@ fate-acodec-dca: SRC = tests/data/asynth-44100-2.wav fate-acodec-dca: CMD = md5 -i $(TARGET_PATH)/$(SRC) -c:a dca -strict -2 -f dts -flags +bitexact fate-acodec-dca: CMP = oneline -fate-acodec-dca: REF = fe28cef432ed88de4ee01b87537fd2bd +fate-acodec-dca: REF = c54ca9a13711755ef90fa143a9b38386 FATE_ACODEC-$(call ENCDEC, DCA, WAV) += fate-acodec-dca2 fate-acodec-dca2: CMD = enc_dec_pcm dts wav s16le $(SRC) -c:a dca -strict -2 -flags +bitexact diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/api.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/api.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/api.mak 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/api.mak 2015-07-04 21:09:16.000000000 +0000 @@ -0,0 +1,23 @@ +FATE_API_LIBAVCODEC-$(call ENCDEC, FLAC, FLAC) += fate-api-flac +fate-api-flac: $(APITESTSDIR)/api-flac-test$(EXESUF) +fate-api-flac: CMD = run $(APITESTSDIR)/api-flac-test +fate-api-flac: CMP = null +fate-api-flac: REF = /dev/null + +FATE_API_SAMPLES_LIBAVFORMAT-$(call DEMDEC, H264, H264) += fate-api-h264 +fate-api-h264: $(APITESTSDIR)/api-h264-test$(EXESUF) +fate-api-h264: CMD = run $(APITESTSDIR)/api-h264-test $(TARGET_SAMPLES)/h264-conformance/SVA_NL2_E.264 + +FATE_API_SAMPLES-$(CONFIG_AVFORMAT) += $(FATE_API_SAMPLES_LIBAVFORMAT-yes) + +ifdef SAMPLES + FATE_API_SAMPLES += $(FATE_API_SAMPLES-yes) +endif + +FATE_API-$(CONFIG_AVCODEC) += $(FATE_API_LIBAVCODEC-yes) +FATE_API-$(CONFIG_AVFORMAT) += $(FATE_API_LIBAVFORMAT-yes) +FATE_API = $(FATE_API-yes) + +FATE-yes += $(FATE_API) $(FATE_API_SAMPLES) + +fate-api: $(FATE_API) $(FATE_API_SAMPLES) diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/checkasm.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/checkasm.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/checkasm.mak 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/checkasm.mak 2015-07-18 17:20:03.000000000 +0000 @@ -0,0 +1,5 @@ +fate-checkasm: tests/checkasm/checkasm$(EXESUF) +fate-checkasm: CMD = run tests/checkasm/checkasm +fate-checkasm: REF = /dev/null + +FATE += fate-checkasm diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/demux.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/demux.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/demux.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/demux.mak 2015-06-26 17:20:02.000000000 +0000 @@ -13,6 +13,10 @@ FATE_SAMPLES_DEMUX-$(CONFIG_BINK_DEMUXER) += fate-bink-demux fate-bink-demux: CMD = crc -i $(TARGET_SAMPLES)/bink/Snd0a7d9b58.dee -vn -acodec copy +FATE_SAMPLES_DEMUX-$(CONFIG_BFSTM_DEMUXER) += fate-bfstm fate-bcstm +fate-bfstm: CMD = crc -i $(TARGET_SAMPLES)/bfstm/spl-forest-day.bfstm -acodec copy +fate-bcstm: CMD = crc -i $(TARGET_SAMPLES)/bfstm/loz-mm-mikau.bcstm -acodec copy + FATE_SAMPLES_DEMUX-$(CONFIG_BRSTM_DEMUXER) += fate-brstm fate-brstm: CMD = crc -i $(TARGET_SAMPLES)/brstm/lozswd_partial.brstm -acodec copy @@ -28,6 +32,9 @@ FATE_SAMPLES_DEMUX-$(CONFIG_DAUD_DEMUXER) += fate-d-cinema-demux fate-d-cinema-demux: CMD = framecrc -i $(TARGET_SAMPLES)/d-cinema/THX_Science_FLT_1920-partial.302 -acodec copy +FATE_SAMPLES_DEMUX-$(CONFIG_EA_DEMUXER) += fate-d-eavp6-demux +fate-d-eavp6-demux: CMD = framecrc -i $(TARGET_SAMPLES)/ea-vp6/SmallRing.vp6 -map 0 -vcodec copy + FATE_SAMPLES_DEMUX-$(CONFIG_GIF_DEMUXER) += fate-gif-demux fate-gif-demux: CMD = framecrc -i $(TARGET_SAMPLES)/gif/Newtons_cradle_animation_book_2.gif -vcodec copy diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/ffprobe.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/ffprobe.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/ffprobe.mak 2015-03-13 17:34:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/ffprobe.mak 2015-07-23 17:20:03.000000000 +0000 @@ -1,33 +1,35 @@ FFPROBE_TEST_FILE=tests/data/ffprobe-test.nut FFPROBE_COMMAND=ffprobe$(EXESUF) -show_streams -show_packets -show_format -show_frames -bitexact $(FFPROBE_TEST_FILE) -FATE_FFPROBE += fate-ffprobe_compact +FATE_FFPROBE-$(CONFIG_AVDEVICE) += fate-ffprobe_compact fate-ffprobe_compact: $(FFPROBE_TEST_FILE) fate-ffprobe_compact: CMD = run $(FFPROBE_COMMAND) -of compact -FATE_FFPROBE += fate-ffprobe_csv +FATE_FFPROBE-$(CONFIG_AVDEVICE) += fate-ffprobe_csv fate-ffprobe_csv: $(FFPROBE_TEST_FILE) fate-ffprobe_csv: CMD = run $(FFPROBE_COMMAND) -of csv -FATE_FFPROBE += fate-ffprobe_default +FATE_FFPROBE-$(CONFIG_AVDEVICE) += fate-ffprobe_default fate-ffprobe_default: $(FFPROBE_TEST_FILE) fate-ffprobe_default: CMD = run $(FFPROBE_COMMAND) -of default -FATE_FFPROBE += fate-ffprobe_flat +FATE_FFPROBE-$(CONFIG_AVDEVICE) += fate-ffprobe_flat fate-ffprobe_flat: $(FFPROBE_TEST_FILE) fate-ffprobe_flat: CMD = run $(FFPROBE_COMMAND) -of flat -FATE_FFPROBE += fate-ffprobe_ini +FATE_FFPROBE-$(CONFIG_AVDEVICE) += fate-ffprobe_ini fate-ffprobe_ini: $(FFPROBE_TEST_FILE) fate-ffprobe_ini: CMD = run $(FFPROBE_COMMAND) -of ini -FATE_FFPROBE += fate-ffprobe_json +FATE_FFPROBE-$(CONFIG_AVDEVICE) += fate-ffprobe_json fate-ffprobe_json: $(FFPROBE_TEST_FILE) fate-ffprobe_json: CMD = run $(FFPROBE_COMMAND) -of json -FATE_FFPROBE += fate-ffprobe_xml +FATE_FFPROBE-$(CONFIG_AVDEVICE) += fate-ffprobe_xml fate-ffprobe_xml: $(FFPROBE_TEST_FILE) fate-ffprobe_xml: CMD = run $(FFPROBE_COMMAND) -of xml +FATE_FFPROBE += $(FATE_FFPROBE-yes) + fate-ffprobe: $(FATE_FFPROBE) diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/filter-audio.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/filter-audio.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/filter-audio.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/filter-audio.mak 2015-06-20 17:20:02.000000000 +0000 @@ -92,5 +92,9 @@ fate-filter-volume: CMP = oneline fate-filter-volume: REF = 4d6ba75ef3e32d305d066b9bc771d6f4 +FATE_AFILTER-yes += fate-filter-formats +fate-filter-formats: libavfilter/formats-test$(EXESUF) +fate-filter-formats: CMD = run libavfilter/formats-test + FATE_SAMPLES_AVCONV += $(FATE_AFILTER-yes) fate-afilter: $(FATE_AFILTER-yes) diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/filter-video.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/filter-video.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/filter-video.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/filter-video.mak 2015-07-19 17:20:03.000000000 +0000 @@ -15,6 +15,14 @@ FATE_FILTER-$(call FILTERDEMDEC, YADIF, MPEGTS, MPEG2VIDEO) += $(FATE_YADIF) +FATE_W3FDIF += fate-filter-w3fdif-simple +fate-filter-w3fdif-simple: CMD = framecrc -flags bitexact -idct simple -i $(TARGET_SAMPLES)/mpeg2/mpeg2_field_encoding.ts -vframes 30 -vf w3fdif=0 + +FATE_W3FDIF += fate-filter-w3fdif-complex +fate-filter-w3fdif-complex: CMD = framecrc -flags bitexact -idct simple -i $(TARGET_SAMPLES)/mpeg2/mpeg2_field_encoding.ts -vframes 30 -vf w3fdif=1 + +FATE_FILTER-$(call FILTERDEMDEC, W3FDIF, MPEGTS, MPEG2VIDEO) += $(FATE_W3FDIF) + FATE_MCDEINT += fate-filter-mcdeint-fast fate-filter-mcdeint-fast: CMD = framecrc -flags bitexact -idct simple -i $(TARGET_SAMPLES)/mpeg2/mpeg2_field_encoding.ts -vframes 30 -vf mcdeint=fast @@ -106,6 +114,10 @@ FATE_FILTER_VSYNTH-$(CONFIG_HISTOGRAM_FILTER) += fate-filter-histogram-waveform fate-filter-histogram-waveform: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf format=yuv444p,histogram=mode=waveform -flags +bitexact -sws_flags +accurate_rnd+bitexact +FATE_FILTER_VSYNTH-$(CONFIG_MERGEPLANES_FILTER) += fate-filter-mergeplanes +fate-filter-mergeplanes: tests/data/filtergraphs/mergeplanes +fate-filter-mergeplanes: CMD = framecrc -c:v pgmyuv -i $(SRC) -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/mergeplanes + FATE_FILTER_VSYNTH-$(CONFIG_OVERLAY_FILTER) += fate-filter-overlay fate-filter-overlay: tests/data/filtergraphs/overlay fate-filter-overlay: CMD = framecrc -c:v pgmyuv -i $(SRC) -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay @@ -129,6 +141,84 @@ FATE_FILTER_VSYNTH-$(CONFIG_PHASE_FILTER) += fate-filter-phase fate-filter-phase: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf phase +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-00 +fate-filter-removegrain-mode-00: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=0:0:0 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-01 +fate-filter-removegrain-mode-01: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=1:1:1 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-02 +fate-filter-removegrain-mode-02: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=2:2:2 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-03 +fate-filter-removegrain-mode-03: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=3:3:3 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-04 +fate-filter-removegrain-mode-04: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=4:4:4 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-05 +fate-filter-removegrain-mode-05: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=5:5:5 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-06 +fate-filter-removegrain-mode-06: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=6:6:6 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-07 +fate-filter-removegrain-mode-07: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=7:7:7 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-08 +fate-filter-removegrain-mode-08: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=8:8:8 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-09 +fate-filter-removegrain-mode-09: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=9:9:9 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-10 +fate-filter-removegrain-mode-10: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=10:10:10 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-11 +fate-filter-removegrain-mode-11: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=11:11:11 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-12 +fate-filter-removegrain-mode-12: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=12:12:12 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-13 +fate-filter-removegrain-mode-13: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=13:13:13 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-14 +fate-filter-removegrain-mode-14: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=14:14:14 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-15 +fate-filter-removegrain-mode-15: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=15:15:15 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-16 +fate-filter-removegrain-mode-16: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=16:16:16 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-17 +fate-filter-removegrain-mode-17: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=17:17:17 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-18 +fate-filter-removegrain-mode-18: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=18:18:18 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-19 +fate-filter-removegrain-mode-19: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=19:19:19 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-20 +fate-filter-removegrain-mode-20: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=20:20:20 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-21 +fate-filter-removegrain-mode-21: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=21:21:21 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-22 +fate-filter-removegrain-mode-22: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=22:22:22 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-23 +fate-filter-removegrain-mode-23: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=23:23:23 + +FATE_REMOVEGRAIN += fate-filter-removegrain-mode-24 +fate-filter-removegrain-mode-24: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 1 -vf removegrain=24:24:24 + +fate-filter-removegrain: $(FATE_REMOVEGRAIN) +FATE_FILTER_VSYNTH-$(CONFIG_REMOVEGRAIN_FILTER) += $(FATE_REMOVEGRAIN) + FATE_FILTER_VSYNTH-$(CONFIG_SEPARATEFIELDS_FILTER) += fate-filter-separatefields fate-filter-separatefields: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf separatefields @@ -148,6 +238,9 @@ FATE_FILTER_VSYNTH-$(CONFIG_SHUFFLEPLANES_FILTER) += $(FATE_SHUFFLEPLANES) +FATE_FILTER_VSYNTH-$(CONFIG_TBLEND_FILTER) += fate-filter-tblend +fate-filter-tblend: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf tblend=all_mode=difference128 + FATE_FILTER_VSYNTH-$(CONFIG_TELECINE_FILTER) += fate-filter-telecine fate-filter-telecine: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf telecine @@ -307,6 +400,49 @@ FATE_STEREO3D += fate-filter-stereo3d-sbsl-sbsr fate-filter-stereo3d-sbsl-sbsr: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:sbsr +FATE_STEREO3D += fate-filter-stereo3d-sbsl-agmc +fate-filter-stereo3d-sbsl-agmc: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:agmc + +FATE_STEREO3D += fate-filter-stereo3d-sbsl-agmd +fate-filter-stereo3d-sbsl-agmd: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:agmd + +FATE_STEREO3D += fate-filter-stereo3d-sbsl-agmg +fate-filter-stereo3d-sbsl-agmg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:agmg + +FATE_STEREO3D += fate-filter-stereo3d-sbsl-agmh +fate-filter-stereo3d-sbsl-agmh: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:agmh + +FATE_STEREO3D += fate-filter-stereo3d-sbsl-arbg +fate-filter-stereo3d-sbsl-arbg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arbg + +FATE_STEREO3D += fate-filter-stereo3d-sbsl-arcc +fate-filter-stereo3d-sbsl-arcc: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arcc + +FATE_STEREO3D += fate-filter-stereo3d-sbsl-arcd +fate-filter-stereo3d-sbsl-arcd: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arcd + +FATE_STEREO3D += fate-filter-stereo3d-sbsl-arcg +fate-filter-stereo3d-sbsl-arcg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arcg + +FATE_STEREO3D += fate-filter-stereo3d-sbsl-arch +fate-filter-stereo3d-sbsl-arch: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arch + +FATE_STEREO3D += fate-filter-stereo3d-sbsl-argg +fate-filter-stereo3d-sbsl-argg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:argg + +FATE_STEREO3D += fate-filter-stereo3d-sbsl-aybc +fate-filter-stereo3d-sbsl-aybc: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:aybc + +FATE_STEREO3D += fate-filter-stereo3d-sbsl-aybd +fate-filter-stereo3d-sbsl-aybd: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:aybd + +FATE_STEREO3D += fate-filter-stereo3d-sbsl-aybg +fate-filter-stereo3d-sbsl-aybg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:aybg + +FATE_STEREO3D += fate-filter-stereo3d-sbsl-aybh +fate-filter-stereo3d-sbsl-aybh: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:aybh + +fate-filter-stereo3d: $(FATE_STEREO3D) FATE_FILTER_VSYNTH-$(CONFIG_STEREO3D_FILTER) += $(FATE_STEREO3D) FATE_FILTER_VSYNTH-$(CONFIG_THUMBNAIL_FILTER) += fate-filter-thumbnail diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/flac.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/flac.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/flac.mak 2015-03-15 02:46:06.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/flac.mak 2015-06-18 17:20:02.000000000 +0000 @@ -6,6 +6,7 @@ fate-flac-16-lpc-cholesky \ fate-flac-16-lpc-levinson \ fate-flac-24-comp-8 \ + fate-flac-rice-params \ fate-flac-16-chmode-%: OPTS = -ch_mode $(@:fate-flac-16-chmode-%=%) fate-flac-16-fixed: OPTS = -lpc_type fixed @@ -19,6 +20,9 @@ fate-flac-24-%: REF = $(SAMPLES)/audio-reference/divertimenti_2ch_96kHz_s24.wav fate-flac-24-%: CMD = enc_dec_pcm flac wav s24le $(subst $(SAMPLES),$(TARGET_SAMPLES),$(REF)) -c flac $(OPTS) +fate-flac-rice-params: REF = $(SAMPLES)/audio-reference/chorusnoise_2ch_44kHz_s16.wav +fate-flac-rice-params: CMD = enc_dec_pcm flac wav s16le $(subst $(SAMPLES),$(TARGET_SAMPLES),$(REF)) -c flac + fate-flac-%: CMP = oneoff fate-flac-%: FUZZ = 0 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/image.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/image.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/image.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/image.mak 2015-07-22 17:20:04.000000000 +0000 @@ -30,6 +30,20 @@ FATE_IMAGE-$(call PARSERDEMDEC, BMP, IMAGE2PIPE, BMP) += fate-bmpparser fate-bmpparser: CMD = framecrc -f image2pipe -i $(TARGET_SAMPLES)/bmp/numbers.bmp -pix_fmt rgb24 +define FATE_IMGSUITE_DDS +FATE_DDS += fate-dds-$(1) +fate-dds-$(1): CMD = framecrc -i $(TARGET_SAMPLES)/dds/fate_$(1).dds $(DDS_OPTS_$(1)) +endef + +DDS_OPTS_pal = -sws_flags +accurate_rnd+bitexact -pix_fmt rgba +DDS_OPTS_pal-ati = -sws_flags +accurate_rnd+bitexact -pix_fmt rgba +DDS_FMT = argb argb-aexp dx10-bc1 dx10-bc1a dx10-bc2 dx10-bc3 dx10-bc4 dx10-bc5 dxt1 dxt1a dxt1-normalmap dxt2 dxt3 dxt4 dxt5 dxt5-aexp dxt5-normalmap dxt5-normalmap-ati dxt5-rbxg dxt5-rgxb dxt5-rxbg dxt5-rxgb dxt5-xgbr dxt5-xgxr dxt5-xrbg dxt5-ycocg dxt5-ycocg-scaled pal pal-ati rgb16 rgb24 rgba rgtc1s rgtc1u rgtc2s rgtc2u rgtc2u-xy uyvy xbgr xrgb y ya ycocg yuyv +$(foreach FMT,$(DDS_FMT),$(eval $(call FATE_IMGSUITE_DDS,$(FMT)))) + +FATE_DDS-$(call DEMDEC, IMAGE2, DDS) += $(FATE_DDS) +FATE_IMAGE += $(FATE_DDS-yes) +fate-dds: $(FATE_DDS-yes) + FATE_IMAGE-$(call DEMDEC, IMAGE2, DPX) += fate-dpx fate-dpx: CMD = framecrc -i $(TARGET_SAMPLES)/dpx/lighthouse_rgb48.dpx @@ -109,7 +123,7 @@ FATE_SGI-$(call DEMDEC, IMAGE2, SGI) += $(FATE_SGI) -FATE_SAMPLES_AVCONV += $(FATE_SGI-yes) +FATE_IMAGE += $(FATE_SGI-yes) fate-sgi: $(FATE_SGI-yes) FATE_SUNRASTER += fate-sunraster-1bit-raw diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/libavcodec.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/libavcodec.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/libavcodec.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/libavcodec.mak 2015-06-27 17:20:02.000000000 +0000 @@ -34,11 +34,10 @@ fate-mathops: CMP = null fate-mathops: REF = /dev/null -FATE_LIBAVCODEC-$(call ENCDEC, FLAC, FLAC) += fate-api-flac -fate-api-flac: libavcodec/api-flac-test$(EXESUF) -fate-api-flac: CMD = run libavcodec/api-flac-test -fate-api-flac: CMP = null -fate-api-flac: REF = /dev/null +FATE_LIBAVCODEC-$(CONFIG_JPEG2000_ENCODER) += fate-j2k-dwt +fate-j2k-dwt: libavcodec/jpeg2000dwt-test$(EXESUF) +fate-j2k-dwt: CMD = run libavcodec/jpeg2000dwt-test + FATE-$(CONFIG_AVCODEC) += $(FATE_LIBAVCODEC-yes) fate-libavcodec: $(FATE_LIBAVCODEC-yes) diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/libavformat.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/libavformat.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/libavformat.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/libavformat.mak 2015-07-21 17:20:03.000000000 +0000 @@ -1,3 +1,7 @@ +FATE_LIBAVFORMAT-$(HAVE_PTHREADS) += fate-async +fate-async: libavformat/async-test$(EXESUF) +fate-async: CMD = run libavformat/async-test + FATE_LIBAVFORMAT-$(CONFIG_NETWORK) += fate-noproxy fate-noproxy: libavformat/noproxy-test$(EXESUF) fate-noproxy: CMD = run libavformat/noproxy-test diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/libavresample.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/libavresample.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/libavresample.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/libavresample.mak 2015-06-22 17:20:02.000000000 +0000 @@ -38,7 +38,7 @@ fate-lavr-resample-$(3)-$(1)-$(2): CMP = oneoff fate-lavr-resample-$(3)-$(1)-$(2): CMP_UNIT = $(5) fate-lavr-resample-$(3)-$(1)-$(2): FUZZ = 6 -fate-lavr-resample-$(3)-$(1)-$(2): REF = $(SAMPLES)/lavr/lavr-resample-$(3)-$(1)-$(2)-v2 +fate-lavr-resample-$(3)-$(1)-$(2): REF = $(SAMPLES)/lavr/lavr-resample-$(3)-$(1)-$(2)-v3 endef $(call CROSS_TEST,$(SAMPLERATES),RESAMPLE,s16p,s16le,s16) diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/libavutil.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/libavutil.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/libavutil.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/libavutil.mak 2015-07-22 17:20:04.000000000 +0000 @@ -121,6 +121,10 @@ fate-xtea: libavutil/xtea-test$(EXESUF) fate-xtea: CMD = run libavutil/xtea-test +FATE_LIBAVUTIL += fate-tea +fate-tea: libavutil/tea-test$(EXESUF) +fate-tea: CMD = run libavutil/tea-test + FATE_LIBAVUTIL += fate-opt fate-opt: libavutil/opt-test$(EXESUF) fate-opt: CMD = run libavutil/opt-test diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/libswresample.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/libswresample.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/libswresample.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/libswresample.mak 2015-06-21 17:20:02.000000000 +0000 @@ -26,124 +26,124 @@ #you can use this if you need to update it! #make -k `make fate-list | grep swr` | egrep 'TEST|stddev' | tr '\n' '@' | sed 's#TEST *\([^@]*\)@stddev: *\([0-9.]*\)[^b@]*bytes: *\([0-9]*\) */ *\([0-9]*\)@#fate-\1: CMP_TARGET = \2@fate-\1: SIZE_TOLERANCE = \3 - \4@@#g' | tr '@' '\n' -fate-swr-resample-dblp-2626-44100: CMP_TARGET = 1393.01 +fate-swr-resample-dblp-2626-44100: CMP_TARGET = 1352.68 fate-swr-resample-dblp-2626-44100: SIZE_TOLERANCE = 31512 - 20480 -fate-swr-resample-dblp-2626-48000: CMP_TARGET = 1393.01 +fate-swr-resample-dblp-2626-48000: CMP_TARGET = 1352.65 fate-swr-resample-dblp-2626-48000: SIZE_TOLERANCE = 31512 - 20480 -fate-swr-resample-dblp-2626-8000: CMP_TARGET = 1393.90 +fate-swr-resample-dblp-2626-8000: CMP_TARGET = 1353.08 fate-swr-resample-dblp-2626-8000: SIZE_TOLERANCE = 31512 - 20482 -fate-swr-resample-dblp-2626-96000: CMP_TARGET = 1393.01 +fate-swr-resample-dblp-2626-96000: CMP_TARGET = 1352.67 fate-swr-resample-dblp-2626-96000: SIZE_TOLERANCE = 31512 - 20480 -fate-swr-resample-dblp-44100-2626: CMP_TARGET = 185.84 +fate-swr-resample-dblp-44100-2626: CMP_TARGET = 185.82 fate-swr-resample-dblp-44100-2626: SIZE_TOLERANCE = 529200 - 20490 fate-swr-resample-dblp-44100-48000: CMP_TARGET = 9.70 fate-swr-resample-dblp-44100-48000: SIZE_TOLERANCE = 529200 - 20482 -fate-swr-resample-dblp-44100-8000: CMP_TARGET = 75.46 +fate-swr-resample-dblp-44100-8000: CMP_TARGET = 75.45 fate-swr-resample-dblp-44100-8000: SIZE_TOLERANCE = 529200 - 20486 fate-swr-resample-dblp-44100-96000: CMP_TARGET = 11.47 fate-swr-resample-dblp-44100-96000: SIZE_TOLERANCE = 529200 - 20482 -fate-swr-resample-dblp-48000-2626: CMP_TARGET = 456.55 +fate-swr-resample-dblp-48000-2626: CMP_TARGET = 456.51 fate-swr-resample-dblp-48000-2626: SIZE_TOLERANCE = 576000 - 20510 -fate-swr-resample-dblp-48000-44100: CMP_TARGET = 1.16 +fate-swr-resample-dblp-48000-44100: CMP_TARGET = 1.02 fate-swr-resample-dblp-48000-44100: SIZE_TOLERANCE = 576000 - 20480 -fate-swr-resample-dblp-48000-8000: CMP_TARGET = 62.41 +fate-swr-resample-dblp-48000-8000: CMP_TARGET = 62.38 fate-swr-resample-dblp-48000-8000: SIZE_TOLERANCE = 576000 - 20484 fate-swr-resample-dblp-48000-96000: CMP_TARGET = 0.47 fate-swr-resample-dblp-48000-96000: SIZE_TOLERANCE = 576000 - 20480 -fate-swr-resample-dblp-8000-2626: CMP_TARGET = 2506.01 +fate-swr-resample-dblp-8000-2626: CMP_TARGET = 2506.02 fate-swr-resample-dblp-8000-2626: SIZE_TOLERANCE = 96000 - 20486 fate-swr-resample-dblp-8000-44100: CMP_TARGET = 15.09 fate-swr-resample-dblp-8000-44100: SIZE_TOLERANCE = 96000 - 20480 -fate-swr-resample-dblp-8000-48000: CMP_TARGET = 14.68 +fate-swr-resample-dblp-8000-48000: CMP_TARGET = 14.69 fate-swr-resample-dblp-8000-48000: SIZE_TOLERANCE = 96000 - 20480 -fate-swr-resample-dblp-8000-96000: CMP_TARGET = 13.82 +fate-swr-resample-dblp-8000-96000: CMP_TARGET = 13.81 fate-swr-resample-dblp-8000-96000: SIZE_TOLERANCE = 96000 - 20480 -fate-swr-resample-dblp-96000-2626: CMP_TARGET = 675.14 +fate-swr-resample-dblp-96000-2626: CMP_TARGET = 675.08 fate-swr-resample-dblp-96000-2626: SIZE_TOLERANCE = 1152000 - 20474 -fate-swr-resample-dblp-96000-44100: CMP_TARGET = 1.58 +fate-swr-resample-dblp-96000-44100: CMP_TARGET = 1.45 fate-swr-resample-dblp-96000-44100: SIZE_TOLERANCE = 1152000 - 20480 -fate-swr-resample-dblp-96000-48000: CMP_TARGET = 1.04 +fate-swr-resample-dblp-96000-48000: CMP_TARGET = 1.00 fate-swr-resample-dblp-96000-48000: SIZE_TOLERANCE = 1152000 - 20480 -fate-swr-resample-dblp-96000-8000: CMP_TARGET = 58.60 +fate-swr-resample-dblp-96000-8000: CMP_TARGET = 58.57 fate-swr-resample-dblp-96000-8000: SIZE_TOLERANCE = 1152000 - 20496 -fate-swr-resample-fltp-2626-44100: CMP_TARGET = 1393.01 +fate-swr-resample-fltp-2626-44100: CMP_TARGET = 1352.68 fate-swr-resample-fltp-2626-44100: SIZE_TOLERANCE = 31512 - 20480 -fate-swr-resample-fltp-2626-48000: CMP_TARGET = 1393.01 +fate-swr-resample-fltp-2626-48000: CMP_TARGET = 1352.65 fate-swr-resample-fltp-2626-48000: SIZE_TOLERANCE = 31512 - 20480 -fate-swr-resample-fltp-2626-8000: CMP_TARGET = 1393.90 +fate-swr-resample-fltp-2626-8000: CMP_TARGET = 1353.08 fate-swr-resample-fltp-2626-8000: SIZE_TOLERANCE = 31512 - 20482 -fate-swr-resample-fltp-2626-96000: CMP_TARGET = 1393.01 +fate-swr-resample-fltp-2626-96000: CMP_TARGET = 1352.67 fate-swr-resample-fltp-2626-96000: SIZE_TOLERANCE = 31512 - 20480 -fate-swr-resample-fltp-44100-2626: CMP_TARGET = 185.84 +fate-swr-resample-fltp-44100-2626: CMP_TARGET = 185.82 fate-swr-resample-fltp-44100-2626: SIZE_TOLERANCE = 529200 - 20490 fate-swr-resample-fltp-44100-48000: CMP_TARGET = 9.70 fate-swr-resample-fltp-44100-48000: SIZE_TOLERANCE = 529200 - 20482 -fate-swr-resample-fltp-44100-8000: CMP_TARGET = 75.46 +fate-swr-resample-fltp-44100-8000: CMP_TARGET = 75.45 fate-swr-resample-fltp-44100-8000: SIZE_TOLERANCE = 529200 - 20486 fate-swr-resample-fltp-44100-96000: CMP_TARGET = 11.47 fate-swr-resample-fltp-44100-96000: SIZE_TOLERANCE = 529200 - 20482 -fate-swr-resample-fltp-48000-2626: CMP_TARGET = 456.55 +fate-swr-resample-fltp-48000-2626: CMP_TARGET = 456.51 fate-swr-resample-fltp-48000-2626: SIZE_TOLERANCE = 576000 - 20510 -fate-swr-resample-fltp-48000-44100: CMP_TARGET = 1.16 +fate-swr-resample-fltp-48000-44100: CMP_TARGET = 1.02 fate-swr-resample-fltp-48000-44100: SIZE_TOLERANCE = 576000 - 20480 -fate-swr-resample-fltp-48000-8000: CMP_TARGET = 62.41 +fate-swr-resample-fltp-48000-8000: CMP_TARGET = 62.38 fate-swr-resample-fltp-48000-8000: SIZE_TOLERANCE = 576000 - 20484 fate-swr-resample-fltp-48000-96000: CMP_TARGET = 0.47 fate-swr-resample-fltp-48000-96000: SIZE_TOLERANCE = 576000 - 20480 -fate-swr-resample-fltp-8000-2626: CMP_TARGET = 2506.01 +fate-swr-resample-fltp-8000-2626: CMP_TARGET = 2506.02 fate-swr-resample-fltp-8000-2626: SIZE_TOLERANCE = 96000 - 20486 fate-swr-resample-fltp-8000-44100: CMP_TARGET = 15.09 fate-swr-resample-fltp-8000-44100: SIZE_TOLERANCE = 96000 - 20480 -fate-swr-resample-fltp-8000-48000: CMP_TARGET = 14.68 +fate-swr-resample-fltp-8000-48000: CMP_TARGET = 14.69 fate-swr-resample-fltp-8000-48000: SIZE_TOLERANCE = 96000 - 20480 -fate-swr-resample-fltp-8000-96000: CMP_TARGET = 13.82 +fate-swr-resample-fltp-8000-96000: CMP_TARGET = 13.81 fate-swr-resample-fltp-8000-96000: SIZE_TOLERANCE = 96000 - 20480 -fate-swr-resample-fltp-96000-2626: CMP_TARGET = 675.14 +fate-swr-resample-fltp-96000-2626: CMP_TARGET = 675.08 fate-swr-resample-fltp-96000-2626: SIZE_TOLERANCE = 1152000 - 20474 -fate-swr-resample-fltp-96000-44100: CMP_TARGET = 1.58 +fate-swr-resample-fltp-96000-44100: CMP_TARGET = 1.45 fate-swr-resample-fltp-96000-44100: SIZE_TOLERANCE = 1152000 - 20480 -fate-swr-resample-fltp-96000-48000: CMP_TARGET = 1.04 +fate-swr-resample-fltp-96000-48000: CMP_TARGET = 1.00 fate-swr-resample-fltp-96000-48000: SIZE_TOLERANCE = 1152000 - 20480 -fate-swr-resample-fltp-96000-8000: CMP_TARGET = 58.60 +fate-swr-resample-fltp-96000-8000: CMP_TARGET = 58.57 fate-swr-resample-fltp-96000-8000: SIZE_TOLERANCE = 1152000 - 20496 fate-swr-resample-s16p-2626-44100: CMP_TARGET = 1393.01 @@ -209,63 +209,64 @@ fate-swr-resample-s32p-2626-44100: CMP_TARGET = 1393.01 fate-swr-resample-s32p-2626-44100: SIZE_TOLERANCE = 31512 - 20480 -fate-swr-resample-s32p-2626-48000: CMP_TARGET = 1393.01 +fate-swr-resample-s32p-2626-48000: CMP_TARGET = 1392.99 fate-swr-resample-s32p-2626-48000: SIZE_TOLERANCE = 31512 - 20480 -fate-swr-resample-s32p-2626-8000: CMP_TARGET = 1393.90 +fate-swr-resample-s32p-2626-8000: CMP_TARGET = 1393.89 fate-swr-resample-s32p-2626-8000: SIZE_TOLERANCE = 31512 - 20482 -fate-swr-resample-s32p-2626-96000: CMP_TARGET = 1393.01 +fate-swr-resample-s32p-2626-96000: CMP_TARGET = 1393.00 fate-swr-resample-s32p-2626-96000: SIZE_TOLERANCE = 31512 - 20480 -fate-swr-resample-s32p-44100-2626: CMP_TARGET = 185.84 +fate-swr-resample-s32p-44100-2626: CMP_TARGET = 185.82 fate-swr-resample-s32p-44100-2626: SIZE_TOLERANCE = 529200 - 20490 fate-swr-resample-s32p-44100-48000: CMP_TARGET = 9.70 fate-swr-resample-s32p-44100-48000: SIZE_TOLERANCE = 529200 - 20482 -fate-swr-resample-s32p-44100-8000: CMP_TARGET = 75.46 +fate-swr-resample-s32p-44100-8000: CMP_TARGET = 75.45 fate-swr-resample-s32p-44100-8000: SIZE_TOLERANCE = 529200 - 20486 fate-swr-resample-s32p-44100-96000: CMP_TARGET = 11.47 fate-swr-resample-s32p-44100-96000: SIZE_TOLERANCE = 529200 - 20482 -fate-swr-resample-s32p-48000-2626: CMP_TARGET = 456.55 +fate-swr-resample-s32p-48000-2626: CMP_TARGET = 456.51 fate-swr-resample-s32p-48000-2626: SIZE_TOLERANCE = 576000 - 20510 -fate-swr-resample-s32p-48000-44100: CMP_TARGET = 1.16 +fate-swr-resample-s32p-48000-44100: CMP_TARGET = 1.02 fate-swr-resample-s32p-48000-44100: SIZE_TOLERANCE = 576000 - 20480 -fate-swr-resample-s32p-48000-8000: CMP_TARGET = 62.41 +fate-swr-resample-s32p-48000-8000: CMP_TARGET = 62.38 fate-swr-resample-s32p-48000-8000: SIZE_TOLERANCE = 576000 - 20484 fate-swr-resample-s32p-48000-96000: CMP_TARGET = 0.47 fate-swr-resample-s32p-48000-96000: SIZE_TOLERANCE = 576000 - 20480 -fate-swr-resample-s32p-8000-2626: CMP_TARGET = 2506.01 +fate-swr-resample-s32p-8000-2626: CMP_TARGET = 2506.02 fate-swr-resample-s32p-8000-2626: SIZE_TOLERANCE = 96000 - 20486 fate-swr-resample-s32p-8000-44100: CMP_TARGET = 15.09 fate-swr-resample-s32p-8000-44100: SIZE_TOLERANCE = 96000 - 20480 -fate-swr-resample-s32p-8000-48000: CMP_TARGET = 14.68 +fate-swr-resample-s32p-8000-48000: CMP_TARGET = 14.69 fate-swr-resample-s32p-8000-48000: SIZE_TOLERANCE = 96000 - 20480 -fate-swr-resample-s32p-8000-96000: CMP_TARGET = 13.82 +fate-swr-resample-s32p-8000-96000: CMP_TARGET = 13.81 fate-swr-resample-s32p-8000-96000: SIZE_TOLERANCE = 96000 - 20480 -fate-swr-resample-s32p-96000-2626: CMP_TARGET = 675.14 +fate-swr-resample-s32p-96000-2626: CMP_TARGET = 675.08 fate-swr-resample-s32p-96000-2626: SIZE_TOLERANCE = 1152000 - 20474 -fate-swr-resample-s32p-96000-44100: CMP_TARGET = 1.58 +fate-swr-resample-s32p-96000-44100: CMP_TARGET = 1.45 fate-swr-resample-s32p-96000-44100: SIZE_TOLERANCE = 1152000 - 20480 -fate-swr-resample-s32p-96000-48000: CMP_TARGET = 1.04 +fate-swr-resample-s32p-96000-48000: CMP_TARGET = 1.00 fate-swr-resample-s32p-96000-48000: SIZE_TOLERANCE = 1152000 - 20480 -fate-swr-resample-s32p-96000-8000: CMP_TARGET = 58.60 +fate-swr-resample-s32p-96000-8000: CMP_TARGET = 58.57 fate-swr-resample-s32p-96000-8000: SIZE_TOLERANCE = 1152000 - 20496 + define ARESAMPLE_LIN FATE_SWR_RESAMPLE += fate-swr-resample_lin-$(3)-$(1)-$(2) fate-swr-resample_lin-$(3)-$(1)-$(2): tests/data/asynth-$(1)-1.wav @@ -277,58 +278,58 @@ fate-swr-resample_lin-$(3)-$(1)-$(2): REF = tests/data/asynth-$(1)-1.wav endef -fate-swr-resample_lin-s16p-8000-44100: CMP_TARGET = 14.63 +fate-swr-resample_lin-s16p-8000-44100: CMP_TARGET = 14.61 fate-swr-resample_lin-s16p-8000-44100: SIZE_TOLERANCE = 96000 - 20480 fate-swr-resample_lin-s16p-8000-48000: CMP_TARGET = 14.53 fate-swr-resample_lin-s16p-8000-48000: SIZE_TOLERANCE = 96000 - 20480 -fate-swr-resample_lin-s16p-44100-8000: CMP_TARGET = 75.45 +fate-swr-resample_lin-s16p-44100-8000: CMP_TARGET = 75.41 fate-swr-resample_lin-s16p-44100-8000: SIZE_TOLERANCE = 529200 - 20486 -fate-swr-resample_lin-s16p-44100-48000: CMP_TARGET = 9.68 +fate-swr-resample_lin-s16p-44100-48000: CMP_TARGET = 9.66 fate-swr-resample_lin-s16p-44100-48000: SIZE_TOLERANCE = 529200 - 20482 -fate-swr-resample_lin-s16p-48000-8000: CMP_TARGET = 62.41 +fate-swr-resample_lin-s16p-48000-8000: CMP_TARGET = 62.39 fate-swr-resample_lin-s16p-48000-8000: SIZE_TOLERANCE = 576000 - 20484 fate-swr-resample_lin-s16p-48000-44100: CMP_TARGET = 0.68 fate-swr-resample_lin-s16p-48000-44100: SIZE_TOLERANCE = 576000 - 20480 -fate-swr-resample_lin-fltp-8000-44100: CMP_TARGET = 14.61 +fate-swr-resample_lin-fltp-8000-44100: CMP_TARGET = 14.59 fate-swr-resample_lin-fltp-8000-44100: SIZE_TOLERANCE = 96000 - 20480 fate-swr-resample_lin-fltp-8000-48000: CMP_TARGET = 14.50 fate-swr-resample_lin-fltp-8000-48000: SIZE_TOLERANCE = 96000 - 20480 -fate-swr-resample_lin-fltp-44100-8000: CMP_TARGET = 75.45 +fate-swr-resample_lin-fltp-44100-8000: CMP_TARGET = 75.38 fate-swr-resample_lin-fltp-44100-8000: SIZE_TOLERANCE = 529200 - 20486 -fate-swr-resample_lin-fltp-44100-48000: CMP_TARGET = 9.67 +fate-swr-resample_lin-fltp-44100-48000: CMP_TARGET = 9.65 fate-swr-resample_lin-fltp-44100-48000: SIZE_TOLERANCE = 529200 - 20482 -fate-swr-resample_lin-fltp-48000-8000: CMP_TARGET = 62.41 +fate-swr-resample_lin-fltp-48000-8000: CMP_TARGET = 62.36 fate-swr-resample_lin-fltp-48000-8000: SIZE_TOLERANCE = 576000 - 20484 -fate-swr-resample_lin-fltp-48000-44100: CMP_TARGET = 0.63 +fate-swr-resample_lin-fltp-48000-44100: CMP_TARGET = 0.26 fate-swr-resample_lin-fltp-48000-44100: SIZE_TOLERANCE = 576000 - 20480 -fate-swr-resample_lin-dblp-8000-44100: CMP_TARGET = 14.61 +fate-swr-resample_lin-dblp-8000-44100: CMP_TARGET = 14.59 fate-swr-resample_lin-dblp-8000-44100: SIZE_TOLERANCE = 96000 - 20480 fate-swr-resample_lin-dblp-8000-48000: CMP_TARGET = 14.50 fate-swr-resample_lin-dblp-8000-48000: SIZE_TOLERANCE = 96000 - 20480 -fate-swr-resample_lin-dblp-44100-8000: CMP_TARGET = 75.45 +fate-swr-resample_lin-dblp-44100-8000: CMP_TARGET = 75.38 fate-swr-resample_lin-dblp-44100-8000: SIZE_TOLERANCE = 529200 - 20486 -fate-swr-resample_lin-dblp-44100-48000: CMP_TARGET = 9.67 +fate-swr-resample_lin-dblp-44100-48000: CMP_TARGET = 9.65 fate-swr-resample_lin-dblp-44100-48000: SIZE_TOLERANCE = 529200 - 20482 -fate-swr-resample_lin-dblp-48000-8000: CMP_TARGET = 62.41 +fate-swr-resample_lin-dblp-48000-8000: CMP_TARGET = 62.36 fate-swr-resample_lin-dblp-48000-8000: SIZE_TOLERANCE = 576000 - 20484 -fate-swr-resample_lin-dblp-48000-44100: CMP_TARGET = 0.63 +fate-swr-resample_lin-dblp-48000-44100: CMP_TARGET = 0.26 fate-swr-resample_lin-dblp-48000-44100: SIZE_TOLERANCE = 576000 - 20480 define ARESAMPLE_NN @@ -365,7 +366,7 @@ fate-swr-resample_async-$(3)-$(1)-$(2): REF = tests/data/asynth-$(1)-1.wav endef -fate-swr-resample_async-fltp-44100-8000: CMP_TARGET = 4031.60 +fate-swr-resample_async-fltp-44100-8000: CMP_TARGET = 4031.48 fate-swr-resample_async-fltp-44100-8000: SIZE_TOLERANCE = 529200 - 20310 fate-swr-resample_async-fltp-8000-44100: CMP_TARGET = 11185.34 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/lossless-audio.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/lossless-audio.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/lossless-audio.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/lossless-audio.mak 2015-06-28 17:20:02.000000000 +0000 @@ -26,7 +26,7 @@ fate-lossless-tta-encrypted: CMD = crc -password ffmpeg -i $(TARGET_SAMPLES)/lossless-audio/encrypted.tta FATE_SAMPLES_LOSSLESS_AUDIO-$(call DEMDEC, ASF, WMALOSSLESS) += fate-lossless-wma -fate-lossless-wma: CMD = md5 -i $(TARGET_SAMPLES)/lossless-audio/luckynight-partial.wma -f s16le +fate-lossless-wma: CMD = md5 -i $(TARGET_SAMPLES)/lossless-audio/luckynight-partial.wma -f s16le -frames 209 FATE_SAMPLES_LOSSLESS_AUDIO += $(FATE_SAMPLES_LOSSLESS_AUDIO-yes) diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/mp3.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/mp3.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/mp3.mak 2015-03-15 02:46:06.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/mp3.mak 2015-08-02 17:20:02.000000000 +0000 @@ -1,41 +1,40 @@ FATE_MP3 += fate-mp3-float-conf-compl -fate-mp3-float-conf-compl: CMD = pcm -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/compl.bit -fate-mp3-float-conf-compl: REF = $(SAMPLES)/mp3-conformance/compl.pcm +fate-mp3-float-conf-compl: CMD = ffmpeg -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/compl.bit -f f32le - +fate-mp3-float-conf-compl: REF = $(SAMPLES)/mp3-conformance/compl.f32 FATE_MP3 += fate-mp3-float-conf-he_32khz -fate-mp3-float-conf-he_32khz: CMD = pcm -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/he_32khz.bit -fs 343296 -fate-mp3-float-conf-he_32khz: REF = $(SAMPLES)/mp3-conformance/he_32khz.pcm +fate-mp3-float-conf-he_32khz: CMD = ffmpeg -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/he_32khz.bit -af atrim=end_sample=171648 -f f32le - +fate-mp3-float-conf-he_32khz: REF = $(SAMPLES)/mp3-conformance/he_32khz.f32 FATE_MP3 += fate-mp3-float-conf-he_44khz -fate-mp3-float-conf-he_44khz: CMD = pcm -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/he_44khz.bit -fs 942336 -fate-mp3-float-conf-he_44khz: REF = $(SAMPLES)/mp3-conformance/he_44khz.pcm +fate-mp3-float-conf-he_44khz: CMD = ffmpeg -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/he_44khz.bit -af atrim=end_sample=471168 -f f32le - +fate-mp3-float-conf-he_44khz: REF = $(SAMPLES)/mp3-conformance/he_44khz.f32 FATE_MP3 += fate-mp3-float-conf-he_48khz -fate-mp3-float-conf-he_48khz: CMD = pcm -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/he_48khz.bit -fs 343296 -fate-mp3-float-conf-he_48khz: REF = $(SAMPLES)/mp3-conformance/he_48khz.pcm +fate-mp3-float-conf-he_48khz: CMD = ffmpeg -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/he_48khz.bit -af atrim=end_sample=171648 -f f32le - +fate-mp3-float-conf-he_48khz: REF = $(SAMPLES)/mp3-conformance/he_48khz.f32 FATE_MP3 += fate-mp3-float-conf-hecommon -fate-mp3-float-conf-hecommon: CMD = pcm -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/hecommon.bit -fs 133632 -fate-mp3-float-conf-hecommon: REF = $(SAMPLES)/mp3-conformance/hecommon.pcm +fate-mp3-float-conf-hecommon: CMD = ffmpeg -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/hecommon.bit -af atrim=end_sample=33408 -f f32le - +fate-mp3-float-conf-hecommon: REF = $(SAMPLES)/mp3-conformance/hecommon.f32 FATE_MP3 += fate-mp3-float-conf-si -fate-mp3-float-conf-si: CMD = pcm -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/si.bit -fs 269568 -fate-mp3-float-conf-si: REF = $(SAMPLES)/mp3-conformance/si.pcm +fate-mp3-float-conf-si: CMD = ffmpeg -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/si.bit -af atrim=end_sample=134784 -f f32le - +fate-mp3-float-conf-si: REF = $(SAMPLES)/mp3-conformance/si.f32 FATE_MP3 += fate-mp3-float-conf-si_block -fate-mp3-float-conf-si_block: CMD = pcm -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/si_block.bit -fs 145152 -fate-mp3-float-conf-si_block: REF = $(SAMPLES)/mp3-conformance/si_block.pcm +fate-mp3-float-conf-si_block: CMD = ffmpeg -acodec mp3float -i $(TARGET_SAMPLES)/mp3-conformance/si_block.bit -af atrim=end_sample=72576 -f f32le - +fate-mp3-float-conf-si_block: REF = $(SAMPLES)/mp3-conformance/si_block.f32 FATE_MP3 += fate-mp3-float-extra_overread -fate-mp3-float-extra_overread: CMD = pcm -c:a mp3float -i $(TARGET_SAMPLES)/mpegaudio/extra_overread.mp3 -fate-mp3-float-extra_overread: REF = $(SAMPLES)/mpegaudio/extra_overread.pcm +fate-mp3-float-extra_overread: CMD = ffmpeg -c:a mp3float -i $(TARGET_SAMPLES)/mpegaudio/extra_overread.mp3 -f f32le - +fate-mp3-float-extra_overread: REF = $(SAMPLES)/mpegaudio/extra_overread.f32 -$(FATE_MP3): CMP = stddev -$(FATE_MP3): FUZZ = 0.07 +$(FATE_MP3): CMP = oneoff +$(FATE_MP3): CMP_UNIT = f32 +$(FATE_MP3): FUZZ = 18 -ifdef HAVE_NEON -fate-mp3-float-conf-hecommon: FUZZ = 0.70 -endif +fate-mp3-float-extra_overread: FUZZ = 20 FATE_MP3-$(call DEMDEC, MP3, MP3FLOAT) += $(FATE_MP3) diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/screen.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/screen.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/screen.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/screen.mak 2015-07-02 17:20:03.000000000 +0000 @@ -29,6 +29,18 @@ FATE_SCREEN-$(call DEMDEC, AVI, FRAPS) += $(FATE_FRAPS) fate-fraps: $(FATE_FRAPS) +FATE_G2M += fate-g2m2 +fate-g2m2: CMD = framecrc -idct simple -i $(TARGET_SAMPLES)/g2m/g2m2.asf -an + +FATE_G2M += fate-g2m3 +fate-g2m3: CMD = framecrc -idct simple -i $(TARGET_SAMPLES)/g2m/g2m3.asf -frames:v 20 -an + +FATE_G2M += fate-g2m4 +fate-g2m4: CMD = framecrc -idct simple -i $(TARGET_SAMPLES)/g2m/g2m4.asf + +FATE_SAMPLES_AVCONV-$(call DEMDEC, ASF, G2M) += $(FATE_G2M) +fate-g2m: $(FATE_G2M) + FATE_SAMPLES_AVCONV-$(call DEMDEC, ASF, TDSC) += fate-tdsc fate-tdsc: CMD = framecrc -idct simple -i $(TARGET_SAMPLES)/tdsc/tdsc.asf -an -pix_fmt bgr24 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/vcodec.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/vcodec.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/vcodec.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/vcodec.mak 2015-06-22 17:20:02.000000000 +0000 @@ -68,9 +68,19 @@ fate-vsynth%-dv-50: DECOPTS = -sws_flags neighbor fate-vsynth%-dv-50: FMT = dv -FATE_VCODEC-$(call ENCDEC, FFV1, AVI) += ffv1 ffv1.0 +FATE_VCODEC-$(call ENCDEC, FFV1, AVI) += ffv1 ffv1.0 ffv1.3-420 ffv1.3-422p10 ffv1.3-444p16 ffv1.3-bgr fate-vsynth%-ffv1: ENCOPTS = -slices 4 fate-vsynth%-ffv1.0: CODEC = ffv1 +fate-vsynth%-ffv1.3-420: ENCOPTS = -vcodec ffv1 -level 3 -pix_fmt yuv420p +fate-vsynth%-ffv1.3-422p10: ENCOPTS = -vcodec ffv1 -level 3 -pix_fmt yuv422p10 \ + -sws_flags neighbor+bitexact +fate-vsynth%-ffv1.3-422p10: DECOPTS = -sws_flags neighbor+bitexact +fate-vsynth%-ffv1.3-444p16: ENCOPTS = -vcodec ffv1 -level 3 -pix_fmt yuv444p16 \ + -sws_flags neighbor+bitexact +fate-vsynth%-ffv1.3-444p16: DECOPTS = -sws_flags neighbor+bitexact +fate-vsynth%-ffv1.3-bgr: ENCOPTS = -vcodec ffv1 -level 3 -pix_fmt bgr0 \ + -sws_flags neighbor+bitexact +fate-vsynth%-ffv1.3-bgr: DECOPTS = -sws_flags neighbor+bitexact FATE_VCODEC-$(call ENCDEC, FFVHUFF, AVI) += ffvhuff ffvhuff444 ffvhuff420p12 ffvhuff422p10left ffvhuff444p16 fate-vsynth%-ffvhuff444: ENCOPTS = -vcodec ffvhuff -pix_fmt yuv444p diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/video.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/video.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/video.mak 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/video.mak 2015-07-22 17:20:04.000000000 +0000 @@ -168,6 +168,21 @@ FATE_VIDEO-$(call ENCDEC, ROQ PGMYUV, ROQ IMAGE2) += fate-idroq-video-encode fate-idroq-video-encode: CMD = md5 -f image2 -vcodec pgmyuv -i $(TARGET_SAMPLES)/ffmpeg-synthetic/vsynth1/%02d.pgm -r 30 -sws_flags +bitexact -vf pad=512:512:80:112 -f roq -t 0.2 +FATE_HAP += fate-hap1 +fate-hap1: CMD = framecrc -i $(TARGET_SAMPLES)/hap/hap1.mov + +FATE_HAP += fate-hap5 +fate-hap5: CMD = framecrc -i $(TARGET_SAMPLES)/hap/hap5.mov + +FATE_HAP += fate-hapy +fate-hapy: CMD = framecrc -i $(TARGET_SAMPLES)/hap/hapy.mov + +FATE_HAP += fate-hap-chunk +fate-hap-chunk: CMD = framecrc -i $(TARGET_SAMPLES)/hap/hapy-12-chunks.mov + +FATE_SAMPLES_AVCONV-$(call DEMDEC, MOV, HAP) += $(FATE_HAP) +fate-hap: $(FATE_HAP) + FATE_IFF-$(CONFIG_IFF_BYTERUN1_DECODER) += fate-iff-byterun1 fate-iff-byterun1: CMD = framecrc -i $(TARGET_SAMPLES)/iff/ASH.LBM -pix_fmt rgb24 @@ -278,7 +293,10 @@ fate-tmv: CMD = framecrc -i $(TARGET_SAMPLES)/tmv/pop-partial.tmv -pix_fmt rgb24 FATE_TXD += fate-txd-16bpp -fate-txd-16bpp: CMD = framecrc -i $(TARGET_SAMPLES)/txd/misc.txd -pix_fmt bgra -an +fate-txd-16bpp: CMD = framecrc -i $(TARGET_SAMPLES)/txd/misc.txd -an + +FATE_TXD += fate-txd-odd +fate-txd-odd: CMD = framecrc -i $(TARGET_SAMPLES)/txd/odd.txd -an FATE_TXD += fate-txd-pal8 fate-txd-pal8: CMD = framecrc -i $(TARGET_SAMPLES)/txd/outro.txd -pix_fmt rgb24 -an diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/fate/wma.mak ffmpeg-2.7.2~trusty~ppa1/tests/fate/wma.mak --- ffmpeg-2.7.1~trusty~ppa1/tests/fate/wma.mak 2015-03-15 02:46:06.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/fate/wma.mak 2015-06-28 17:20:02.000000000 +0000 @@ -1,10 +1,12 @@ FATE_WMAPRO-$(call DEMDEC, ASF, WMAPRO) += fate-wmapro-2ch -fate-wmapro-2ch: CMD = pcm -i $(TARGET_SAMPLES)/wmapro/Beethovens_9th-1_small.wma +fate-wmapro-2ch: CMD = pcm -i $(TARGET_SAMPLES)/wmapro/Beethovens_9th-1_small.wma -frames 43 fate-wmapro-2ch: REF = $(SAMPLES)/wmapro/Beethovens_9th-1_small.pcm +fate-wmapro-2ch: SIZE_TOLERANCE = 8192 FATE_WMAPRO-$(call DEMDEC, ASF, WMAPRO) += fate-wmapro-5.1 -fate-wmapro-5.1: CMD = pcm -i $(TARGET_SAMPLES)/wmapro/latin_192_mulitchannel_cut.wma +fate-wmapro-5.1: CMD = pcm -i $(TARGET_SAMPLES)/wmapro/latin_192_mulitchannel_cut.wma -frames 101 fate-wmapro-5.1: REF = $(SAMPLES)/wmapro/latin_192_mulitchannel_cut.pcm +fate-wmapro-5.1: SIZE_TOLERANCE = 24576 FATE_WMAPRO-$(call DEMDEC, MOV, WMAPRO) += fate-wmapro-ism fate-wmapro-ism: CMD = pcm -i $(TARGET_SAMPLES)/isom/vc1-wmapro.ism -vn diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/filtergraphs/mergeplanes ffmpeg-2.7.2~trusty~ppa1/tests/filtergraphs/mergeplanes --- ffmpeg-2.7.1~trusty~ppa1/tests/filtergraphs/mergeplanes 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/filtergraphs/mergeplanes 2015-07-19 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +sws_flags=+accurate_rnd+bitexact; +format=yuv420p,mergeplanes=0:yuv444p diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/Makefile ffmpeg-2.7.2~trusty~ppa1/tests/Makefile --- ffmpeg-2.7.1~trusty~ppa1/tests/Makefile 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/Makefile 2015-07-18 17:20:03.000000000 +0000 @@ -16,7 +16,8 @@ @echo $(SRC_PATH)/tests/ffserver-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/ffserver.conf -OBJDIRS += tests/data tests/vsynth1 tests/data/filtergraphs +APITESTSDIR := tests/api +OBJDIRS += tests/data tests/vsynth1 tests/data/filtergraphs $(APITESTSDIR)/ $(VREF): tests/videogen$(HOSTEXESUF) | tests/vsynth1 $(M)./$< 'tests/vsynth1/' @@ -89,6 +90,8 @@ PARSERDEMDEC = $(call ALLYES, $(1)_PARSER $(2)_DEMUXER $(3)_DECODER) +include $(SRC_PATH)/$(APITESTSDIR)/Makefile + include $(SRC_PATH)/tests/fate/acodec.mak include $(SRC_PATH)/tests/fate/vcodec.mak include $(SRC_PATH)/tests/fate/avformat.mak @@ -101,10 +104,12 @@ include $(SRC_PATH)/tests/fate/als.mak include $(SRC_PATH)/tests/fate/amrnb.mak include $(SRC_PATH)/tests/fate/amrwb.mak +include $(SRC_PATH)/tests/fate/api.mak include $(SRC_PATH)/tests/fate/atrac.mak include $(SRC_PATH)/tests/fate/audio.mak include $(SRC_PATH)/tests/fate/bmp.mak include $(SRC_PATH)/tests/fate/cdxl.mak +include $(SRC_PATH)/tests/fate/checkasm.mak include $(SRC_PATH)/tests/fate/cover-art.mak include $(SRC_PATH)/tests/fate/demux.mak include $(SRC_PATH)/tests/fate/dfa.mak @@ -218,7 +223,7 @@ clean:: testclean -testclean: +testclean:: $(RM) -r tests/vsynth1 tests/data tools/lavfi-showfiltfmts$(EXESUF) $(RM) $(CLEANSUFFIXES:%=tests/%) $(RM) $(TESTTOOLS:%=tests/%$(HOSTEXESUF)) @@ -226,5 +231,7 @@ -include $(wildcard tests/*.d) +include $(SRC_PATH)/tests/checkasm/Makefile + .PHONY: fate* lcov lcov-reset .INTERMEDIATE: coverage.info diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/acodec/adpcm-adx ffmpeg-2.7.2~trusty~ppa1/tests/ref/acodec/adpcm-adx --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/acodec/adpcm-adx 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/acodec/adpcm-adx 2015-06-21 17:20:02.000000000 +0000 @@ -1,4 +1,4 @@ -d7ec7d52a2f5c91464812d031b07cc1d *tests/data/fate/acodec-adpcm-adx.adx +6bf1a8e5ec9cc958a31cb2b1b66bfc75 *tests/data/fate/acodec-adpcm-adx.adx 297720 tests/data/fate/acodec-adpcm-adx.adx 5b5a436ec9d528d6eb0bebaf667521b0 *tests/data/fate/acodec-adpcm-adx.out.wav stddev: 2549.93 PSNR: 28.20 MAXDIFF:57514 bytes: 1058400/ 1058432 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/acodec/adpcm-adx-trellis ffmpeg-2.7.2~trusty~ppa1/tests/ref/acodec/adpcm-adx-trellis --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/acodec/adpcm-adx-trellis 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/acodec/adpcm-adx-trellis 2015-06-21 17:20:02.000000000 +0000 @@ -1,4 +1,4 @@ -d7ec7d52a2f5c91464812d031b07cc1d *tests/data/fate/acodec-adpcm-adx-trellis.adx +6bf1a8e5ec9cc958a31cb2b1b66bfc75 *tests/data/fate/acodec-adpcm-adx-trellis.adx 297720 tests/data/fate/acodec-adpcm-adx-trellis.adx 5b5a436ec9d528d6eb0bebaf667521b0 *tests/data/fate/acodec-adpcm-adx-trellis.out.wav stddev: 2549.93 PSNR: 28.20 MAXDIFF:57514 bytes: 1058400/ 1058432 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/adpcm-thp ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/adpcm-thp --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/adpcm-thp 2015-03-13 17:34:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/adpcm-thp 2015-06-21 17:20:02.000000000 +0000 @@ -1,72 +1,72 @@ #tb 0: 1/32000 0, 0, 0, 1078, 4312, 0x469714f6 -0, 1078, 1078, 1064, 4256, 0xe03dd882 -0, 2142, 2142, 1078, 4312, 0x46b901f7 -0, 3220, 3220, 1064, 4256, 0x8d4a54e4 -0, 4284, 4284, 1064, 4256, 0xfd616b67 -0, 5348, 5348, 1078, 4312, 0xefe62302 -0, 6426, 6426, 1064, 4256, 0xab11684e -0, 7490, 7490, 1064, 4256, 0xb4b3feb8 -0, 8554, 8554, 1078, 4312, 0x71db6461 -0, 9632, 9632, 1064, 4256, 0x090e5efa -0, 10696, 10696, 1064, 4256, 0x36f49c28 -0, 11760, 11760, 1078, 4312, 0x0fe3d262 -0, 12838, 12838, 1064, 4256, 0x199ce269 -0, 13902, 13902, 1064, 4256, 0x98342d05 -0, 14966, 14966, 1078, 4312, 0xb6fb7ebe -0, 16044, 16044, 1064, 4256, 0x033dd562 -0, 17108, 17108, 1064, 4256, 0xc2cc17e0 -0, 18172, 18172, 1078, 4312, 0x4bb3ff50 -0, 19250, 19250, 1064, 4256, 0x6f2671ef -0, 20314, 20314, 1064, 4256, 0x5a337bf4 -0, 21378, 21378, 1078, 4312, 0xa71f6967 -0, 22456, 22456, 1064, 4256, 0x48084aa9 -0, 23520, 23520, 1064, 4256, 0x3cce4218 -0, 24584, 24584, 1078, 4312, 0xcbb8f73d -0, 25662, 25662, 1064, 4256, 0x36825021 -0, 26726, 26726, 1064, 4256, 0xeae036c6 -0, 27790, 27790, 1078, 4312, 0x0d650ac6 -0, 28868, 28868, 1064, 4256, 0xfba4f58c -0, 29932, 29932, 1064, 4256, 0x54311f9b -0, 30996, 30996, 1078, 4312, 0x286386b3 -0, 32074, 32074, 1064, 4256, 0x871896de -0, 33138, 33138, 1064, 4256, 0x9ef9f970 -0, 34202, 34202, 1078, 4312, 0xf9ae97f1 -0, 35280, 35280, 1064, 4256, 0x0ad0d765 -0, 36344, 36344, 1064, 4256, 0x8e6aa9b5 -0, 37408, 37408, 1078, 4312, 0x8362787b -0, 38486, 38486, 1064, 4256, 0x9b6a5d9c -0, 39550, 39550, 1064, 4256, 0xfb715d8f -0, 40614, 40614, 1078, 4312, 0x02bd8075 -0, 41692, 41692, 1064, 4256, 0x428eb932 -0, 42756, 42756, 1064, 4256, 0x17ea8c94 -0, 43820, 43820, 1078, 4312, 0xb3e761d7 -0, 44898, 44898, 1064, 4256, 0x0919755a -0, 45962, 45962, 1064, 4256, 0x5e520edd -0, 47026, 47026, 1078, 4312, 0x69aa070e -0, 48104, 48104, 1064, 4256, 0xf8192f7d -0, 49168, 49168, 1064, 4256, 0xaad4475c -0, 50232, 50232, 1078, 4312, 0x0cabcfcb -0, 51310, 51310, 1064, 4256, 0x952f0f96 -0, 52374, 52374, 1064, 4256, 0x1b805a0c -0, 53438, 53438, 1078, 4312, 0x93043d2a -0, 54516, 54516, 1064, 4256, 0x38b99e44 -0, 55580, 55580, 1064, 4256, 0x60cc52ff -0, 56644, 56644, 1078, 4312, 0x6a875849 -0, 57722, 57722, 1064, 4256, 0xd08d6d0e -0, 58786, 58786, 1064, 4256, 0x36bfe48e -0, 59850, 59850, 1078, 4312, 0x795c6134 -0, 60928, 60928, 1064, 4256, 0x4fd79583 -0, 61992, 61992, 1064, 4256, 0x65e2ab9f -0, 63056, 63056, 1078, 4312, 0xedeede4a -0, 64134, 64134, 1064, 4256, 0x097e0d09 -0, 65198, 65198, 1064, 4256, 0x58afa133 -0, 66262, 66262, 1078, 4312, 0x442525b5 -0, 67340, 67340, 1064, 4256, 0x6645c591 -0, 68404, 68404, 1064, 4256, 0xb0dd948a -0, 69468, 69468, 1078, 4312, 0x12684e69 -0, 70546, 70546, 1064, 4256, 0xb45098e3 -0, 71610, 71610, 1064, 4256, 0xb6d3c61c -0, 72674, 72674, 1078, 4312, 0xb46b5b22 -0, 73752, 73752, 1064, 4256, 0x9a556830 -0, 74816, 74816, 1064, 4256, 0x67ca2b35 +0, 1078, 1078, 1064, 4256, 0x6ca28f25 +0, 2142, 2142, 1078, 4312, 0xd466f806 +0, 3220, 3220, 1064, 4256, 0x59d69463 +0, 4284, 4284, 1064, 4256, 0xf4805f42 +0, 5348, 5348, 1078, 4312, 0x579f22aa +0, 6426, 6426, 1064, 4256, 0xbdc88f45 +0, 7490, 7490, 1064, 4256, 0xc71ebf04 +0, 8554, 8554, 1078, 4312, 0xc1c86e49 +0, 9632, 9632, 1064, 4256, 0x96365506 +0, 10696, 10696, 1064, 4256, 0xaf59bfe5 +0, 11760, 11760, 1078, 4312, 0x4f00811d +0, 12838, 12838, 1064, 4256, 0x0d8a243a +0, 13902, 13902, 1064, 4256, 0x98fc3477 +0, 14966, 14966, 1078, 4312, 0xbf327cc1 +0, 16044, 16044, 1064, 4256, 0xdc52d5bd +0, 17108, 17108, 1064, 4256, 0x29eb1ca6 +0, 18172, 18172, 1078, 4312, 0xf647067f +0, 19250, 19250, 1064, 4256, 0x4f4b70db +0, 20314, 20314, 1064, 4256, 0xa73b7e5d +0, 21378, 21378, 1078, 4312, 0x1f5464ff +0, 22456, 22456, 1064, 4256, 0xcd7a46f2 +0, 23520, 23520, 1064, 4256, 0x7e203f8e +0, 24584, 24584, 1078, 4312, 0x82e5f5ee +0, 25662, 25662, 1064, 4256, 0xfbb65050 +0, 26726, 26726, 1064, 4256, 0x474d33ff +0, 27790, 27790, 1078, 4312, 0x737a0586 +0, 28868, 28868, 1064, 4256, 0xf677f86a +0, 29932, 29932, 1064, 4256, 0xe35919f9 +0, 30996, 30996, 1078, 4312, 0x74f382b2 +0, 32074, 32074, 1064, 4256, 0xe10095c1 +0, 33138, 33138, 1064, 4256, 0x5af2f855 +0, 34202, 34202, 1078, 4312, 0x55239722 +0, 35280, 35280, 1064, 4256, 0xf904da45 +0, 36344, 36344, 1064, 4256, 0xdd8ca94f +0, 37408, 37408, 1078, 4312, 0xcc7a76f6 +0, 38486, 38486, 1064, 4256, 0x67aa5b74 +0, 39550, 39550, 1064, 4256, 0x6559608f +0, 40614, 40614, 1078, 4312, 0x7d297e71 +0, 41692, 41692, 1064, 4256, 0x15c2b2e3 +0, 42756, 42756, 1064, 4256, 0x0bf2896c +0, 43820, 43820, 1078, 4312, 0x17f75da7 +0, 44898, 44898, 1064, 4256, 0x90b27489 +0, 45962, 45962, 1064, 4256, 0xcc7d0de4 +0, 47026, 47026, 1078, 4312, 0x0c8a0586 +0, 48104, 48104, 1064, 4256, 0x184a2e34 +0, 49168, 49168, 1064, 4256, 0xfe354354 +0, 50232, 50232, 1078, 4312, 0x4e3bd1c1 +0, 51310, 51310, 1064, 4256, 0x37a50e20 +0, 52374, 52374, 1064, 4256, 0x2556584a +0, 53438, 53438, 1078, 4312, 0x380f3466 +0, 54516, 54516, 1064, 4256, 0x25b4a1db +0, 55580, 55580, 1064, 4256, 0x77f15645 +0, 56644, 56644, 1078, 4312, 0x278b5864 +0, 57722, 57722, 1064, 4256, 0xcf2e701d +0, 58786, 58786, 1064, 4256, 0x8924e60f +0, 59850, 59850, 1078, 4312, 0x54db60f9 +0, 60928, 60928, 1064, 4256, 0x365993ef +0, 61992, 61992, 1064, 4256, 0x37e4a996 +0, 63056, 63056, 1078, 4312, 0x0b9bda87 +0, 64134, 64134, 1064, 4256, 0x2eed0d61 +0, 65198, 65198, 1064, 4256, 0xa826a02f +0, 66262, 66262, 1078, 4312, 0x9620255e +0, 67340, 67340, 1064, 4256, 0x0f3cc6f2 +0, 68404, 68404, 1064, 4256, 0x14d89149 +0, 69468, 69468, 1078, 4312, 0x87c74a3d +0, 70546, 70546, 1064, 4256, 0x73ca9dd9 +0, 71610, 71610, 1064, 4256, 0x8419cab6 +0, 72674, 72674, 1078, 4312, 0x7d1c59ec +0, 73752, 73752, 1064, 4256, 0xbf927052 +0, 74816, 74816, 1064, 4256, 0x4a422bc3 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/api-h264 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/api-h264 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/api-h264 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/api-h264 2015-06-25 17:20:03.000000000 +0000 @@ -0,0 +1,18 @@ +#tb 0: 1/1200000 +0, 0, 0, 48000, 38016, 0xb9ac19bd +0, 1, 1, 48000, 38016, 0x53c91566 +0, 2, 2, 48000, 38016, 0xb5bd089f +0, 3, 3, 48000, 38016, 0xb81320bb +0, 4, 4, 48000, 38016, 0x7c793dce +0, 5, 5, 48000, 38016, 0x3d605b31 +0, 6, 6, 48000, 38016, 0x40216830 +0, 7, 7, 48000, 38016, 0x11c48f52 +0, 8, 8, 48000, 38016, 0x0f37a013 +0, 9, 9, 48000, 38016, 0xb06cb753 +0, 10, 10, 48000, 38016, 0x6233ca83 +0, 11, 11, 48000, 38016, 0x02b6d5a1 +0, 12, 12, 48000, 38016, 0xf76cc409 +0, 13, 13, 48000, 38016, 0xd19fa5c3 +0, 14, 14, 48000, 38016, 0x8d1c8a02 +0, 15, 15, 48000, 38016, 0x6802966d +0, 16, 16, 48000, 38016, 0x107fb055 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/async ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/async --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/async 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/async 2015-07-21 17:20:03.000000000 +0000 @@ -0,0 +1,7 @@ +open: 0 +size: 2048 +read: 2048 +read: 0 +seek: 1536 +read: 512 +read: 0 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/bcstm ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/bcstm --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/bcstm 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/bcstm 2015-06-24 17:20:02.000000000 +0000 @@ -0,0 +1 @@ +CRC=0xca62d03b diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/bfstm ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/bfstm --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/bfstm 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/bfstm 2015-06-24 17:20:02.000000000 +0000 @@ -0,0 +1 @@ +CRC=0xbd3d0d33 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-argb ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-argb --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-argb 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-argb 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 56320, 0xfcaa920b diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-argb-aexp ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-argb-aexp --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-argb-aexp 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-argb-aexp 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xfdd37c43 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dx10-bc1 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dx10-bc1 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dx10-bc1 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dx10-bc1 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xed2f850f diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dx10-bc1a ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dx10-bc1a --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dx10-bc1a 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dx10-bc1a 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x473b484b diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dx10-bc2 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dx10-bc2 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dx10-bc2 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dx10-bc2 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x2bce3baa diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dx10-bc3 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dx10-bc3 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dx10-bc3 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dx10-bc3 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xb91d3c62 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dx10-bc4 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dx10-bc4 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dx10-bc4 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dx10-bc4 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xfdfd1751 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dx10-bc5 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dx10-bc5 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dx10-bc5 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dx10-bc5 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x79bd207e diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt1 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt1 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt1 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt1 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 32768, 0xf52adc80 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt1a ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt1a --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt1a 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt1a 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xcabb50ea diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt1-normalmap ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt1-normalmap --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt1-normalmap 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt1-normalmap 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x2b411855 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt2 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt2 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt2 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt2 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x11cebeb0 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt3 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt3 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt3 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt3 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x729b74ba diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt4 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt4 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt4 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt4 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x31aaacd6 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xfd3166aa diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-aexp ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-aexp --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-aexp 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-aexp 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x3c987914 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-normalmap ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-normalmap --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-normalmap 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-normalmap 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xd29b1ea1 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-normalmap-ati ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-normalmap-ati --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-normalmap-ati 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-normalmap-ati 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x54cb212f diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-rbxg ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-rbxg --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-rbxg 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-rbxg 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x37588d12 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-rgxb ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-rgxb --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-rgxb 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-rgxb 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xfb6b91cf diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-rxbg ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-rxbg --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-rxbg 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-rxbg 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xc6cb8cbe diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-rxgb ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-rxgb --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-rxgb 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-rxgb 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xb67d936a diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-xgbr ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-xgbr --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-xgbr 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-xgbr 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xb0e69293 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-xgxr ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-xgxr --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-xgxr 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-xgxr 2015-06-23 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xa93de1ad diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-xrbg ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-xrbg --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-xrbg 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-xrbg 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xf20d8b69 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-ycocg ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-ycocg --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-ycocg 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-ycocg 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x0d0c8d20 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-ycocg-scaled ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-ycocg-scaled --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-dxt5-ycocg-scaled 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-dxt5-ycocg-scaled 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x5a089973 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-pal ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-pal --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-pal 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-pal 2015-07-20 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 65536, 0x4287e5cd diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-pal-ati ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-pal-ati --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-pal-ati 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-pal-ati 2015-07-20 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x6ac18060 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgb16 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgb16 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgb16 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgb16 2015-07-01 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xc8910265 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgb24 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgb24 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgb24 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgb24 2015-07-01 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 24576, 0xef0f9653 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgba ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgba --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgba 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgba 2015-07-22 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 25600, 0xa2a47b2f diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgtc1s ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgtc1s --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgtc1s 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgtc1s 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xcda652a4 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgtc1u ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgtc1u --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgtc1u 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgtc1u 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x629a1b44 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgtc2s ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgtc2s --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgtc2s 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgtc2s 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0xa0135ca8 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgtc2u ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgtc2u --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgtc2u 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgtc2u 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x38cb221a diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgtc2u-xy ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgtc2u-xy --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-rgtc2u-xy 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-rgtc2u-xy 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x79bd207e diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-uyvy ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-uyvy --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-uyvy 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-uyvy 2015-07-01 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 8192, 0x3c658750 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-xbgr ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-xbgr --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-xbgr 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-xbgr 2015-07-01 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x70336a28 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-xrgb ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-xrgb --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-xrgb 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-xrgb 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x702f6a28 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-y ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-y --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-y 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-y 2015-07-01 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 8192, 0x56eca90f diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-ya ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-ya --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-ya 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-ya 2015-07-01 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 28160, 0xd3981fcb diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-ycocg ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-ycocg --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-ycocg 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-ycocg 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 16384, 0x4cb08d0a diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-yuyv ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-yuyv --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/dds-yuyv 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/dds-yuyv 2015-07-01 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 8192, 0xc1108750 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/d-eavp6-demux ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/d-eavp6-demux --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/d-eavp6-demux 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/d-eavp6-demux 2015-06-26 17:20:02.000000000 +0000 @@ -0,0 +1,98 @@ +#tb 0: 32767/982027 +#tb 1: 32767/982027 +0, 0, 0, 1, 1860, 0xbd548c4c +1, 0, 0, 1, 1748, 0x96046284 +0, 1, 1, 1, 1044, 0x814efc86, F=0x0 +1, 1, 1, 1, 204, 0x0ea1573a, F=0x0 +0, 2, 2, 1, 1036, 0xf672f905, F=0x0 +1, 2, 2, 1, 240, 0x634e7448, F=0x0 +0, 3, 3, 1, 1048, 0xe0f80ee7, F=0x0 +1, 3, 3, 1, 260, 0xc35b8521, F=0x0 +0, 4, 4, 1, 1072, 0x980918e9, F=0x0 +1, 4, 4, 1, 376, 0x6e5cb85e, F=0x0 +0, 5, 5, 1, 1052, 0x73e6fd33, F=0x0 +1, 5, 5, 1, 344, 0xaacdad6b, F=0x0 +0, 6, 6, 1, 1056, 0x5242fb20, F=0x0 +1, 6, 6, 1, 404, 0x7498be1f, F=0x0 +0, 7, 7, 1, 1092, 0x8b7111c2, F=0x0 +1, 7, 7, 1, 368, 0xe2b8afd2, F=0x0 +0, 8, 8, 1, 1144, 0xc1003410, F=0x0 +1, 8, 8, 1, 412, 0x3615c893, F=0x0 +0, 9, 9, 1, 1152, 0x6b9234f9, F=0x0 +1, 9, 9, 1, 424, 0x04a5cdb7, F=0x0 +0, 10, 10, 1, 1132, 0x7d45384b, F=0x0 +1, 10, 10, 1, 356, 0x4ad5a9d5, F=0x0 +0, 11, 11, 1, 1164, 0x47d637a1, F=0x0 +1, 11, 11, 1, 448, 0x2811d959, F=0x0 +0, 12, 12, 1, 1152, 0xede932ad, F=0x0 +1, 12, 12, 1, 316, 0x911a9c11, F=0x0 +0, 13, 13, 1, 1112, 0x49f31a9e, F=0x0 +1, 13, 13, 1, 312, 0x1bb08de2, F=0x0 +0, 14, 14, 1, 1112, 0x7f022bc7, F=0x0 +1, 14, 14, 1, 308, 0x2c3698bb, F=0x0 +0, 15, 15, 1, 1128, 0x2a7a4381, F=0x0 +1, 15, 15, 1, 424, 0xec77c694, F=0x0 +0, 16, 16, 1, 1012, 0x22a3f64b, F=0x0 +1, 16, 16, 1, 220, 0x7506677f, F=0x0 +0, 17, 17, 1, 1012, 0x0ea3f03b, F=0x0 +1, 17, 17, 1, 204, 0xbf3f607e, F=0x0 +0, 18, 18, 1, 1072, 0xdf860cc2, F=0x0 +1, 18, 18, 1, 416, 0x5f08ca69, F=0x0 +0, 19, 19, 1, 1052, 0x29a9116a, F=0x0 +1, 19, 19, 1, 244, 0x8d1a7c05, F=0x0 +0, 20, 20, 1, 1048, 0xfeb1107d, F=0x0 +1, 20, 20, 1, 260, 0xd0b27b40, F=0x0 +0, 21, 21, 1, 1084, 0xeed50a32, F=0x0 +1, 21, 21, 1, 304, 0x5e5e8f10, F=0x0 +0, 22, 22, 1, 992, 0xabd4e695, F=0x0 +1, 22, 22, 1, 304, 0x2c839490, F=0x0 +0, 23, 23, 1, 1016, 0x7396e5a4, F=0x0 +1, 23, 23, 1, 264, 0x5bac855a, F=0x0 +0, 24, 24, 1, 1000, 0x1d91ef45, F=0x0 +1, 24, 24, 1, 220, 0xcda465a8, F=0x0 +0, 25, 25, 1, 960, 0x1c99da31, F=0x0 +1, 25, 25, 1, 280, 0xc1d08783, F=0x0 +0, 26, 26, 1, 948, 0x48a4c938, F=0x0 +1, 26, 26, 1, 440, 0xe2ebd578, F=0x0 +0, 27, 27, 1, 952, 0xea12d081, F=0x0 +1, 27, 27, 1, 188, 0xe7b15222, F=0x0 +0, 28, 28, 1, 944, 0x9a83dce3, F=0x0 +1, 28, 28, 1, 208, 0xc3f05b2a, F=0x0 +0, 29, 29, 1, 916, 0xacdaba99, F=0x0 +1, 29, 29, 1, 248, 0x95f47262, F=0x0 +0, 30, 30, 1, 1408, 0x8b86c584 +1, 30, 30, 1, 452, 0x2444db2a +0, 31, 31, 1, 848, 0xdaed99bd, F=0x0 +1, 31, 31, 1, 224, 0x1edf679b, F=0x0 +0, 32, 32, 1, 836, 0x2b0ba278, F=0x0 +1, 32, 32, 1, 256, 0x9fc079ff, F=0x0 +0, 33, 33, 1, 804, 0xa9268780, F=0x0 +1, 33, 33, 1, 240, 0x1ef76c13, F=0x0 +0, 34, 34, 1, 744, 0xb48f68fc, F=0x0 +1, 34, 34, 1, 216, 0x51e56846, F=0x0 +0, 35, 35, 1, 608, 0x538734c4, F=0x0 +1, 35, 35, 1, 220, 0x09b26d72, F=0x0 +0, 36, 36, 1, 604, 0x003520de, F=0x0 +1, 36, 36, 1, 212, 0xa124688a, F=0x0 +0, 37, 37, 1, 756, 0xc375752e, F=0x0 +1, 37, 37, 1, 288, 0x76bb8cec, F=0x0 +0, 38, 38, 1, 820, 0xd9529ca1, F=0x0 +1, 38, 38, 1, 336, 0xc15ca7a3, F=0x0 +0, 39, 39, 1, 900, 0xe447be51, F=0x0 +1, 39, 39, 1, 308, 0x1b92950e, F=0x0 +0, 40, 40, 1, 936, 0x17dcc60d, F=0x0 +1, 40, 40, 1, 300, 0x0f608f70, F=0x0 +0, 41, 41, 1, 952, 0xd5d8e11d, F=0x0 +1, 41, 41, 1, 424, 0x2fb3c6a6, F=0x0 +0, 42, 42, 1, 988, 0x4596e71c, F=0x0 +1, 42, 42, 1, 488, 0x3cb2ead4, F=0x0 +0, 43, 43, 1, 1040, 0x46300cfa, F=0x0 +1, 43, 43, 1, 452, 0x431dd5b1, F=0x0 +0, 44, 44, 1, 1040, 0xc8ad0ac0, F=0x0 +1, 44, 44, 1, 428, 0x8162c607, F=0x0 +0, 45, 45, 1, 1116, 0x9b4319da, F=0x0 +1, 45, 45, 1, 428, 0xe430de88, F=0x0 +0, 46, 46, 1, 1184, 0x016d38b6, F=0x0 +1, 46, 46, 1, 424, 0x6baecd21, F=0x0 +0, 47, 47, 1, 1188, 0xe885478b, F=0x0 +1, 47, 47, 1, 392, 0xc001c8e9, F=0x0 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-formats ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-formats --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-formats 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-formats 2015-06-21 17:20:02.000000000 +0000 @@ -0,0 +1,85 @@ +mono +2 channels (FC+LFE) +stereo +2.1 +3.0 +3.1 +3 channels (FC+BL+BR) +4 channels (FC+LFE+BL+BR) +quad +5 channels (FL+FR+LFE+BL+BR) +5.0 +5.1 +2 channels (FC+BC) +3 channels (FC+LFE+BC) +3.0(back) +4 channels (FL+FR+LFE+BC) +4.0 +4.1 +3 channels (FC+SL+SR) +4 channels (FC+LFE+SL+SR) +quad(side) +5 channels (FL+FR+LFE+SL+SR) +5.0(side) +5.1(side) +5 channels (FC+BL+BR+SL+SR) +6 channels (FC+LFE+BL+BR+SL+SR) +6 channels (FL+FR+BL+BR+SL+SR) +7 channels (FL+FR+LFE+BL+BR+SL+SR) +7.0 +7.1 +4 channels (FC+BC+SL+SR) +5 channels (FC+LFE+BC+SL+SR) +5 channels (FL+FR+BC+SL+SR) +6 channels (FL+FR+LFE+BC+SL+SR) +6.0 +6.1 +3 channels (FC+DL+DR) +4 channels (FC+LFE+DL+DR) +4 channels (FL+FR+DL+DR) +5 channels (FL+FR+LFE+DL+DR) +5 channels (FL+FR+FC+DL+DR) +6 channels (FL+FR+FC+LFE+DL+DR) +5 channels (FC+BL+BR+DL+DR) +6 channels (FC+LFE+BL+BR+DL+DR) +6 channels (FL+FR+BL+BR+DL+DR) +7 channels (FL+FR+LFE+BL+BR+DL+DR) +7 channels (FL+FR+FC+BL+BR+DL+DR) +8 channels (FL+FR+FC+LFE+BL+BR+DL+DR) +4 channels (FC+BC+DL+DR) +5 channels (FC+LFE+BC+DL+DR) +5 channels (FL+FR+BC+DL+DR) +6 channels (FL+FR+LFE+BC+DL+DR) +6 channels (FL+FR+FC+BC+DL+DR) +7 channels (FL+FR+FC+LFE+BC+DL+DR) +5 channels (FC+SL+SR+DL+DR) +6 channels (FC+LFE+SL+SR+DL+DR) +6 channels (FL+FR+SL+SR+DL+DR) +7 channels (FL+FR+LFE+SL+SR+DL+DR) +7 channels (FL+FR+FC+SL+SR+DL+DR) +8 channels (FL+FR+FC+LFE+SL+SR+DL+DR) +7 channels (FC+BL+BR+SL+SR+DL+DR) +8 channels (FC+LFE+BL+BR+SL+SR+DL+DR) +8 channels (FL+FR+BL+BR+SL+SR+DL+DR) +6 channels (FC+BC+SL+SR+DL+DR) +7 channels (FC+LFE+BC+SL+SR+DL+DR) +7 channels (FL+FR+BC+SL+SR+DL+DR) +8 channels (FL+FR+LFE+BC+SL+SR+DL+DR) +8 channels (FL+FR+FC+BC+SL+SR+DL+DR) +-1 = ff_parse_channel_layout(FFFFFFFFFFFFFFFF, -1, blah); +0 = ff_parse_channel_layout(0000000000000004, 1, 1); +0 = ff_parse_channel_layout(0000000000000003, 2, 2); +-1 = ff_parse_channel_layout(FFFFFFFFFFFFFFFF, -1, -1); +0 = ff_parse_channel_layout(0000000000000000, 60, 60); +-1 = ff_parse_channel_layout(FFFFFFFFFFFFFFFF, -1, 65); +0 = ff_parse_channel_layout(0000000000000004, 1, 1c); +0 = ff_parse_channel_layout(0000000000000003, 2, 2c); +-1 = ff_parse_channel_layout(FFFFFFFFFFFFFFFF, -1, -1c); +0 = ff_parse_channel_layout(0000000000000000, 60, 60c); +-1 = ff_parse_channel_layout(FFFFFFFFFFFFFFFF, -1, 65c); +0 = ff_parse_channel_layout(000000000000003F, 6, 5.1); +0 = ff_parse_channel_layout(0000000000000003, 2, stereo); +0 = ff_parse_channel_layout(0000000000000004, 1, 1+1+1+1); +0 = ff_parse_channel_layout(0000000000000004, 1, 1c+1c+1c+1c); +0 = ff_parse_channel_layout(0000000000000007, 3, 2c+1c); +0 = ff_parse_channel_layout(0000000000000003, 2, 0x3); diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-mergeplanes ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-mergeplanes --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-mergeplanes 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-mergeplanes 2015-07-19 17:20:03.000000000 +0000 @@ -0,0 +1,51 @@ +#tb 0: 1/25 +0, 0, 0, 1, 304128, 0x90660272 +0, 1, 1, 1, 304128, 0x6b09c8a6 +0, 2, 2, 1, 304128, 0x343858f3 +0, 3, 3, 1, 304128, 0x2f8ba46c +0, 4, 4, 1, 304128, 0xe31fc163 +0, 5, 5, 1, 304128, 0xc1f3a301 +0, 6, 6, 1, 304128, 0x76b132d2 +0, 7, 7, 1, 304128, 0xf47b97f1 +0, 8, 8, 1, 304128, 0x12089641 +0, 9, 9, 1, 304128, 0x04156f0f +0, 10, 10, 1, 304128, 0xc8bf96e8 +0, 11, 11, 1, 304128, 0xbecdae62 +0, 12, 12, 1, 304128, 0x74053994 +0, 13, 13, 1, 304128, 0xc1f3eec7 +0, 14, 14, 1, 304128, 0xf4e496b3 +0, 15, 15, 1, 304128, 0xa5a3d663 +0, 16, 16, 1, 304128, 0x1d3738ea +0, 17, 17, 1, 304128, 0xfdfa09f5 +0, 18, 18, 1, 304128, 0x8844bbc5 +0, 19, 19, 1, 304128, 0x7eb20cea +0, 20, 20, 1, 304128, 0x5b5e7351 +0, 21, 21, 1, 304128, 0x2b5e5fc1 +0, 22, 22, 1, 304128, 0xd6a2e9a7 +0, 23, 23, 1, 304128, 0xf56ed1be +0, 24, 24, 1, 304128, 0xd60530a5 +0, 25, 25, 1, 304128, 0x363aa5bf +0, 26, 26, 1, 304128, 0x37f56bb0 +0, 27, 27, 1, 304128, 0xe8428c1f +0, 28, 28, 1, 304128, 0x78ef39cf +0, 29, 29, 1, 304128, 0x76b2ab97 +0, 30, 30, 1, 304128, 0x3f09f5ef +0, 31, 31, 1, 304128, 0x6f2c0371 +0, 32, 32, 1, 304128, 0x8baaf4a3 +0, 33, 33, 1, 304128, 0xda157bc0 +0, 34, 34, 1, 304128, 0xae46ebb0 +0, 35, 35, 1, 304128, 0xbe3458a2 +0, 36, 36, 1, 304128, 0x9784f913 +0, 37, 37, 1, 304128, 0xa67d93cd +0, 38, 38, 1, 304128, 0x8b0e84ba +0, 39, 39, 1, 304128, 0x583250f1 +0, 40, 40, 1, 304128, 0x7d1ee0a8 +0, 41, 41, 1, 304128, 0x6d83f980 +0, 42, 42, 1, 304128, 0x027ce4c5 +0, 43, 43, 1, 304128, 0xcf1a0c75 +0, 44, 44, 1, 304128, 0xbd1c2e5c +0, 45, 45, 1, 304128, 0x36d4fe48 +0, 46, 46, 1, 304128, 0x9cc1650e +0, 47, 47, 1, 304128, 0xf1af6288 +0, 48, 48, 1, 304128, 0x5eb8d36e +0, 49, 49, 1, 304128, 0x2c4f2305 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixdesc-ayuv64le ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixdesc-ayuv64le --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixdesc-ayuv64le 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixdesc-ayuv64le 2015-07-24 17:20:02.000000000 +0000 @@ -0,0 +1 @@ +pixdesc-ayuv64le 2269279a2df156931021793927876e84 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixdesc-ya8 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixdesc-ya8 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixdesc-ya8 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixdesc-ya8 2015-07-03 17:20:03.000000000 +0000 @@ -0,0 +1 @@ +pixdesc-ya8 1719d17930180793286230dd38d18edb diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-copy ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-copy --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-copy 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-copy 2015-07-24 17:20:02.000000000 +0000 @@ -2,6 +2,7 @@ 0rgb 527ef3d164c8fd0700493733959689c2 abgr 023ecf6396d324edb113e4a483b79ba2 argb f003b555ef429222005d33844cca9325 +ayuv64le 07b9c969dfbe4add4c0626773b151d4f bgr0 6fcd67c8e6cec723dab21c70cf53dc16 bgr24 4cff3814819f02ecf5824edfd768d2b1 bgr444be 1cd47c1555f947dfcba99192e3429d20 @@ -53,6 +54,7 @@ uyvy422 3bcf3c80047592f2211fae3260b1b65d xyz12be a1ef56bf746d71f59669c28e48fc8450 xyz12le 831ff03c1ba4ef19374686f16a064d8c +ya8 e4bdc2165c1fe29905accfc68e7597ca yuv410p 5d4d992a7728431aa4e0700f87fb7fd8 yuv411p 7e1300e89f5bc07939e2c4a6acbdf267 yuv420p a014c7eb7a8385d1dd092b7a583f1bff diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-crop ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-crop --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-crop 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-crop 2015-07-24 17:20:02.000000000 +0000 @@ -2,6 +2,7 @@ 0rgb 974833c777e6abe6d84dc59af2ca5625 abgr 1d21f5b8a20186ac9dd54459c986a2a7 argb 8b822972049a1e207000763f2564d6e0 +ayuv64le ab2f7bc8f150af47c42c778e3ea28bce bgr0 38a84849a9198667c348c686802e3b52 bgr24 1dacd8e04bf0eff163e82250d01a9cc7 bgr444be e2d2b864dfa528e77684ddc117f2d974 @@ -50,6 +51,7 @@ rgba64le fea8ebfc869b52adf353778f29eac7a7 xyz12be cb4571f9aaa7b59f999ef327276104b7 xyz12le cd6aae8d26b18bdb4b9d068586276d91 +ya8 2a888cb3018a09443435ce8bfa731cc1 yuv410p 3bb6c7b64f2c46bc5e8b77198ce4ea58 yuv411p 693e4afe96998e6dd91734037d75d887 yuv420p 510d36163e4d3710988c23c2240ca6dc diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-field ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-field --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-field 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-field 2015-07-24 17:20:02.000000000 +0000 @@ -2,6 +2,7 @@ 0rgb e2c35753a2271d1f9455b1809bc0e907 abgr c0eb95959edf5d40ff8af315e62d0f8a argb 6dca4f2987b49b7d63f702d17bace630 +ayuv64le d9836decca6323ba88b3b3d02257c0b6 bgr0 1da3fdbac616b3b410d081e39ed7a1f6 bgr24 573c76d77b1cbe6534ea7c0267dc1b13 bgr444be 064887b4ca8f49cfb7c776057bc75c74 @@ -53,6 +54,7 @@ uyvy422 1c49e44ab3f060e85fc4a3a9464f045e xyz12be d2fa69ec91d3ed862f2dac3f8e7a3437 xyz12le 02bccd5e0b6824779a1f848b0ea3e3b5 +ya8 9b3f26c05060aab832817967bf3c90ab yuv410p a85920d6bd26f51306e2ecbe71d1c554 yuv411p 9106e283d5dbcfba01c611886d58871a yuv420p 9ea8ed3c22c31c0354b7face540bb280 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-fieldorder ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-fieldorder --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-fieldorder 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-fieldorder 2015-07-24 17:20:02.000000000 +0000 @@ -2,6 +2,7 @@ 0rgb 2b0f066cfa0bef378a492875d541de8f abgr 832924b5351361db68dbdbb96c60ae55 argb 80d08e68cb91bc8f2f817516e65f0bd0 +ayuv64le 84ef6260fe02427da946d4a2207fb54c bgr0 d2c676224ea80ac3ce01afde325ea1a0 bgr24 b7fdbcd10f20e6ea2d40aae0f329f80d bgr444be ca5acc0d5315d6d9f4422337c6f20842 @@ -48,6 +49,7 @@ uyvy422 75de70e31c435dde878002d3f22b238a xyz12be 15f5cda71de5fef9cec5e75e3833b6bc xyz12le 7be6c8781f38c21a6b8f602f62ca31e6 +ya8 9dab461f986b50151ccb2eb3bac75da9 yuv411p e4a040e0e786c4dae07d9d3f90a54905 yuv422p 16ce67249c6ce7ef57a433646ad6dfc1 yuv422p10be 62ae323dcc41aabf8ff6ecc53b119ce8 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-hflip ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-hflip --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-hflip 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-hflip 2015-07-24 17:20:02.000000000 +0000 @@ -2,6 +2,7 @@ 0rgb ada57572ee2b35f86edac9b911ce8523 abgr d2da6c3ee72e4a89a7cd011dd08566b2 argb 36cf791c52c5463bfc52a070de54337e +ayuv64le 4cedbc38b3d4dcb26cdab170ce6d667b bgr0 66e9fda4e658d73bfe4fc9d792542271 bgr24 db074979bd684ca4547e28681ad3f6ab bgr444be 63ad2fe7b4e44b11c5ca03b545a941ca @@ -50,6 +51,7 @@ rgba64le 0c810d8b3a6bca10321788e1cb145340 xyz12be 25f90259ff8a226befdaec3dfe82996e xyz12le 926c0791d59aaff61b2778e8ada3316d +ya8 68b888a5e5e5e51f57c282d98e736ad4 yuv410p c49fd0c55c41185b1580aac77211992b yuv411p c416371077dce13d31bf1dc706111ae7 yuv420p eb8d9f02db98e10400781428c43e9438 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-il ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-il --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-il 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-il 2015-07-24 17:20:02.000000000 +0000 @@ -2,6 +2,7 @@ 0rgb 53efe0182723cd1dedfdbf56357c76f5 abgr 97603869e6248a8e5d8501563a11b114 argb 9e50e6ef02c83f28e97865a1f46ddfcd +ayuv64le 6f45f683e99ddf4180c7c7f47719efcc bgr0 590dcd1297d1dd4541eea217381db604 bgr24 73afe7b447b083a7c2d682abe8dd451a bgr444be 4fa078adc981fd07440a7b657c98c4c1 @@ -52,6 +53,7 @@ uyvy422 d6ee3ca43356d08c392382b24b22cda5 xyz12be 7c7d54c55f136cbbc50b18029f3be0b3 xyz12le 090ba6b1170baf2b1358b43b971d33b0 +ya8 ec043b98eb0fd044fd8072d91d9cd31a yuv410p dea1ab8843465adf5b8240b2d98fd85b yuv411p 8bf73777a5ff43c126be274245aceff1 yuv420p f1f4e7e94a76d5320049464bdeac24ed diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-lut ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-lut --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-lut 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-lut 2015-07-03 17:20:03.000000000 +0000 @@ -7,12 +7,32 @@ yuv410p 51b39a0e33f108e652457a26667319ea yuv411p 9204c5af92aef4922a05f58c1f6c095e yuv420p 7c43bb0cae8dee633375c89295598508 +yuv420p10le 1352712dd31cce78bd5441294004cf85 +yuv420p12le c66f82da9fda458ba3abda057c58e591 +yuv420p14le e45cb5e2a75bf6143da0b55004767f78 +yuv420p16le eff54782c51770edfd6b84c958ac7120 +yuv420p9le 62bf40b1cb97660238c991efa6ef2962 yuv422p 67df35da0c35e54882492b2365438254 +yuv422p10le 0158371a800294015def7f0ef66c78ea +yuv422p12le bc49d3863ffb89658a17bf8c4fe773b0 +yuv422p14le b55cb791d286b0b3391fe7481785e5b3 +yuv422p16le fc3b2ba889ffaf1633000fc774307c33 +yuv422p9le bb6d5a46073ff4aabfcd2f97416ccb59 yuv440p 5e41adcfc27be4369afd217b61b2ffe3 +yuv440p10le 8b49714bba268fb4a79b5a84223ad17a +yuv440p12le 15ab4f453238bd9c13b18af81e22f060 yuv444p a2b58590aef88db2c1f14a1a3a3b0359 +yuv444p10le c076c20fc808f95b34adb88aca442f48 +yuv444p12le af8d4dd88169d5cffc2f3fce6333a94c +yuv444p14le 93367133e25d088d4535199ed1f1ed58 +yuv444p16le 800940feec14365ccd9b4863e38f6991 +yuv444p9le 08cab94dfa6d2a688f9a8cbac8c4b61b yuva420p 518a380bf1af60ef2ecf4754eec088e9 +yuva420p16le 72ad4fa535b007d122666ce103ef9c8b yuva422p 7110ac2e37377b05b6fc5ad967dfabb5 +yuva422p16le e2867210660ada5784a60b4339ac52c0 yuva444p 642f3958f141dece9e99407945e2ef43 +yuva444p16le ab04ba8acbe38085b0df650d82065eb0 yuvj420p 65bc88887c7f06a6221155ca7f9cfca4 yuvj422p ff5baffefc8ffe4547653092fd7da200 yuvj440p ef3f27270e60ac06582e3ac7c2f3e6fa diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-null ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-null --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-null 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-null 2015-07-24 17:20:02.000000000 +0000 @@ -2,6 +2,7 @@ 0rgb 527ef3d164c8fd0700493733959689c2 abgr 023ecf6396d324edb113e4a483b79ba2 argb f003b555ef429222005d33844cca9325 +ayuv64le 07b9c969dfbe4add4c0626773b151d4f bgr0 6fcd67c8e6cec723dab21c70cf53dc16 bgr24 4cff3814819f02ecf5824edfd768d2b1 bgr444be 1cd47c1555f947dfcba99192e3429d20 @@ -53,6 +54,7 @@ uyvy422 3bcf3c80047592f2211fae3260b1b65d xyz12be a1ef56bf746d71f59669c28e48fc8450 xyz12le 831ff03c1ba4ef19374686f16a064d8c +ya8 e4bdc2165c1fe29905accfc68e7597ca yuv410p 5d4d992a7728431aa4e0700f87fb7fd8 yuv411p 7e1300e89f5bc07939e2c4a6acbdf267 yuv420p a014c7eb7a8385d1dd092b7a583f1bff diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-pad ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-pad --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-pad 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-pad 2015-07-03 17:20:03.000000000 +0000 @@ -11,6 +11,7 @@ rgb0 78d500c8361ab6423a4826a00268c908 rgb24 17f9e2e0c609009acaf2175c42d4a2a5 rgba b157c90191463d34fb3ce77b36c96386 +ya8 310847fa55017bcb2ceb5dcbbea3557c yuv410p cb871dcc1e84a7ef1d21f9237b88cf6e yuv411p aec2c1740de9a62db0d41f4dda9121b0 yuv420p 4398e408fc35436ce4b20468946f58b6 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-scale ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-scale --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-scale 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-scale 2015-07-24 17:20:02.000000000 +0000 @@ -2,12 +2,13 @@ 0rgb 80a58af8c639743307207ab4b69ca863 abgr 63f2eaa8712ea6108985f4a0b83587c9 argb f0e17c71a40643c33a5bcfb481f6d8f8 +ayuv64le 59fb016f9874062d0be77cb3920ffed2 bgr0 243d58ca64f97b2f415b4c63cb79f0e1 bgr24 18744aaab4b8bce065a7144dc0ccf921 bgr444be 920760bee08c4fa161bf060e21ebba92 bgr444le 01be36a28ebca1a11eb4d192986cd4e9 -bgr48be a6fee4ac9f70d0da6a4b3a0e6353ca7f -bgr48le 9c5d30b3b31ceaf3009fc7f1cf1cf7b6 +bgr48be 3ae02769c69d2512eaa26fff65763acb +bgr48le a6ce2344f07b77438258b6787fe5c24c bgr4_byte 01efea74088e5e3343c19ee053b95f31 bgr555be ab353278d103d379e1ec86e5cabb645f bgr555le 16ccbf59297e4b9ab25fd8af5a84a95d @@ -15,8 +16,8 @@ bgr565le 82a81e7c9d4e0431fa22f4df9694afdc bgr8 2c57e76ccf04d51de6acafcf35d6fa70 bgra d8316272bc3a360ef9dff3ecc84520a3 -bgra64be 688499004461a2ce9debadb36dbcde5b -bgra64le c80dda435633c301e14d5b46a7edcf8d +bgra64be 4e6a1b9f9c18b881c27d76611d45f737 +bgra64le efeee0abcc658ebcff049d5e74d74943 gbrap e97ea4a104467c482173b7eaa57c14e3 gbrp dc3387f925f972c61aae7eb23cdc19f0 gbrp10be 3a6d59192b6bb89ab42252b2b4818519 @@ -39,8 +40,8 @@ rgb24 e022e741451e81f2ecce1c7240b93e87 rgb444be db52b9ecdf98479b693e3f4bd9e77bac rgb444le 63288425c05f146cde5c82b85bb126e0 -rgb48be c2e456838a71237cb1398ab5a7c35a6e -rgb48le 6ef772549307349c599f419313c75b7a +rgb48be 45b25016f10d54cf36eef3479afd8249 +rgb48le 40577b147620ecfb115717473d000697 rgb4_byte 9e540a2e7193ebcbf1c7f85d192a0c4e rgb555be cb5407a0d40f3d0120155daeaaa9a222 rgb555le c15540d1fc887882c35860634009c439 @@ -48,11 +49,12 @@ rgb565le a4a6ef89cdc10282b428cb1392f2a353 rgb8 bcdc033b4ef0979d060dbc8893d4db58 rgba 85bb5d03cea1c6e8002ced3373904336 -rgba64be 21611863fbbe149416a11e95877824ac -rgba64le 35c195a441e5f8ca8e7e4ed098ecf0c1 +rgba64be ee73e57923af984b31cc7795d13929da +rgba64le 783d2779adfafe3548bdb671ec0de69e uyvy422 aeb4ba4f9f003ae21f6d18089198244f -xyz12be f6350b9a2f5add20d3d67f59c100166f -xyz12le 982935a6ea6a297fd7be8aee0fda9870 +xyz12be c7ba8345998c0141ddc079cdd29b1a40 +xyz12le 95f5d3a0de834cc495c9032a14987cde +ya8 9d08dbcf1ed51bd4e437cc1f1db583e4 yuv410p e8f49b5fb9335b62c074f7f8bb0234fc yuv411p 5af32557c93beb482e26e7af693104c6 yuv420p 5d3ac239c3712143560b1dfbd48a7ddd diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-vflip ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-vflip --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-pixfmts-vflip 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-pixfmts-vflip 2015-07-24 17:20:02.000000000 +0000 @@ -2,6 +2,7 @@ 0rgb 76b792f8ce8a72925e04294dc2f25b36 abgr 8b94f489e68802d76f1e2844688a4911 argb 3fd6af7ef2364d8aa845d45db289a04a +ayuv64le 558671dd31d0754cfa6344eaf441df78 bgr0 7117438cf000254610f23625265769b5 bgr24 52b2c21cbc166978a38a646c354b6858 bgr444be 6c6cb3f5a26d5fd00bd04467bb0bbcca @@ -53,6 +54,7 @@ uyvy422 3a237e8376264e0cfa78f8a3fdadec8a xyz12be 810644e008deb231850d779aaa27cc7e xyz12le 829701db461b43533cf9241e0743bc61 +ya8 4ac56b8d1c3efc54d5fb585608a8c688 yuv410p c7adfe96c8e043a6cb9290c39bf8063c yuv411p 3fce29db403a25f81be39e01aaf6ff3a yuv420p d64fae96fac22aefa8fbcf45a09f37c1 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-00 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-00 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-00 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-00 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x05b789ef diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-01 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-01 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-01 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-01 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x4f234e65 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-02 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-02 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-02 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-02 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0xc2dd0535 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-03 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-03 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-03 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-03 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x09dbc38a diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-04 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-04 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-04 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-04 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x32c6a66e diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-05 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-05 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-05 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-05 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0xc3c64ec6 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-06 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-06 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-06 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-06 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x38e84065 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-07 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-07 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-07 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-07 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0xfbdeec94 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-08 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-08 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-08 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-08 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x8f7c85a2 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-09 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-09 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-09 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-09 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x9609a659 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-10 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-10 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-10 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-10 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x4adb45d6 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-11 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-11 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-11 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-11 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0xd0d891ff diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-12 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-12 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-12 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-12 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0xd0d891ff diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-13 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-13 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-13 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-13 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x09d4da80 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-14 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-14 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-14 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-14 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x145f34c8 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-15 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-15 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-15 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-15 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x11eea9b4 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-16 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-16 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-16 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-16 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x8bc800ee diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-17 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-17 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-17 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-17 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x7195b9a7 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-18 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-18 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-18 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-18 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0xb47a081c diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-19 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-19 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-19 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-19 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x948dc65d diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-20 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-20 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-20 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-20 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x64a388ea diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-21 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-21 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-21 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-21 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0xb7ae17f5 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-22 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-22 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-22 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-22 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0xe5736698 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-23 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-23 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-23 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-23 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x8d15a472 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-24 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-24 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-24 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-removegrain-mode-24 2015-07-10 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x77f6d439 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmc ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmc --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmc 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmc 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0xa950d0d9 +0, 1, 1, 1, 152064, 0x6a6933c3 +0, 2, 2, 1, 152064, 0x66a1da3a +0, 3, 3, 1, 152064, 0xe591aa12 +0, 4, 4, 1, 152064, 0x42413288 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmd ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmd --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmd 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmd 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x962d1371 +0, 1, 1, 1, 152064, 0xe7db1d51 +0, 2, 2, 1, 152064, 0x3bb0c409 +0, 3, 3, 1, 152064, 0xcc213557 +0, 4, 4, 1, 152064, 0x913e1048 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmg ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmg --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmg 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmg 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x45a6c9a8 +0, 1, 1, 1, 152064, 0xe7ba65fc +0, 2, 2, 1, 152064, 0x88ab8fcc +0, 3, 3, 1, 152064, 0x91478b9d +0, 4, 4, 1, 152064, 0xb7ecc7cf diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmh ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmh --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmh 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-agmh 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x96464057 +0, 1, 1, 1, 152064, 0x58c4e280 +0, 2, 2, 1, 152064, 0xaf76fd24 +0, 3, 3, 1, 152064, 0xa4dacf0d +0, 4, 4, 1, 152064, 0x964a2110 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arbg ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arbg --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arbg 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arbg 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x4d83ea30 +0, 1, 1, 1, 152064, 0xa4a3be5b +0, 2, 2, 1, 152064, 0x21032989 +0, 3, 3, 1, 152064, 0xa201194b +0, 4, 4, 1, 152064, 0x9b7980cc diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arcc ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arcc --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arcc 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arcc 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x2760b14a +0, 1, 1, 1, 152064, 0xcf94baaf +0, 2, 2, 1, 152064, 0x9b5e0e0a +0, 3, 3, 1, 152064, 0x6bfb8127 +0, 4, 4, 1, 152064, 0xa0293fed diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arcd ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arcd --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arcd 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arcd 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0xa0261570 +0, 1, 1, 1, 152064, 0x678403c8 +0, 2, 2, 1, 152064, 0x1087e7b6 +0, 3, 3, 1, 152064, 0xa3909df3 +0, 4, 4, 1, 152064, 0x87e4c4d4 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arcg ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arcg --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arcg 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arcg 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x70f5c9a8 +0, 1, 1, 1, 152064, 0x56f165fc +0, 2, 2, 1, 152064, 0xe59f8fcc +0, 3, 3, 1, 152064, 0xc5df8b9d +0, 4, 4, 1, 152064, 0xaab2c7cf diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arch ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arch --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arch 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-arch 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x81ab8dad +0, 1, 1, 1, 152064, 0x820fd98a +0, 2, 2, 1, 152064, 0x1ccc712b +0, 3, 3, 1, 152064, 0x0d278740 +0, 4, 4, 1, 152064, 0x13eaa8e2 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-argg ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-argg --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-argg 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-argg 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x2cfbea30 +0, 1, 1, 1, 152064, 0x4c44be5b +0, 2, 2, 1, 152064, 0x87462989 +0, 3, 3, 1, 152064, 0x1462194b +0, 4, 4, 1, 152064, 0xe27c80cc diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybc ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybc --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybc 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybc 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0xae8c985d +0, 1, 1, 1, 152064, 0x489e1535 +0, 2, 2, 1, 152064, 0x01a83b2b +0, 3, 3, 1, 152064, 0x3870ffd6 +0, 4, 4, 1, 152064, 0x3d5b0cc4 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybd ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybd --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybd 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybd 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x7dc98468 +0, 1, 1, 1, 152064, 0xf72db6c9 +0, 2, 2, 1, 152064, 0x1630f53f +0, 3, 3, 1, 152064, 0xc1765599 +0, 4, 4, 1, 152064, 0x12e35db1 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybg ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybg --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybg 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybg 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0x1a57c9a8 +0, 1, 1, 1, 152064, 0x789265fc +0, 2, 2, 1, 152064, 0x2bb78fcc +0, 3, 3, 1, 152064, 0x5caf8b9d +0, 4, 4, 1, 152064, 0xc526c7cf diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybh ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybh --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybh 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-stereo3d-sbsl-aybh 2015-07-13 17:20:03.000000000 +0000 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +0, 0, 0, 1, 152064, 0xf3ee182f +0, 1, 1, 1, 152064, 0x8b1c25f1 +0, 2, 2, 1, 152064, 0xe78de2ac +0, 3, 3, 1, 152064, 0x3eb08db6 +0, 4, 4, 1, 152064, 0x852eae5c diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-tblend ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-tblend --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-tblend 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-tblend 2015-07-19 17:20:03.000000000 +0000 @@ -0,0 +1,50 @@ +#tb 0: 1/25 +0, 1, 1, 1, 152064, 0x8e50e5e5 +0, 2, 2, 1, 152064, 0x7187a95e +0, 3, 3, 1, 152064, 0xbd73863e +0, 4, 4, 1, 152064, 0xabaefc78 +0, 5, 5, 1, 152064, 0xf080523f +0, 6, 6, 1, 152064, 0x2ba7c11c +0, 7, 7, 1, 152064, 0x1bfe0964 +0, 8, 8, 1, 152064, 0xe081d9db +0, 9, 9, 1, 152064, 0x26eee75b +0, 10, 10, 1, 152064, 0xcc28e18c +0, 11, 11, 1, 152064, 0x3d2ed08b +0, 12, 12, 1, 152064, 0x4567acbe +0, 13, 13, 1, 152064, 0xa22f09db +0, 14, 14, 1, 152064, 0xe4438e6f +0, 15, 15, 1, 152064, 0x34d02799 +0, 16, 16, 1, 152064, 0x4c9230b3 +0, 17, 17, 1, 152064, 0x08e6c23c +0, 18, 18, 1, 152064, 0xa0a475a5 +0, 19, 19, 1, 152064, 0x47f5d5e9 +0, 20, 20, 1, 152064, 0x0713219a +0, 21, 21, 1, 152064, 0x9e4434a2 +0, 22, 22, 1, 152064, 0xc06a2482 +0, 23, 23, 1, 152064, 0xba321552 +0, 24, 24, 1, 152064, 0x74070b31 +0, 25, 25, 1, 152064, 0x92188f27 +0, 26, 26, 1, 152064, 0x29cf1fae +0, 27, 27, 1, 152064, 0x04fd06ea +0, 28, 28, 1, 152064, 0xcbbded09 +0, 29, 29, 1, 152064, 0x7f731df8 +0, 30, 30, 1, 152064, 0x9fd5b56f +0, 31, 31, 1, 152064, 0x82217442 +0, 32, 32, 1, 152064, 0x95496106 +0, 33, 33, 1, 152064, 0xb9c50804 +0, 34, 34, 1, 152064, 0xa7051cba +0, 35, 35, 1, 152064, 0x76bc5e88 +0, 36, 36, 1, 152064, 0x8276cfb2 +0, 37, 37, 1, 152064, 0x88bbf936 +0, 38, 38, 1, 152064, 0x160c5d4e +0, 39, 39, 1, 152064, 0x0b61942a +0, 40, 40, 1, 152064, 0x4a4aae9b +0, 41, 41, 1, 152064, 0x049978fa +0, 42, 42, 1, 152064, 0x12584f81 +0, 43, 43, 1, 152064, 0xada82b80 +0, 44, 44, 1, 152064, 0x3a4876ef +0, 45, 45, 1, 152064, 0x7ccb86f2 +0, 46, 46, 1, 152064, 0x11bef54d +0, 47, 47, 1, 152064, 0xb1714cd0 +0, 48, 48, 1, 152064, 0x950a3388 +0, 49, 49, 1, 152064, 0x1c1cc3ec diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-w3fdif-complex ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-w3fdif-complex --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-w3fdif-complex 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-w3fdif-complex 2015-07-12 17:20:02.000000000 +0000 @@ -0,0 +1,31 @@ +#tb 0: 1/50 +0, 18, 18, 1, 622080, 0x21d21485 +0, 19, 19, 1, 622080, 0x600a5468 +0, 20, 20, 1, 622080, 0x9526f7b8 +0, 21, 21, 1, 622080, 0x8b3e661f +0, 22, 22, 1, 622080, 0xff5cb5a9 +0, 23, 23, 1, 622080, 0x7e5e730c +0, 24, 24, 1, 622080, 0x85219ac6 +0, 25, 25, 1, 622080, 0x2f3465a0 +0, 26, 26, 1, 622080, 0xddbf4da0 +0, 27, 27, 1, 622080, 0xc115d4ee +0, 28, 28, 1, 622080, 0x7a8a8d72 +0, 29, 29, 1, 622080, 0xbafcd973 +0, 30, 30, 1, 622080, 0xd2c15603 +0, 31, 31, 1, 622080, 0xd7217855 +0, 32, 32, 1, 622080, 0x9a584eca +0, 33, 33, 1, 622080, 0x9f3e1c40 +0, 34, 34, 1, 622080, 0x6d01efb7 +0, 35, 35, 1, 622080, 0x9ecfcce0 +0, 36, 36, 1, 622080, 0xb355fd7e +0, 37, 37, 1, 622080, 0xc7784021 +0, 38, 38, 1, 622080, 0x13fe4187 +0, 39, 39, 1, 622080, 0xfa03b613 +0, 40, 40, 1, 622080, 0x2c9ccfcd +0, 41, 41, 1, 622080, 0xcae6e6c6 +0, 42, 42, 1, 622080, 0x177968f9 +0, 43, 43, 1, 622080, 0xf708de36 +0, 44, 44, 1, 622080, 0x4491870a +0, 45, 45, 1, 622080, 0x37709f98 +0, 46, 46, 1, 622080, 0x23e8d22f +0, 47, 47, 1, 622080, 0x25cba876 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-w3fdif-simple ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-w3fdif-simple --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/filter-w3fdif-simple 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/filter-w3fdif-simple 2015-07-12 17:20:02.000000000 +0000 @@ -0,0 +1,31 @@ +#tb 0: 1/50 +0, 18, 18, 1, 622080, 0xc73774f5 +0, 19, 19, 1, 622080, 0x4ea3a400 +0, 20, 20, 1, 622080, 0x95153cda +0, 21, 21, 1, 622080, 0xec39bf0b +0, 22, 22, 1, 622080, 0x94b6f836 +0, 23, 23, 1, 622080, 0xc145c3ee +0, 24, 24, 1, 622080, 0x4d4cdee2 +0, 25, 25, 1, 622080, 0x193ebc7c +0, 26, 26, 1, 622080, 0xbd728fd8 +0, 27, 27, 1, 622080, 0xf0f3252f +0, 28, 28, 1, 622080, 0xc012d20a +0, 29, 29, 1, 622080, 0x7b5831b2 +0, 30, 30, 1, 622080, 0x464e9622 +0, 31, 31, 1, 622080, 0x46e3c6c0 +0, 32, 32, 1, 622080, 0xa6ec908b +0, 33, 33, 1, 622080, 0x6a257595 +0, 34, 34, 1, 622080, 0xa6552ecc +0, 35, 35, 1, 622080, 0xdecd1a91 +0, 36, 36, 1, 622080, 0xfaa53e71 +0, 37, 37, 1, 622080, 0xc94a9707 +0, 38, 38, 1, 622080, 0xb5727fd4 +0, 39, 39, 1, 622080, 0x143c018c +0, 40, 40, 1, 622080, 0x92d110c9 +0, 41, 41, 1, 622080, 0x4f762fc0 +0, 42, 42, 1, 622080, 0x3dd2a7d2 +0, 43, 43, 1, 622080, 0xa5d02dc0 +0, 44, 44, 1, 622080, 0x2223ce3d +0, 45, 45, 1, 622080, 0xe4a5fc36 +0, 46, 46, 1, 622080, 0x8384159e +0, 47, 47, 1, 622080, 0x995efa57 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/g2m2 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/g2m2 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/g2m2 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/g2m2 2015-07-02 17:20:03.000000000 +0000 @@ -0,0 +1,161 @@ +#tb 0: 1/1000 +0, 47, 47, 0, 2359296, 0xb4434e4f +0, 62, 62, 0, 2359296, 0x59cb5027 +0, 78, 78, 0, 2359296, 0xe9bc578d +0, 109, 109, 0, 2359296, 0x5d17554f +0, 125, 125, 0, 2359296, 0x6d685457 +0, 437, 437, 0, 2359296, 0x13205420 +0, 438, 438, 0, 2359296, 0xb8e15116 +0, 453, 453, 0, 2359296, 0x2ca55195 +0, 469, 469, 0, 2359296, 0x767d1c45 +0, 484, 484, 0, 2359296, 0x0af42016 +0, 500, 500, 0, 2359296, 0xa2083e69 +0, 516, 516, 0, 2359296, 0xb68a1308 +0, 531, 531, 0, 2359296, 0x4f334c0e +0, 547, 547, 0, 2359296, 0x98b74e4f +0, 562, 562, 0, 2359296, 0xd9de4e4f +0, 578, 578, 0, 2359296, 0xa17c4e4f +0, 594, 594, 0, 2359296, 0xa49a665d +0, 609, 609, 0, 2359296, 0xf5f87360 +0, 781, 781, 0, 2359296, 0x75747360 +0, 797, 797, 0, 2359296, 0x745d7360 +0, 812, 812, 0, 2359296, 0x33047360 +0, 828, 828, 0, 2359296, 0xf19c7360 +0, 844, 844, 0, 2359296, 0xb0437360 +0, 859, 859, 0, 2359296, 0xaf2c7360 +0, 875, 875, 0, 2359296, 0x2ea87360 +0, 891, 891, 0, 2359296, 0xee577360 +0, 953, 953, 0, 2359296, 0x6dd37360 +0, 1078, 1078, 0, 2359296, 0xab327965 +0, 1094, 1094, 0, 2359296, 0x5f8677d0 +0, 1109, 1109, 0, 2359296, 0x02135eb4 +0, 1125, 1125, 0, 2359296, 0x09784e4f +0, 1141, 1141, 0, 2359296, 0xa140a62d +0, 1156, 1156, 0, 2359296, 0xa140a62d +0, 1484, 1484, 0, 2359296, 0xa140a62d +0, 1516, 1516, 0, 2359296, 0xa140a62d +0, 1547, 1547, 0, 2359296, 0xa140a62d +0, 1641, 1641, 0, 2359296, 0xa140a62d +0, 1642, 1642, 0, 2359296, 0xa140a62d +0, 1656, 1656, 0, 2359296, 0xa140a62d +0, 1657, 1657, 0, 2359296, 0xa140a62d +0, 1672, 1672, 0, 2359296, 0xa140a62d +0, 1673, 1673, 0, 2359296, 0x92024e4f +0, 1687, 1687, 0, 2359296, 0xb1754dbe +0, 1688, 1688, 0, 2359296, 0x15ee5eb4 +0, 1703, 1703, 0, 2359296, 0xb1d9746e +0, 1719, 1719, 0, 2359296, 0xabe77360 +0, 1734, 1734, 0, 2359296, 0xaad07360 +0, 1750, 1750, 0, 2359296, 0x2a4c7360 +0, 1766, 1766, 0, 2359296, 0x69777360 +0, 1781, 1781, 0, 2359296, 0xe8e47360 +0, 2328, 2328, 0, 2359296, 0x29357360 +0, 3031, 3031, 0, 2359296, 0x69777360 +0, 3078, 3078, 0, 2359296, 0xa9b97360 +0, 3109, 3109, 0, 2359296, 0xd2697707 +0, 3141, 3141, 0, 2359296, 0x22a07965 +0, 3156, 3156, 0, 2359296, 0xf9327aa7 +0, 3172, 3172, 0, 2359296, 0xa5d277d0 +0, 3203, 3203, 0, 2359296, 0x97b6746e +0, 3328, 3328, 0, 2359296, 0x80bb746e +0, 4562, 4562, 0, 2359296, 0x530b719a +0, 4672, 4672, 0, 2359296, 0x4827665d +0, 4703, 4703, 0, 2359296, 0xc48c5eb4 +0, 5391, 5391, 0, 2359296, 0xe6465eb4 +0, 5578, 5578, 0, 2359296, 0xece455ec +0, 5594, 5594, 0, 2359296, 0xb5344dbe +0, 5609, 5609, 0, 2359296, 0xa140a62d +0, 5625, 5625, 0, 2359296, 0xa140a62d +0, 5641, 5641, 0, 2359296, 0xa140a62d +0, 5642, 5642, 0, 2359296, 0xa140a62d +0, 5656, 5656, 0, 2359296, 0xa140a62d +0, 5672, 5672, 0, 2359296, 0xa140a62d +0, 5703, 5703, 0, 2359296, 0xa140a62d +0, 5750, 5750, 0, 2359296, 0xa140a62d +0, 5766, 5766, 0, 2359296, 0xa140a62d +0, 5781, 5781, 0, 2359296, 0xa140a62d +0, 5797, 5797, 0, 2359296, 0xa140a62d +0, 5812, 5812, 0, 2359296, 0xa140a62d +0, 5875, 5875, 0, 2359296, 0xa140a62d +0, 5922, 5922, 0, 2359296, 0xa140a62d +0, 5984, 5984, 0, 2359296, 0xa140a62d +0, 6031, 6031, 0, 2359296, 0xa140a62d +0, 6047, 6047, 0, 2359296, 0xa140a62d +0, 6062, 6062, 0, 2359296, 0xa140a62d +0, 6406, 6406, 0, 2359296, 0xa140a62d +0, 6453, 6453, 0, 2359296, 0xa140a62d +0, 6469, 6469, 0, 2359296, 0xa140a62d +0, 6484, 6484, 0, 2359296, 0xa140a62d +0, 6500, 6500, 0, 2359296, 0xa140a62d +0, 6516, 6516, 0, 2359296, 0xa140a62d +0, 6531, 6531, 0, 2359296, 0xa140a62d +0, 6547, 6547, 0, 2359296, 0xa140a62d +0, 6562, 6562, 0, 2359296, 0x5c2a4cd9 +0, 6578, 6578, 0, 2359296, 0x28f94e4f +0, 6594, 6594, 0, 2359296, 0x9acb4820 +0, 6609, 6609, 0, 2359296, 0x9ec716e1 +0, 6625, 6625, 0, 2359296, 0xaf5f3fa4 +0, 6641, 6641, 0, 2359296, 0x7d633218 +0, 6642, 6642, 0, 2359296, 0x34fb2016 +0, 6656, 6656, 0, 2359296, 0x61351665 +0, 6812, 6812, 0, 2359296, 0xb23c1039 +0, 6828, 6828, 0, 2359296, 0x59290d69 +0, 6844, 6844, 0, 2359296, 0x639c132d +0, 6859, 6859, 0, 2359296, 0x0b252237 +0, 6875, 6875, 0, 2359296, 0xe66f2fc5 +0, 6891, 6891, 0, 2359296, 0xa8b33761 +0, 6906, 6906, 0, 2359296, 0x81a63f8b +0, 6969, 6969, 0, 2359296, 0x18074843 +0, 6984, 6984, 0, 2359296, 0x434a5195 +0, 7000, 7000, 0, 2359296, 0x6da15116 +0, 7001, 7001, 0, 2359296, 0xca755420 +0, 7016, 7016, 0, 2359296, 0xe6fc5457 +0, 7017, 7017, 0, 2359296, 0x271d53fd +0, 7031, 7031, 0, 2359296, 0xa15b554f +0, 7281, 7281, 0, 2359296, 0x49f6578d +0, 7282, 7282, 0, 2359296, 0x2c0c4e4f +0, 7297, 7297, 0, 2359296, 0x7e924e4f +0, 7298, 7298, 0, 2359296, 0x32ff4e4f +0, 7312, 7312, 0, 2359296, 0x23ad4e4f +0, 7313, 7313, 0, 2359296, 0x7ddc4e4f +0, 7328, 7328, 0, 2359296, 0xd0624e4f +0, 7329, 7329, 0, 2359296, 0x22f74e4f +0, 7781, 7781, 0, 2359296, 0x49fa4e4f +0, 7797, 7797, 0, 2359296, 0x6a5a5027 +0, 7812, 7812, 0, 2359296, 0x9f935027 +0, 7828, 7828, 0, 2359296, 0xc5e55027 +0, 7844, 7844, 0, 2359296, 0xd4cc5027 +0, 8250, 8250, 0, 2359296, 0xd2ab5027 +0, 8266, 8266, 0, 2359296, 0x68f04e4f +0, 8281, 8281, 0, 2359296, 0xd0b44e4f +0, 8297, 8297, 0, 2359296, 0xfced4e4f +0, 8298, 8298, 0, 2359296, 0x8b0d4e4f +0, 8312, 8312, 0, 2359296, 0x09db4e4f +0, 8328, 8328, 0, 2359296, 0x4d0f4e4f +0, 8329, 8329, 0, 2359296, 0xad824dbe +0, 8344, 8344, 0, 2359296, 0x9aca4dbe +0, 8345, 8345, 0, 2359296, 0x755a4dbe +0, 8359, 8359, 0, 2359296, 0xc6824d2d +0, 8360, 8360, 0, 2359296, 0x7c344c0e +0, 8375, 8375, 0, 2359296, 0x50f04c0e +0, 8391, 8391, 0, 2359296, 0xfa594c0e +0, 8406, 8406, 0, 2359296, 0x4d494c0e +0, 8422, 8422, 0, 2359296, 0xf6b24c0e +0, 8437, 8437, 0, 2359296, 0xcb6e4c0e +0, 8453, 8453, 0, 2359296, 0xbd024c0e +0, 8516, 8516, 0, 2359296, 0x245b4dbe +0, 8531, 8531, 0, 2359296, 0x47874e4f +0, 8547, 8547, 0, 2359296, 0xdead4e4f +0, 8562, 8562, 0, 2359296, 0x847e4e4f +0, 9344, 9344, 0, 2359296, 0x1a13e47c +0, 9345, 9345, 0, 2359296, 0x46b3e321 +0, 9876, 9876, 0, 2359296, 0x76c0e35d +0, 9922, 9922, 0, 2359296, 0xf6d9e519 +0, 9938, 9938, 0, 2359296, 0xac0fe4b3 +0, 9954, 9954, 0, 2359296, 0x3a3fe424 +0, 9955, 9955, 0, 2359296, 0xa97ce1a8 +0, 9969, 9969, 0, 2359296, 0x12fae01d +0, 9970, 9970, 0, 2359296, 0x65b4df14 +0, 9985, 9985, 0, 2359296, 0x82d0e032 +0, 9986, 9986, 0, 2359296, 0xa452e0cf +0, 10001, 10001, 0, 2359296, 0x22d6df37 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/g2m3 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/g2m3 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/g2m3 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/g2m3 2015-07-02 17:20:03.000000000 +0000 @@ -0,0 +1,21 @@ +#tb 0: 1001/24000 +0, 0, 0, 1, 3824640, 0x9a253d29 +0, 12, 12, 1, 3824640, 0xcb232b06 +0, 15, 15, 1, 3824640, 0xb03c288c +0, 16, 16, 1, 3824640, 0x260b284e +0, 18, 18, 1, 3824640, 0x53ed2f30 +0, 19, 19, 1, 3824640, 0x00af334d +0, 21, 21, 1, 3824640, 0x35ba3ef7 +0, 22, 22, 1, 3824640, 0x05c24e9a +0, 24, 24, 1, 3824640, 0x03846423 +0, 25, 25, 1, 3824640, 0x0bcf6423 +0, 30, 30, 1, 3824640, 0x96446423 +0, 33, 33, 1, 3824640, 0x9e8f6423 +0, 34, 34, 1, 3824640, 0x22bc6423 +0, 36, 36, 1, 3824640, 0x714a6423 +0, 37, 37, 1, 3824640, 0x060d6423 +0, 39, 39, 1, 3824640, 0x5bf96423 +0, 40, 40, 1, 3824640, 0xb3476423 +0, 123, 123, 1, 3824640, 0xbf056423 +0, 124, 124, 1, 3824640, 0x30746423 +0, 126, 126, 1, 3824640, 0xea6f6423 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/g2m4 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/g2m4 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/g2m4 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/g2m4 2015-07-02 17:20:03.000000000 +0000 @@ -0,0 +1,26 @@ +#tb 0: 1/10 +0, 0, 0, 1, 3932160, 0x109148ee +0, 1, 1, 1, 3932160, 0xa87b7bff +0, 2, 2, 1, 3932160, 0x00e14d16 +0, 3, 3, 1, 3932160, 0xbf8d7871 +0, 4, 4, 1, 3932160, 0x998ded98 +0, 5, 5, 1, 3932160, 0xe0d1328f +0, 6, 6, 1, 3932160, 0xde7e69a0 +0, 7, 7, 1, 3932160, 0x5355cde3 +0, 8, 8, 1, 3932160, 0x4b3c6b11 +0, 9, 9, 1, 3932160, 0x19d8366f +0, 10, 10, 1, 3932160, 0xf80f3663 +0, 14, 14, 1, 3932160, 0xe2dc1cc7 +0, 30, 30, 1, 3932160, 0x3ae51cc7 +0, 31, 31, 1, 3932160, 0x10ecd14c +0, 32, 32, 1, 3932160, 0xda0f1d1f +0, 33, 33, 1, 3932160, 0x50bd3602 +0, 34, 34, 1, 3932160, 0xad2083ba +0, 35, 35, 1, 3932160, 0xa5b388bd +0, 36, 36, 1, 3932160, 0x37ae6d4f +0, 37, 37, 1, 3932160, 0x436ee825 +0, 38, 38, 1, 3932160, 0x6c2ec178 +0, 39, 39, 1, 3932160, 0x6c3f389b +0, 40, 40, 1, 3932160, 0x3c0421c1 +0, 41, 41, 1, 3932160, 0x861b0449 +0, 42, 42, 1, 3932160, 0x41640723 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/gapless-mp3 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/gapless-mp3 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/gapless-mp3 2015-06-19 20:44:54.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/gapless-mp3 2015-06-24 17:20:02.000000000 +0000 @@ -2,4 +2,4 @@ c96c3ae7bd3300fd2f4debac222de5b7 3386bc2009b31b7ef39247918cbb02a5 *tests/data/fate/gapless-mp3.out-2 c96c3ae7bd3300fd2f4debac222de5b7 -92e37f050ad4fc817730c8af17ee6d1b *tests/data/fate/gapless-mp3.out-3 +3ce35ec2a9a59b7459ecd6c98d8fa123 *tests/data/fate/gapless-mp3.out-3 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/hap1 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/hap1 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/hap1 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/hap1 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 62/2997 +0, 0, 0, 1, 1228800, 0x0fa946bc diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/hap5 ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/hap5 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/hap5 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/hap5 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/30 +0, 0, 0, 1, 1228800, 0xb71ecf93 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/hap-chunk ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/hap-chunk --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/hap-chunk 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/hap-chunk 2015-07-22 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/30 +0, 0, 0, 1, 16384, 0x096d409e diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/hapy ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/hapy --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/hapy 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/hapy 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 62/2997 +0, 0, 0, 1, 1228800, 0x5993522d diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/j2k-dwt ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/j2k-dwt --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/j2k-dwt 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/j2k-dwt 2015-06-23 17:20:04.000000000 +0000 @@ -0,0 +1,60 @@ +5/3i, decomp:15 border 151 170 140 183 milli-err2: 0 +9/7i, decomp:15 border 151 170 140 183 milli-err2: 544 +9/7f, decomp:15 border 151 170 140 183 err2: 0.000 +5/3i, decomp:21 border 173 201 81 189 milli-err2: 0 +9/7i, decomp:21 border 173 201 81 189 milli-err2: 592 +9/7f, decomp:21 border 173 201 81 189 err2: 0.000 +5/3i, decomp:22 border 213 227 76 245 milli-err2: 0 +9/7i, decomp:22 border 213 227 76 245 milli-err2: 533 +9/7f, decomp:22 border 213 227 76 245 err2: 0.000 +5/3i, decomp:13 border 134 157 184 203 milli-err2: 0 +9/7i, decomp:13 border 134 157 184 203 milli-err2: 535 +9/7f, decomp:13 border 134 157 184 203 err2: 0.000 +5/3i, decomp: 1 border 204 237 6 106 milli-err2: 0 +9/7i, decomp: 1 border 204 237 6 106 milli-err2: 219 +9/7f, decomp: 1 border 204 237 6 106 err2: 0.000 +5/3i, decomp:28 border 76 211 13 210 milli-err2: 0 +9/7i, decomp:28 border 76 211 13 210 milli-err2: 791 +9/7f, decomp:28 border 76 211 13 210 err2: 0.000 +5/3i, decomp:21 border 76 99 43 123 milli-err2: 0 +9/7i, decomp:21 border 76 99 43 123 milli-err2: 686 +9/7f, decomp:21 border 76 99 43 123 err2: 0.000 +5/3i, decomp:15 border 192 243 174 204 milli-err2: 0 +9/7i, decomp:15 border 192 243 174 204 milli-err2: 476 +9/7f, decomp:15 border 192 243 174 204 err2: 0.000 +5/3i, decomp:21 border 17 68 93 204 milli-err2: 0 +9/7i, decomp:21 border 17 68 93 204 milli-err2: 633 +9/7f, decomp:21 border 17 68 93 204 err2: 0.000 +5/3i, decomp:11 border 142 168 82 174 milli-err2: 0 +9/7i, decomp:11 border 142 168 82 174 milli-err2: 696 +9/7f, decomp:11 border 142 168 82 174 err2: 0.000 +5/3i, decomp:23 border 142 209 171 235 milli-err2: 0 +9/7i, decomp:23 border 142 209 171 235 milli-err2: 626 +9/7f, decomp:23 border 142 209 171 235 err2: 0.000 +5/3i, decomp:30 border 37 185 79 245 milli-err2: 0 +9/7i, decomp:30 border 37 185 79 245 milli-err2: 953 +9/7f, decomp:30 border 37 185 79 245 err2: 0.000 +5/3i, decomp: 5 border 129 236 30 243 milli-err2: 0 +9/7i, decomp: 5 border 129 236 30 243 milli-err2: 620 +9/7f, decomp: 5 border 129 236 30 243 err2: 0.000 +5/3i, decomp:10 border 5 160 146 247 milli-err2: 0 +9/7i, decomp:10 border 5 160 146 247 milli-err2: 797 +9/7f, decomp:10 border 5 160 146 247 err2: 0.000 +5/3i, decomp: 5 border 104 162 6 47 milli-err2: 0 +9/7i, decomp: 5 border 104 162 6 47 milli-err2: 603 +9/7f, decomp: 5 border 104 162 6 47 err2: 0.000 +5/3i, decomp:24 border 78 250 102 218 milli-err2: 0 +9/7i, decomp:24 border 78 250 102 218 milli-err2: 836 +9/7f, decomp:24 border 78 250 102 218 err2: 0.000 +5/3i, decomp:28 border 86 98 56 79 milli-err2: 0 +9/7i, decomp:28 border 86 98 56 79 milli-err2: 597 +9/7f, decomp:28 border 86 98 56 79 err2: 0.000 +5/3i, decomp: 6 border 95 238 197 214 milli-err2: 0 +9/7i, decomp: 6 border 95 238 197 214 milli-err2: 478 +9/7f, decomp: 6 border 95 238 197 214 err2: 0.000 +5/3i, decomp:17 border 77 169 93 165 milli-err2: 0 +9/7i, decomp:17 border 77 169 93 165 milli-err2: 616 +9/7f, decomp:17 border 77 169 93 165 err2: 0.000 +5/3i, decomp:22 border 178 187 7 119 milli-err2: 0 +9/7i, decomp:22 border 178 187 7 119 milli-err2: 392 +9/7f, decomp:22 border 178 187 7 119 err2: 0.000 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/jpeg2000-dcinema ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/jpeg2000-dcinema --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/jpeg2000-dcinema 2015-03-15 02:46:06.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/jpeg2000-dcinema 2015-06-28 17:20:02.000000000 +0000 @@ -1,3 +1,3 @@ #tb 0: 1/24 -0, 0, 0, 1, 12441600, 0xf0de508b -0, 1, 1, 1, 12441600, 0x8e50c249 +0, 0, 0, 1, 12441600, 0xfcf6a127 +0, 1, 1, 1, 12441600, 0x577b6a64 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/lossless-wma ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/lossless-wma --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/lossless-wma 2015-03-13 17:34:52.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/lossless-wma 2015-06-28 17:20:02.000000000 +0000 @@ -1 +1 @@ -35dc840f91cbcece02178d03c8f2fe26 +ab45f262b22030e908cb03f2cc8e89b5 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/tea ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/tea --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/tea 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/tea 2015-07-22 17:20:04.000000000 +0000 @@ -0,0 +1 @@ +Test encryption/decryption success. diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/txd-16bpp ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/txd-16bpp --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/txd-16bpp 2015-03-13 17:34:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/txd-16bpp 2015-07-01 17:20:03.000000000 +0000 @@ -1,12 +1,12 @@ #tb 0: 1/5 -0, 0, 0, 1, 16384, 0x213f9ea8 -0, 1, 1, 1, 16384, 0x8185fdb1 -0, 2, 2, 1, 16384, 0xf03581d1 -0, 3, 3, 1, 16384, 0x629cd573 -0, 4, 4, 1, 16384, 0xfe7a5b63 -0, 5, 5, 1, 16384, 0x4afc05b2 -0, 6, 6, 1, 16384, 0x074b8515 -0, 7, 7, 1, 16384, 0x17fde900 -0, 8, 8, 1, 16384, 0x831bac76 -0, 9, 9, 1, 16384, 0x2fb579f3 -0, 10, 10, 1, 16384, 0x68762bed +0, 0, 0, 1, 16384, 0x4d39b4cb +0, 1, 1, 1, 16384, 0x2a8d14b4 +0, 2, 2, 1, 16384, 0xe26793cb +0, 3, 3, 1, 16384, 0x62b5ed43 +0, 4, 4, 1, 16384, 0x5ae86c21 +0, 5, 5, 1, 16384, 0x416d184a +0, 6, 6, 1, 16384, 0x33f59d3e +0, 7, 7, 1, 16384, 0x3d0ffd9c +0, 8, 8, 1, 16384, 0x35bac4c6 +0, 9, 9, 1, 16384, 0xa1cd8ffb +0, 10, 10, 1, 16384, 0xf7dc38d2 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/txd-odd ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/txd-odd --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/fate/txd-odd 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/fate/txd-odd 2015-07-01 17:20:03.000000000 +0000 @@ -0,0 +1,2 @@ +#tb 0: 1/5 +0, 0, 0, 1, 385452, 0x055a14d6 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/seek/lavf-mxf ffmpeg-2.7.2~trusty~ppa1/tests/ref/seek/lavf-mxf --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/seek/lavf-mxf 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/seek/lavf-mxf 2015-07-17 17:20:02.000000000 +0000 @@ -43,6 +43,6 @@ ret: 0 st: 1 flags:1 ts: 1.565833 ret: 0 st: 0 flags:1 dts: 0.840000 pts: 0.960000 pos: 460800 size: 24711 ret: 0 st:-1 flags:0 ts: 0.460008 -ret: 0 st: 0 flags:1 dts: 0.840000 pts: 0.960000 pos: 460800 size: 24711 +ret: 0 st: 0 flags:1 dts: 0.360000 pts: 0.480000 pos: 211968 size: 24786 ret: 0 st:-1 flags:1 ts:-0.645825 ret: 0 st: 0 flags:1 dts:-0.040000 pts: 0.000000 pos: 6656 size: 24801 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/seek/lavf-yuv4mpeg ffmpeg-2.7.2~trusty~ppa1/tests/ref/seek/lavf-yuv4mpeg --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/seek/lavf-yuv4mpeg 2015-03-13 17:34:53.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/seek/lavf-yuv4mpeg 2015-07-11 17:20:02.000000000 +0000 @@ -1,27 +1,53 @@ ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 64 size:152064 -ret:-1 st:-1 flags:0 ts:-1.000000 -ret:-1 st:-1 flags:1 ts: 1.894167 -ret:-1 st: 0 flags:0 ts: 0.800000 -ret:-1 st: 0 flags:1 ts:-0.320000 -ret:-1 st:-1 flags:0 ts: 2.576668 -ret:-1 st:-1 flags:1 ts: 1.470835 -ret:-1 st: 0 flags:0 ts: 0.360000 -ret:-1 st: 0 flags:1 ts:-0.760000 -ret:-1 st:-1 flags:0 ts: 2.153336 -ret:-1 st:-1 flags:1 ts: 1.047503 -ret:-1 st: 0 flags:0 ts:-0.040000 -ret:-1 st: 0 flags:1 ts: 2.840000 -ret:-1 st:-1 flags:0 ts: 1.730004 -ret:-1 st:-1 flags:1 ts: 0.624171 -ret:-1 st: 0 flags:0 ts:-0.480000 -ret:-1 st: 0 flags:1 ts: 2.400000 -ret:-1 st:-1 flags:0 ts: 1.306672 -ret:-1 st:-1 flags:1 ts: 0.200839 -ret:-1 st: 0 flags:0 ts:-0.920000 -ret:-1 st: 0 flags:1 ts: 2.000000 -ret:-1 st:-1 flags:0 ts: 0.883340 -ret:-1 st:-1 flags:1 ts:-0.222493 -ret:-1 st: 0 flags:0 ts: 2.680000 -ret:-1 st: 0 flags:1 ts: 1.560000 -ret:-1 st:-1 flags:0 ts: 0.460008 -ret:-1 st:-1 flags:1 ts:-0.645825 +ret: 0 st:-1 flags:0 ts:-1.000000 +ret: 0 st: 0 flags:1 dts: 0.040000 pts: 0.040000 pos: 152134 size:152064 +ret: 0 st:-1 flags:1 ts: 1.894167 +ret:-EOF +ret: 0 st: 0 flags:0 ts: 0.800000 +ret: 0 st: 0 flags:1 dts: 0.800000 pts: 0.800000 pos:3041464 size:152064 +ret: 0 st: 0 flags:1 ts:-0.320000 +ret: 0 st: 0 flags:1 dts: 0.840000 pts: 0.840000 pos:3193534 size:152064 +ret: 0 st:-1 flags:0 ts: 2.576668 +ret:-EOF +ret: 0 st:-1 flags:1 ts: 1.470835 +ret:-EOF +ret: 0 st: 0 flags:0 ts: 0.360000 +ret: 0 st: 0 flags:1 dts: 0.360000 pts: 0.360000 pos:1368694 size:152064 +ret: 0 st: 0 flags:1 ts:-0.760000 +ret: 0 st: 0 flags:1 dts: 0.400000 pts: 0.400000 pos:1520764 size:152064 +ret: 0 st:-1 flags:0 ts: 2.153336 +ret:-EOF +ret: 0 st:-1 flags:1 ts: 1.047503 +ret:-EOF +ret: 0 st: 0 flags:0 ts:-0.040000 +ret:-EOF +ret: 0 st: 0 flags:1 ts: 2.840000 +ret:-EOF +ret: 0 st:-1 flags:0 ts: 1.730004 +ret:-EOF +ret: 0 st:-1 flags:1 ts: 0.624171 +ret: 0 st: 0 flags:1 dts: 0.640000 pts: 0.640000 pos:2433184 size:152064 +ret: 0 st: 0 flags:0 ts:-0.480000 +ret: 0 st: 0 flags:1 dts: 0.680000 pts: 0.680000 pos:2585254 size:152064 +ret: 0 st: 0 flags:1 ts: 2.400000 +ret:-EOF +ret: 0 st:-1 flags:0 ts: 1.306672 +ret:-EOF +ret: 0 st:-1 flags:1 ts: 0.200839 +ret: 0 st: 0 flags:1 dts: 0.200000 pts: 0.200000 pos: 760414 size:152064 +ret: 0 st: 0 flags:0 ts:-0.920000 +ret: 0 st: 0 flags:1 dts: 0.240000 pts: 0.240000 pos: 912484 size:152064 +ret: 0 st: 0 flags:1 ts: 2.000000 +ret:-EOF +ret: 0 st:-1 flags:0 ts: 0.883340 +ret: 0 st: 0 flags:1 dts: 0.880000 pts: 0.880000 pos:3345604 size:152064 +ret: 0 st:-1 flags:1 ts:-0.222493 +ret: 0 st: 0 flags:1 dts: 0.920000 pts: 0.920000 pos:3497674 size:152064 +ret: 0 st: 0 flags:0 ts: 2.680000 +ret:-EOF +ret: 0 st: 0 flags:1 ts: 1.560000 +ret:-EOF +ret: 0 st:-1 flags:0 ts: 0.460008 +ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:1824904 size:152064 +ret: 0 st:-1 flags:1 ts:-0.645825 +ret: 0 st: 0 flags:1 dts: 0.520000 pts: 0.520000 pos:1976974 size:152064 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-420 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-420 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-420 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-420 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +26b1296a0ef80a3b5c8b63cc57c52bc2 *tests/data/fate/vsynth1-ffv1.3-420.avi +2691268 tests/data/fate/vsynth1-ffv1.3-420.avi +c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-ffv1.3-420.out.rawvideo +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-422p10 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-422p10 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-422p10 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-422p10 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +aa8c5630213381c7b2afdec4a91405ed *tests/data/fate/vsynth1-ffv1.3-422p10.avi +2845574 tests/data/fate/vsynth1-ffv1.3-422p10.avi +c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-ffv1.3-422p10.out.rawvideo +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-444p16 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-444p16 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-444p16 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-444p16 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +f6b6943455d8b2c3010ff898df5dc9db *tests/data/fate/vsynth1-ffv1.3-444p16.avi +5357816 tests/data/fate/vsynth1-ffv1.3-444p16.avi +c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-ffv1.3-444p16.out.rawvideo +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-bgr ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-bgr --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-bgr 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-ffv1.3-bgr 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +3c68357b239479fc26656f6dd76b0b58 *tests/data/fate/vsynth1-ffv1.3-bgr.avi +6883176 tests/data/fate/vsynth1-ffv1.3-bgr.avi +49c03ab1b73b7cd3cabc3c77a9479c9e *tests/data/fate/vsynth1-ffv1.3-bgr.out.rawvideo +stddev: 3.16 PSNR: 38.12 MAXDIFF: 50 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-h261 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-h261 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-h261 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-h261 2015-07-09 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -be41f18a8c3120b730270a9ec45545aa *tests/data/fate/vsynth1-h261.avi +5a1114f9356235172ba9ad13f88108cf *tests/data/fate/vsynth1-h261.avi 707550 tests/data/fate/vsynth1-h261.avi 85fde92037c2ccecc02e2d6c21a169b0 *tests/data/fate/vsynth1-h261.out.rawvideo stddev: 9.11 PSNR: 28.93 MAXDIFF: 113 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-h261-trellis ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-h261-trellis --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-h261-trellis 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-h261-trellis 2015-07-09 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -707aac692b7478d2312a87b09228e437 *tests/data/fate/vsynth1-h261-trellis.avi +02b4109ce5343b7ef24fb11c2635498a *tests/data/fate/vsynth1-h261-trellis.avi 655416 tests/data/fate/vsynth1-h261-trellis.avi 70ceba944548ba680b1101c91707ea25 *tests/data/fate/vsynth1-h261-trellis.out.rawvideo stddev: 8.75 PSNR: 29.28 MAXDIFF: 90 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-jpeg2000 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-jpeg2000 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-jpeg2000 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-jpeg2000 2015-06-30 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -ed9c45dc090a03c2eb9c35cf76e4d914 *tests/data/fate/vsynth1-jpeg2000.avi -2306906 tests/data/fate/vsynth1-jpeg2000.avi -64166a8fbb730a7a132c50ee89592672 *tests/data/fate/vsynth1-jpeg2000.out.rawvideo -stddev: 5.41 PSNR: 33.46 MAXDIFF: 63 bytes: 7603200/ 7603200 +d2a06ad916711d29b30977a06335bb76 *tests/data/fate/vsynth1-jpeg2000.avi +2265698 tests/data/fate/vsynth1-jpeg2000.avi +15a8e49f6fd014193bbafd72f84936c7 *tests/data/fate/vsynth1-jpeg2000.out.rawvideo +stddev: 5.36 PSNR: 33.55 MAXDIFF: 61 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-jpeg2000-97 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-jpeg2000-97 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth1-jpeg2000-97 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth1-jpeg2000-97 2015-06-30 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -dfb35e733795195c6519ecc37e953931 *tests/data/fate/vsynth1-jpeg2000-97.avi -2243136 tests/data/fate/vsynth1-jpeg2000-97.avi -e1a095b40d7f6440f6c46f2995c4759c *tests/data/fate/vsynth1-jpeg2000-97.out.rawvideo -stddev: 6.23 PSNR: 32.23 MAXDIFF: 75 bytes: 7603200/ 7603200 +8bb707e596f97451fd325dec2dd610a7 *tests/data/fate/vsynth1-jpeg2000-97.avi +3654620 tests/data/fate/vsynth1-jpeg2000-97.avi +5073771a78e1f5366a7eb0df341662fc *tests/data/fate/vsynth1-jpeg2000-97.out.rawvideo +stddev: 4.23 PSNR: 35.59 MAXDIFF: 53 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-420 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-420 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-420 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-420 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +6d7b6352f49e21153bb891df411e60ec *tests/data/fate/vsynth2-ffv1.3-420.avi +3718026 tests/data/fate/vsynth2-ffv1.3-420.avi +36d7ca943916e1743cefa609eba0205c *tests/data/fate/vsynth2-ffv1.3-420.out.rawvideo +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-422p10 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-422p10 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-422p10 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-422p10 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +b43b20163948e44a6c806714e69ac3bf *tests/data/fate/vsynth2-ffv1.3-422p10.avi +4069370 tests/data/fate/vsynth2-ffv1.3-422p10.avi +36d7ca943916e1743cefa609eba0205c *tests/data/fate/vsynth2-ffv1.3-422p10.out.rawvideo +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-444p16 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-444p16 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-444p16 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-444p16 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +ae0bad7ece3ceacc9554f342ab489a4d *tests/data/fate/vsynth2-ffv1.3-444p16.avi +5086918 tests/data/fate/vsynth2-ffv1.3-444p16.avi +36d7ca943916e1743cefa609eba0205c *tests/data/fate/vsynth2-ffv1.3-444p16.out.rawvideo +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-bgr ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-bgr --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-bgr 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-ffv1.3-bgr 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +4e8ea4c31ddb7703638989c6251e37fe *tests/data/fate/vsynth2-ffv1.3-bgr.avi +6386312 tests/data/fate/vsynth2-ffv1.3-bgr.avi +835a86f8dff88917c3e5f2776954c5b7 *tests/data/fate/vsynth2-ffv1.3-bgr.out.rawvideo +stddev: 1.57 PSNR: 44.18 MAXDIFF: 20 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-h261 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-h261 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-h261 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-h261 2015-07-09 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -6334083b8899cdd8b56f80f8e1345213 *tests/data/fate/vsynth2-h261.avi +49ae672f343b45e9d18523634176b857 *tests/data/fate/vsynth2-h261.avi 257938 tests/data/fate/vsynth2-h261.avi 8962b6ea3153a828e5a4df68e1d5da44 *tests/data/fate/vsynth2-h261.out.rawvideo stddev: 7.21 PSNR: 30.97 MAXDIFF: 96 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-h261-trellis ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-h261-trellis --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-h261-trellis 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-h261-trellis 2015-07-09 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -f5105d846793cd12f1fedffd917a240d *tests/data/fate/vsynth2-h261-trellis.avi +f5e0cfc70bbe4f4048c15be88dea4378 *tests/data/fate/vsynth2-h261-trellis.avi 249856 tests/data/fate/vsynth2-h261-trellis.avi 15452237f6c333690d3e05f354f63196 *tests/data/fate/vsynth2-h261-trellis.out.rawvideo stddev: 7.10 PSNR: 31.10 MAXDIFF: 96 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-jpeg2000 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-jpeg2000 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-jpeg2000 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-jpeg2000 2015-06-30 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -b918de21dec4310f87af3788ed458462 *tests/data/fate/vsynth2-jpeg2000.avi -1513144 tests/data/fate/vsynth2-jpeg2000.avi -d30f637670a60de6cc8d177047f32a59 *tests/data/fate/vsynth2-jpeg2000.out.rawvideo -stddev: 5.04 PSNR: 34.07 MAXDIFF: 71 bytes: 7603200/ 7603200 +6c2f979e4a33a36f36aec86f2d464143 *tests/data/fate/vsynth2-jpeg2000.avi +1494516 tests/data/fate/vsynth2-jpeg2000.avi +36afd96d6e55bc83166fd615351ba366 *tests/data/fate/vsynth2-jpeg2000.out.rawvideo +stddev: 5.00 PSNR: 34.15 MAXDIFF: 59 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-jpeg2000-97 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-jpeg2000-97 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth2-jpeg2000-97 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth2-jpeg2000-97 2015-06-30 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -f8880f48a46ad43623d00de15ecba2cd *tests/data/fate/vsynth2-jpeg2000-97.avi -1467472 tests/data/fate/vsynth2-jpeg2000-97.avi -e523db4385f586d73aa0ee2688a75d2e *tests/data/fate/vsynth2-jpeg2000-97.out.rawvideo -stddev: 5.44 PSNR: 33.41 MAXDIFF: 57 bytes: 7603200/ 7603200 +2e43f004a55f4a55a19c4b79fc8e8743 *tests/data/fate/vsynth2-jpeg2000-97.avi +2448706 tests/data/fate/vsynth2-jpeg2000-97.avi +a6e2453118a0de135836a868b2ca0e60 *tests/data/fate/vsynth2-jpeg2000-97.out.rawvideo +stddev: 3.23 PSNR: 37.94 MAXDIFF: 29 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-420 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-420 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-420 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-420 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +f969ca8542c8384c27233f362b661f8a *tests/data/fate/vsynth3-ffv1.3-420.avi +62194 tests/data/fate/vsynth3-ffv1.3-420.avi +a038ad7c3c09f776304ef7accdea9c74 *tests/data/fate/vsynth3-ffv1.3-420.out.rawvideo +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 86700/ 86700 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-422p10 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-422p10 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-422p10 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-422p10 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +4fc113caac00ada68e19639ae6f7bc47 *tests/data/fate/vsynth3-ffv1.3-422p10.avi +63840 tests/data/fate/vsynth3-ffv1.3-422p10.avi +a038ad7c3c09f776304ef7accdea9c74 *tests/data/fate/vsynth3-ffv1.3-422p10.out.rawvideo +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 86700/ 86700 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-444p16 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-444p16 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-444p16 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-444p16 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +1e8981cec92407938b25cd82381d1c64 *tests/data/fate/vsynth3-ffv1.3-444p16.avi +82908 tests/data/fate/vsynth3-ffv1.3-444p16.avi +a038ad7c3c09f776304ef7accdea9c74 *tests/data/fate/vsynth3-ffv1.3-444p16.out.rawvideo +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 86700/ 86700 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-bgr ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-bgr --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-bgr 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth3-ffv1.3-bgr 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +bdb5f694222e91bb7cb7264d2d5d419b *tests/data/fate/vsynth3-ffv1.3-bgr.avi +112780 tests/data/fate/vsynth3-ffv1.3-bgr.avi +5d031d2e891b13593b8cd79e63d083b4 *tests/data/fate/vsynth3-ffv1.3-bgr.out.rawvideo +stddev: 3.23 PSNR: 37.92 MAXDIFF: 50 bytes: 86700/ 86700 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth3-jpeg2000 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth3-jpeg2000 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth3-jpeg2000 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth3-jpeg2000 2015-06-30 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -7ea4e3901817f06a3de59ee70836f5d9 *tests/data/fate/vsynth3-jpeg2000.avi -63772 tests/data/fate/vsynth3-jpeg2000.avi -ddfc0e8e033aeecf334c1450148dab44 *tests/data/fate/vsynth3-jpeg2000.out.rawvideo -stddev: 5.52 PSNR: 33.28 MAXDIFF: 48 bytes: 86700/ 86700 +0b8aa8113c10772cffff60f9c8ffd902 *tests/data/fate/vsynth3-jpeg2000.avi +65548 tests/data/fate/vsynth3-jpeg2000.avi +2d8bd94d558755c47d7e23fd9556e164 *tests/data/fate/vsynth3-jpeg2000.out.rawvideo +stddev: 5.48 PSNR: 33.34 MAXDIFF: 47 bytes: 86700/ 86700 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth3-jpeg2000-97 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth3-jpeg2000-97 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth3-jpeg2000-97 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth3-jpeg2000-97 2015-06-30 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -3e2f1e7d009d05e2bb9e8c3b10fab134 *tests/data/fate/vsynth3-jpeg2000-97.avi -65364 tests/data/fate/vsynth3-jpeg2000-97.avi -f9dad7a31175e400ca35de60aec826fd *tests/data/fate/vsynth3-jpeg2000-97.out.rawvideo -stddev: 6.27 PSNR: 32.17 MAXDIFF: 52 bytes: 86700/ 86700 +b6c88a623c3296ca945346d2203f0af0 *tests/data/fate/vsynth3-jpeg2000-97.avi +83870 tests/data/fate/vsynth3-jpeg2000-97.avi +0cd707bfb1bbe5312b00c094f695b1fa *tests/data/fate/vsynth3-jpeg2000-97.out.rawvideo +stddev: 4.52 PSNR: 35.02 MAXDIFF: 47 bytes: 86700/ 86700 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-420 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-420 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-420 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-420 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +ed72c22374718589ffacd7ea15424687 *tests/data/fate/vsynth_lena-ffv1.3-420.avi +3547792 tests/data/fate/vsynth_lena-ffv1.3-420.avi +dde5895817ad9d219f79a52d0bdfb001 *tests/data/fate/vsynth_lena-ffv1.3-420.out.rawvideo +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-422p10 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-422p10 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-422p10 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-422p10 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +cd3f5b3d4544a30bd08a9a11945a8adc *tests/data/fate/vsynth_lena-ffv1.3-422p10.avi +3910306 tests/data/fate/vsynth_lena-ffv1.3-422p10.avi +dde5895817ad9d219f79a52d0bdfb001 *tests/data/fate/vsynth_lena-ffv1.3-422p10.out.rawvideo +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-444p16 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-444p16 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-444p16 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-444p16 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +e65ad01440ad756b1872b22d3cfa23d7 *tests/data/fate/vsynth_lena-ffv1.3-444p16.avi +4871266 tests/data/fate/vsynth_lena-ffv1.3-444p16.avi +dde5895817ad9d219f79a52d0bdfb001 *tests/data/fate/vsynth_lena-ffv1.3-444p16.out.rawvideo +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-bgr ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-bgr --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-bgr 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-ffv1.3-bgr 2015-06-22 17:20:02.000000000 +0000 @@ -0,0 +1,4 @@ +edf0987619d4d63f8b7e3022a8d0a724 *tests/data/fate/vsynth_lena-ffv1.3-bgr.avi +6013028 tests/data/fate/vsynth_lena-ffv1.3-bgr.avi +0a8b7ddfec03622e37c869c5b552f9fc *tests/data/fate/vsynth_lena-ffv1.3-bgr.out.rawvideo +stddev: 1.24 PSNR: 46.26 MAXDIFF: 17 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-h261 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-h261 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-h261 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-h261 2015-07-09 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -a8a6fe710cf8591d1ce5fd18f478e217 *tests/data/fate/vsynth_lena-h261.avi +9a2104849cbcf03a612e5906ef4d264b *tests/data/fate/vsynth_lena-h261.avi 191064 tests/data/fate/vsynth_lena-h261.avi 08f65e9aeeeaf189548c2bb417d5114f *tests/data/fate/vsynth_lena-h261.out.rawvideo stddev: 6.37 PSNR: 32.03 MAXDIFF: 77 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-h261-trellis ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-h261-trellis --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-h261-trellis 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-h261-trellis 2015-07-09 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -43fca6298b5366199104942e8a901d52 *tests/data/fate/vsynth_lena-h261-trellis.avi +41522be50f14b7fff6b1fb8d10b1ff00 *tests/data/fate/vsynth_lena-h261-trellis.avi 184586 tests/data/fate/vsynth_lena-h261-trellis.avi f9df8cd110a2f3d9706dd2f29a1d0a89 *tests/data/fate/vsynth_lena-h261-trellis.out.rawvideo stddev: 6.32 PSNR: 32.11 MAXDIFF: 89 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-jpeg2000 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-jpeg2000 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-jpeg2000 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-jpeg2000 2015-06-30 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -9283c83bc8dc830bd48ad66f71ae42e8 *tests/data/fate/vsynth_lena-jpeg2000.avi -1151148 tests/data/fate/vsynth_lena-jpeg2000.avi -71a9ee7ad7c3dad60aa6641712c1f9e4 *tests/data/fate/vsynth_lena-jpeg2000.out.rawvideo -stddev: 4.44 PSNR: 35.17 MAXDIFF: 61 bytes: 7603200/ 7603200 +1f2cf6061c78905b8011091a9a7c425f *tests/data/fate/vsynth_lena-jpeg2000.avi +1138054 tests/data/fate/vsynth_lena-jpeg2000.avi +955653ca7a08447e7b1501b444f24562 *tests/data/fate/vsynth_lena-jpeg2000.out.rawvideo +stddev: 4.40 PSNR: 35.25 MAXDIFF: 58 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-jpeg2000-97 ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-jpeg2000-97 --- ffmpeg-2.7.1~trusty~ppa1/tests/ref/vsynth/vsynth_lena-jpeg2000-97 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tests/ref/vsynth/vsynth_lena-jpeg2000-97 2015-06-30 17:20:03.000000000 +0000 @@ -1,4 +1,4 @@ -ba27504dcabe43d6608798c9cadc5cca *tests/data/fate/vsynth_lena-jpeg2000-97.avi -1118956 tests/data/fate/vsynth_lena-jpeg2000-97.avi -8ac8b9ee81fa73c873668e9f6b78764d *tests/data/fate/vsynth_lena-jpeg2000-97.out.rawvideo -stddev: 4.95 PSNR: 34.23 MAXDIFF: 60 bytes: 7603200/ 7603200 +e5a756e97910420c90e76259c56261cb *tests/data/fate/vsynth_lena-jpeg2000-97.avi +1918956 tests/data/fate/vsynth_lena-jpeg2000-97.avi +93a4ba0c230f2430a813df594676e58a *tests/data/fate/vsynth_lena-jpeg2000-97.out.rawvideo +stddev: 2.84 PSNR: 39.04 MAXDIFF: 28 bytes: 7603200/ 7603200 diff -Nru ffmpeg-2.7.1~trusty~ppa1/tools/cws2fws.c ffmpeg-2.7.2~trusty~ppa1/tools/cws2fws.c --- ffmpeg-2.7.1~trusty~ppa1/tools/cws2fws.c 2015-06-19 20:44:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/tools/cws2fws.c 2015-06-13 17:20:02.000000000 +0000 @@ -31,6 +31,7 @@ char buf_in[1024], buf_out[65536]; z_stream zstream; struct stat statbuf; + int ret = 1; if (argc < 3) { printf("Usage: %s \n", argv[0]); @@ -52,14 +53,12 @@ if (read(fd_in, &buf_in, 8) != 8) { printf("Header error\n"); - close(fd_in); - close(fd_out); - return 1; + goto out; } if (buf_in[0] != 'C' || buf_in[1] != 'W' || buf_in[2] != 'S') { printf("Not a compressed flash file\n"); - return 1; + goto out; } if (fstat(fd_in, &statbuf) < 0) { @@ -76,7 +75,7 @@ buf_in[0] = 'F'; if (write(fd_out, &buf_in, 8) < 8) { perror("Error writing output file"); - return 1; + goto out; } zstream.zalloc = NULL; @@ -103,7 +102,7 @@ if (ret != Z_STREAM_END && ret != Z_OK) { printf("Error while decompressing: %d\n", ret); inflateEnd(&zstream); - return 1; + goto out; } dbgprintf("a_in: %d t_in: %lu a_out: %d t_out: %lu -- %lu out\n", @@ -113,7 +112,8 @@ if (write(fd_out, &buf_out, zstream.total_out - last_out) < zstream.total_out - last_out) { perror("Error writing output file"); - return 1; + inflateEnd(&zstream); + goto out; } i += len; @@ -134,12 +134,15 @@ if ( lseek(fd_out, 4, SEEK_SET) < 0 || write(fd_out, &buf_in, 4) < 4) { perror("Error writing output file"); - return 1; + inflateEnd(&zstream); + goto out; } } + ret = 0; inflateEnd(&zstream); +out: close(fd_in); close(fd_out); - return 0; + return ret; } diff -Nru ffmpeg-2.7.1~trusty~ppa1/VERSION ffmpeg-2.7.2~trusty~ppa1/VERSION --- ffmpeg-2.7.1~trusty~ppa1/VERSION 2015-06-19 20:47:55.000000000 +0000 +++ ffmpeg-2.7.2~trusty~ppa1/VERSION 2015-08-04 17:22:11.000000000 +0000 @@ -1 +1 @@ -2.7.1 +N-74276-g3c86522