}
}
-static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base)
+static int init_duplicate_context(MpegEncContext *s)
{
int y_size = s->b8_stride * (2 * s->mb_height + 1);
int c_size = s->mb_stride * (s->mb_height + 1);
}
for (i = 0; i < nb_slices; i++) {
- if (init_duplicate_context(s->thread_context[i], s) < 0)
+ if (init_duplicate_context(s->thread_context[i]) < 0)
goto fail;
s->thread_context[i]->start_mb_y =
(s->mb_height * (i) + nb_slices / 2) / nb_slices;
(s->mb_height * (i + 1) + nb_slices / 2) / nb_slices;
}
} else {
- if (init_duplicate_context(s, s) < 0)
+ if (init_duplicate_context(s) < 0)
goto fail;
s->start_mb_y = 0;
s->end_mb_y = s->mb_height;
}
for (i = 0; i < nb_slices; i++) {
- if (init_duplicate_context(s->thread_context[i], s) < 0)
+ if (init_duplicate_context(s->thread_context[i]) < 0)
goto fail;
s->thread_context[i]->start_mb_y =
(s->mb_height * (i) + nb_slices / 2) / nb_slices;
(s->mb_height * (i + 1) + nb_slices / 2) / nb_slices;
}
} else {
- if (init_duplicate_context(s, s) < 0)
+ if (init_duplicate_context(s) < 0)
goto fail;
s->start_mb_y = 0;
s->end_mb_y = s->mb_height;
s->last_picture_ptr->f.data[0] == NULL) &&
(s->pict_type != AV_PICTURE_TYPE_I ||
s->picture_structure != PICT_FRAME)) {
+ int h_chroma_shift, v_chroma_shift;
+ av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
+ &h_chroma_shift, &v_chroma_shift);
if (s->pict_type != AV_PICTURE_TYPE_I)
av_log(avctx, AV_LOG_ERROR,
"warning: first frame is no keyframe\n");
s->last_picture_ptr = NULL;
return -1;
}
+
+ memset(s->last_picture_ptr->f.data[0], 0,
+ avctx->height * s->last_picture_ptr->f.linesize[0]);
+ memset(s->last_picture_ptr->f.data[1], 0x80,
+ (avctx->height >> v_chroma_shift) *
+ s->last_picture_ptr->f.linesize[1]);
+ memset(s->last_picture_ptr->f.data[2], 0x80,
+ (avctx->height >> v_chroma_shift) *
+ s->last_picture_ptr->f.linesize[2]);
+
ff_thread_report_progress(&s->last_picture_ptr->f, INT_MAX, 0);
ff_thread_report_progress(&s->last_picture_ptr->f, INT_MAX, 1);
s->last_picture_ptr->f.reference = 3;
}
}
+/**
+ * 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;