mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
mpegvideo: split ff_draw_horiz_band().
Split out dependency on MpegEncContext.
This commit is contained in:
parent
54974c6298
commit
1d0feb5d1a
@ -147,6 +147,6 @@ end:
|
||||
}
|
||||
|
||||
if (!result)
|
||||
ff_draw_horiz_band(s, 0, s->avctx->height);
|
||||
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
|
||||
return result;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ static int decode_slice(MpegEncContext *s){
|
||||
|
||||
if(++s->mb_x >= s->mb_width){
|
||||
s->mb_x=0;
|
||||
ff_draw_horiz_band(s, s->mb_y*mb_size, mb_size);
|
||||
ff_mpeg_draw_horiz_band(s, s->mb_y*mb_size, mb_size);
|
||||
ff_MPV_report_decode_progress(s);
|
||||
s->mb_y++;
|
||||
}
|
||||
@ -256,7 +256,7 @@ static int decode_slice(MpegEncContext *s){
|
||||
ff_h263_loop_filter(s);
|
||||
}
|
||||
|
||||
ff_draw_horiz_band(s, s->mb_y*mb_size, mb_size);
|
||||
ff_mpeg_draw_horiz_band(s, s->mb_y*mb_size, mb_size);
|
||||
ff_MPV_report_decode_progress(s);
|
||||
|
||||
s->mb_x= 0;
|
||||
|
@ -3662,7 +3662,7 @@ static void decode_finish_row(H264Context *h)
|
||||
top = 0;
|
||||
}
|
||||
|
||||
ff_draw_horiz_band(s, top, height);
|
||||
ff_mpeg_draw_horiz_band(s, top, height);
|
||||
|
||||
if (s->droppable)
|
||||
return;
|
||||
|
@ -779,7 +779,7 @@ int ff_intrax8_decode_picture(IntraX8Context * const w, int dquant, int quant_of
|
||||
s->dest[0]+= 8;
|
||||
}
|
||||
if(s->mb_y&1){
|
||||
ff_draw_horiz_band(s, (s->mb_y-1)*8, 16);
|
||||
ff_mpeg_draw_horiz_band(s, (s->mb_y-1)*8, 16);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1762,7 +1762,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
|
||||
if (++s->mb_x >= s->mb_width) {
|
||||
const int mb_size = 16;
|
||||
|
||||
ff_draw_horiz_band(s, mb_size*(s->mb_y >> field_pic), mb_size);
|
||||
ff_mpeg_draw_horiz_band(s, mb_size*(s->mb_y >> field_pic), mb_size);
|
||||
ff_MPV_report_decode_progress(s);
|
||||
|
||||
s->mb_x = 0;
|
||||
|
@ -2459,73 +2459,91 @@ void ff_MPV_decode_mb(MpegEncContext *s, int16_t block[12][64]){
|
||||
/**
|
||||
* @param h is the normal height, this will be reduced automatically if needed for the last row
|
||||
*/
|
||||
void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
|
||||
const int field_pic= s->picture_structure != PICT_FRAME;
|
||||
void ff_draw_horiz_band(AVCodecContext *avctx, DSPContext *dsp, Picture *cur,
|
||||
Picture *last, int y, int h, int picture_structure,
|
||||
int first_field, int draw_edges, int low_delay,
|
||||
int v_edge_pos, int h_edge_pos)
|
||||
{
|
||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
|
||||
int hshift = desc->log2_chroma_w;
|
||||
int vshift = desc->log2_chroma_h;
|
||||
const int field_pic = picture_structure != PICT_FRAME;
|
||||
if(field_pic){
|
||||
h <<= 1;
|
||||
y <<= 1;
|
||||
}
|
||||
|
||||
if (!s->avctx->hwaccel
|
||||
&& !(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
|
||||
&& s->unrestricted_mv
|
||||
&& s->current_picture.f.reference
|
||||
&& !s->intra_only
|
||||
&& !(s->flags&CODEC_FLAG_EMU_EDGE)) {
|
||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
|
||||
if (!avctx->hwaccel &&
|
||||
!(avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) &&
|
||||
draw_edges &&
|
||||
cur->f.reference &&
|
||||
!(avctx->flags & CODEC_FLAG_EMU_EDGE)) {
|
||||
int *linesize = cur->f.linesize;
|
||||
int sides = 0, edge_h;
|
||||
int hshift = desc->log2_chroma_w;
|
||||
int vshift = desc->log2_chroma_h;
|
||||
if (y==0) sides |= EDGE_TOP;
|
||||
if (y + h >= s->v_edge_pos) sides |= EDGE_BOTTOM;
|
||||
if (y + h >= v_edge_pos)
|
||||
sides |= EDGE_BOTTOM;
|
||||
|
||||
edge_h= FFMIN(h, s->v_edge_pos - y);
|
||||
edge_h= FFMIN(h, v_edge_pos - y);
|
||||
|
||||
s->dsp.draw_edges(s->current_picture_ptr->f.data[0] + y *s->linesize,
|
||||
s->linesize, s->h_edge_pos, edge_h,
|
||||
dsp->draw_edges(cur->f.data[0] + y * linesize[0],
|
||||
linesize[0], h_edge_pos, edge_h,
|
||||
EDGE_WIDTH, EDGE_WIDTH, sides);
|
||||
s->dsp.draw_edges(s->current_picture_ptr->f.data[1] + (y>>vshift)*s->uvlinesize,
|
||||
s->uvlinesize, s->h_edge_pos>>hshift, edge_h>>vshift,
|
||||
dsp->draw_edges(cur->f.data[1] + (y >> vshift) * linesize[1],
|
||||
linesize[1], h_edge_pos >> hshift, edge_h >> vshift,
|
||||
EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift, sides);
|
||||
s->dsp.draw_edges(s->current_picture_ptr->f.data[2] + (y>>vshift)*s->uvlinesize,
|
||||
s->uvlinesize, s->h_edge_pos>>hshift, edge_h>>vshift,
|
||||
dsp->draw_edges(cur->f.data[2] + (y >> vshift) * linesize[2],
|
||||
linesize[2], h_edge_pos >> hshift, edge_h >> vshift,
|
||||
EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift, sides);
|
||||
}
|
||||
|
||||
h= FFMIN(h, s->avctx->height - y);
|
||||
h = FFMIN(h, avctx->height - y);
|
||||
|
||||
if(field_pic && s->first_field && !(s->avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return;
|
||||
if(field_pic && first_field && !(avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return;
|
||||
|
||||
if (s->avctx->draw_horiz_band) {
|
||||
if (avctx->draw_horiz_band) {
|
||||
AVFrame *src;
|
||||
int offset[AV_NUM_DATA_POINTERS];
|
||||
int i;
|
||||
|
||||
if(s->pict_type==AV_PICTURE_TYPE_B || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER))
|
||||
src = &s->current_picture_ptr->f;
|
||||
else if(s->last_picture_ptr)
|
||||
src = &s->last_picture_ptr->f;
|
||||
if(cur->f.pict_type == AV_PICTURE_TYPE_B || low_delay ||
|
||||
(avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
|
||||
src = &cur->f;
|
||||
else if (last)
|
||||
src = &last->f;
|
||||
else
|
||||
return;
|
||||
|
||||
if(s->pict_type==AV_PICTURE_TYPE_B && s->picture_structure == PICT_FRAME && s->out_format != FMT_H264){
|
||||
if (cur->f.pict_type == AV_PICTURE_TYPE_B &&
|
||||
picture_structure == PICT_FRAME &&
|
||||
avctx->codec_id != AV_CODEC_ID_H264 &&
|
||||
avctx->codec_id != AV_CODEC_ID_SVQ3) {
|
||||
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
|
||||
offset[i] = 0;
|
||||
}else{
|
||||
offset[0]= y * s->linesize;
|
||||
offset[0]= y * src->linesize[0];
|
||||
offset[1]=
|
||||
offset[2]= (y >> s->chroma_y_shift) * s->uvlinesize;
|
||||
offset[2]= (y >> vshift) * src->linesize[1];
|
||||
for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
|
||||
offset[i] = 0;
|
||||
}
|
||||
|
||||
emms_c();
|
||||
|
||||
s->avctx->draw_horiz_band(s->avctx, src, offset,
|
||||
y, s->picture_structure, h);
|
||||
avctx->draw_horiz_band(avctx, src, offset,
|
||||
y, picture_structure, h);
|
||||
}
|
||||
}
|
||||
|
||||
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
|
||||
{
|
||||
int draw_edges = s->unrestricted_mv && !s->intra_only;
|
||||
ff_draw_horiz_band(s->avctx, &s->dsp, &s->current_picture,
|
||||
&s->last_picture, y, h, s->picture_structure,
|
||||
s->first_field, draw_edges, s->low_delay,
|
||||
s->v_edge_pos, s->h_edge_pos);
|
||||
}
|
||||
|
||||
void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
|
||||
const int linesize = s->current_picture.f.linesize[0]; //not s->linesize as this would be wrong for field pics
|
||||
const int uvlinesize = s->current_picture.f.linesize[1];
|
||||
|
@ -760,7 +760,11 @@ void ff_MPV_common_init_arm(MpegEncContext *s);
|
||||
void ff_MPV_common_init_altivec(MpegEncContext *s);
|
||||
void ff_MPV_common_init_bfin(MpegEncContext *s);
|
||||
void ff_clean_intra_table_entries(MpegEncContext *s);
|
||||
void ff_draw_horiz_band(MpegEncContext *s, int y, int h);
|
||||
void ff_draw_horiz_band(AVCodecContext *avctx, DSPContext *dsp, Picture *cur,
|
||||
Picture *last, int y, int h, int picture_structure,
|
||||
int first_field, int draw_edges, int low_delay,
|
||||
int v_edge_pos, int h_edge_pos);
|
||||
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h);
|
||||
void ff_mpeg_flush(AVCodecContext *avctx);
|
||||
void ff_print_debug_info(MpegEncContext *s, AVFrame *pict);
|
||||
void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix);
|
||||
|
@ -145,7 +145,7 @@ void ff_xvmc_field_end(MpegEncContext *s)
|
||||
assert(render);
|
||||
|
||||
if (render->filled_mv_blocks_num > 0)
|
||||
ff_draw_horiz_band(s, 0, 0);
|
||||
ff_mpeg_draw_horiz_band(s, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -328,5 +328,5 @@ void ff_xvmc_decode_mb(MpegEncContext *s)
|
||||
|
||||
|
||||
if (render->filled_mv_blocks_num == render->allocated_mv_blocks)
|
||||
ff_draw_horiz_band(s, 0, 0);
|
||||
ff_mpeg_draw_horiz_band(s, 0, 0);
|
||||
}
|
||||
|
@ -1126,7 +1126,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
|
||||
(s->pict_type == AV_PICTURE_TYPE_P && mb_type < 8) ? (mb_type - 1) : -1;
|
||||
}
|
||||
|
||||
ff_draw_horiz_band(s, 16 * s->mb_y, 16);
|
||||
ff_mpeg_draw_horiz_band(s, 16 * s->mb_y, 16);
|
||||
}
|
||||
|
||||
ff_MPV_frame_end(s);
|
||||
|
@ -187,7 +187,7 @@ int ff_vaapi_common_end_frame(MpegEncContext *s)
|
||||
if (vactx->n_slice_buf_ids > 0) {
|
||||
if (render_picture(vactx, ff_vaapi_get_surface_id(s->current_picture_ptr)) < 0)
|
||||
goto done;
|
||||
ff_draw_horiz_band(s, 0, s->avctx->height);
|
||||
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
|
@ -4441,14 +4441,14 @@ static void vc1_decode_i_blocks(VC1Context *v)
|
||||
}
|
||||
}
|
||||
if (!v->s.loop_filter)
|
||||
ff_draw_horiz_band(s, s->mb_y * 16, 16);
|
||||
ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16);
|
||||
else if (s->mb_y)
|
||||
ff_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
|
||||
ff_mpeg_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
|
||||
|
||||
s->first_slice_line = 0;
|
||||
}
|
||||
if (v->s.loop_filter)
|
||||
ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
|
||||
ff_mpeg_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
|
||||
|
||||
/* This is intentionally mb_height and not end_mb_y - unlike in advanced
|
||||
* profile, these only differ are when decoding MSS2 rectangles. */
|
||||
@ -4569,9 +4569,9 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
|
||||
}
|
||||
}
|
||||
if (!v->s.loop_filter)
|
||||
ff_draw_horiz_band(s, s->mb_y * 16, 16);
|
||||
ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16);
|
||||
else if (s->mb_y)
|
||||
ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16);
|
||||
ff_mpeg_draw_horiz_band(s, (s->mb_y-1) * 16, 16);
|
||||
s->first_slice_line = 0;
|
||||
}
|
||||
|
||||
@ -4585,7 +4585,7 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
|
||||
vc1_loop_filter_iblk_delayed(v, v->pq);
|
||||
}
|
||||
if (v->s.loop_filter)
|
||||
ff_draw_horiz_band(s, (s->end_mb_y-1)*16, 16);
|
||||
ff_mpeg_draw_horiz_band(s, (s->end_mb_y-1)*16, 16);
|
||||
ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
|
||||
(s->end_mb_y << v->field_mode) - 1, ER_MB_END);
|
||||
}
|
||||
@ -4648,7 +4648,7 @@ static void vc1_decode_p_blocks(VC1Context *v)
|
||||
memmove(v->ttblk_base, v->ttblk, sizeof(v->ttblk_base[0]) * s->mb_stride);
|
||||
memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0]) * s->mb_stride);
|
||||
memmove(v->luma_mv_base, v->luma_mv, sizeof(v->luma_mv_base[0]) * s->mb_stride);
|
||||
if (s->mb_y != s->start_mb_y) ff_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
|
||||
if (s->mb_y != s->start_mb_y) ff_mpeg_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
|
||||
s->first_slice_line = 0;
|
||||
}
|
||||
if (apply_loop_filter) {
|
||||
@ -4660,7 +4660,7 @@ static void vc1_decode_p_blocks(VC1Context *v)
|
||||
}
|
||||
}
|
||||
if (s->end_mb_y >= s->start_mb_y)
|
||||
ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
|
||||
ff_mpeg_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
|
||||
ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
|
||||
(s->end_mb_y << v->field_mode) - 1, ER_MB_END);
|
||||
}
|
||||
@ -4715,13 +4715,13 @@ static void vc1_decode_b_blocks(VC1Context *v)
|
||||
if (v->s.loop_filter) vc1_loop_filter_iblk(v, v->pq);
|
||||
}
|
||||
if (!v->s.loop_filter)
|
||||
ff_draw_horiz_band(s, s->mb_y * 16, 16);
|
||||
ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16);
|
||||
else if (s->mb_y)
|
||||
ff_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
|
||||
ff_mpeg_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
|
||||
s->first_slice_line = 0;
|
||||
}
|
||||
if (v->s.loop_filter)
|
||||
ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
|
||||
ff_mpeg_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
|
||||
ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
|
||||
(s->end_mb_y << v->field_mode) - 1, ER_MB_END);
|
||||
}
|
||||
@ -4739,7 +4739,7 @@ static void vc1_decode_skip_blocks(VC1Context *v)
|
||||
memcpy(s->dest[0], s->last_picture.f.data[0] + s->mb_y * 16 * s->linesize, s->linesize * 16);
|
||||
memcpy(s->dest[1], s->last_picture.f.data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8);
|
||||
memcpy(s->dest[2], s->last_picture.f.data[2] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8);
|
||||
ff_draw_horiz_band(s, s->mb_y * 16, 16);
|
||||
ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16);
|
||||
s->first_slice_line = 0;
|
||||
}
|
||||
s->pict_type = AV_PICTURE_TYPE_P;
|
||||
|
@ -59,7 +59,7 @@ int ff_vdpau_common_end_frame(AVCodecContext *avctx)
|
||||
hwctx->render(hwctx->decoder, surf, (void *)&hwctx->info,
|
||||
hwctx->bitstream_buffers_used, hwctx->bitstream_buffers);
|
||||
|
||||
ff_draw_horiz_band(s, 0, s->avctx->height);
|
||||
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
|
||||
hwctx->bitstream_buffers_used = 0;
|
||||
}
|
||||
return 0;
|
||||
@ -235,7 +235,7 @@ void ff_vdpau_h264_picture_complete(MpegEncContext *s)
|
||||
memcpy(render->info.h264.scaling_lists_8x8[0], h->pps.scaling_matrix8[0], sizeof(render->info.h264.scaling_lists_8x8[0]));
|
||||
memcpy(render->info.h264.scaling_lists_8x8[1], h->pps.scaling_matrix8[3], sizeof(render->info.h264.scaling_lists_8x8[0]));
|
||||
|
||||
ff_draw_horiz_band(s, 0, s->avctx->height);
|
||||
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
|
||||
render->bitstream_buffers_used = 0;
|
||||
}
|
||||
|
||||
@ -292,7 +292,7 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
|
||||
render->info.mpeg.slice_count = slice_count;
|
||||
|
||||
if (slice_count)
|
||||
ff_draw_horiz_band(s, 0, s->avctx->height);
|
||||
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
|
||||
render->bitstream_buffers_used = 0;
|
||||
}
|
||||
|
||||
@ -361,7 +361,7 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
|
||||
|
||||
render->info.vc1.slice_count = 1;
|
||||
|
||||
ff_draw_horiz_band(s, 0, s->avctx->height);
|
||||
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
|
||||
render->bitstream_buffers_used = 0;
|
||||
}
|
||||
|
||||
@ -415,7 +415,7 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
|
||||
|
||||
ff_vdpau_add_data_chunk(s, buf, buf_size);
|
||||
|
||||
ff_draw_horiz_band(s, 0, s->avctx->height);
|
||||
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
|
||||
render->bitstream_buffers_used = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user