#include "libavutil/intmath.h"
#include "avcodec.h"
+#include "dsputil.h"
+#include "internal.h"
#include "proresdata.h"
#include "proresdsp.h"
#include "get_bits.h"
int x_pos, y_pos;
int slice_width;
int prev_slice_sf; ///< scalefactor of the previous decoded slice
- DECLARE_ALIGNED(16, DCTELEM, blocks)[8 * 4 * 64];
+ DECLARE_ALIGNED(16, int16_t, blocks)[8 * 4 * 64];
DECLARE_ALIGNED(16, int16_t, qmat_luma_scaled)[64];
DECLARE_ALIGNED(16, int16_t, qmat_chroma_scaled)[64];
} ProresThreadData;
typedef struct {
ProresDSPContext dsp;
- AVFrame picture;
+ AVFrame *frame;
ScanTable scantable;
int scantable_type; ///< -1 = uninitialized, 0 = progressive, 1/2 = interlaced
avctx->bits_per_raw_sample = PRORES_BITS_PER_SAMPLE;
ff_proresdsp_init(&ctx->dsp);
- avctx->coded_frame = &ctx->picture;
- avcodec_get_frame_defaults(&ctx->picture);
- ctx->picture.type = AV_PICTURE_TYPE_I;
- ctx->picture.key_frame = 1;
-
ctx->scantable_type = -1; // set scantable type to uninitialized
memset(ctx->qmat_luma, 4, 64);
memset(ctx->qmat_chroma, 4, 64);
}
if (ctx->frame_type) { /* if interlaced */
- ctx->picture.interlaced_frame = 1;
- ctx->picture.top_field_first = ctx->frame_type & 1;
+ ctx->frame->interlaced_frame = 1;
+ ctx->frame->top_field_first = ctx->frame_type & 1;
+ } else {
+ ctx->frame->interlaced_frame = 0;
}
avctx->color_primaries = buf[14];
ctx->alpha_info = buf[17] & 0xf;
if (ctx->alpha_info)
- av_log_missing_feature(avctx, "alpha channel", 0);
+ avpriv_report_missing_feature(avctx, "Alpha channel");
ctx->qmat_changed = 0;
ptr = buf + 20;
ctx->num_x_mbs = (avctx->width + 15) >> 4;
ctx->num_y_mbs = (avctx->height +
- (1 << (4 + ctx->picture.interlaced_frame)) - 1) >>
- (4 + ctx->picture.interlaced_frame);
+ (1 << (4 + ctx->frame->interlaced_frame)) - 1) >>
+ (4 + ctx->frame->interlaced_frame);
remainder = ctx->num_x_mbs & ((1 << slice_width_factor) - 1);
num_x_slices = (ctx->num_x_mbs >> slice_width_factor) + (remainder & 1) +
/**
* Decode DC coefficients for all blocks in a slice.
*/
-static inline void decode_dc_coeffs(GetBitContext *gb, DCTELEM *out,
+static inline void decode_dc_coeffs(GetBitContext *gb, int16_t *out,
int nblocks)
{
- DCTELEM prev_dc;
+ int16_t prev_dc;
int i, sign;
int16_t delta;
unsigned int code;
/**
* Decode AC coefficients for all blocks in a slice.
*/
-static inline void decode_ac_coeffs(GetBitContext *gb, DCTELEM *out,
+static inline void decode_ac_coeffs(GetBitContext *gb, int16_t *out,
int blocks_per_slice,
int plane_size_factor,
const uint8_t *scan)
const int16_t *qmat, int is_chroma)
{
GetBitContext gb;
- DCTELEM *block_ptr;
+ int16_t *block_ptr;
int mb_num, blocks_per_slice;
blocks_per_slice = mbs_per_slice * blocks_per_mb;
int mbs_per_slice = td->slice_width;
const uint8_t *buf;
uint8_t *y_data, *u_data, *v_data;
- AVFrame *pic = avctx->coded_frame;
+ AVFrame *pic = ctx->frame;
int i, sf, slice_width_factor;
int slice_data_size, hdr_size, y_data_size, u_data_size, v_data_size;
int y_linesize, u_linesize, v_linesize;
#define MOVE_DATA_PTR(nbytes) buf += (nbytes); buf_size -= (nbytes)
-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
+static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
ProresContext *ctx = avctx->priv_data;
- AVFrame *picture = avctx->coded_frame;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int frame_hdr_size, pic_num, pic_data_size;
+ ctx->frame = data;
+ ctx->frame->pict_type = AV_PICTURE_TYPE_I;
+ ctx->frame->key_frame = 1;
+
/* check frame atom container */
if (buf_size < 28 || buf_size < AV_RB32(buf) ||
AV_RB32(buf + 4) != FRAME_ID) {
MOVE_DATA_PTR(frame_hdr_size);
- if (picture->data[0])
- avctx->release_buffer(avctx, picture);
-
- picture->reference = 0;
- if (avctx->get_buffer(avctx, picture) < 0)
+ if (ff_get_buffer(avctx, ctx->frame, 0) < 0)
return -1;
- for (pic_num = 0; ctx->picture.interlaced_frame - pic_num + 1; pic_num++) {
+ for (pic_num = 0; ctx->frame->interlaced_frame - pic_num + 1; pic_num++) {
pic_data_size = decode_picture_header(ctx, buf, buf_size, avctx);
if (pic_data_size < 0)
return AVERROR_INVALIDDATA;
MOVE_DATA_PTR(pic_data_size);
}
- *data_size = sizeof(AVPicture);
- *(AVFrame*) data = *avctx->coded_frame;
+ ctx->frame = NULL;
+ *got_frame = 1;
return avpkt->size;
}
{
ProresContext *ctx = avctx->priv_data;
- if (ctx->picture.data[0])
- avctx->release_buffer(avctx, &ctx->picture);
-
av_freep(&ctx->slice_data);
return 0;