diff options
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/audio_remap.c | 2 | ||||
-rw-r--r-- | libhb/audio_resample.c | 4 | ||||
-rw-r--r-- | libhb/audio_resample.h | 2 | ||||
-rw-r--r-- | libhb/bd.c | 45 | ||||
-rw-r--r-- | libhb/common.h | 2 | ||||
-rw-r--r-- | libhb/decavcodec.c | 61 | ||||
-rw-r--r-- | libhb/decmpeg2.c | 8 | ||||
-rw-r--r-- | libhb/decpgssub.c | 22 | ||||
-rw-r--r-- | libhb/decvobsub.c | 2 | ||||
-rw-r--r-- | libhb/dvd.c | 4 | ||||
-rw-r--r-- | libhb/dvdnav.c | 4 | ||||
-rw-r--r-- | libhb/encavcodec.c | 8 | ||||
-rw-r--r-- | libhb/encavcodecaudio.c | 13 | ||||
-rw-r--r-- | libhb/enctheora.c | 2 | ||||
-rw-r--r-- | libhb/encx264.c | 8 | ||||
-rw-r--r-- | libhb/hb.c | 41 | ||||
-rw-r--r-- | libhb/hbffmpeg.h | 6 | ||||
-rw-r--r-- | libhb/internal.h | 27 | ||||
-rw-r--r-- | libhb/mcdeint.c | 2 | ||||
-rw-r--r-- | libhb/rendersub.c | 2 | ||||
-rw-r--r-- | libhb/scan.c | 7 | ||||
-rw-r--r-- | libhb/stream.c | 271 | ||||
-rw-r--r-- | libhb/sync.c | 23 | ||||
-rw-r--r-- | libhb/work.c | 14 |
24 files changed, 302 insertions, 278 deletions
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 ); |