qmat16[qscale][0][i] == 128 * 256)
qmat16[qscale][0][i] = 128 * 256 - 1;
qmat16[qscale][1][i] =
- ROUNDED_DIV(bias << (16 - QUANT_BIAS_SHIFT),
+ ROUNDED_DIV(bias * (1<<(16 - QUANT_BIAS_SHIFT)),
qmat16[qscale][0][i]);
}
}
Picture *pic = NULL;
int64_t pts;
int i, display_picture_number = 0, ret;
- const int encoding_delay = s->max_b_frames ? s->max_b_frames :
- (s->low_delay ? 0 : 1);
+ int encoding_delay = s->max_b_frames ? s->max_b_frames :
+ (s->low_delay ? 0 : 1);
int direct = 1;
+ int shift = 1;
if (pic_arg) {
pts = pic_arg->pts;
pts = display_picture_number;
}
}
- }
- if (pic_arg) {
if (!pic_arg->buf[0] ||
pic_arg->linesize[0] != s->linesize ||
pic_arg->linesize[1] != s->uvlinesize ||
pic->f->display_picture_number = display_picture_number;
pic->f->pts = pts; // we set this here to avoid modifiying pic_arg
+ } else {
+ /* Flushing: When we have not received enough input frames,
+ * ensure s->input_picture[0] contains the first picture */
+ for (shift = 0; shift < encoding_delay + 1; shift++)
+ if (s->input_picture[shift]) break;
+ if (shift <= 1) shift = 1;
+ else encoding_delay = encoding_delay - shift + 1;
}
/* shift buffer entries */
- for (i = 1; i < MAX_PICTURE_COUNT /*s->encoding_delay + 1*/; i++)
- s->input_picture[i - 1] = s->input_picture[i];
+ for (i = shift; i < MAX_PICTURE_COUNT /*s->encoding_delay + 1*/; i++)
+ s->input_picture[i - shift] = s->input_picture[i];
s->input_picture[encoding_delay] = (Picture*) pic;
}
}
no_output_pic:
+ ff_mpeg_unref_picture(s->avctx, &s->new_picture);
+
if (s->reordered_input_picture[0]) {
s->reordered_input_picture[0]->reference =
s->reordered_input_picture[0]->f->pict_type !=
AV_PICTURE_TYPE_B ? 3 : 0;
- ff_mpeg_unref_picture(s->avctx, &s->new_picture);
if ((ret = ff_mpeg_ref_picture(s->avctx, &s->new_picture, s->reordered_input_picture[0])))
return ret;
return ret;
s->picture_number = s->new_picture.f->display_picture_number;
- } else {
- ff_mpeg_unref_picture(s->avctx, &s->new_picture);
}
return 0;
}
* permutation up, the block is not (inverse) permutated
* to scantable order!
*/
-static void block_permute(int16_t *block, uint8_t *permutation,
- const uint8_t *scantable, int last)
+void ff_block_permute(int16_t *block, uint8_t *permutation,
+ const uint8_t *scantable, int last)
{
int i;
int16_t temp[64];
/* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */
if (s->idsp.perm_type != FF_IDCT_PERM_NONE)
- block_permute(block, s->idsp.idct_permutation,
+ ff_block_permute(block, s->idsp.idct_permutation,
scantable, last_non_zero);
return last_non_zero;