#include "libavutil/internal.h"
#include "libavutil/mem_internal.h"
#include "libavutil/thread.h"
+#include "libavutil/video_enc_params.h"
#include "avcodec.h"
#include "error_resilience.h"
if (!(r->cbp_chroma && r->cbp_luma && r->deblock_coefs &&
r->intra_types_hist && r->mb_type)) {
+ r->s.context_reinit = 1;
rv34_decoder_free(r);
return AVERROR(ENOMEM);
}
ff_h264_pred_init(&r->h, AV_CODEC_ID_RV40, 8, 1);
-#if CONFIG_RV30_DECODER
- if (avctx->codec_id == AV_CODEC_ID_RV30)
- ff_rv30dsp_init(&r->rdsp);
-#endif
-#if CONFIG_RV40_DECODER
- if (avctx->codec_id == AV_CODEC_ID_RV40)
- ff_rv40dsp_init(&r->rdsp);
-#endif
-
if ((ret = rv34_decoder_alloc(r)) < 0) {
ff_mpv_common_end(&r->s);
return ret;
if (dst == src || !s1->context_initialized)
return 0;
- if (s->height != s1->height || s->width != s1->width) {
+ if (s->height != s1->height || s->width != s1->width || s->context_reinit) {
s->height = s1->height;
s->width = s1->width;
if ((err = ff_mpv_common_frame_size_change(s)) < 0)
if (s->mb_num_left > 0 && s->current_picture_ptr) {
av_log(avctx, AV_LOG_ERROR, "New frame but still %d MB left.\n",
s->mb_num_left);
- ff_er_frame_end(&s->er);
+ if (!s->context_reinit)
+ ff_er_frame_end(&s->er);
ff_mpv_frame_end(s);
}
- if (s->width != si.width || s->height != si.height) {
+ if (s->width != si.width || s->height != si.height || s->context_reinit) {
int err;
av_log(s->avctx, AV_LOG_WARNING, "Changing dimensions to %dx%d\n",
err = ff_set_dimensions(s->avctx, s->width, s->height);
if (err < 0)
return err;
-
if ((err = ff_mpv_common_frame_size_change(s)) < 0)
return err;
if ((err = rv34_decoder_realloc(r)) < 0)
}
s->mb_x = s->mb_y = 0;
ff_thread_finish_setup(s->avctx);
+ } else if (s->context_reinit) {
+ av_log(s->avctx, AV_LOG_ERROR, "Decoder needs full frames to "
+ "reinitialize (start MB is %d).\n", si.start);
+ return AVERROR_INVALIDDATA;
} else if (HAVE_THREADS &&
(s->avctx->active_thread_type & FF_THREAD_FRAME)) {
av_log(s->avctx, AV_LOG_ERROR, "Decoder needs full frames in frame "