summaryrefslogtreecommitdiff
path: root/libavcodec/mpegvideo.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r--libavcodec/mpegvideo.c86
1 files changed, 52 insertions, 34 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 4396ec2df9..08d4cbbf8f 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -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,
- 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,
- 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,
- EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides);
+ dsp->draw_edges(cur->f.data[0] + y * linesize[0],
+ linesize[0], h_edge_pos, edge_h,
+ EDGE_WIDTH, EDGE_WIDTH, sides);
+ 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);
+ 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];