00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00031 #define LONG_BITSTREAM_READER // some ProRes vlc codes require up to 28 bits to be read at once
00032
00033 #include <stdint.h>
00034
00035 #include "libavutil/intmath.h"
00036 #include "avcodec.h"
00037 #include "internal.h"
00038 #include "proresdata.h"
00039 #include "proresdsp.h"
00040 #include "get_bits.h"
00041
00042 typedef struct {
00043 const uint8_t *index;
00044 int slice_num;
00045 int x_pos, y_pos;
00046 int slice_width;
00047 int prev_slice_sf;
00048 DECLARE_ALIGNED(16, DCTELEM, blocks)[8 * 4 * 64];
00049 DECLARE_ALIGNED(16, int16_t, qmat_luma_scaled)[64];
00050 DECLARE_ALIGNED(16, int16_t, qmat_chroma_scaled)[64];
00051 } ProresThreadData;
00052
00053 typedef struct {
00054 ProresDSPContext dsp;
00055 AVFrame picture;
00056 ScanTable scantable;
00057 int scantable_type;
00058
00059 int frame_type;
00060 int pic_format;
00061 uint8_t qmat_luma[64];
00062 uint8_t qmat_chroma[64];
00063 int qmat_changed;
00064 int total_slices;
00065 ProresThreadData *slice_data;
00066 int pic_num;
00067 int chroma_factor;
00068 int mb_chroma_factor;
00069 int num_chroma_blocks;
00070 int num_x_slices;
00071 int num_y_slices;
00072 int slice_width_factor;
00073 int slice_height_factor;
00074 int num_x_mbs;
00075 int num_y_mbs;
00076 int alpha_info;
00077 } ProresContext;
00078
00079
00080 static av_cold int decode_init(AVCodecContext *avctx)
00081 {
00082 ProresContext *ctx = avctx->priv_data;
00083
00084 ctx->total_slices = 0;
00085 ctx->slice_data = NULL;
00086
00087 avctx->bits_per_raw_sample = PRORES_BITS_PER_SAMPLE;
00088 ff_proresdsp_init(&ctx->dsp, avctx);
00089
00090 avctx->coded_frame = &ctx->picture;
00091 avcodec_get_frame_defaults(&ctx->picture);
00092 ctx->picture.type = AV_PICTURE_TYPE_I;
00093 ctx->picture.key_frame = 1;
00094
00095 ctx->scantable_type = -1;
00096 memset(ctx->qmat_luma, 4, 64);
00097 memset(ctx->qmat_chroma, 4, 64);
00098
00099 return 0;
00100 }
00101
00102
00103 static int decode_frame_header(ProresContext *ctx, const uint8_t *buf,
00104 const int data_size, AVCodecContext *avctx)
00105 {
00106 int hdr_size, version, width, height, flags;
00107 const uint8_t *ptr;
00108
00109 hdr_size = AV_RB16(buf);
00110 if (hdr_size > data_size) {
00111 av_log(avctx, AV_LOG_ERROR, "frame data too small\n");
00112 return AVERROR_INVALIDDATA;
00113 }
00114
00115 version = AV_RB16(buf + 2);
00116 if (version >= 2) {
00117 av_log(avctx, AV_LOG_ERROR,
00118 "unsupported header version: %d\n", version);
00119 return AVERROR_INVALIDDATA;
00120 }
00121
00122 width = AV_RB16(buf + 8);
00123 height = AV_RB16(buf + 10);
00124 if (width != avctx->width || height != avctx->height) {
00125 av_log(avctx, AV_LOG_ERROR,
00126 "picture dimension changed: old: %d x %d, new: %d x %d\n",
00127 avctx->width, avctx->height, width, height);
00128 return AVERROR_INVALIDDATA;
00129 }
00130
00131 ctx->frame_type = (buf[12] >> 2) & 3;
00132 if (ctx->frame_type > 2) {
00133 av_log(avctx, AV_LOG_ERROR,
00134 "unsupported frame type: %d\n", ctx->frame_type);
00135 return AVERROR_INVALIDDATA;
00136 }
00137
00138 ctx->chroma_factor = (buf[12] >> 6) & 3;
00139 ctx->mb_chroma_factor = ctx->chroma_factor + 2;
00140 ctx->num_chroma_blocks = (1 << ctx->chroma_factor) >> 1;
00141 switch (ctx->chroma_factor) {
00142 case 2:
00143 avctx->pix_fmt = AV_PIX_FMT_YUV422P10;
00144 break;
00145 case 3:
00146 avctx->pix_fmt = AV_PIX_FMT_YUV444P10;
00147 break;
00148 default:
00149 av_log(avctx, AV_LOG_ERROR,
00150 "unsupported picture format: %d\n", ctx->pic_format);
00151 return AVERROR_INVALIDDATA;
00152 }
00153
00154 if (ctx->scantable_type != ctx->frame_type) {
00155 if (!ctx->frame_type)
00156 ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable,
00157 ff_prores_progressive_scan);
00158 else
00159 ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable,
00160 ff_prores_interlaced_scan);
00161 ctx->scantable_type = ctx->frame_type;
00162 }
00163
00164 if (ctx->frame_type) {
00165 ctx->picture.interlaced_frame = 1;
00166 ctx->picture.top_field_first = ctx->frame_type & 1;
00167 }
00168
00169 avctx->color_primaries = buf[14];
00170 avctx->color_trc = buf[15];
00171 avctx->colorspace = buf[16];
00172
00173 ctx->alpha_info = buf[17] & 0xf;
00174 if (ctx->alpha_info)
00175 av_log_missing_feature(avctx, "Alpha channel", 0);
00176
00177 ctx->qmat_changed = 0;
00178 ptr = buf + 20;
00179 flags = buf[19];
00180 if (flags & 2) {
00181 if (ptr - buf > hdr_size - 64) {
00182 av_log(avctx, AV_LOG_ERROR, "header data too small\n");
00183 return AVERROR_INVALIDDATA;
00184 }
00185 if (memcmp(ctx->qmat_luma, ptr, 64)) {
00186 memcpy(ctx->qmat_luma, ptr, 64);
00187 ctx->qmat_changed = 1;
00188 }
00189 ptr += 64;
00190 } else {
00191 memset(ctx->qmat_luma, 4, 64);
00192 ctx->qmat_changed = 1;
00193 }
00194
00195 if (flags & 1) {
00196 if (ptr - buf > hdr_size - 64) {
00197 av_log(avctx, AV_LOG_ERROR, "header data too small\n");
00198 return -1;
00199 }
00200 if (memcmp(ctx->qmat_chroma, ptr, 64)) {
00201 memcpy(ctx->qmat_chroma, ptr, 64);
00202 ctx->qmat_changed = 1;
00203 }
00204 } else {
00205 memset(ctx->qmat_chroma, 4, 64);
00206 ctx->qmat_changed = 1;
00207 }
00208
00209 return hdr_size;
00210 }
00211
00212
00213 static int decode_picture_header(ProresContext *ctx, const uint8_t *buf,
00214 const int data_size, AVCodecContext *avctx)
00215 {
00216 int i, hdr_size, pic_data_size, num_slices;
00217 int slice_width_factor, slice_height_factor;
00218 int remainder, num_x_slices;
00219 const uint8_t *data_ptr, *index_ptr;
00220
00221 hdr_size = data_size > 0 ? buf[0] >> 3 : 0;
00222 if (hdr_size < 8 || hdr_size > data_size) {
00223 av_log(avctx, AV_LOG_ERROR, "picture header too small\n");
00224 return AVERROR_INVALIDDATA;
00225 }
00226
00227 pic_data_size = AV_RB32(buf + 1);
00228 if (pic_data_size > data_size) {
00229 av_log(avctx, AV_LOG_ERROR, "picture data too small\n");
00230 return AVERROR_INVALIDDATA;
00231 }
00232
00233 slice_width_factor = buf[7] >> 4;
00234 slice_height_factor = buf[7] & 0xF;
00235 if (slice_width_factor > 3 || slice_height_factor) {
00236 av_log(avctx, AV_LOG_ERROR,
00237 "unsupported slice dimension: %d x %d\n",
00238 1 << slice_width_factor, 1 << slice_height_factor);
00239 return AVERROR_INVALIDDATA;
00240 }
00241
00242 ctx->slice_width_factor = slice_width_factor;
00243 ctx->slice_height_factor = slice_height_factor;
00244
00245 ctx->num_x_mbs = (avctx->width + 15) >> 4;
00246 ctx->num_y_mbs = (avctx->height +
00247 (1 << (4 + ctx->picture.interlaced_frame)) - 1) >>
00248 (4 + ctx->picture.interlaced_frame);
00249
00250 remainder = ctx->num_x_mbs & ((1 << slice_width_factor) - 1);
00251 num_x_slices = (ctx->num_x_mbs >> slice_width_factor) + (remainder & 1) +
00252 ((remainder >> 1) & 1) + ((remainder >> 2) & 1);
00253
00254 num_slices = num_x_slices * ctx->num_y_mbs;
00255 if (num_slices != AV_RB16(buf + 5)) {
00256 av_log(avctx, AV_LOG_ERROR, "invalid number of slices\n");
00257 return AVERROR_INVALIDDATA;
00258 }
00259
00260 if (ctx->total_slices != num_slices) {
00261 av_freep(&ctx->slice_data);
00262 ctx->slice_data = av_malloc((num_slices + 1) * sizeof(ctx->slice_data[0]));
00263 if (!ctx->slice_data)
00264 return AVERROR(ENOMEM);
00265 ctx->total_slices = num_slices;
00266 }
00267
00268 if (hdr_size + num_slices * 2 > data_size) {
00269 av_log(avctx, AV_LOG_ERROR, "slice table too small\n");
00270 return AVERROR_INVALIDDATA;
00271 }
00272
00273
00274 index_ptr = buf + hdr_size;
00275 data_ptr = index_ptr + num_slices * 2;
00276
00277 for (i = 0; i < num_slices; i++) {
00278 ctx->slice_data[i].index = data_ptr;
00279 ctx->slice_data[i].prev_slice_sf = 0;
00280 data_ptr += AV_RB16(index_ptr + i * 2);
00281 }
00282 ctx->slice_data[i].index = data_ptr;
00283 ctx->slice_data[i].prev_slice_sf = 0;
00284
00285 if (data_ptr > buf + data_size) {
00286 av_log(avctx, AV_LOG_ERROR, "out of slice data\n");
00287 return -1;
00288 }
00289
00290 return pic_data_size;
00291 }
00292
00293
00297 static inline int decode_vlc_codeword(GetBitContext *gb, unsigned codebook)
00298 {
00299 unsigned int rice_order, exp_order, switch_bits;
00300 unsigned int buf, code;
00301 int log, prefix_len, len;
00302
00303 OPEN_READER(re, gb);
00304 UPDATE_CACHE(re, gb);
00305 buf = GET_CACHE(re, gb);
00306
00307
00308 switch_bits = (codebook & 3) + 1;
00309 rice_order = codebook >> 5;
00310 exp_order = (codebook >> 2) & 7;
00311
00312 log = 31 - av_log2(buf);
00313
00314 if (log < switch_bits) {
00315 if (!rice_order) {
00316
00317 code = log;
00318 LAST_SKIP_BITS(re, gb, log + 1);
00319 } else {
00320 prefix_len = log + 1;
00321 code = (log << rice_order) + NEG_USR32(buf << prefix_len, rice_order);
00322 LAST_SKIP_BITS(re, gb, prefix_len + rice_order);
00323 }
00324 } else {
00325 len = (log << 1) - switch_bits + exp_order + 1;
00326 code = NEG_USR32(buf, len) - (1 << exp_order) + (switch_bits << rice_order);
00327 LAST_SKIP_BITS(re, gb, len);
00328 }
00329
00330 CLOSE_READER(re, gb);
00331
00332 return code;
00333 }
00334
00335 #define LSB2SIGN(x) (-((x) & 1))
00336 #define TOSIGNED(x) (((x) >> 1) ^ LSB2SIGN(x))
00337
00341 static inline void decode_dc_coeffs(GetBitContext *gb, DCTELEM *out,
00342 int nblocks)
00343 {
00344 DCTELEM prev_dc;
00345 int i, sign;
00346 int16_t delta;
00347 unsigned int code;
00348
00349 code = decode_vlc_codeword(gb, FIRST_DC_CB);
00350 out[0] = prev_dc = TOSIGNED(code);
00351
00352 out += 64;
00353 delta = 3;
00354
00355 for (i = 1; i < nblocks; i++, out += 64) {
00356 code = decode_vlc_codeword(gb, ff_prores_dc_codebook[FFMIN(FFABS(delta), 3)]);
00357
00358 sign = -(((delta >> 15) & 1) ^ (code & 1));
00359 delta = (((code + 1) >> 1) ^ sign) - sign;
00360 prev_dc += delta;
00361 out[0] = prev_dc;
00362 }
00363 }
00364
00365
00369 static inline void decode_ac_coeffs(GetBitContext *gb, DCTELEM *out,
00370 int blocks_per_slice,
00371 int plane_size_factor,
00372 const uint8_t *scan)
00373 {
00374 int pos, block_mask, run, level, sign, run_cb_index, lev_cb_index;
00375 int max_coeffs, bits_left;
00376
00377
00378 run = 4;
00379 level = 2;
00380
00381 max_coeffs = blocks_per_slice << 6;
00382 block_mask = blocks_per_slice - 1;
00383
00384 for (pos = blocks_per_slice - 1; pos < max_coeffs;) {
00385 run_cb_index = ff_prores_run_to_cb_index[FFMIN(run, 15)];
00386 lev_cb_index = ff_prores_lev_to_cb_index[FFMIN(level, 9)];
00387
00388 bits_left = get_bits_left(gb);
00389 if (bits_left <= 0 || (bits_left <= 8 && !show_bits(gb, bits_left)))
00390 return;
00391
00392 run = decode_vlc_codeword(gb, ff_prores_ac_codebook[run_cb_index]);
00393
00394 bits_left = get_bits_left(gb);
00395 if (bits_left <= 0 || (bits_left <= 8 && !show_bits(gb, bits_left)))
00396 return;
00397
00398 level = decode_vlc_codeword(gb, ff_prores_ac_codebook[lev_cb_index]) + 1;
00399
00400 pos += run + 1;
00401 if (pos >= max_coeffs)
00402 break;
00403
00404 sign = get_sbits(gb, 1);
00405 out[((pos & block_mask) << 6) + scan[pos >> plane_size_factor]] =
00406 (level ^ sign) - sign;
00407 }
00408 }
00409
00410
00414 static void decode_slice_plane(ProresContext *ctx, ProresThreadData *td,
00415 const uint8_t *buf,
00416 int data_size, uint16_t *out_ptr,
00417 int linesize, int mbs_per_slice,
00418 int blocks_per_mb, int plane_size_factor,
00419 const int16_t *qmat, int is_chroma)
00420 {
00421 GetBitContext gb;
00422 DCTELEM *block_ptr;
00423 int mb_num, blocks_per_slice;
00424
00425 blocks_per_slice = mbs_per_slice * blocks_per_mb;
00426
00427 memset(td->blocks, 0, 8 * 4 * 64 * sizeof(*td->blocks));
00428
00429 init_get_bits(&gb, buf, data_size << 3);
00430
00431 decode_dc_coeffs(&gb, td->blocks, blocks_per_slice);
00432
00433 decode_ac_coeffs(&gb, td->blocks, blocks_per_slice,
00434 plane_size_factor, ctx->scantable.permutated);
00435
00436
00437 block_ptr = td->blocks;
00438
00439 if (!is_chroma) {
00440 for (mb_num = 0; mb_num < mbs_per_slice; mb_num++, out_ptr += blocks_per_mb * 4) {
00441 ctx->dsp.idct_put(out_ptr, linesize, block_ptr, qmat);
00442 block_ptr += 64;
00443 if (blocks_per_mb > 2) {
00444 ctx->dsp.idct_put(out_ptr + 8, linesize, block_ptr, qmat);
00445 block_ptr += 64;
00446 }
00447 ctx->dsp.idct_put(out_ptr + linesize * 4, linesize, block_ptr, qmat);
00448 block_ptr += 64;
00449 if (blocks_per_mb > 2) {
00450 ctx->dsp.idct_put(out_ptr + linesize * 4 + 8, linesize, block_ptr, qmat);
00451 block_ptr += 64;
00452 }
00453 }
00454 } else {
00455 for (mb_num = 0; mb_num < mbs_per_slice; mb_num++, out_ptr += blocks_per_mb * 4) {
00456 ctx->dsp.idct_put(out_ptr, linesize, block_ptr, qmat);
00457 block_ptr += 64;
00458 ctx->dsp.idct_put(out_ptr + linesize * 4, linesize, block_ptr, qmat);
00459 block_ptr += 64;
00460 if (blocks_per_mb > 2) {
00461 ctx->dsp.idct_put(out_ptr + 8, linesize, block_ptr, qmat);
00462 block_ptr += 64;
00463 ctx->dsp.idct_put(out_ptr + linesize * 4 + 8, linesize, block_ptr, qmat);
00464 block_ptr += 64;
00465 }
00466 }
00467 }
00468 }
00469
00470
00471 static int decode_slice(AVCodecContext *avctx, void *tdata)
00472 {
00473 ProresThreadData *td = tdata;
00474 ProresContext *ctx = avctx->priv_data;
00475 int mb_x_pos = td->x_pos;
00476 int mb_y_pos = td->y_pos;
00477 int pic_num = ctx->pic_num;
00478 int slice_num = td->slice_num;
00479 int mbs_per_slice = td->slice_width;
00480 const uint8_t *buf;
00481 uint8_t *y_data, *u_data, *v_data;
00482 AVFrame *pic = avctx->coded_frame;
00483 int i, sf, slice_width_factor;
00484 int slice_data_size, hdr_size, y_data_size, u_data_size, v_data_size;
00485 int y_linesize, u_linesize, v_linesize;
00486
00487 buf = ctx->slice_data[slice_num].index;
00488 slice_data_size = ctx->slice_data[slice_num + 1].index - buf;
00489
00490 slice_width_factor = av_log2(mbs_per_slice);
00491
00492 y_data = pic->data[0];
00493 u_data = pic->data[1];
00494 v_data = pic->data[2];
00495 y_linesize = pic->linesize[0];
00496 u_linesize = pic->linesize[1];
00497 v_linesize = pic->linesize[2];
00498
00499 if (pic->interlaced_frame) {
00500 if (!(pic_num ^ pic->top_field_first)) {
00501 y_data += y_linesize;
00502 u_data += u_linesize;
00503 v_data += v_linesize;
00504 }
00505 y_linesize <<= 1;
00506 u_linesize <<= 1;
00507 v_linesize <<= 1;
00508 }
00509
00510 if (slice_data_size < 6) {
00511 av_log(avctx, AV_LOG_ERROR, "slice data too small\n");
00512 return AVERROR_INVALIDDATA;
00513 }
00514
00515
00516 hdr_size = buf[0] >> 3;
00517 y_data_size = AV_RB16(buf + 2);
00518 u_data_size = AV_RB16(buf + 4);
00519 v_data_size = hdr_size > 7 ? AV_RB16(buf + 6) :
00520 slice_data_size - y_data_size - u_data_size - hdr_size;
00521
00522 if (hdr_size + y_data_size + u_data_size + v_data_size > slice_data_size ||
00523 v_data_size < 0 || hdr_size < 6) {
00524 av_log(avctx, AV_LOG_ERROR, "invalid data size\n");
00525 return AVERROR_INVALIDDATA;
00526 }
00527
00528 sf = av_clip(buf[1], 1, 224);
00529 sf = sf > 128 ? (sf - 96) << 2 : sf;
00530
00531
00532
00533 if (ctx->qmat_changed || sf != td->prev_slice_sf) {
00534 td->prev_slice_sf = sf;
00535 for (i = 0; i < 64; i++) {
00536 td->qmat_luma_scaled[ctx->dsp.idct_permutation[i]] = ctx->qmat_luma[i] * sf;
00537 td->qmat_chroma_scaled[ctx->dsp.idct_permutation[i]] = ctx->qmat_chroma[i] * sf;
00538 }
00539 }
00540
00541
00542 decode_slice_plane(ctx, td, buf + hdr_size, y_data_size,
00543 (uint16_t*) (y_data + (mb_y_pos << 4) * y_linesize +
00544 (mb_x_pos << 5)), y_linesize,
00545 mbs_per_slice, 4, slice_width_factor + 2,
00546 td->qmat_luma_scaled, 0);
00547
00548
00549 decode_slice_plane(ctx, td, buf + hdr_size + y_data_size, u_data_size,
00550 (uint16_t*) (u_data + (mb_y_pos << 4) * u_linesize +
00551 (mb_x_pos << ctx->mb_chroma_factor)),
00552 u_linesize, mbs_per_slice, ctx->num_chroma_blocks,
00553 slice_width_factor + ctx->chroma_factor - 1,
00554 td->qmat_chroma_scaled, 1);
00555
00556
00557 decode_slice_plane(ctx, td, buf + hdr_size + y_data_size + u_data_size,
00558 v_data_size,
00559 (uint16_t*) (v_data + (mb_y_pos << 4) * v_linesize +
00560 (mb_x_pos << ctx->mb_chroma_factor)),
00561 v_linesize, mbs_per_slice, ctx->num_chroma_blocks,
00562 slice_width_factor + ctx->chroma_factor - 1,
00563 td->qmat_chroma_scaled, 1);
00564
00565 return 0;
00566 }
00567
00568
00569 static int decode_picture(ProresContext *ctx, int pic_num,
00570 AVCodecContext *avctx)
00571 {
00572 int slice_num, slice_width, x_pos, y_pos;
00573
00574 slice_num = 0;
00575
00576 ctx->pic_num = pic_num;
00577 for (y_pos = 0; y_pos < ctx->num_y_mbs; y_pos++) {
00578 slice_width = 1 << ctx->slice_width_factor;
00579
00580 for (x_pos = 0; x_pos < ctx->num_x_mbs && slice_width;
00581 x_pos += slice_width) {
00582 while (ctx->num_x_mbs - x_pos < slice_width)
00583 slice_width >>= 1;
00584
00585 ctx->slice_data[slice_num].slice_num = slice_num;
00586 ctx->slice_data[slice_num].x_pos = x_pos;
00587 ctx->slice_data[slice_num].y_pos = y_pos;
00588 ctx->slice_data[slice_num].slice_width = slice_width;
00589
00590 slice_num++;
00591 }
00592 }
00593
00594 return avctx->execute(avctx, decode_slice,
00595 ctx->slice_data, NULL, slice_num,
00596 sizeof(ctx->slice_data[0]));
00597 }
00598
00599
00600 #define MOVE_DATA_PTR(nbytes) buf += (nbytes); buf_size -= (nbytes)
00601
00602 static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
00603 AVPacket *avpkt)
00604 {
00605 ProresContext *ctx = avctx->priv_data;
00606 AVFrame *picture = avctx->coded_frame;
00607 const uint8_t *buf = avpkt->data;
00608 int buf_size = avpkt->size;
00609 int frame_hdr_size, pic_num, pic_data_size;
00610
00611
00612 if (buf_size < 28 || buf_size < AV_RB32(buf) ||
00613 AV_RB32(buf + 4) != FRAME_ID) {
00614 av_log(avctx, AV_LOG_ERROR, "invalid frame\n");
00615 return AVERROR_INVALIDDATA;
00616 }
00617
00618 MOVE_DATA_PTR(8);
00619
00620 frame_hdr_size = decode_frame_header(ctx, buf, buf_size, avctx);
00621 if (frame_hdr_size < 0)
00622 return AVERROR_INVALIDDATA;
00623
00624 MOVE_DATA_PTR(frame_hdr_size);
00625
00626 if (picture->data[0])
00627 avctx->release_buffer(avctx, picture);
00628
00629 picture->reference = 0;
00630 if (ff_get_buffer(avctx, picture) < 0)
00631 return -1;
00632
00633 for (pic_num = 0; ctx->picture.interlaced_frame - pic_num + 1; pic_num++) {
00634 pic_data_size = decode_picture_header(ctx, buf, buf_size, avctx);
00635 if (pic_data_size < 0)
00636 return AVERROR_INVALIDDATA;
00637
00638 if (decode_picture(ctx, pic_num, avctx))
00639 return -1;
00640
00641 MOVE_DATA_PTR(pic_data_size);
00642 }
00643
00644 *got_frame = 1;
00645 *(AVFrame*) data = *avctx->coded_frame;
00646
00647 return avpkt->size;
00648 }
00649
00650
00651 static av_cold int decode_close(AVCodecContext *avctx)
00652 {
00653 ProresContext *ctx = avctx->priv_data;
00654
00655 if (ctx->picture.data[0])
00656 avctx->release_buffer(avctx, &ctx->picture);
00657
00658 av_freep(&ctx->slice_data);
00659
00660 return 0;
00661 }
00662
00663
00664 AVCodec ff_prores_lgpl_decoder = {
00665 .name = "prores_lgpl",
00666 .type = AVMEDIA_TYPE_VIDEO,
00667 .id = AV_CODEC_ID_PRORES,
00668 .priv_data_size = sizeof(ProresContext),
00669 .init = decode_init,
00670 .close = decode_close,
00671 .decode = decode_frame,
00672 .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS,
00673 .long_name = NULL_IF_CONFIG_SMALL("Apple ProRes (iCodec Pro)")
00674 };