#include "avcodec.h"
#include "mpegutils.h"
#include "h264.h"
- #include "h264_mvpred.h"
+#include "h264data.h"
#include "golomb.h"
#include "hpeldsp.h"
#include "mathops.h"
for (i = 0; i < 16; i += 2) {
vlc = svq3_get_ue_golomb(&s->gb_slice);
- if (vlc >= 25) {
+ if (vlc >= 25U) {
- av_log(h->avctx, AV_LOG_ERROR,
+ av_log(s->avctx, AV_LOG_ERROR,
"luma prediction:%"PRIu32"\n", vlc);
return -1;
}
if (!IS_INTRA16x16(mb_type) &&
(!IS_SKIP(mb_type) || s->pict_type == AV_PICTURE_TYPE_B)) {
- if ((vlc = svq3_get_ue_golomb(&s->gb_slice)) >= 48) {
+ if ((vlc = svq3_get_ue_golomb(&s->gb_slice)) >= 48U){
- av_log(h->avctx, AV_LOG_ERROR, "cbp_vlc=%"PRIu32"\n", vlc);
+ av_log(s->avctx, AV_LOG_ERROR, "cbp_vlc=%"PRIu32"\n", vlc);
return -1;
}
ff_h264_pred_init(&s->hpc, AV_CODEC_ID_SVQ3, 8, 1);
ff_videodsp_init(&s->vdsp, 8);
- h->sps.bit_depth_luma = 8;
- h->chroma_format_idc = 1;
+
+ avctx->bits_per_raw_sample = 8;
+
ff_hpeldsp_init(&s->hdsp, avctx->flags);
ff_tpeldsp_init(&s->tdsp);
avctx->pix_fmt = AV_PIX_FMT_YUVJ420P;
avctx->color_range = AVCOL_RANGE_JPEG;
- h->chroma_x_shift = h->chroma_y_shift = 1;
-
+ s->avctx = avctx;
s->halfpel_flag = 1;
s->thirdpel_flag = 1;
- s->unknown_flag = 0;
+ s->has_watermark = 0;
/* prowl for the "SEQH" marker in the extradata */
extradata = (unsigned char *)avctx->extradata;
s->thirdpel_flag = get_bits1(&gb);
/* unknown fields */
- skip_bits1(&gb);
- skip_bits1(&gb);
- skip_bits1(&gb);
- skip_bits1(&gb);
+ unk0 = get_bits1(&gb);
+ unk1 = get_bits1(&gb);
+ unk2 = get_bits1(&gb);
+ unk3 = get_bits1(&gb);
- h->low_delay = get_bits1(&gb);
+ s->low_delay = get_bits1(&gb);
/* unknown field */
- skip_bits1(&gb);
+ unk4 = get_bits1(&gb);
- while (get_bits1(&gb))
- skip_bits(&gb, 8);
+ av_log(avctx, AV_LOG_DEBUG, "Unknown fields %d %d %d %d %d\n",
+ unk0, unk1, unk2, unk3, unk4);
- s->unknown_flag = get_bits1(&gb);
+ if (skip_1stop_8data_bits(&gb) < 0) {
+ ret = AVERROR_INVALIDDATA;
+ goto fail;
+ }
+
+ s->has_watermark = get_bits1(&gb);
- avctx->has_b_frames = !h->low_delay;
+ avctx->has_b_frames = !s->low_delay;
- if (s->unknown_flag) {
+ if (s->has_watermark) {
#if CONFIG_ZLIB
unsigned watermark_width = svq3_get_ue_golomb(&gb);
unsigned watermark_height = svq3_get_ue_golomb(&gb);
static int svq3_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
- const uint8_t *buf = avpkt->data;
SVQ3Context *s = avctx->priv_data;
- H264Context *h = &s->h;
int buf_size = avpkt->size;
+ int left;
+ uint8_t *buf;
int ret, m, i;
/* special case for last picture */
return -1;
}
- if (mb_type != 0)
+ if (mb_type != 0 || s->cbp)
- hl_decode_mb(s, h);
+ hl_decode_mb(s);
- if (s->pict_type != AV_PICTURE_TYPE_B && !h->low_delay)
+ if (s->pict_type != AV_PICTURE_TYPE_B && !s->low_delay)
s->cur_pic->mb_type[s->mb_x + s->mb_y * s->mb_stride] =
(s->pict_type == AV_PICTURE_TYPE_P && mb_type < 8) ? (mb_type - 1) : -1;
}
ff_draw_horiz_band(avctx, s->cur_pic->f,
s->last_pic->f->data[0] ? s->last_pic->f : NULL,
- 16 * s->mb_y, 16, h->picture_structure, 0,
- h->low_delay);
+ 16 * s->mb_y, 16, PICT_FRAME, 0,
+ s->low_delay);
}
- if (s->mb_y != h->mb_height || s->mb_x != h->mb_width) {
+ left = buf_size*8 - get_bits_count(&s->gb_slice);
+
- if (s->pict_type == AV_PICTURE_TYPE_B || h->low_delay)
++ if (s->mb_y != s->mb_height || s->mb_x != s->mb_width) {
+ av_log(avctx, AV_LOG_INFO, "frame num %d incomplete pic x %d y %d left %d\n", avctx->frame_number, s->mb_y, s->mb_x, left);
+ //av_hex_dump(stderr, buf+buf_size-8, 8);
+ }
+
+ if (left < 0) {
+ av_log(avctx, AV_LOG_ERROR, "frame num %d left %d\n", avctx->frame_number, left);
+ return -1;
+ }
+
+ if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay)
ret = av_frame_ref(data, s->cur_pic->f);
else if (s->last_pic->f->data[0])
ret = av_frame_ref(data, s->last_pic->f);
av_freep(&s->edge_emu_buffer);
av_freep(&s->mb2br_xy);
- ff_h264_free_context(h);
+
+ av_freep(&s->buf);
+ s->buf_size = 0;
+
return 0;
}