avformat_find编码

*/ static int try_decode_frame(AVFormatContext *s, AVStream *st, AVPacket *avpkt, AVDictionary **options) { const AVCodec *codec; int got_picture = 1, ret = 0; AVFrame *frame = av_frame_alloc(); AVSubtitle 字幕;

AVPacket pkt = *avpkt; if (!frame) 返回 AVERROR(ENOMEM); if (!avcodec_is_open(st->codec) && st->info->found_decoder <= 0 && (st->codec->codec_id != -st->info->found_decoder || !st->codec->codec_id ))

{ AVDictionary *thread_opt = NULL; 编解码器 = find_decoder(s, st, st->codec->codec_id); if (!codec) { st->info->found_decoder = -st->codec->codec_id; ret = ⑴; 失败;}

。*/ av_dict_set(options ? options : &thread_opt, "threads", "1", 0); if (s->codec_whitelist) av_dict_set(options ? options : &thread_opt, "codec_whitelist", s->codec_whitelist, 0);
ret = avcodec_open2(st->codec, codec, options ? options : &thread_opt); if (!options) av_dict_free(&thread_opt); if (ret < 0) { st->info->found_decoder = -st->codec->codec_id; 失败;

} st->info->found_decoder = 1; } else if (!st->info-> found_decoder) st->info->found_decoder = 1; if (st->info->found_decoder < 0) { ret = ⑴; 失败;}

while ((pkt.size > 0 || (!pkt.data && got_picture)) && ret >= 0 && (!has_codec_parameters(st, NULL) || !has_decode_delay_been_guessed(st) ||

(!st->codec_info_nb_frames && st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF))) { got_picture = 0; switch (st->codec->codec_type)

{ case AVMEDIA_TYPE_VIDEO: ret = avcodec_decode_video2(st->codec, frame, &got_picture, &pkt); 

; case AVMEDIA_TYPE_AUDIO: ret = avcodec_decode_audio4(st->codec, frame, &got_picture, & 包); 打破; case AVMEDIA_TYPE_SUBTITLE:

ret = avcodec_decode_subtitle2(st->codec, &subtitle, &got_picture, &pkt); ret = pkt.size; 打破; 默认值:中断;} if (ret >= 0) { if (got_picture) st->nb_decoded_frames++;

pkt.data += ret; pkt.size -= ret; ret = got_picture; } } if (!pkt.data && !got_picture) ret = ⑴; 失败:av_frame_free(&frame); 返回 ret; } 打破; 默认值中断;}

if (ret >= 0) { if (got_picture) st->nb_decoded_frames++; pkt.data += ret; pkt.size -= ret; ret = got_picture; } } if (!pkt.data && !got_picture) ret = ⑴;

失败:av_frame_free(&frame); 返回 ret; } 打破; 默认值:中断;} if (ret >= 0) { if (got_picture) st->nb_decoded_frames++; pkt.data += ret; pkt.size -= ret; ret = got_picture;

} } if (!pkt.data && !got_picture) ret = ⑴; 失败:av_frame_free(&frame); 返回 ret; }

posted @ 2021-08-24 09:35  v17166570219  阅读(46)  评论(0)    收藏  举报