/*
- * ITU H263 bitstream decoder
+ * ITU H.263 bitstream decoder
* Copyright (c) 2000,2001 Fabrice Bellard
- * H263+ support.
+ * H.263+ support.
* Copyright (c) 2001 Juan J. Sierralta P
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
*
/**
* @file
- * h263 decoder.
+ * H.263 decoder.
*/
#include <limits.h>
#include "libavutil/attributes.h"
+#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/mathematics.h"
#include "avcodec.h"
#include "internal.h"
#include "mathops.h"
#include "mpegutils.h"
-#include "unary.h"
+#include "unary_legacy.h"
#include "flv.h"
#include "rv10.h"
#include "mpeg4video.h"
{
int i, mb_pos;
- for(i=0; i<6; i++){
- if(s->mb_num-1 <= ff_mba_max[i]) break;
- }
- mb_pos= get_bits(&s->gb, ff_mba_length[i]);
- s->mb_x= mb_pos % s->mb_width;
- s->mb_y= mb_pos / s->mb_width;
+ for (i = 0; i < 6; i++)
+ if (s->mb_num - 1 <= ff_mba_max[i])
+ break;
+ mb_pos = get_bits(&s->gb, ff_mba_length[i]);
+ s->mb_x = mb_pos % s->mb_width;
+ s->mb_y = mb_pos / s->mb_width;
return mb_pos;
}
if (!s->h263_long_vectors) {
val = sign_extend(val, 5 + f_code);
} else {
- /* horrible h263 long vector mode */
+ /* horrible H.263 long vector mode */
if (pred < -31 && val < -63)
val += 64;
if (pred > 32 && val > 63)
return SLICE_OK;
}
-/* most is hardcoded. should extend to handle all h263 streams */
+/* Most is hardcoded; should extend to handle all H.263 streams. */
int ff_h263_decode_picture_header(MpegEncContext *s)
{
- int format, width, height, i;
+ int format, width, height, i, ret;
uint32_t startcode;
align_get_bits(&s->gb);
return -1;
}
if (get_bits1(&s->gb) != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
- return -1; /* h263 id */
+ av_log(s->avctx, AV_LOG_ERROR, "Bad H.263 id\n");
+ return -1; /* H.263 id */
}
skip_bits1(&s->gb); /* split screen off */
skip_bits1(&s->gb); /* camera off */
/* H.263v1 */
width = ff_h263_format[format][0];
height = ff_h263_format[format][1];
- if (!width)
- return -1;
s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb);
s->h263_long_vectors = get_bits1(&s->gb);
if (get_bits1(&s->gb) != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "H263 SAC not supported\n");
+ av_log(s->avctx, AV_LOG_ERROR, "H.263 SAC not supported\n");
return -1; /* SAC: off */
}
s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
height = get_bits(&s->gb, 9) * 4;
ff_dlog(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height);
if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
- /* aspected dimensions */
+ /* expected dimensions */
s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);
s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8);
}else{
s->qscale = get_bits(&s->gb, 5);
}
+ if ((ret = av_image_check_size(s->width, s->height, 0, s)) < 0)
+ return ret;
+
s->mb_width = (s->width + 15) / 16;
s->mb_height = (s->height + 15) / 16;
s->mb_num = s->mb_width * s->mb_height;