#include "idctdsp.h"
#include "internal.h"
#include "mathops.h"
+#include "mpeg_er.h"
#include "mpegutils.h"
#include "mpegvideo.h"
#include "mpegvideodata.h"
}
}
-static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
- int (*mv)[2][4][2],
- int mb_x, int mb_y, int mb_intra, int mb_skipped)
-{
- MpegEncContext *s = opaque;
-
- s->mv_dir = mv_dir;
- s->mv_type = mv_type;
- s->mb_intra = mb_intra;
- s->mb_skipped = mb_skipped;
- s->mb_x = mb_x;
- s->mb_y = mb_y;
- memcpy(s->mv, mv, sizeof(*mv));
-
- ff_init_block_index(s);
- ff_update_block_index(s);
-
- s->bdsp.clear_blocks(s->block[0]);
-
- s->dest[0] = s->current_picture.f->data[0] + (s->mb_y * 16 * s->linesize) + s->mb_x * 16;
- s->dest[1] = s->current_picture.f->data[1] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift);
- s->dest[2] = s->current_picture.f->data[2] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift);
-
- if (ref)
- av_log(s->avctx, AV_LOG_DEBUG,
- "Interlaced error concealment is not fully implemented\n");
- ff_mpv_decode_mb(s, s->block);
-}
static void gray16(uint8_t *dst, const uint8_t *src, ptrdiff_t linesize, int h)
{
s->codec_tag = avpriv_toupper4(avctx->codec_tag);
}
-static int init_er(MpegEncContext *s)
-{
- ERContext *er = &s->er;
- int mb_array_size = s->mb_height * s->mb_stride;
- int i;
-
- er->avctx = s->avctx;
-
- er->mb_index2xy = s->mb_index2xy;
- er->mb_num = s->mb_num;
- er->mb_width = s->mb_width;
- er->mb_height = s->mb_height;
- er->mb_stride = s->mb_stride;
- er->b8_stride = s->b8_stride;
-
- er->er_temp_buffer = av_malloc(s->mb_height * s->mb_stride);
- er->error_status_table = av_mallocz(mb_array_size);
- if (!er->er_temp_buffer || !er->error_status_table)
- goto fail;
-
- er->mbskip_table = s->mbskip_table;
- er->mbintra_table = s->mbintra_table;
-
- for (i = 0; i < FF_ARRAY_ELEMS(s->dc_val); i++)
- er->dc_val[i] = s->dc_val[i];
-
- er->decode_mb = mpeg_er_decode_mb;
- er->opaque = s;
-
- return 0;
-fail:
- av_freep(&er->er_temp_buffer);
- av_freep(&er->error_status_table);
- return AVERROR(ENOMEM);
-}
-
/**
* Initialize and allocates MpegEncContext fields dependent on the resolution.
*/
FF_ALLOCZ_OR_GOTO(s->avctx, s->mbskip_table, mb_array_size + 2, fail);
// Note the + 1 is for a quicker mpeg4 slice_end detection
- return init_er(s);
+ return ff_mpeg_er_init(s);
fail:
return AVERROR(ENOMEM);
}
s->linesize = s->uvlinesize = 0;
}
-static void release_unused_pictures(AVCodecContext *avctx, Picture *picture)
-{
- int i;
-
- /* release non reference frames */
- for (i = 0; i < MAX_PICTURE_COUNT; i++) {
- if (!picture[i].reference)
- ff_mpeg_unref_picture(avctx, &picture[i]);
- }
-}
static void gray_frame(AVFrame *frame)
{
ff_mpeg_unref_picture(s->avctx, &s->current_picture);
- release_unused_pictures(s->avctx, s->picture);
+ /* release non reference frames */
+ for (i = 0; i < MAX_PICTURE_COUNT; i++) {
+ if (!s->picture[i].reference)
+ ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
+ }
if (s->current_picture_ptr && !s->current_picture_ptr->f->buf[0]) {
// we already have a unused image
/**
* find the lowest MB row referenced in the MVs
*/
-int ff_mpv_lowest_referenced_row(MpegEncContext *s, int dir)
+static int lowest_referenced_row(MpegEncContext *s, int dir)
{
int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->quarter_sample;
int my, off, i, mvs;
if(HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) {
if (s->mv_dir & MV_DIR_FORWARD) {
ff_thread_await_progress(&s->last_picture_ptr->tf,
- ff_mpv_lowest_referenced_row(s, 0),
+ lowest_referenced_row(s, 0),
0);
}
if (s->mv_dir & MV_DIR_BACKWARD) {
ff_thread_await_progress(&s->next_picture_ptr->tf,
- ff_mpv_lowest_referenced_row(s, 1),
+ lowest_referenced_row(s, 1),
0);
}
}
}
}
-/**
- * Permute an 8x8 block.
- * @param block the block which will be permuted according to the given permutation vector
- * @param permutation the permutation vector
- * @param last the last non zero coefficient in scantable order, used to speed the permutation up
- * @param scantable the used scantable, this is only used to speed the permutation up, the block is not
- * (inverse) permutated to scantable order!
- */
-void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last)
-{
- int i;
- int16_t temp[64];
-
- if(last<=0) return;
- //if(permutation[1]==1) return; //FIXME it is ok but not clean and might fail for some permutations
-
- for(i=0; i<=last; i++){
- const int j= scantable[i];
- temp[j]= block[j];
- block[j]=0;
- }
-
- for(i=0; i<=last; i++){
- const int j= scantable[i];
- const int perm_j= permutation[j];
- block[perm_j]= temp[j];
- }
-}
-
void ff_mpeg_flush(AVCodecContext *avctx){
int i;
MpegEncContext *s = avctx->priv_data;