summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-10-15 21:32:20 +0000
committerjstebbins <[email protected]>2011-10-15 21:32:20 +0000
commit0646bd60a8f672a003195e1c83ebbcb08d05aa99 (patch)
tree7a0655dddf26d2a5463f6ea59a0e6e802119e867
parente3cbf2a342b7093d0b0b1720d3b3c933c3a4fa69 (diff)
bump Libav from v0.7.1 to v0.7-1241-g5f3fb59
Fixes VC-1 decode issue Adds partial support for interlaced VC-1 decode Adds ProRes decoder Fixes ac3 encoder dolby flag Fixes DCA frame size setting (delete patch A04) Fixes VC-1 repeat field processing (delete patch A05) Numerous other bug fixes and enhancements git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4291 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--contrib/ffmpeg/A01-mpegleak.patch14
-rw-r--r--contrib/ffmpeg/A02-audioconvert.patch4
-rw-r--r--contrib/ffmpeg/A03-png-sequences.patch2
-rw-r--r--contrib/ffmpeg/A04-channel-layout-order.patch86
-rw-r--r--contrib/ffmpeg/A04-dca-frame-size.patch12
-rw-r--r--contrib/ffmpeg/A05-vc1-pulldown.patch96
-rw-r--r--contrib/ffmpeg/A06-h264-recovery-point.patch18
-rw-r--r--contrib/ffmpeg/P01-solaris.patch4
-rw-r--r--contrib/ffmpeg/P02-darwin-pic.patch8
-rw-r--r--contrib/ffmpeg/module.defs7
-rw-r--r--libhb/common.c1
-rw-r--r--libhb/decavcodec.c15
-rw-r--r--libhb/encavcodec.c23
-rw-r--r--libhb/encavcodecaudio.c21
-rw-r--r--libhb/hb.c41
-rw-r--r--libhb/hbffmpeg.h4
-rw-r--r--libhb/mcdeint.c5
-rw-r--r--libhb/stream.c2
-rw-r--r--libhb/sync.c2
19 files changed, 173 insertions, 192 deletions
diff --git a/contrib/ffmpeg/A01-mpegleak.patch b/contrib/ffmpeg/A01-mpegleak.patch
index 555be9228..214e9caf9 100644
--- a/contrib/ffmpeg/A01-mpegleak.patch
+++ b/contrib/ffmpeg/A01-mpegleak.patch
@@ -1,8 +1,8 @@
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
-index 2c000a3..93850d6 100644
+index 9889224..041fccf 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
-@@ -3908,7 +3908,7 @@ static int decode_frame(AVCodecContext *avctx,
+@@ -3848,7 +3848,7 @@ static int decode_frame(AVCodecContext *avctx,
if(!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr){
if (avctx->skip_frame >= AVDISCARD_NONREF)
return 0;
@@ -12,10 +12,10 @@ index 2c000a3..93850d6 100644
}
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
-index a025f7d..eda5e41 100644
+index 1f30916..dce88f3 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
-@@ -628,7 +628,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
+@@ -634,7 +634,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
* stream. Need to discard one frame. Prevents overrun of the
* short_ref and long_ref buffers.
*/
@@ -25,10 +25,10 @@ index a025f7d..eda5e41 100644
"corrupt input), discarding one\n",
h->long_ref_count, h->short_ref_count, h->sps.ref_frame_count);
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
-index 4978d28..bb9509f 100644
+index e418e95..87cb73c 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
-@@ -986,19 +986,18 @@ int ff_find_unused_picture(MpegEncContext *s, int shared){
+@@ -1004,19 +1004,18 @@ int ff_find_unused_picture(MpegEncContext *s, int shared){
}
av_log(s->avctx, AV_LOG_FATAL, "Internal error, picture buffer overflow\n");
@@ -52,7 +52,7 @@ index 4978d28..bb9509f 100644
+ * the oldest we have & reusing its slot. */
+ int oldest=0;
+ for(i=0; i<MAX_PICTURE_COUNT; i++){
-+ if (s->picture[i].coded_picture_number < s->picture[oldest].coded_picture_number)
++ if (s->picture[i].f.coded_picture_number < s->picture[oldest].f.coded_picture_number)
+ oldest = i;
+ }
+ s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[oldest]);
diff --git a/contrib/ffmpeg/A02-audioconvert.patch b/contrib/ffmpeg/A02-audioconvert.patch
index f8481240b..5248a9fd3 100644
--- a/contrib/ffmpeg/A02-audioconvert.patch
+++ b/contrib/ffmpeg/A02-audioconvert.patch
@@ -1,8 +1,8 @@
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
-index 0cfa08c..f9c407e 100644
+index 3c4e2f8..fe84b8c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
-@@ -3,7 +3,7 @@ include $(SUBDIR)../config.mak
+@@ -1,7 +1,7 @@
NAME = avcodec
FFLIBS = avutil
diff --git a/contrib/ffmpeg/A03-png-sequences.patch b/contrib/ffmpeg/A03-png-sequences.patch
index 5be83fbb4..66fe1f7c3 100644
--- a/contrib/ffmpeg/A03-png-sequences.patch
+++ b/contrib/ffmpeg/A03-png-sequences.patch
@@ -1,5 +1,5 @@
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
-index 7477f67..9e8e29b 100644
+index a40cebb..26239e2 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -599,6 +599,18 @@ static int decode_frame(AVCodecContext *avctx,
diff --git a/contrib/ffmpeg/A04-channel-layout-order.patch b/contrib/ffmpeg/A04-channel-layout-order.patch
new file mode 100644
index 000000000..99faa5ddc
--- /dev/null
+++ b/contrib/ffmpeg/A04-channel-layout-order.patch
@@ -0,0 +1,86 @@
+diff --git a/libavcodec/Makefile b/libavcodec/Makefile
+index 3c4e2f8..5cfd1bf 100644
+--- a/libavcodec/Makefile
++++ b/libavcodec/Makefile
+@@ -142,7 +142,7 @@ OBJS-$(CONFIG_FFV1_DECODER) += ffv1.o rangecoder.o
+ OBJS-$(CONFIG_FFV1_ENCODER) += ffv1.o rangecoder.o
+ OBJS-$(CONFIG_FFVHUFF_DECODER) += huffyuv.o
+ OBJS-$(CONFIG_FFVHUFF_ENCODER) += huffyuv.o
+-OBJS-$(CONFIG_FLAC_DECODER) += flacdec.o flacdata.o flac.o
++OBJS-$(CONFIG_FLAC_DECODER) += flacdec.o flacdata.o flac.o vorbis_data.o
+ OBJS-$(CONFIG_FLAC_ENCODER) += flacenc.o flacdata.o flac.o
+ OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o
+ OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o
+diff --git a/libavcodec/flac.c b/libavcodec/flac.c
+index e6a427a..397155e 100644
+--- a/libavcodec/flac.c
++++ b/libavcodec/flac.c
+@@ -22,6 +22,7 @@
+ #include "libavutil/crc.h"
+ #include "flac.h"
+ #include "flacdata.h"
++#include "vorbis.h"
+
+ static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 };
+
+@@ -54,9 +55,12 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
+ fi->ch_mode = get_bits(gb, 4);
+ if (fi->ch_mode < FLAC_MAX_CHANNELS) {
+ fi->channels = fi->ch_mode + 1;
++ if (fi->ch_mode <= 5)
++ avctx->channel_layout = ff_vorbis_channel_layouts[fi->ch_mode];
+ fi->ch_mode = FLAC_CHMODE_INDEPENDENT;
+ } else if (fi->ch_mode <= FLAC_CHMODE_MID_SIDE) {
+ fi->channels = 2;
++ avctx->channel_layout = AV_CH_LAYOUT_STEREO;
+ } else {
+ av_log(avctx, AV_LOG_ERROR + log_level_offset,
+ "invalid channel mode: %d\n", fi->ch_mode);
+diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
+index c90285a..58235c8 100644
+--- a/libavcodec/mlpdec.c
++++ b/libavcodec/mlpdec.c
+@@ -133,6 +133,9 @@ typedef struct MLPDecodeContext {
+ //! Index of the last substream to decode - further substreams are skipped.
+ uint8_t max_decoded_substream;
+
++ //! Stream needs channel reordering to comply with FFmpeg's channel order
++ uint8_t needs_reordering;
++
+ //! number of PCM samples contained in each frame
+ int access_unit_size;
+ //! next power of two above the number of samples in each frame
+@@ -326,6 +329,8 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
+ for (substr = 0; substr < MAX_SUBSTREAMS; substr++)
+ m->substream[substr].restart_seen = 0;
+
++ m->needs_reordering = mh.channels_mlp >= 18 && mh.channels_mlp <= 20;
++
+ return 0;
+ }
+
+@@ -436,6 +441,24 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
+ s->ch_assign[ch_assign] = ch;
+ }
+
++ if (m->avctx->codec_id == CODEC_ID_MLP && m->needs_reordering) {
++ if (m->avctx->channel_layout == (AV_CH_LAYOUT_2_2|AV_CH_LOW_FREQUENCY) ||
++ m->avctx->channel_layout == AV_CH_LAYOUT_5POINT0) {
++ int i = s->ch_assign[4];
++ s->ch_assign[4] = s->ch_assign[3];
++ s->ch_assign[3] = s->ch_assign[2];
++ s->ch_assign[2] = i;
++ } else if (m->avctx->channel_layout == AV_CH_LAYOUT_5POINT1) {
++ FFSWAP(int, s->ch_assign[2], s->ch_assign[4]);
++ FFSWAP(int, s->ch_assign[3], s->ch_assign[5]);
++ }
++ }
++ if (m->avctx->codec_id == CODEC_ID_TRUEHD &&
++ m->avctx->channel_layout == AV_CH_LAYOUT_7POINT1) {
++ FFSWAP(int, s->ch_assign[4], s->ch_assign[6]);
++ FFSWAP(int, s->ch_assign[5], s->ch_assign[7]);
++ }
++
+ checksum = ff_mlp_restart_checksum(buf, get_bits_count(gbp) - start_count);
+
+ if (checksum != get_bits(gbp, 8))
diff --git a/contrib/ffmpeg/A04-dca-frame-size.patch b/contrib/ffmpeg/A04-dca-frame-size.patch
deleted file mode 100644
index 5af1040b2..000000000
--- a/contrib/ffmpeg/A04-dca-frame-size.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/libavcodec/dca.c b/libavcodec/dca.c
-index 68731c9..cf62c48 100644
---- a/libavcodec/dca.c
-+++ b/libavcodec/dca.c
-@@ -1650,6 +1650,7 @@ static int dca_decode_frame(AVCodecContext * avctx,
- //set AVCodec values with parsed data
- avctx->sample_rate = s->sample_rate;
- avctx->bit_rate = s->bit_rate;
-+ avctx->frame_size = s->sample_blocks * 32;
-
- s->profile = FF_PROFILE_DTS;
-
diff --git a/contrib/ffmpeg/A05-vc1-pulldown.patch b/contrib/ffmpeg/A05-vc1-pulldown.patch
deleted file mode 100644
index ff93bd119..000000000
--- a/contrib/ffmpeg/A05-vc1-pulldown.patch
+++ /dev/null
@@ -1,96 +0,0 @@
-diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
-index 243bef5..d20b000 100644
---- a/libavcodec/vc1.c
-+++ b/libavcodec/vc1.c
-@@ -504,6 +504,10 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
- v->s.avctx->time_base.den = ff_vc1_fps_nr[nr - 1] * 1000;
- }
- }
-+ if(v->broadcast) { // Pulldown may be present
-+ v->s.avctx->time_base.den *= 2;
-+ v->s.avctx->ticks_per_frame = 2;
-+ }
- }
-
- if(get_bits1(gb)){
-@@ -821,7 +825,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
- case 4:
- v->s.pict_type = AV_PICTURE_TYPE_P; // skipped pic
- v->p_frame_skipped = 1;
-- return 0;
-+ break;
- }
- if(v->tfcntrflag)
- skip_bits(gb, 8);
-@@ -830,13 +834,16 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
- v->rptfrm = get_bits(gb, 2);
- } else {
- v->tff = get_bits1(gb);
-- v->rptfrm = get_bits1(gb);
-+ v->rff = get_bits1(gb);
- }
- }
- if(v->panscanflag) {
- av_log_missing_feature(v->s.avctx, "Pan-scan", 0);
- //...
- }
-+ if(v->p_frame_skipped) {
-+ return 0;
-+ }
- v->rnd = get_bits1(gb);
- if(v->interlace)
- v->uvsamp = get_bits1(gb);
-diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c
-index 27ff1bd..4151119 100644
---- a/libavcodec/vc1_parser.c
-+++ b/libavcodec/vc1_parser.c
-@@ -45,6 +45,7 @@ static void vc1_extract_headers(AVCodecParserContext *s, AVCodecContext *avctx,
- vpc->v.s.avctx = avctx;
- vpc->v.parse_only = 1;
- next = buf;
-+ s->repeat_pict = 0;
-
- for(start = buf, end = buf + buf_size; next < end; start = next){
- int buf2_size, size;
-@@ -73,6 +74,18 @@ static void vc1_extract_headers(AVCodecParserContext *s, AVCodecContext *avctx,
- else
- s->pict_type = vpc->v.s.pict_type;
-
-+ // process pulldown flags
-+ s->repeat_pict = 1;
-+ // Pulldown flags are only valid when 'broadcast' has been set.
-+ // So ticks_per_frame will be 2
-+ if (vpc->v.rff){
-+ // repeat field
-+ s->repeat_pict = 2;
-+ }else if (vpc->v.rptfrm){
-+ // repeat frames
-+ s->repeat_pict = vpc->v.rptfrm * 2 + 1;
-+ }
-+
- break;
- }
- }
-diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
-index ae7906d..58cb8c0 100644
---- a/libavcodec/vc1dec.c
-+++ b/libavcodec/vc1dec.c
-@@ -3698,6 +3698,18 @@ static int vc1_decode_frame(AVCodecContext *avctx,
- av_log(v->s.avctx, AV_LOG_WARNING, "Sprite decoder: expected I-frame\n");
- }
-
-+ // process pulldown flags
-+ s->current_picture_ptr->repeat_pict = 0;
-+ // Pulldown flags are only valid when 'broadcast' has been set.
-+ // So ticks_per_frame will be 2
-+ if (v->rff){
-+ // repeat field
-+ s->current_picture_ptr->repeat_pict = 1;
-+ }else if (v->rptfrm){
-+ // repeat frames
-+ s->current_picture_ptr->repeat_pict = v->rptfrm * 2;
-+ }
-+
- // for skipping the frame
- s->current_picture.f.pict_type = s->pict_type;
- s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
diff --git a/contrib/ffmpeg/A06-h264-recovery-point.patch b/contrib/ffmpeg/A06-h264-recovery-point.patch
index 8b1531444..61442bd44 100644
--- a/contrib/ffmpeg/A06-h264-recovery-point.patch
+++ b/contrib/ffmpeg/A06-h264-recovery-point.patch
@@ -1,23 +1,31 @@
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
-index d047448..e96a129 100644
+index 9889224..ae77285 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
-@@ -3654,9 +3654,18 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
+@@ -2229,6 +2229,7 @@ static void flush_dpb(AVCodecContext *avctx){
+ h->s.first_field= 0;
+ ff_h264_reset_sei(h);
+ ff_mpeg_flush(avctx);
++ h->recovery_frame= -1;
+ }
+
+ static int init_poc(H264Context *h){
+@@ -3654,9 +3655,18 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
if((err = decode_slice_header(hx, h)))
break;
-+ if (h->sei_recovery_frame_cnt >= 0) {
++ if (h->sei_recovery_frame_cnt >= 0 && h->recovery_frame < 0) {
+ h->recovery_frame = (h->frame_num + h->sei_recovery_frame_cnt) %
+ (1 << h->sps.log2_max_frame_num);
+ }
+
- s->current_picture_ptr->key_frame |=
+ s->current_picture_ptr->f.key_frame |=
- (hx->nal_unit_type == NAL_IDR_SLICE) ||
- (h->sei_recovery_frame_cnt >= 0);
+ (hx->nal_unit_type == NAL_IDR_SLICE);
+
+ if (h->recovery_frame == h->frame_num) {
-+ s->current_picture_ptr->key_frame |= 1;
++ s->current_picture_ptr->f.key_frame |= 1;
+ h->recovery_frame = -1;
+ }
diff --git a/contrib/ffmpeg/P01-solaris.patch b/contrib/ffmpeg/P01-solaris.patch
index d807d76de..d9bb05be2 100644
--- a/contrib/ffmpeg/P01-solaris.patch
+++ b/contrib/ffmpeg/P01-solaris.patch
@@ -1,5 +1,5 @@
diff --git a/configure b/configure
-index 5e40e08..12d6232 100755
+index e01d9fd..69ba7ea 100755
--- a/configure
+++ b/configure
@@ -54,6 +54,9 @@ if test "$E1" != 0 || test "$E2" = 0; then
@@ -12,7 +12,7 @@ index 5e40e08..12d6232 100755
show_help(){
cat <<EOF
Usage: configure [options]
-@@ -2597,7 +2600,7 @@ EOF
+@@ -2603,7 +2606,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 115f07696..e93180fd3 100644
--- a/contrib/ffmpeg/P02-darwin-pic.patch
+++ b/contrib/ffmpeg/P02-darwin-pic.patch
@@ -1,16 +1,16 @@
diff --git a/configure b/configure
-index 5e40e08..4e05487 100755
+index e01d9fd..d5d6aec 100755
--- a/configure
+++ b/configure
-@@ -2412,6 +2412,7 @@ case $target_os in
- FFSERVERLDFLAGS=-Wl,-bind_at_load
+@@ -2413,6 +2413,7 @@ case $target_os in
+ AVSERVERLDFLAGS=-Wl,-bind_at_load
objformat="macho"
enabled x86_64 && objformat="macho64"
+ enabled x86_64 && enable pic
enabled_any pic shared ||
{ check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
;;
-@@ -2523,7 +2524,7 @@ esac
+@@ -2530,7 +2531,7 @@ esac
echo "config:$arch:$subarch:$cpu:$target_os:$cc_ident:$LIBAV_CONFIGURATION" >config.fate
diff --git a/contrib/ffmpeg/module.defs b/contrib/ffmpeg/module.defs
index 732b7778a..e231c5547 100644
--- a/contrib/ffmpeg/module.defs
+++ b/contrib/ffmpeg/module.defs
@@ -1,7 +1,7 @@
$(eval $(call import.MODULE.defs,FFMPEG,ffmpeg,BZIP2 ZLIB))
$(eval $(call import.CONTRIB.defs,FFMPEG))
-FFMPEG.FETCH.url = http://download.handbrake.fr/handbrake/contrib/ffmpeg-v0.7.1.tar.bz2
+FFMPEG.FETCH.url = http://download.handbrake.fr/handbrake/contrib/ffmpeg-v0.7-1318-g91038cd.tar.bz2
FFMPEG.CONFIGURE.deps =
FFMPEG.CONFIGURE.env =
@@ -12,7 +12,10 @@ FFMPEG.CONFIGURE.extra = \
--disable-bsfs \
--disable-encoders \
--disable-ffmpeg \
- --disable-ffserver \
+ --disable-avconv \
+ --disable-avplay \
+ --disable-avprobe \
+ --disable-avserver \
--disable-muxers \
--disable-network \
--disable-vaapi \
diff --git a/libhb/common.c b/libhb/common.c
index 4620602a7..cbf4ae65d 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -682,6 +682,7 @@ int hb_get_best_mixdown( uint32_t codec, int layout, int mixdown )
switch (codec)
{
case HB_ACODEC_LAME:
+ case HB_ACODEC_FFAAC:
best_mixdown = HB_AMIXDOWN_DOLBYPLII;
break;
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index ce459d6e5..28498273c 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -188,7 +188,7 @@ static int decavcodecaInit( hb_work_object_t * w, hb_job_t * job )
if ( pv->title->opaque_priv )
{
AVFormatContext *ic = (AVFormatContext*)pv->title->opaque_priv;
- pv->context = avcodec_alloc_context();
+ pv->context = avcodec_alloc_context3(codec);
avcodec_copy_context( pv->context, ic->streams[w->audio->id]->codec);
hb_ff_set_sample_fmt( pv->context, codec );
}
@@ -199,7 +199,7 @@ static int decavcodecaInit( hb_work_object_t * w, hb_job_t * job )
pv->context = avcodec_alloc_context3(codec);
hb_ff_set_sample_fmt( pv->context, codec );
}
- if ( hb_avcodec_open( pv->context, codec, 0 ) )
+ if ( hb_avcodec_open( pv->context, codec, NULL, 0 ) )
{
hb_log( "decavcodecaInit: avcodec_open failed" );
return 1;
@@ -419,7 +419,7 @@ static int decavcodecaBSInfo( hb_work_object_t *w, const hb_buffer_t *buf,
AVCodecParserContext *parser = av_parser_init( codec->id );
AVCodecContext *context = avcodec_alloc_context3(codec);
hb_ff_set_sample_fmt( context, codec );
- if ( hb_avcodec_open( context, codec, 0 ) )
+ if ( hb_avcodec_open( context, codec, NULL, 0 ) )
{
return -1;
}
@@ -988,13 +988,13 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job )
hb_log( "decavcodecvInit: failed to find codec for id (%d)", w->codec_param );
return 1;
}
- pv->context = avcodec_alloc_context();
+ pv->context = avcodec_alloc_context3(codec);
avcodec_copy_context( pv->context, ic->streams[pv->title->video_id]->codec);
pv->context->workaround_bugs = FF_BUG_AUTODETECT;
pv->context->error_recognition = 1;
pv->context->error_concealment = FF_EC_GUESS_MVS|FF_EC_DEBLOCK;
- if ( hb_avcodec_open( pv->context, codec, pv->job ? HB_FFMPEG_THREADS_AUTO : 0 ) )
+ if ( hb_avcodec_open( pv->context, codec, NULL, pv->job ? HB_FFMPEG_THREADS_AUTO : 0 ) )
{
hb_log( "decavcodecvInit: avcodec_open failed" );
return 1;
@@ -1010,8 +1010,9 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job )
}
else
{
+ AVCodec *codec = avcodec_find_decoder( w->codec_param );
pv->parser = av_parser_init( w->codec_param );
- pv->context = avcodec_alloc_context2( AVMEDIA_TYPE_VIDEO );
+ pv->context = avcodec_alloc_context3( codec );
pv->context->workaround_bugs = FF_BUG_AUTODETECT;
pv->context->error_recognition = 1;
pv->context->error_concealment = FF_EC_GUESS_MVS|FF_EC_DEBLOCK;
@@ -1155,7 +1156,7 @@ static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
return HB_WORK_OK;
}
// disable threaded decoding for scan, can cause crashes
- if ( hb_avcodec_open( pv->context, codec, pv->job ? HB_FFMPEG_THREADS_AUTO : 0 ) )
+ if ( hb_avcodec_open( pv->context, codec, NULL, pv->job ? HB_FFMPEG_THREADS_AUTO : 0 ) )
{
hb_log( "decavcodecvWork: avcodec_open failed" );
*buf_out = hb_buffer_init( 0 );;
diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c
index 965752aa9..a3164f4a8 100644
--- a/libhb/encavcodec.c
+++ b/libhb/encavcodec.c
@@ -167,6 +167,7 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
the left side of the equals sign in "name" and the right side into
"value." Then you hand those strings off to avutil for interpretation.
*/
+ AVDictionary *av_opts = NULL;
if( job->advanced_opts != NULL && *job->advanced_opts != '\0' )
{
char *opts, *opts_start;
@@ -179,7 +180,6 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
{
char *name = opts;
char *value;
- int ret;
opts += strcspn( opts, ":" );
if( *opts )
@@ -196,15 +196,7 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
}
/* Here's where the strings are passed to avutil for parsing. */
- ret = hb_av_set_string( context, codec, name, value );
-
- /* Let avutil sanity check the options for us*/
- if( ret == AVERROR_OPTION_NOT_FOUND )
- hb_log( "avcodec options: Unknown option %s", name );
-
- if( ret == AVERROR(EINVAL) )
- hb_log( "avcodec options: Bad argument %s=%s",
- name, value ? value : "(null)" );
+ av_dict_set( &av_opts, name, value, 0 );
}
}
free(opts_start);
@@ -282,10 +274,19 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
}
}
- if( hb_avcodec_open( context, codec, 0 ) )
+ if( hb_avcodec_open( context, codec, &av_opts, 0 ) )
{
hb_log( "encavcodecInit: avcodec_open failed" );
}
+ // avcodec_open populates the opts dictionary with the
+ // things it didn't recognize.
+ AVDictionaryEntry *t = NULL;
+ while( ( t = av_dict_get( av_opts, "", t, AV_DICT_IGNORE_SUFFIX ) ) )
+ {
+ hb_log( "encavcodecInit: Unknown avcodec option %s", t->key );
+ }
+ av_dict_free( &av_opts );
+
pv->context = context;
job->areBframes = 0;
diff --git a/libhb/encavcodecaudio.c b/libhb/encavcodecaudio.c
index cf27f0405..6645d22dc 100644
--- a/libhb/encavcodecaudio.c
+++ b/libhb/encavcodecaudio.c
@@ -58,16 +58,10 @@ static int encavcodecaInit( hb_work_object_t * w, hb_job_t * job )
}
context = avcodec_alloc_context3(codec);
+ AVDictionary *av_opts = NULL;
if ( w->codec_param == CODEC_ID_AAC )
{
- int ret = hb_av_set_string( context, codec, "stereo_mode", "ms_off" );
- /* Let avutil sanity check the options for us*/
- if( ret == AVERROR_OPTION_NOT_FOUND )
- hb_log( "avcodec options: Unknown option %s", "stereo_mode" );
-
- if( ret == AVERROR(EINVAL) )
- hb_log( "avcodec options: Bad argument %s=%s",
- "stereo_mode", "ms_off" ? "ms_off" : "(null)" );
+ av_dict_set( &av_opts, "stereo_mode", "ms_off", 0 );
}
context->channel_layout = AV_CH_LAYOUT_STEREO;
@@ -111,11 +105,20 @@ static int encavcodecaInit( hb_work_object_t * w, hb_job_t * job )
// Try to set format to float. Fallback to whatever is supported.
hb_ff_set_sample_fmt( context, codec );
- if( hb_avcodec_open( context, codec, 0 ) )
+ if( hb_avcodec_open( context, codec, &av_opts, 0 ) )
{
hb_log( "encavcodecaInit: avcodec_open failed" );
return 1;
}
+ // avcodec_open populates the opts dictionary with the
+ // things it didn't recognize.
+ AVDictionaryEntry *t = NULL;
+ while( ( t = av_dict_get( av_opts, "", t, AV_DICT_IGNORE_SUFFIX ) ) )
+ {
+ hb_log( "encavcodecaInit: Unknown avcodec option %s", t->key );
+ }
+ av_dict_free( &av_opts );
+
pv->context = context;
audio->config.out.samples_per_frame = pv->samples_per_frame = context->frame_size;
diff --git a/libhb/hb.c b/libhb/hb.c
index 697c68c7a..f5c93de4d 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -99,7 +99,7 @@ void hb_avcodec_init()
av_register_all();
}
-int hb_avcodec_open(AVCodecContext *avctx, AVCodec *codec, int thread_count)
+int hb_avcodec_open(AVCodecContext *avctx, AVCodec *codec, AVDictionary **av_opts, int thread_count)
{
int ret;
@@ -116,7 +116,7 @@ int hb_avcodec_open(AVCodecContext *avctx, AVCodec *codec, int thread_count)
avctx->thread_count = 1;
}
- ret = avcodec_open(avctx, codec);
+ ret = avcodec_open2(avctx, codec, av_opts);
return ret;
}
@@ -127,20 +127,6 @@ int hb_avcodec_close(AVCodecContext *avctx)
return ret;
}
-int hb_av_set_string( AVCodecContext *c, AVCodec *codec, const char *name, const char *val )
-{
- void * priv_context = NULL;
-
- if ( c && codec && codec->priv_class && c->priv_data )
- priv_context = c->priv_data;
-
- int ret = av_set_string3( c, name, val, 1, NULL );
- if ( ret == AVERROR_OPTION_NOT_FOUND && priv_context )
- ret = av_set_string3( priv_context, name, val, 1, NULL );
-
- return ret;
-}
-
static int handle_jpeg(enum PixelFormat *format)
{
switch (*format) {
@@ -166,17 +152,19 @@ hb_sws_get_context(int srcW, int srcH, enum PixelFormat srcFormat,
srcRange = handle_jpeg(&srcFormat);
dstRange = handle_jpeg(&dstFormat);
+ /* enable this when implemented in Libav
flags |= SWS_FULL_CHR_H_INT | SWS_FULL_CHR_H_INP;
+ */
- av_set_int(ctx, "srcw", srcW);
- av_set_int(ctx, "srch", srcH);
- av_set_int(ctx, "src_range", srcRange);
- av_set_int(ctx, "src_format", srcFormat);
- av_set_int(ctx, "dstw", dstW);
- av_set_int(ctx, "dsth", dstH);
- av_set_int(ctx, "dst_range", dstRange);
- av_set_int(ctx, "dst_format", dstFormat);
- av_set_int(ctx, "sws_flags", flags);
+ av_opt_set_int(ctx, "srcw", srcW, 0);
+ av_opt_set_int(ctx, "srch", srcH, 0);
+ av_opt_set_int(ctx, "src_range", srcRange, 0);
+ av_opt_set_int(ctx, "src_format", srcFormat, 0);
+ av_opt_set_int(ctx, "dstw", dstW, 0);
+ av_opt_set_int(ctx, "dsth", dstH, 0);
+ av_opt_set_int(ctx, "dst_range", dstRange, 0);
+ av_opt_set_int(ctx, "dst_format", dstFormat, 0);
+ av_opt_set_int(ctx, "sws_flags", flags, 0);
sws_setColorspaceDetails( ctx,
sws_getCoefficients( SWS_CS_DEFAULT ), // src colorspace
@@ -544,8 +532,7 @@ hb_handle_t * hb_init_dl( int verbose, int update_check )
h->pause_lock = hb_lock_init();
/* libavcodec */
- avcodec_init();
- avcodec_register_all();
+ hb_avcodec_init();
/* Start library thread */
hb_log( "hb_init: starting libhb thread" );
diff --git a/libhb/hbffmpeg.h b/libhb/hbffmpeg.h
index f1ea4a704..53cdee87a 100644
--- a/libhb/hbffmpeg.h
+++ b/libhb/hbffmpeg.h
@@ -5,12 +5,13 @@
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavutil/opt.h"
+#include "libavutil/mathematics.h"
#include "libswscale/swscale.h"
#define HB_FFMPEG_THREADS_AUTO (-1) // let hb_avcodec_open decide thread_count
void hb_avcodec_init(void);
-int hb_avcodec_open( AVCodecContext *, struct AVCodec *, int thread_count );
+int hb_avcodec_open( AVCodecContext *, struct AVCodec *, AVDictionary **av_opts, int thread_count );
int hb_avcodec_close( AVCodecContext * );
int hb_ff_layout_xlat(int64_t ff_layout, int channels);
struct SwsContext*
@@ -19,4 +20,3 @@ hb_sws_get_context(int srcW, int srcH, enum PixelFormat srcFormat,
int flags);
void hb_ff_set_sample_fmt(AVCodecContext *context, AVCodec *codec);
int hb_ff_dts_request_5point1( AVCodecContext *c );
-int hb_av_set_string( AVCodecContext *c, AVCodec *codec, const char *name, const char *val );
diff --git a/libhb/mcdeint.c b/libhb/mcdeint.c
index 1c7138bd7..9e3d82371 100644
--- a/libhb/mcdeint.c
+++ b/libhb/mcdeint.c
@@ -37,7 +37,6 @@ void mcdeint_init( mcdeint_private_t * pv,
/* Allocate mcdeint specific buffers */
if( pv->mcdeint_mode >= 0 )
{
- avcodec_init();
avcodec_register_all();
AVCodec * enc = avcodec_find_encoder( CODEC_ID_SNOW );
@@ -47,7 +46,7 @@ void mcdeint_init( mcdeint_private_t * pv,
{
AVCodecContext * avctx_enc;
- avctx_enc = pv->mcdeint_avctx_enc = avcodec_alloc_context();
+ avctx_enc = pv->mcdeint_avctx_enc = avcodec_alloc_context3( enc );
avctx_enc->width = width;
avctx_enc->height = height;
@@ -76,7 +75,7 @@ void mcdeint_init( mcdeint_private_t * pv,
avctx_enc->flags |= CODEC_FLAG_QPEL;
}
- hb_avcodec_open(avctx_enc, enc, 0);
+ hb_avcodec_open(avctx_enc, enc, NULL, 0);
}
pv->mcdeint_frame = avcodec_alloc_frame();
diff --git a/libhb/stream.c b/libhb/stream.c
index 90f6a895b..a5401ec18 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -4763,7 +4763,7 @@ static int ffmpeg_open( hb_stream_t *stream, hb_title_t *title, int scan )
{
return 0;
}
- if ( av_find_stream_info( info_ic ) < 0 )
+ if ( avformat_find_stream_info( info_ic, NULL ) < 0 )
goto fail;
title->opaque_priv = (void*)info_ic;
diff --git a/libhb/sync.c b/libhb/sync.c
index b1ec99619..6c1911b98 100644
--- a/libhb/sync.c
+++ b/libhb/sync.c
@@ -1174,7 +1174,7 @@ static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i )
c->channel_layout |= AV_CH_LOW_FREQUENCY;
}
- if( hb_avcodec_open( c, codec, 0 ) < 0 )
+ if( hb_avcodec_open( c, codec, NULL, 0 ) < 0 )
{
hb_log( "sync: avcodec_open failed" );
return;