#include "avcodec.h"
#include "get_bits.h"
+#include "internal.h"
#include "simple_idct.h"
#include "proresdec.h"
ff_dsputil_init(&ctx->dsp, avctx);
ff_proresdsp_init(&ctx->prodsp, avctx);
- avctx->coded_frame = &ctx->frame;
- ctx->frame.type = AV_PICTURE_TYPE_I;
- ctx->frame.key_frame = 1;
-
ff_init_scantable_permutation(idct_permutation,
ctx->prodsp.idct_permutation_type);
ctx->scan = ctx->progressive_scan; // permuted
} else {
ctx->scan = ctx->interlaced_scan; // permuted
- ctx->frame.interlaced_frame = 1;
- ctx->frame.top_field_first = ctx->frame_type == 1;
+ ctx->frame->interlaced_frame = 1;
+ ctx->frame->top_field_first = ctx->frame_type == 1;
}
- avctx->pix_fmt = (buf[12] & 0xC0) == 0xC0 ? PIX_FMT_YUV444P10 : PIX_FMT_YUV422P10;
+ avctx->pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUV444P10 : AV_PIX_FMT_YUV422P10;
ptr = buf + 20;
flags = buf[19];
av_dlog(avctx, "flags %x\n", flags);
if (flags & 2) {
+ if(buf + data_size - ptr < 64) {
+ av_log(avctx, AV_LOG_ERROR, "Header truncated\n");
+ return -1;
+ }
permute(ctx->qmat_luma, ctx->prodsp.idct_permutation, ptr);
ptr += 64;
} else {
}
if (flags & 1) {
+ if(buf + data_size - ptr < 64) {
+ av_log(avctx, AV_LOG_ERROR, "Header truncated\n");
+ return -1;
+ }
permute(ctx->qmat_chroma, ctx->prodsp.idct_permutation, ptr);
} else {
memset(ctx->qmat_chroma, 4, 64);
static const uint8_t dc_codebook[7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70};
-static av_always_inline void decode_dc_coeffs(GetBitContext *gb, DCTELEM *out,
+static av_always_inline void decode_dc_coeffs(GetBitContext *gb, int16_t *out,
int blocks_per_slice)
{
- DCTELEM prev_dc;
+ int16_t prev_dc;
int code, i, sign;
OPEN_READER(re, gb);
static const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28, 0x28, 0x28, 0x28, 0x4C };
static av_always_inline void decode_ac_coeffs(AVCodecContext *avctx, GetBitContext *gb,
- DCTELEM *out, int blocks_per_slice)
+ int16_t *out, int blocks_per_slice)
{
ProresContext *ctx = avctx->priv_data;
int block_mask, sign;
const int16_t *qmat)
{
ProresContext *ctx = avctx->priv_data;
- LOCAL_ALIGNED_16(DCTELEM, blocks, [8*4*64]);
- DCTELEM *block;
+ LOCAL_ALIGNED_16(int16_t, blocks, [8*4*64]);
+ int16_t *block;
GetBitContext gb;
int i, blocks_per_slice = slice->mb_count<<2;
const int16_t *qmat, int log2_blocks_per_mb)
{
ProresContext *ctx = avctx->priv_data;
- LOCAL_ALIGNED_16(DCTELEM, blocks, [8*4*64]);
- DCTELEM *block;
+ LOCAL_ALIGNED_16(int16_t, blocks, [8*4*64]);
+ int16_t *block;
GetBitContext gb;
int i, j, blocks_per_slice = slice->mb_count << log2_blocks_per_mb;
ProresContext *ctx = avctx->priv_data;
SliceContext *slice = &ctx->slices[jobnr];
const uint8_t *buf = slice->data;
- AVFrame *pic = avctx->coded_frame;
+ AVFrame *pic = ctx->frame;
int i, hdr_size, qscale, log2_chroma_blocks_per_mb;
int luma_stride, chroma_stride;
int y_data_size, u_data_size, v_data_size;
int16_t qmat_chroma_scaled[64];
int mb_x_shift;
+ slice->ret = -1;
//av_log(avctx, AV_LOG_INFO, "slice %d mb width %d mb x %d y %d\n",
// jobnr, slice->mb_count, slice->mb_x, slice->mb_y);
chroma_stride = pic->linesize[1] << 1;
}
- if (avctx->pix_fmt == PIX_FMT_YUV444P10) {
+ if (avctx->pix_fmt == AV_PIX_FMT_YUV444P10) {
mb_x_shift = 5;
log2_chroma_blocks_per_mb = 2;
} else {
dest_u = pic->data[1] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);
dest_v = pic->data[2] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);
- if (ctx->frame_type && ctx->first_field ^ ctx->frame.top_field_first) {
+ if (ctx->frame_type && ctx->first_field ^ ctx->frame->top_field_first) {
dest_y += pic->linesize[0];
dest_u += pic->linesize[1];
dest_v += pic->linesize[2];
qmat_chroma_scaled, log2_chroma_blocks_per_mb);
}
+ slice->ret = 0;
return 0;
}
static int decode_picture(AVCodecContext *avctx)
{
ProresContext *ctx = avctx->priv_data;
- int i, threads_ret[ctx->slice_count];
+ int i;
- avctx->execute2(avctx, decode_slice_thread, NULL, threads_ret, ctx->slice_count);
+ avctx->execute2(avctx, decode_slice_thread, NULL, NULL, ctx->slice_count);
for (i = 0; i < ctx->slice_count; i++)
- if (threads_ret[i] < 0)
- return threads_ret[i];
+ if (ctx->slices[i].ret < 0)
+ return ctx->slices[i].ret;
return 0;
}
-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 *frame = avctx->coded_frame;
+ AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int frame_hdr_size, pic_size;
return -1;
}
+ ctx->frame = frame;
+ ctx->frame->pict_type = AV_PICTURE_TYPE_I;
+ ctx->frame->key_frame = 1;
ctx->first_field = 1;
buf += 8;
buf += frame_hdr_size;
buf_size -= frame_hdr_size;
- if (frame->data[0])
- avctx->release_buffer(avctx, frame);
-
- if (avctx->get_buffer(avctx, frame) < 0)
+ if (ff_get_buffer(avctx, frame, 0) < 0)
return -1;
decode_picture:
goto decode_picture;
}
- *data_size = sizeof(AVFrame);
- *(AVFrame*)data = *frame;
+ *got_frame = 1;
return avpkt->size;
}
{
ProresContext *ctx = avctx->priv_data;
- AVFrame *frame = avctx->coded_frame;
- if (frame->data[0])
- avctx->release_buffer(avctx, frame);
av_freep(&ctx->slices);
return 0;