comparison mpegvideo.c @ 1138:e10e841c9bf0 libavcodec

field pic decoding cleanup
author michaelni
date Sun, 16 Mar 2003 20:22:22 +0000
parents c8dfb8579606
children 6d6003cf89c2
comparison
equal deleted inserted replaced
1137:7fb0b38ab5a3 1138:e10e841c9bf0
856 AVFrame *pic; 856 AVFrame *pic;
857 857
858 s->mb_skiped = 0; 858 s->mb_skiped = 0;
859 859
860 /* mark&release old frames */ 860 /* mark&release old frames */
861 if (s->pict_type != B_TYPE && s->last_picture.data[0]) { 861 if (s->pict_type != B_TYPE && s->last_picture_ptr) {
862 for(i=0; i<MAX_PICTURE_COUNT; i++){ 862 avctx->release_buffer(avctx, (AVFrame*)s->last_picture_ptr);
863 //printf("%8X %d %d %X %X\n", s->picture[i].data[0], s->picture[i].type, i, s->next_picture.data[0], s->last_picture.data[0]);
864 if(s->picture[i].data[0] == s->last_picture.data[0]){
865 // s->picture[i].reference=0;
866 avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);
867 break;
868 }
869 }
870 assert(i<MAX_PICTURE_COUNT);
871 863
872 /* release forgotten pictures */ 864 /* release forgotten pictures */
873 /* if(mpeg124/h263) */ 865 /* if(mpeg124/h263) */
874 if(!s->encoding){ 866 if(!s->encoding){
875 for(i=0; i<MAX_PICTURE_COUNT; i++){ 867 for(i=0; i<MAX_PICTURE_COUNT; i++){
876 if(s->picture[i].data[0] && s->picture[i].data[0] != s->next_picture.data[0] && s->picture[i].reference){ 868 if(s->picture[i].data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].reference){
877 fprintf(stderr, "releasing zombie picture\n"); 869 fprintf(stderr, "releasing zombie picture\n");
878 avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]); 870 avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);
879 } 871 }
880 } 872 }
881 } 873 }
882 } 874 }
875
883 alloc: 876 alloc:
884 if(!s->encoding){ 877 if(!s->encoding){
885 i= find_unused_picture(s, 0); 878 i= find_unused_picture(s, 0);
886 879
887 pic= (AVFrame*)&s->picture[i]; 880 pic= (AVFrame*)&s->picture[i];
888 pic->reference= s->pict_type != B_TYPE; 881 pic->reference= s->pict_type != B_TYPE;
889 pic->coded_picture_number= s->current_picture.coded_picture_number+1; 882
883 if(s->current_picture_ptr)
884 pic->coded_picture_number= s->current_picture_ptr->coded_picture_number+1;
890 885
891 alloc_picture(s, (Picture*)pic, 0); 886 alloc_picture(s, (Picture*)pic, 0);
892 887
893 s->current_picture= s->picture[i]; 888 s->current_picture_ptr= &s->picture[i];
894 } 889 }
895 890
896 if (s->pict_type != B_TYPE) { 891 if (s->pict_type != B_TYPE) {
897 s->last_picture= s->next_picture; 892 s->last_picture_ptr= s->next_picture_ptr;
898 s->next_picture= s->current_picture; 893 s->next_picture_ptr= s->current_picture_ptr;
899 } 894 }
900 895 s->current_picture= *s->current_picture_ptr;
901 if(s->pict_type != I_TYPE && s->last_picture.data[0]==NULL){ 896 if(s->last_picture_ptr) s->last_picture= *s->last_picture_ptr;
897 if(s->next_picture_ptr) s->next_picture= *s->next_picture_ptr;
898 if(s->new_picture_ptr ) s->new_picture = *s->new_picture_ptr;
899
900 if(s->picture_structure!=PICT_FRAME){
901 int i;
902 for(i=0; i<4; i++){
903 if(s->picture_structure == PICT_BOTTOM_FIELD){
904 s->current_picture.data[i] += s->current_picture.linesize[i];
905 }
906 s->current_picture.linesize[i] *= 2;
907 s->last_picture.linesize[i] *=2;
908 s->next_picture.linesize[i] *=2;
909 }
910 }
911
912 if(s->pict_type != I_TYPE && s->last_picture_ptr==NULL){
902 fprintf(stderr, "warning: first frame is no keyframe\n"); 913 fprintf(stderr, "warning: first frame is no keyframe\n");
903 assert(s->pict_type != B_TYPE); //these should have been dropped if we dont have a reference 914 assert(s->pict_type != B_TYPE); //these should have been dropped if we dont have a reference
904 goto alloc; 915 goto alloc;
905 } 916 }
906 917
936 947
937 s->last_pict_type = s->pict_type; 948 s->last_pict_type = s->pict_type;
938 if(s->pict_type!=B_TYPE){ 949 if(s->pict_type!=B_TYPE){
939 s->last_non_b_pict_type= s->pict_type; 950 s->last_non_b_pict_type= s->pict_type;
940 } 951 }
941 952 #if 0
942 s->current_picture.quality= s->qscale; //FIXME get average of qscale_table 953 /* copy back current_picture variables */
943 s->current_picture.pict_type= s->pict_type;
944 s->current_picture.key_frame= s->pict_type == I_TYPE;
945
946 /* copy back current_picture variables */
947 for(i=0; i<MAX_PICTURE_COUNT; i++){ 954 for(i=0; i<MAX_PICTURE_COUNT; i++){
948 if(s->picture[i].data[0] == s->current_picture.data[0]){ 955 if(s->picture[i].data[0] == s->current_picture.data[0]){
949 s->picture[i]= s->current_picture; 956 s->picture[i]= s->current_picture;
950 break; 957 break;
951 } 958 }
952 } 959 }
953 assert(i<MAX_PICTURE_COUNT); 960 assert(i<MAX_PICTURE_COUNT);
961 #endif
962 s->current_picture_ptr->quality= s->qscale; //FIXME get average of qscale_table
963 s->current_picture_ptr->pict_type= s->pict_type;
964 s->current_picture_ptr->key_frame= s->pict_type == I_TYPE;
954 965
955 /* release non refernce frames */ 966 /* release non refernce frames */
956 for(i=0; i<MAX_PICTURE_COUNT; i++){ 967 for(i=0; i<MAX_PICTURE_COUNT; i++){
957 if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/) 968 if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/)
958 s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]); 969 s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]);
967 } 978 }
968 printf("\n"); 979 printf("\n");
969 } 980 }
970 printf("pict type: %d\n", s->pict_type); 981 printf("pict type: %d\n", s->pict_type);
971 } 982 }
983
984 // clear copies, to avoid confusion
985 #if 0
986 memset(&s->last_picture, 0, sizeof(Picture));
987 memset(&s->next_picture, 0, sizeof(Picture));
988 memset(&s->current_picture, 0, sizeof(Picture));
989 #endif
972 } 990 }
973 991
974 #ifdef CONFIG_ENCODERS 992 #ifdef CONFIG_ENCODERS
975 993
976 static int get_sae(uint8_t *src, int ref, int stride){ 994 static int get_sae(uint8_t *src, int ref, int stride){
1036 1054
1037 pic= (AVFrame*)&s->picture[i]; 1055 pic= (AVFrame*)&s->picture[i];
1038 pic->reference= 1; 1056 pic->reference= 1;
1039 1057
1040 alloc_picture(s, (Picture*)pic, 0); 1058 alloc_picture(s, (Picture*)pic, 0);
1059 for(i=0; i<4; i++){
1060 /* the input will be 16 pixels to the right relative to the actual buffer start
1061 * and the current_pic, so the buffer can be reused, yes its not beatifull
1062 */
1063 pic->data[i]+= 16;
1064 }
1041 1065
1042 if( pic->data[0] == pic_arg->data[0] 1066 if( pic->data[0] == pic_arg->data[0]
1043 && pic->data[1] == pic_arg->data[1] 1067 && pic->data[1] == pic_arg->data[1]
1044 && pic->data[2] == pic_arg->data[2]){ 1068 && pic->data[2] == pic_arg->data[2]){
1045 // empty 1069 // empty
1098 s->reordered_input_picture[i-1]= s->reordered_input_picture[i]; 1122 s->reordered_input_picture[i-1]= s->reordered_input_picture[i];
1099 s->reordered_input_picture[MAX_PICTURE_COUNT-1]= NULL; 1123 s->reordered_input_picture[MAX_PICTURE_COUNT-1]= NULL;
1100 1124
1101 /* set next picture types & ordering */ 1125 /* set next picture types & ordering */
1102 if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){ 1126 if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){
1103 if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture.data[0]==NULL || s->intra_only){ 1127 if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){
1104 s->reordered_input_picture[0]= s->input_picture[0]; 1128 s->reordered_input_picture[0]= s->input_picture[0];
1105 s->reordered_input_picture[0]->pict_type= I_TYPE; 1129 s->reordered_input_picture[0]->pict_type= I_TYPE;
1106 s->reordered_input_picture[0]->coded_picture_number= coded_pic_num; 1130 s->reordered_input_picture[0]->coded_picture_number= coded_pic_num;
1107 }else{ 1131 }else{
1108 int b_frames; 1132 int b_frames;
1172 } 1196 }
1173 } 1197 }
1174 } 1198 }
1175 1199
1176 if(s->reordered_input_picture[0]){ 1200 if(s->reordered_input_picture[0]){
1177 s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE; 1201 s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE;
1202
1203 s->new_picture= *s->reordered_input_picture[0];
1178 1204
1179 if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED){ 1205 if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED){
1206 // input is a shared pix, so we cant modifiy it -> alloc a new one & ensure that the shared one is reuseable
1207
1180 int i= find_unused_picture(s, 0); 1208 int i= find_unused_picture(s, 0);
1181 Picture *pic= &s->picture[i]; 1209 Picture *pic= &s->picture[i];
1182
1183 s->new_picture= *s->reordered_input_picture[0];
1184 1210
1185 /* mark us unused / free shared pic */ 1211 /* mark us unused / free shared pic */
1186 for(i=0; i<4; i++) 1212 for(i=0; i<4; i++)
1187 s->reordered_input_picture[0]->data[i]= NULL; 1213 s->reordered_input_picture[0]->data[i]= NULL;
1188 s->reordered_input_picture[0]->type= 0; 1214 s->reordered_input_picture[0]->type= 0;
1189 1215
1216 //FIXME bad, copy * except
1190 pic->pict_type = s->reordered_input_picture[0]->pict_type; 1217 pic->pict_type = s->reordered_input_picture[0]->pict_type;
1191 pic->quality = s->reordered_input_picture[0]->quality; 1218 pic->quality = s->reordered_input_picture[0]->quality;
1192 pic->coded_picture_number = s->reordered_input_picture[0]->coded_picture_number; 1219 pic->coded_picture_number = s->reordered_input_picture[0]->coded_picture_number;
1193 pic->reference = s->reordered_input_picture[0]->reference; 1220 pic->reference = s->reordered_input_picture[0]->reference;
1194 1221
1195 alloc_picture(s, pic, 0); 1222 alloc_picture(s, pic, 0);
1196 1223
1197 s->current_picture= *pic; 1224 s->current_picture_ptr= pic;
1198 }else{ 1225 }else{
1226 // input is not a shared pix -> reuse buffer for current_pix
1227
1199 assert( s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_USER 1228 assert( s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_USER
1200 || s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL); 1229 || s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL);
1201 1230
1202 s->new_picture= *s->reordered_input_picture[0]; 1231 s->current_picture_ptr= s->reordered_input_picture[0];
1203
1204 for(i=0; i<4; i++){ 1232 for(i=0; i<4; i++){
1205 s->reordered_input_picture[0]->data[i]-=16; //FIXME dirty 1233 //reverse the +16 we did before storing the input
1206 } 1234 s->current_picture_ptr->data[i]-=16;
1207 s->current_picture= *s->reordered_input_picture[0]; 1235 }
1208 } 1236 }
1237 s->current_picture= *s->current_picture_ptr;
1209 1238
1210 s->picture_number= s->new_picture.display_picture_number; 1239 s->picture_number= s->new_picture.display_picture_number;
1211 //printf("dpn:%d\n", s->picture_number); 1240 //printf("dpn:%d\n", s->picture_number);
1212 }else{ 1241 }else{
1213 memset(&s->new_picture, 0, sizeof(Picture)); 1242 memset(&s->new_picture, 0, sizeof(Picture));
1258 if (s->out_format == FMT_MJPEG) 1287 if (s->out_format == FMT_MJPEG)
1259 mjpeg_picture_trailer(s); 1288 mjpeg_picture_trailer(s);
1260 1289
1261 if(s->flags&CODEC_FLAG_PASS1) 1290 if(s->flags&CODEC_FLAG_PASS1)
1262 ff_write_pass1_stats(s); 1291 ff_write_pass1_stats(s);
1292
1293 for(i=0; i<4; i++){
1294 avctx->error[i] += s->current_picture_ptr->error[i];
1295 }
1263 } 1296 }
1264 1297
1265 s->input_picture_number++; 1298 s->input_picture_number++;
1266 1299
1267 flush_put_bits(&s->pb); 1300 flush_put_bits(&s->pb);
1268 s->frame_bits = (pbBufPtr(&s->pb) - s->pb.buf) * 8; 1301 s->frame_bits = (pbBufPtr(&s->pb) - s->pb.buf) * 8;
1269 1302
1270 s->total_bits += s->frame_bits; 1303 s->total_bits += s->frame_bits;
1271 avctx->frame_bits = s->frame_bits; 1304 avctx->frame_bits = s->frame_bits;
1272
1273 for(i=0; i<4; i++){
1274 avctx->error[i] += s->current_picture.error[i];
1275 }
1276 1305
1277 return pbBufPtr(&s->pb) - s->pb.buf; 1306 return pbBufPtr(&s->pb) - s->pb.buf;
1278 } 1307 }
1279 1308
1280 #endif //CONFIG_ENCODERS 1309 #endif //CONFIG_ENCODERS
1521 if (src_x == s->width) 1550 if (src_x == s->width)
1522 dxy &= ~1; 1551 dxy &= ~1;
1523 src_y = clip(src_y, -16, height); 1552 src_y = clip(src_y, -16, height);
1524 if (src_y == height) 1553 if (src_y == height)
1525 dxy &= ~2; 1554 dxy &= ~2;
1526 linesize = s->linesize << field_based; 1555 linesize = s->current_picture.linesize[0] << field_based;
1527 uvlinesize = s->uvlinesize << field_based; 1556 uvlinesize = s->current_picture.linesize[1] << field_based;
1528 ptr = ref_picture[0] + (src_y * linesize) + (src_x) + src_offset; 1557 ptr = ref_picture[0] + (src_y * linesize) + (src_x) + src_offset;
1529 dest_y += dest_offset; 1558 dest_y += dest_offset;
1530 1559
1531 if(s->flags&CODEC_FLAG_EMU_EDGE){ 1560 if(s->flags&CODEC_FLAG_EMU_EDGE){
1532 if(src_x<0 || src_y<0 || src_x + (motion_x&1) + 16 > s->h_edge_pos 1561 if(src_x<0 || src_y<0 || src_x + (motion_x&1) + 16 > s->h_edge_pos
1533 || src_y + (motion_y&1) + h > v_edge_pos){ 1562 || src_y + (motion_y&1) + h > v_edge_pos){
1534 ff_emulated_edge_mc(s, ptr - src_offset, s->linesize, 17, 17+field_based, 1563 ff_emulated_edge_mc(s, ptr - src_offset, s->linesize, 17, 17+field_based, //FIXME linesize? and uv below
1535 src_x, src_y<<field_based, s->h_edge_pos, s->v_edge_pos); 1564 src_x, src_y<<field_based, s->h_edge_pos, s->v_edge_pos);
1536 ptr= s->edge_emu_buffer + src_offset; 1565 ptr= s->edge_emu_buffer + src_offset;
1537 emu=1; 1566 emu=1;
1538 } 1567 }
1539 } 1568 }
1862 s->mv[dir][1][0], s->mv[dir][1][1], 8); 1891 s->mv[dir][1][0], s->mv[dir][1][1], 8);
1863 } 1892 }
1864 } else { 1893 } else {
1865 int offset; 1894 int offset;
1866 if(s->picture_structure == s->field_select[dir][0] + 1 || s->pict_type == B_TYPE || s->first_field){ 1895 if(s->picture_structure == s->field_select[dir][0] + 1 || s->pict_type == B_TYPE || s->first_field){
1867 offset= s->field_select[dir][0] ? s->linesize/2 : 0; 1896 offset= s->field_select[dir][0] ? s->linesize : 0;
1868 }else{ 1897 }else{
1869 ref_picture= s->current_picture.data; 1898 ref_picture= s->current_picture.data;
1870 offset= s->field_select[dir][0] ? s->linesize/2 : -s->linesize/2; 1899 offset= s->field_select[dir][0] ? s->linesize : -s->linesize;
1871 } 1900 }
1872 1901
1873 mpeg_motion(s, dest_y, dest_cb, dest_cr, 0, 1902 mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
1874 ref_picture, offset, 1903 ref_picture, offset,
1875 0, pix_op, 1904 0, pix_op,
2021 if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==B_TYPE))) { //FIXME precalc 2050 if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==B_TYPE))) { //FIXME precalc
2022 uint8_t *dest_y, *dest_cb, *dest_cr; 2051 uint8_t *dest_y, *dest_cb, *dest_cr;
2023 int dct_linesize, dct_offset; 2052 int dct_linesize, dct_offset;
2024 op_pixels_func (*op_pix)[4]; 2053 op_pixels_func (*op_pix)[4];
2025 qpel_mc_func (*op_qpix)[16]; 2054 qpel_mc_func (*op_qpix)[16];
2055 const int linesize= s->current_picture.linesize[0]; //not s->linesize as this woulnd be wrong for field pics
2056 const int uvlinesize= s->current_picture.linesize[1];
2026 2057
2027 /* avoid copy if macroblock skipped in last frame too */ 2058 /* avoid copy if macroblock skipped in last frame too */
2028 if (s->pict_type != B_TYPE) { 2059 if (s->pict_type != B_TYPE) {
2029 s->current_picture.mbskip_table[mb_xy]= s->mb_skiped; 2060 s->current_picture.mbskip_table[mb_xy]= s->mb_skiped;
2030 } 2061 }
2059 if(s->pict_type==B_TYPE && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME){ //FIXME precalc 2090 if(s->pict_type==B_TYPE && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME){ //FIXME precalc
2060 dest_y = s->current_picture.data[0] + mb_x * 16; 2091 dest_y = s->current_picture.data[0] + mb_x * 16;
2061 dest_cb = s->current_picture.data[1] + mb_x * 8; 2092 dest_cb = s->current_picture.data[1] + mb_x * 8;
2062 dest_cr = s->current_picture.data[2] + mb_x * 8; 2093 dest_cr = s->current_picture.data[2] + mb_x * 8;
2063 }else{ 2094 }else{
2064 dest_y = s->current_picture.data[0] + (mb_y * 16* s->linesize ) + mb_x * 16; 2095 dest_y = s->current_picture.data[0] + (mb_y * 16* linesize ) + mb_x * 16;
2065 dest_cb = s->current_picture.data[1] + (mb_y * 8 * s->uvlinesize) + mb_x * 8; 2096 dest_cb = s->current_picture.data[1] + (mb_y * 8 * uvlinesize) + mb_x * 8;
2066 dest_cr = s->current_picture.data[2] + (mb_y * 8 * s->uvlinesize) + mb_x * 8; 2097 dest_cr = s->current_picture.data[2] + (mb_y * 8 * uvlinesize) + mb_x * 8;
2067 } 2098 }
2068 2099
2069 if (s->interlaced_dct) { 2100 if (s->interlaced_dct) {
2070 dct_linesize = s->linesize * 2; 2101 dct_linesize = linesize * 2;
2071 dct_offset = s->linesize; 2102 dct_offset = linesize;
2072 } else { 2103 } else {
2073 dct_linesize = s->linesize; 2104 dct_linesize = linesize;
2074 dct_offset = s->linesize * 8; 2105 dct_offset = linesize * 8;
2075 } 2106 }
2076 2107
2077 if (!s->mb_intra) { 2108 if (!s->mb_intra) {
2078 /* motion handling */ 2109 /* motion handling */
2079 /* decoding or more than one mb_type (MC was allready done otherwise) */ 2110 /* decoding or more than one mb_type (MC was allready done otherwise) */
2106 add_dequant_dct(s, block[1], 1, dest_y + 8, dct_linesize); 2137 add_dequant_dct(s, block[1], 1, dest_y + 8, dct_linesize);
2107 add_dequant_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); 2138 add_dequant_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize);
2108 add_dequant_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); 2139 add_dequant_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);
2109 2140
2110 if(!(s->flags&CODEC_FLAG_GRAY)){ 2141 if(!(s->flags&CODEC_FLAG_GRAY)){
2111 add_dequant_dct(s, block[4], 4, dest_cb, s->uvlinesize); 2142 add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize);
2112 add_dequant_dct(s, block[5], 5, dest_cr, s->uvlinesize); 2143 add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize);
2113 } 2144 }
2114 } else if(s->codec_id != CODEC_ID_WMV2){ 2145 } else if(s->codec_id != CODEC_ID_WMV2){
2115 add_dct(s, block[0], 0, dest_y, dct_linesize); 2146 add_dct(s, block[0], 0, dest_y, dct_linesize);
2116 add_dct(s, block[1], 1, dest_y + 8, dct_linesize); 2147 add_dct(s, block[1], 1, dest_y + 8, dct_linesize);
2117 add_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); 2148 add_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize);
2118 add_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); 2149 add_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);
2119 2150
2120 if(!(s->flags&CODEC_FLAG_GRAY)){ 2151 if(!(s->flags&CODEC_FLAG_GRAY)){
2121 add_dct(s, block[4], 4, dest_cb, s->uvlinesize); 2152 add_dct(s, block[4], 4, dest_cb, uvlinesize);
2122 add_dct(s, block[5], 5, dest_cr, s->uvlinesize); 2153 add_dct(s, block[5], 5, dest_cr, uvlinesize);
2123 } 2154 }
2124 } 2155 }
2125 #ifdef CONFIG_RISKY 2156 #ifdef CONFIG_RISKY
2126 else{ 2157 else{
2127 ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr); 2158 ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);
2134 put_dct(s, block[1], 1, dest_y + 8, dct_linesize); 2165 put_dct(s, block[1], 1, dest_y + 8, dct_linesize);
2135 put_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); 2166 put_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize);
2136 put_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); 2167 put_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);
2137 2168
2138 if(!(s->flags&CODEC_FLAG_GRAY)){ 2169 if(!(s->flags&CODEC_FLAG_GRAY)){
2139 put_dct(s, block[4], 4, dest_cb, s->uvlinesize); 2170 put_dct(s, block[4], 4, dest_cb, uvlinesize);
2140 put_dct(s, block[5], 5, dest_cr, s->uvlinesize); 2171 put_dct(s, block[5], 5, dest_cr, uvlinesize);
2141 } 2172 }
2142 }else{ 2173 }else{
2143 s->dsp.idct_put(dest_y , dct_linesize, block[0]); 2174 s->dsp.idct_put(dest_y , dct_linesize, block[0]);
2144 s->dsp.idct_put(dest_y + 8, dct_linesize, block[1]); 2175 s->dsp.idct_put(dest_y + 8, dct_linesize, block[1]);
2145 s->dsp.idct_put(dest_y + dct_offset , dct_linesize, block[2]); 2176 s->dsp.idct_put(dest_y + dct_offset , dct_linesize, block[2]);
2146 s->dsp.idct_put(dest_y + dct_offset + 8, dct_linesize, block[3]); 2177 s->dsp.idct_put(dest_y + dct_offset + 8, dct_linesize, block[3]);
2147 2178
2148 if(!(s->flags&CODEC_FLAG_GRAY)){ 2179 if(!(s->flags&CODEC_FLAG_GRAY)){
2149 s->dsp.idct_put(dest_cb, s->uvlinesize, block[4]); 2180 s->dsp.idct_put(dest_cb, uvlinesize, block[4]);
2150 s->dsp.idct_put(dest_cr, s->uvlinesize, block[5]); 2181 s->dsp.idct_put(dest_cr, uvlinesize, block[5]);
2151 } 2182 }
2152 } 2183 }
2153 } 2184 }
2154 } 2185 }
2155 } 2186 }
2298 * 2329 *
2299 * @param h is the normal height, this will be reduced automatically if needed for the last row 2330 * @param h is the normal height, this will be reduced automatically if needed for the last row
2300 */ 2331 */
2301 void ff_draw_horiz_band(MpegEncContext *s, int y, int h){ 2332 void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
2302 if ( s->avctx->draw_horiz_band 2333 if ( s->avctx->draw_horiz_band
2303 && (s->last_picture.data[0] || s->low_delay) ) { 2334 && (s->last_picture_ptr || s->low_delay) ) {
2304 uint8_t *src_ptr[3]; 2335 uint8_t *src_ptr[3];
2305 int offset; 2336 int offset;
2306 h= FFMIN(h, s->height - y); 2337 h= FFMIN(h, s->height - y);
2307 2338
2308 if(s->pict_type==B_TYPE && s->picture_structure == PICT_FRAME) 2339 if(s->pict_type==B_TYPE && s->picture_structure == PICT_FRAME)