#include "libavutil/thread.h"
#include "avcodec.h"
#include "decode.h"
-#include "hwaccel.h"
+#include "hwconfig.h"
#include "libavutil/opt.h"
#include "mpegvideo.h"
#include "thread.h"
}
avctx->internal = avci;
- avci->pool = av_mallocz(sizeof(*avci->pool));
- if (!avci->pool) {
- ret = AVERROR(ENOMEM);
- goto free_and_end;
- }
-
avci->to_free = av_frame_alloc();
- if (!avci->to_free) {
- ret = AVERROR(ENOMEM);
- goto free_and_end;
- }
-
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();
- if (!avci->buffer_frame) {
- ret = AVERROR(ENOMEM);
- goto free_and_end;
- }
-
avci->buffer_pkt = av_packet_alloc();
- if (!avci->buffer_pkt) {
- ret = AVERROR(ENOMEM);
- goto free_and_end;
- }
-
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();
- 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);
goto free_and_end;
}
av_packet_free(&avci->ds.in_pkt);
ff_decode_bsfs_uninit(avctx);
- av_freep(&avci->pool);
+ av_buffer_unref(&avci->pool);
}
av_freep(&avci);
avctx->internal = NULL;
return 0;
if (avcodec_is_open(avctx)) {
- FramePool *pool = avctx->internal->pool;
if (CONFIG_FRAME_THREAD_ENCODER &&
avctx->internal->frame_thread_encoder && avctx->thread_count > 1) {
ff_frame_thread_encoder_free(avctx);
av_packet_free(&avctx->internal->ds.in_pkt);
- for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++)
- av_buffer_pool_uninit(&pool->pools[i]);
- av_freep(&avctx->internal->pool);
+ av_buffer_unref(&avctx->internal->pool);
if (avctx->hwaccel && avctx->hwaccel->uninit)
avctx->hwaccel->uninit(avctx);
AVPacketSideData *tmp;
AVCPBProperties *props;
size_t size;
+ int i;
+
+ for (i = 0; i < avctx->nb_coded_side_data; i++)
+ if (avctx->coded_side_data[i].type == AV_PKT_DATA_CPB_PROPERTIES)
+ return (AVCPBProperties *)avctx->coded_side_data[i].data;
props = av_cpb_properties_alloc(&size);
if (!props)