| 833 | } |
| 834 | |
| 835 | static int decavcodecaBSInfo( hb_work_object_t *w, const hb_buffer_t *buf, |
| 836 | hb_work_info_t *info ) |
| 837 | { |
| 838 | hb_work_private_t *pv = w->private_data; |
| 839 | int result = 0, done = 0; |
| 840 | hb_audio_t *audio = w->audio; |
| 841 | |
| 842 | memset( info, 0, sizeof(*info) ); |
| 843 | info->ch_layout = calloc(1, sizeof(*info->ch_layout)); |
| 844 | |
| 845 | if ( pv && pv->context ) |
| 846 | { |
| 847 | return decavcodecaInfo( w, info ); |
| 848 | } |
| 849 | |
| 850 | const AVCodec *codec = avcodec_find_decoder( w->codec_param ); |
| 851 | if ( ! codec ) |
| 852 | { |
| 853 | // there's no ffmpeg codec for this audio type - give up |
| 854 | return -1; |
| 855 | } |
| 856 | |
| 857 | static char codec_name[64]; |
| 858 | info->name = strncpy( codec_name, codec->name, sizeof(codec_name)-1 ); |
| 859 | |
| 860 | AVCodecContext *context = avcodec_alloc_context3(codec); |
| 861 | AVCodecParserContext *parser = NULL; |
| 862 | |
| 863 | if (w->title && w->title->opaque_priv != NULL) |
| 864 | { |
| 865 | AVFormatContext *ic = (AVFormatContext*)w->title->opaque_priv; |
| 866 | avcodec_parameters_to_context(context, |
| 867 | ic->streams[audio->id]->codecpar); |
| 868 | // libav's eac3 parser toggles the codec_id in the context as |
| 869 | // it reads eac3 data between AV_CODEC_ID_AC3 and AV_CODEC_ID_EAC3. |
| 870 | // It detects an AC3 sync pattern sometimes in ac3_sync() which |
| 871 | // causes it to eventually set avctx->codec_id to AV_CODEC_ID_AC3 |
| 872 | // in ff_aac_ac3_parse(). Since we are parsing some data before |
| 873 | // we get here, the codec_id may have flipped. This will cause an |
| 874 | // error in hb_avcodec_open(). So flip it back! |
| 875 | context->codec_id = w->codec_param; |
| 876 | } |
| 877 | else |
| 878 | { |
| 879 | // AVCodecContext bit_rate default is 128 Kb |
| 880 | // unset it to avoid getting a wrong value if |
| 881 | // nothing sets it to the actual streams value |
| 882 | context->bit_rate = 1; |
| 883 | parser = av_parser_init(codec->id); |
| 884 | } |
| 885 | |
| 886 | hb_ff_set_sample_fmt( context, codec, AV_SAMPLE_FMT_FLT ); |
| 887 | |
| 888 | AVDictionary * av_opts = NULL; |
| 889 | av_dict_set( &av_opts, "err_detect", "crccheck+explode", 0 ); |
| 890 | if ( hb_avcodec_open( context, codec, &av_opts, 0 ) ) |
| 891 | { |
| 892 | av_dict_free( &av_opts ); |
nothing calls this directly
no test coverage detected