return get_ue_golomb(gb);
}
-static inline int dequant(AVSContext *h, DCTELEM *level_buf, uint8_t *run_buf,
- DCTELEM *dst, int mul, int shift, int coeff_num)
+static inline int dequant(AVSContext *h, int16_t *level_buf, uint8_t *run_buf,
+ int16_t *dst, int mul, int shift, int coeff_num)
{
int round = 1 << (shift - 1);
int pos = -1;
int qp, uint8_t *dst, int stride)
{
int i, level_code, esc_code, level, run, mask;
- DCTELEM level_buf[65];
+ int16_t level_buf[65];
uint8_t run_buf[65];
- DCTELEM *block = h->block;
+ int16_t *block = h->block;
for (i = 0;i < 65; i++) {
level_code = get_ue_code(gb, r->golomb_order);
set_mvs(&h->mv[MV_FWD_X0], BLK_16X16);
h->mv[MV_BWD_X0] = ff_cavs_intra_mv;
set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);
- if (h->pic_type != AV_PICTURE_TYPE_B)
+ if (h->cur.f->pict_type != AV_PICTURE_TYPE_B)
h->col_type_base[h->mbidx] = I_8X8;
}
ff_cavs_modify_mb_i(h, &pred_mode_uv);
/* get coded block pattern */
- if (h->pic_type == AV_PICTURE_TYPE_I)
+ if (h->cur.f->pict_type == AV_PICTURE_TYPE_I)
cbp_code = get_ue_golomb(gb);
if (cbp_code > 63) {
av_log(h->avctx, AV_LOG_ERROR, "illegal intra cbp\n");
h->qp = get_bits(gb, 6);
}
/* inter frame or second slice can have weighting params */
- if ((h->pic_type != AV_PICTURE_TYPE_I) ||
+ if ((h->cur.f->pict_type != AV_PICTURE_TYPE_I) ||
(!h->pic_structure && h->mby >= h->mb_width / 2))
if (get_bits1(gb)) { //slice_weighting_flag
av_log(h->avctx, AV_LOG_ERROR,
int skip_count = -1;
enum cavs_mb mb_type;
+ if (!h->top_qp) {
+ av_log(h->avctx, AV_LOG_ERROR, "No sequence header decoded yet\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ av_frame_unref(h->cur.f);
+
skip_bits(&h->gb, 16);//bbv_dwlay
if (h->stc == PIC_PB_START_CODE) {
- h->pic_type = get_bits(&h->gb, 2) + AV_PICTURE_TYPE_I;
- if (h->pic_type > AV_PICTURE_TYPE_B) {
+ h->cur.f->pict_type = get_bits(&h->gb, 2) + AV_PICTURE_TYPE_I;
+ if (h->cur.f->pict_type > AV_PICTURE_TYPE_B) {
av_log(h->avctx, AV_LOG_ERROR, "illegal picture type\n");
return -1;
}
/* make sure we have the reference frames we need */
if (!h->DPB[0].f->data[0] ||
- (!h->DPB[1].f->data[0] && h->pic_type == AV_PICTURE_TYPE_B))
+ (!h->DPB[1].f->data[0] && h->cur.f->pict_type == AV_PICTURE_TYPE_B))
return -1;
} else {
- h->pic_type = AV_PICTURE_TYPE_I;
+ h->cur.f->pict_type = AV_PICTURE_TYPE_I;
if (get_bits1(&h->gb))
skip_bits(&h->gb, 24);//time_code
/* old sample clips were all progressive and no low_delay,
if (h->stream_revision > 0)
skip_bits(&h->gb, 1); //marker_bit
}
- /* release last B frame */
- if (h->cur.f->data[0])
- h->avctx->release_buffer(h->avctx, h->cur.f);
- ff_get_buffer(h->avctx, h->cur.f);
+ ff_get_buffer(h->avctx, h->cur.f, h->cur.f->pict_type == AV_PICTURE_TYPE_B ?
+ 0 : AV_GET_BUFFER_FLAG_REF);
if (!h->edge_emu_buffer) {
int alloc_size = FFALIGN(FFABS(h->cur.f->linesize[0]) + 32, 32);
h->cur.poc = get_bits(&h->gb, 8) * 2;
/* get temporal distances and MV scaling factors */
- if (h->pic_type != AV_PICTURE_TYPE_B) {
+ if (h->cur.f->pict_type != AV_PICTURE_TYPE_B) {
h->dist[0] = (h->cur.poc - h->DPB[0].poc + 512) % 512;
} else {
h->dist[0] = (h->DPB[0].poc - h->cur.poc + 512) % 512;
h->dist[1] = (h->cur.poc - h->DPB[1].poc + 512) % 512;
h->scale_den[0] = h->dist[0] ? 512/h->dist[0] : 0;
h->scale_den[1] = h->dist[1] ? 512/h->dist[1] : 0;
- if (h->pic_type == AV_PICTURE_TYPE_B) {
+ if (h->cur.f->pict_type == AV_PICTURE_TYPE_B) {
h->sym_factor = h->dist[0] * h->scale_den[1];
} else {
h->direct_den[0] = h->dist[0] ? 16384 / h->dist[0] : 0;
skip_bits1(&h->gb); //repeat_first_field
h->qp_fixed = get_bits1(&h->gb);
h->qp = get_bits(&h->gb, 6);
- if (h->pic_type == AV_PICTURE_TYPE_I) {
+ if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) {
if (!h->progressive && !h->pic_structure)
skip_bits1(&h->gb);//what is this?
skip_bits(&h->gb, 4); //reserved bits
} else {
- if (!(h->pic_type == AV_PICTURE_TYPE_B && h->pic_structure == 1))
+ if (!(h->cur.f->pict_type == AV_PICTURE_TYPE_B && h->pic_structure == 1))
h->ref_flag = get_bits1(&h->gb);
skip_bits(&h->gb, 4); //reserved bits
h->skip_mode_flag = get_bits1(&h->gb);
} else {
h->alpha_offset = h->beta_offset = 0;
}
- if (h->pic_type == AV_PICTURE_TYPE_I) {
+ if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) {
do {
check_for_slice(h);
decode_mb_i(h, 0);
} while (ff_cavs_next_mb(h));
- } else if (h->pic_type == AV_PICTURE_TYPE_P) {
+ } else if (h->cur.f->pict_type == AV_PICTURE_TYPE_P) {
do {
if (check_for_slice(h))
skip_count = -1;
}
} while (ff_cavs_next_mb(h));
}
- if (h->pic_type != AV_PICTURE_TYPE_B) {
- if (h->DPB[1].f->data[0])
- h->avctx->release_buffer(h->avctx, h->DPB[1].f);
+ if (h->cur.f->pict_type != AV_PICTURE_TYPE_B) {
+ av_frame_unref(h->DPB[1].f);
FFSWAP(AVSFrame, h->cur, h->DPB[1]);
FFSWAP(AVSFrame, h->DPB[0], h->DPB[1]);
}
width = get_bits(&h->gb, 14);
height = get_bits(&h->gb, 14);
if ((h->width || h->height) && (h->width != width || h->height != height)) {
- av_log_missing_feature(h->avctx, "Width/height changing in CAVS", 0);
+ avpriv_report_missing_feature(h->avctx,
+ "Width/height changing in CAVS");
return AVERROR_PATCHWELCOME;
}
h->width = width;
AVSContext *h = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
- AVFrame *picture = data;
uint32_t stc = -1;
- int input_size;
+ int input_size, ret;
const uint8_t *buf_end;
const uint8_t *buf_ptr;
if (buf_size == 0) {
if (!h->low_delay && h->DPB[0].f->data[0]) {
*got_frame = 1;
- *picture = *h->DPB[0].f;
- if (h->cur.f->data[0])
- avctx->release_buffer(avctx, h->cur.f);
- FFSWAP(AVSFrame, h->cur, h->DPB[0]);
+ av_frame_move_ref(data, h->DPB[0].f);
}
return 0;
}
buf_ptr = buf;
buf_end = buf + buf_size;
for(;;) {
- buf_ptr = avpriv_mpv_find_start_code(buf_ptr, buf_end, &stc);
+ buf_ptr = avpriv_find_start_code(buf_ptr, buf_end, &stc);
if ((stc & 0xFFFFFE00) || buf_ptr == buf_end)
return FFMAX(0, buf_ptr - buf);
input_size = (buf_end - buf_ptr) * 8;
break;
case PIC_I_START_CODE:
if (!h->got_keyframe) {
- if(h->DPB[0].f->data[0])
- avctx->release_buffer(avctx, h->DPB[0].f);
- if(h->DPB[1].f->data[0])
- avctx->release_buffer(avctx, h->DPB[1].f);
+ av_frame_unref(h->DPB[0].f);
+ av_frame_unref(h->DPB[1].f);
h->got_keyframe = 1;
}
case PIC_PB_START_CODE:
if (decode_pic(h))
break;
*got_frame = 1;
- if (h->pic_type != AV_PICTURE_TYPE_B) {
+ if (h->cur.f->pict_type != AV_PICTURE_TYPE_B) {
if (h->DPB[1].f->data[0]) {
- *picture = *h->DPB[1].f;
+ if ((ret = av_frame_ref(data, h->DPB[1].f)) < 0)
+ return ret;
} else {
*got_frame = 0;
}
- } else
- *picture = *h->cur.f;
+ } else {
+ av_frame_move_ref(data, h->cur.f);
+ }
break;
case EXT_START_CODE:
//mpeg_decode_extension(avctx, buf_ptr, input_size);