avcodec/utils: simplify, remove duplicate code
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
This commit is contained in:
@ -584,37 +584,14 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
|||||||
avctx->internal = avci;
|
avctx->internal = avci;
|
||||||
|
|
||||||
avci->to_free = av_frame_alloc();
|
avci->to_free = av_frame_alloc();
|
||||||
if (!avci->to_free) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto free_and_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
avci->compat_decode_frame = av_frame_alloc();
|
avci->compat_decode_frame = av_frame_alloc();
|
||||||
if (!avci->compat_decode_frame) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto free_and_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
avci->buffer_frame = av_frame_alloc();
|
avci->buffer_frame = av_frame_alloc();
|
||||||
if (!avci->buffer_frame) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto free_and_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
avci->buffer_pkt = av_packet_alloc();
|
avci->buffer_pkt = av_packet_alloc();
|
||||||
if (!avci->buffer_pkt) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto free_and_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
avci->ds.in_pkt = av_packet_alloc();
|
avci->ds.in_pkt = av_packet_alloc();
|
||||||
if (!avci->ds.in_pkt) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto free_and_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
avci->last_pkt_props = av_packet_alloc();
|
avci->last_pkt_props = av_packet_alloc();
|
||||||
if (!avci->last_pkt_props) {
|
if (!avci->to_free || !avci->compat_decode_frame ||
|
||||||
|
!avci->buffer_frame || !avci->buffer_pkt ||
|
||||||
|
!avci->ds.in_pkt || !avci->last_pkt_props) {
|
||||||
ret = AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
goto free_and_end;
|
goto free_and_end;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user