diff options
34 files changed, 363 insertions, 459 deletions
diff --git a/contrib/ffmpeg/A01-swscale-assert.patch b/contrib/ffmpeg/A01-swscale-assert.patch index 8136a35b2..e0b6aad6b 100644 --- a/contrib/ffmpeg/A01-swscale-assert.patch +++ b/contrib/ffmpeg/A01-swscale-assert.patch @@ -1,8 +1,8 @@ diff --git a/libswscale/utils.c b/libswscale/utils.c -index d8fee58..b96a771 100644 +index e5e4d60..062ae01 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c -@@ -508,7 +508,9 @@ static int initFilter(int16_t **outFilter, int32_t **filterPos, +@@ -531,7 +531,9 @@ static int initFilter(int16_t **outFilter, int32_t **filterPos, // FIXME try to align filterPos if possible // fix borders diff --git a/contrib/ffmpeg/A02-channel-layout-order.patch b/contrib/ffmpeg/A02-channel-layout-order.patch index 2326e7d3e..ce57af038 100644 --- a/contrib/ffmpeg/A02-channel-layout-order.patch +++ b/contrib/ffmpeg/A02-channel-layout-order.patch @@ -1,20 +1,20 @@ diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c -index 91efaf3..e6c5c8e 100644 +index 3852f6e..c7217c8 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c -@@ -30,6 +30,7 @@ - #include "dsputil.h" +@@ -28,6 +28,7 @@ + + #include "avcodec.h" #include "libavutil/intreadwrite.h" ++#include "libavutil/channel_layout.h" #include "get_bits.h" -+#include "libavutil/audioconvert.h" + #include "internal.h" #include "libavutil/crc.h" - #include "parser.h" - #include "mlp_parser.h" -@@ -434,6 +435,28 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, +@@ -435,6 +436,28 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, s->ch_assign[ch_assign] = ch; } -+ if (m->avctx->codec_id == CODEC_ID_TRUEHD) { ++ if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD) { + switch (m->avctx->channel_layout) { + case AV_CH_LAYOUT_6POINT1: + case (AV_CH_LAYOUT_6POINT1|AV_CH_TOP_CENTER): diff --git a/contrib/ffmpeg/A03-h264-recovery-point.patch b/contrib/ffmpeg/A03-h264-recovery-point.patch index d018dd6b1..bbd25ab46 100644 --- a/contrib/ffmpeg/A03-h264-recovery-point.patch +++ b/contrib/ffmpeg/A03-h264-recovery-point.patch @@ -1,16 +1,16 @@ diff --git a/libavcodec/h264.c b/libavcodec/h264.c -index 6ed251e..a3242ce 100644 +index 1a0b341..98a0350 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c -@@ -2627,6 +2627,7 @@ static void flush_dpb(AVCodecContext *avctx) - h->s.first_field = 0; - ff_h264_reset_sei(h); +@@ -2163,6 +2163,7 @@ static void flush_dpb(AVCodecContext *avctx) + + flush_change(h); ff_mpeg_flush(avctx); + h->recovery_frame= -1; } static int init_poc(H264Context *h) -@@ -4289,9 +4290,18 @@ again: +@@ -3976,9 +3977,18 @@ again: if ((err = decode_slice_header(hx, h))) break; @@ -32,10 +32,10 @@ index 6ed251e..a3242ce 100644 if (h->current_slice == 1) { if (!(s->flags2 & CODEC_FLAG2_CHUNKS)) diff --git a/libavcodec/h264.h b/libavcodec/h264.h -index 570ce2f..454b755 100644 +index 8596121..23daee3 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h -@@ -569,6 +569,13 @@ typedef struct H264Context { +@@ -568,6 +568,13 @@ typedef struct H264Context { * frames. */ int sei_recovery_frame_cnt; diff --git a/contrib/ffmpeg/A04-pgs-pts.patch b/contrib/ffmpeg/A04-pgs-pts.patch deleted file mode 100644 index fe6a6dc93..000000000 --- a/contrib/ffmpeg/A04-pgs-pts.patch +++ /dev/null @@ -1,84 +0,0 @@ -diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h -index 102df3a..aa40c78 100644 ---- a/libavcodec/avcodec.h -+++ b/libavcodec/avcodec.h -@@ -3093,6 +3093,7 @@ typedef struct AVSubtitle { - unsigned num_rects; - AVSubtitleRect **rects; - int64_t pts; ///< Same as packet pts, in AV_TIME_BASE -+ uint8_t forced; - } AVSubtitle; - - /** -diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c -index 3335412..3f14a2d 100644 ---- a/libavcodec/pgssubdec.c -+++ b/libavcodec/pgssubdec.c -@@ -45,6 +45,8 @@ typedef struct PGSSubPresentation { - int y; - int id_number; - int object_number; -+ uint8_t composition_flag; -+ int64_t pts; - } PGSSubPresentation; - - typedef struct PGSSubPicture { -@@ -271,7 +273,8 @@ static void parse_palette_segment(AVCodecContext *avctx, - * @todo TODO: Implement forcing of subtitles - */ - static void parse_presentation_segment(AVCodecContext *avctx, -- const uint8_t *buf, int buf_size) -+ const uint8_t *buf, int buf_size, -+ int64_t pts) - { - PGSSubContext *ctx = avctx->priv_data; - -@@ -280,6 +283,8 @@ static void parse_presentation_segment(AVCodecContext *avctx, - int w = bytestream_get_be16(&buf); - int h = bytestream_get_be16(&buf); - -+ ctx->presentation.pts = pts; -+ - av_dlog(avctx, "Video Dimensions %dx%d\n", - w, h); - if (av_image_check_size(w, h, 0, avctx) >= 0) -@@ -299,16 +304,17 @@ static void parse_presentation_segment(AVCodecContext *avctx, - buf += 3; - - ctx->presentation.object_number = bytestream_get_byte(&buf); -+ ctx->presentation.composition_flag = 0; - if (!ctx->presentation.object_number) - return; - - /* -- * Skip 4 bytes of unknown: -+ * Skip 3 bytes of unknown: - * object_id_ref (2 bytes), - * window_id_ref, -- * composition_flag (0x80 - object cropped, 0x40 - object forced) - */ -- buf += 4; -+ buf += 3; -+ ctx->presentation.composition_flag = bytestream_get_byte(&buf); - - x = bytestream_get_be16(&buf); - y = bytestream_get_be16(&buf); -@@ -356,6 +362,9 @@ static int display_end_segment(AVCodecContext *avctx, void *data, - */ - - memset(sub, 0, sizeof(*sub)); -+ sub->pts = ctx->presentation.pts; -+ sub->forced = (ctx->presentation.composition_flag & 0x40) != 0; -+ - // Blank if last object_number was 0. - // Note that this may be wrong for more complex subtitles. - if (!ctx->presentation.object_number) -@@ -441,7 +450,7 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, - parse_picture_segment(avctx, buf, segment_length); - break; - case PRESENTATION_SEGMENT: -- parse_presentation_segment(avctx, buf, segment_length); -+ parse_presentation_segment(avctx, buf, segment_length, avpkt->pts); - break; - case WINDOW_SEGMENT: - /* diff --git a/contrib/ffmpeg/A04-snow-use-videodspcontext.patch b/contrib/ffmpeg/A04-snow-use-videodspcontext.patch new file mode 100644 index 000000000..fc9a120b9 --- /dev/null +++ b/contrib/ffmpeg/A04-snow-use-videodspcontext.patch @@ -0,0 +1,33 @@ +diff --git a/libavcodec/snow.c b/libavcodec/snow.c +index b9dab45..153e5b2 100644 +--- a/libavcodec/snow.c ++++ b/libavcodec/snow.c +@@ -349,7 +349,7 @@ void ff_snow_pred_block(SnowContext *s, uint8_t *dst, uint8_t *tmp, int stride, + src += sx + sy*stride; + if( (unsigned)sx >= w - b_w - (HTAPS_MAX-2) + || (unsigned)sy >= h - b_h - (HTAPS_MAX-2)){ +- s->dsp.emulated_edge_mc(tmp + MB_SIZE, src, stride, b_w+HTAPS_MAX-1, b_h+HTAPS_MAX-1, sx, sy, w, h); ++ s->vdsp.emulated_edge_mc(tmp + MB_SIZE, src, stride, b_w+HTAPS_MAX-1, b_h+HTAPS_MAX-1, sx, sy, w, h); + src= tmp + MB_SIZE; + } + // assert(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h); +@@ -402,6 +402,7 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ + s->max_ref_frames=1; //just make sure its not an invalid value in case of no initial keyframe + + ff_dsputil_init(&s->dsp, avctx); ++ ff_videodsp_init(&s->vdsp, 8); + ff_dwt_init(&s->dwt); + + #define mcf(dx,dy)\ +diff --git a/libavcodec/snow.h b/libavcodec/snow.h +index abf3309..b988115 100644 +--- a/libavcodec/snow.h ++++ b/libavcodec/snow.h +@@ -108,6 +108,7 @@ typedef struct SnowContext{ + AVCodecContext *avctx; + RangeCoder c; + DSPContext dsp; ++ VideoDSPContext vdsp; + DWTContext dwt; + AVFrame new_picture; + AVFrame input_picture; ///< new_picture with the internal linesizes diff --git a/contrib/ffmpeg/A05-mix-normalization.patch b/contrib/ffmpeg/A05-mix-normalization.patch deleted file mode 100644 index 06fb2754c..000000000 --- a/contrib/ffmpeg/A05-mix-normalization.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff --git a/libavresample/audio_mix.c b/libavresample/audio_mix.c -index 2c2a356..25f9f98 100644 ---- a/libavresample/audio_mix.c -+++ b/libavresample/audio_mix.c -@@ -327,7 +327,9 @@ int ff_audio_mix_init(AVAudioResampleContext *avr) - avr->out_channel_layout, - avr->center_mix_level, - avr->surround_mix_level, -- avr->lfe_mix_level, 1, matrix_dbl, -+ avr->lfe_mix_level, -+ avr->normalize_mix_level, -+ matrix_dbl, - avr->in_channels, - avr->matrix_encoding); - if (ret < 0) { -diff --git a/libavresample/internal.h b/libavresample/internal.h -index 7b7648f..006b6fd 100644 ---- a/libavresample/internal.h -+++ b/libavresample/internal.h -@@ -45,6 +45,7 @@ struct AVAudioResampleContext { - double center_mix_level; /**< center mix level */ - double surround_mix_level; /**< surround mix level */ - double lfe_mix_level; /**< lfe mix level */ -+ int normalize_mix_level; /**< enable mix level normalization */ - int force_resampling; /**< force resampling */ - int filter_size; /**< length of each FIR filter in the resampling filterbank relative to the cutoff frequency */ - int phase_shift; /**< log2 of the number of entries in the resampling polyphase filterbank */ -diff --git a/libavresample/options.c b/libavresample/options.c -index 02e1f86..e7e0c27 100644 ---- a/libavresample/options.c -+++ b/libavresample/options.c -@@ -47,6 +47,7 @@ static const AVOption options[] = { - { "center_mix_level", "Center Mix Level", OFFSET(center_mix_level), AV_OPT_TYPE_DOUBLE, { M_SQRT1_2 }, -32.0, 32.0, PARAM }, - { "surround_mix_level", "Surround Mix Level", OFFSET(surround_mix_level), AV_OPT_TYPE_DOUBLE, { M_SQRT1_2 }, -32.0, 32.0, PARAM }, - { "lfe_mix_level", "LFE Mix Level", OFFSET(lfe_mix_level), AV_OPT_TYPE_DOUBLE, { 0.0 }, -32.0, 32.0, PARAM }, -+ { "normalize_mix_level", "Normalize Mix Level", OFFSET(normalize_mix_level), AV_OPT_TYPE_INT, { 1 }, 0, 1, PARAM }, - { "force_resampling", "Force Resampling", OFFSET(force_resampling), AV_OPT_TYPE_INT, { 0 }, 0, 1, PARAM }, - { "filter_size", "Resampling Filter Size", OFFSET(filter_size), AV_OPT_TYPE_INT, { 16 }, 0, 32, /* ??? */ PARAM }, - { "phase_shift", "Resampling Phase Shift", OFFSET(phase_shift), AV_OPT_TYPE_INT, { 10 }, 0, 30, /* ??? */ PARAM }, diff --git a/contrib/ffmpeg/A06-fmac-scalar-asm.patch b/contrib/ffmpeg/A06-fmac-scalar-asm.patch deleted file mode 100644 index b0ca0f084..000000000 --- a/contrib/ffmpeg/A06-fmac-scalar-asm.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/libavutil/x86/float_dsp.asm b/libavutil/x86/float_dsp.asm -index c4e0c66..d379d8f 100644 ---- a/libavutil/x86/float_dsp.asm -+++ b/libavutil/x86/float_dsp.asm -@@ -60,12 +60,12 @@ cglobal vector_fmac_scalar, 3,3,3, dst, src, len - %else - cglobal vector_fmac_scalar, 4,4,3, dst, src, mul, len - %endif --%if WIN64 -- SWAP 0, 2 --%endif - %if ARCH_X86_32 - VBROADCASTSS m0, mulm - %else -+%if WIN64 -+ mova xmm0, xmm2 -+%endif - shufps xmm0, xmm0, 0 - %if cpuflag(avx) - vinsertf128 m0, m0, xmm0, 1 diff --git a/contrib/ffmpeg/P01-solaris.patch b/contrib/ffmpeg/P01-solaris.patch index 8266d0914..b97907941 100644 --- a/contrib/ffmpeg/P01-solaris.patch +++ b/contrib/ffmpeg/P01-solaris.patch @@ -1,18 +1,8 @@ diff --git a/configure b/configure -index 07baa2f..4597a0d 100755 +index 5355300..5ac7bc0 100755 --- a/configure +++ b/configure -@@ -54,6 +54,9 @@ if test "$E1" != 0 || test "$E2" = 0; then - exit 1 - fi - -+# Solaris must use the xpg4 version of grep -+PATH=/usr/xpg4/bin:$PATH -+ - show_help(){ - cat <<EOF - Usage: configure [options] -@@ -2688,7 +2691,7 @@ EOF +@@ -3146,7 +3146,7 @@ EOF check_cc <<EOF || die "endian test failed" unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E'; EOF diff --git a/contrib/ffmpeg/P02-darwin-pic.patch b/contrib/ffmpeg/P02-darwin-pic.patch index e9d8dfc00..576c23e79 100644 --- a/contrib/ffmpeg/P02-darwin-pic.patch +++ b/contrib/ffmpeg/P02-darwin-pic.patch @@ -1,8 +1,8 @@ diff --git a/configure b/configure -index 07baa2f..8a2a581 100755 +index 5355300..7ae7148 100755 --- a/configure +++ b/configure -@@ -2494,6 +2494,7 @@ case $target_os in +@@ -2868,6 +2868,7 @@ case $target_os in AVSERVERLDFLAGS=-Wl,-bind_at_load objformat="macho" enabled x86_64 && objformat="macho64" @@ -10,7 +10,7 @@ index 07baa2f..8a2a581 100755 enabled_any pic shared || { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; } ;; -@@ -2614,7 +2615,7 @@ esc(){ +@@ -3070,7 +3071,7 @@ esc(){ echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $LIBAV_CONFIGURATION)" >config.fate @@ -18,4 +18,4 @@ index 07baa2f..8a2a581 100755 +#check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic set_default $PATHS_LIST - + set_default nm diff --git a/contrib/ffmpeg/module.defs b/contrib/ffmpeg/module.defs index 54ac675f7..2c0d64bdc 100644 --- a/contrib/ffmpeg/module.defs +++ b/contrib/ffmpeg/module.defs @@ -1,13 +1,14 @@ $(eval $(call import.MODULE.defs,FFMPEG,ffmpeg,YASM BZIP2 ZLIB)) $(eval $(call import.CONTRIB.defs,FFMPEG)) -FFMPEG.FETCH.url = http://download.handbrake.fr/handbrake/contrib/libav-v0.8-2551-gc83f44d.tar.bz2 +FFMPEG.FETCH.url = http://download.handbrake.fr/handbrake/contrib/libav-v9_beta3.tar.bz2 FFMPEG.CONFIGURE.deps = FFMPEG.CONFIGURE.env = FFMPEG.CONFIGURE.host = FFMPEG.CONFIGURE.extra = \ + --enable-gpl \ --disable-doc \ --disable-bsfs \ --disable-avconv \ @@ -19,13 +20,12 @@ FFMPEG.CONFIGURE.extra = \ --disable-network \ --disable-hwaccels \ --disable-encoders \ - --enable-encoder=flac \ - --enable-encoder=ac3 \ --enable-encoder=aac \ - --enable-encoder=mpeg4 \ + --enable-encoder=ac3 \ + --enable-encoder=flac \ --enable-encoder=mpeg2video \ + --enable-encoder=mpeg4 \ --enable-encoder=snow \ - --enable-gpl \ --enable-zlib \ --enable-bzlib \ --cc="$(FFMPEG.GCC.gcc)" \ diff --git a/libhb/audio_remap.c b/libhb/audio_remap.c index d0374a0a0..2ca935fbb 100644 --- a/libhb/audio_remap.c +++ b/libhb/audio_remap.c @@ -11,7 +11,7 @@ #include "hbffmpeg.h" #include "audio_remap.h" -// source: libavutil/audioconvert.h +// source: libavutil/channel_layout.h hb_chan_map_t hb_libav_chan_map = { { diff --git a/libhb/audio_resample.c b/libhb/audio_resample.c index cc9b50d8b..a1cfb1d24 100644 --- a/libhb/audio_resample.c +++ b/libhb/audio_resample.c @@ -231,8 +231,8 @@ hb_buffer_t* hb_audio_resample(hb_audio_resample_t *resample, out = hb_buffer_init(out_size); out_samples = avresample_convert(resample->avresample, - (void**)&out->data, out_linesize, nsamples, - (void**)samples, in_linesize, nsamples); + &out->data, out_linesize, nsamples, + samples, in_linesize, nsamples); if (out_samples <= 0) { diff --git a/libhb/audio_resample.h b/libhb/audio_resample.h index 62a536d61..c1903eac0 100644 --- a/libhb/audio_resample.h +++ b/libhb/audio_resample.h @@ -19,7 +19,7 @@ #include <math.h> #include <stdint.h> -#include "libavutil/audioconvert.h" +#include "libavutil/channel_layout.h" #include "libavresample/avresample.h" /* Default mix level for center and surround channels */ diff --git a/libhb/bd.c b/libhb/bd.c index 268cdaab0..67331bff5 100644 --- a/libhb/bd.c +++ b/libhb/bd.c @@ -352,12 +352,12 @@ hb_title_t * hb_bd_title_scan( hb_bd_t * d, int tt, uint64_t min_duration ) case BLURAY_STREAM_TYPE_VIDEO_VC1: title->video_codec = WORK_DECAVCODECV; - title->video_codec_param = CODEC_ID_VC1; + title->video_codec_param = AV_CODEC_ID_VC1; break; case BLURAY_STREAM_TYPE_VIDEO_H264: title->video_codec = WORK_DECAVCODECV; - title->video_codec_param = CODEC_ID_H264; + title->video_codec_param = AV_CODEC_ID_H264; title->flags |= HBTF_NO_IDR; break; @@ -409,62 +409,63 @@ hb_title_t * hb_bd_title_scan( hb_bd_t * d, int tt, uint64_t min_duration ) } // Add all the audios found in the above clip. - for ( ii = 0; ii < ti->clips[audio_clip_index].audio_stream_count; ii++ ) + for (ii = 0; ii < ti->clips[audio_clip_index].audio_stream_count; ii++) { BLURAY_STREAM_INFO * bdaudio; bdaudio = &ti->clips[audio_clip_index].audio_streams[ii]; - switch( bdaudio->coding_type ) + switch (bdaudio->coding_type) { case BLURAY_STREAM_TYPE_AUDIO_TRUHD: // Add 2 audio tracks. One for TrueHD and one for AC-3 - add_audio(ii, title->list_audio, bdaudio, - HB_SUBSTREAM_BD_AC3, HB_ACODEC_AC3, 0); - add_audio(ii, title->list_audio, bdaudio, - HB_SUBSTREAM_BD_TRUEHD, HB_ACODEC_FFMPEG, CODEC_ID_TRUEHD); + add_audio(ii, title->list_audio, bdaudio, HB_SUBSTREAM_BD_AC3, + HB_ACODEC_AC3, 0); + add_audio(ii, title->list_audio, bdaudio, HB_SUBSTREAM_BD_TRUEHD, + HB_ACODEC_FFMPEG, AV_CODEC_ID_TRUEHD); break; case BLURAY_STREAM_TYPE_AUDIO_DTS: - add_audio(ii, title->list_audio, bdaudio, 0, HB_ACODEC_DCA, - CODEC_ID_DTS); + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_DCA, AV_CODEC_ID_DTS); break; case BLURAY_STREAM_TYPE_AUDIO_MPEG2: case BLURAY_STREAM_TYPE_AUDIO_MPEG1: - add_audio(ii, title->list_audio, bdaudio, 0, - HB_ACODEC_FFMPEG, CODEC_ID_MP2); + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_FFMPEG, AV_CODEC_ID_MP2); break; case BLURAY_STREAM_TYPE_AUDIO_AC3PLUS: - add_audio(ii, title->list_audio, bdaudio, 0, - HB_ACODEC_FFMPEG, CODEC_ID_EAC3); + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_FFMPEG, AV_CODEC_ID_EAC3); break; case BLURAY_STREAM_TYPE_AUDIO_LPCM: - add_audio(ii, title->list_audio, bdaudio, 0, - HB_ACODEC_FFMPEG, CODEC_ID_PCM_BLURAY); + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_FFMPEG, AV_CODEC_ID_PCM_BLURAY); break; case BLURAY_STREAM_TYPE_AUDIO_AC3: - add_audio(ii, title->list_audio, bdaudio, 0, HB_ACODEC_AC3, 0); + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_AC3, 0); break; case BLURAY_STREAM_TYPE_AUDIO_DTSHD_MASTER: case BLURAY_STREAM_TYPE_AUDIO_DTSHD: // Add 2 audio tracks. One for DTS-HD and one for DTS - add_audio(ii, title->list_audio, bdaudio, HB_SUBSTREAM_BD_DTS, - HB_ACODEC_DCA, CODEC_ID_DTS); + add_audio(ii, title->list_audio, bdaudio, HB_SUBSTREAM_BD_DTS, + HB_ACODEC_DCA, AV_CODEC_ID_DTS); // DTS-HD is special. The substreams must be concatinated // DTS-core followed by DTS-hd-extensions. Setting // a substream id of 0 says use all substreams. add_audio(ii, title->list_audio, bdaudio, 0, - HB_ACODEC_DCA_HD, CODEC_ID_DTS); + HB_ACODEC_DCA_HD, AV_CODEC_ID_DTS); break; default: - hb_log( "scan: unknown audio pid 0x%x codec 0x%x", - bdaudio->pid, bdaudio->coding_type ); + hb_log("scan: unknown audio pid 0x%x codec 0x%x", bdaudio->pid, + bdaudio->coding_type); break; } } diff --git a/libhb/common.h b/libhb/common.h index b929852d0..0b6d6ec2c 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -101,7 +101,7 @@ typedef struct hb_lock_s hb_lock_t; #define PRIVATE const #endif #include "audio_remap.h" -#include "libavutil/audioconvert.h" +#include "libavutil/channel_layout.h" hb_list_t * hb_list_init(); int hb_list_count( const hb_list_t * ); diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 5248d5f52..fe59300fe 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -423,10 +423,10 @@ static int decavcodecaBSInfo( hb_work_object_t *w, const hb_buffer_t *buf, pos += len; if ( pbuffer_size > 0 ) { - AVFrame frame; int got_frame; + AVFrame frame = { { 0 } }; AVPacket avp; - av_init_packet( &avp ); + av_init_packet(&avp); avp.data = pbuffer; avp.size = pbuffer_size; @@ -504,31 +504,32 @@ static hb_buffer_t *copy_frame( hb_work_private_t *pv, AVFrame *frame ) hb_buffer_t *buf = hb_video_buffer_init( w, h ); uint8_t *dst = buf->data; - if ( context->pix_fmt != PIX_FMT_YUV420P || w != context->width || - h != context->height ) + if (context->pix_fmt != AV_PIX_FMT_YUV420P || w != context->width || + h != context->height) { // have to convert to our internal color space and/or rescale AVPicture dstpic; - hb_avpicture_fill( &dstpic, buf ); + hb_avpicture_fill(&dstpic, buf); - if ( ! pv->sws_context || - pv->sws_width != context->width || - pv->sws_height != context->height || - pv->sws_pix_fmt != context->pix_fmt ) + if (pv->sws_context == NULL || + pv->sws_width != context->width || + pv->sws_height != context->height || + pv->sws_pix_fmt != context->pix_fmt) { - if( pv->sws_context ) - sws_freeContext( pv->sws_context ); - pv->sws_context = hb_sws_get_context( - context->width, context->height, context->pix_fmt, - w, h, PIX_FMT_YUV420P, - SWS_LANCZOS|SWS_ACCURATE_RND); - pv->sws_width = context->width; - pv->sws_height = context->height; + if (pv->sws_context != NULL) + sws_freeContext(pv->sws_context); + pv->sws_context = hb_sws_get_context(context->width, + context->height, + context->pix_fmt, + w, h, AV_PIX_FMT_YUV420P, + SWS_LANCZOS|SWS_ACCURATE_RND); + pv->sws_width = context->width; + pv->sws_height = context->height; pv->sws_pix_fmt = context->pix_fmt; } - sws_scale( pv->sws_context, (const uint8_t* const *)frame->data, - frame->linesize, 0, context->height, - dstpic.data, dstpic.linesize ); + sws_scale(pv->sws_context, + (const uint8_t* const *)frame->data, frame->linesize, + 0, context->height, dstpic.data, dstpic.linesize); } else { @@ -690,7 +691,7 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int sequen { hb_work_private_t *pv = w->private_data; int got_picture, oldlevel = 0; - AVFrame frame; + AVFrame frame = { { 0 } }; AVPacket avp; if ( global_verbosity_level <= 1 ) @@ -699,11 +700,11 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int sequen av_log_set_level( AV_LOG_QUIET ); } - av_init_packet( &avp ); + av_init_packet(&avp); avp.data = data; avp.size = size; - avp.pts = pts; - avp.dts = dts; + avp.pts = pts; + avp.dts = dts; /* * libav avcodec_decode_video2() needs AVPacket flagged with AV_PKT_FLAG_KEY * for some codecs. For example, sequence of PNG in a mov container. @@ -727,10 +728,9 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int sequen // codecs it simply sets frame.key_frame. But for others, it only // sets frame.pict_type. And for yet others neither gets set at all // (qtrle). - int key = frame.key_frame || - ( w->codec_param != CODEC_ID_H264 && - ( frame.pict_type == AV_PICTURE_TYPE_I || - frame.pict_type == 0 ) ); + int key = frame.key_frame || (w->codec_param != AV_CODEC_ID_H264 && + (frame.pict_type == 0 || + frame.pict_type == AV_PICTURE_TYPE_I)); if( !key ) { pv->wait_for_keyframe--; @@ -1058,7 +1058,7 @@ static int setup_extradata( hb_work_object_t *w, hb_buffer_t *in ) // vc1t_read_header allocates 'extradata' to deal with header issues // related to Microsoft's bizarre engineering notions. We alloc a chunk // of space to make vc1 work then associate the codec with the context. - if ( w->codec_param != CODEC_ID_VC1 ) + if ( w->codec_param != AV_CODEC_ID_VC1 ) { // we haven't been inflicted with M$ - allocate a little space as // a marker and return success. @@ -1434,9 +1434,10 @@ static void decodeAudio(hb_audio_t *audio, hb_work_private_t *pv, uint8_t *data, pv->pts_next = pts; while (pos < size) { - AVFrame frame; int got_frame; + AVFrame frame = { { 0 } }; AVPacket avp; + av_init_packet(&avp); avp.data = data + pos; avp.size = size - pos; diff --git a/libhb/decmpeg2.c b/libhb/decmpeg2.c index 991feb8e9..15c0d21d5 100644 --- a/libhb/decmpeg2.c +++ b/libhb/decmpeg2.c @@ -44,7 +44,7 @@ typedef struct hb_libmpeg2_s int height; int rate; double aspect_ratio; - enum PixelFormat pixfmt; + enum AVPixelFormat pixfmt; int got_iframe; /* set when we get our first iframe */ int look_for_iframe; /* need an iframe to add chap break */ int look_for_break; /* need gop start to add chap break */ @@ -272,7 +272,7 @@ static hb_buffer_t *hb_copy_frame( hb_libmpeg2_t *m ) hb_job_t * job = m->job; int width = m->info->sequence->width; int height = m->info->sequence->height; - enum PixelFormat pixfmt = m->pixfmt; + enum AVPixelFormat pixfmt = m->pixfmt; uint8_t *y = m->info->display_fbuf->buf[0]; uint8_t *u = m->info->display_fbuf->buf[1]; uint8_t *v = m->info->display_fbuf->buf[2]; @@ -423,11 +423,11 @@ static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es, if ( m->info->sequence->width >> 1 == m->info->sequence->chroma_width && m->info->sequence->height >> 1 == m->info->sequence->chroma_height ) { - m->pixfmt = PIX_FMT_YUV420P; + m->pixfmt = AV_PIX_FMT_YUV420P; } else { - m->pixfmt = PIX_FMT_YUV422P; + m->pixfmt = AV_PIX_FMT_YUV422P; } } else if( state == STATE_GOP && m->look_for_break) diff --git a/libhb/decpgssub.c b/libhb/decpgssub.c index 9d32c85e3..7a11d924b 100644 --- a/libhb/decpgssub.c +++ b/libhb/decpgssub.c @@ -42,7 +42,7 @@ struct hb_work_private_s static int decsubInit( hb_work_object_t * w, hb_job_t * job ) { - AVCodec *codec = avcodec_find_decoder( CODEC_ID_HDMV_PGS_SUBTITLE ); + AVCodec *codec = avcodec_find_decoder( AV_CODEC_ID_HDMV_PGS_SUBTITLE ); AVCodecContext *context = avcodec_alloc_context3( codec ); context->codec = codec; @@ -226,9 +226,10 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in, * 2. we're not doing Foreign Audio Search (!pv->job->indepth_scan) AND * 3. the sub is non-empty or we've seen one such sub before (!pv->discard_subtitle) * For forced-only extraction, usable subtitles also need to: - * a. be forced (subtitle.forced) OR + * a. be forced (subtitle.rects[0]->flags & AV_SUBTITLE_FLAG_FORCED) OR * b. follow a forced sub (pv->seen_forced_sub) */ - uint8_t useable_sub = 0; + uint8_t forced_sub = 0; + uint8_t useable_sub = 0; uint8_t clear_subtitle = 0; if (has_subtitle) @@ -237,8 +238,9 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in, if (subtitle.num_rects) { w->subtitle->hits++; - if (subtitle.forced) + if (subtitle.rects[0]->flags & AV_SUBTITLE_FLAG_FORCED) { + forced_sub = 1; w->subtitle->forced_hits++; } } @@ -254,10 +256,10 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in, // do we need this subtitle? useable_sub = (!pv->discard_subtitle && (!w->subtitle->config.force || - subtitle.forced || pv->seen_forced_sub)); + forced_sub || pv->seen_forced_sub)); // do we need to create an empty subtitle? - if (w->subtitle->config.force && useable_sub && - !subtitle.forced && !clear_subtitle) + if (w->subtitle->config.force && + useable_sub && !forced_sub && !clear_subtitle) { // We are forced-only and need to output this subtitle, but // it's neither forced nor empty. @@ -268,7 +270,7 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in, clear_subtitle = 1; } // is the subtitle forced? - pv->seen_forced_sub = subtitle.forced; + pv->seen_forced_sub = forced_sub; } } @@ -343,8 +345,8 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in, { AVSubtitleRect *rect = subtitle.rects[ii]; - out = hb_frame_buffer_init( - PIX_FMT_YUVA420P, rect->w, rect->h ); + out = hb_frame_buffer_init(AV_PIX_FMT_YUVA420P, + rect->w, rect->h); out->s.id = in->s.id; out->sequence = in->sequence; diff --git a/libhb/decvobsub.c b/libhb/decvobsub.c index b57c75f12..05d4ae09d 100644 --- a/libhb/decvobsub.c +++ b/libhb/decvobsub.c @@ -536,7 +536,7 @@ static hb_buffer_t * CropSubtitle( hb_work_object_t * w, uint8_t * raw ) realwidth = crop[3] - crop[2] + 1; realheight = crop[1] - crop[0] + 1; - buf = hb_frame_buffer_init( PIX_FMT_YUVA420P, realwidth, realheight ); + buf = hb_frame_buffer_init( AV_PIX_FMT_YUVA420P, realwidth, realheight ); buf->s.start = pv->pts_start; buf->s.stop = pv->pts_stop; buf->s.type = SUBTITLE_BUF; diff --git a/libhb/dvd.c b/libhb/dvd.c index f342b5474..0368486a8 100644 --- a/libhb/dvd.c +++ b/libhb/dvd.c @@ -369,7 +369,7 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur case 0x03: audio->id = 0xc0 + position; audio->config.in.codec = HB_ACODEC_FFMPEG; - audio->config.in.codec_param = CODEC_ID_MP2; + audio->config.in.codec_param = AV_CODEC_ID_MP2; codec_name = "MPEG"; break; @@ -382,7 +382,7 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur case 0x06: audio->id = ( ( 0x88 + position ) << 8 ) | 0xbd; audio->config.in.codec = HB_ACODEC_DCA; - audio->config.in.codec_param = CODEC_ID_DTS; + audio->config.in.codec_param = AV_CODEC_ID_DTS; codec_name = "DTS"; break; diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c index c1f152efd..e9cd44053 100644 --- a/libhb/dvdnav.c +++ b/libhb/dvdnav.c @@ -545,7 +545,7 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura case 0x03: audio->id = 0xc0 + position; audio->config.in.codec = HB_ACODEC_FFMPEG; - audio->config.in.codec_param = CODEC_ID_MP2; + audio->config.in.codec_param = AV_CODEC_ID_MP2; codec_name = "MPEG"; break; @@ -558,7 +558,7 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura case 0x06: audio->id = ( ( 0x88 + position ) << 8 ) | 0xbd; audio->config.in.codec = HB_ACODEC_DCA; - audio->config.in.codec_param = CODEC_ID_DTS; + audio->config.in.codec_param = AV_CODEC_ID_DTS; codec_name = "DTS"; break; diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c index 44453477f..7468e9657 100644 --- a/libhb/encavcodec.c +++ b/libhb/encavcodec.c @@ -70,11 +70,11 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) switch ( w->codec_param ) { - case CODEC_ID_MPEG4: + case AV_CODEC_ID_MPEG4: { hb_log("encavcodecInit: MPEG-4 ASP encoder"); } break; - case CODEC_ID_MPEG2VIDEO: + case AV_CODEC_ID_MPEG2VIDEO: { hb_log("encavcodecInit: MPEG-2 encoder"); } break; @@ -198,7 +198,7 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) } context->width = job->width; context->height = job->height; - context->pix_fmt = PIX_FMT_YUV420P; + context->pix_fmt = AV_PIX_FMT_YUV420P; if( job->anamorphic.mode ) { @@ -539,7 +539,7 @@ int encavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in, hb_error( "encavcodec: codec context has uninitialized codec; skipping frame" ); } - av_free( frame ); + avcodec_free_frame(&frame); *buf_out = buf; diff --git a/libhb/encavcodecaudio.c b/libhb/encavcodecaudio.c index 8da52d8b8..db09e8a6f 100644 --- a/libhb/encavcodecaudio.c +++ b/libhb/encavcodecaudio.c @@ -66,11 +66,12 @@ static int encavcodecaInit(hb_work_object_t *w, hb_job_t *job) context->sample_rate = audio->config.out.samplerate; AVDictionary *av_opts = NULL; - if (w->codec_param == CODEC_ID_AAC) + if (w->codec_param == AV_CODEC_ID_AAC) { av_dict_set(&av_opts, "stereo_mode", "ms_off", 0); } - else if (w->codec_param == CODEC_ID_AC3 && mode != AV_MATRIX_ENCODING_NONE) + else if (w->codec_param == AV_CODEC_ID_AC3 && + mode != AV_MATRIX_ENCODING_NONE) { av_dict_set(&av_opts, "dsur_mode", "on", 0); } @@ -268,10 +269,10 @@ static hb_buffer_t* Encode(hb_work_object_t *w) av_samples_get_buffer_size(&in_linesize, pv->context->channels, frame.nb_samples, AV_SAMPLE_FMT_FLT, 1); int out_samples = avresample_convert(pv->avresample, - (void**)frame.extended_data, - out_linesize, frame.nb_samples, - (void**)&pv->input_buf, - in_linesize, frame.nb_samples); + frame.extended_data, out_linesize, + frame.nb_samples, + &pv->input_buf, in_linesize, + frame.nb_samples); if (out_samples != pv->samples_per_frame) { // we're not doing sample rate conversion, so this shouldn't happen diff --git a/libhb/enctheora.c b/libhb/enctheora.c index 77df0c0b5..3d2ecc440 100644 --- a/libhb/enctheora.c +++ b/libhb/enctheora.c @@ -365,7 +365,7 @@ int enctheoraWork( hb_work_object_t * w, hb_buffer_t ** buf_in, buf = hb_buffer_init( op.bytes + sizeof(op) ); memcpy(buf->data, &op, sizeof(op)); memcpy(buf->data + sizeof(op), op.packet, op.bytes); - buf->f.fmt = PIX_FMT_YUV420P; + buf->f.fmt = AV_PIX_FMT_YUV420P; buf->f.width = frame_width; buf->f.height = frame_height; buf->s.frametype = ( th_packet_iskeyframe(&op) ) ? HB_FRAME_KEY : HB_FRAME_REF; diff --git a/libhb/encx264.c b/libhb/encx264.c index 74a4adda2..f5808963f 100644 --- a/libhb/encx264.c +++ b/libhb/encx264.c @@ -340,10 +340,10 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job ) if( job->grayscale ) { - int uvsize = hb_image_stride( PIX_FMT_YUV420P, job->width, 1 ) * - hb_image_height( PIX_FMT_YUV420P, job->height, 1 ); - pv->grey_data = malloc( uvsize ); - memset( pv->grey_data, 0x80, uvsize ); + int uvsize = (hb_image_stride(AV_PIX_FMT_YUV420P, job->width, 1) * + hb_image_height(AV_PIX_FMT_YUV420P, job->height, 1)); + pv->grey_data = malloc(uvsize); + memset(pv->grey_data, 0x80, uvsize); pv->pic_in.img.plane[1] = pv->pic_in.img.plane[2] = pv->grey_data; } diff --git a/libhb/hb.c b/libhb/hb.c index 5a71ee7f2..ac9a7d015 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -122,6 +122,12 @@ int hb_avcodec_open(AVCodecContext *avctx, AVCodec *codec, avctx->thread_count = 1; } + if (codec->capabilities & CODEC_CAP_EXPERIMENTAL) + { + // "experimental" encoders will not open without this + avctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; + } + ret = avcodec_open2(avctx, codec, av_opts); return ret; } @@ -152,20 +158,21 @@ int hb_avpicture_fill(AVPicture *pic, hb_buffer_t *buf) return ret; } -static int handle_jpeg(enum PixelFormat *format) +static int handle_jpeg(enum AVPixelFormat *format) { - switch (*format) { - case PIX_FMT_YUVJ420P: *format = PIX_FMT_YUV420P; return 1; - case PIX_FMT_YUVJ422P: *format = PIX_FMT_YUV422P; return 1; - case PIX_FMT_YUVJ444P: *format = PIX_FMT_YUV444P; return 1; - case PIX_FMT_YUVJ440P: *format = PIX_FMT_YUV440P; return 1; - default: return 0; + switch (*format) + { + case AV_PIX_FMT_YUVJ420P: *format = AV_PIX_FMT_YUV420P; return 1; + case AV_PIX_FMT_YUVJ422P: *format = AV_PIX_FMT_YUV422P; return 1; + case AV_PIX_FMT_YUVJ444P: *format = AV_PIX_FMT_YUV444P; return 1; + case AV_PIX_FMT_YUVJ440P: *format = AV_PIX_FMT_YUV440P; return 1; + default: return 0; } } struct SwsContext* -hb_sws_get_context(int srcW, int srcH, enum PixelFormat srcFormat, - int dstW, int dstH, enum PixelFormat dstFormat, +hb_sws_get_context(int srcW, int srcH, enum AVPixelFormat srcFormat, + int dstW, int dstH, enum AVPixelFormat dstFormat, int flags) { struct SwsContext * ctx; @@ -766,7 +773,7 @@ hb_buffer_t * hb_read_preview( hb_handle_t * h, int title_idx, int preview ) } hb_buffer_t * buf; - buf = hb_frame_buffer_init( PIX_FMT_YUV420P, title->width, title->height ); + buf = hb_frame_buffer_init( AV_PIX_FMT_YUV420P, title->width, title->height ); int pp, hh; for( pp = 0; pp < 3; pp++ ) @@ -809,7 +816,7 @@ void hb_get_preview( hb_handle_t * h, hb_job_t * job, int picture, swsflags = SWS_LANCZOS | SWS_ACCURATE_RND; - preview_buf = hb_frame_buffer_init( PIX_FMT_RGB32, + preview_buf = hb_frame_buffer_init( AV_PIX_FMT_RGB32, job->width, job->height ); hb_avpicture_fill( &pic_preview, preview_buf ); @@ -835,26 +842,26 @@ void hb_get_preview( hb_handle_t * h, hb_job_t * job, int picture, // we have aligned all buffers to 16 byte width and height strides // so there is room in the buffers to accomodate a litte // overscan. - deint_buf = hb_frame_buffer_init( PIX_FMT_YUV420P, + deint_buf = hb_frame_buffer_init( AV_PIX_FMT_YUV420P, title->width, title->height ); hb_avpicture_fill( &pic_deint, deint_buf ); - avpicture_deinterlace( &pic_deint, &pic_in, PIX_FMT_YUV420P, + avpicture_deinterlace( &pic_deint, &pic_in, AV_PIX_FMT_YUV420P, width, height ); - av_picture_crop( &pic_crop, &pic_deint, PIX_FMT_YUV420P, + av_picture_crop( &pic_crop, &pic_deint, AV_PIX_FMT_YUV420P, job->crop[0], job->crop[2] ); } else { // Crop - av_picture_crop( &pic_crop, &pic_in, PIX_FMT_YUV420P, job->crop[0], job->crop[2] ); + av_picture_crop( &pic_crop, &pic_in, AV_PIX_FMT_YUV420P, job->crop[0], job->crop[2] ); } // Get scaling context context = hb_sws_get_context(title->width - (job->crop[2] + job->crop[3]), title->height - (job->crop[0] + job->crop[1]), - PIX_FMT_YUV420P, - job->width, job->height, PIX_FMT_RGB32, + AV_PIX_FMT_YUV420P, + job->width, job->height, AV_PIX_FMT_RGB32, swsflags); // Scale diff --git a/libhb/hbffmpeg.h b/libhb/hbffmpeg.h index 2de771505..a28e340fa 100644 --- a/libhb/hbffmpeg.h +++ b/libhb/hbffmpeg.h @@ -9,7 +9,7 @@ #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" -#include "libavutil/audioconvert.h" +#include "libavutil/channel_layout.h" #include "libavutil/imgutils.h" #include "libavutil/mathematics.h" #include "libavutil/opt.h" @@ -27,7 +27,7 @@ uint64_t hb_ff_mixdown_xlat(int hb_mixdown, int *downmix_mode); void hb_ff_set_sample_fmt(AVCodecContext *, AVCodec *, enum AVSampleFormat); struct SwsContext* -hb_sws_get_context(int srcW, int srcH, enum PixelFormat srcFormat, - int dstW, int dstH, enum PixelFormat dstFormat, +hb_sws_get_context(int srcW, int srcH, enum AVPixelFormat srcFormat, + int dstW, int dstH, enum AVPixelFormat dstFormat, int flags); int hb_avpicture_fill(AVPicture *pic, hb_buffer_t *buf); diff --git a/libhb/internal.h b/libhb/internal.h index 1c02ffe85..81cc8680f 100644 --- a/libhb/internal.h +++ b/libhb/internal.h @@ -174,27 +174,26 @@ static inline int hb_image_stride( int pix_fmt, int width, int plane ) return linesize; } -static inline int hb_image_width( int pix_fmt, int width, int plane ) +static inline int hb_image_width(int pix_fmt, int width, int plane) { - const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); - if ( plane == 1 || plane == 2 ) + if (desc != NULL && (plane == 1 || plane == 2)) { // The wacky arithmatic assures rounding up. - width = -((-width)>>desc->log2_chroma_w); + width = -((-width) >> desc->log2_chroma_w); } return width; } -static inline int hb_image_height_stride( int pix_fmt, int height, int plane ) +static inline int hb_image_height_stride(int pix_fmt, int height, int plane) { - const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); // Decomb requires 6 extra lines and stride aligned to 32 bytes - // TODO: eliminate extra buffer copies in decomb - height = MULTIPLE_MOD_UP( height + 6, 32 ); - if ( plane == 1 || plane == 2 ) + height = MULTIPLE_MOD_UP(height + 6, 32); + if (desc != NULL && (plane == 1 || plane == 2)) { height = height >> desc->log2_chroma_h; } @@ -202,14 +201,14 @@ static inline int hb_image_height_stride( int pix_fmt, int height, int plane ) return height; } -static inline int hb_image_height( int pix_fmt, int height, int plane ) +static inline int hb_image_height(int pix_fmt, int height, int plane) { - const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); - if ( plane == 1 || plane == 2 ) + if (desc != NULL && (plane == 1 || plane == 2)) { // The wacky arithmatic assures rounding up. - height = -((-height)>>desc->log2_chroma_h); + height = -((-height) >> desc->log2_chroma_h); } return height; @@ -219,7 +218,7 @@ static inline int hb_image_height( int pix_fmt, int height, int plane ) // with dimensions width x height. static inline hb_buffer_t * hb_video_buffer_init( int width, int height ) { - return hb_frame_buffer_init( PIX_FMT_YUV420P, width, height ); + return hb_frame_buffer_init( AV_PIX_FMT_YUV420P, width, height ); } /*********************************************************************** diff --git a/libhb/mcdeint.c b/libhb/mcdeint.c index 4c8c7cb1e..9eb6f5ac0 100644 --- a/libhb/mcdeint.c +++ b/libhb/mcdeint.c @@ -40,7 +40,7 @@ void mcdeint_init( mcdeint_private_t * pv, { avcodec_register_all(); - AVCodec * enc = avcodec_find_encoder( CODEC_ID_SNOW ); + AVCodec * enc = avcodec_find_encoder( AV_CODEC_ID_SNOW ); // Snow ME_ITER will crash if width & height are not 16 pixel // aligned (or 8 pixel if CODEC_FLAG_4MV is set). diff --git a/libhb/rendersub.c b/libhb/rendersub.c index 4e37699ae..9166ad89f 100644 --- a/libhb/rendersub.c +++ b/libhb/rendersub.c @@ -366,7 +366,7 @@ static hb_buffer_t * RenderSSAFrame( hb_filter_private_t * pv, ASS_Image * frame unsigned frameV = (yuv >> 8 ) & 0xff; unsigned frameU = (yuv >> 0 ) & 0xff; - sub = hb_frame_buffer_init( PIX_FMT_YUVA420P, frame->w, frame->h ); + sub = hb_frame_buffer_init( AV_PIX_FMT_YUVA420P, frame->w, frame->h ); if( sub == NULL ) return NULL; diff --git a/libhb/scan.c b/libhb/scan.c index 0163af406..49c092a1e 100644 --- a/libhb/scan.c +++ b/libhb/scan.c @@ -523,7 +523,7 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title ) if (vcodec == WORK_DECMPEG2) { vcodec = WORK_DECAVCODECV; - title->video_codec_param = CODEC_ID_MPEG2VIDEO; + title->video_codec_param = AV_CODEC_ID_MPEG2VIDEO; } #endif hb_work_object_t *vid_decoder = hb_get_work( vcodec ); @@ -1035,11 +1035,12 @@ static void LookForAudio( hb_title_t * title, hb_buffer_t * b ) } else if (audio->config.in.channel_layout) { - int lfe = !!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY); + int lfes = (!!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY) + + !!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY_2)); int channels = av_get_channel_layout_nb_channels(audio->config.in.channel_layout); char *desc = audio->config.lang.description + strlen(audio->config.lang.description); - sprintf(desc, " (%d.%d ch)", channels - lfe, lfe); + sprintf(desc, " (%d.%d ch)", channels - lfes, lfes); } hb_log( "scan: audio 0x%x: %s, rate=%dHz, bitrate=%d %s", audio->id, diff --git a/libhb/stream.c b/libhb/stream.c index 02a49e20c..a7034042d 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -47,57 +47,57 @@ typedef struct { [id] = { kind, codec, codec_param, name } static const stream2codec_t st2codec[256] = { - st(0x00, U, 0, 0, NULL), - st(0x01, V, WORK_DECMPEG2, 0, "MPEG1"), - st(0x02, V, WORK_DECMPEG2, 0, "MPEG2"), - st(0x03, A, HB_ACODEC_FFMPEG, CODEC_ID_MP2, "MPEG1"), - st(0x04, A, HB_ACODEC_FFMPEG, CODEC_ID_MP2, "MPEG2"), - st(0x05, N, 0, 0, "ISO 13818-1 private section"), - st(0x06, U, 0, 0, "ISO 13818-1 PES private data"), - st(0x07, N, 0, 0, "ISO 13522 MHEG"), - st(0x08, N, 0, 0, "ISO 13818-1 DSM-CC"), - st(0x09, N, 0, 0, "ISO 13818-1 auxiliary"), - st(0x0a, N, 0, 0, "ISO 13818-6 encap"), - st(0x0b, N, 0, 0, "ISO 13818-6 DSM-CC U-N msgs"), - st(0x0c, N, 0, 0, "ISO 13818-6 Stream descriptors"), - st(0x0d, N, 0, 0, "ISO 13818-6 Sections"), - st(0x0e, N, 0, 0, "ISO 13818-1 auxiliary"), - st(0x0f, A, HB_ACODEC_FFAAC, CODEC_ID_AAC, "AAC"), - st(0x10, V, WORK_DECAVCODECV, CODEC_ID_MPEG4, "MPEG4"), - st(0x11, A, HB_ACODEC_FFMPEG, CODEC_ID_AAC_LATM, "LATM AAC"), - st(0x12, U, 0, 0, "MPEG4 generic"), - - st(0x14, N, 0, 0, "ISO 13818-6 DSM-CC download"), - - st(0x1b, V, WORK_DECAVCODECV, CODEC_ID_H264, "H.264"), - - st(0x80, U, HB_ACODEC_FFMPEG, CODEC_ID_PCM_BLURAY, "Digicipher II Video"), - st(0x81, A, HB_ACODEC_AC3, 0, "AC3"), - st(0x82, A, HB_ACODEC_DCA, CODEC_ID_DTS, "DTS"), + st(0x00, U, 0, 0, NULL), + st(0x01, V, WORK_DECMPEG2, 0, "MPEG1"), + st(0x02, V, WORK_DECMPEG2, 0, "MPEG2"), + st(0x03, A, HB_ACODEC_FFMPEG, AV_CODEC_ID_MP2, "MPEG1"), + st(0x04, A, HB_ACODEC_FFMPEG, AV_CODEC_ID_MP2, "MPEG2"), + st(0x05, N, 0, 0, "ISO 13818-1 private section"), + st(0x06, U, 0, 0, "ISO 13818-1 PES private data"), + st(0x07, N, 0, 0, "ISO 13522 MHEG"), + st(0x08, N, 0, 0, "ISO 13818-1 DSM-CC"), + st(0x09, N, 0, 0, "ISO 13818-1 auxiliary"), + st(0x0a, N, 0, 0, "ISO 13818-6 encap"), + st(0x0b, N, 0, 0, "ISO 13818-6 DSM-CC U-N msgs"), + st(0x0c, N, 0, 0, "ISO 13818-6 Stream descriptors"), + st(0x0d, N, 0, 0, "ISO 13818-6 Sections"), + st(0x0e, N, 0, 0, "ISO 13818-1 auxiliary"), + st(0x0f, A, HB_ACODEC_FFAAC, AV_CODEC_ID_AAC, "AAC"), + st(0x10, V, WORK_DECAVCODECV, AV_CODEC_ID_MPEG4, "MPEG4"), + st(0x11, A, HB_ACODEC_FFMPEG, AV_CODEC_ID_AAC_LATM, "LATM AAC"), + st(0x12, U, 0, 0, "MPEG4 generic"), + + st(0x14, N, 0, 0, "ISO 13818-6 DSM-CC download"), + + st(0x1b, V, WORK_DECAVCODECV, AV_CODEC_ID_H264, "H.264"), + + st(0x80, U, HB_ACODEC_FFMPEG, AV_CODEC_ID_PCM_BLURAY, "Digicipher II Video"), + st(0x81, A, HB_ACODEC_AC3, 0, "AC3"), + st(0x82, A, HB_ACODEC_DCA, AV_CODEC_ID_DTS, "DTS"), // 0x83 can be LPCM or BD TrueHD. Set to 'unknown' till we know more. - st(0x83, U, HB_ACODEC_LPCM, 0, "LPCM"), + st(0x83, U, HB_ACODEC_LPCM, 0, "LPCM"), // BD E-AC3 Primary audio - st(0x84, U, 0, 0, "SDDS"), - st(0x85, U, 0, 0, "ATSC Program ID"), + st(0x84, U, 0, 0, "SDDS"), + st(0x85, U, 0, 0, "ATSC Program ID"), // 0x86 can be BD DTS-HD/DTS. Set to 'unknown' till we know more. - st(0x86, U, HB_ACODEC_DCA_HD, CODEC_ID_DTS, "DTS-HD MA"), - st(0x87, A, HB_ACODEC_FFMPEG, CODEC_ID_EAC3, "E-AC3"), + st(0x86, U, HB_ACODEC_DCA_HD, AV_CODEC_ID_DTS, "DTS-HD MA"), + st(0x87, A, HB_ACODEC_FFMPEG, AV_CODEC_ID_EAC3, "E-AC3"), - st(0x8a, A, HB_ACODEC_DCA, CODEC_ID_DTS, "DTS"), + st(0x8a, A, HB_ACODEC_DCA, AV_CODEC_ID_DTS, "DTS"), - st(0x90, S, WORK_DECPGSSUB, 0, "PGS Subtitle"), + st(0x90, S, WORK_DECPGSSUB, 0, "PGS Subtitle"), // 0x91 can be AC3 or BD Interactive Graphics Stream. - st(0x91, U, 0, 0, "AC3/IGS"), - st(0x92, N, 0, 0, "Subtitle"), + st(0x91, U, 0, 0, "AC3/IGS"), + st(0x92, N, 0, 0, "Subtitle"), - st(0x94, U, 0, 0, "SDDS"), - st(0xa0, V, 0, 0, "MSCODEC"), + st(0x94, U, 0, 0, "SDDS"), + st(0xa0, V, 0, 0, "MSCODEC"), // BD E-AC3 Secondary audio - st(0xa1, U, 0, 0, "E-AC3"), + st(0xa1, U, 0, 0, "E-AC3"), // BD DTS-HD Secondary audio - st(0xa2, U, 0, 0, "DTS-HD LBR"), + st(0xa2, U, 0, 0, "DTS-HD LBR"), - st(0xea, V, WORK_DECAVCODECV, CODEC_ID_VC1, "VC-1"), + st(0xea, V, WORK_DECAVCODECV, AV_CODEC_ID_VC1, "VC-1"), }; #undef st @@ -1244,8 +1244,8 @@ static int isIframe( hb_stream_t *stream, const uint8_t *buf, int len ) int vid = pes_index_of_video( stream ); hb_pes_stream_t *pes = &stream->pes.list[vid]; if ( pes->stream_type <= 2 || - pes->codec_param == CODEC_ID_MPEG1VIDEO || - pes->codec_param == CODEC_ID_MPEG2VIDEO ) + pes->codec_param == AV_CODEC_ID_MPEG1VIDEO || + pes->codec_param == AV_CODEC_ID_MPEG2VIDEO ) { // This section of the code handles MPEG-1 and MPEG-2 video streams for (ii = 0; ii < len; ii++) @@ -1279,7 +1279,7 @@ static int isIframe( hb_stream_t *stream, const uint8_t *buf, int len ) // didn't find an I-frame return 0; } - if ( pes->stream_type == 0x1b || pes->codec_param == CODEC_ID_H264 ) + if ( pes->stream_type == 0x1b || pes->codec_param == AV_CODEC_ID_H264 ) { // we have an h.264 stream for (ii = 0; ii < len; ii++) @@ -1313,7 +1313,7 @@ static int isIframe( hb_stream_t *stream, const uint8_t *buf, int len ) // didn't find an I-frame return 0; } - if ( pes->stream_type == 0xea || pes->codec_param == CODEC_ID_VC1 ) + if ( pes->stream_type == 0xea || pes->codec_param == AV_CODEC_ID_VC1 ) { // we have an vc1 stream for (ii = 0; ii < len; ii++) @@ -2047,11 +2047,12 @@ static void set_audio_description( } else if (audio->config.in.channel_layout) { - int lfe = !!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY); + int lfes = (!!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY) + + !!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY_2)); int channels = av_get_channel_layout_nb_channels(audio->config.in.channel_layout); char *desc = audio->config.lang.description + strlen(audio->config.lang.description); - sprintf(desc, " (%d.%d ch)", channels - lfe, lfe); + sprintf(desc, " (%d.%d ch)", channels - lfes, lfes); } } @@ -3955,7 +3956,7 @@ static void hb_ps_stream_find_streams(hb_stream_t *stream) int idx = update_ps_streams( stream, pes_info.stream_id, pes_info.bd_substream_id, 0, U ); stream->pes.list[idx].codec = HB_ACODEC_DCA_HD; - stream->pes.list[idx].codec_param = CODEC_ID_DTS; + stream->pes.list[idx].codec_param = AV_CODEC_ID_DTS; continue; } else if ( ssid >= 0xa0 && ssid <= 0xaf ) @@ -3974,7 +3975,7 @@ static void hb_ps_stream_find_streams(hb_stream_t *stream) int idx = update_ps_streams( stream, pes_info.stream_id, pes_info.bd_substream_id, 0, A ); stream->pes.list[idx].codec = HB_ACODEC_FFMPEG; - stream->pes.list[idx].codec_param = CODEC_ID_TRUEHD; + stream->pes.list[idx].codec_param = AV_CODEC_ID_TRUEHD; continue; } else if ( ssid >= 0xc0 && ssid <= 0xcf ) @@ -4140,28 +4141,32 @@ static int do_probe( hb_pes_stream_t *pes, hb_buffer_t *buf ) if( !codec ) { int i; - static const struct { - const char *name; enum CodecID id; - } fmt_id_type[] = { - { "g722" , CODEC_ID_ADPCM_G722 }, - { "mlp" , CODEC_ID_MLP }, - { "truehd" , CODEC_ID_TRUEHD }, - { "shn" , CODEC_ID_SHORTEN }, - { "aac" , CODEC_ID_AAC }, - { "ac3" , CODEC_ID_AC3 }, - { "dts" , CODEC_ID_DTS }, - { "eac3" , CODEC_ID_EAC3 }, - { "h264" , CODEC_ID_H264 }, - { "m4v" , CODEC_ID_MPEG4 }, - { "mp3" , CODEC_ID_MP3 }, - { "mpegvideo", CODEC_ID_MPEG2VIDEO }, - { "cavsvideo", CODEC_ID_CAVS }, - { "dnxhd" , CODEC_ID_DNXHD }, - { "h261" , CODEC_ID_H261 }, - { "h263" , CODEC_ID_H263 }, - { "mjpeg" , CODEC_ID_MJPEG }, - { "vc1" , CODEC_ID_VC1 }, - { 0 } + static const struct + { + const char *name; + enum AVCodecID id; + } + fmt_id_type[] = + { + { "g722" , AV_CODEC_ID_ADPCM_G722 }, + { "mlp" , AV_CODEC_ID_MLP }, + { "truehd" , AV_CODEC_ID_TRUEHD }, + { "shn" , AV_CODEC_ID_SHORTEN }, + { "aac" , AV_CODEC_ID_AAC }, + { "ac3" , AV_CODEC_ID_AC3 }, + { "dts" , AV_CODEC_ID_DTS }, + { "eac3" , AV_CODEC_ID_EAC3 }, + { "h264" , AV_CODEC_ID_H264 }, + { "m4v" , AV_CODEC_ID_MPEG4 }, + { "mp3" , AV_CODEC_ID_MP3 }, + { "mpegvideo", AV_CODEC_ID_MPEG2VIDEO }, + { "cavsvideo", AV_CODEC_ID_CAVS }, + { "dnxhd" , AV_CODEC_ID_DNXHD }, + { "h261" , AV_CODEC_ID_H261 }, + { "h263" , AV_CODEC_ID_H263 }, + { "mjpeg" , AV_CODEC_ID_MJPEG }, + { "vc1" , AV_CODEC_ID_VC1 }, + { 0 }, }; for( i = 0; fmt_id_type[i].name; i++ ) { @@ -4180,22 +4185,22 @@ static int do_probe( hb_pes_stream_t *pes, hb_buffer_t *buf ) pes->stream_kind = V; switch ( codec->id ) { - case CODEC_ID_MPEG1VIDEO: + case AV_CODEC_ID_MPEG1VIDEO: pes->codec = WORK_DECMPEG2; pes->stream_type = 0x01; break; - case CODEC_ID_MPEG2VIDEO: + case AV_CODEC_ID_MPEG2VIDEO: pes->codec = WORK_DECMPEG2; pes->stream_type = 0x02; break; - case CODEC_ID_H264: + case AV_CODEC_ID_H264: pes->codec = WORK_DECAVCODECV; pes->stream_type = 0x1b; break; - case CODEC_ID_VC1: + case AV_CODEC_ID_VC1: pes->codec = WORK_DECAVCODECV; pes->stream_type = 0xea; break; @@ -4209,7 +4214,7 @@ static int do_probe( hb_pes_stream_t *pes, hb_buffer_t *buf ) pes->stream_kind = A; switch ( codec->id ) { - case CODEC_ID_AC3: + case AV_CODEC_ID_AC3: pes->codec = HB_ACODEC_AC3; break; default: @@ -4251,7 +4256,7 @@ static void hb_ts_resolve_pid_types(hb_stream_t *stream) // To distinguish, Bluray streams have a reg_desc of HDMV update_ts_streams( stream, pid, 0, stype, A, &pes_idx ); stream->pes.list[pes_idx].codec = HB_ACODEC_FFMPEG; - stream->pes.list[pes_idx].codec_param = CODEC_ID_PCM_BLURAY; + stream->pes.list[pes_idx].codec_param = AV_CODEC_ID_PCM_BLURAY; continue; } @@ -4273,7 +4278,7 @@ static void hb_ts_resolve_pid_types(hb_stream_t *stream) update_ts_streams( stream, pid, HB_SUBSTREAM_BD_TRUEHD, stype, A, &pes_idx ); stream->pes.list[pes_idx].codec = HB_ACODEC_FFMPEG; - stream->pes.list[pes_idx].codec_param = CODEC_ID_TRUEHD; + stream->pes.list[pes_idx].codec_param = AV_CODEC_ID_TRUEHD; continue; } if ( ( stype == 0x84 || stype == 0xa1 ) && @@ -4284,7 +4289,7 @@ static void hb_ts_resolve_pid_types(hb_stream_t *stream) // To distinguish, Bluray streams have a reg_desc of HDMV update_ts_streams( stream, pid, 0, stype, A, &pes_idx ); stream->pes.list[pes_idx].codec = HB_ACODEC_FFMPEG; - stream->pes.list[pes_idx].codec_param = CODEC_ID_EAC3; + stream->pes.list[pes_idx].codec_param = AV_CODEC_ID_EAC3; continue; } // 0xa2 is DTS-HD LBR used in HD-DVD and bluray for @@ -4303,11 +4308,11 @@ static void hb_ts_resolve_pid_types(hb_stream_t *stream) update_ts_streams( stream, pid, HB_SUBSTREAM_BD_DTS, stype, A, &pes_idx ); stream->pes.list[pes_idx].codec = HB_ACODEC_DCA; - stream->pes.list[pes_idx].codec_param = CODEC_ID_DTS; + stream->pes.list[pes_idx].codec_param = AV_CODEC_ID_DTS; update_ts_streams( stream, pid, 0, stype, A, &pes_idx ); stream->pes.list[pes_idx].codec = HB_ACODEC_DCA_HD; - stream->pes.list[pes_idx].codec_param = CODEC_ID_DTS; + stream->pes.list[pes_idx].codec_param = AV_CODEC_ID_DTS; continue; } if ( stype == 0x86 && @@ -4318,11 +4323,11 @@ static void hb_ts_resolve_pid_types(hb_stream_t *stream) update_ts_streams( stream, pid, HB_SUBSTREAM_BD_DTS, stype, A, &pes_idx ); stream->pes.list[pes_idx].codec = HB_ACODEC_DCA; - stream->pes.list[pes_idx].codec_param = CODEC_ID_DTS; + stream->pes.list[pes_idx].codec_param = AV_CODEC_ID_DTS; update_ts_streams( stream, pid, 0, stype, A, &pes_idx ); stream->pes.list[pes_idx].codec = HB_ACODEC_DCA_HD; - stream->pes.list[pes_idx].codec_param = CODEC_ID_DTS; + stream->pes.list[pes_idx].codec_param = AV_CODEC_ID_DTS; continue; } @@ -5105,7 +5110,7 @@ static void ffmpeg_close( hb_stream_t *d ) } } -static void add_ffmpeg_audio( hb_title_t *title, hb_stream_t *stream, int id ) +static void add_ffmpeg_audio(hb_title_t *title, hb_stream_t *stream, int id) { AVStream *st = stream->ffmpeg_ic->streams[id]; AVCodecContext *codec = st->codec; @@ -5113,38 +5118,44 @@ static void add_ffmpeg_audio( hb_title_t *title, hb_stream_t *stream, int id ) // scan will ignore any audio without a bitrate. Since we've already typed the // audio in order to determine its codec we set up the audio parameters here. - if ( codec->bit_rate || codec->sample_rate ) + if (codec->bit_rate || codec->sample_rate) { - hb_audio_t *audio = calloc( 1, sizeof(*audio) );; - + hb_audio_t *audio = calloc(1, sizeof(*audio)); audio->id = id; - if ( codec->codec_id == CODEC_ID_AC3 ) + + if (codec->codec_id == AV_CODEC_ID_AC3) { audio->config.in.codec = HB_ACODEC_AC3; } else { - if ( codec->codec_id == CODEC_ID_DTS && - ( codec->profile == FF_PROFILE_DTS || - codec->profile == FF_PROFILE_DTS_ES || - codec->profile == FF_PROFILE_DTS_96_24 ) ) + if (codec->codec_id == AV_CODEC_ID_DTS) { - audio->config.in.codec = HB_ACODEC_DCA; - } - else if ( codec->codec_id == CODEC_ID_DTS && - ( codec->profile == FF_PROFILE_DTS_HD_MA || - codec->profile == FF_PROFILE_DTS_HD_HRA ) ) - { - audio->config.in.codec = HB_ACODEC_DCA_HD; + if (codec->profile == FF_PROFILE_DTS_HD_MA || + codec->profile == FF_PROFILE_DTS_HD_HRA) + { + audio->config.in.codec = HB_ACODEC_DCA_HD; + } + else if (codec->profile == FF_PROFILE_DTS || + codec->profile == FF_PROFILE_DTS_ES || + codec->profile == FF_PROFILE_DTS_96_24) + { + audio->config.in.codec = HB_ACODEC_DCA; + } + else + { + audio->config.in.codec = HB_ACODEC_FFMPEG; + } } - else if ( codec->codec_id == CODEC_ID_AAC ) + else if (codec->codec_id == AV_CODEC_ID_AAC) { int len = MIN(codec->extradata_size, HB_CONFIG_MAX_SIZE); - memcpy(audio->priv.config.extradata.bytes, codec->extradata, len); + memcpy(audio->priv.config.extradata.bytes, codec->extradata, + len); audio->priv.config.extradata.length = len; audio->config.in.codec = HB_ACODEC_FFAAC; } - else if ( codec->codec_id == CODEC_ID_MP3 ) + else if (codec->codec_id == AV_CODEC_ID_MP3) { audio->config.in.codec = HB_ACODEC_MP3; } @@ -5155,24 +5166,32 @@ static void add_ffmpeg_audio( hb_title_t *title, hb_stream_t *stream, int id ) audio->config.in.codec_param = codec->codec_id; int bps = av_get_bits_per_sample(codec->codec_id); - if( bps && codec->sample_rate && codec->channels ) - audio->config.in.bitrate = bps * codec->sample_rate * codec->channels; - else if( codec->bit_rate ) + if (bps && codec->sample_rate && codec->channels) + { + audio->config.in.bitrate = (codec->channels * + codec->sample_rate * bps); + } + else if (codec->bit_rate) + { audio->config.in.bitrate = codec->bit_rate; + } else + { audio->config.in.bitrate = 1; + } audio->config.in.samplerate = codec->sample_rate; audio->config.in.samples_per_frame = codec->frame_size; audio->config.in.channel_map = &hb_libav_chan_map; - audio->config.in.channel_layout = hb_ff_layout_xlat(codec->channel_layout, - codec->channels); + audio->config.in.channel_layout = + hb_ff_layout_xlat(codec->channel_layout, codec->channels); } - tag = av_dict_get( st->metadata, "language", NULL, 0 ); - set_audio_description( stream, audio, lang_for_code2( tag ? tag->value : "und" ) ); + tag = av_dict_get(st->metadata, "language", NULL, 0); + set_audio_description(stream, audio, + lang_for_code2(tag ? tag->value : "und")); audio->config.in.track = id; - hb_list_add( title->list_audio, audio ); + hb_list_add(title->list_audio, audio); } } @@ -5311,7 +5330,7 @@ static void add_ffmpeg_subtitle( hb_title_t *title, hb_stream_t *stream, int id switch ( codec->codec_id ) { - case CODEC_ID_DVD_SUBTITLE: + case AV_CODEC_ID_DVD_SUBTITLE: subtitle->format = PICTURESUB; subtitle->source = VOBSUB; subtitle->config.dest = RENDERSUB; // By default render (burn-in) the VOBSUB. @@ -5320,25 +5339,25 @@ static void add_ffmpeg_subtitle( hb_title_t *title, hb_stream_t *stream, int id hb_log( "add_ffmpeg_subtitle: malformed extradata for VOB subtitle track; " "subtitle colors likely to be wrong" ); break; - case CODEC_ID_TEXT: + case AV_CODEC_ID_TEXT: subtitle->format = TEXTSUB; subtitle->source = UTF8SUB; subtitle->config.dest = PASSTHRUSUB; subtitle->codec = WORK_DECUTF8SUB; break; - case CODEC_ID_MOV_TEXT: // TX3G + case AV_CODEC_ID_MOV_TEXT: // TX3G subtitle->format = TEXTSUB; subtitle->source = TX3GSUB; subtitle->config.dest = PASSTHRUSUB; subtitle->codec = WORK_DECTX3GSUB; break; - case CODEC_ID_SSA: + case AV_CODEC_ID_SSA: subtitle->format = TEXTSUB; subtitle->source = SSASUB; subtitle->config.dest = PASSTHRUSUB; subtitle->codec = WORK_DECSSASUB; break; - case CODEC_ID_HDMV_PGS_SUBTITLE: + case AV_CODEC_ID_HDMV_PGS_SUBTITLE: subtitle->format = PICTURESUB; subtitle->source = PGSSUB; subtitle->config.dest = RENDERSUB; @@ -5390,7 +5409,7 @@ static void add_ffmpeg_attachment( hb_title_t *title, hb_stream_t *stream, int i const char *name = get_ffmpeg_metadata_value( st->metadata, "filename" ); switch ( codec->codec_id ) { - case CODEC_ID_TTF: + case AV_CODEC_ID_TTF: // Libav sets codec ID based on mime type of the attachment type = FONT_TTF_ATTACH; break; @@ -5517,7 +5536,7 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream, hb_title_t *title ) title->video_codec == 0 ) { AVCodecContext *context = ic->streams[i]->codec; - if ( context->pix_fmt != PIX_FMT_YUV420P && + if ( context->pix_fmt != AV_PIX_FMT_YUV420P && !sws_isSupportedInput( context->pix_fmt ) ) { hb_log( "ffmpeg_title_scan: Unsupported color space" ); @@ -5532,7 +5551,7 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream, hb_title_t *title ) title->pixel_aspect_height = ic->streams[i]->sample_aspect_ratio.den; } - if ( context->codec_id == CODEC_ID_H264 ) + if ( context->codec_id == AV_CODEC_ID_H264 ) title->flags |= HBTF_NO_IDR; title->video_codec = WORK_DECAVCODECV; @@ -5640,7 +5659,7 @@ static int ffmpeg_is_keyframe( hb_stream_t *stream ) switch ( stream->ffmpeg_ic->streams[stream->ffmpeg_video_id]->codec->codec_id ) { - case CODEC_ID_VC1: + case AV_CODEC_ID_VC1: // XXX the VC1 codec doesn't mark key frames so to get previews // we do it ourselves here. The decoder gets messed up if it // doesn't get a SEQ header first so we consider that to be a key frame. @@ -5650,7 +5669,7 @@ static int ffmpeg_is_keyframe( hb_stream_t *stream ) return 0; - case CODEC_ID_WMV3: + case AV_CODEC_ID_WMV3: // XXX the ffmpeg WMV3 codec doesn't mark key frames. // Only M$ could make I-frame detection this complicated: there // are two to four bits of unused junk ahead of the frame type @@ -5764,20 +5783,20 @@ hb_buffer_t * hb_ffmpeg_read( hb_stream_t *stream ) /* * Fill out buf->s.stop for subtitle packets * - * libavcodec's MKV demuxer stores the duration of UTF-8 subtitles (CODEC_ID_TEXT) + * libavcodec's MKV demuxer stores the duration of UTF-8 subtitles (AV_CODEC_ID_TEXT) * in the 'convergence_duration' field for some reason. * * Other subtitles' durations are stored in the 'duration' field. * - * VOB subtitles (CODEC_ID_DVD_SUBTITLE) do not have their duration stored in + * VOB subtitles (AV_CODEC_ID_DVD_SUBTITLE) do not have their duration stored in * either field. This is not a problem because the VOB decoder can extract this * information from the packet payload itself. * - * SSA subtitles (CODEC_ID_SSA) do not have their duration stored in + * SSA subtitles (AV_CODEC_ID_SSA) do not have their duration stored in * either field. This is not a problem because the SSA decoder can extract this * information from the packet payload itself. */ - enum CodecID ffmpeg_pkt_codec; + enum AVCodecID ffmpeg_pkt_codec; enum AVMediaType codec_type; ffmpeg_pkt_codec = stream->ffmpeg_ic->streams[stream->ffmpeg_pkt->stream_index]->codec->codec_id; codec_type = stream->ffmpeg_ic->streams[stream->ffmpeg_pkt->stream_index]->codec->codec_type; @@ -5807,12 +5826,12 @@ hb_buffer_t * hb_ffmpeg_read( hb_stream_t *stream ) buf->s.type = OTHER_BUF; break; } - if ( ffmpeg_pkt_codec == CODEC_ID_TEXT ) { + if ( ffmpeg_pkt_codec == AV_CODEC_ID_TEXT ) { int64_t ffmpeg_pkt_duration = stream->ffmpeg_pkt->convergence_duration; int64_t buf_duration = av_to_hb_pts( ffmpeg_pkt_duration, tsconv ); buf->s.stop = buf->s.start + buf_duration; } - if ( ffmpeg_pkt_codec == CODEC_ID_MOV_TEXT ) { + if ( ffmpeg_pkt_codec == AV_CODEC_ID_MOV_TEXT ) { int64_t ffmpeg_pkt_duration = stream->ffmpeg_pkt->duration; int64_t buf_duration = av_to_hb_pts( ffmpeg_pkt_duration, tsconv ); buf->s.stop = buf->s.start + buf_duration; diff --git a/libhb/sync.c b/libhb/sync.c index 592ebb8c3..5ad5bfedb 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -950,15 +950,11 @@ static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i ) { case HB_ACODEC_AC3_PASS: { - codec = avcodec_find_encoder( CODEC_ID_AC3 ); + codec = avcodec_find_encoder( AV_CODEC_ID_AC3 ); } break; case HB_ACODEC_AAC_PASS: { - codec = avcodec_find_encoder( CODEC_ID_AAC ); - } break; - case HB_ACODEC_MP3_PASS: - { - codec = avcodec_find_encoder( CODEC_ID_MP3 ); + codec = avcodec_find_encoder( AV_CODEC_ID_AAC ); } break; default: { @@ -990,16 +986,13 @@ static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i ) } // Prepare input frame - AVFrame frame; - uint8_t * zeros; - - frame.nb_samples= c->frame_size; + AVFrame frame = { .nb_samples = c->frame_size, .pts = 0, }; int input_size = av_samples_get_buffer_size(NULL, c->channels, - frame.nb_samples, c->sample_fmt, 1); - zeros = calloc( 1, input_size ); - avcodec_fill_audio_frame(&frame, c->channels, - c->sample_fmt, zeros, input_size, 1); - frame.pts = 0; + frame.nb_samples, + c->sample_fmt, 1); + uint8_t *zeros = calloc(1, input_size); + avcodec_fill_audio_frame(&frame, c->channels, c->sample_fmt, zeros, + input_size, 1); // Allocate enough space for the encoded silence // The output should be < the input diff --git a/libhb/work.c b/libhb/work.c index 030920c59..c6ddd9472 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -140,19 +140,19 @@ hb_work_object_t * hb_codec_encoder( int codec ) case HB_ACODEC_FFAAC: { w = hb_get_work( WORK_ENCAVCODEC_AUDIO ); - w->codec_param = CODEC_ID_AAC; + w->codec_param = AV_CODEC_ID_AAC; return w; } case HB_ACODEC_FFFLAC: { w = hb_get_work( WORK_ENCAVCODEC_AUDIO ); - w->codec_param = CODEC_ID_FLAC; + w->codec_param = AV_CODEC_ID_FLAC; return w; } case HB_ACODEC_AC3: { w = hb_get_work( WORK_ENCAVCODEC_AUDIO ); - w->codec_param = CODEC_ID_AC3; + w->codec_param = AV_CODEC_ID_AC3; return w; } } @@ -696,7 +696,7 @@ static void do_job( hb_job_t * job ) hb_filter_init_t init; init.job = job; - init.pix_fmt = PIX_FMT_YUV420P; + init.pix_fmt = AV_PIX_FMT_YUV420P; init.width = title->width; init.height = title->height; init.par_width = job->anamorphic.par_width; @@ -995,7 +995,7 @@ static void do_job( hb_job_t * job ) if (vcodec == WORK_DECMPEG2) { vcodec = WORK_DECAVCODECV; - title->video_codec_param = CODEC_ID_MPEG2VIDEO; + title->video_codec_param = AV_CODEC_ID_MPEG2VIDEO; } #endif hb_list_add( job->list_work, ( w = hb_get_work( vcodec ) ) ); @@ -1060,11 +1060,11 @@ static void do_job( hb_job_t * job ) { case HB_VCODEC_FFMPEG_MPEG4: w = hb_get_work( WORK_ENCAVCODEC ); - w->codec_param = CODEC_ID_MPEG4; + w->codec_param = AV_CODEC_ID_MPEG4; break; case HB_VCODEC_FFMPEG_MPEG2: w = hb_get_work( WORK_ENCAVCODEC ); - w->codec_param = CODEC_ID_MPEG2VIDEO; + w->codec_param = AV_CODEC_ID_MPEG2VIDEO; break; case HB_VCODEC_X264: w = hb_get_work( WORK_ENCX264 ); |