comparison mpegvideo.c @ 10894:4b2227257766 libavcodec

Support lowres 3 when decoding MPEG video. Patch by Anatoliy Nenashev, nenashev_as mail ru
author cehoyos
date Sat, 16 Jan 2010 10:41:52 +0000
parents a47f207fe4b5
children ea8f891d997d
comparison
equal deleted inserted replaced
10893:2aafcafbe1f0 10894:4b2227257766
1414 int h_edge_pos, int v_edge_pos, 1414 int h_edge_pos, int v_edge_pos,
1415 int w, int h, h264_chroma_mc_func *pix_op, 1415 int w, int h, h264_chroma_mc_func *pix_op,
1416 int motion_x, int motion_y) 1416 int motion_x, int motion_y)
1417 { 1417 {
1418 const int lowres= s->avctx->lowres; 1418 const int lowres= s->avctx->lowres;
1419 const int op_index= FFMIN(lowres, 2);
1419 const int s_mask= (2<<lowres)-1; 1420 const int s_mask= (2<<lowres)-1;
1420 int emu=0; 1421 int emu=0;
1421 int sx, sy; 1422 int sx, sy;
1422 1423
1423 if(s->quarter_sample){ 1424 if(s->quarter_sample){
1438 src_x, src_y<<field_based, h_edge_pos, v_edge_pos); 1439 src_x, src_y<<field_based, h_edge_pos, v_edge_pos);
1439 src= s->edge_emu_buffer; 1440 src= s->edge_emu_buffer;
1440 emu=1; 1441 emu=1;
1441 } 1442 }
1442 1443
1443 sx <<= 2 - lowres; 1444 sx= (sx << 2) >> lowres;
1444 sy <<= 2 - lowres; 1445 sy= (sy << 2) >> lowres;
1445 if(field_select) 1446 if(field_select)
1446 src += s->linesize; 1447 src += s->linesize;
1447 pix_op[lowres](dest, src, stride, h, sx, sy); 1448 pix_op[op_index](dest, src, stride, h, sx, sy);
1448 return emu; 1449 return emu;
1449 } 1450 }
1450 1451
1451 /* apply one mpeg motion vector to the three components */ 1452 /* apply one mpeg motion vector to the three components */
1452 static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, 1453 static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
1456 int motion_x, int motion_y, int h, int mb_y) 1457 int motion_x, int motion_y, int h, int mb_y)
1457 { 1458 {
1458 uint8_t *ptr_y, *ptr_cb, *ptr_cr; 1459 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
1459 int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, uvlinesize, linesize, sx, sy, uvsx, uvsy; 1460 int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, uvlinesize, linesize, sx, sy, uvsx, uvsy;
1460 const int lowres= s->avctx->lowres; 1461 const int lowres= s->avctx->lowres;
1462 const int op_index= FFMIN(lowres, 2);
1461 const int block_s= 8>>lowres; 1463 const int block_s= 8>>lowres;
1462 const int s_mask= (2<<lowres)-1; 1464 const int s_mask= (2<<lowres)-1;
1463 const int h_edge_pos = s->h_edge_pos >> lowres; 1465 const int h_edge_pos = s->h_edge_pos >> lowres;
1464 const int v_edge_pos = s->v_edge_pos >> lowres; 1466 const int v_edge_pos = s->v_edge_pos >> lowres;
1465 linesize = s->current_picture.linesize[0] << field_based; 1467 linesize = s->current_picture.linesize[0] << field_based;
1530 ptr_y += s->linesize; 1532 ptr_y += s->linesize;
1531 ptr_cb+= s->uvlinesize; 1533 ptr_cb+= s->uvlinesize;
1532 ptr_cr+= s->uvlinesize; 1534 ptr_cr+= s->uvlinesize;
1533 } 1535 }
1534 1536
1535 sx <<= 2 - lowres; 1537 sx= (sx << 2) >> lowres;
1536 sy <<= 2 - lowres; 1538 sy= (sy << 2) >> lowres;
1537 pix_op[lowres-1](dest_y, ptr_y, linesize, h, sx, sy); 1539 pix_op[lowres-1](dest_y, ptr_y, linesize, h, sx, sy);
1538 1540
1539 if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){ 1541 if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
1540 uvsx <<= 2 - lowres; 1542 uvsx= (uvsx << 2) >> lowres;
1541 uvsy <<= 2 - lowres; 1543 uvsy= (uvsy << 2) >> lowres;
1542 pix_op[lowres](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy); 1544 pix_op[op_index](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy);
1543 pix_op[lowres](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy); 1545 pix_op[op_index](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy);
1544 } 1546 }
1545 //FIXME h261 lowres loop filter 1547 //FIXME h261 lowres loop filter
1546 } 1548 }
1547 1549
1548 static inline void chroma_4mv_motion_lowres(MpegEncContext *s, 1550 static inline void chroma_4mv_motion_lowres(MpegEncContext *s,
1549 uint8_t *dest_cb, uint8_t *dest_cr, 1551 uint8_t *dest_cb, uint8_t *dest_cr,
1550 uint8_t **ref_picture, 1552 uint8_t **ref_picture,
1551 h264_chroma_mc_func *pix_op, 1553 h264_chroma_mc_func *pix_op,
1552 int mx, int my){ 1554 int mx, int my){
1553 const int lowres= s->avctx->lowres; 1555 const int lowres= s->avctx->lowres;
1556 const int op_index= FFMIN(lowres, 2);
1554 const int block_s= 8>>lowres; 1557 const int block_s= 8>>lowres;
1555 const int s_mask= (2<<lowres)-1; 1558 const int s_mask= (2<<lowres)-1;
1556 const int h_edge_pos = s->h_edge_pos >> (lowres+1); 1559 const int h_edge_pos = s->h_edge_pos >> (lowres+1);
1557 const int v_edge_pos = s->v_edge_pos >> (lowres+1); 1560 const int v_edge_pos = s->v_edge_pos >> (lowres+1);
1558 int emu=0, src_x, src_y, offset, sx, sy; 1561 int emu=0, src_x, src_y, offset, sx, sy;
1581 ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos); 1584 ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos);
1582 ptr= s->edge_emu_buffer; 1585 ptr= s->edge_emu_buffer;
1583 emu=1; 1586 emu=1;
1584 } 1587 }
1585 } 1588 }
1586 sx <<= 2 - lowres; 1589 sx= (sx << 2) >> lowres;
1587 sy <<= 2 - lowres; 1590 sy= (sy << 2) >> lowres;
1588 pix_op[lowres](dest_cb, ptr, s->uvlinesize, block_s, sx, sy); 1591 pix_op[op_index](dest_cb, ptr, s->uvlinesize, block_s, sx, sy);
1589 1592
1590 ptr = ref_picture[2] + offset; 1593 ptr = ref_picture[2] + offset;
1591 if(emu){ 1594 if(emu){
1592 ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos); 1595 ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos);
1593 ptr= s->edge_emu_buffer; 1596 ptr= s->edge_emu_buffer;
1594 } 1597 }
1595 pix_op[lowres](dest_cr, ptr, s->uvlinesize, block_s, sx, sy); 1598 pix_op[op_index](dest_cr, ptr, s->uvlinesize, block_s, sx, sy);
1596 } 1599 }
1597 1600
1598 /** 1601 /**
1599 * motion compensation of a single macroblock 1602 * motion compensation of a single macroblock
1600 * @param s context 1603 * @param s context