mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-28 12:32:17 +02:00
avfilter/lavfutils: remove usage of AVStream->codec
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
837c55e072
commit
9a174d203a
@ -29,6 +29,7 @@ int ff_load_image(uint8_t *data[4], int linesize[4],
|
|||||||
AVFormatContext *format_ctx = NULL;
|
AVFormatContext *format_ctx = NULL;
|
||||||
AVCodec *codec;
|
AVCodec *codec;
|
||||||
AVCodecContext *codec_ctx;
|
AVCodecContext *codec_ctx;
|
||||||
|
AVCodecParameters *par;
|
||||||
AVFrame *frame;
|
AVFrame *frame;
|
||||||
int frame_decoded, ret = 0;
|
int frame_decoded, ret = 0;
|
||||||
AVPacket pkt;
|
AVPacket pkt;
|
||||||
@ -50,14 +51,27 @@ int ff_load_image(uint8_t *data[4], int linesize[4],
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
codec_ctx = format_ctx->streams[0]->codec;
|
par = format_ctx->streams[0]->codecpar;
|
||||||
codec = avcodec_find_decoder(codec_ctx->codec_id);
|
codec = avcodec_find_decoder(par->codec_id);
|
||||||
if (!codec) {
|
if (!codec) {
|
||||||
av_log(log_ctx, AV_LOG_ERROR, "Failed to find codec\n");
|
av_log(log_ctx, AV_LOG_ERROR, "Failed to find codec\n");
|
||||||
ret = AVERROR(EINVAL);
|
ret = AVERROR(EINVAL);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
codec_ctx = avcodec_alloc_context3(codec);
|
||||||
|
if (!codec_ctx) {
|
||||||
|
av_log(log_ctx, AV_LOG_ERROR, "Failed to alloc video decoder context\n");
|
||||||
|
ret = AVERROR(ENOMEM);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = avcodec_parameters_to_context(codec_ctx, par);
|
||||||
|
if (ret < 0) {
|
||||||
|
av_log(log_ctx, AV_LOG_ERROR, "Failed to copy codec parameters to decoder context\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
av_dict_set(&opt, "thread_type", "slice", 0);
|
av_dict_set(&opt, "thread_type", "slice", 0);
|
||||||
if ((ret = avcodec_open2(codec_ctx, codec, &opt)) < 0) {
|
if ((ret = avcodec_open2(codec_ctx, codec, &opt)) < 0) {
|
||||||
av_log(log_ctx, AV_LOG_ERROR, "Failed to open codec\n");
|
av_log(log_ctx, AV_LOG_ERROR, "Failed to open codec\n");
|
||||||
@ -96,7 +110,7 @@ int ff_load_image(uint8_t *data[4], int linesize[4],
|
|||||||
|
|
||||||
end:
|
end:
|
||||||
av_packet_unref(&pkt);
|
av_packet_unref(&pkt);
|
||||||
avcodec_close(codec_ctx);
|
avcodec_free_context(&codec_ctx);
|
||||||
avformat_close_input(&format_ctx);
|
avformat_close_input(&format_ctx);
|
||||||
av_frame_free(&frame);
|
av_frame_free(&frame);
|
||||||
av_dict_free(&opt);
|
av_dict_free(&opt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user