#include "libavutil/imgutils.h"
#include "avcodec.h"
-#include "dsputil.h"
+#include "error_resilience.h"
#include "mpegvideo.h"
#include "mpeg4video.h"
#include "h263.h"
mb_pos = ff_h263_decode_mba(s);
-//av_log(s->avctx, AV_LOG_DEBUG, "%d\n", seq);
seq |= s->time &~0x7FFF;
if(seq - s->time > 0x4000) seq -= 0x8000;
if(seq - s->time < -0x4000) seq += 0x8000;
ff_mpeg4_init_direct_mv(s);
}
}
-// printf("%d %d %d %d %d\n", seq, (int)s->time, (int)s->last_non_b_time, s->pp_time, s->pb_time);
-/*for(i=0; i<32; i++){
- av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
-}
-av_log(s->avctx, AV_LOG_DEBUG, "\n");*/
+
s->no_rounding= get_bits1(&s->gb);
if(RV_GET_MINOR_VER(rv->sub_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B)
// s->obmc=1;
// s->umvplus=1;
s->modified_quant=1;
- if(!s->avctx->lowres)
- s->loop_filter=1;
+ s->loop_filter=1;
if(s->avctx->debug & FF_DEBUG_PICT_INFO){
av_log(s->avctx, AV_LOG_INFO, "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n",
av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%X\n", rv->sub_id, avctx->extradata_size >= 4 ? ((uint32_t*)avctx->extradata)[0] : -1);
}
- avctx->pix_fmt = PIX_FMT_YUV420P;
+ avctx->pix_fmt = AV_PIX_FMT_YUV420P;
if (ff_MPV_common_init(s) < 0)
return -1;
- ff_h263_decode_init_vlc(s);
+ ff_h263_decode_init_vlc();
/* init rv vlc */
if (!done) {
active_bits_size = buf_size * 8;
init_get_bits(&s->gb, buf, FFMAX(buf_size, buf_size2) * 8);
- if(s->codec_id ==CODEC_ID_RV10)
+ if(s->codec_id ==AV_CODEC_ID_RV10)
mb_count = rv10_decode_picture_header(s);
else
mb_count = rv20_decode_picture_header(rv);
if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) {
if(s->current_picture_ptr){ //FIXME write parser so we always have complete frames?
- ff_er_frame_end(s);
+ ff_er_frame_end(&s->er);
ff_MPV_frame_end(s);
s->mb_x= s->mb_y = s->resync_mb_x = s->resync_mb_y= 0;
}
if(ff_MPV_frame_start(s, avctx) < 0)
return -1;
- ff_er_frame_start(s);
+ ff_mpeg_er_frame_start(s);
} else {
if (s->current_picture_ptr->f.pict_type != s->pict_type) {
av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
av_dlog(avctx, "qscale=%d\n", s->qscale);
/* default quantization values */
- if(s->codec_id== CODEC_ID_RV10){
+ if(s->codec_id== AV_CODEC_ID_RV10){
if(s->mb_y==0) s->first_slice_line=1;
}else{
s->first_slice_line=1;
if(ret == SLICE_END) break;
}
- ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
+ ff_er_add_slice(&s->er, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
return active_bits_size;
}
}
static int rv10_decode_frame(AVCodecContext *avctx,
- void *data, int *data_size,
+ void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *s = avctx->priv_data;
- int i;
+ int i, ret;
AVFrame *pict = data;
int slice_count;
const uint8_t *slices_hdr = NULL;
if(!avctx->slice_count){
slice_count = (*buf++) + 1;
buf_size--;
+
+ if (!slice_count || buf_size <= 8 * slice_count) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid slice count: %d.\n", slice_count);
+ return AVERROR_INVALIDDATA;
+ }
+
slices_hdr = buf + 4;
buf += 8 * slice_count;
buf_size -= 8 * slice_count;
- if (buf_size <= 0)
- return AVERROR_INVALIDDATA;
}else
slice_count = avctx->slice_count;
}
if(s->current_picture_ptr != NULL && s->mb_y>=s->mb_height){
- ff_er_frame_end(s);
+ ff_er_frame_end(&s->er);
ff_MPV_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
- *pict = s->current_picture_ptr->f;
+ if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
+ return ret;
+ ff_print_debug_info(s, s->current_picture_ptr);
} else if (s->last_picture_ptr != NULL) {
- *pict = s->last_picture_ptr->f;
+ if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
+ return ret;
+ ff_print_debug_info(s, s->last_picture_ptr);
}
if(s->last_picture_ptr || s->low_delay){
- *data_size = sizeof(AVFrame);
- ff_print_debug_info(s, pict);
+ *got_frame = 1;
}
- s->current_picture_ptr= NULL; //so we can detect if frame_end wasnt called (find some nicer solution...)
+ s->current_picture_ptr= NULL; // so we can detect if frame_end was not called (find some nicer solution...)
}
return avpkt->size;
AVCodec ff_rv10_decoder = {
.name = "rv10",
.type = AVMEDIA_TYPE_VIDEO,
- .id = CODEC_ID_RV10,
+ .id = AV_CODEC_ID_RV10,
.priv_data_size = sizeof(RVDecContext),
.init = rv10_decode_init,
.close = rv10_decode_end,
.decode = rv10_decode_frame,
.capabilities = CODEC_CAP_DR1,
- .max_lowres = 3,
.long_name = NULL_IF_CONFIG_SMALL("RealVideo 1.0"),
.pix_fmts = ff_pixfmt_list_420,
};
AVCodec ff_rv20_decoder = {
.name = "rv20",
.type = AVMEDIA_TYPE_VIDEO,
- .id = CODEC_ID_RV20,
+ .id = AV_CODEC_ID_RV20,
.priv_data_size = sizeof(RVDecContext),
.init = rv10_decode_init,
.close = rv10_decode_end,
.decode = rv10_decode_frame,
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY,
.flush = ff_mpeg_flush,
- .max_lowres = 3,
.long_name = NULL_IF_CONFIG_SMALL("RealVideo 2.0"),
.pix_fmts = ff_pixfmt_list_420,
};