mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-19 05:49:09 +02:00
Merge commit 'b1268e0f032a3af3912fe3fb8d3855e12d7ea83b'
* commit 'b1268e0f032a3af3912fe3fb8d3855e12d7ea83b': intrax8: Pass macroblock coordinates to ff_intrax8_decode_picture Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
commit
123fef54cc
@ -380,9 +380,7 @@ static int x8_setup_spatial_predictor(IntraX8Context *const w, const int chroma)
|
|||||||
static void x8_update_predictions(IntraX8Context *const w, const int orient,
|
static void x8_update_predictions(IntraX8Context *const w, const int orient,
|
||||||
const int est_run)
|
const int est_run)
|
||||||
{
|
{
|
||||||
MpegEncContext *const s = w->s;
|
w->prediction_table[w->mb_x * 2 + (w->mb_y & 1)] = (est_run << 2) + 1 * (orient == 4) + 2 * (orient == 8);
|
||||||
|
|
||||||
w->prediction_table[s->mb_x * 2 + (s->mb_y & 1)] = (est_run << 2) + 1 * (orient == 4) + 2 * (orient == 8);
|
|
||||||
/*
|
/*
|
||||||
* y = 2n + 0 -> // 0 2 4
|
* y = 2n + 0 -> // 0 2 4
|
||||||
* y = 2n + 1 -> // 1 3 5
|
* y = 2n + 1 -> // 1 3 5
|
||||||
@ -391,11 +389,9 @@ static void x8_update_predictions(IntraX8Context *const w, const int orient,
|
|||||||
|
|
||||||
static void x8_get_prediction_chroma(IntraX8Context *const w)
|
static void x8_get_prediction_chroma(IntraX8Context *const w)
|
||||||
{
|
{
|
||||||
MpegEncContext *const s = w->s;
|
w->edges = 1 * (!(w->mb_x >> 1));
|
||||||
|
w->edges |= 2 * (!(w->mb_y >> 1));
|
||||||
w->edges = 1 * (!(s->mb_x >> 1));
|
w->edges |= 4 * (w->mb_x >= (2 * w->mb_width - 1)); // mb_x for chroma would always be odd
|
||||||
w->edges |= 2 * (!(s->mb_y >> 1));
|
|
||||||
w->edges |= 4 * (s->mb_x >= (2 * w->mb_width - 1)); // mb_x for chroma would always be odd
|
|
||||||
|
|
||||||
w->raw_orient = 0;
|
w->raw_orient = 0;
|
||||||
// lut_co[8] = {inv,4,8,8, inv,4,8,8} <- => {1,1,0,0;1,1,0,0} => 0xCC
|
// lut_co[8] = {inv,4,8,8, inv,4,8,8} <- => {1,1,0,0;1,1,0,0} => 0xCC
|
||||||
@ -404,29 +400,28 @@ static void x8_get_prediction_chroma(IntraX8Context *const w)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// block[x - 1][y | 1 - 1)]
|
// block[x - 1][y | 1 - 1)]
|
||||||
w->chroma_orient = (w->prediction_table[2 * s->mb_x - 2] & 0x03) << 2;
|
w->chroma_orient = (w->prediction_table[2 * w->mb_x - 2] & 0x03) << 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void x8_get_prediction(IntraX8Context *const w)
|
static void x8_get_prediction(IntraX8Context *const w)
|
||||||
{
|
{
|
||||||
MpegEncContext *const s = w->s;
|
|
||||||
int a, b, c, i;
|
int a, b, c, i;
|
||||||
|
|
||||||
w->edges = 1 * (!s->mb_x);
|
w->edges = 1 * (!w->mb_x);
|
||||||
w->edges |= 2 * (!s->mb_y);
|
w->edges |= 2 * (!w->mb_y);
|
||||||
w->edges |= 4 * (s->mb_x >= (2 * w->mb_width - 1));
|
w->edges |= 4 * (w->mb_x >= (2 * w->mb_width - 1));
|
||||||
|
|
||||||
switch (w->edges & 3) {
|
switch (w->edges & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// take the one from the above block[0][y - 1]
|
// take the one from the above block[0][y - 1]
|
||||||
w->est_run = w->prediction_table[!(s->mb_y & 1)] >> 2;
|
w->est_run = w->prediction_table[!(w->mb_y & 1)] >> 2;
|
||||||
w->orient = 1;
|
w->orient = 1;
|
||||||
return;
|
return;
|
||||||
case 2:
|
case 2:
|
||||||
// take the one from the previous block[x - 1][0]
|
// take the one from the previous block[x - 1][0]
|
||||||
w->est_run = w->prediction_table[2 * s->mb_x - 2] >> 2;
|
w->est_run = w->prediction_table[2 * w->mb_x - 2] >> 2;
|
||||||
w->orient = 2;
|
w->orient = 2;
|
||||||
return;
|
return;
|
||||||
case 3:
|
case 3:
|
||||||
@ -435,15 +430,15 @@ static void x8_get_prediction(IntraX8Context *const w)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// no edge cases
|
// no edge cases
|
||||||
b = w->prediction_table[2 * s->mb_x + !(s->mb_y & 1)]; // block[x ][y - 1]
|
b = w->prediction_table[2 * w->mb_x + !(w->mb_y & 1)]; // block[x ][y - 1]
|
||||||
a = w->prediction_table[2 * s->mb_x - 2 + (s->mb_y & 1)]; // block[x - 1][y ]
|
a = w->prediction_table[2 * w->mb_x - 2 + (w->mb_y & 1)]; // block[x - 1][y ]
|
||||||
c = w->prediction_table[2 * s->mb_x - 2 + !(s->mb_y & 1)]; // block[x - 1][y - 1]
|
c = w->prediction_table[2 * w->mb_x - 2 + !(w->mb_y & 1)]; // block[x - 1][y - 1]
|
||||||
|
|
||||||
w->est_run = FFMIN(b, a);
|
w->est_run = FFMIN(b, a);
|
||||||
/* This condition has nothing to do with w->edges, even if it looks
|
/* This condition has nothing to do with w->edges, even if it looks
|
||||||
* similar it would trigger if e.g. x = 3; y = 2;
|
* similar it would trigger if e.g. x = 3; y = 2;
|
||||||
* I guess somebody wrote something wrong and it became standard. */
|
* I guess somebody wrote something wrong and it became standard. */
|
||||||
if ((s->mb_x & s->mb_y) != 0)
|
if ((w->mb_x & w->mb_y) != 0)
|
||||||
w->est_run = FFMIN(c, w->est_run);
|
w->est_run = FFMIN(c, w->est_run);
|
||||||
w->est_run >>= 2;
|
w->est_run >>= 2;
|
||||||
|
|
||||||
@ -716,7 +711,7 @@ block_placed:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME maybe merge with ff_*
|
// FIXME maybe merge with ff_*
|
||||||
static void x8_init_block_index(IntraX8Context *w, AVFrame *frame, int mb_y)
|
static void x8_init_block_index(IntraX8Context *w, AVFrame *frame)
|
||||||
{
|
{
|
||||||
// not parent codec linesize as this would be wrong for field pics
|
// not parent codec linesize as this would be wrong for field pics
|
||||||
// not that IntraX8 has interlacing support ;)
|
// not that IntraX8 has interlacing support ;)
|
||||||
@ -727,10 +722,10 @@ static void x8_init_block_index(IntraX8Context *w, AVFrame *frame, int mb_y)
|
|||||||
w->dest[1] = frame->data[1];
|
w->dest[1] = frame->data[1];
|
||||||
w->dest[2] = frame->data[2];
|
w->dest[2] = frame->data[2];
|
||||||
|
|
||||||
w->dest[0] += mb_y * linesize << 3;
|
w->dest[0] += w->mb_y * linesize << 3;
|
||||||
// chroma blocks are on add rows
|
// chroma blocks are on add rows
|
||||||
w->dest[1] += (mb_y & (~1)) * uvlinesize << 2;
|
w->dest[1] += (w->mb_y & (~1)) * uvlinesize << 2;
|
||||||
w->dest[2] += (mb_y & (~1)) * uvlinesize << 2;
|
w->dest[2] += (w->mb_y & (~1)) * uvlinesize << 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
|
av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
|
||||||
@ -744,8 +739,6 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
|
|||||||
|
|
||||||
w->avctx = avctx;
|
w->avctx = avctx;
|
||||||
w->idsp = *idsp;
|
w->idsp = *idsp;
|
||||||
s->mb_x = 0;
|
|
||||||
s->mb_y = 0;
|
|
||||||
w->mb_width = mb_width;
|
w->mb_width = mb_width;
|
||||||
w->mb_height = mb_height;
|
w->mb_height = mb_height;
|
||||||
w->s = s;
|
w->s = s;
|
||||||
@ -779,7 +772,7 @@ av_cold void ff_intrax8_common_end(IntraX8Context *w)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ff_intrax8_decode_picture(IntraX8Context *const w, Picture *pict,
|
int ff_intrax8_decode_picture(IntraX8Context *const w, Picture *pict,
|
||||||
GetBitContext *gb,
|
GetBitContext *gb, int *mb_x, int *mb_y,
|
||||||
int dquant, int quant_offset, int loopfilter)
|
int dquant, int quant_offset, int loopfilter)
|
||||||
{
|
{
|
||||||
MpegEncContext *const s = w->s;
|
MpegEncContext *const s = w->s;
|
||||||
@ -793,6 +786,9 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, Picture *pict,
|
|||||||
w->loopfilter = loopfilter;
|
w->loopfilter = loopfilter;
|
||||||
w->use_quant_matrix = get_bits1(w->gb);
|
w->use_quant_matrix = get_bits1(w->gb);
|
||||||
|
|
||||||
|
w->mb_x = *mb_x;
|
||||||
|
w->mb_y = *mb_y;
|
||||||
|
|
||||||
w->divide_quant_dc_luma = ((1 << 16) + (w->quant >> 1)) / w->quant;
|
w->divide_quant_dc_luma = ((1 << 16) + (w->quant >> 1)) / w->quant;
|
||||||
if (w->quant < 5) {
|
if (w->quant < 5) {
|
||||||
w->quant_dc_chroma = w->quant;
|
w->quant_dc_chroma = w->quant;
|
||||||
@ -803,17 +799,17 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, Picture *pict,
|
|||||||
}
|
}
|
||||||
x8_reset_vlc_tables(w);
|
x8_reset_vlc_tables(w);
|
||||||
|
|
||||||
for (s->mb_y = 0; s->mb_y < w->mb_height * 2; s->mb_y++) {
|
for (w->mb_y = 0; w->mb_y < w->mb_height * 2; w->mb_y++) {
|
||||||
x8_init_block_index(w, w->frame, s->mb_y);
|
x8_init_block_index(w, w->frame);
|
||||||
mb_xy = (s->mb_y >> 1) * (w->mb_width + 1);
|
mb_xy = (w->mb_y >> 1) * (w->mb_width + 1);
|
||||||
for (s->mb_x = 0; s->mb_x < w->mb_width * 2; s->mb_x++) {
|
for (w->mb_x = 0; w->mb_x < w->mb_width * 2; w->mb_x++) {
|
||||||
x8_get_prediction(w);
|
x8_get_prediction(w);
|
||||||
if (x8_setup_spatial_predictor(w, 0))
|
if (x8_setup_spatial_predictor(w, 0))
|
||||||
goto error;
|
goto error;
|
||||||
if (x8_decode_intra_mb(w, 0))
|
if (x8_decode_intra_mb(w, 0))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (s->mb_x & s->mb_y & 1) {
|
if (w->mb_x & w->mb_y & 1) {
|
||||||
x8_get_prediction_chroma(w);
|
x8_get_prediction_chroma(w);
|
||||||
|
|
||||||
/* when setting up chroma, no vlc is read,
|
/* when setting up chroma, no vlc is read,
|
||||||
@ -837,10 +833,13 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, Picture *pict,
|
|||||||
}
|
}
|
||||||
w->dest[0] += 8;
|
w->dest[0] += 8;
|
||||||
}
|
}
|
||||||
if (s->mb_y & 1)
|
if (w->mb_y & 1)
|
||||||
ff_mpeg_draw_horiz_band(s, (s->mb_y - 1) * 8, 16);
|
ff_mpeg_draw_horiz_band(s, (w->mb_y - 1) * 8, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
*mb_x = w->mb_x;
|
||||||
|
*mb_y = w->mb_y;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -105,12 +105,14 @@ void ff_intrax8_common_end(IntraX8Context *w);
|
|||||||
* @param w pointer to IntraX8Context
|
* @param w pointer to IntraX8Context
|
||||||
* @param pict the output Picture containing an AVFrame
|
* @param pict the output Picture containing an AVFrame
|
||||||
* @param gb open bitstream reader
|
* @param gb open bitstream reader
|
||||||
|
* @param mb_x pointer to the x coordinate of the current macroblock
|
||||||
|
* @param mb_y pointer to the y coordinate of the current macroblock
|
||||||
* @param dquant doubled quantizer, it would be odd in case of VC-1 halfpq==1.
|
* @param dquant doubled quantizer, it would be odd in case of VC-1 halfpq==1.
|
||||||
* @param quant_offset offset away from zero
|
* @param quant_offset offset away from zero
|
||||||
* @param loopfilter enable filter after decoding a block
|
* @param loopfilter enable filter after decoding a block
|
||||||
*/
|
*/
|
||||||
int ff_intrax8_decode_picture(IntraX8Context *w, Picture *pict,
|
int ff_intrax8_decode_picture(IntraX8Context *w, Picture *pict,
|
||||||
GetBitContext *gb,
|
GetBitContext *gb, int *mb_x, int *mb_y,
|
||||||
int quant, int halfpq, int loopfilter);
|
int quant, int halfpq, int loopfilter);
|
||||||
|
|
||||||
#endif /* AVCODEC_INTRAX8_H */
|
#endif /* AVCODEC_INTRAX8_H */
|
||||||
|
@ -2931,7 +2931,8 @@ void ff_vc1_decode_blocks(VC1Context *v)
|
|||||||
|
|
||||||
v->s.esc3_level_length = 0;
|
v->s.esc3_level_length = 0;
|
||||||
if (v->x8_type) {
|
if (v->x8_type) {
|
||||||
ff_intrax8_decode_picture(&v->x8, &v->s.current_picture, &v->s.gb,
|
ff_intrax8_decode_picture(&v->x8, &v->s.current_picture,
|
||||||
|
&v->s.gb, &v->s.mb_x, &v->s.mb_y,
|
||||||
2 * v->pq + v->halfpq, v->pq * !v->pquantizer,
|
2 * v->pq + v->halfpq, v->pq * !v->pquantizer,
|
||||||
v->s.loop_filter);
|
v->s.loop_filter);
|
||||||
|
|
||||||
|
@ -219,7 +219,8 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s)
|
|||||||
s->picture_number++; // FIXME ?
|
s->picture_number++; // FIXME ?
|
||||||
|
|
||||||
if (w->j_type) {
|
if (w->j_type) {
|
||||||
ff_intrax8_decode_picture(&w->x8, &s->current_picture, &s->gb,
|
ff_intrax8_decode_picture(&w->x8, &s->current_picture,
|
||||||
|
&s->gb, &s->mb_x, &s->mb_y,
|
||||||
2 * s->qscale, (s->qscale - 1) | 1,
|
2 * s->qscale, (s->qscale - 1) | 1,
|
||||||
s->loop_filter);
|
s->loop_filter);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user